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
DeepCopyPointerByClone & operator=(DeepCopyPointerByClone &&other)
DeepCopyPointerByClone & operator=(const DeepCopyPointerByClone &other)
DeepCopyPointerByClone(const DeepCopyPointerByClone &other)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
bool operator==(const T *otherP) const
to allow test like " if (p == &someT) {...}"
DeepCopyPointerByClone(DeepCopyPointerByClone &&other)
long double T