1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2005-2012. 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 #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/interprocess/detail/type_traits.hpp>
25 #include <boost/container/detail/type_traits.hpp> //alignment_of, aligned_storage
26 #include <typeinfo> //typeid
29 //!Describes an abstract interface for placement construction and destruction.
32 namespace interprocess {
35 struct in_place_interface
37 in_place_interface(std::size_t alignm, std::size_t sz, const char *tname)
38 : alignment(alignm), size(sz), type_name(tname)
41 std::size_t alignment;
43 const char *type_name;
45 virtual void construct_n(void *mem, std::size_t num, std::size_t &constructed) = 0;
46 virtual void destroy_n(void *mem, std::size_t num, std::size_t &destroyed) = 0;
47 virtual ~in_place_interface(){}
51 struct placement_destroy : public in_place_interface
54 : in_place_interface(::boost::container::container_detail::alignment_of<T>::value, sizeof(T), typeid(T).name())
57 virtual void destroy_n(void *mem, std::size_t num, std::size_t &destroyed)
59 T* memory = static_cast<T*>(mem);
60 for(destroyed = 0; destroyed < num; ++destroyed)
64 virtual void construct_n(void *, std::size_t, std::size_t &) {}
67 void destroy(void *mem)
68 { static_cast<T*>(mem)->~T(); }
73 } //namespace boost { namespace interprocess { namespace ipcdetail {
75 #include <boost/interprocess/detail/config_end.hpp>
77 #endif //#ifndef BOOST_INTERPROCESS_IN_PLACE_INTERFACE_HPP