]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
2 | // Copyright 2006-2009 Daniel James. | |
3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |
4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
5 | ||
6 | // Define some minimal classes which provide the bare minimum concepts to | |
7 | // test that the containers don't rely on something that they shouldn't. | |
8 | // They are not intended to be good examples of how to implement the concepts. | |
9 | ||
10 | #if !defined(BOOST_UNORDERED_OBJECTS_MINIMAL_HEADER) | |
11 | #define BOOST_UNORDERED_OBJECTS_MINIMAL_HEADER | |
12 | ||
7c673cae | 13 | #include <boost/move/move.hpp> |
b32b8144 | 14 | #include <cstddef> |
7c673cae FG |
15 | #include <utility> |
16 | ||
17 | #if defined(BOOST_MSVC) | |
18 | #pragma warning(push) | |
b32b8144 | 19 | #pragma warning(disable : 4100) // unreferenced formal parameter |
7c673cae FG |
20 | #endif |
21 | ||
22 | #if !BOOST_WORKAROUND(BOOST_MSVC, == 1500) | |
23 | #define BOOST_UNORDERED_CHECK_ADDR_OPERATOR_NOT_USED 1 | |
24 | #else | |
25 | #define BOOST_UNORDERED_CHECK_ADDR_OPERATOR_NOT_USED 0 | |
26 | #endif | |
27 | ||
b32b8144 FG |
28 | namespace test { |
29 | namespace minimal { | |
7c673cae FG |
30 | class destructible; |
31 | class copy_constructible; | |
32 | class copy_constructible_equality_comparable; | |
33 | class default_assignable; | |
34 | class assignable; | |
35 | ||
b32b8144 FG |
36 | struct ampersand_operator_used |
37 | { | |
38 | ampersand_operator_used() { BOOST_TEST(false); } | |
7c673cae FG |
39 | }; |
40 | ||
41 | template <class T> class hash; | |
42 | template <class T> class equal_to; | |
43 | template <class T> class ptr; | |
44 | template <class T> class const_ptr; | |
45 | template <class T> class allocator; | |
46 | template <class T> class cxx11_allocator; | |
47 | ||
48 | struct constructor_param | |
49 | { | |
b32b8144 | 50 | operator int() const { return 0; } |
7c673cae FG |
51 | }; |
52 | ||
53 | class destructible | |
54 | { | |
55 | public: | |
b32b8144 FG |
56 | destructible(constructor_param const&) {} |
57 | ~destructible() {} | |
58 | void dummy_member() const {} | |
59 | ||
7c673cae | 60 | private: |
b32b8144 FG |
61 | destructible(destructible const&); |
62 | destructible& operator=(destructible const&); | |
7c673cae FG |
63 | }; |
64 | ||
65 | class copy_constructible | |
66 | { | |
67 | public: | |
b32b8144 FG |
68 | copy_constructible(constructor_param const&) {} |
69 | copy_constructible(copy_constructible const&) {} | |
70 | ~copy_constructible() {} | |
71 | void dummy_member() const {} | |
72 | ||
7c673cae | 73 | private: |
b32b8144 FG |
74 | copy_constructible& operator=(copy_constructible const&); |
75 | copy_constructible() {} | |
7c673cae FG |
76 | }; |
77 | ||
78 | class copy_constructible_equality_comparable | |
79 | { | |
80 | public: | |
b32b8144 FG |
81 | copy_constructible_equality_comparable(constructor_param const&) {} |
82 | ||
83 | copy_constructible_equality_comparable( | |
84 | copy_constructible_equality_comparable const&) | |
85 | { | |
86 | } | |
7c673cae | 87 | |
b32b8144 | 88 | ~copy_constructible_equality_comparable() {} |
7c673cae | 89 | |
b32b8144 | 90 | void dummy_member() const {} |
7c673cae | 91 | |
7c673cae | 92 | private: |
b32b8144 FG |
93 | copy_constructible_equality_comparable& operator=( |
94 | copy_constructible_equality_comparable const&); | |
95 | copy_constructible_equality_comparable() {} | |
7c673cae | 96 | #if BOOST_UNORDERED_CHECK_ADDR_OPERATOR_NOT_USED |
b32b8144 FG |
97 | ampersand_operator_used operator&() const |
98 | { | |
99 | return ampersand_operator_used(); | |
100 | } | |
7c673cae FG |
101 | #endif |
102 | }; | |
103 | ||
b32b8144 FG |
104 | bool operator==(copy_constructible_equality_comparable, |
105 | copy_constructible_equality_comparable) | |
7c673cae | 106 | { |
b32b8144 | 107 | return true; |
7c673cae FG |
108 | } |
109 | ||
b32b8144 FG |
110 | bool operator!=(copy_constructible_equality_comparable, |
111 | copy_constructible_equality_comparable) | |
7c673cae | 112 | { |
b32b8144 | 113 | return false; |
7c673cae FG |
114 | } |
115 | ||
116 | class default_assignable | |
117 | { | |
118 | public: | |
b32b8144 | 119 | default_assignable(constructor_param const&) {} |
7c673cae | 120 | |
b32b8144 | 121 | default_assignable() {} |
7c673cae | 122 | |
b32b8144 | 123 | default_assignable(default_assignable const&) {} |
7c673cae | 124 | |
b32b8144 | 125 | default_assignable& operator=(default_assignable const&) { return *this; } |
7c673cae | 126 | |
b32b8144 | 127 | ~default_assignable() {} |
7c673cae | 128 | |
b32b8144 | 129 | void dummy_member() const {} |
7c673cae FG |
130 | |
131 | #if BOOST_UNORDERED_CHECK_ADDR_OPERATOR_NOT_USED | |
b32b8144 FG |
132 | ampersand_operator_used operator&() const |
133 | { | |
134 | return ampersand_operator_used(); | |
135 | } | |
7c673cae FG |
136 | #endif |
137 | }; | |
138 | ||
139 | class assignable | |
140 | { | |
141 | public: | |
b32b8144 FG |
142 | assignable(constructor_param const&) {} |
143 | assignable(assignable const&) {} | |
144 | assignable& operator=(assignable const&) { return *this; } | |
145 | ~assignable() {} | |
146 | void dummy_member() const {} | |
147 | ||
7c673cae | 148 | private: |
b32b8144 | 149 | assignable() {} |
7c673cae | 150 | #if BOOST_UNORDERED_CHECK_ADDR_OPERATOR_NOT_USED |
b32b8144 FG |
151 | ampersand_operator_used operator&() const |
152 | { | |
153 | return ampersand_operator_used(); | |
154 | } | |
7c673cae FG |
155 | #endif |
156 | }; | |
157 | ||
b32b8144 FG |
158 | struct movable_init |
159 | { | |
160 | }; | |
7c673cae FG |
161 | |
162 | class movable1 | |
163 | { | |
b32b8144 | 164 | BOOST_MOVABLE_BUT_NOT_COPYABLE(movable1) |
7c673cae FG |
165 | |
166 | public: | |
b32b8144 FG |
167 | movable1(constructor_param const&) {} |
168 | movable1() {} | |
169 | explicit movable1(movable_init) {} | |
170 | movable1(BOOST_RV_REF(movable1)) {} | |
171 | movable1& operator=(BOOST_RV_REF(movable1)) { return *this; } | |
172 | ~movable1() {} | |
173 | void dummy_member() const {} | |
7c673cae FG |
174 | }; |
175 | ||
176 | #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) | |
177 | class movable2 | |
178 | { | |
179 | public: | |
b32b8144 FG |
180 | movable2(constructor_param const&) {} |
181 | explicit movable2(movable_init) {} | |
182 | movable2(movable2&&) {} | |
183 | ~movable2() {} | |
184 | movable2& operator=(movable2&&) { return *this; } | |
185 | void dummy_member() const {} | |
186 | ||
7c673cae | 187 | private: |
b32b8144 FG |
188 | movable2() {} |
189 | movable2(movable2 const&); | |
190 | movable2& operator=(movable2 const&); | |
7c673cae FG |
191 | }; |
192 | #else | |
193 | typedef movable1 movable2; | |
194 | #endif | |
195 | ||
b32b8144 | 196 | template <class T> class hash |
7c673cae FG |
197 | { |
198 | public: | |
b32b8144 FG |
199 | hash(constructor_param const&) {} |
200 | hash() {} | |
201 | hash(hash const&) {} | |
202 | hash& operator=(hash const&) { return *this; } | |
203 | ~hash() {} | |
7c673cae | 204 | |
b32b8144 | 205 | std::size_t operator()(T const&) const { return 0; } |
7c673cae | 206 | #if BOOST_UNORDERED_CHECK_ADDR_OPERATOR_NOT_USED |
b32b8144 FG |
207 | ampersand_operator_used operator&() const |
208 | { | |
209 | return ampersand_operator_used(); | |
210 | } | |
7c673cae FG |
211 | #endif |
212 | }; | |
213 | ||
b32b8144 | 214 | template <class T> class equal_to |
7c673cae FG |
215 | { |
216 | public: | |
b32b8144 FG |
217 | equal_to(constructor_param const&) {} |
218 | equal_to() {} | |
219 | equal_to(equal_to const&) {} | |
220 | equal_to& operator=(equal_to const&) { return *this; } | |
221 | ~equal_to() {} | |
7c673cae | 222 | |
b32b8144 | 223 | bool operator()(T const&, T const&) const { return true; } |
7c673cae | 224 | #if BOOST_UNORDERED_CHECK_ADDR_OPERATOR_NOT_USED |
b32b8144 FG |
225 | ampersand_operator_used operator&() const |
226 | { | |
227 | return ampersand_operator_used(); | |
228 | } | |
7c673cae FG |
229 | #endif |
230 | }; | |
231 | ||
232 | template <class T> class ptr; | |
233 | template <class T> class const_ptr; | |
234 | ||
235 | struct void_ptr | |
236 | { | |
237 | #if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) | |
b32b8144 FG |
238 | template <typename T> friend class ptr; |
239 | ||
7c673cae FG |
240 | private: |
241 | #endif | |
242 | ||
b32b8144 | 243 | void* ptr_; |
7c673cae FG |
244 | |
245 | public: | |
b32b8144 | 246 | void_ptr() : ptr_(0) {} |
7c673cae | 247 | |
b32b8144 | 248 | template <typename T> explicit void_ptr(ptr<T> const& x) : ptr_(x.ptr_) {} |
7c673cae | 249 | |
b32b8144 FG |
250 | // I'm not using the safe bool idiom because the containers should be |
251 | // able to cope with bool conversions. | |
252 | operator bool() const { return !!ptr_; } | |
7c673cae | 253 | |
b32b8144 FG |
254 | bool operator==(void_ptr const& x) const { return ptr_ == x.ptr_; } |
255 | bool operator!=(void_ptr const& x) const { return ptr_ != x.ptr_; } | |
7c673cae FG |
256 | }; |
257 | ||
258 | class void_const_ptr | |
259 | { | |
260 | #if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) | |
b32b8144 FG |
261 | template <typename T> friend class const_ptr; |
262 | ||
7c673cae FG |
263 | private: |
264 | #endif | |
265 | ||
b32b8144 | 266 | void* ptr_; |
7c673cae FG |
267 | |
268 | public: | |
b32b8144 | 269 | void_const_ptr() : ptr_(0) {} |
7c673cae | 270 | |
b32b8144 FG |
271 | template <typename T> |
272 | explicit void_const_ptr(const_ptr<T> const& x) : ptr_(x.ptr_) | |
273 | { | |
274 | } | |
7c673cae | 275 | |
b32b8144 FG |
276 | // I'm not using the safe bool idiom because the containers should be |
277 | // able to cope with bool conversions. | |
278 | operator bool() const { return !!ptr_; } | |
7c673cae | 279 | |
b32b8144 FG |
280 | bool operator==(void_const_ptr const& x) const { return ptr_ == x.ptr_; } |
281 | bool operator!=(void_const_ptr const& x) const { return ptr_ != x.ptr_; } | |
7c673cae FG |
282 | }; |
283 | ||
b32b8144 | 284 | template <class T> class ptr |
7c673cae | 285 | { |
b32b8144 FG |
286 | friend class allocator<T>; |
287 | friend class const_ptr<T>; | |
288 | friend struct void_ptr; | |
289 | ||
290 | T* ptr_; | |
7c673cae | 291 | |
b32b8144 | 292 | ptr(T* x) : ptr_(x) {} |
7c673cae | 293 | |
7c673cae | 294 | public: |
b32b8144 FG |
295 | ptr() : ptr_(0) {} |
296 | explicit ptr(void_ptr const& x) : ptr_((T*)x.ptr_) {} | |
297 | ||
298 | T& operator*() const { return *ptr_; } | |
299 | T* operator->() const { return ptr_; } | |
300 | ptr& operator++() | |
301 | { | |
302 | ++ptr_; | |
303 | return *this; | |
304 | } | |
305 | ptr operator++(int) | |
306 | { | |
307 | ptr tmp(*this); | |
308 | ++ptr_; | |
309 | return tmp; | |
310 | } | |
311 | ptr operator+(std::ptrdiff_t s) const { return ptr<T>(ptr_ + s); } | |
312 | friend ptr operator+(std::ptrdiff_t s, ptr p) | |
313 | { | |
314 | return ptr<T>(s + p.ptr_); | |
315 | } | |
316 | T& operator[](std::ptrdiff_t s) const { return ptr_[s]; } | |
317 | bool operator!() const { return !ptr_; } | |
318 | ||
319 | // I'm not using the safe bool idiom because the containers should be | |
320 | // able to cope with bool conversions. | |
321 | operator bool() const { return !!ptr_; } | |
322 | ||
323 | bool operator==(ptr const& x) const { return ptr_ == x.ptr_; } | |
324 | bool operator!=(ptr const& x) const { return ptr_ != x.ptr_; } | |
325 | bool operator<(ptr const& x) const { return ptr_ < x.ptr_; } | |
326 | bool operator>(ptr const& x) const { return ptr_ > x.ptr_; } | |
327 | bool operator<=(ptr const& x) const { return ptr_ <= x.ptr_; } | |
328 | bool operator>=(ptr const& x) const { return ptr_ >= x.ptr_; } | |
7c673cae | 329 | #if BOOST_UNORDERED_CHECK_ADDR_OPERATOR_NOT_USED |
b32b8144 FG |
330 | ampersand_operator_used operator&() const |
331 | { | |
332 | return ampersand_operator_used(); | |
333 | } | |
7c673cae FG |
334 | #endif |
335 | }; | |
336 | ||
b32b8144 | 337 | template <class T> class const_ptr |
7c673cae | 338 | { |
b32b8144 FG |
339 | friend class allocator<T>; |
340 | friend struct const_void_ptr; | |
341 | ||
342 | T const* ptr_; | |
7c673cae | 343 | |
b32b8144 | 344 | const_ptr(T const* ptr) : ptr_(ptr) {} |
7c673cae | 345 | |
7c673cae | 346 | public: |
b32b8144 FG |
347 | const_ptr() : ptr_(0) {} |
348 | const_ptr(ptr<T> const& x) : ptr_(x.ptr_) {} | |
349 | explicit const_ptr(void_const_ptr const& x) : ptr_((T const*)x.ptr_) {} | |
350 | ||
351 | T const& operator*() const { return *ptr_; } | |
352 | T const* operator->() const { return ptr_; } | |
353 | const_ptr& operator++() | |
354 | { | |
355 | ++ptr_; | |
356 | return *this; | |
357 | } | |
358 | const_ptr operator++(int) | |
359 | { | |
360 | const_ptr tmp(*this); | |
361 | ++ptr_; | |
362 | return tmp; | |
363 | } | |
364 | const_ptr operator+(std::ptrdiff_t s) const | |
365 | { | |
366 | return const_ptr(ptr_ + s); | |
367 | } | |
368 | friend const_ptr operator+(std::ptrdiff_t s, const_ptr p) | |
369 | { | |
370 | return ptr<T>(s + p.ptr_); | |
371 | } | |
372 | T const& operator[](int s) const { return ptr_[s]; } | |
373 | bool operator!() const { return !ptr_; } | |
374 | operator bool() const { return !!ptr_; } | |
375 | ||
376 | bool operator==(const_ptr const& x) const { return ptr_ == x.ptr_; } | |
377 | bool operator!=(const_ptr const& x) const { return ptr_ != x.ptr_; } | |
378 | bool operator<(const_ptr const& x) const { return ptr_ < x.ptr_; } | |
379 | bool operator>(const_ptr const& x) const { return ptr_ > x.ptr_; } | |
380 | bool operator<=(const_ptr const& x) const { return ptr_ <= x.ptr_; } | |
381 | bool operator>=(const_ptr const& x) const { return ptr_ >= x.ptr_; } | |
7c673cae | 382 | #if BOOST_UNORDERED_CHECK_ADDR_OPERATOR_NOT_USED |
b32b8144 FG |
383 | ampersand_operator_used operator&() const |
384 | { | |
385 | return ampersand_operator_used(); | |
386 | } | |
7c673cae FG |
387 | #endif |
388 | }; | |
389 | ||
b32b8144 FG |
390 | template <class T> class allocator |
391 | { | |
392 | public: | |
393 | typedef std::size_t size_type; | |
394 | typedef std::ptrdiff_t difference_type; | |
395 | typedef void_ptr void_pointer; | |
396 | typedef void_const_ptr const_void_pointer; | |
397 | typedef ptr<T> pointer; | |
398 | typedef const_ptr<T> const_pointer; | |
399 | typedef T& reference; | |
400 | typedef T const& const_reference; | |
401 | typedef T value_type; | |
402 | ||
403 | template <class U> struct rebind | |
404 | { | |
405 | typedef allocator<U> other; | |
406 | }; | |
407 | ||
408 | allocator() {} | |
409 | template <class Y> allocator(allocator<Y> const&) {} | |
410 | allocator(allocator const&) {} | |
411 | ~allocator() {} | |
412 | ||
413 | pointer address(reference r) { return pointer(&r); } | |
414 | const_pointer address(const_reference r) { return const_pointer(&r); } | |
415 | ||
416 | pointer allocate(size_type n) | |
417 | { | |
418 | return pointer(static_cast<T*>(::operator new(n * sizeof(T)))); | |
419 | } | |
420 | ||
421 | template <class Y> pointer allocate(size_type n, const_ptr<Y>) | |
422 | { | |
423 | return pointer(static_cast<T*>(::operator new(n * sizeof(T)))); | |
424 | } | |
425 | ||
426 | void deallocate(pointer p, size_type) | |
427 | { | |
428 | ::operator delete((void*)p.ptr_); | |
429 | } | |
430 | ||
431 | void construct(T* p, T const& t) { new ((void*)p) T(t); } | |
432 | ||
433 | #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
434 | template <class... Args> void construct(T* p, BOOST_FWD_REF(Args)... args) | |
435 | { | |
436 | new ((void*)p) T(boost::forward<Args>(args)...); | |
437 | } | |
438 | #endif | |
439 | ||
440 | void destroy(T* p) { p->~T(); } | |
441 | ||
442 | size_type max_size() const { return 1000; } | |
443 | ||
444 | #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) || \ | |
445 | BOOST_WORKAROUND(BOOST_MSVC, <= 1300) | |
446 | public: | |
447 | allocator& operator=(allocator const&) { return *this; } | |
448 | #else | |
449 | private: | |
450 | allocator& operator=(allocator const&); | |
451 | #endif | |
452 | #if BOOST_UNORDERED_CHECK_ADDR_OPERATOR_NOT_USED | |
453 | ampersand_operator_used operator&() const | |
454 | { | |
455 | return ampersand_operator_used(); | |
456 | } | |
457 | #endif | |
458 | }; | |
459 | ||
460 | template <class T> class allocator<T const> | |
7c673cae FG |
461 | { |
462 | public: | |
b32b8144 FG |
463 | typedef std::size_t size_type; |
464 | typedef std::ptrdiff_t difference_type; | |
465 | typedef void_ptr void_pointer; | |
466 | typedef void_const_ptr const_void_pointer; | |
467 | // Maybe these two should be const_ptr<T> | |
468 | typedef ptr<T const> pointer; | |
469 | typedef const_ptr<T const> const_pointer; | |
470 | typedef T const& reference; | |
471 | typedef T const& const_reference; | |
472 | typedef T const value_type; | |
473 | ||
474 | template <class U> struct rebind | |
475 | { | |
476 | typedef allocator<U> other; | |
477 | }; | |
478 | ||
479 | allocator() {} | |
480 | template <class Y> allocator(allocator<Y> const&) {} | |
481 | allocator(allocator const&) {} | |
482 | ~allocator() {} | |
483 | ||
484 | const_pointer address(const_reference r) { return const_pointer(&r); } | |
485 | ||
486 | pointer allocate(size_type n) | |
487 | { | |
488 | return pointer(static_cast<T const*>(::operator new(n * sizeof(T)))); | |
489 | } | |
490 | ||
491 | template <class Y> pointer allocate(size_type n, const_ptr<Y>) | |
492 | { | |
493 | return pointer(static_cast<T const*>(::operator new(n * sizeof(T)))); | |
494 | } | |
495 | ||
496 | void deallocate(pointer p, size_type) | |
497 | { | |
498 | ::operator delete((void*)p.ptr_); | |
499 | } | |
500 | ||
501 | void construct(T const* p, T const& t) { new ((void*)p) T(t); } | |
7c673cae FG |
502 | |
503 | #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
b32b8144 FG |
504 | template <class... Args> |
505 | void construct(T const* p, BOOST_FWD_REF(Args)... args) | |
506 | { | |
507 | new ((void*)p) T(boost::forward<Args>(args)...); | |
508 | } | |
7c673cae FG |
509 | #endif |
510 | ||
b32b8144 | 511 | void destroy(T const* p) { p->~T(); } |
7c673cae | 512 | |
b32b8144 | 513 | size_type max_size() const { return 1000; } |
7c673cae | 514 | |
b32b8144 FG |
515 | #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) || \ |
516 | BOOST_WORKAROUND(BOOST_MSVC, <= 1300) | |
517 | public: | |
518 | allocator& operator=(allocator const&) { return *this; } | |
7c673cae | 519 | #else |
b32b8144 FG |
520 | private: |
521 | allocator& operator=(allocator const&); | |
7c673cae FG |
522 | #endif |
523 | #if BOOST_UNORDERED_CHECK_ADDR_OPERATOR_NOT_USED | |
b32b8144 FG |
524 | ampersand_operator_used operator&() const |
525 | { | |
526 | return ampersand_operator_used(); | |
527 | } | |
7c673cae FG |
528 | #endif |
529 | }; | |
530 | ||
531 | template <class T> | |
532 | inline bool operator==(allocator<T> const&, allocator<T> const&) | |
533 | { | |
b32b8144 | 534 | return true; |
7c673cae FG |
535 | } |
536 | ||
537 | template <class T> | |
538 | inline bool operator!=(allocator<T> const&, allocator<T> const&) | |
539 | { | |
b32b8144 | 540 | return false; |
7c673cae FG |
541 | } |
542 | ||
b32b8144 | 543 | template <class T> void swap(allocator<T>&, allocator<T>&) {} |
7c673cae FG |
544 | |
545 | // C++11 allocator | |
546 | // | |
547 | // Not a fully minimal C++11 allocator, just what I support. Hopefully will | |
548 | // cut down further in the future. | |
549 | ||
b32b8144 | 550 | template <class T> class cxx11_allocator |
7c673cae FG |
551 | { |
552 | public: | |
b32b8144 FG |
553 | typedef T value_type; |
554 | // template <class U> struct rebind { typedef cxx11_allocator<U> other; }; | |
7c673cae | 555 | |
b32b8144 FG |
556 | cxx11_allocator() {} |
557 | template <class Y> cxx11_allocator(cxx11_allocator<Y> const&) {} | |
558 | cxx11_allocator(cxx11_allocator const&) {} | |
559 | ~cxx11_allocator() {} | |
7c673cae | 560 | |
b32b8144 FG |
561 | T* address(T& r) { return &r; } |
562 | T const* address(T const& r) { return &r; } | |
7c673cae | 563 | |
b32b8144 FG |
564 | T* allocate(std::size_t n) |
565 | { | |
566 | return static_cast<T*>(::operator new(n * sizeof(T))); | |
567 | } | |
7c673cae | 568 | |
b32b8144 FG |
569 | template <class Y> T* allocate(std::size_t n, const_ptr<Y>) |
570 | { | |
571 | return static_cast<T*>(::operator new(n * sizeof(T))); | |
572 | } | |
7c673cae | 573 | |
b32b8144 | 574 | void deallocate(T* p, std::size_t) { ::operator delete((void*)p); } |
7c673cae | 575 | |
b32b8144 | 576 | void construct(T* p, T const& t) { new ((void*)p) T(t); } |
7c673cae FG |
577 | |
578 | #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
b32b8144 FG |
579 | template <class... Args> void construct(T* p, BOOST_FWD_REF(Args)... args) |
580 | { | |
581 | new ((void*)p) T(boost::forward<Args>(args)...); | |
582 | } | |
7c673cae FG |
583 | #endif |
584 | ||
b32b8144 | 585 | void destroy(T* p) { p->~T(); } |
7c673cae | 586 | |
b32b8144 | 587 | std::size_t max_size() const { return 1000u; } |
7c673cae FG |
588 | }; |
589 | ||
590 | template <class T> | |
591 | inline bool operator==(cxx11_allocator<T> const&, cxx11_allocator<T> const&) | |
592 | { | |
b32b8144 | 593 | return true; |
7c673cae FG |
594 | } |
595 | ||
596 | template <class T> | |
597 | inline bool operator!=(cxx11_allocator<T> const&, cxx11_allocator<T> const&) | |
598 | { | |
b32b8144 | 599 | return false; |
7c673cae FG |
600 | } |
601 | ||
b32b8144 FG |
602 | template <class T> void swap(cxx11_allocator<T>&, cxx11_allocator<T>&) {} |
603 | } | |
7c673cae FG |
604 | } |
605 | ||
606 | #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) | |
607 | namespace boost { | |
608 | #else | |
609 | namespace test { | |
b32b8144 | 610 | namespace minimal { |
7c673cae | 611 | #endif |
b32b8144 FG |
612 | std::size_t hash_value(test::minimal::copy_constructible_equality_comparable) |
613 | { | |
614 | return 1; | |
615 | } | |
7c673cae | 616 | #if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) |
7c673cae | 617 | } |
b32b8144 FG |
618 | } |
619 | #else | |
620 | } | |
7c673cae FG |
621 | #endif |
622 | ||
7c673cae FG |
623 | #if defined(BOOST_MSVC) |
624 | #pragma warning(pop) | |
625 | #endif | |
626 | ||
627 | #endif |