CMS 3D CMS Logo

clone_ptr.h
Go to the documentation of this file.
1 #ifndef FWCore_Utilities_clone_ptr_h
2 #define FWCore_Utilities_clone_ptr_h
3 
4 #include <memory>
5 
6 namespace extstd {
7 
8  /* modify unique_ptr behaviour adding a "cloning" copy-constructor and assignment-operator
9  */
10  template <typename T>
11  struct clone_ptr : public std::unique_ptr<T> {
12  template <typename... Args>
13  explicit clone_ptr(Args&&... args) noexcept : std::unique_ptr<T>(std::forward<Args>(args)...) {}
14 
15  clone_ptr(clone_ptr const& rh) : std::unique_ptr<T>(rh ? rh->clone() : nullptr) {}
16  clone_ptr(clone_ptr&& rh) noexcept : std::unique_ptr<T>(std::move(rh)) {}
17 
19  if (&rh != this)
20  this->reset(rh ? rh->clone() : nullptr);
21  return *this;
22  }
23  clone_ptr& operator=(clone_ptr&& rh) noexcept {
24  if (&rh != this)
25  std::unique_ptr<T>::operator=(std::move(rh));
26  return *this;
27  }
28 
29  template <typename U>
30  clone_ptr(clone_ptr<U> const& rh) : std::unique_ptr<T>(rh ? rh->clone() : nullptr) {}
31  template <typename U>
32  clone_ptr(clone_ptr<U>&& rh) noexcept : std::unique_ptr<T>(std::move(rh)) {}
33 
34  template <typename U>
36  if (&rh != this)
37  this->reset(rh ? rh->clone() : nullptr);
38  return *this;
39  }
40  template <typename U>
41  clone_ptr& operator=(clone_ptr<U>&& rh) noexcept {
42  if (&rh != this)
43  std::unique_ptr<T>::operator=(std::move(rh));
44  return *this;
45  }
46  };
47 
48 } // namespace extstd
49 
50 #endif
writedatasetfile.args
args
Definition: writedatasetfile.py:18
extstd::clone_ptr
Definition: clone_ptr.h:11
extstd::clone_ptr::clone_ptr
clone_ptr(Args &&... args) noexcept
Definition: clone_ptr.h:13
extstd::clone_ptr::operator=
clone_ptr & operator=(clone_ptr const &rh)
Definition: clone_ptr.h:18
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
extstd::clone_ptr::clone_ptr
clone_ptr(clone_ptr &&rh) noexcept
Definition: clone_ptr.h:16
extstd::clone_ptr::clone_ptr
clone_ptr(clone_ptr< U > const &rh)
Definition: clone_ptr.h:30
extstd
Definition: clone_ptr.h:6
cms::cuda::device::unique_ptr
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
Definition: device_unique_ptr.h:33
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
extstd::clone_ptr::operator=
clone_ptr & operator=(clone_ptr< U > const &rh)
Definition: clone_ptr.h:35
T
long double T
Definition: Basic3DVectorLD.h:48
extstd::clone_ptr::clone_ptr
clone_ptr(clone_ptr const &rh)
Definition: clone_ptr.h:15
extstd::clone_ptr::clone_ptr
clone_ptr(clone_ptr< U > &&rh) noexcept
Definition: clone_ptr.h:32
reset
void reset(double vett[256])
Definition: TPedValues.cc:11
extstd::clone_ptr::operator=
clone_ptr & operator=(clone_ptr &&rh) noexcept
Definition: clone_ptr.h:23
extstd::clone_ptr::operator=
clone_ptr & operator=(clone_ptr< U > &&rh) noexcept
Definition: clone_ptr.h:41