////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/interprocess for documentation. // ////////////////////////////////////////////////////////////////////////////// #ifndef BOOST_INTERPROCESS_IN_PLACE_INTERFACE_HPP #define BOOST_INTERPROCESS_IN_PLACE_INTERFACE_HPP #if (defined _MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif #include #include #include #include #include //typeid //!\file //!Describes an abstract interface for placement construction and destruction. namespace boost { namespace interprocess { namespace ipcdetail { struct in_place_interface { in_place_interface(std::size_t alignm, std::size_t sz, const char *tname) : alignment(alignm), size(sz), type_name(tname) {} std::size_t alignment; std::size_t size; const char *type_name; virtual void construct_n(void *mem, std::size_t num, std::size_t &constructed) = 0; virtual void destroy_n(void *mem, std::size_t num, std::size_t &destroyed) = 0; virtual ~in_place_interface(){} }; template struct placement_destroy : public in_place_interface { placement_destroy() : in_place_interface(::boost::alignment_of::value, sizeof(T), typeid(T).name()) {} virtual void destroy_n(void *mem, std::size_t num, std::size_t &destroyed) { T* memory = static_cast(mem); for(destroyed = 0; destroyed < num; ++destroyed) (memory++)->~T(); } virtual void construct_n(void *, std::size_t, std::size_t &) {} private: void destroy(void *mem) { static_cast(mem)->~T(); } }; } } } //namespace boost { namespace interprocess { namespace ipcdetail { #include #endif //#ifndef BOOST_INTERPROCESS_IN_PLACE_INTERFACE_HPP