Chris@16: ////////////////////////////////////////////////////////////////////////////// Chris@16: // Chris@16: // (C) Copyright Ion Gaztanaga 2005-2012. 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_IN_PLACE_INTERFACE_HPP Chris@16: #define BOOST_INTERPROCESS_IN_PLACE_INTERFACE_HPP 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@16: # pragma once Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@101: #include //alignment_of, aligned_storage Chris@16: #include //typeid Chris@16: Chris@16: //!\file Chris@16: //!Describes an abstract interface for placement construction and destruction. Chris@16: Chris@16: namespace boost { Chris@16: namespace interprocess { Chris@16: namespace ipcdetail { Chris@16: Chris@16: struct in_place_interface Chris@16: { Chris@16: in_place_interface(std::size_t alignm, std::size_t sz, const char *tname) Chris@16: : alignment(alignm), size(sz), type_name(tname) Chris@16: {} Chris@16: Chris@16: std::size_t alignment; Chris@16: std::size_t size; Chris@16: const char *type_name; Chris@16: Chris@16: virtual void construct_n(void *mem, std::size_t num, std::size_t &constructed) = 0; Chris@16: virtual void destroy_n(void *mem, std::size_t num, std::size_t &destroyed) = 0; Chris@16: virtual ~in_place_interface(){} Chris@16: }; Chris@16: Chris@16: template Chris@16: struct placement_destroy : public in_place_interface Chris@16: { Chris@16: placement_destroy() Chris@101: : in_place_interface(::boost::container::container_detail::alignment_of::value, sizeof(T), typeid(T).name()) Chris@16: {} Chris@16: Chris@16: virtual void destroy_n(void *mem, std::size_t num, std::size_t &destroyed) Chris@16: { Chris@16: T* memory = static_cast(mem); Chris@16: for(destroyed = 0; destroyed < num; ++destroyed) Chris@16: (memory++)->~T(); Chris@16: } Chris@16: Chris@16: virtual void construct_n(void *, std::size_t, std::size_t &) {} Chris@16: Chris@16: private: Chris@16: void destroy(void *mem) Chris@16: { static_cast(mem)->~T(); } Chris@16: }; Chris@16: Chris@16: } Chris@16: } Chris@16: } //namespace boost { namespace interprocess { namespace ipcdetail { Chris@16: Chris@16: #include Chris@16: Chris@16: #endif //#ifndef BOOST_INTERPROCESS_IN_PLACE_INTERFACE_HPP