Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_RCPBoostSharedPtrConversionsDecl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TEUCHOS_RCP_BOOST_SHAREDPTR_CONVERSIONS_DECL_HPP
11 #define TEUCHOS_RCP_BOOST_SHAREDPTR_CONVERSIONS_DECL_HPP
12 
13 #include "Teuchos_RCPDecl.hpp"
14 #include "boost/shared_ptr.hpp"
15 
16 
17 namespace Teuchos {
18 
19 
39 template<class T>
41 {
42 public:
44  DeallocBoostSharedPtr( const boost::shared_ptr<T> &sptr ) : sptr_(sptr) {}
46  typedef T ptr_t;
48  void free( T* ptr_in ) const { sptr_.reset(); }
50  const boost::shared_ptr<T>& ptr() const { return sptr_; }
51 private:
52  mutable boost::shared_ptr<T> sptr_;
53  DeallocBoostSharedPtr(); // Not defined and not to be called!
54 };
55 
56 
62 template<class T>
64 {
65 public:
67  RCPDeleter( const RCP<T> &rcp ) : rcp_(rcp) {}
69  typedef void result_type;
71  typedef T * argument_type;
73  void operator()(T * x) const { rcp_ = null; }
75  const RCP<T>& ptr() const { return rcp_; }
76 private:
77  mutable RCP<T> rcp_;
78  RCPDeleter(); // Not defined and not to be called!
79 };
80 
81 
92 template<class T>
93 RCP<T> rcp( const boost::shared_ptr<T> &sptr );
94 
95 
107 template<class T>
108 boost::shared_ptr<T> shared_pointer( const RCP<T> &rcp );
109 
110 
111 } // namespace Teuchos
112 
113 
114 namespace boost {
115 
116 
121 template<class T> inline
122 bool is_null( const boost::shared_ptr<T> &p )
123 {
124  return p.get() == 0;
125 }
126 
127 
132 template<class T> inline
133 bool nonnull( const boost::shared_ptr<T> &p )
134 {
135  return p.get() != 0;
136 }
137 
138 
139 } // namespace boost
140 
141 
142 #endif // TEUCHOS_RCP_BOOST_SHAREDPTR_CONVERSIONS_DECL_HPP
bool is_null(const boost::shared_ptr< T > &p)
Returns true if p.get()==NULL.
DeallocBoostSharedPtr(const boost::shared_ptr< T > &sptr)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
const boost::shared_ptr< T > & ptr() const
bool nonnull(const boost::shared_ptr< T > &p)
Returns true if p.get()!=NULL.
Reference-counted pointer class and non-member templated function implementations.
boost::shared_ptr deleter class that wraps a Teuchos::RCP.
Smart reference counting pointer class for automatic garbage collection.
Teuchos::RCP Deallocator class that wraps a boost::shared_ptr