CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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:
13 
16 
18 
20  if (other.theData) theData = other->clone(); else theData = 0;
21  }
22 
23 
25  if ( theData != other.theData) {
26  delete theData;
27  if (other.theData) theData = other->clone(); else theData = 0;
28  }
29  return *this;
30  }
31 
32 #if defined( __GXX_EXPERIMENTAL_CXX0X__)
33  // straight from http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2027.html
34 
36  other.theData=0;
37  }
38 
40  std::swap(theData,other.theData);
41  return *this;
42  }
43 #endif
44 
45 
46  T& operator*() { return *theData;}
47  const T& operator*() const { return *theData;}
48 
49  T* operator->() { return theData;}
50  const T* operator->() const { return theData;}
51 
53  operator bool() const { return theData != 0;}
54 
56  bool operator==( const T* otherP) const { return theData == otherP;}
57 
58 private:
60 };
61 
62 #endif // DeepCopyPointerByClone_H
bool operator==(const T *otherP) const
to allow test like &quot; if (p == &amp;someT) {...}&quot;
DeepCopyPointerByClone & operator=(const DeepCopyPointerByClone &other)
DeepCopyPointerByClone(const DeepCopyPointerByClone &other)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
const T & operator*() const
const T * operator->() const
long double T