CMS 3D CMS Logo

unique_void_ptr.h
Go to the documentation of this file.
1 #ifndef CondFormats_SerializationHelper_unique_void_ptr_h
2 #define CondFormats_SerializationHelper_unique_void_ptr_h
3 // -*- C++ -*-
4 //
5 // Package: CondFormats/SerializationHelper
6 // Class : unique_void_ptr
7 //
16 //
17 // Original Author: Christopher Jones
18 // Created: Wed, 31 May 2023 14:34:15 GMT
19 //
20 
21 // system include files
22 #include <functional>
23 
24 // user include files
25 
26 // forward declarations
27 
28 namespace cond::serialization {
30  public:
31  unique_void_ptr() noexcept : ptr_{nullptr} {}
32  unique_void_ptr(const void* iPtr, std::function<void(const void*)> iDestructor) noexcept
33  : ptr_(iPtr), destructor_(std::move(iDestructor)) {}
34 
35  ~unique_void_ptr() noexcept {
36  if (destructor_) {
38  }
39  }
40 
41  unique_void_ptr(const unique_void_ptr&) = delete; // stop default
42  unique_void_ptr& operator=(const unique_void_ptr&) = delete; // stop default
43 
44  unique_void_ptr(unique_void_ptr&& iOld) noexcept : ptr_(iOld.ptr_), destructor_(std::move(iOld.destructor_)) {
45  iOld.ptr_ = nullptr;
46  }
49  std::swap(ptr_, iOld.ptr_);
50  std::swap(destructor_, iOld.destructor_);
51  return *this;
52  }
53  // ---------- const member functions ---------------------
54  const void* get() const noexcept { return ptr_; }
55 
56  // ---------- member functions --------------------------------
57  const void* release() noexcept {
58  auto tmp = ptr_;
59  ptr_ = nullptr;
60  return tmp;
61  }
62 
63  private:
64  // ---------- member data --------------------------------
65  const void* ptr_;
66  std::function<void(const void*)> destructor_;
67  };
68 } // namespace cond::serialization
69 #endif
unique_void_ptr(unique_void_ptr &&iOld) noexcept
unique_void_ptr & operator=(unique_void_ptr &&iOld) noexcept
std::function< void(const void *)> destructor_
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
unique_void_ptr & operator=(const unique_void_ptr &)=delete
unique_void_ptr(const void *iPtr, std::function< void(const void *)> iDestructor) noexcept
tmp
align.sh
Definition: createJobs.py:716
def move(src, dest)
Definition: eostools.py:511