1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2006-2014. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/interprocess for documentation.
9 //////////////////////////////////////////////////////////////////////////////
11 #ifndef BOOST_INTERPROCESS_UNIQUE_PTR_HPP_INCLUDED
12 #define BOOST_INTERPROCESS_UNIQUE_PTR_HPP_INCLUDED
14 #ifndef BOOST_CONFIG_HPP
15 # include <boost/config.hpp>
18 #if defined(BOOST_HAS_PRAGMA_ONCE)
22 #include <boost/interprocess/detail/config_begin.hpp>
23 #include <boost/interprocess/detail/workaround.hpp>
24 #include <boost/move/unique_ptr.hpp>
27 //!This header provides utilities to define a unique_ptr that plays nicely with managed segments.
30 namespace interprocess{
32 //For backwards compatibility
33 using ::boost::movelib::unique_ptr;
35 //!Returns the type of a unique pointer
36 //!of type T with boost::interprocess::deleter deleter
37 //!that can be constructed in the given managed segment type.
38 template<class T, class ManagedMemory>
39 struct managed_unique_ptr
41 typedef boost::movelib::unique_ptr
43 , typename ManagedMemory::template deleter<T>::type
47 //!Returns an instance of a unique pointer constructed
48 //!with boost::interproces::deleter from a pointer
49 //!of type T that has been allocated in the passed managed segment
50 template<class T, class ManagedMemory>
51 inline typename managed_unique_ptr<T, ManagedMemory>::type
52 make_managed_unique_ptr(T *constructed_object, ManagedMemory &managed_memory)
54 return typename managed_unique_ptr<T, ManagedMemory>::type
55 (constructed_object, managed_memory.template get_deleter<T>());
58 } //namespace interprocess{
61 #include <boost/interprocess/detail/config_end.hpp>
63 #endif //#ifndef BOOST_INTERPROCESS_UNIQUE_PTR_HPP_INCLUDED