summaryrefslogtreecommitdiff
path: root/boost/interprocess/smart_ptr
diff options
context:
space:
mode:
Diffstat (limited to 'boost/interprocess/smart_ptr')
-rw-r--r--boost/interprocess/smart_ptr/deleter.hpp4
-rw-r--r--boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp4
-rw-r--r--boost/interprocess/smart_ptr/detail/shared_count.hpp7
-rw-r--r--boost/interprocess/smart_ptr/detail/sp_counted_base.hpp6
-rw-r--r--boost/interprocess/smart_ptr/detail/sp_counted_base_atomic.hpp4
-rw-r--r--boost/interprocess/smart_ptr/detail/sp_counted_impl.hpp15
-rw-r--r--boost/interprocess/smart_ptr/enable_shared_from_this.hpp14
-rw-r--r--boost/interprocess/smart_ptr/intrusive_ptr.hpp24
-rw-r--r--boost/interprocess/smart_ptr/scoped_ptr.hpp18
-rw-r--r--boost/interprocess/smart_ptr/shared_ptr.hpp40
-rw-r--r--boost/interprocess/smart_ptr/unique_ptr.hpp512
-rw-r--r--boost/interprocess/smart_ptr/weak_ptr.hpp22
12 files changed, 102 insertions, 568 deletions
diff --git a/boost/interprocess/smart_ptr/deleter.hpp b/boost/interprocess/smart_ptr/deleter.hpp
index 3a07ccd..1a9e390 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 9429613..77ceda0 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 <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 7daaee6..aed83eb 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 24d96ee..47743c1 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 <boost/interprocess/smart_ptr/detail/sp_counted_base_atomic.hpp>
#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 edb39ee..6ec1d56 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 6a46bb7..3e01be5 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 A, class D>
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> 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_allocator&>(*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<this_allocator> >
- 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 9c8c791..0ca3b0a 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 <boost/interprocess/detail/config_begin.hpp>
#include <boost/interprocess/detail/workaround.hpp>
@@ -34,7 +38,7 @@ namespace interprocess{
template<class T, class A, class D>
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<T, A, D> 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<element_type, A, D> _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 f6d5c8b..ff66512 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<T, VP>::pointer &a,
template<class T, class VP> inline
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.
@@ -277,7 +281,7 @@ inline boost::interprocess::intrusive_ptr<T, VP>reinterpret_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<T, VP> 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 a3755d3..e628608 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 <boost/interprocess/detail/config_begin.hpp>
#include <boost/interprocess/detail/workaround.hpp>
#include <boost/interprocess/detail/pointer_type.hpp>
@@ -40,13 +44,13 @@ template<class T, class Deleter>
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<T, Deleter> this_type;
typedef typename ipcdetail::add_reference<T>::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<Deleter>(*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<T, D>::pointer to_raw_pointer(scoped_ptr<T, D> const & p)
} // namespace interprocess
-/// @cond
+#if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
#if defined(_MSC_VER) && (_MSC_VER < 1400)
template<class T, class D> inline
@@ -155,7 +159,7 @@ T *to_raw_pointer(boost::interprocess::scoped_ptr<T, D> 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 5ede547..fdf7235 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 <boost/interprocess/detail/config_begin.hpp>
#include <boost/interprocess/detail/workaround.hpp>
@@ -24,7 +28,7 @@
#include <boost/assert.hpp>
#include <boost/interprocess/smart_ptr/detail/shared_count.hpp>
#include <boost/interprocess/detail/mpl.hpp>
-#include <boost/move/move.hpp>
+#include <boost/move/utility_core.hpp>
#include <boost/interprocess/detail/type_traits.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/smart_ptr/deleter.hpp>
@@ -52,7 +56,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){
@@ -88,10 +92,10 @@ inline void sp_enable_shared_from_this(shared_count<T, VoidAllocator, Deleter> c
template<class T, class VoidAllocator, class Deleter>
class shared_ptr
{
- /// @cond
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
private:
typedef shared_ptr<T, VoidAllocator, Deleter> 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<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())))
@@ -193,7 +197,7 @@ class shared_ptr
m_pn = ipcdetail::shared_count<T, VoidAllocator, Deleter>();
}
}
- /// @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<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::
@@ -239,7 +243,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>
@@ -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<T, VoidAllocator, Deleter> & other) // never throws
{ m_pn.swap(other.m_pn); }
- /// @cond
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
template<class T2, class A2, class Deleter2>
bool _internal_less(shared_ptr<T2, A2, Deleter2> const & rhs) const
@@ -313,7 +317,7 @@ class shared_ptr
template<class T2, class A2, class Deleter2> friend class weak_ptr;
ipcdetail::shared_count<T, VoidAllocator, Deleter> m_pn; // reference counter
- /// @endcond
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
}; // shared_ptr
template<class T, class VoidAllocator, class Deleter, class U, class VoidAllocator2, class Deleter2> inline
@@ -404,7 +408,7 @@ inline typename managed_shared_ptr<T, ManagedMemory>::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<T, VoidAllocator, Deleter> 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 89cdb1e..9e51c93 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 <boost/interprocess/detail/config_begin.hpp>
#include <boost/interprocess/detail/workaround.hpp>
-#include <boost/assert.hpp>
-#include <boost/interprocess/detail/utilities.hpp>
-#include <boost/interprocess/detail/pointer_type.hpp>
-#include <boost/move/move.hpp>
-#include <boost/compressed_pair.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/interprocess/detail/mpl.hpp>
-#include <boost/interprocess/detail/type_traits.hpp>
-#include <boost/interprocess/smart_ptr/deleter.hpp>
-#include <cstddef>
+#include <boost/move/unique_ptr.hpp>
//!\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 T, class D> class unique_ptr;
-
-namespace ipcdetail {
-
-template <class T> struct unique_ptr_error;
-
-template <class T, class D>
-struct unique_ptr_error<const unique_ptr<T, D> >
-{
- typedef unique_ptr<T, D> 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 T, class D>
-class unique_ptr
-{
- /// @cond
- struct nat {int for_bool_;};
- typedef typename ipcdetail::add_reference<D>::type deleter_reference;
- typedef typename ipcdetail::add_reference<const D>::type deleter_const_reference;
- /// @endcond
-
- public:
-
- typedef T element_type;
- typedef D deleter_type;
- typedef typename ipcdetail::pointer_type<T, D>::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_<ipcdetail::is_reference<D>
- ,D
- ,typename ipcdetail::add_reference<const D>::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<D>. -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<D>(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<U, E>::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 <class U, class E>
- unique_ptr(BOOST_RV_REF_2_TEMPL_ARGS(unique_ptr, U, E) u,
- typename ipcdetail::enable_if_c<
- ipcdetail::is_convertible<typename unique_ptr<U, E>::pointer, pointer>::value &&
- ipcdetail::is_convertible<E, D>::value &&
- (
- !ipcdetail::is_reference<D>::value ||
- ipcdetail::is_same<D, E>::value
- )
- ,
- nat
- >::type = nat())
- : ptr_(const_cast<unique_ptr<U,E>&>(u).release(), boost::move<D>(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 <class U, class E>
- 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<T>::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<pointer, D> 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
-};
-/*
-template <class T, class D>
-class unique_ptr<T[], D>
-{
- struct nat {int for_bool_;};
- typedef typename ipcdetail::add_reference<D>::type deleter_reference;
- typedef typename ipcdetail::add_reference<const D>::type deleter_const_reference;
-public:
- typedef T element_type;
- typedef D deleter_type;
- typedef typename ipcdetail::pointer_type<T, D>::type pointer;
-
- // constructors
- unique_ptr() : ptr_(pointer()) {}
- explicit unique_ptr(pointer p) : ptr_(p) {}
- unique_ptr(pointer p, typename if_<
- boost::is_reference<D>,
- D,
- typename ipcdetail::add_reference<const D>::type>::type d)
- : ptr_(p, d) {}
- unique_ptr(const unique_ptr& u)
- : ptr_(const_cast<unique_ptr&>(u).release(), u.get_deleter()) {}
-
- // destructor
- ~unique_ptr() {reset();}
-
- // assignment
- unique_ptr& operator=(const unique_ptr& cu)
- {
- unique_ptr& u = const_cast<unique_ptr&>(cu);
- reset(u.release());
- ptr_.second() = u.get_deleter();
- return *this;
- }
- unique_ptr& operator=(int nat::*)
- {
- reset();
- return *this;
- }
-
- // observers
- typename ipcdetail::add_reference<T>::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<pointer, D> ptr_;
-
- template <class U, class E> unique_ptr(U p, E,
- typename boost::enable_if<boost::is_convertible<U, pointer> >::type* = 0);
- template <class U> explicit unique_ptr(U,
- typename boost::enable_if<boost::is_convertible<U, pointer> >::type* = 0);
-
- unique_ptr(unique_ptr&);
- template <class U> unique_ptr(U&, typename ipcdetail::unique_ptr_error<U>::type = 0);
-
- unique_ptr& operator=(unique_ptr&);
- template <class U> typename ipcdetail::unique_ptr_error<U>::type operator=(U&);
-};
-
-template <class T, class D, std::size_t N>
-class unique_ptr<T[N], D>
-{
- struct nat {int for_bool_;};
- typedef typename ipcdetail::add_reference<D>::type deleter_reference;
- typedef typename ipcdetail::add_reference<const D>::type deleter_const_reference;
-public:
- typedef T element_type;
- typedef D deleter_type;
- typedef typename ipcdetail::pointer_type<T, D>::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>,
- D,
- typename ipcdetail::add_reference<const D>::type>::type d)
- : ptr_(p, d) {}
- unique_ptr(const unique_ptr& u)
- : ptr_(const_cast<unique_ptr&>(u).release(), u.get_deleter()) {}
-
- // destructor
- ~unique_ptr() {reset();}
-
- // assignment
- unique_ptr& operator=(const unique_ptr& cu)
- {
- unique_ptr& u = const_cast<unique_ptr&>(cu);
- reset(u.release());
- ptr_.second() = u.get_deleter();
- return *this;
- }
- unique_ptr& operator=(int nat::*)
- {
- reset();
- return *this;
- }
-
- // observers
- typename ipcdetail::add_reference<T>::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<pointer, D> ptr_;
-
- template <class U, class E> unique_ptr(U p, E,
- typename boost::enable_if<boost::is_convertible<U, pointer> >::type* = 0);
- template <class U> explicit unique_ptr(U,
- typename boost::enable_if<boost::is_convertible<U, pointer> >::type* = 0);
-
- unique_ptr(unique_ptr&);
- template <class U> unique_ptr(U&, typename ipcdetail::unique_ptr_error<U>::type = 0);
-
- unique_ptr& operator=(unique_ptr&);
- template <class U> typename ipcdetail::unique_ptr_error<U>::type operator=(U&);
-};
-*/
-template <class T, class D> inline
-void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y)
-{ x.swap(y); }
-
-template <class T1, class D1, class T2, class D2> inline
-bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y)
-{ return x.get() == y.get(); }
-
-template <class T1, class D1, class T2, class D2> inline
-bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y)
-{ return x.get() != y.get(); }
-
-template <class T1, class D1, class T2, class D2> inline
-bool operator <(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y)
-{ return x.get() < y.get(); }
-
-template <class T1, class D1, class T2, class D2> inline
-bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y)
-{ return x.get() <= y.get(); }
-
-template <class T1, class D1, class T2, class D2> inline
-bool operator >(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y)
-{ return x.get() > y.get(); }
-
-template <class T1, class D1, class T2, class D2> inline
-bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& 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<T1, D1>& x, const unique_ptr<T2, D2>& y)
template<class T, class ManagedMemory>
struct managed_unique_ptr
{
- typedef unique_ptr
+ typedef boost::movelib::unique_ptr
< T
, typename ManagedMemory::template deleter<T>::type
> type;
diff --git a/boost/interprocess/smart_ptr/weak_ptr.hpp b/boost/interprocess/smart_ptr/weak_ptr.hpp
index 5202ede..e4c47cb 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 <boost/interprocess/detail/config_begin.hpp>
#include <boost/interprocess/detail/workaround.hpp>
@@ -50,7 +54,7 @@ namespace interprocess{
template<class T, class A, class D>
class weak_ptr
{
- /// @cond
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
private:
// Borland 5.5.1 specific workarounds
typedef weak_ptr<T, A, D> this_type;
@@ -61,7 +65,7 @@ class weak_ptr
<T>::type reference;
typedef typename ipcdetail::add_reference
<T>::type const_reference;
- /// @endcond
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
public:
typedef T element_type;
@@ -99,7 +103,7 @@ 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();
@@ -126,7 +130,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 +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<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)
{
@@ -213,7 +217,7 @@ class weak_ptr
template<class T2, class A2, class D2> friend class weak_ptr;
ipcdetail::weak_count<T, A, D> m_pn; // reference counter
- /// @endcond
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
}; // weak_ptr
template<class T, class A, class D, class U, class A2, class D2> inline