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 
29  public:
30 
32  explicit ConstRespectingPtr(T*);
34 
35  T const* operator->() const { return m_data; }
36  T const& operator*() const { return *m_data; }
37  T const* get() const { return m_data; }
38 
39  T* operator->() { return m_data; }
40  T& operator*() { return *m_data; }
41  T* get() { return m_data; }
42 
43  bool isSet() const;
44 
45  void set(std::unique_ptr<T> iNewValue);
46 
47  T* release();
48  void reset();
49 
50  private:
51 
54 
56  };
57 
58  template<typename T>
60 
61  template<typename T>
63 
64  template<typename T>
66  delete m_data.get();
67  }
68 
69  template<typename T>
70  bool ConstRespectingPtr<T>::isSet() const { return nullptr != m_data; }
71 
72  template<typename T>
73  void ConstRespectingPtr<T>::set(std::unique_ptr<T> iNewValue) {
74  delete m_data;
75  m_data = iNewValue.release();
76  }
77 
78  template<typename T>
80  T* tmp = m_data;
81  m_data = nullptr;
82  return tmp;
83  }
84 
85  template<typename T>
87  delete m_data;
88  m_data = nullptr;
89  }
90 }
91 #endif
edm::propagate_const< T * > m_data
#define nullptr
ConstRespectingPtr & operator=(ConstRespectingPtr< T > const &)
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