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