Chris@16: ////////////////////////////////////////////////////////////////////////////// Chris@16: // Chris@101: // (C) Copyright Ion Gaztanaga 2006-2014. Distributed under the Boost Chris@16: // Software License, Version 1.0. (See accompanying file Chris@16: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // See http://www.boost.org/libs/interprocess for documentation. Chris@16: // Chris@16: ////////////////////////////////////////////////////////////////////////////// Chris@16: Chris@16: #ifndef BOOST_INTERPROCESS_UNIQUE_PTR_HPP_INCLUDED Chris@16: #define BOOST_INTERPROCESS_UNIQUE_PTR_HPP_INCLUDED Chris@16: Chris@101: #ifndef BOOST_CONFIG_HPP Chris@101: # include Chris@101: #endif Chris@101: # Chris@101: #if defined(BOOST_HAS_PRAGMA_ONCE) Chris@101: # pragma once Chris@101: #endif Chris@101: Chris@16: #include Chris@16: #include Chris@101: #include Chris@16: Chris@16: //!\file Chris@101: //!This header provides utilities to define a unique_ptr that plays nicely with managed segments. Chris@16: Chris@16: namespace boost{ Chris@16: namespace interprocess{ Chris@16: Chris@101: //For backwards compatibility Chris@101: using ::boost::movelib::unique_ptr; Chris@16: Chris@16: //!Returns the type of a unique pointer Chris@16: //!of type T with boost::interprocess::deleter deleter Chris@16: //!that can be constructed in the given managed segment type. Chris@16: template Chris@16: struct managed_unique_ptr Chris@16: { Chris@101: typedef boost::movelib::unique_ptr Chris@16: < T Chris@16: , typename ManagedMemory::template deleter::type Chris@16: > type; Chris@16: }; Chris@16: Chris@16: //!Returns an instance of a unique pointer constructed Chris@16: //!with boost::interproces::deleter from a pointer Chris@16: //!of type T that has been allocated in the passed managed segment Chris@16: template Chris@16: inline typename managed_unique_ptr::type Chris@16: make_managed_unique_ptr(T *constructed_object, ManagedMemory &managed_memory) Chris@16: { Chris@16: return typename managed_unique_ptr::type Chris@16: (constructed_object, managed_memory.template get_deleter()); Chris@16: } Chris@16: Chris@16: } //namespace interprocess{ Chris@16: } //namespace boost{ Chris@16: Chris@16: #include Chris@16: Chris@16: #endif //#ifndef BOOST_INTERPROCESS_UNIQUE_PTR_HPP_INCLUDED