CMS 3D CMS Logo

ConstRespectingPtr.h
Go to the documentation of this file.
1 #ifndef FWCore_Utilities_ConstRespectingPtr_h
2 #define FWCore_Utilities_ConstRespectingPtr_h
3 
4 // Package: FWCore/Utilities
5 // Class : ConstRespectingPtr
6 //
17 // Original Author: W. David Dagenhart
18 // Created: 20 March 2014
19 
20 #include <memory>
21 
23 
24 namespace edm {
25 
26  template <typename T>
28  public:
30  explicit ConstRespectingPtr(T*);
32 
33  T const* operator->() const { return m_data; }
34  T const& operator*() const { return *m_data; }
35  T const* get() const { return m_data; }
36 
37  T* operator->() { return m_data; }
38  T& operator*() { return *m_data; }
39  T* get() { return m_data; }
40 
41  bool isSet() const;
42 
43  void set(std::unique_ptr<T> iNewValue);
44 
45  T* release();
46  void reset();
47 
48  private:
51 
53  };
54 
55  template <typename T>
57 
58  template <typename T>
60 
61  template <typename T>
63  delete m_data.get();
64  }
65 
66  template <typename T>
68  return nullptr != m_data;
69  }
70 
71  template <typename T>
72  void ConstRespectingPtr<T>::set(std::unique_ptr<T> iNewValue) {
73  delete m_data;
74  m_data = iNewValue.release();
75  }
76 
77  template <typename T>
79  T* tmp = m_data;
80  m_data = nullptr;
81  return tmp;
82  }
83 
84  template <typename T>
86  delete m_data;
87  m_data = nullptr;
88  }
89 } // namespace edm
90 #endif
#define nullptr
edm::propagate_const< T * > m_data
element_type const * get() const
T const & operator*() const
T const * operator->() const
void set(std::unique_ptr< T > iNewValue)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
HLT enums.
long double T
ConstRespectingPtr & operator=(ConstRespectingPtr< T > const &)=delete