summaryrefslogtreecommitdiff
path: root/boost/interprocess/smart_ptr
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-10-30 19:57:26 (GMT)
committerAnas Nashif <anas.nashif@intel.com>2012-10-30 19:57:26 (GMT)
commit1a78a62555be32868418fe52f8e330c9d0f95d5a (patch)
treed3765a80e7d3b9640ec2e930743630cd6b9fce2b /boost/interprocess/smart_ptr
downloadboost-1a78a62555be32868418fe52f8e330c9d0f95d5a.zip
boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.gz
boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.bz2
Imported Upstream version 1.49.0upstream/1.49.0
Diffstat (limited to 'boost/interprocess/smart_ptr')
-rw-r--r--boost/interprocess/smart_ptr/deleter.hpp64
-rw-r--r--boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp44
-rw-r--r--boost/interprocess/smart_ptr/detail/shared_count.hpp338
-rw-r--r--boost/interprocess/smart_ptr/detail/sp_counted_base.hpp18
-rw-r--r--boost/interprocess/smart_ptr/detail/sp_counted_base_atomic.hpp92
-rw-r--r--boost/interprocess/smart_ptr/detail/sp_counted_impl.hpp155
-rw-r--r--boost/interprocess/smart_ptr/enable_shared_from_this.hpp79
-rw-r--r--boost/interprocess/smart_ptr/intrusive_ptr.hpp296
-rw-r--r--boost/interprocess/smart_ptr/scoped_ptr.hpp164
-rw-r--r--boost/interprocess/smart_ptr/shared_ptr.hpp417
-rw-r--r--boost/interprocess/smart_ptr/unique_ptr.hpp551
-rw-r--r--boost/interprocess/smart_ptr/weak_ptr.hpp260
12 files changed, 2478 insertions, 0 deletions
diff --git a/boost/interprocess/smart_ptr/deleter.hpp b/boost/interprocess/smart_ptr/deleter.hpp
new file mode 100644
index 0000000..4aba772
--- /dev/null
+++ b/boost/interprocess/smart_ptr/deleter.hpp
@@ -0,0 +1,64 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2007-2011.
+//
+// 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)
+//
+// See http://www.boost.org/libs/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTERPROCESS_DELETER_HPP
+#define BOOST_INTERPROCESS_DELETER_HPP
+
+#if (defined _MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/interprocess/detail/config_begin.hpp>
+#include <boost/interprocess/interprocess_fwd.hpp>
+#include <boost/interprocess/detail/utilities.hpp>
+#include <boost/intrusive/pointer_traits.hpp>
+
+//!\file
+//!Describes the functor to delete objects from the segment.
+
+namespace boost {
+namespace interprocess {
+
+//!A deleter that uses the segment manager's destroy_ptr
+//!function to destroy the passed pointer resource.
+//!
+//!This deleter is used
+template<class T, class SegmentManager>
+class deleter
+{
+ public:
+ typedef typename boost::intrusive::
+ pointer_traits<typename SegmentManager::void_pointer>::template
+ rebind_pointer<T>::type pointer;
+
+ private:
+ typedef typename boost::intrusive::
+ pointer_traits<pointer>::template
+ rebind_pointer<SegmentManager>::type segment_manager_pointer;
+
+ segment_manager_pointer mp_mngr;
+
+ public:
+ deleter(segment_manager_pointer pmngr)
+ : mp_mngr(pmngr)
+ {}
+
+ void operator()(const pointer &p)
+ { mp_mngr->destroy_ptr(ipcdetail::to_raw_pointer(p)); }
+};
+
+} //namespace interprocess {
+} //namespace boost {
+
+#include <boost/interprocess/detail/config_end.hpp>
+
+#endif //#ifndef BOOST_INTERPROCESS_DELETER_HPP
diff --git a/boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp b/boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp
new file mode 100644
index 0000000..9429613
--- /dev/null
+++ b/boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp
@@ -0,0 +1,44 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// This file is the adaptation for Interprocess of boost/detail/bad_weak_ptr.hpp
+//
+// (C) Copyright Peter Dimov and Multi Media Ltd. 2001, 2002, 2003
+// (C) Copyright Ion Gaztanaga 2006. 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)
+//
+// See http://www.boost.org/libs/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_INTERPROCESS_BAD_WEAK_PTR_HPP_INCLUDED
+#define BOOST_INTERPROCESS_BAD_WEAK_PTR_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/interprocess/detail/config_begin.hpp>
+#include <boost/interprocess/detail/workaround.hpp>
+
+#ifndef BOOST_NO_EXCEPTIONS
+#include <exception>
+#endif
+
+namespace boost{
+namespace interprocess{
+
+class bad_weak_ptr
+ : public std::exception
+{
+ public:
+
+ virtual char const * what() const throw()
+ { return "boost::interprocess::bad_weak_ptr"; }
+};
+
+} // namespace interprocess
+} // namespace boost
+
+#include <boost/interprocess/detail/config_end.hpp>
+
+#endif // #ifndef BOOST_INTERPROCESS_BAD_WEAK_PTR_HPP_INCLUDED
diff --git a/boost/interprocess/smart_ptr/detail/shared_count.hpp b/boost/interprocess/smart_ptr/detail/shared_count.hpp
new file mode 100644
index 0000000..0150ef6
--- /dev/null
+++ b/boost/interprocess/smart_ptr/detail/shared_count.hpp
@@ -0,0 +1,338 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// This file is the adaptation for Interprocess of boost/detail/shared_count.hpp
+//
+// (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
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_INTERPROCESS_DETAIL_SHARED_COUNT_HPP_INCLUDED
+#define BOOST_INTERPROCESS_DETAIL_SHARED_COUNT_HPP_INCLUDED
+
+// MS compatible compilers support #pragma once
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/interprocess/detail/config_begin.hpp>
+#include <boost/interprocess/detail/workaround.hpp>
+
+#include <boost/checked_delete.hpp>
+#include <boost/intrusive/pointer_traits.hpp>
+#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/detail/no_exceptions_support.hpp>
+#include <functional> // std::less
+
+namespace boost {
+namespace interprocess {
+namespace ipcdetail{
+
+template<class T, class VoidAllocator, class Deleter>
+class weak_count;
+
+template<class T, class VoidAllocator, class Deleter>
+class shared_count
+{
+ public:
+ typedef typename boost::intrusive::
+ pointer_traits<typename VoidAllocator::pointer>::template
+ rebind_pointer<T>::type pointer;
+
+ private:
+ typedef sp_counted_impl_pd<VoidAllocator, Deleter> counted_impl;
+
+ typedef typename boost::intrusive::
+ pointer_traits<typename VoidAllocator::pointer>::template
+ rebind_pointer<counted_impl>::type counted_impl_ptr;
+ typedef typename boost::intrusive::
+ pointer_traits<typename VoidAllocator::pointer>::template
+ rebind_pointer<sp_counted_base>::type counted_base_ptr;
+
+ typedef boost::container::allocator_traits<VoidAllocator> vallocator_traits;
+
+ typedef typename vallocator_traits::template
+ portable_rebind_alloc<counted_impl>::type counted_impl_allocator;
+
+ typedef typename boost::intrusive::
+ pointer_traits<typename VoidAllocator::pointer>::template
+ rebind_pointer<const Deleter>::type const_deleter_pointer;
+
+ typedef typename boost::intrusive::
+ pointer_traits<typename VoidAllocator::pointer>::template
+ rebind_pointer<const VoidAllocator>::type const_allocator_pointer;
+
+ pointer m_px;
+ counted_impl_ptr m_pi;
+
+ template <class T2, class VoidAllocator2, class Deleter2>
+ friend class weak_count;
+
+ template <class T2, class VoidAllocator2, class Deleter2>
+ friend class shared_count;
+
+ public:
+
+ shared_count()
+ : m_px(0), m_pi(0) // nothrow
+ {}
+
+ template <class Ptr>
+ shared_count(const shared_count &other_shared_count, const Ptr &p)
+ : m_px(p), m_pi(other_shared_count.m_pi)
+ {}
+
+ template <class Ptr>
+ shared_count(const Ptr &p, const VoidAllocator &a, Deleter d)
+ : m_px(p), m_pi(0)
+ {
+ BOOST_TRY{
+ if(p){
+ counted_impl_allocator alloc(a);
+ m_pi = alloc.allocate(1);
+ //Anti-exception deallocator
+ scoped_ptr<counted_impl,
+ scoped_ptr_dealloc_functor<counted_impl_allocator> >
+ deallocator(m_pi, alloc);
+ //It's more correct to use VoidAllocator::construct but
+ //this needs copy constructor and we don't like it
+ new(ipcdetail::to_raw_pointer(m_pi))counted_impl(p, a, d);
+ deallocator.release();
+ }
+ }
+ BOOST_CATCH (...){
+ d(p); // delete p
+ BOOST_RETHROW
+ }
+ BOOST_CATCH_END
+ }
+
+ ~shared_count() // nothrow
+ {
+ if(m_pi)
+ m_pi->release();
+ }
+
+ shared_count(shared_count const & r)
+ : m_px(r.m_px), m_pi(r.m_pi) // nothrow
+ { if( m_pi != 0 ) m_pi->add_ref_copy(); }
+
+ //this is a test
+ template<class Y>
+ explicit shared_count(shared_count<Y, VoidAllocator, Deleter> const & r)
+ : m_px(r.m_px), m_pi(r.m_pi) // nothrow
+ { if( m_pi != 0 ) m_pi->add_ref_copy(); }
+
+ //this is a test
+ template<class Y>
+ explicit shared_count(const pointer & ptr, shared_count<Y, VoidAllocator, Deleter> const & r)
+ : m_px(ptr), m_pi(r.m_pi) // nothrow
+ { if( m_pi != 0 ) m_pi->add_ref_copy(); }
+
+/*
+ explicit shared_count(weak_count<Y, VoidAllocator, Deleter> const & r)
+ // throws bad_weak_ptr when r.use_count() == 0
+ : m_pi( r.m_pi )
+ {
+ if( m_pi == 0 || !m_pi->add_ref_lock() ){
+ boost::throw_exception( boost::interprocess::bad_weak_ptr() );
+ }
+ }
+*/
+ template<class Y>
+ explicit shared_count(weak_count<Y, VoidAllocator, Deleter> const & r)
+ // throws bad_weak_ptr when r.use_count() == 0
+ : m_px(r.m_px), m_pi( r.m_pi )
+ {
+ if( m_pi == 0 || !m_pi->add_ref_lock() ){
+ throw( boost::interprocess::bad_weak_ptr() );
+ }
+ }
+
+ const pointer &to_raw_pointer() const
+ { return m_px; }
+
+ pointer &to_raw_pointer()
+ { return m_px; }
+
+ shared_count & operator= (shared_count const & r) // nothrow
+ {
+ m_px = r.m_px;
+ counted_impl_ptr tmp = r.m_pi;
+ if( tmp != m_pi ){
+ if(tmp != 0) tmp->add_ref_copy();
+ if(m_pi != 0) m_pi->release();
+ m_pi = tmp;
+ }
+ return *this;
+ }
+
+ template<class Y>
+ shared_count & operator= (shared_count<Y, VoidAllocator, Deleter> const & r) // nothrow
+ {
+ m_px = r.m_px;
+ counted_impl_ptr tmp = r.m_pi;
+ if( tmp != m_pi ){
+ if(tmp != 0) tmp->add_ref_copy();
+ if(m_pi != 0) m_pi->release();
+ m_pi = tmp;
+ }
+ return *this;
+ }
+
+ void swap(shared_count & r) // nothrow
+ { ipcdetail::do_swap(m_px, r.m_px); ipcdetail::do_swap(m_pi, r.m_pi); }
+
+ long use_count() const // nothrow
+ { return m_pi != 0? m_pi->use_count(): 0; }
+
+ bool unique() const // nothrow
+ { return use_count() == 1; }
+
+ const_deleter_pointer get_deleter() const
+ { return m_pi ? m_pi->get_deleter() : 0; }
+
+// const_allocator_pointer get_allocator() const
+// { return m_pi ? m_pi->get_allocator() : 0; }
+
+ template<class T2, class VoidAllocator2, class Deleter2>
+ bool internal_equal (shared_count<T2, VoidAllocator2, Deleter2> const & other) const
+ { return this->m_pi == other.m_pi; }
+
+ template<class T2, class VoidAllocator2, class Deleter2>
+ bool internal_less (shared_count<T2, VoidAllocator2, Deleter2> const & other) const
+ { return std::less<counted_base_ptr>()(this->m_pi, other.m_pi); }
+};
+
+template<class T, class VoidAllocator, class Deleter, class T2, class VoidAllocator2, class Deleter2> inline
+bool operator==(shared_count<T, VoidAllocator, Deleter> const & a, shared_count<T2, VoidAllocator2, Deleter2> const & b)
+{ return a.internal_equal(b); }
+
+template<class T, class VoidAllocator, class Deleter, class T2, class VoidAllocator2, class Deleter2> inline
+bool operator<(shared_count<T, VoidAllocator, Deleter> const & a, shared_count<T2, VoidAllocator2, Deleter2> const & b)
+{ return a.internal_less(b); }
+
+
+template<class T, class VoidAllocator, class Deleter>
+class weak_count
+{
+ public:
+ typedef typename boost::intrusive::
+ pointer_traits<typename VoidAllocator::pointer>::template
+ rebind_pointer<T>::type pointer;
+
+ private:
+
+ typedef sp_counted_impl_pd<VoidAllocator, Deleter> counted_impl;
+
+ typedef typename boost::intrusive::
+ pointer_traits<typename VoidAllocator::pointer>::template
+ rebind_pointer<counted_impl>::type counted_impl_ptr;
+ typedef typename boost::intrusive::
+ pointer_traits<typename VoidAllocator::pointer>::template
+ rebind_pointer<sp_counted_base>::type counted_base_ptr;
+
+ pointer m_px;
+ counted_impl_ptr m_pi;
+
+ template <class T2, class VoidAllocator2, class Deleter2>
+ friend class weak_count;
+
+ template <class T2, class VoidAllocator2, class Deleter2>
+ friend class shared_count;
+
+ public:
+
+ weak_count(): m_px(0), m_pi(0) // nothrow
+ {}
+
+ template <class Y>
+ explicit weak_count(shared_count<Y, VoidAllocator, Deleter> const & r)
+ : m_px(r.m_px), m_pi(r.m_pi) // nothrow
+ { if(m_pi != 0) m_pi->weak_add_ref(); }
+
+ weak_count(weak_count const & r)
+ : m_px(r.m_px), m_pi(r.m_pi) // nothrow
+ { if(m_pi != 0) m_pi->weak_add_ref(); }
+
+ template<class Y>
+ weak_count(weak_count<Y, VoidAllocator, Deleter> const & r)
+ : m_px(r.m_px), m_pi(r.m_pi) // nothrow
+ { if(m_pi != 0) m_pi->weak_add_ref(); }
+
+ ~weak_count() // nothrow
+ { if(m_pi != 0) m_pi->weak_release(); }
+
+ template<class Y>
+ weak_count & operator= (shared_count<Y, VoidAllocator, Deleter> 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();
+ m_pi = tmp;
+ return *this;
+ }
+
+ weak_count & operator= (weak_count const & r) // nothrow
+ {
+ counted_impl_ptr tmp = r.m_pi;
+ if(tmp != 0) tmp->weak_add_ref();
+ if(m_pi != 0) m_pi->weak_release();
+ m_pi = tmp;
+ return *this;
+ }
+
+ void set_pointer(const pointer &ptr)
+ { m_px = ptr; }
+
+ template<class Y>
+ weak_count & operator= (weak_count<Y, VoidAllocator, Deleter> const& r) // nothrow
+ {
+ counted_impl_ptr tmp = r.m_pi;
+ if(tmp != 0) tmp->weak_add_ref();
+ if(m_pi != 0) m_pi->weak_release();
+ m_pi = tmp;
+ return *this;
+ }
+
+ void swap(weak_count & r) // nothrow
+ { ipcdetail::do_swap(m_px, r.m_px); ipcdetail::do_swap(m_pi, r.m_pi); }
+
+ long use_count() const // nothrow
+ { return m_pi != 0? m_pi->use_count() : 0; }
+
+ template<class T2, class VoidAllocator2, class Deleter2>
+ bool internal_equal (weak_count<T2, VoidAllocator2, Deleter2> const & other) const
+ { return this->m_pi == other.m_pi; }
+
+ template<class T2, class VoidAllocator2, class Deleter2>
+ bool internal_less (weak_count<T2, VoidAllocator2, Deleter2> const & other) const
+ { return std::less<counted_base_ptr>()(this->m_pi, other.m_pi); }
+};
+
+template<class T, class VoidAllocator, class Deleter, class T2, class VoidAllocator2, class Deleter2> inline
+bool operator==(weak_count<T, VoidAllocator, Deleter> const & a, weak_count<T2, VoidAllocator2, Deleter2> const & b)
+{ return a.internal_equal(b); }
+
+template<class T, class VoidAllocator, class Deleter, class T2, class VoidAllocator2, class Deleter2> inline
+bool operator<(weak_count<T, VoidAllocator, Deleter> const & a, weak_count<T2, VoidAllocator2, Deleter2> const & b)
+{ return a.internal_less(b); }
+
+} // namespace ipcdetail
+} // namespace interprocess
+} // namespace boost
+
+
+#include <boost/interprocess/detail/config_end.hpp>
+
+
+#endif // #ifndef BOOST_INTERPROCESS_DETAIL_SHARED_COUNT_HPP_INCLUDED
diff --git a/boost/interprocess/smart_ptr/detail/sp_counted_base.hpp b/boost/interprocess/smart_ptr/detail/sp_counted_base.hpp
new file mode 100644
index 0000000..24d96ee
--- /dev/null
+++ b/boost/interprocess/smart_ptr/detail/sp_counted_base.hpp
@@ -0,0 +1,18 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2007-2011.
+//
+// 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)
+//
+// See http://www.boost.org/libs/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED
+#define BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED
+
+# 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
new file mode 100644
index 0000000..edb39ee
--- /dev/null
+++ b/boost/interprocess/smart_ptr/detail/sp_counted_base_atomic.hpp
@@ -0,0 +1,92 @@
+#ifndef BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_ATOMIC_HPP_INCLUDED
+#define BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_ATOMIC_HPP_INCLUDED
+
+// MS compatible compilers support #pragma once
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
+// Copyright 2004-2005 Peter Dimov
+// Copyright 2007-2011 Ion Gaztanaga
+//
+// 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)
+//
+//
+// Lock-free algorithm by Alexander Terekhov
+//
+// Thanks to Ben Hitchings for the #weak + (#shared != 0)
+// formulation
+//
+
+#include <boost/interprocess/detail/config_begin.hpp>
+#include <boost/interprocess/detail/workaround.hpp>
+
+#include <boost/interprocess/detail/atomic.hpp>
+#include <typeinfo>
+
+namespace boost {
+
+namespace interprocess {
+
+namespace ipcdetail {
+
+class sp_counted_base
+{
+private:
+
+ sp_counted_base( sp_counted_base const & );
+ sp_counted_base & operator= ( sp_counted_base const & );
+
+ boost::uint32_t use_count_; // #shared
+ boost::uint32_t weak_count_; // #weak + (#shared != 0)
+
+public:
+
+ sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
+ {}
+
+ ~sp_counted_base() // nothrow
+ {}
+
+ void add_ref_copy()
+ {
+ ipcdetail::atomic_inc32( &use_count_ );
+ }
+
+ bool add_ref_lock() // true on success
+ {
+ for( ;; )
+ {
+ boost::uint32_t tmp = static_cast< boost::uint32_t const volatile& >( use_count_ );
+ if( tmp == 0 ) return false;
+ if( ipcdetail::atomic_cas32( &use_count_, tmp + 1, tmp ) == tmp )
+ return true;
+ }
+ }
+
+ bool ref_release() // nothrow
+ { return 1 == ipcdetail::atomic_dec32( &use_count_ ); }
+
+ void weak_add_ref() // nothrow
+ { ipcdetail::atomic_inc32( &weak_count_ ); }
+
+ bool weak_release() // nothrow
+ { return 1 == ipcdetail::atomic_dec32( &weak_count_ ); }
+
+ long use_count() const // nothrow
+ { return (long)static_cast<boost::uint32_t const volatile &>( use_count_ ); }
+};
+
+} // namespace ipcdetail
+
+} // namespace interprocess
+
+} // namespace boost
+
+#include <boost/interprocess/detail/config_end.hpp>
+
+#endif // #ifndef BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_ATOMIC_HPP_INCLUDED
diff --git a/boost/interprocess/smart_ptr/detail/sp_counted_impl.hpp b/boost/interprocess/smart_ptr/detail/sp_counted_impl.hpp
new file mode 100644
index 0000000..4e2e664
--- /dev/null
+++ b/boost/interprocess/smart_ptr/detail/sp_counted_impl.hpp
@@ -0,0 +1,155 @@
+#ifndef BOOST_INTERPROCESS_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED
+#define BOOST_INTERPROCESS_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED
+
+// MS compatible compilers support #pragma once
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+//
+// This file is the adaptation for shared memory memory mapped
+// files of boost/detail/sp_counted_impl.hpp
+//
+// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
+// Copyright 2004-2005 Peter Dimov
+// Copyright 2006 Ion Gaztanaga
+//
+// 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)
+//
+
+#include <boost/interprocess/detail/config_begin.hpp>
+#include <boost/interprocess/detail/workaround.hpp>
+
+#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/intrusive/pointer_traits.hpp>
+
+namespace boost {
+
+namespace interprocess {
+
+namespace ipcdetail {
+
+//!A deleter for scoped_ptr that deallocates the memory
+//!allocated for an object using a STL allocator.
+template <class Allocator>
+struct scoped_ptr_dealloc_functor
+{
+ typedef typename Allocator::pointer pointer;
+ typedef ipcdetail::integral_constant<unsigned,
+ boost::interprocess::version<Allocator>::value> alloc_version;
+ typedef ipcdetail::integral_constant<unsigned, 1> allocator_v1;
+ typedef ipcdetail::integral_constant<unsigned, 2> allocator_v2;
+
+ private:
+ void priv_deallocate(const typename Allocator::pointer &p, allocator_v1)
+ { m_alloc.deallocate(p, 1); }
+
+ void priv_deallocate(const typename Allocator::pointer &p, allocator_v2)
+ { m_alloc.deallocate_one(p); }
+
+ public:
+ Allocator& m_alloc;
+
+ scoped_ptr_dealloc_functor(Allocator& a)
+ : m_alloc(a) {}
+
+ void operator()(pointer ptr)
+ { if (ptr) priv_deallocate(ptr, alloc_version()); }
+};
+
+
+
+template<class A, class D>
+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
+ , D // copy constructor must not throw
+{
+ private:
+ typedef sp_counted_impl_pd<A, D> this_type;
+ typedef typename boost::container::
+ allocator_traits<A>::template
+ portable_rebind_alloc
+ < this_type >::type this_allocator;
+ typedef typename boost::container::
+ allocator_traits<A>::template
+ portable_rebind_alloc
+ < const this_type >::type const_this_allocator;
+ typedef typename this_allocator::pointer this_pointer;
+
+ sp_counted_impl_pd( sp_counted_impl_pd const & );
+ sp_counted_impl_pd & operator= ( sp_counted_impl_pd const & );
+
+ typedef typename boost::intrusive::
+ pointer_traits<typename A::pointer>::template
+ rebind_pointer<const D>::type const_deleter_pointer;
+ typedef typename boost::intrusive::
+ pointer_traits<typename A::pointer>::template
+ rebind_pointer<const A>::type const_allocator_pointer;
+
+ typedef typename D::pointer pointer;
+ pointer m_ptr;
+
+ public:
+ // pre: d(p) must not throw
+ template<class Ptr>
+ sp_counted_impl_pd(const Ptr & p, const A &a, const D &d )
+ : this_allocator(a), D(d), m_ptr(p)
+ {}
+
+ const_deleter_pointer get_deleter() const
+ { return const_deleter_pointer(&static_cast<const D&>(*this)); }
+
+ const_allocator_pointer get_allocator() const
+ { return const_allocator_pointer(&static_cast<const A&>(*this)); }
+
+ void dispose() // nothrow
+ { static_cast<D&>(*this)(m_ptr); }
+
+ void destroy() // nothrow
+ {
+ //Self destruction, so get a copy of the allocator
+ //(in the future we could move it)
+ this_allocator a_copy(*this);
+ BOOST_ASSERT(a_copy == *this);
+ this_pointer this_ptr (this);
+ //Do it now!
+ scoped_ptr< this_type, scoped_ptr_dealloc_functor<this_allocator> >
+ deleter(this_ptr, a_copy);
+ typedef typename this_allocator::value_type value_type;
+ ipcdetail::to_raw_pointer(this_ptr)->~value_type();
+ }
+
+ void release() // nothrow
+ {
+ if(this->ref_release()){
+ this->dispose();
+ this->weak_release();
+ }
+ }
+
+ void weak_release() // nothrow
+ {
+ if(sp_counted_base::weak_release()){
+ this->destroy();
+ }
+ }
+};
+
+
+} // namespace ipcdetail
+
+} // namespace interprocess
+
+} // namespace boost
+
+#include <boost/interprocess/detail/config_end.hpp>
+
+#endif // #ifndef BOOST_INTERPROCESS_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED
diff --git a/boost/interprocess/smart_ptr/enable_shared_from_this.hpp b/boost/interprocess/smart_ptr/enable_shared_from_this.hpp
new file mode 100644
index 0000000..9c8c791
--- /dev/null
+++ b/boost/interprocess/smart_ptr/enable_shared_from_this.hpp
@@ -0,0 +1,79 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// 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
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTERPROCESS_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
+#define BOOST_INTERPROCESS_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
+
+#include <boost/interprocess/detail/config_begin.hpp>
+#include <boost/interprocess/detail/workaround.hpp>
+
+#include <boost/assert.hpp>
+#include <boost/interprocess/smart_ptr/weak_ptr.hpp>
+#include <boost/interprocess/smart_ptr/shared_ptr.hpp>
+
+//!\file
+//!Describes an utility to form a shared pointer from this
+
+namespace boost{
+namespace interprocess{
+
+//!This class is used as a base class that allows a shared_ptr to the current
+//!object to be obtained from within a member function.
+//!enable_shared_from_this defines two member functions called shared_from_this
+//!that return a shared_ptr<T> and shared_ptr<T const>, depending on constness, to this.
+template<class T, class A, class D>
+class enable_shared_from_this
+{
+ /// @cond
+ protected:
+ enable_shared_from_this()
+ {}
+
+ enable_shared_from_this(enable_shared_from_this const &)
+ {}
+
+ enable_shared_from_this & operator=(enable_shared_from_this const &)
+ { return *this; }
+
+ ~enable_shared_from_this()
+ {}
+ /// @endcond
+
+ public:
+ shared_ptr<T, A, D> shared_from_this()
+ {
+ shared_ptr<T, A, D> p(_internal_weak_this);
+ BOOST_ASSERT(ipcdetail::to_raw_pointer(p.get()) == this);
+ return p;
+ }
+
+ shared_ptr<T const, A, D> shared_from_this() const
+ {
+ shared_ptr<T const, A, D> p(_internal_weak_this);
+ BOOST_ASSERT(ipcdetail::to_raw_pointer(p.get()) == this);
+ return p;
+ }
+
+ /// @cond
+ typedef T element_type;
+ mutable weak_ptr<element_type, A, D> _internal_weak_this;
+ /// @endcond
+};
+
+} // namespace interprocess
+} // namespace boost
+
+#include <boost/interprocess/detail/config_end.hpp>
+
+#endif // #ifndef BOOST_INTERPROCESS_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
+
diff --git a/boost/interprocess/smart_ptr/intrusive_ptr.hpp b/boost/interprocess/smart_ptr/intrusive_ptr.hpp
new file mode 100644
index 0000000..3f086f5
--- /dev/null
+++ b/boost/interprocess/smart_ptr/intrusive_ptr.hpp
@@ -0,0 +1,296 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// 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
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTERPROCESS_INTRUSIVE_PTR_HPP_INCLUDED
+#define BOOST_INTERPROCESS_INTRUSIVE_PTR_HPP_INCLUDED
+
+//!\file
+//!Describes an intrusive ownership pointer.
+
+#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/intrusive/pointer_traits.hpp>
+
+#include <functional> // for std::less
+#include <iosfwd> // for std::basic_ostream
+
+
+namespace boost {
+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
+//!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);
+//!
+//! with (p != 0)
+//!
+//!The object is responsible for destroying itself.
+template<class T, class VoidPointer>
+class intrusive_ptr
+{
+ public:
+ //!Provides the type of the internal stored pointer.
+ typedef typename boost::intrusive::
+ pointer_traits<VoidPointer>::template
+ rebind_pointer<T>::type pointer;
+ //!Provides the type of the stored pointer.
+ typedef T element_type;
+
+ /// @cond
+ private:
+ typedef VoidPointer VP;
+ typedef intrusive_ptr this_type;
+ typedef pointer this_type::*unspecified_bool_type;
+ /// @endcond
+
+ public:
+ //!Constructor. Initializes internal pointer to 0.
+ //!Does not throw
+ intrusive_ptr(): m_ptr(0)
+ {}
+
+ //!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)
+ {
+ if(m_ptr != 0 && add_ref) intrusive_ptr_add_ref(ipcdetail::to_raw_pointer(m_ptr));
+ }
+
+ //!Copy constructor. Copies the internal pointer and if "p" is not
+ //!zero calls intrusive_ptr_add_ref(to_raw_pointer(p)). Does not throw
+ intrusive_ptr(intrusive_ptr const & rhs)
+ : m_ptr(rhs.m_ptr)
+ {
+ if(m_ptr != 0) intrusive_ptr_add_ref(ipcdetail::to_raw_pointer(m_ptr));
+ }
+
+ //!Constructor from related. Copies the internal pointer and if "p" is not
+ //!zero calls intrusive_ptr_add_ref(to_raw_pointer(p)). Does not throw
+ template<class U> intrusive_ptr
+ (intrusive_ptr<U, VP> const & rhs)
+ : m_ptr(rhs.get())
+ {
+ if(m_ptr != 0) intrusive_ptr_add_ref(ipcdetail::to_raw_pointer(m_ptr));
+ }
+
+ //!Destructor. If internal pointer is not 0, calls
+ //!intrusive_ptr_release(to_raw_pointer(m_ptr)). Does not throw
+ ~intrusive_ptr()
+ {
+ if(m_ptr != 0) intrusive_ptr_release(ipcdetail::to_raw_pointer(m_ptr));
+ }
+
+ //!Assignment operator. Equivalent to intrusive_ptr(r).swap(*this).
+ //!Does not throw
+ intrusive_ptr & operator=(intrusive_ptr const & rhs)
+ {
+ this_type(rhs).swap(*this);
+ return *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)
+ {
+ this_type(rhs).swap(*this);
+ return *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()
+ { return m_ptr; }
+
+ //!Returns a reference to the internal pointer.
+ //!Does not throw
+ const pointer &get() const
+ { return m_ptr; }
+
+ //!Returns *get().
+ //!Does not throw
+ T & operator*() const
+ { return *m_ptr; }
+
+ //!Returns *get().
+ //!Does not throw
+ const pointer &operator->() const
+ { return m_ptr; }
+
+ //!Returns get().
+ //!Does not throw
+ pointer &operator->()
+ { return m_ptr; }
+
+ //!Conversion to boolean.
+ //!Does not throw
+ operator unspecified_bool_type () const
+ { return m_ptr == 0? 0: &this_type::m_ptr; }
+
+ //!Not operator.
+ //!Does not throw
+ bool operator! () const
+ { return m_ptr == 0; }
+
+ //!Exchanges the contents of the two smart pointers.
+ //!Does not throw
+ void swap(intrusive_ptr & rhs)
+ { ipcdetail::do_swap(m_ptr, rhs.m_ptr); }
+
+ /// @cond
+ private:
+ pointer m_ptr;
+ /// @endcond
+};
+
+//!Returns a.get() == b.get().
+//!Does not throw
+template<class T, class U, class VP> inline
+bool operator==(intrusive_ptr<T, VP> const & a,
+ intrusive_ptr<U, VP> const & b)
+{ return a.get() == b.get(); }
+
+//!Returns a.get() != b.get().
+//!Does not throw
+template<class T, class U, class VP> inline
+bool operator!=(intrusive_ptr<T, VP> const & a,
+ intrusive_ptr<U, VP> const & b)
+{ return a.get() != b.get(); }
+
+//!Returns a.get() == b.
+//!Does not throw
+template<class T, class VP> inline
+bool operator==(intrusive_ptr<T, VP> const & a,
+ const typename intrusive_ptr<T, VP>::pointer &b)
+{ return a.get() == b; }
+
+//!Returns a.get() != b.
+//!Does not throw
+template<class T, class VP> inline
+bool operator!=(intrusive_ptr<T, VP> const & a,
+ const typename intrusive_ptr<T, VP>::pointer &b)
+{ return a.get() != b; }
+
+//!Returns a == b.get().
+//!Does not throw
+template<class T, class VP> inline
+bool operator==(const typename intrusive_ptr<T, VP>::pointer &a,
+ intrusive_ptr<T, VP> const & b)
+{ return a == b.get(); }
+
+//!Returns a != b.get().
+//!Does not throw
+template<class T, class VP> inline
+bool operator!=(const typename intrusive_ptr<T, VP>::pointer &a,
+ intrusive_ptr<T, VP> const & b)
+{ return a != b.get(); }
+
+//!Returns a.get() < b.get().
+//!Does not throw
+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());
+}
+
+//!Exchanges the contents of the two intrusive_ptrs.
+//!Does not throw
+template<class T, class VP> inline
+void swap(intrusive_ptr<T, VP> & lhs,
+ intrusive_ptr<T, VP> & rhs)
+{ lhs.swap(rhs); }
+
+// operator<<
+template<class E, class T, class Y, class VP>
+inline std::basic_ostream<E, T> & operator<<
+ (std::basic_ostream<E, T> & os, intrusive_ptr<Y, VP> const & p)
+{ os << p.get(); return os; }
+
+//!Returns p.get().
+//!Does not throw
+template<class T, class VP>
+inline typename boost::interprocess::intrusive_ptr<T, VP>::pointer
+ to_raw_pointer(intrusive_ptr<T, VP> p)
+{ return p.get(); }
+
+/*Emulates static cast operator. Does not throw*/
+/*
+template<class T, class U, class VP>
+inline boost::interprocess::intrusive_ptr<T, VP> static_pointer_cast
+ (boost::interprocess::intrusive_ptr<U, VP> const & p)
+{ return do_static_cast<U>(p.get()); }
+*/
+/*Emulates const cast operator. Does not throw*/
+/*
+template<class T, class U, class VP>
+inline boost::interprocess::intrusive_ptr<T, VP> const_pointer_cast
+ (boost::interprocess::intrusive_ptr<U, VP> const & p)
+{ return do_const_cast<U>(p.get()); }
+*/
+
+/*Emulates dynamic cast operator. Does not throw*/
+/*
+template<class T, class U, class VP>
+inline boost::interprocess::intrusive_ptr<T, VP> dynamic_pointer_cast
+ (boost::interprocess::intrusive_ptr<U, VP> const & p)
+{ return do_dynamic_cast<U>(p.get()); }
+*/
+
+/*Emulates reinterpret cast operator. Does not throw*/
+/*
+template<class T, class U, class VP>
+inline boost::interprocess::intrusive_ptr<T, VP>reinterpret_pointer_cast
+ (boost::interprocess::intrusive_ptr<U, VP> const & p)
+{ return do_reinterpret_cast<U>(p.get()); }
+*/
+
+} // namespace interprocess
+
+/// @cond
+
+#if defined(_MSC_VER) && (_MSC_VER < 1400)
+//!Returns p.get().
+//!Does not throw
+template<class T, class VP>
+inline T *to_raw_pointer(boost::interprocess::intrusive_ptr<T, VP> p)
+{ return p.get(); }
+#endif
+
+/// @endcond
+
+} // namespace boost
+
+#include <boost/interprocess/detail/config_end.hpp>
+
+#endif // #ifndef BOOST_INTERPROCESS_INTRUSIVE_PTR_HPP_INCLUDED
diff --git a/boost/interprocess/smart_ptr/scoped_ptr.hpp b/boost/interprocess/smart_ptr/scoped_ptr.hpp
new file mode 100644
index 0000000..1885838
--- /dev/null
+++ b/boost/interprocess/smart_ptr/scoped_ptr.hpp
@@ -0,0 +1,164 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// This file is the adaptation for Interprocess of boost/scoped_ptr.hpp
+//
+// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
+// (C) Copyright Peter Dimov 2001, 2002
+// (C) Copyright Ion Gaztanaga 2006. 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)
+//
+// See http://www.boost.org/libs/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTERPROCESS_SCOPED_PTR_HPP_INCLUDED
+#define BOOST_INTERPROCESS_SCOPED_PTR_HPP_INCLUDED
+
+#include <boost/interprocess/detail/config_begin.hpp>
+#include <boost/interprocess/detail/workaround.hpp>
+#include <boost/interprocess/detail/pointer_type.hpp>
+#include <boost/interprocess/detail/utilities.hpp>
+#include <boost/assert.hpp>
+
+//!\file
+//!Describes the smart pointer scoped_ptr
+
+namespace boost {
+namespace interprocess {
+
+//!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
+//!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
+//!offset_ptr<void>, the internal pointer will be offset_ptr<T>).
+template<class T, class Deleter>
+class scoped_ptr
+ : private Deleter
+{
+ /// @cond
+ 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
+
+ public:
+
+ typedef T element_type;
+ typedef Deleter deleter_type;
+ typedef typename ipcdetail::pointer_type<T, Deleter>::type pointer;
+
+ //!Constructs a scoped_ptr, storing a copy of p(which can be 0) and d.
+ //!Does not throw.
+ explicit scoped_ptr(const pointer &p = 0, const Deleter &d = Deleter())
+ : 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.
+ //!calling the operator() of the stored deleter. Never throws
+ ~scoped_ptr()
+ {
+ if(m_ptr){
+ Deleter &del = static_cast<Deleter&>(*this);
+ del(m_ptr);
+ }
+ }
+
+ //!Deletes the object pointed to by the stored pointer and then
+ //!stores a copy of p. Never throws
+ void reset(const pointer &p = 0) // never throws
+ { BOOST_ASSERT(p == 0 || p != m_ptr); this_type(p).swap(*this); }
+
+ //!Deletes the object pointed to by the stored pointer and then
+ //!stores a copy of p and a copy of d.
+ void reset(const pointer &p, const Deleter &d) // never throws
+ { BOOST_ASSERT(p == 0 || p != m_ptr); this_type(p, d).swap(*this); }
+
+ //!Assigns internal pointer as 0 and returns previous pointer. This will
+ //!avoid deletion on destructor
+ pointer release()
+ { pointer tmp(m_ptr); m_ptr = 0; return tmp; }
+
+ //!Returns a reference to the object pointed to by the stored pointer.
+ //!Never throws.
+ reference operator*() const
+ { BOOST_ASSERT(m_ptr != 0); return *m_ptr; }
+
+ //!Returns the internal stored pointer.
+ //!Never throws.
+ pointer &operator->()
+ { BOOST_ASSERT(m_ptr != 0); return m_ptr; }
+
+ //!Returns the internal stored pointer.
+ //!Never throws.
+ const pointer &operator->() const
+ { BOOST_ASSERT(m_ptr != 0); return m_ptr; }
+
+ //!Returns the stored pointer.
+ //!Never throws.
+ pointer & get()
+ { return m_ptr; }
+
+ //!Returns the stored pointer.
+ //!Never throws.
+ const pointer & get() const
+ { return m_ptr; }
+
+ typedef pointer this_type::*unspecified_bool_type;
+
+ //!Conversion to bool
+ //!Never throws
+ operator unspecified_bool_type() const
+ { return m_ptr == 0? 0: &this_type::m_ptr; }
+
+ //!Returns true if the stored pointer is 0.
+ //!Never throws.
+ bool operator! () const // never throws
+ { return m_ptr == 0; }
+
+ //!Exchanges the internal pointer and deleter with other scoped_ptr
+ //!Never throws.
+ void swap(scoped_ptr & b) // never throws
+ { ipcdetail::do_swap<Deleter>(*this, b); ipcdetail::do_swap(m_ptr, b.m_ptr); }
+
+ /// @cond
+ private:
+ pointer m_ptr;
+ /// @endcond
+};
+
+//!Exchanges the internal pointer and deleter with other scoped_ptr
+//!Never throws.
+template<class T, class D> inline
+void swap(scoped_ptr<T, D> & a, scoped_ptr<T, D> & b)
+{ a.swap(b); }
+
+//!Returns a copy of the stored pointer
+//!Never throws
+template<class T, class D> inline
+typename scoped_ptr<T, D>::pointer to_raw_pointer(scoped_ptr<T, D> const & p)
+{ return p.get(); }
+
+} // namespace interprocess
+
+/// @cond
+
+#if defined(_MSC_VER) && (_MSC_VER < 1400)
+template<class T, class D> inline
+T *to_raw_pointer(boost::interprocess::scoped_ptr<T, D> const & p)
+{ return p.get(); }
+#endif
+
+/// @endcond
+
+} // namespace boost
+
+#include <boost/interprocess/detail/config_end.hpp>
+
+#endif // #ifndef BOOST_INTERPROCESS_SCOPED_PTR_HPP_INCLUDED
diff --git a/boost/interprocess/smart_ptr/shared_ptr.hpp b/boost/interprocess/smart_ptr/shared_ptr.hpp
new file mode 100644
index 0000000..6182907
--- /dev/null
+++ b/boost/interprocess/smart_ptr/shared_ptr.hpp
@@ -0,0 +1,417 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// This file is the adaptation for Interprocess of boost/shared_ptr.hpp
+//
+// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
+// (C) Copyright Peter Dimov 2001, 2002, 2003
+// (C) Copyright Ion Gaztanaga 2006-2011.
+// 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)
+//
+// See http://www.boost.org/libs/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTERPROCESS_SHARED_PTR_HPP_INCLUDED
+#define BOOST_INTERPROCESS_SHARED_PTR_HPP_INCLUDED
+
+#include <boost/interprocess/detail/config_begin.hpp>
+#include <boost/interprocess/detail/workaround.hpp>
+
+#include <boost/interprocess/detail/utilities.hpp>
+#include <boost/interprocess/detail/cast_tags.hpp>
+#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/interprocess/detail/type_traits.hpp>
+#include <boost/interprocess/allocators/allocator.hpp>
+#include <boost/interprocess/smart_ptr/deleter.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/intrusive/pointer_traits.hpp>
+
+#include <algorithm> // for std::swap
+#include <functional> // for std::less
+#include <typeinfo> // for std::bad_cast
+#include <iosfwd> // for std::basic_ostream
+
+//!\file
+//!Describes the smart pointer shared_ptr
+
+namespace boost{
+namespace interprocess{
+
+template<class T, class VoidAllocator, class Deleter> class weak_ptr;
+template<class T, class VoidAllocator, class Deleter> class enable_shared_from_this;
+
+namespace ipcdetail{
+
+template<class T, class VoidAllocator, class Deleter>
+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){
+ pe->_internal_weak_this._internal_assign(pn);
+ }
+}
+
+template<class T, class VoidAllocator, class Deleter>
+inline void sp_enable_shared_from_this(shared_count<T, VoidAllocator, Deleter> const &, ...)
+{}
+
+} // 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
+//!it is destroyed or reset.
+//!
+//!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
+//!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
+//!offset_ptr<void>, the internal pointer will be offset_ptr<T>).
+//!
+//!Because the implementation uses reference counting, cycles of shared_ptr
+//!instances will not be reclaimed. For example, if main() holds a
+//!shared_ptr to A, which directly or indirectly holds a shared_ptr back
+//!to A, A's use count will be 2. Destruction of the original shared_ptr
+//!will leave A dangling with a use count of 1.
+//!Use weak_ptr to "break cycles."
+template<class T, class VoidAllocator, class Deleter>
+class shared_ptr
+{
+ /// @cond
+ private:
+ typedef shared_ptr<T, VoidAllocator, Deleter> this_type;
+ /// @endcond
+
+ public:
+
+ typedef T element_type;
+ typedef T value_type;
+ typedef typename boost::intrusive::
+ pointer_traits<typename VoidAllocator::pointer>::template
+ rebind_pointer<T>::type pointer;
+ typedef typename ipcdetail::add_reference
+ <value_type>::type reference;
+ typedef typename ipcdetail::add_reference
+ <const value_type>::type const_reference;
+ typedef typename boost::intrusive::
+ pointer_traits<typename VoidAllocator::pointer>::template
+ rebind_pointer<const Deleter>::type const_deleter_pointer;
+ typedef typename boost::intrusive::
+ pointer_traits<typename VoidAllocator::pointer>::template
+ rebind_pointer<const VoidAllocator>::type const_allocator_pointer;
+
+ BOOST_COPYABLE_AND_MOVABLE(shared_ptr)
+ public:
+
+ //!Constructs an empty shared_ptr.
+ //!Use_count() == 0 && get()== 0.
+ shared_ptr()
+ : m_pn() // never throws
+ {}
+
+ //!Constructs a shared_ptr that owns the pointer p. Auxiliary data will be allocated
+ //!with a copy of a and the object will be deleted with a copy of d.
+ //!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::
+ pointer_traits<pointer>::template
+ rebind_pointer<T>::type ParameterPointer;
+
+ 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) );
+ }
+
+
+ //!Constructs a shared_ptr that shares ownership with r 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
+ //!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
+ //!a copy of the pointer stored in r.
+ template<class Y>
+ explicit shared_ptr(weak_ptr<Y, VoidAllocator, Deleter> const & r)
+ : m_pn(r.m_pn) // may throw
+ {}
+
+ //!Move-Constructs a shared_ptr that takes ownership of other resource and
+ //!other is put in default-constructed state.
+ //!Throws: nothing.
+ explicit shared_ptr(BOOST_RV_REF(shared_ptr) other)
+ : m_pn()
+ { this->swap(other); }
+
+ /// @cond
+ 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)
+ {}
+
+ 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)
+ {}
+
+ 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)
+ {
+ if(!m_pn.to_raw_pointer()){ // need to allocate new counter -- the cast failed
+ m_pn = ipcdetail::shared_count<T, VoidAllocator, Deleter>();
+ }
+ }
+ /// @endcond
+
+ //!Equivalent to shared_ptr(r).swap(*this).
+ //!Never throws
+ template<class Y>
+ shared_ptr & operator=(shared_ptr<Y, VoidAllocator, Deleter> const & r)
+ {
+ m_pn = r.m_pn; // shared_count::op= doesn't throw
+ return *this;
+ }
+
+ //!Equivalent to shared_ptr(r).swap(*this).
+ //!Never throws
+ shared_ptr & operator=(BOOST_COPY_ASSIGN_REF(shared_ptr) r)
+ {
+ m_pn = r.m_pn; // shared_count::op= doesn't throw
+ return *this;
+ }
+
+ //!Move-assignment. Equivalent to shared_ptr(other).swap(*this).
+ //!Never throws
+ shared_ptr & operator=(BOOST_RV_REF(shared_ptr) other) // never throws
+ {
+ this_type(other).swap(*this);
+ return *this;
+ }
+
+ //!This is equivalent to:
+ //!this_type().swap(*this);
+ void reset()
+ {
+ 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::
+ pointer_traits<Pointer>::template
+ 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);
+ }
+
+ template<class Y>
+ void reset(shared_ptr<Y, VoidAllocator, Deleter> const & r, const pointer &p)
+ {
+ this_type(r, p).swap(*this);
+ }
+
+ //!Returns a reference to the
+ //!pointed type
+ reference operator* () const // never throws
+ { BOOST_ASSERT(m_pn.to_raw_pointer() != 0); return *m_pn.to_raw_pointer(); }
+
+ //!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
+ //!to the owned object
+ pointer get() const // never throws
+ { return m_pn.to_raw_pointer(); }
+
+ /// @cond
+ // 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
+
+ //!Not operator.
+ //!Returns true if this->get() != 0, false otherwise
+ bool operator! () const // never throws
+ { return !m_pn.to_raw_pointer(); }
+
+ //!Returns use_count() == 1.
+ //!unique() might be faster than use_count()
+ bool unique() const // never throws
+ { return m_pn.unique(); }
+
+ //!Returns the number of shared_ptr objects, *this included,
+ //!that share ownership with *this, or an unspecified nonnegative
+ //!value when *this is empty.
+ //!use_count() is not necessarily efficient. Use only for
+ //!debugging and testing purposes, not for production code.
+ long use_count() const // never throws
+ { return m_pn.use_count(); }
+
+ //!Exchanges the contents of the two
+ //!smart pointers.
+ void swap(shared_ptr<T, VoidAllocator, Deleter> & other) // never throws
+ { m_pn.swap(other.m_pn); }
+
+ /// @cond
+
+ template<class T2, class A2, class Deleter2>
+ bool _internal_less(shared_ptr<T2, A2, Deleter2> const & rhs) const
+ { return m_pn < rhs.m_pn; }
+
+ const_deleter_pointer get_deleter() const
+ { return m_pn.get_deleter(); }
+
+// const_allocator_pointer get_allocator() const
+// { return m_pn.get_allocator(); }
+
+ private:
+
+ template<class T2, class A2, class Deleter2> friend 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
+}; // shared_ptr
+
+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
+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
+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
+void swap(shared_ptr<T, VoidAllocator, Deleter> & a, shared_ptr<T, VoidAllocator, Deleter> & b)
+{ a.swap(b); }
+
+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
+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
+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()); }
+
+// to_raw_pointer() enables boost::mem_fn to recognize shared_ptr
+template<class T, class VoidAllocator, class Deleter> inline
+T * to_raw_pointer(shared_ptr<T, VoidAllocator, Deleter> const & p)
+{ return p.get(); }
+
+// operator<<
+template<class E, class T, class Y, class VoidAllocator, class Deleter> inline
+std::basic_ostream<E, T> & operator<<
+ (std::basic_ostream<E, T> & os, shared_ptr<Y, VoidAllocator, Deleter> const & p)
+{ os << p.get(); return os; }
+
+//!Returns the type of a shared pointer
+//!of type T with the allocator boost::interprocess::allocator allocator
+//!and boost::interprocess::deleter deleter
+//!that can be constructed in the given managed segment type.
+template<class T, class ManagedMemory>
+struct managed_shared_ptr
+{
+ typedef typename ManagedMemory::template allocator<void>::type void_allocator;
+ typedef typename ManagedMemory::template deleter<T>::type deleter;
+ typedef shared_ptr< T, void_allocator, deleter> type;
+};
+
+//!Returns an instance of a shared pointer constructed
+//!with the default allocator and deleter from a pointer
+//!of type T that has been allocated in the passed managed segment
+template<class T, class ManagedMemory>
+inline typename managed_shared_ptr<T, ManagedMemory>::type
+ make_managed_shared_ptr(T *constructed_object, ManagedMemory &managed_memory)
+{
+ return typename managed_shared_ptr<T, ManagedMemory>::type
+ ( constructed_object
+ , managed_memory.template get_allocator<void>()
+ , managed_memory.template get_deleter<T>()
+ );
+}
+
+//!Returns an instance of a shared pointer constructed
+//!with the default allocator and deleter from a pointer
+//!of type T that has been allocated in the passed managed segment.
+//!Does not throw, return null shared pointer in error.
+template<class T, class ManagedMemory>
+inline typename managed_shared_ptr<T, ManagedMemory>::type
+ make_managed_shared_ptr(T *constructed_object, ManagedMemory &managed_memory, std::nothrow_t)
+{
+ try{
+ return typename managed_shared_ptr<T, ManagedMemory>::type
+ ( constructed_object
+ , managed_memory.template get_allocator<void>()
+ , managed_memory.template get_deleter<T>()
+ );
+ }
+ catch(...){
+ return typename managed_shared_ptr<T, ManagedMemory>::type();
+ }
+}
+
+
+} // namespace interprocess
+
+/// @cond
+
+#if defined(_MSC_VER) && (_MSC_VER < 1400)
+// to_raw_pointer() enables boost::mem_fn to recognize shared_ptr
+template<class T, class VoidAllocator, class Deleter> inline
+T * to_raw_pointer(boost::interprocess::shared_ptr<T, VoidAllocator, Deleter> const & p)
+{ return p.get(); }
+#endif
+
+/// @endcond
+
+} // namespace boost
+
+#include <boost/interprocess/detail/config_end.hpp>
+
+#endif // #ifndef BOOST_INTERPROCESS_SHARED_PTR_HPP_INCLUDED
diff --git a/boost/interprocess/smart_ptr/unique_ptr.hpp b/boost/interprocess/smart_ptr/unique_ptr.hpp
new file mode 100644
index 0000000..547038b
--- /dev/null
+++ b/boost/interprocess/smart_ptr/unique_ptr.hpp
@@ -0,0 +1,551 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTERPROCESS_UNIQUE_PTR_HPP_INCLUDED
+#define BOOST_INTERPROCESS_UNIQUE_PTR_HPP_INCLUDED
+
+#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>
+
+//!\file
+//!Describes the smart pointer unique_ptr
+
+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(); }
+
+
+//!Returns the type of a unique pointer
+//!of type T with boost::interprocess::deleter deleter
+//!that can be constructed in the given managed segment type.
+template<class T, class ManagedMemory>
+struct managed_unique_ptr
+{
+ typedef unique_ptr
+ < T
+ , typename ManagedMemory::template deleter<T>::type
+ > type;
+};
+
+//!Returns an instance of a unique pointer constructed
+//!with boost::interproces::deleter from a pointer
+//!of type T that has been allocated in the passed managed segment
+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
+ (constructed_object, managed_memory.template get_deleter<T>());
+}
+
+} //namespace interprocess{
+} //namespace boost{
+
+#include <boost/interprocess/detail/config_end.hpp>
+
+#endif //#ifndef BOOST_INTERPROCESS_UNIQUE_PTR_HPP_INCLUDED
diff --git a/boost/interprocess/smart_ptr/weak_ptr.hpp b/boost/interprocess/smart_ptr/weak_ptr.hpp
new file mode 100644
index 0000000..7126d05
--- /dev/null
+++ b/boost/interprocess/smart_ptr/weak_ptr.hpp
@@ -0,0 +1,260 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// 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.
+// 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)
+//
+// See http://www.boost.org/libs/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTERPROCESS_WEAK_PTR_HPP_INCLUDED
+#define BOOST_INTERPROCESS_WEAK_PTR_HPP_INCLUDED
+
+#include <boost/interprocess/detail/config_begin.hpp>
+#include <boost/interprocess/detail/workaround.hpp>
+
+#include <boost/interprocess/smart_ptr/shared_ptr.hpp>
+#include <boost/detail/no_exceptions_support.hpp>
+#include <boost/interprocess/allocators/allocator.hpp>
+#include <boost/interprocess/smart_ptr/deleter.hpp>
+#include <boost/intrusive/pointer_traits.hpp>
+
+//!\file
+//!Describes the smart pointer weak_ptr.
+
+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
+//!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
+//!weak_ptr instances that refer to the deleted object will fail: the constructor
+//!will throw an exception of type bad_weak_ptr, and weak_ptr::lock will
+//!return an empty shared_ptr.
+//!
+//!Every weak_ptr meets the CopyConstructible and Assignable requirements
+//!of the C++ Standard Library, and so can be used in standard library containers.
+//!Comparison operators are supplied so that weak_ptr works with the standard
+//!library's associative containers.
+//!
+//!weak_ptr operations never throw exceptions.
+//!
+//!The class template is parameterized on T, the type of the object pointed to.
+template<class T, class A, class D>
+class weak_ptr
+{
+ /// @cond
+ private:
+ // Borland 5.5.1 specific workarounds
+ typedef weak_ptr<T, A, D> this_type;
+ typedef typename boost::intrusive::
+ pointer_traits<typename A::pointer>::template
+ rebind_pointer<T>::type pointer;
+ typedef typename ipcdetail::add_reference
+ <T>::type reference;
+ typedef typename ipcdetail::add_reference
+ <T>::type const_reference;
+ /// @endcond
+
+ public:
+ typedef T element_type;
+ typedef T value_type;
+
+ //!Effects: Constructs an empty weak_ptr.
+ //!Postconditions: use_count() == 0.
+ weak_ptr()
+ : m_pn() // never throws
+ {}
+ // generated copy constructor, assignment, destructor are fine
+ //
+ // The "obvious" converting constructor implementation:
+ //
+ // template<class Y>
+ // weak_ptr(weak_ptr<Y> const & r): m_px(r.m_px), m_pn(r.m_pn) // never throws
+ // {
+ // }
+ //
+ // has a serious problem.
+ //
+ // r.m_px may already have been invalidated. The m_px(r.m_px)
+ // conversion may require access to *r.m_px (virtual inheritance).
+ //
+ // It is not possible to avoid spurious access violations since
+ // in multithreaded programs r.m_px may be invalidated at any point.
+
+ //!Effects: If r is empty, constructs an empty weak_ptr; otherwise,
+ //!constructs a weak_ptr that shares ownership with r as if by storing a
+ //!copy of the pointer stored in r.
+ //!
+ //!Postconditions: use_count() == r.use_count().
+ //!
+ //!Throws: nothing.
+ 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());
+ }
+
+ //!Effects: If r is empty, constructs an empty weak_ptr; otherwise,
+ //!constructs a weak_ptr that shares ownership with r as if by storing a
+ //!copy of the pointer stored in r.
+ //!
+ //!Postconditions: use_count() == r.use_count().
+ //!
+ //!Throws: nothing.
+ template<class Y>
+ weak_ptr(shared_ptr<Y, A, D> const & r)
+ : m_pn(r.m_pn) // never throws
+ {}
+
+ //!Effects: Equivalent to weak_ptr(r).swap(*this).
+ //!
+ //!Throws: nothing.
+ //!
+ //!Notes: The implementation is free to meet the effects (and the
+ //!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();
+ m_pn = r.m_pn;
+ m_pn.set_pointer(ref.get());
+ return *this;
+ }
+
+ //!Effects: Equivalent to weak_ptr(r).swap(*this).
+ //!
+ //!Throws: nothing.
+ //!
+ //!Notes: The implementation is free to meet the effects (and the
+ //!implied guarantees) via different means, without creating a temporary.
+ template<class Y>
+ weak_ptr & operator=(shared_ptr<Y, A, D> const & r) // never throws
+ { m_pn = r.m_pn; return *this; }
+
+ //!Returns: expired()? shared_ptr<T>(): shared_ptr<T>(*this).
+ //!
+ //!Throws: nothing.
+ shared_ptr<T, A, D> lock() const // never throws
+ {
+ // optimization: avoid throw overhead
+ if(expired()){
+ return shared_ptr<element_type, A, D>();
+ }
+ BOOST_TRY{
+ return shared_ptr<element_type, A, D>(*this);
+ }
+ BOOST_CATCH(bad_weak_ptr const &){
+ // Q: how can we get here?
+ // A: another thread may have invalidated r after the use_count test above.
+ return shared_ptr<element_type, A, D>();
+ }
+ BOOST_CATCH_END
+ }
+
+ //!Returns: 0 if *this is empty; otherwise, the number of shared_ptr objects
+ //!that share ownership with *this.
+ //!
+ //!Throws: nothing.
+ //!
+ //!Notes: use_count() is not necessarily efficient. Use only for debugging and
+ //!testing purposes, not for production code.
+ long use_count() const // never throws
+ { return m_pn.use_count(); }
+
+ //!Returns: Returns: use_count() == 0.
+ //!
+ //!Throws: nothing.
+ //!
+ //!Notes: expired() may be faster than use_count().
+ bool expired() const // never throws
+ { return m_pn.use_count() == 0; }
+
+ //!Effects: Equivalent to:
+ //!weak_ptr().swap(*this).
+ void reset() // never throws in 1.30+
+ { this_type().swap(*this); }
+
+ //!Effects: Exchanges the contents of the two
+ //!smart pointers.
+ //!
+ //!Throws: nothing.
+ void swap(this_type & other) // never throws
+ { ipcdetail::do_swap(m_pn, other.m_pn); }
+
+ /// @cond
+ 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)
+ {
+
+ m_pn = pn2;
+ }
+
+ private:
+
+ template<class T2, class A2, class D2> friend class shared_ptr;
+ template<class T2, class A2, class D2> friend class weak_ptr;
+
+ ipcdetail::weak_count<T, A, D> m_pn; // reference counter
+ /// @endcond
+}; // weak_ptr
+
+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); }
+
+template<class T, class A, class D> inline
+void swap(weak_ptr<T, A, D> & a, weak_ptr<T, A, D> & b)
+{ a.swap(b); }
+
+//!Returns the type of a weak pointer
+//!of type T with the allocator boost::interprocess::allocator allocator
+//!and boost::interprocess::deleter deleter
+//!that can be constructed in the given managed segment type.
+template<class T, class ManagedMemory>
+struct managed_weak_ptr
+{
+ typedef weak_ptr
+ < T
+ , typename ManagedMemory::template allocator<void>::type
+ , typename ManagedMemory::template deleter<T>::type
+ > type;
+};
+
+//!Returns an instance of a weak pointer constructed
+//!with the default allocator and deleter from a pointer
+//!of type T that has been allocated in the passed managed segment
+template<class T, class ManagedMemory>
+inline typename managed_weak_ptr<T, ManagedMemory>::type
+ make_managed_weak_ptr(T *constructed_object, ManagedMemory &managed_memory)
+{
+ return typename managed_weak_ptr<T, ManagedMemory>::type
+ ( constructed_object
+ , managed_memory.template get_allocator<void>()
+ , managed_memory.template get_deleter<T>()
+ );
+}
+
+} // namespace interprocess
+} // namespace boost
+
+#include <boost/interprocess/detail/config_end.hpp>
+
+#endif // #ifndef BOOST_INTERPROCESS_WEAK_PTR_HPP_INCLUDED