Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:25

0001 //////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
0004 // Software License, Version 1.0. (See accompanying file
0005 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // See http://www.boost.org/libs/interprocess for documentation.
0008 //
0009 //////////////////////////////////////////////////////////////////////////////
0010 
0011 #ifndef BOOST_INTERPROCESS_IN_PLACE_INTERFACE_HPP
0012 #define BOOST_INTERPROCESS_IN_PLACE_INTERFACE_HPP
0013 
0014 #ifndef BOOST_CONFIG_HPP
0015 #  include <boost/config.hpp>
0016 #endif
0017 #
0018 #if defined(BOOST_HAS_PRAGMA_ONCE)
0019 #  pragma once
0020 #endif
0021 
0022 #include <boost/interprocess/detail/config_begin.hpp>
0023 #include <boost/interprocess/detail/workaround.hpp>
0024 #include <boost/interprocess/detail/type_traits.hpp>
0025 #include <boost/container/detail/type_traits.hpp>  //alignment_of, aligned_storage
0026 #include <typeinfo>  //typeid
0027 
0028 //!\file
0029 //!Describes an abstract interface for placement construction and destruction.
0030 
0031 namespace boost {
0032 namespace interprocess {
0033 namespace ipcdetail {
0034 
0035 struct in_place_interface
0036 {
0037    in_place_interface(std::size_t alignm, std::size_t sz, const char *tname)
0038    :  alignment(alignm), size(sz), type_name(tname)
0039    {}
0040 
0041    std::size_t alignment;
0042    std::size_t size;
0043    const char *type_name;
0044 
0045    virtual void construct_n(void *mem, std::size_t num, std::size_t &constructed) = 0;
0046    virtual void destroy_n(void *mem, std::size_t num, std::size_t &destroyed) = 0;
0047    virtual ~in_place_interface(){}
0048 };
0049 
0050 template<class T>
0051 struct placement_destroy :  public in_place_interface
0052 {
0053    placement_destroy()
0054       :  in_place_interface(::boost::container::dtl::alignment_of<T>::value, sizeof(T), typeid(T).name())
0055    {}
0056 
0057    virtual void destroy_n(void *mem, std::size_t num, std::size_t &destroyed) BOOST_OVERRIDE
0058    {
0059       T* memory = static_cast<T*>(mem);
0060       for(destroyed = 0; destroyed < num; ++destroyed)
0061          (memory++)->~T();
0062    }
0063 
0064    virtual void construct_n(void *, std::size_t, std::size_t &) BOOST_OVERRIDE {}
0065 
0066    private:
0067    void destroy(void *mem)
0068    {  static_cast<T*>(mem)->~T();   }
0069 };
0070 
0071 }
0072 }
0073 }   //namespace boost { namespace interprocess { namespace ipcdetail {
0074 
0075 #include <boost/interprocess/detail/config_end.hpp>
0076 
0077 #endif //#ifndef BOOST_INTERPROCESS_IN_PLACE_INTERFACE_HPP