Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_RCPBoostSharedPtrConversionsDecl.hpp
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
17namespace Teuchos {
18
19
39template<class T>
41{
42public:
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_; }
51private:
52 mutable boost::shared_ptr<T> sptr_;
53 DeallocBoostSharedPtr(); // Not defined and not to be called!
54};
55
56
62template<class T>
64{
65public:
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_; }
76private:
77 mutable RCP<T> rcp_;
78 RCPDeleter(); // Not defined and not to be called!
79};
80
81
92template<class T>
93RCP<T> rcp( const boost::shared_ptr<T> &sptr );
94
95
107template<class T>
108boost::shared_ptr<T> shared_pointer( const RCP<T> &rcp );
109
110
111} // namespace Teuchos
112
113
114namespace boost {
115
116
121template<class T> inline
122bool is_null( const boost::shared_ptr<T> &p )
123{
124 return p.get() == 0;
125}
126
127
132template<class T> inline
133bool 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
Reference-counted pointer class and non-member templated function implementations.
Teuchos::RCP Deallocator class that wraps a boost::shared_ptr
DeallocBoostSharedPtr(const boost::shared_ptr< T > &sptr)
boost::shared_ptr deleter class that wraps a Teuchos::RCP.
Smart reference counting pointer class for automatic garbage collection.
boost::shared_ptr< T > shared_pointer(const RCP< T > &rcp)
Conversion function that takes in a Teuchos::RCP object and spits out a boost::shared_ptr object.
RCP< T > rcp(const boost::shared_ptr< T > &sptr)
Conversion function that takes in a boost::shared_ptr object and spits out a Teuchos::RCP object.
T * get() const
Get the raw C++ pointer to the underlying object.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.