DD4hep  1.38.0
Detector Description Toolkit for High Energy Physics
Memory.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 
14 #ifndef DD4HEP_MEMORY_H
15 #define DD4HEP_MEMORY_H
16 
17 // Framework include files
18 #ifdef __has_include
19 #if __has_include(<ROOT/RVersion.hxx>)
20 #include <ROOT/RVersion.hxx>
21 #else
22 #include <RVersion.h>
23 #endif
24 #else
25 #include <RVersion.h>
26 #endif
27 
28 #ifdef __GNUC__
29 #pragma GCC diagnostic push
30 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" // Code that causes warning goes here
31 #elif defined(__llvm__) || defined(__APPLE__)
32 #pragma clang diagnostic push
33 #pragma clang diagnostic ignored "-Wdeprecated-declarations" // Code that causes warning goes here
34 #endif
35 
36 
37 // C/C++ include files
38 #include <memory>
39 
40 
42 namespace dd4hep {
43 
45 
53  template <typename T> class dd4hep_ptr
54  : public std::unique_ptr<T> {
55  public:
56  typedef std::unique_ptr<T> base_t;
57  public:
59  dd4hep_ptr() : base_t() {}
61  dd4hep_ptr(T* p) : base_t(p) {}
63  dd4hep_ptr(base_t& c) : base_t(c) {}
66  if ( this != &c ) {
67  this->swap(c);
68  }
69  return *this;
70  }
72  dd4hep_ptr& adopt(T* ptr) {
73  base_t smart_ptr(ptr);
74  this->swap(smart_ptr);
75  return *this;
76  }
77  };
78  }
79 
80 #ifdef __GNUC__
81 #pragma GCC diagnostic pop
82 #elif defined(__llvm__) || defined(__APPLE__)
83 #pragma clang diagnostic pop
84 #endif
85 
86 #endif // DD4HEP_MEMORY_H
dd4hep::dd4hep_ptr::dd4hep_ptr
dd4hep_ptr(base_t &c)
Constructor from copy.
Definition: Memory.h:63
dd4hep::dd4hep_ptr::dd4hep_ptr
dd4hep_ptr(T *p)
Constructor from pointer.
Definition: Memory.h:61
dd4hep::dd4hep_ptr::adopt
dd4hep_ptr & adopt(T *ptr)
Assignment operator.
Definition: Memory.h:72
dd4hep::dd4hep_ptr::operator=
dd4hep_ptr & operator=(base_t &c)
Assignment operator.
Definition: Memory.h:65
dd4hep::dd4hep_ptr::base_t
std::unique_ptr< T > base_t
Definition: Memory.h:56
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::dd4hep_ptr::dd4hep_ptr
dd4hep_ptr()
Default Constructor.
Definition: Memory.h:59
dd4hep::dd4hep_ptr
Out version of the std auto_ptr implementation base either on auto_ptr or unique_ptr.
Definition: Memory.h:54