diff options
Diffstat (limited to 'boost/interprocess/smart_ptr')
-rw-r--r-- | boost/interprocess/smart_ptr/deleter.hpp | 6 | ||||
-rw-r--r-- | boost/interprocess/smart_ptr/detail/shared_count.hpp | 6 | ||||
-rw-r--r-- | boost/interprocess/smart_ptr/detail/sp_counted_impl.hpp | 6 | ||||
-rw-r--r-- | boost/interprocess/smart_ptr/intrusive_ptr.hpp | 24 | ||||
-rw-r--r-- | boost/interprocess/smart_ptr/scoped_ptr.hpp | 12 | ||||
-rw-r--r-- | boost/interprocess/smart_ptr/shared_ptr.hpp | 63 | ||||
-rw-r--r-- | boost/interprocess/smart_ptr/unique_ptr.hpp | 10 | ||||
-rw-r--r-- | boost/interprocess/smart_ptr/weak_ptr.hpp | 16 |
8 files changed, 74 insertions, 69 deletions
diff --git a/boost/interprocess/smart_ptr/deleter.hpp b/boost/interprocess/smart_ptr/deleter.hpp index 4aba772975..3a07ccd8f4 100644 --- a/boost/interprocess/smart_ptr/deleter.hpp +++ b/boost/interprocess/smart_ptr/deleter.hpp @@ -26,9 +26,9 @@ //!Describes the functor to delete objects from the segment. namespace boost { -namespace interprocess { +namespace interprocess { -//!A deleter that uses the segment manager's destroy_ptr +//!A deleter that uses the segment manager's destroy_ptr //!function to destroy the passed pointer resource. //! //!This deleter is used @@ -56,7 +56,7 @@ class deleter { mp_mngr->destroy_ptr(ipcdetail::to_raw_pointer(p)); } }; -} //namespace interprocess { +} //namespace interprocess { } //namespace boost { #include <boost/interprocess/detail/config_end.hpp> diff --git a/boost/interprocess/smart_ptr/detail/shared_count.hpp b/boost/interprocess/smart_ptr/detail/shared_count.hpp index 0150ef6c00..7daaee6ea4 100644 --- a/boost/interprocess/smart_ptr/detail/shared_count.hpp +++ b/boost/interprocess/smart_ptr/detail/shared_count.hpp @@ -28,7 +28,7 @@ #include <boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp> #include <boost/interprocess/smart_ptr/detail/sp_counted_impl.hpp> #include <boost/interprocess/detail/utilities.hpp> -#include <boost/container/allocator/allocator_traits.hpp> +#include <boost/container/allocator_traits.hpp> #include <boost/detail/no_exceptions_support.hpp> #include <functional> // std::less @@ -99,7 +99,7 @@ class shared_count counted_impl_allocator alloc(a); m_pi = alloc.allocate(1); //Anti-exception deallocator - scoped_ptr<counted_impl, + scoped_ptr<counted_impl, scoped_ptr_dealloc_functor<counted_impl_allocator> > deallocator(m_pi, alloc); //It's more correct to use VoidAllocator::construct but @@ -116,7 +116,7 @@ class shared_count } ~shared_count() // nothrow - { + { if(m_pi) m_pi->release(); } diff --git a/boost/interprocess/smart_ptr/detail/sp_counted_impl.hpp b/boost/interprocess/smart_ptr/detail/sp_counted_impl.hpp index 4e2e664c86..6a46bb75e6 100644 --- a/boost/interprocess/smart_ptr/detail/sp_counted_impl.hpp +++ b/boost/interprocess/smart_ptr/detail/sp_counted_impl.hpp @@ -26,7 +26,7 @@ #include <boost/interprocess/smart_ptr/detail/sp_counted_base.hpp> #include <boost/interprocess/smart_ptr/scoped_ptr.hpp> #include <boost/interprocess/detail/utilities.hpp> -#include <boost/container/allocator/allocator_traits.hpp> +#include <boost/container/allocator_traits.hpp> #include <boost/intrusive/pointer_traits.hpp> namespace boost { @@ -63,10 +63,10 @@ struct scoped_ptr_dealloc_functor { if (ptr) priv_deallocate(ptr, alloc_version()); } }; - + template<class A, class D> -class sp_counted_impl_pd +class sp_counted_impl_pd : public sp_counted_base , boost::container::allocator_traits<A>::template portable_rebind_alloc< sp_counted_impl_pd<A, D> >::type diff --git a/boost/interprocess/smart_ptr/intrusive_ptr.hpp b/boost/interprocess/smart_ptr/intrusive_ptr.hpp index 3f086f5360..f6d5c8b77c 100644 --- a/boost/interprocess/smart_ptr/intrusive_ptr.hpp +++ b/boost/interprocess/smart_ptr/intrusive_ptr.hpp @@ -33,12 +33,12 @@ namespace interprocess { //!The intrusive_ptr class template stores a pointer to an object //!with an embedded reference count. intrusive_ptr is parameterized on -//!T (the type of the object pointed to) and VoidPointer(a void pointer type +//!T (the type of the object pointed to) and VoidPointer(a void pointer type //!that defines the type of pointer that intrusive_ptr will store). //!intrusive_ptr<T, void *> defines a class with a T* member whereas //!intrusive_ptr<T, offset_ptr<void> > defines a class with a offset_ptr<T> member. //!Relies on unqualified calls to: -//! +//! //! void intrusive_ptr_add_ref(T * p); //! void intrusive_ptr_release(T * p); //! @@ -69,7 +69,7 @@ class intrusive_ptr intrusive_ptr(): m_ptr(0) {} - //!Constructor. Copies pointer and if "p" is not zero and + //!Constructor. Copies pointer and if "p" is not zero and //!"add_ref" is true calls intrusive_ptr_add_ref(to_raw_pointer(p)). //!Does not throw intrusive_ptr(const pointer &p, bool add_ref = true): m_ptr(p) @@ -101,7 +101,7 @@ class intrusive_ptr if(m_ptr != 0) intrusive_ptr_release(ipcdetail::to_raw_pointer(m_ptr)); } - //!Assignment operator. Equivalent to intrusive_ptr(r).swap(*this). + //!Assignment operator. Equivalent to intrusive_ptr(r).swap(*this). //!Does not throw intrusive_ptr & operator=(intrusive_ptr const & rhs) { @@ -109,7 +109,7 @@ class intrusive_ptr return *this; } - //!Assignment from related. Equivalent to intrusive_ptr(r).swap(*this). + //!Assignment from related. Equivalent to intrusive_ptr(r).swap(*this). //!Does not throw template<class U> intrusive_ptr & operator= (intrusive_ptr<U, VP> const & rhs) @@ -118,14 +118,14 @@ class intrusive_ptr return *this; } - //!Assignment from pointer. Equivalent to intrusive_ptr(r).swap(*this). + //!Assignment from pointer. Equivalent to intrusive_ptr(r).swap(*this). //!Does not throw intrusive_ptr & operator=(pointer rhs) { this_type(rhs).swap(*this); return *this; } - + //!Returns a reference to the internal pointer. //!Does not throw pointer &get() @@ -175,7 +175,7 @@ class intrusive_ptr //!Returns a.get() == b.get(). //!Does not throw template<class T, class U, class VP> inline -bool operator==(intrusive_ptr<T, VP> const & a, +bool operator==(intrusive_ptr<T, VP> const & a, intrusive_ptr<U, VP> const & b) { return a.get() == b.get(); } @@ -217,11 +217,11 @@ bool operator!=(const typename intrusive_ptr<T, VP>::pointer &a, //!Returns a.get() < b.get(). //!Does not throw template<class T, class VP> inline -bool operator<(intrusive_ptr<T, VP> const & a, +bool operator<(intrusive_ptr<T, VP> const & a, intrusive_ptr<T, VP> const & b) -{ +{ return std::less<typename intrusive_ptr<T, VP>::pointer>() - (a.get(), b.get()); + (a.get(), b.get()); } //!Exchanges the contents of the two intrusive_ptrs. @@ -233,7 +233,7 @@ void swap(intrusive_ptr<T, VP> & lhs, // operator<< template<class E, class T, class Y, class VP> -inline std::basic_ostream<E, T> & operator<< +inline std::basic_ostream<E, T> & operator<< (std::basic_ostream<E, T> & os, intrusive_ptr<Y, VP> const & p) { os << p.get(); return os; } diff --git a/boost/interprocess/smart_ptr/scoped_ptr.hpp b/boost/interprocess/smart_ptr/scoped_ptr.hpp index 1885838ffe..a3755d3592 100644 --- a/boost/interprocess/smart_ptr/scoped_ptr.hpp +++ b/boost/interprocess/smart_ptr/scoped_ptr.hpp @@ -27,14 +27,14 @@ namespace boost { namespace interprocess { -//!scoped_ptr stores a pointer to a dynamically allocated object. +//!scoped_ptr stores a pointer to a dynamically allocated object. //!The object pointed to is guaranteed to be deleted, either on destruction //!of the scoped_ptr, or via an explicit reset. The user can avoid this //!deletion using release(). -//!scoped_ptr is parameterized on T (the type of the object pointed to) and +//!scoped_ptr is parameterized on T (the type of the object pointed to) and //!Deleter (the functor to be executed to delete the internal pointer). -//!The internal pointer will be of the same pointer type as typename -//!Deleter::pointer type (that is, if typename Deleter::pointer is +//!The internal pointer will be of the same pointer type as typename +//!Deleter::pointer type (that is, if typename Deleter::pointer is //!offset_ptr<void>, the internal pointer will be offset_ptr<T>). template<class T, class Deleter> class scoped_ptr @@ -60,10 +60,10 @@ class scoped_ptr : Deleter(d), m_ptr(p) // throws if pointer/Deleter copy ctor throws {} - //!If the stored pointer is not 0, destroys the object pointed to by the stored pointer. + //!If the stored pointer is not 0, destroys the object pointed to by the stored pointer. //!calling the operator() of the stored deleter. Never throws ~scoped_ptr() - { + { if(m_ptr){ Deleter &del = static_cast<Deleter&>(*this); del(m_ptr); diff --git a/boost/interprocess/smart_ptr/shared_ptr.hpp b/boost/interprocess/smart_ptr/shared_ptr.hpp index 61829078e8..5ede547a3f 100644 --- a/boost/interprocess/smart_ptr/shared_ptr.hpp +++ b/boost/interprocess/smart_ptr/shared_ptr.hpp @@ -52,7 +52,7 @@ inline void sp_enable_shared_from_this (shared_count<T, VoidAllocator, Deleter> const & pn ,enable_shared_from_this<T, VoidAllocator, Deleter> *pe ,T *ptr) - + { (void)ptr; if(pe != 0){ @@ -66,17 +66,17 @@ inline void sp_enable_shared_from_this(shared_count<T, VoidAllocator, Deleter> c } // namespace ipcdetail -//!shared_ptr stores a pointer to a dynamically allocated object. -//!The object pointed to is guaranteed to be deleted when the last shared_ptr pointing to +//!shared_ptr stores a pointer to a dynamically allocated object. +//!The object pointed to is guaranteed to be deleted when the last shared_ptr pointing to //!it is destroyed or reset. //! -//!shared_ptr is parameterized on +//!shared_ptr is parameterized on //!T (the type of the object pointed to), VoidAllocator (the void allocator to be used -//!to allocate the auxiliary data) and Deleter (the deleter whose +//!to allocate the auxiliary data) and Deleter (the deleter whose //!operator() will be used to delete the object. //! -//!The internal pointer will be of the same pointer type as typename -//!VoidAllocator::pointer type (that is, if typename VoidAllocator::pointer is +//!The internal pointer will be of the same pointer type as typename +//!VoidAllocator::pointer type (that is, if typename VoidAllocator::pointer is //!offset_ptr<void>, the internal pointer will be offset_ptr<T>). //! //!Because the implementation uses reference counting, cycles of shared_ptr @@ -125,7 +125,7 @@ class shared_ptr //!Requirements: Deleter and A's copy constructor must not throw. explicit shared_ptr(const pointer&p, const VoidAllocator &a = VoidAllocator(), const Deleter &d = Deleter()) : m_pn(p, a, d) - { + { //Check that the pointer passed is of the same type that //the pointer the allocator defines or it's a raw pointer typedef typename boost::intrusive:: @@ -134,25 +134,30 @@ class shared_ptr BOOST_STATIC_ASSERT((ipcdetail::is_same<pointer, ParameterPointer>::value) || (ipcdetail::is_pointer<pointer>::value)); - ipcdetail::sp_enable_shared_from_this<T, VoidAllocator, Deleter>( m_pn, ipcdetail::to_raw_pointer(p), ipcdetail::to_raw_pointer(p) ); + ipcdetail::sp_enable_shared_from_this<T, VoidAllocator, Deleter>( m_pn, ipcdetail::to_raw_pointer(p), ipcdetail::to_raw_pointer(p) ); } + //!Copy constructs a shared_ptr. If r is empty, constructs an empty shared_ptr. Otherwise, constructs + //!a shared_ptr that shares ownership with r. Never throws. + shared_ptr(const shared_ptr &r) + : m_pn(r.m_pn) // never throws + {} - //!Constructs a shared_ptr that shares ownership with r and stores p. + //!Constructs a shared_ptr that shares ownership with other and stores p. //!Postconditions: get() == p && use_count() == r.use_count(). //!Throws: nothing. shared_ptr(const shared_ptr &other, const pointer &p) : m_pn(other.m_pn, p) {} - //!If r is empty, constructs an empty shared_ptr. Otherwise, constructs + //!If r is empty, constructs an empty shared_ptr. Otherwise, constructs //!a shared_ptr that shares ownership with r. Never throws. template<class Y> shared_ptr(shared_ptr<Y, VoidAllocator, Deleter> const & r) : m_pn(r.m_pn) // never throws {} - //!Constructs a shared_ptr that shares ownership with r and stores + //!Constructs a shared_ptr that shares ownership with r and stores //!a copy of the pointer stored in r. template<class Y> explicit shared_ptr(weak_ptr<Y, VoidAllocator, Deleter> const & r) @@ -170,19 +175,19 @@ class shared_ptr template<class Y> shared_ptr(shared_ptr<Y, VoidAllocator, Deleter> const & r, ipcdetail::static_cast_tag) : m_pn( pointer(static_cast<T*>(ipcdetail::to_raw_pointer(r.m_pn.to_raw_pointer()))) - , r.m_pn) + , r.m_pn) {} template<class Y> shared_ptr(shared_ptr<Y, VoidAllocator, Deleter> const & r, ipcdetail::const_cast_tag) : m_pn( pointer(const_cast<T*>(ipcdetail::to_raw_pointer(r.m_pn.to_raw_pointer()))) - , r.m_pn) + , r.m_pn) {} template<class Y> shared_ptr(shared_ptr<Y, VoidAllocator, Deleter> const & r, ipcdetail::dynamic_cast_tag) : m_pn( pointer(dynamic_cast<T*>(ipcdetail::to_raw_pointer(r.m_pn.to_raw_pointer()))) - , r.m_pn) + , r.m_pn) { if(!m_pn.to_raw_pointer()){ // need to allocate new counter -- the cast failed m_pn = ipcdetail::shared_count<T, VoidAllocator, Deleter>(); @@ -218,15 +223,15 @@ class shared_ptr //!This is equivalent to: //!this_type().swap(*this); void reset() - { - this_type().swap(*this); + { + this_type().swap(*this); } //!This is equivalent to: //!this_type(p, a, d).swap(*this); template<class Pointer> void reset(const Pointer &p, const VoidAllocator &a = VoidAllocator(), const Deleter &d = Deleter()) - { + { //Check that the pointer passed is of the same type that //the pointer the allocator defines or it's a raw pointer typedef typename boost::intrusive:: @@ -234,7 +239,7 @@ class shared_ptr rebind_pointer<T>::type ParameterPointer; BOOST_STATIC_ASSERT((ipcdetail::is_same<pointer, ParameterPointer>::value) || (ipcdetail::is_pointer<Pointer>::value)); - this_type(p, a, d).swap(*this); + this_type(p, a, d).swap(*this); } template<class Y> @@ -248,12 +253,12 @@ class shared_ptr reference operator* () const // never throws { BOOST_ASSERT(m_pn.to_raw_pointer() != 0); return *m_pn.to_raw_pointer(); } - //!Returns the pointer pointing + //!Returns the pointer pointing //!to the owned object pointer operator-> () const // never throws { BOOST_ASSERT(m_pn.to_raw_pointer() != 0); return m_pn.to_raw_pointer(); } - //!Returns the pointer pointing + //!Returns the pointer pointing //!to the owned object pointer get() const // never throws { return m_pn.to_raw_pointer(); } @@ -292,7 +297,7 @@ class shared_ptr /// @cond - template<class T2, class A2, class Deleter2> + template<class T2, class A2, class Deleter2> bool _internal_less(shared_ptr<T2, A2, Deleter2> const & rhs) const { return m_pn < rhs.m_pn; } @@ -311,19 +316,19 @@ class shared_ptr /// @endcond }; // shared_ptr -template<class T, class VoidAllocator, class Deleter, class U, class VoidAllocator2, class Deleter2> inline +template<class T, class VoidAllocator, class Deleter, class U, class VoidAllocator2, class Deleter2> inline bool operator==(shared_ptr<T, VoidAllocator, Deleter> const & a, shared_ptr<U, VoidAllocator2, Deleter2> const & b) { return a.get() == b.get(); } -template<class T, class VoidAllocator, class Deleter, class U, class VoidAllocator2, class Deleter2> inline +template<class T, class VoidAllocator, class Deleter, class U, class VoidAllocator2, class Deleter2> inline bool operator!=(shared_ptr<T, VoidAllocator, Deleter> const & a, shared_ptr<U, VoidAllocator2, Deleter2> const & b) { return a.get() != b.get(); } -template<class T, class VoidAllocator, class Deleter, class U, class VoidAllocator2, class Deleter2> inline +template<class T, class VoidAllocator, class Deleter, class U, class VoidAllocator2, class Deleter2> inline bool operator<(shared_ptr<T, VoidAllocator, Deleter> const & a, shared_ptr<U, VoidAllocator2, Deleter2> const & b) { return a._internal_less(b); } -template<class T, class VoidAllocator, class Deleter> inline +template<class T, class VoidAllocator, class Deleter> inline void swap(shared_ptr<T, VoidAllocator, Deleter> & a, shared_ptr<T, VoidAllocator, Deleter> & b) { a.swap(b); } @@ -331,11 +336,11 @@ template<class T, class VoidAllocator, class Deleter, class U> inline shared_ptr<T, VoidAllocator, Deleter> static_pointer_cast(shared_ptr<U, VoidAllocator, Deleter> const & r) { return shared_ptr<T, VoidAllocator, Deleter>(r, ipcdetail::static_cast_tag()); } -template<class T, class VoidAllocator, class Deleter, class U> inline +template<class T, class VoidAllocator, class Deleter, class U> inline shared_ptr<T, VoidAllocator, Deleter> const_pointer_cast(shared_ptr<U, VoidAllocator, Deleter> const & r) { return shared_ptr<T, VoidAllocator, Deleter>(r, ipcdetail::const_cast_tag()); } -template<class T, class VoidAllocator, class Deleter, class U> inline +template<class T, class VoidAllocator, class Deleter, class U> inline shared_ptr<T, VoidAllocator, Deleter> dynamic_pointer_cast(shared_ptr<U, VoidAllocator, Deleter> const & r) { return shared_ptr<T, VoidAllocator, Deleter>(r, ipcdetail::dynamic_cast_tag()); } @@ -346,7 +351,7 @@ T * to_raw_pointer(shared_ptr<T, VoidAllocator, Deleter> const & p) // operator<< template<class E, class T, class Y, class VoidAllocator, class Deleter> inline -std::basic_ostream<E, T> & operator<< +std::basic_ostream<E, T> & operator<< (std::basic_ostream<E, T> & os, shared_ptr<Y, VoidAllocator, Deleter> const & p) { os << p.get(); return os; } diff --git a/boost/interprocess/smart_ptr/unique_ptr.hpp b/boost/interprocess/smart_ptr/unique_ptr.hpp index 547038b69b..89cdb1e6e2 100644 --- a/boost/interprocess/smart_ptr/unique_ptr.hpp +++ b/boost/interprocess/smart_ptr/unique_ptr.hpp @@ -272,20 +272,20 @@ class unique_ptr //!Returns: A reference to the stored deleter. //! //!Throws: nothing. - deleter_reference get_deleter() + deleter_reference get_deleter() { return ptr_.second(); } //!Returns: A const reference to the stored deleter. //! //!Throws: nothing. - deleter_const_reference get_deleter() const + deleter_const_reference get_deleter() const { return ptr_.second(); } //!Returns: An unspecified value that, when used in boolean //!contexts, is equivalent to get() != 0. //! //!Throws: nothing. - operator int nat::*() const + operator int nat::*() const { return ptr_.first() ? &nat::for_bool_ : 0; } //!Postcondition: get() == 0. @@ -328,7 +328,7 @@ class unique_ptr BOOST_MOVABLE_BUT_NOT_COPYABLE(unique_ptr) template <class U, class E> unique_ptr(unique_ptr<U, E>&); template <class U> unique_ptr(U&, typename ipcdetail::unique_ptr_error<U>::type = 0); - + template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&); template <class U> typename ipcdetail::unique_ptr_error<U>::type operator=(U&); /// @endcond @@ -539,7 +539,7 @@ template<class T, class ManagedMemory> inline typename managed_unique_ptr<T, ManagedMemory>::type make_managed_unique_ptr(T *constructed_object, ManagedMemory &managed_memory) { - return typename managed_unique_ptr<T, ManagedMemory>::type + return typename managed_unique_ptr<T, ManagedMemory>::type (constructed_object, managed_memory.template get_deleter<T>()); } diff --git a/boost/interprocess/smart_ptr/weak_ptr.hpp b/boost/interprocess/smart_ptr/weak_ptr.hpp index 7126d055aa..5202ede91c 100644 --- a/boost/interprocess/smart_ptr/weak_ptr.hpp +++ b/boost/interprocess/smart_ptr/weak_ptr.hpp @@ -31,7 +31,7 @@ namespace boost{ namespace interprocess{ //!The weak_ptr class template stores a "weak reference" to an object -//!that's already managed by a shared_ptr. To access the object, a weak_ptr +//!that's already managed by a shared_ptr. To access the object, a weak_ptr //!can be converted to a shared_ptr using the shared_ptr constructor or the //!member function lock. When the last shared_ptr to the object goes away //!and the object is deleted, the attempt to obtain a shared_ptr from the @@ -99,11 +99,11 @@ class weak_ptr template<class Y> weak_ptr(weak_ptr<Y, A, D> const & r) : m_pn(r.m_pn) // never throws - { + { //Construct a temporary shared_ptr so that nobody //can destroy the value while constructing this const shared_ptr<T, A, D> &ref = r.lock(); - m_pn.set_pointer(ref.get()); + m_pn.set_pointer(ref.get()); } //!Effects: If r is empty, constructs an empty weak_ptr; otherwise, @@ -126,7 +126,7 @@ class weak_ptr //!implied guarantees) via different means, without creating a temporary. template<class Y> weak_ptr & operator=(weak_ptr<Y, A, D> const & r) // never throws - { + { //Construct a temporary shared_ptr so that nobody //can destroy the value while constructing this const shared_ptr<T, A, D> &ref = r.lock(); @@ -174,7 +174,7 @@ class weak_ptr //!testing purposes, not for production code. long use_count() const // never throws { return m_pn.use_count(); } - + //!Returns: Returns: use_count() == 0. //! //!Throws: nothing. @@ -196,10 +196,10 @@ class weak_ptr { ipcdetail::do_swap(m_pn, other.m_pn); } /// @cond - template<class T2, class A2, class D2> + template<class T2, class A2, class D2> bool _internal_less(weak_ptr<T2, A2, D2> const & rhs) const { return m_pn < rhs.m_pn; } - + template<class Y> void _internal_assign(const ipcdetail::shared_count<Y, A, D> & pn2) { @@ -216,7 +216,7 @@ class weak_ptr /// @endcond }; // weak_ptr -template<class T, class A, class D, class U, class A2, class D2> inline +template<class T, class A, class D, class U, class A2, class D2> inline bool operator<(weak_ptr<T, A, D> const & a, weak_ptr<U, A2, D2> const & b) { return a._internal_less(b); } |