1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2005-2008. 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_IN_PLACE_INTERFACE_HPP
12 #define BOOST_INTERPROCESS_IN_PLACE_INTERFACE_HPP
14 #if (defined _MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/interprocess/detail/config_begin.hpp>
19 #include <boost/interprocess/detail/workaround.hpp>
20 #include <boost/interprocess/detail/type_traits.hpp>
21 #include <typeinfo> //typeid
24 //!Describes an abstract interface for placement construction and destruction.
27 namespace interprocess
{
30 struct in_place_interface
32 in_place_interface(std::size_t alignm
, std::size_t sz
, const char *tname
)
33 : alignment(alignm
), size(sz
), type_name(tname
)
36 std::size_t alignment
;
38 const char *type_name
;
40 virtual void construct_n(void *mem
, std::size_t num
, std::size_t &constructed
) = 0;
41 virtual void destroy_n(void *mem
, std::size_t num
, std::size_t &destroyed
) = 0;
42 virtual ~in_place_interface(){}
46 struct placement_destroy
: public in_place_interface
49 : in_place_interface(detail::alignment_of
<T
>::value
, sizeof(T
), typeid(T
).name())
52 virtual void destroy_n(void *mem
, std::size_t num
, std::size_t &destroyed
)
54 T
* memory
= static_cast<T
*>(mem
);
55 for(destroyed
= 0; destroyed
< num
; ++destroyed
)
59 virtual void construct_n(void *, std::size_t, std::size_t &) {}
62 void destroy(void *mem
)
63 { static_cast<T
*>(mem
)->~T(); }
68 } //namespace boost { namespace interprocess { namespace detail {
70 #include <boost/interprocess/detail/config_end.hpp>
72 #endif //#ifndef BOOST_INTERPROCESS_IN_PLACE_INTERFACE_HPP