From 08c1e93fa36a49f49325a07fe91ff92c964c2b6c Mon Sep 17 00:00:00 2001 From: Chanho Park Date: Thu, 11 Dec 2014 18:55:56 +0900 Subject: Imported Upstream version 1.57.0 --- boost/interprocess/smart_ptr/deleter.hpp | 4 +- .../interprocess/smart_ptr/detail/bad_weak_ptr.hpp | 4 +- .../interprocess/smart_ptr/detail/shared_count.hpp | 7 +- .../smart_ptr/detail/sp_counted_base.hpp | 6 +- .../smart_ptr/detail/sp_counted_base_atomic.hpp | 4 +- .../smart_ptr/detail/sp_counted_impl.hpp | 15 +- .../smart_ptr/enable_shared_from_this.hpp | 14 +- boost/interprocess/smart_ptr/intrusive_ptr.hpp | 24 +- boost/interprocess/smart_ptr/scoped_ptr.hpp | 18 +- boost/interprocess/smart_ptr/shared_ptr.hpp | 40 +- boost/interprocess/smart_ptr/unique_ptr.hpp | 512 +-------------------- boost/interprocess/smart_ptr/weak_ptr.hpp | 22 +- 12 files changed, 102 insertions(+), 568 deletions(-) (limited to 'boost/interprocess/smart_ptr') diff --git a/boost/interprocess/smart_ptr/deleter.hpp b/boost/interprocess/smart_ptr/deleter.hpp index 3a07ccd8f4..1a9e390018 100644 --- a/boost/interprocess/smart_ptr/deleter.hpp +++ b/boost/interprocess/smart_ptr/deleter.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2011. +// (C) Copyright Ion Gaztanaga 2007-2012. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -13,7 +13,7 @@ #ifndef BOOST_INTERPROCESS_DELETER_HPP #define BOOST_INTERPROCESS_DELETER_HPP -#if (defined _MSC_VER) && (_MSC_VER >= 1200) +#if defined(_MSC_VER) # pragma once #endif diff --git a/boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp b/boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp index 9429613492..77ceda0c58 100644 --- a/boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp +++ b/boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp @@ -13,7 +13,7 @@ #ifndef BOOST_INTERPROCESS_BAD_WEAK_PTR_HPP_INCLUDED #define BOOST_INTERPROCESS_BAD_WEAK_PTR_HPP_INCLUDED -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif @@ -36,7 +36,7 @@ class bad_weak_ptr { return "boost::interprocess::bad_weak_ptr"; } }; -} // namespace interprocess +} // namespace interprocess } // namespace boost #include diff --git a/boost/interprocess/smart_ptr/detail/shared_count.hpp b/boost/interprocess/smart_ptr/detail/shared_count.hpp index 7daaee6ea4..aed83eb2ab 100644 --- a/boost/interprocess/smart_ptr/detail/shared_count.hpp +++ b/boost/interprocess/smart_ptr/detail/shared_count.hpp @@ -4,7 +4,7 @@ // // (C) Copyright Peter Dimov and Multi Media Ltd. 2001, 2002, 2003 // (C) Copyright Peter Dimov 2004-2005 -// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // @@ -16,7 +16,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif @@ -116,7 +116,7 @@ class shared_count } ~shared_count() // nothrow - { + { if(m_pi) m_pi->release(); } @@ -284,6 +284,7 @@ class weak_count weak_count & operator= (weak_count const & r) // nothrow { + m_px = r.m_px; counted_impl_ptr tmp = r.m_pi; if(tmp != 0) tmp->weak_add_ref(); if(m_pi != 0) m_pi->weak_release(); diff --git a/boost/interprocess/smart_ptr/detail/sp_counted_base.hpp b/boost/interprocess/smart_ptr/detail/sp_counted_base.hpp index 24d96ee482..47743c1b91 100644 --- a/boost/interprocess/smart_ptr/detail/sp_counted_base.hpp +++ b/boost/interprocess/smart_ptr/detail/sp_counted_base.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2011. +// (C) Copyright Ion Gaztanaga 2007-2012. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -12,6 +12,10 @@ #ifndef BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED #define BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED +#if defined(_MSC_VER) +# pragma once +#endif + # include #endif // #ifndef BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED diff --git a/boost/interprocess/smart_ptr/detail/sp_counted_base_atomic.hpp b/boost/interprocess/smart_ptr/detail/sp_counted_base_atomic.hpp index edb39eeeb3..6ec1d56e59 100644 --- a/boost/interprocess/smart_ptr/detail/sp_counted_base_atomic.hpp +++ b/boost/interprocess/smart_ptr/detail/sp_counted_base_atomic.hpp @@ -3,13 +3,13 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif // Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. // Copyright 2004-2005 Peter Dimov -// Copyright 2007-2011 Ion Gaztanaga +// Copyright 2007-2012 Ion Gaztanaga // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at diff --git a/boost/interprocess/smart_ptr/detail/sp_counted_impl.hpp b/boost/interprocess/smart_ptr/detail/sp_counted_impl.hpp index 6a46bb75e6..3e01be5531 100644 --- a/boost/interprocess/smart_ptr/detail/sp_counted_impl.hpp +++ b/boost/interprocess/smart_ptr/detail/sp_counted_impl.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif @@ -63,7 +63,7 @@ struct scoped_ptr_dealloc_functor { if (ptr) priv_deallocate(ptr, alloc_version()); } }; - + template class sp_counted_impl_pd @@ -83,6 +83,8 @@ class sp_counted_impl_pd portable_rebind_alloc < const this_type >::type const_this_allocator; typedef typename this_allocator::pointer this_pointer; + typedef typename boost::intrusive:: + pointer_traits this_pointer_traits; sp_counted_impl_pd( sp_counted_impl_pd const & ); sp_counted_impl_pd & operator= ( sp_counted_impl_pd const & ); @@ -115,14 +117,13 @@ class sp_counted_impl_pd void destroy() // nothrow { - //Self destruction, so get a copy of the allocator - //(in the future we could move it) - this_allocator a_copy(*this); + //Self destruction, so move the allocator + this_allocator a_copy(::boost::move(static_cast(*this))); BOOST_ASSERT(a_copy == *this); - this_pointer this_ptr (this); + this_pointer this_ptr(this_pointer_traits::pointer_to(*this)); //Do it now! scoped_ptr< this_type, scoped_ptr_dealloc_functor > - deleter(this_ptr, a_copy); + deleter_ptr(this_ptr, a_copy); typedef typename this_allocator::value_type value_type; ipcdetail::to_raw_pointer(this_ptr)->~value_type(); } diff --git a/boost/interprocess/smart_ptr/enable_shared_from_this.hpp b/boost/interprocess/smart_ptr/enable_shared_from_this.hpp index 9c8c7918f5..0ca3b0a390 100644 --- a/boost/interprocess/smart_ptr/enable_shared_from_this.hpp +++ b/boost/interprocess/smart_ptr/enable_shared_from_this.hpp @@ -3,7 +3,7 @@ // This file is the adaptation for Interprocess of boost/enable_shared_from_this.hpp // // (C) Copyright Peter Dimov 2002 -// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // @@ -14,6 +14,10 @@ #ifndef BOOST_INTERPROCESS_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED #define BOOST_INTERPROCESS_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED +#if defined(_MSC_VER) +# pragma once +#endif + #include #include @@ -34,7 +38,7 @@ namespace interprocess{ template class enable_shared_from_this { - /// @cond + #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) protected: enable_shared_from_this() {} @@ -47,7 +51,7 @@ class enable_shared_from_this ~enable_shared_from_this() {} - /// @endcond + #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED public: shared_ptr shared_from_this() @@ -64,10 +68,10 @@ class enable_shared_from_this return p; } - /// @cond + #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) typedef T element_type; mutable weak_ptr _internal_weak_this; - /// @endcond + #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED }; } // namespace interprocess diff --git a/boost/interprocess/smart_ptr/intrusive_ptr.hpp b/boost/interprocess/smart_ptr/intrusive_ptr.hpp index f6d5c8b77c..ff66512251 100644 --- a/boost/interprocess/smart_ptr/intrusive_ptr.hpp +++ b/boost/interprocess/smart_ptr/intrusive_ptr.hpp @@ -3,7 +3,7 @@ // This file is the adaptation for Interprocess of boost/intrusive_ptr.hpp // // (C) Copyright Peter Dimov 2001, 2002 -// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // @@ -14,6 +14,10 @@ #ifndef BOOST_INTERPROCESS_INTRUSIVE_PTR_HPP_INCLUDED #define BOOST_INTERPROCESS_INTRUSIVE_PTR_HPP_INCLUDED +#if defined(_MSC_VER) +# pragma once +#endif + //!\file //!Describes an intrusive ownership pointer. @@ -56,12 +60,12 @@ class intrusive_ptr //!Provides the type of the stored pointer. typedef T element_type; - /// @cond + #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) private: typedef VoidPointer VP; typedef intrusive_ptr this_type; typedef pointer this_type::*unspecified_bool_type; - /// @endcond + #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED public: //!Constructor. Initializes internal pointer to 0. @@ -125,7 +129,7 @@ class intrusive_ptr this_type(rhs).swap(*this); return *this; } - + //!Returns a reference to the internal pointer. //!Does not throw pointer &get() @@ -166,10 +170,10 @@ class intrusive_ptr void swap(intrusive_ptr & rhs) { ipcdetail::do_swap(m_ptr, rhs.m_ptr); } - /// @cond + #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) private: pointer m_ptr; - /// @endcond + #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED }; //!Returns a.get() == b.get(). @@ -219,9 +223,9 @@ bool operator!=(const typename intrusive_ptr::pointer &a, template inline bool operator<(intrusive_ptr const & a, intrusive_ptr const & b) -{ +{ return std::less::pointer>() - (a.get(), b.get()); + (a.get(), b.get()); } //!Exchanges the contents of the two intrusive_ptrs. @@ -277,7 +281,7 @@ inline boost::interprocess::intrusive_ptrreinterpret_pointer_cast } // namespace interprocess -/// @cond +#if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) #if defined(_MSC_VER) && (_MSC_VER < 1400) //!Returns p.get(). @@ -287,7 +291,7 @@ inline T *to_raw_pointer(boost::interprocess::intrusive_ptr p) { return p.get(); } #endif -/// @endcond +#endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED } // namespace boost diff --git a/boost/interprocess/smart_ptr/scoped_ptr.hpp b/boost/interprocess/smart_ptr/scoped_ptr.hpp index a3755d3592..e628608c9a 100644 --- a/boost/interprocess/smart_ptr/scoped_ptr.hpp +++ b/boost/interprocess/smart_ptr/scoped_ptr.hpp @@ -4,7 +4,7 @@ // // (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. // (C) Copyright Peter Dimov 2001, 2002 -// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // @@ -15,6 +15,10 @@ #ifndef BOOST_INTERPROCESS_SCOPED_PTR_HPP_INCLUDED #define BOOST_INTERPROCESS_SCOPED_PTR_HPP_INCLUDED +#if defined(_MSC_VER) +# pragma once +#endif + #include #include #include @@ -40,13 +44,13 @@ template class scoped_ptr : private Deleter { - /// @cond + #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) scoped_ptr(scoped_ptr const &); scoped_ptr & operator=(scoped_ptr const &); typedef scoped_ptr this_type; typedef typename ipcdetail::add_reference::type reference; - /// @endcond + #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED public: @@ -127,10 +131,10 @@ class scoped_ptr void swap(scoped_ptr & b) // never throws { ipcdetail::do_swap(*this, b); ipcdetail::do_swap(m_ptr, b.m_ptr); } - /// @cond + #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) private: pointer m_ptr; - /// @endcond + #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED }; //!Exchanges the internal pointer and deleter with other scoped_ptr @@ -147,7 +151,7 @@ typename scoped_ptr::pointer to_raw_pointer(scoped_ptr const & p) } // namespace interprocess -/// @cond +#if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) #if defined(_MSC_VER) && (_MSC_VER < 1400) template inline @@ -155,7 +159,7 @@ T *to_raw_pointer(boost::interprocess::scoped_ptr const & p) { return p.get(); } #endif -/// @endcond +#endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED } // namespace boost diff --git a/boost/interprocess/smart_ptr/shared_ptr.hpp b/boost/interprocess/smart_ptr/shared_ptr.hpp index 5ede547a3f..fdf7235727 100644 --- a/boost/interprocess/smart_ptr/shared_ptr.hpp +++ b/boost/interprocess/smart_ptr/shared_ptr.hpp @@ -4,7 +4,7 @@ // // (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. // (C) Copyright Peter Dimov 2001, 2002, 2003 -// (C) Copyright Ion Gaztanaga 2006-2011. +// (C) Copyright Ion Gaztanaga 2006-2012. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -16,6 +16,10 @@ #ifndef BOOST_INTERPROCESS_SHARED_PTR_HPP_INCLUDED #define BOOST_INTERPROCESS_SHARED_PTR_HPP_INCLUDED +#if defined(_MSC_VER) +# pragma once +#endif + #include #include @@ -24,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -52,7 +56,7 @@ inline void sp_enable_shared_from_this (shared_count const & pn ,enable_shared_from_this *pe ,T *ptr) - + { (void)ptr; if(pe != 0){ @@ -88,10 +92,10 @@ inline void sp_enable_shared_from_this(shared_count c template class shared_ptr { - /// @cond + #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) private: typedef shared_ptr this_type; - /// @endcond + #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED public: @@ -125,7 +129,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:: @@ -171,7 +175,7 @@ class shared_ptr : m_pn() { this->swap(other); } - /// @cond + #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) template shared_ptr(shared_ptr const & r, ipcdetail::static_cast_tag) : m_pn( pointer(static_cast(ipcdetail::to_raw_pointer(r.m_pn.to_raw_pointer()))) @@ -193,7 +197,7 @@ class shared_ptr m_pn = ipcdetail::shared_count(); } } - /// @endcond + #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED //!Equivalent to shared_ptr(r).swap(*this). //!Never throws @@ -223,15 +227,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 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:: @@ -239,7 +243,7 @@ class shared_ptr rebind_pointer::type ParameterPointer; BOOST_STATIC_ASSERT((ipcdetail::is_same::value) || (ipcdetail::is_pointer::value)); - this_type(p, a, d).swap(*this); + this_type(p, a, d).swap(*this); } template @@ -263,14 +267,14 @@ class shared_ptr pointer get() const // never throws { return m_pn.to_raw_pointer(); } - /// @cond + #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) // implicit conversion to "bool" void unspecified_bool_type_func() const {} typedef void (this_type::*unspecified_bool_type)() const; operator unspecified_bool_type() const // never throws { return !m_pn.to_raw_pointer() ? 0 : &this_type::unspecified_bool_type_func; } - /// @endcond + #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED //!Not operator. //!Returns true if this->get() != 0, false otherwise @@ -295,7 +299,7 @@ class shared_ptr void swap(shared_ptr & other) // never throws { m_pn.swap(other.m_pn); } - /// @cond + #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) template bool _internal_less(shared_ptr const & rhs) const @@ -313,7 +317,7 @@ class shared_ptr template friend class weak_ptr; ipcdetail::shared_count m_pn; // reference counter - /// @endcond + #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED }; // shared_ptr template inline @@ -404,7 +408,7 @@ inline typename managed_shared_ptr::type } // namespace interprocess -/// @cond +#if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) #if defined(_MSC_VER) && (_MSC_VER < 1400) // to_raw_pointer() enables boost::mem_fn to recognize shared_ptr @@ -413,7 +417,7 @@ T * to_raw_pointer(boost::interprocess::shared_ptr co { return p.get(); } #endif -/// @endcond +#endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED } // namespace boost diff --git a/boost/interprocess/smart_ptr/unique_ptr.hpp b/boost/interprocess/smart_ptr/unique_ptr.hpp index 89cdb1e6e2..9e51c93508 100644 --- a/boost/interprocess/smart_ptr/unique_ptr.hpp +++ b/boost/interprocess/smart_ptr/unique_ptr.hpp @@ -1,11 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// -// I, Howard Hinnant, hereby place this code in the public domain. -////////////////////////////////////////////////////////////////////////////// -// -// This file is the adaptation for Interprocess of -// Howard Hinnant's unique_ptr emulation code. // -// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2006-2014. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // @@ -16,509 +11,22 @@ #ifndef BOOST_INTERPROCESS_UNIQUE_PTR_HPP_INCLUDED #define BOOST_INTERPROCESS_UNIQUE_PTR_HPP_INCLUDED +#if defined(_MSC_VER) +# pragma once +#endif + #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include //!\file -//!Describes the smart pointer unique_ptr +//!This header provides utilities to define a unique_ptr that plays nicely with managed segments. namespace boost{ namespace interprocess{ -/// @cond -template class unique_ptr; - -namespace ipcdetail { - -template struct unique_ptr_error; - -template -struct unique_ptr_error > -{ - typedef unique_ptr type; -}; - -} //namespace ipcdetail { -/// @endcond - -//!Template unique_ptr stores a pointer to an object and deletes that object -//!using the associated deleter when it is itself destroyed (such as when -//!leaving block scope. -//! -//!The unique_ptr provides a semantics of strict ownership. A unique_ptr owns the -//!object it holds a pointer to. -//! -//!A unique_ptr is not CopyConstructible, nor CopyAssignable, however it is -//!MoveConstructible and Move-Assignable. -//! -//!The uses of unique_ptr include providing exception safety for dynamically -//!allocated memory, passing ownership of dynamically allocated memory to a -//!function, and returning dynamically allocated memory from a function -//! -//!A client-supplied template argument D must be a -//!function pointer or functor for which, given a value d of type D and a pointer -//!ptr to a type T*, the expression d(ptr) is -//!valid and has the effect of deallocating the pointer as appropriate for that -//!deleter. D may also be an lvalue-reference to a deleter. -//! -//!If the deleter D maintains state, it is intended that this state stay with -//!the associated pointer as ownership is transferred -//!from unique_ptr to unique_ptr. The deleter state need never be copied, -//!only moved or swapped as pointer ownership -//!is moved around. That is, the deleter need only be MoveConstructible, -//!MoveAssignable, and Swappable, and need not be CopyConstructible -//!(unless copied into the unique_ptr) nor CopyAssignable. -template -class unique_ptr -{ - /// @cond - struct nat {int for_bool_;}; - typedef typename ipcdetail::add_reference::type deleter_reference; - typedef typename ipcdetail::add_reference::type deleter_const_reference; - /// @endcond - - public: - - typedef T element_type; - typedef D deleter_type; - typedef typename ipcdetail::pointer_type::type pointer; - - //!Requires: D must be default constructible, and that construction must not - //!throw an exception. D must not be a reference type. - //! - //!Effects: Constructs a unique_ptr which owns nothing. - //! - //!Postconditions: get() == 0. get_deleter() returns a reference to a - //!default constructed deleter D. - //! - //!Throws: nothing. - unique_ptr() - : ptr_(pointer(0)) - {} - - //!Requires: The expression D()(p) must be well formed. The default constructor - //!of D must not throw an exception. - //! - //!D must not be a reference type. - //! - //!Effects: Constructs a unique_ptr which owns p. - //! - //!Postconditions: get() == p. get_deleter() returns a reference to a default constructed deleter D. - //! - //!Throws: nothing. - explicit unique_ptr(pointer p) - : ptr_(p) - {} - - //!Requires: The expression d(p) must be well formed. - //! - //!Postconditions: get() == p. get_deleter() returns a reference to the - //!internally stored deleter. If D is a - //!reference type then get_deleter() returns a reference to the lvalue d. - //! - //!Throws: nothing. - unique_ptr(pointer p - ,typename ipcdetail::if_ - ,D - ,typename ipcdetail::add_reference::type>::type d) - : ptr_(p, d) - {} - - //!Requires: If the deleter is not a reference type, construction of the - //!deleter D from an lvalue D must not throw an exception. - //! - //!Effects: Constructs a unique_ptr which owns the pointer which u owns - //!(if any). If the deleter is not a reference type, it is move constructed - //!from u's deleter, otherwise the reference is copy constructed from u's deleter. - //! - //!After the construction, u no longer owns a pointer. - //![ Note: The deleter constructor can be implemented with - //! boost::forward. -end note ] - //! - //!Postconditions: get() == value u.get() had before the construction. - //!get_deleter() returns a reference to the internally stored deleter which - //!was constructed from u.get_deleter(). If D is a reference type then get_- - //!deleter() and u.get_deleter() both reference the same lvalue deleter. - //! - //!Throws: nothing. - unique_ptr(BOOST_RV_REF(unique_ptr) u) - : ptr_(u.release(), boost::forward(u.get_deleter())) - {} - - //!Requires: If D is not a reference type, construction of the deleter - //!D from an rvalue of type E must be well formed - //!and not throw an exception. If D is a reference type, then E must be - //!the same type as D (diagnostic required). unique_ptr::pointer - //!must be implicitly convertible to pointer. - //! - //!Effects: Constructs a unique_ptr which owns the pointer which u owns - //!(if any). If the deleter is not a reference - //!type, it is move constructed from u's deleter, otherwise the reference - //!is copy constructed from u's deleter. - //! - //!After the construction, u no longer owns a pointer. - //! - //!postconditions get() == value u.get() had before the construction, - //!modulo any required offset adjustments - //!resulting from the cast from U* to T*. get_deleter() returns a reference to the internally stored deleter which - //!was constructed from u.get_deleter(). - //! - //!Throws: nothing. - template - unique_ptr(BOOST_RV_REF_2_TEMPL_ARGS(unique_ptr, U, E) u, - typename ipcdetail::enable_if_c< - ipcdetail::is_convertible::pointer, pointer>::value && - ipcdetail::is_convertible::value && - ( - !ipcdetail::is_reference::value || - ipcdetail::is_same::value - ) - , - nat - >::type = nat()) - : ptr_(const_cast&>(u).release(), boost::move(u.get_deleter())) - {} - - //!Effects: If get() == 0 there are no effects. Otherwise get_deleter()(get()). - //! - //!Throws: nothing. - ~unique_ptr() - { reset(); } - - // assignment - - //!Requires: Assignment of the deleter D from an rvalue D must not throw an exception. - //! - //!Effects: reset(u.release()) followed by a move assignment from u's deleter to - //!this deleter. - //! - //!Postconditions: This unique_ptr now owns the pointer which u owned, and u no - //!longer owns it. - //! - //!Returns: *this. - //! - //!Throws: nothing. - unique_ptr& operator=(BOOST_RV_REF(unique_ptr) u) - { - reset(u.release()); - ptr_.second() = boost::move(u.get_deleter()); - return *this; - } - - //!Requires: Assignment of the deleter D from an rvalue D must not - //!throw an exception. U* must be implicitly convertible to T*. - //! - //!Effects: reset(u.release()) followed by a move assignment from - //!u's deleter to this deleter. If either D or E is - //!a reference type, then the referenced lvalue deleter participates - //!in the move assignment. - //! - //!Postconditions: This unique_ptr now owns the pointer which u owned, - //!and u no longer owns it. - //! - //!Returns: *this. - //! - //!Throws: nothing. - template - unique_ptr& operator=(BOOST_RV_REF_2_TEMPL_ARGS(unique_ptr, U, E) u) - { - reset(u.release()); - ptr_.second() = boost::move(u.get_deleter()); - return *this; - } - - //!Assigns from the literal 0 or NULL. - //! - //!Effects: reset(). - //! - //!Postcondition: get() == 0 - //! - //!Returns: *this. - //! - //!Throws: nothing. - unique_ptr& operator=(int nat::*) - { - reset(); - return *this; - } - - //!Requires: get() != 0. - //!Returns: *get(). - //!Throws: nothing. - typename ipcdetail::add_reference::type operator*() const - { return *ptr_.first(); } - - //!Requires: get() != 0. - //!Returns: get(). - //!Throws: nothing. - pointer operator->() const - { return ptr_.first(); } - - //!Returns: The stored pointer. - //!Throws: nothing. - pointer get() const - { return ptr_.first(); } - - //!Returns: A reference to the stored deleter. - //! - //!Throws: nothing. - deleter_reference get_deleter() - { return ptr_.second(); } - - //!Returns: A const reference to the stored deleter. - //! - //!Throws: nothing. - 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 - { return ptr_.first() ? &nat::for_bool_ : 0; } - - //!Postcondition: get() == 0. - //! - //!Returns: The value get() had at the start of the call to release. - //! - //!Throws: nothing. - pointer release() - { - pointer tmp = ptr_.first(); - ptr_.first() = 0; - return tmp; - } - - //!Effects: If p == get() there are no effects. Otherwise get_deleter()(get()). - //! - //!Postconditions: get() == p. - //! - //!Throws: nothing. - void reset(pointer p = 0) - { - if (ptr_.first() != p){ - if (ptr_.first()) - ptr_.second()(ptr_.first()); - ptr_.first() = p; - } - } - - //!Requires: The deleter D is Swappable and will not throw an exception under swap. - //! - //!Effects: The stored pointers of this and u are exchanged. - //! The stored deleters are swapped (unqualified). - //!Throws: nothing. - void swap(unique_ptr& u) - { ptr_.swap(u.ptr_); } - - /// @cond - private: - boost::compressed_pair ptr_; - BOOST_MOVABLE_BUT_NOT_COPYABLE(unique_ptr) - template unique_ptr(unique_ptr&); - template unique_ptr(U&, typename ipcdetail::unique_ptr_error::type = 0); - - template unique_ptr& operator=(unique_ptr&); - template typename ipcdetail::unique_ptr_error::type operator=(U&); - /// @endcond -}; -/* -template -class unique_ptr -{ - struct nat {int for_bool_;}; - typedef typename ipcdetail::add_reference::type deleter_reference; - typedef typename ipcdetail::add_reference::type deleter_const_reference; -public: - typedef T element_type; - typedef D deleter_type; - typedef typename ipcdetail::pointer_type::type pointer; - - // constructors - unique_ptr() : ptr_(pointer()) {} - explicit unique_ptr(pointer p) : ptr_(p) {} - unique_ptr(pointer p, typename if_< - boost::is_reference, - D, - typename ipcdetail::add_reference::type>::type d) - : ptr_(p, d) {} - unique_ptr(const unique_ptr& u) - : ptr_(const_cast(u).release(), u.get_deleter()) {} - - // destructor - ~unique_ptr() {reset();} - - // assignment - unique_ptr& operator=(const unique_ptr& cu) - { - unique_ptr& u = const_cast(cu); - reset(u.release()); - ptr_.second() = u.get_deleter(); - return *this; - } - unique_ptr& operator=(int nat::*) - { - reset(); - return *this; - } - - // observers - typename ipcdetail::add_reference::type operator[](std::size_t i) const {return ptr_.first()[i];} - pointer get() const {return ptr_.first();} - deleter_reference get_deleter() {return ptr_.second();} - deleter_const_reference get_deleter() const {return ptr_.second();} - operator int nat::*() const {return ptr_.first() ? &nat::for_bool_ : 0;} - - // modifiers - pointer release() - { - pointer tmp = ptr_.first(); - ptr_.first() = 0; - return tmp; - } - void reset(pointer p = 0) - { - if (ptr_.first() != p) - { - if (ptr_.first()) - ptr_.second()(ptr_.first()); - ptr_.first() = p; - } - } - void swap(unique_ptr& u) {ptr_.swap(u.ptr_);} -private: - boost::compressed_pair ptr_; - - template unique_ptr(U p, E, - typename boost::enable_if >::type* = 0); - template explicit unique_ptr(U, - typename boost::enable_if >::type* = 0); - - unique_ptr(unique_ptr&); - template unique_ptr(U&, typename ipcdetail::unique_ptr_error::type = 0); - - unique_ptr& operator=(unique_ptr&); - template typename ipcdetail::unique_ptr_error::type operator=(U&); -}; - -template -class unique_ptr -{ - struct nat {int for_bool_;}; - typedef typename ipcdetail::add_reference::type deleter_reference; - typedef typename ipcdetail::add_reference::type deleter_const_reference; -public: - typedef T element_type; - typedef D deleter_type; - typedef typename ipcdetail::pointer_type::type pointer; - static const std::size_t size = N; - - // constructors - unique_ptr() : ptr_(0) {} - explicit unique_ptr(pointer p) : ptr_(p) {} - unique_ptr(pointer p, typename if_< - boost::is_reference, - D, - typename ipcdetail::add_reference::type>::type d) - : ptr_(p, d) {} - unique_ptr(const unique_ptr& u) - : ptr_(const_cast(u).release(), u.get_deleter()) {} - - // destructor - ~unique_ptr() {reset();} - - // assignment - unique_ptr& operator=(const unique_ptr& cu) - { - unique_ptr& u = const_cast(cu); - reset(u.release()); - ptr_.second() = u.get_deleter(); - return *this; - } - unique_ptr& operator=(int nat::*) - { - reset(); - return *this; - } - - // observers - typename ipcdetail::add_reference::type operator[](std::size_t i) const {return ptr_.first()[i];} - pointer get() const {return ptr_.first();} - deleter_reference get_deleter() {return ptr_.second();} - deleter_const_reference get_deleter() const {return ptr_.second();} - operator int nat::*() const {return ptr_.first() ? &nat::for_bool_ : 0;} - - // modifiers - pointer release() - { - pointer tmp = ptr_.first(); - ptr_.first() = 0; - return tmp; - } - void reset(pointer p = 0) - { - if (ptr_.first() != p) - { - if (ptr_.first()) - ptr_.second()(ptr_.first(), N); - ptr_.first() = p; - } - } - void swap(unique_ptr& u) {ptr_.swap(u.ptr_);} -private: - boost::compressed_pair ptr_; - - template unique_ptr(U p, E, - typename boost::enable_if >::type* = 0); - template explicit unique_ptr(U, - typename boost::enable_if >::type* = 0); - - unique_ptr(unique_ptr&); - template unique_ptr(U&, typename ipcdetail::unique_ptr_error::type = 0); - - unique_ptr& operator=(unique_ptr&); - template typename ipcdetail::unique_ptr_error::type operator=(U&); -}; -*/ -template inline -void swap(unique_ptr& x, unique_ptr& y) -{ x.swap(y); } - -template inline -bool operator==(const unique_ptr& x, const unique_ptr& y) -{ return x.get() == y.get(); } - -template inline -bool operator!=(const unique_ptr& x, const unique_ptr& y) -{ return x.get() != y.get(); } - -template inline -bool operator <(const unique_ptr& x, const unique_ptr& y) -{ return x.get() < y.get(); } - -template inline -bool operator<=(const unique_ptr& x, const unique_ptr& y) -{ return x.get() <= y.get(); } - -template inline -bool operator >(const unique_ptr& x, const unique_ptr& y) -{ return x.get() > y.get(); } - -template inline -bool operator>=(const unique_ptr& x, const unique_ptr& y) -{ return x.get() >= y.get(); } - +//For backwards compatibility +using ::boost::movelib::unique_ptr; //!Returns the type of a unique pointer //!of type T with boost::interprocess::deleter deleter @@ -526,7 +34,7 @@ bool operator>=(const unique_ptr& x, const unique_ptr& y) template struct managed_unique_ptr { - typedef unique_ptr + typedef boost::movelib::unique_ptr < T , typename ManagedMemory::template deleter::type > type; diff --git a/boost/interprocess/smart_ptr/weak_ptr.hpp b/boost/interprocess/smart_ptr/weak_ptr.hpp index 5202ede91c..e4c47cb253 100644 --- a/boost/interprocess/smart_ptr/weak_ptr.hpp +++ b/boost/interprocess/smart_ptr/weak_ptr.hpp @@ -3,7 +3,7 @@ // This file is the adaptation for Interprocess of boost/weak_ptr.hpp // // (C) Copyright Peter Dimov 2001, 2002, 2003 -// (C) Copyright Ion Gaztanaga 2006-2011. +// (C) Copyright Ion Gaztanaga 2006-2012. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -15,6 +15,10 @@ #ifndef BOOST_INTERPROCESS_WEAK_PTR_HPP_INCLUDED #define BOOST_INTERPROCESS_WEAK_PTR_HPP_INCLUDED +#if defined(_MSC_VER) +# pragma once +#endif + #include #include @@ -50,7 +54,7 @@ namespace interprocess{ template class weak_ptr { - /// @cond + #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) private: // Borland 5.5.1 specific workarounds typedef weak_ptr this_type; @@ -61,7 +65,7 @@ class weak_ptr ::type reference; typedef typename ipcdetail::add_reference ::type const_reference; - /// @endcond + #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED public: typedef T element_type; @@ -99,7 +103,7 @@ class weak_ptr template weak_ptr(weak_ptr 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 &ref = r.lock(); @@ -126,7 +130,7 @@ class weak_ptr //!implied guarantees) via different means, without creating a temporary. template weak_ptr & operator=(weak_ptr const & r) // never throws - { + { //Construct a temporary shared_ptr so that nobody //can destroy the value while constructing this const shared_ptr &ref = r.lock(); @@ -174,7 +178,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. @@ -195,11 +199,11 @@ class weak_ptr void swap(this_type & other) // never throws { ipcdetail::do_swap(m_pn, other.m_pn); } - /// @cond + #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) template bool _internal_less(weak_ptr const & rhs) const { return m_pn < rhs.m_pn; } - + template void _internal_assign(const ipcdetail::shared_count & pn2) { @@ -213,7 +217,7 @@ class weak_ptr template friend class weak_ptr; ipcdetail::weak_count m_pn; // reference counter - /// @endcond + #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED }; // weak_ptr template inline -- cgit v1.2.3