fix doc example typo
[boost.git] / boost / interprocess / detail / in_place_interface.hpp
blobdd8c4c0ad864c115ccffac18337bc454db9e2672
1 //////////////////////////////////////////////////////////////////////////////
2 //
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)
6 //
7 // See http://www.boost.org/libs/interprocess for documentation.
8 //
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)
15 # pragma once
16 #endif
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
23 //!\file
24 //!Describes an abstract interface for placement construction and destruction.
26 namespace boost {
27 namespace interprocess {
28 namespace detail {
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;
37 std::size_t size;
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(){}
45 template<class T>
46 struct placement_destroy : public in_place_interface
48 placement_destroy()
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)
56 (memory++)->~T();
59 virtual void construct_n(void *, std::size_t, std::size_t &) {}
61 private:
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