fix doc example typo
[boost.git] / boost / interprocess / managed_external_buffer.hpp
blob30b822ad6fa497ae575135a26c6aca995bc023ee
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_MANAGED_EXTERNAL_BUFFER_HPP
12 #define BOOST_INTERPROCESS_MANAGED_EXTERNAL_BUFFER_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/creation_tags.hpp>
21 #include <boost/interprocess/detail/managed_memory_impl.hpp>
22 #include <boost/interprocess/detail/move.hpp>
23 #include <cassert>
25 //!\file
26 //!Describes a named user memory allocation user class.
28 namespace boost {
29 namespace interprocess {
31 //!A basic user memory named object creation class. Inherits all
32 //!basic functionality from
33 //!basic_managed_memory_impl<CharType, AllocationAlgorithm, IndexType>*/
34 template
36 class CharType,
37 class AllocationAlgorithm,
38 template<class IndexConfig> class IndexType
40 class basic_managed_external_buffer
41 : public detail::basic_managed_memory_impl <CharType, AllocationAlgorithm, IndexType>
43 /// @cond
44 typedef detail::basic_managed_memory_impl
45 <CharType, AllocationAlgorithm, IndexType> base_t;
46 basic_managed_external_buffer(basic_managed_external_buffer&);
47 basic_managed_external_buffer & operator=(basic_managed_external_buffer&);
48 /// @endcond
50 public:
51 BOOST_INTERPROCESS_ENABLE_MOVE_EMULATION(basic_managed_external_buffer)
53 //!Default constructor. Does nothing.
54 //!Useful in combination with move semantics
55 basic_managed_external_buffer()
58 //!Creates and places the segment manager. This can throw
59 basic_managed_external_buffer
60 (create_only_t, void *addr, std::size_t size)
62 //Check if alignment is correct
63 assert((0 == (((std::size_t)addr) & (AllocationAlgorithm::Alignment - std::size_t(1u)))));
64 if(!base_t::create_impl(addr, size)){
65 throw interprocess_exception();
69 //!Creates and places the segment manager. This can throw
70 basic_managed_external_buffer
71 (open_only_t, void *addr, std::size_t size)
73 //Check if alignment is correct
74 assert((0 == (((std::size_t)addr) & (AllocationAlgorithm::Alignment - std::size_t(1u)))));
75 if(!base_t::open_impl(addr, size)){
76 throw interprocess_exception();
80 //!Moves the ownership of "moved"'s managed memory to *this. Does not throw
81 basic_managed_external_buffer(BOOST_INTERPROCESS_RV_REF(basic_managed_external_buffer) moved)
83 this->swap(moved);
86 //!Moves the ownership of "moved"'s managed memory to *this. Does not throw
87 basic_managed_external_buffer &operator=(BOOST_INTERPROCESS_RV_REF(basic_managed_external_buffer) moved)
89 basic_managed_external_buffer tmp(boost::interprocess::move(moved));
90 this->swap(tmp);
91 return *this;
94 void grow(std::size_t extra_bytes)
95 { base_t::grow(extra_bytes); }
97 //!Swaps the ownership of the managed heap memories managed by *this and other.
98 //!Never throws.
99 void swap(basic_managed_external_buffer &other)
100 { base_t::swap(other); }
103 } //namespace interprocess {
104 } //namespace boost {
106 #include <boost/interprocess/detail/config_end.hpp>
108 #endif //BOOST_INTERPROCESS_MANAGED_EXTERNAL_BUFFER_HPP