Chris@16
|
1 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 //
|
Chris@16
|
3 // (C) Copyright Pablo Halpern 2009. Distributed under the Boost
|
Chris@16
|
4 // Software License, Version 1.0. (See accompanying file
|
Chris@16
|
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 //
|
Chris@16
|
7 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
8 //
|
Chris@101
|
9 // (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the Boost
|
Chris@16
|
10 // Software License, Version 1.0. (See accompanying file
|
Chris@16
|
11 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
12 //
|
Chris@16
|
13 // See http://www.boost.org/libs/container for documentation.
|
Chris@16
|
14 //
|
Chris@16
|
15 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
16 #ifndef BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP
|
Chris@16
|
17 #define BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP
|
Chris@16
|
18
|
Chris@101
|
19 #ifndef BOOST_CONFIG_HPP
|
Chris@101
|
20 # include <boost/config.hpp>
|
Chris@101
|
21 #endif
|
Chris@101
|
22
|
Chris@101
|
23 #if defined(BOOST_HAS_PRAGMA_ONCE)
|
Chris@16
|
24 # pragma once
|
Chris@16
|
25 #endif
|
Chris@16
|
26
|
Chris@16
|
27 #include <boost/container/detail/config_begin.hpp>
|
Chris@16
|
28 #include <boost/container/detail/workaround.hpp>
|
Chris@101
|
29
|
Chris@101
|
30 // container
|
Chris@16
|
31 #include <boost/container/container_fwd.hpp>
|
Chris@101
|
32 #include <boost/container/detail/mpl.hpp>
|
Chris@101
|
33 #include <boost/container/detail/type_traits.hpp> //is_empty
|
Chris@101
|
34 #include <boost/container/detail/placement_new.hpp>
|
Chris@101
|
35 #ifndef BOOST_CONTAINER_DETAIL_STD_FWD_HPP
|
Chris@101
|
36 #include <boost/container/detail/std_fwd.hpp>
|
Chris@101
|
37 #endif
|
Chris@101
|
38 // intrusive
|
Chris@16
|
39 #include <boost/intrusive/pointer_traits.hpp>
|
Chris@101
|
40 #include <boost/intrusive/detail/mpl.hpp>
|
Chris@101
|
41 // move
|
Chris@101
|
42 #include <boost/move/utility_core.hpp>
|
Chris@101
|
43 // move/detail
|
Chris@101
|
44 #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
Chris@101
|
45 #include <boost/move/detail/fwd_macros.hpp>
|
Chris@101
|
46 #endif
|
Chris@101
|
47 // other boost
|
Chris@101
|
48 #include <boost/static_assert.hpp>
|
Chris@16
|
49
|
Chris@101
|
50 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
Chris@16
|
51
|
Chris@101
|
52 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME allocate
|
Chris@101
|
53 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace container_detail {
|
Chris@101
|
54 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}}
|
Chris@101
|
55 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 2
|
Chris@101
|
56 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 2
|
Chris@101
|
57 #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
|
Chris@101
|
58
|
Chris@101
|
59 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME destroy
|
Chris@101
|
60 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace container_detail {
|
Chris@101
|
61 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}}
|
Chris@101
|
62 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 1
|
Chris@101
|
63 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 1
|
Chris@101
|
64 #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
|
Chris@101
|
65
|
Chris@101
|
66 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME construct
|
Chris@101
|
67 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace container_detail {
|
Chris@101
|
68 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}}
|
Chris@101
|
69 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 1
|
Chris@101
|
70 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 9
|
Chris@101
|
71 #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
|
Chris@101
|
72
|
Chris@101
|
73 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
Chris@16
|
74
|
Chris@16
|
75 namespace boost {
|
Chris@16
|
76 namespace container {
|
Chris@101
|
77
|
Chris@101
|
78 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
Chris@101
|
79
|
Chris@101
|
80 namespace allocator_traits_detail {
|
Chris@101
|
81
|
Chris@101
|
82 BOOST_INTRUSIVE_HAS_STATIC_MEMBER_FUNC_SIGNATURE(has_max_size, max_size)
|
Chris@101
|
83 BOOST_INTRUSIVE_HAS_STATIC_MEMBER_FUNC_SIGNATURE(has_select_on_container_copy_construction, select_on_container_copy_construction)
|
Chris@101
|
84
|
Chris@101
|
85 } //namespace allocator_traits_detail {
|
Chris@101
|
86
|
Chris@16
|
87 namespace container_detail {
|
Chris@16
|
88
|
Chris@16
|
89 //workaround needed for C++03 compilers with no construct()
|
Chris@16
|
90 //supporting rvalue references
|
Chris@101
|
91 template<class Allocator>
|
Chris@16
|
92 struct is_std_allocator
|
Chris@16
|
93 { static const bool value = false; };
|
Chris@16
|
94
|
Chris@16
|
95 template<class T>
|
Chris@16
|
96 struct is_std_allocator< std::allocator<T> >
|
Chris@16
|
97 { static const bool value = true; };
|
Chris@16
|
98
|
Chris@101
|
99 BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(pointer)
|
Chris@101
|
100 BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(const_pointer)
|
Chris@101
|
101 BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reference)
|
Chris@101
|
102 BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_reference)
|
Chris@101
|
103 BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(void_pointer)
|
Chris@101
|
104 BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(const_void_pointer)
|
Chris@101
|
105 BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(size_type)
|
Chris@101
|
106 BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_copy_assignment)
|
Chris@101
|
107 BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_move_assignment)
|
Chris@101
|
108 BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_swap)
|
Chris@101
|
109 BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(is_always_equal)
|
Chris@101
|
110 BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type)
|
Chris@101
|
111 BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(is_partially_propagable)
|
Chris@101
|
112
|
Chris@16
|
113 } //namespace container_detail {
|
Chris@16
|
114
|
Chris@101
|
115 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
Chris@16
|
116
|
Chris@16
|
117 //! The class template allocator_traits supplies a uniform interface to all allocator types.
|
Chris@16
|
118 //! This class is a C++03-compatible implementation of std::allocator_traits
|
Chris@101
|
119 template <typename Allocator>
|
Chris@16
|
120 struct allocator_traits
|
Chris@16
|
121 {
|
Chris@16
|
122 //allocator_type
|
Chris@101
|
123 typedef Allocator allocator_type;
|
Chris@16
|
124 //value_type
|
Chris@101
|
125 typedef typename allocator_type::value_type value_type;
|
Chris@16
|
126
|
Chris@16
|
127 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
Chris@101
|
128 //! Allocator::pointer if such a type exists; otherwise, value_type*
|
Chris@16
|
129 //!
|
Chris@16
|
130 typedef unspecified pointer;
|
Chris@101
|
131 //! Allocator::const_pointer if such a type exists ; otherwise, pointer_traits<pointer>::rebind<const
|
Chris@16
|
132 //!
|
Chris@16
|
133 typedef see_documentation const_pointer;
|
Chris@16
|
134 //! Non-standard extension
|
Chris@101
|
135 //! Allocator::reference if such a type exists; otherwise, value_type&
|
Chris@16
|
136 typedef see_documentation reference;
|
Chris@16
|
137 //! Non-standard extension
|
Chris@101
|
138 //! Allocator::const_reference if such a type exists ; otherwise, const value_type&
|
Chris@16
|
139 typedef see_documentation const_reference;
|
Chris@101
|
140 //! Allocator::void_pointer if such a type exists ; otherwise, pointer_traits<pointer>::rebind<void>.
|
Chris@16
|
141 //!
|
Chris@16
|
142 typedef see_documentation void_pointer;
|
Chris@101
|
143 //! Allocator::const_void_pointer if such a type exists ; otherwis e, pointer_traits<pointer>::rebind<const
|
Chris@16
|
144 //!
|
Chris@16
|
145 typedef see_documentation const_void_pointer;
|
Chris@101
|
146 //! Allocator::difference_type if such a type exists ; otherwise, pointer_traits<pointer>::difference_type.
|
Chris@16
|
147 //!
|
Chris@16
|
148 typedef see_documentation difference_type;
|
Chris@101
|
149 //! Allocator::size_type if such a type exists ; otherwise, make_unsigned<difference_type>::type
|
Chris@16
|
150 //!
|
Chris@16
|
151 typedef see_documentation size_type;
|
Chris@101
|
152 //! Allocator::propagate_on_container_copy_assignment if such a type exists, otherwise a type
|
Chris@101
|
153 //! with an internal constant static boolean member <code>value</code> == false.
|
Chris@16
|
154 typedef see_documentation propagate_on_container_copy_assignment;
|
Chris@101
|
155 //! Allocator::propagate_on_container_move_assignment if such a type exists, otherwise a type
|
Chris@101
|
156 //! with an internal constant static boolean member <code>value</code> == false.
|
Chris@16
|
157 typedef see_documentation propagate_on_container_move_assignment;
|
Chris@101
|
158 //! Allocator::propagate_on_container_swap if such a type exists, otherwise a type
|
Chris@101
|
159 //! with an internal constant static boolean member <code>value</code> == false.
|
Chris@16
|
160 typedef see_documentation propagate_on_container_swap;
|
Chris@101
|
161 //! Allocator::is_always_equal if such a type exists, otherwise a type
|
Chris@101
|
162 //! with an internal constant static boolean member <code>value</code> == is_empty<Allocator>::value
|
Chris@101
|
163 typedef see_documentation is_always_equal;
|
Chris@101
|
164 //! Allocator::is_partially_propagable if such a type exists, otherwise a type
|
Chris@101
|
165 //! with an internal constant static boolean member <code>value</code> == false
|
Chris@101
|
166 //! <b>Note</b>: Non-standard extension used to implement `small_vector_allocator`.
|
Chris@101
|
167 typedef see_documentation is_partially_propagable;
|
Chris@101
|
168 //! Defines an allocator: Allocator::rebind<T>::other if such a type exists; otherwise, Allocator<T, Args>
|
Chris@101
|
169 //! if Allocator is a class template instantiation of the form Allocator<U, Args>, where Args is zero or
|
Chris@16
|
170 //! more type arguments ; otherwise, the instantiation of rebind_alloc is ill-formed.
|
Chris@16
|
171 //!
|
Chris@101
|
172 //! In C++03 compilers <code>rebind_alloc</code> is a struct derived from an allocator
|
Chris@16
|
173 //! deduced by previously detailed rules.
|
Chris@16
|
174 template <class T> using rebind_alloc = see_documentation;
|
Chris@16
|
175
|
Chris@101
|
176 //! In C++03 compilers <code>rebind_traits</code> is a struct derived from
|
Chris@101
|
177 //! <code>allocator_traits<OtherAlloc></code>, where <code>OtherAlloc</code> is
|
Chris@101
|
178 //! the allocator deduced by rules explained in <code>rebind_alloc</code>.
|
Chris@16
|
179 template <class T> using rebind_traits = allocator_traits<rebind_alloc<T> >;
|
Chris@16
|
180
|
Chris@16
|
181 //! Non-standard extension: Portable allocator rebind for C++03 and C++11 compilers.
|
Chris@101
|
182 //! <code>type</code> is an allocator related to Allocator deduced deduced by rules explained in <code>rebind_alloc</code>.
|
Chris@16
|
183 template <class T>
|
Chris@16
|
184 struct portable_rebind_alloc
|
Chris@16
|
185 { typedef see_documentation type; };
|
Chris@16
|
186 #else
|
Chris@16
|
187 //pointer
|
Chris@101
|
188 typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
|
Chris@16
|
189 pointer, value_type*)
|
Chris@16
|
190 pointer;
|
Chris@16
|
191 //const_pointer
|
Chris@101
|
192 typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Allocator,
|
Chris@16
|
193 const_pointer, typename boost::intrusive::pointer_traits<pointer>::template
|
Chris@16
|
194 rebind_pointer<const value_type>)
|
Chris@16
|
195 const_pointer;
|
Chris@16
|
196 //reference
|
Chris@101
|
197 typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
|
Chris@16
|
198 reference, typename container_detail::unvoid<value_type>::type&)
|
Chris@16
|
199 reference;
|
Chris@16
|
200 //const_reference
|
Chris@101
|
201 typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
|
Chris@16
|
202 const_reference, const typename container_detail::unvoid<value_type>::type&)
|
Chris@16
|
203 const_reference;
|
Chris@16
|
204 //void_pointer
|
Chris@101
|
205 typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Allocator,
|
Chris@16
|
206 void_pointer, typename boost::intrusive::pointer_traits<pointer>::template
|
Chris@16
|
207 rebind_pointer<void>)
|
Chris@16
|
208 void_pointer;
|
Chris@16
|
209 //const_void_pointer
|
Chris@101
|
210 typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Allocator,
|
Chris@16
|
211 const_void_pointer, typename boost::intrusive::pointer_traits<pointer>::template
|
Chris@16
|
212 rebind_pointer<const void>)
|
Chris@16
|
213 const_void_pointer;
|
Chris@16
|
214 //difference_type
|
Chris@101
|
215 typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
|
Chris@16
|
216 difference_type, std::ptrdiff_t)
|
Chris@16
|
217 difference_type;
|
Chris@16
|
218 //size_type
|
Chris@101
|
219 typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
|
Chris@16
|
220 size_type, std::size_t)
|
Chris@16
|
221 size_type;
|
Chris@16
|
222 //propagate_on_container_copy_assignment
|
Chris@101
|
223 typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
|
Chris@101
|
224 propagate_on_container_copy_assignment, container_detail::false_type)
|
Chris@16
|
225 propagate_on_container_copy_assignment;
|
Chris@16
|
226 //propagate_on_container_move_assignment
|
Chris@101
|
227 typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
|
Chris@101
|
228 propagate_on_container_move_assignment, container_detail::false_type)
|
Chris@16
|
229 propagate_on_container_move_assignment;
|
Chris@16
|
230 //propagate_on_container_swap
|
Chris@101
|
231 typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
|
Chris@101
|
232 propagate_on_container_swap, container_detail::false_type)
|
Chris@16
|
233 propagate_on_container_swap;
|
Chris@101
|
234 //is_always_equal
|
Chris@101
|
235 typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
|
Chris@101
|
236 is_always_equal, container_detail::is_empty<Allocator>)
|
Chris@101
|
237 is_always_equal;
|
Chris@101
|
238 //is_partially_propagable
|
Chris@101
|
239 typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
|
Chris@101
|
240 is_partially_propagable, container_detail::false_type)
|
Chris@101
|
241 is_partially_propagable;
|
Chris@16
|
242
|
Chris@101
|
243 //rebind_alloc & rebind_traits
|
Chris@16
|
244 #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
Chris@16
|
245 //C++11
|
Chris@101
|
246 template <typename T> using rebind_alloc = typename boost::intrusive::pointer_rebind<Allocator, T>::type;
|
Chris@16
|
247 template <typename T> using rebind_traits = allocator_traits< rebind_alloc<T> >;
|
Chris@16
|
248 #else // #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
Chris@16
|
249 //Some workaround for C++03 or C++11 compilers with no template aliases
|
Chris@16
|
250 template <typename T>
|
Chris@101
|
251 struct rebind_alloc : boost::intrusive::pointer_rebind<Allocator,T>::type
|
Chris@16
|
252 {
|
Chris@101
|
253 typedef typename boost::intrusive::pointer_rebind<Allocator,T>::type Base;
|
Chris@16
|
254 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
Chris@101
|
255 template <typename... Args>
|
Chris@101
|
256 rebind_alloc(BOOST_FWD_REF(Args)... args) : Base(boost::forward<Args>(args)...) {}
|
Chris@16
|
257 #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
Chris@101
|
258 #define BOOST_CONTAINER_ALLOCATOR_TRAITS_REBIND_ALLOC(N) \
|
Chris@101
|
259 BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N\
|
Chris@101
|
260 explicit rebind_alloc(BOOST_MOVE_UREF##N) : Base(BOOST_MOVE_FWD##N){}\
|
Chris@101
|
261 //
|
Chris@101
|
262 BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_ALLOCATOR_TRAITS_REBIND_ALLOC)
|
Chris@101
|
263 #undef BOOST_CONTAINER_ALLOCATOR_TRAITS_REBIND_ALLOC
|
Chris@16
|
264 #endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
Chris@16
|
265 };
|
Chris@16
|
266
|
Chris@16
|
267 template <typename T>
|
Chris@16
|
268 struct rebind_traits
|
Chris@101
|
269 : allocator_traits<typename boost::intrusive::pointer_rebind<Allocator, T>::type>
|
Chris@16
|
270 {};
|
Chris@16
|
271 #endif // #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
Chris@101
|
272
|
Chris@101
|
273 //portable_rebind_alloc
|
Chris@16
|
274 template <class T>
|
Chris@16
|
275 struct portable_rebind_alloc
|
Chris@101
|
276 { typedef typename boost::intrusive::pointer_rebind<Allocator, T>::type type; };
|
Chris@16
|
277 #endif //BOOST_CONTAINER_DOXYGEN_INVOKED
|
Chris@16
|
278
|
Chris@101
|
279 //! <b>Returns</b>: <code>a.allocate(n)</code>
|
Chris@16
|
280 //!
|
Chris@101
|
281 static pointer allocate(Allocator &a, size_type n)
|
Chris@16
|
282 { return a.allocate(n); }
|
Chris@16
|
283
|
Chris@101
|
284 //! <b>Returns</b>: <code>a.deallocate(p, n)</code>
|
Chris@16
|
285 //!
|
Chris@16
|
286 //! <b>Throws</b>: Nothing
|
Chris@101
|
287 static void deallocate(Allocator &a, pointer p, size_type n)
|
Chris@16
|
288 { a.deallocate(p, n); }
|
Chris@16
|
289
|
Chris@101
|
290 //! <b>Effects</b>: calls <code>a.allocate(n, p)</code> if that call is well-formed;
|
Chris@101
|
291 //! otherwise, invokes <code>a.allocate(n)</code>
|
Chris@101
|
292 static pointer allocate(Allocator &a, size_type n, const_void_pointer p)
|
Chris@16
|
293 {
|
Chris@16
|
294 const bool value = boost::container::container_detail::
|
Chris@16
|
295 has_member_function_callable_with_allocate
|
Chris@101
|
296 <Allocator, const size_type, const const_void_pointer>::value;
|
Chris@101
|
297 container_detail::bool_<value> flag;
|
Chris@16
|
298 return allocator_traits::priv_allocate(flag, a, n, p);
|
Chris@16
|
299 }
|
Chris@16
|
300
|
Chris@101
|
301 //! <b>Effects</b>: calls <code>a.destroy(p)</code> if that call is well-formed;
|
Chris@101
|
302 //! otherwise, invokes <code>p->~T()</code>.
|
Chris@16
|
303 template<class T>
|
Chris@101
|
304 static void destroy(Allocator &a, T*p) BOOST_NOEXCEPT_OR_NOTHROW
|
Chris@16
|
305 {
|
Chris@16
|
306 typedef T* destroy_pointer;
|
Chris@16
|
307 const bool value = boost::container::container_detail::
|
Chris@16
|
308 has_member_function_callable_with_destroy
|
Chris@101
|
309 <Allocator, const destroy_pointer>::value;
|
Chris@101
|
310 container_detail::bool_<value> flag;
|
Chris@16
|
311 allocator_traits::priv_destroy(flag, a, p);
|
Chris@16
|
312 }
|
Chris@16
|
313
|
Chris@101
|
314 //! <b>Returns</b>: <code>a.max_size()</code> if that expression is well-formed; otherwise,
|
Chris@101
|
315 //! <code>numeric_limits<size_type>::max()</code>.
|
Chris@101
|
316 static size_type max_size(const Allocator &a) BOOST_NOEXCEPT_OR_NOTHROW
|
Chris@16
|
317 {
|
Chris@101
|
318 const bool value = allocator_traits_detail::has_max_size<Allocator, size_type (Allocator::*)() const>::value;
|
Chris@101
|
319 container_detail::bool_<value> flag;
|
Chris@16
|
320 return allocator_traits::priv_max_size(flag, a);
|
Chris@16
|
321 }
|
Chris@16
|
322
|
Chris@101
|
323 //! <b>Returns</b>: <code>a.select_on_container_copy_construction()</code> if that expression is well-formed;
|
Chris@16
|
324 //! otherwise, a.
|
Chris@101
|
325 static BOOST_CONTAINER_DOC1ST(Allocator,
|
Chris@101
|
326 typename container_detail::if_c
|
Chris@101
|
327 < allocator_traits_detail::has_select_on_container_copy_construction<Allocator BOOST_MOVE_I Allocator (Allocator::*)() const>::value
|
Chris@101
|
328 BOOST_MOVE_I Allocator BOOST_MOVE_I const Allocator & >::type)
|
Chris@101
|
329 select_on_container_copy_construction(const Allocator &a)
|
Chris@16
|
330 {
|
Chris@101
|
331 const bool value = allocator_traits_detail::has_select_on_container_copy_construction
|
Chris@101
|
332 <Allocator, Allocator (Allocator::*)() const>::value;
|
Chris@101
|
333 container_detail::bool_<value> flag;
|
Chris@16
|
334 return allocator_traits::priv_select_on_container_copy_construction(flag, a);
|
Chris@16
|
335 }
|
Chris@16
|
336
|
Chris@16
|
337 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
Chris@101
|
338 //! <b>Effects</b>: calls <code>a.construct(p, std::forward<Args>(args)...)</code> if that call is well-formed;
|
Chris@101
|
339 //! otherwise, invokes <code>::new (static_cast<void*>(p)) T(std::forward<Args>(args)...)</code>
|
Chris@16
|
340 template <class T, class ...Args>
|
Chris@101
|
341 static void construct(Allocator & a, T* p, BOOST_FWD_REF(Args)... args)
|
Chris@16
|
342 {
|
Chris@101
|
343 container_detail::bool_<container_detail::is_std_allocator<Allocator>::value> flag;
|
Chris@16
|
344 allocator_traits::priv_construct(flag, a, p, ::boost::forward<Args>(args)...);
|
Chris@16
|
345 }
|
Chris@16
|
346 #endif
|
Chris@101
|
347
|
Chris@101
|
348 //! <b>Returns</b>: <code>a.storage_is_unpropagable(p)</code> if is_partially_propagable::value is true; otherwise,
|
Chris@101
|
349 //! <code>false</code>.
|
Chris@101
|
350 static bool storage_is_unpropagable(const Allocator &a, pointer p) BOOST_NOEXCEPT_OR_NOTHROW
|
Chris@101
|
351 {
|
Chris@101
|
352 container_detail::bool_<is_partially_propagable::value> flag;
|
Chris@101
|
353 return allocator_traits::priv_storage_is_unpropagable(flag, a, p);
|
Chris@101
|
354 }
|
Chris@101
|
355
|
Chris@101
|
356 //! <b>Returns</b>: <code>true</code> if <code>is_always_equal::value == true</code>, otherwise,
|
Chris@101
|
357 //! <code>a == b</code>.
|
Chris@101
|
358 static bool equal(const Allocator &a, const Allocator &b) BOOST_NOEXCEPT_OR_NOTHROW
|
Chris@101
|
359 {
|
Chris@101
|
360 container_detail::bool_<is_always_equal::value> flag;
|
Chris@101
|
361 return allocator_traits::priv_equal(flag, a, b);
|
Chris@101
|
362 }
|
Chris@101
|
363
|
Chris@16
|
364 #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
Chris@101
|
365 private:
|
Chris@101
|
366 static pointer priv_allocate(container_detail::true_type, Allocator &a, size_type n, const_void_pointer p)
|
Chris@101
|
367 { return a.allocate(n, p); }
|
Chris@101
|
368
|
Chris@101
|
369 static pointer priv_allocate(container_detail::false_type, Allocator &a, size_type n, const_void_pointer)
|
Chris@101
|
370 { return a.allocate(n); }
|
Chris@101
|
371
|
Chris@101
|
372 template<class T>
|
Chris@101
|
373 static void priv_destroy(container_detail::true_type, Allocator &a, T* p) BOOST_NOEXCEPT_OR_NOTHROW
|
Chris@101
|
374 { a.destroy(p); }
|
Chris@101
|
375
|
Chris@101
|
376 template<class T>
|
Chris@101
|
377 static void priv_destroy(container_detail::false_type, Allocator &, T* p) BOOST_NOEXCEPT_OR_NOTHROW
|
Chris@101
|
378 { p->~T(); (void)p; }
|
Chris@101
|
379
|
Chris@101
|
380 static size_type priv_max_size(container_detail::true_type, const Allocator &a) BOOST_NOEXCEPT_OR_NOTHROW
|
Chris@101
|
381 { return a.max_size(); }
|
Chris@101
|
382
|
Chris@101
|
383 static size_type priv_max_size(container_detail::false_type, const Allocator &) BOOST_NOEXCEPT_OR_NOTHROW
|
Chris@101
|
384 { return size_type(-1)/sizeof(value_type); }
|
Chris@101
|
385
|
Chris@101
|
386 static Allocator priv_select_on_container_copy_construction(container_detail::true_type, const Allocator &a)
|
Chris@101
|
387 { return a.select_on_container_copy_construction(); }
|
Chris@101
|
388
|
Chris@101
|
389 static const Allocator &priv_select_on_container_copy_construction(container_detail::false_type, const Allocator &a) BOOST_NOEXCEPT_OR_NOTHROW
|
Chris@101
|
390 { return a; }
|
Chris@101
|
391
|
Chris@101
|
392 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
Chris@101
|
393 template<class T, class ...Args>
|
Chris@101
|
394 static void priv_construct(container_detail::false_type, Allocator &a, T *p, BOOST_FWD_REF(Args) ...args)
|
Chris@101
|
395 {
|
Chris@101
|
396 const bool value = boost::container::container_detail::
|
Chris@101
|
397 has_member_function_callable_with_construct
|
Chris@101
|
398 < Allocator, T*, Args... >::value;
|
Chris@101
|
399 container_detail::bool_<value> flag;
|
Chris@101
|
400 (priv_construct_dispatch_next)(flag, a, p, ::boost::forward<Args>(args)...);
|
Chris@101
|
401 }
|
Chris@101
|
402
|
Chris@101
|
403 template<class T, class ...Args>
|
Chris@101
|
404 static void priv_construct(container_detail::true_type, Allocator &a, T *p, BOOST_FWD_REF(Args) ...args)
|
Chris@101
|
405 { (priv_construct_dispatch_next)(container_detail::false_type(), a, p, ::boost::forward<Args>(args)...); }
|
Chris@101
|
406
|
Chris@101
|
407 template<class T, class ...Args>
|
Chris@101
|
408 static void priv_construct_dispatch_next(container_detail::true_type, Allocator &a, T *p, BOOST_FWD_REF(Args) ...args)
|
Chris@101
|
409 { a.construct( p, ::boost::forward<Args>(args)...); }
|
Chris@101
|
410
|
Chris@101
|
411 template<class T, class ...Args>
|
Chris@101
|
412 static void priv_construct_dispatch_next(container_detail::false_type, Allocator &, T *p, BOOST_FWD_REF(Args) ...args)
|
Chris@101
|
413 { ::new((void*)p, boost_container_new_t()) T(::boost::forward<Args>(args)...); }
|
Chris@101
|
414 #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
Chris@101
|
415 public:
|
Chris@101
|
416
|
Chris@101
|
417 #define BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL(N) \
|
Chris@101
|
418 template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\
|
Chris@101
|
419 static void construct(Allocator &a, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
|
Chris@101
|
420 {\
|
Chris@101
|
421 container_detail::bool_<container_detail::is_std_allocator<Allocator>::value> flag;\
|
Chris@101
|
422 (priv_construct)(flag, a, p BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
|
Chris@101
|
423 }\
|
Chris@101
|
424 //
|
Chris@101
|
425 BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL)
|
Chris@101
|
426 #undef BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL
|
Chris@101
|
427
|
Chris@16
|
428 private:
|
Chris@16
|
429
|
Chris@101
|
430 //////////////////
|
Chris@101
|
431 // priv_construct
|
Chris@101
|
432 //////////////////
|
Chris@101
|
433 #define BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL(N) \
|
Chris@101
|
434 template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\
|
Chris@101
|
435 static void priv_construct(container_detail::false_type, Allocator &a, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
|
Chris@101
|
436 {\
|
Chris@101
|
437 const bool value = boost::container::container_detail::has_member_function_callable_with_construct\
|
Chris@101
|
438 < Allocator, T* BOOST_MOVE_I##N BOOST_MOVE_FWD_T##N>::value;\
|
Chris@101
|
439 container_detail::bool_<value> flag;\
|
Chris@101
|
440 (priv_construct_dispatch_next)(flag, a, p BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
|
Chris@101
|
441 }\
|
Chris@101
|
442 \
|
Chris@101
|
443 template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\
|
Chris@101
|
444 static void priv_construct(container_detail::true_type, Allocator &a, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
|
Chris@101
|
445 { (priv_construct_dispatch_next)(container_detail::false_type(), a, p BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
|
Chris@101
|
446 //
|
Chris@101
|
447 BOOST_MOVE_ITERATE_0TO8(BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL)
|
Chris@101
|
448 #undef BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL
|
Chris@16
|
449
|
Chris@101
|
450 /////////////////////////////////
|
Chris@101
|
451 // priv_construct_dispatch_next
|
Chris@101
|
452 /////////////////////////////////
|
Chris@101
|
453 #define BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_DISPATCH_NEXT_IMPL(N) \
|
Chris@101
|
454 template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\
|
Chris@101
|
455 static void priv_construct_dispatch_next(container_detail::true_type, Allocator &a, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
|
Chris@101
|
456 { a.construct( p BOOST_MOVE_I##N BOOST_MOVE_FWD##N ); }\
|
Chris@101
|
457 \
|
Chris@101
|
458 template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\
|
Chris@101
|
459 static void priv_construct_dispatch_next(container_detail::false_type, Allocator &, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
|
Chris@101
|
460 { ::new((void*)p, boost_container_new_t()) T(BOOST_MOVE_FWD##N); }\
|
Chris@101
|
461 //
|
Chris@101
|
462 BOOST_MOVE_ITERATE_0TO8(BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_DISPATCH_NEXT_IMPL)
|
Chris@101
|
463 #undef BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_DISPATCH_NEXT_IMPL
|
Chris@16
|
464
|
Chris@101
|
465 #endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
Chris@16
|
466
|
Chris@101
|
467 template<class T>
|
Chris@101
|
468 static void priv_construct_dispatch_next(container_detail::false_type, Allocator &, T *p, const ::boost::container::default_init_t&)
|
Chris@101
|
469 { ::new((void*)p) T; }
|
Chris@16
|
470
|
Chris@101
|
471 static bool priv_storage_is_unpropagable(container_detail::true_type, const Allocator &a, pointer p)
|
Chris@101
|
472 { return a.storage_is_unpropagable(p); }
|
Chris@16
|
473
|
Chris@101
|
474 static bool priv_storage_is_unpropagable(container_detail::false_type, const Allocator &, pointer)
|
Chris@101
|
475 { return false; }
|
Chris@16
|
476
|
Chris@101
|
477 static bool priv_equal(container_detail::true_type, const Allocator &, const Allocator &)
|
Chris@101
|
478 { return true; }
|
Chris@16
|
479
|
Chris@101
|
480 static bool priv_equal(container_detail::false_type, const Allocator &a, const Allocator &b)
|
Chris@101
|
481 { return a == b; }
|
Chris@16
|
482
|
Chris@16
|
483 #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
Chris@16
|
484 };
|
Chris@16
|
485
|
Chris@16
|
486 } //namespace container {
|
Chris@16
|
487 } //namespace boost {
|
Chris@16
|
488
|
Chris@16
|
489 #include <boost/container/detail/config_end.hpp>
|
Chris@16
|
490
|
Chris@16
|
491 #endif // ! defined(BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP)
|