CMS 3D CMS Logo

DeepCopyPointerByClone.h
Go to the documentation of this file.
1 #ifndef DeepCopyPointerByClone_H
2 #define DeepCopyPointerByClone_H
3 
4 #include <algorithm>
5 
10 template <class T>
12 public:
15 
17 
19  if (other.theData)
20  theData = other->clone();
21  else
22  theData = nullptr;
23  }
24 
26  if (theData != other.theData) {
27  delete theData;
28  if (other.theData)
29  theData = other->clone();
30  else
31  theData = 0;
32  }
33  return *this;
34  }
35 
36  // straight from http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2027.html
39  std::swap(theData, other.theData);
40  return *this;
41  }
42 
43  T& operator*() { return *theData; }
44  const T& operator*() const { return *theData; }
45 
46  T* operator->() { return theData; }
47  const T* operator->() const { return theData; }
48 
50  operator bool() const { return theData != 0; }
51 
53  bool operator==(const T* otherP) const { return theData == otherP; }
54 
55 private:
57 };
58 
59 #endif // DeepCopyPointerByClone_H
electrons_cff.bool
bool
Definition: electrons_cff.py:366
DeepCopyPointerByClone::operator*
const T & operator*() const
Definition: DeepCopyPointerByClone.h:44
DeepCopyPointerByClone::operator==
bool operator==(const T *otherP) const
to allow test like " if (p == &someT) {...}"
Definition: DeepCopyPointerByClone.h:53
DeepCopyPointerByClone
Definition: DeepCopyPointerByClone.h:11
DeepCopyPointerByClone::operator->
const T * operator->() const
Definition: DeepCopyPointerByClone.h:47
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
DeepCopyPointerByClone::DeepCopyPointerByClone
DeepCopyPointerByClone(DeepCopyPointerByClone &&other)
Definition: DeepCopyPointerByClone.h:37
DeepCopyPointerByClone::operator*
T & operator*()
Definition: DeepCopyPointerByClone.h:43
trackingPlots.other
other
Definition: trackingPlots.py:1460
DeepCopyPointerByClone::theData
T * theData
Definition: DeepCopyPointerByClone.h:56
DeepCopyPointerByClone::~DeepCopyPointerByClone
~DeepCopyPointerByClone()
Definition: DeepCopyPointerByClone.h:13
DeepCopyPointerByClone::DeepCopyPointerByClone
DeepCopyPointerByClone(T *t)
Definition: DeepCopyPointerByClone.h:16
DeepCopyPointerByClone::DeepCopyPointerByClone
DeepCopyPointerByClone()
Definition: DeepCopyPointerByClone.h:14
T
long double T
Definition: Basic3DVectorLD.h:48
DeepCopyPointerByClone::DeepCopyPointerByClone
DeepCopyPointerByClone(const DeepCopyPointerByClone &other)
Definition: DeepCopyPointerByClone.h:18
DeepCopyPointerByClone::operator=
DeepCopyPointerByClone & operator=(DeepCopyPointerByClone &&other)
Definition: DeepCopyPointerByClone.h:38
DeepCopyPointerByClone::operator=
DeepCopyPointerByClone & operator=(const DeepCopyPointerByClone &other)
Definition: DeepCopyPointerByClone.h:25
DeepCopyPointerByClone::operator->
T * operator->()
Definition: DeepCopyPointerByClone.h:46
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644