Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | #ifndef ALLOC_LAST_H |
| 2 | #define ALLOC_LAST_H |
| 3 | |
| 4 | #include <cassert> |
| 5 | |
| 6 | #include "allocators.h" |
| 7 | |
| 8 | struct alloc_last |
| 9 | { |
| 10 | static bool allocator_constructed; |
| 11 | |
| 12 | typedef A1<int> allocator_type; |
| 13 | |
| 14 | int data_; |
| 15 | |
| 16 | alloc_last() : data_(0) {} |
| 17 | alloc_last(int d) : data_(d) {} |
| 18 | alloc_last(const A1<int>& a) |
| 19 | : data_(0) |
| 20 | { |
| 21 | assert(a.id() == 5); |
| 22 | allocator_constructed = true; |
| 23 | } |
| 24 | |
| 25 | alloc_last(int d, const A1<int>& a) |
| 26 | : data_(d) |
| 27 | { |
| 28 | assert(a.id() == 5); |
| 29 | allocator_constructed = true; |
| 30 | } |
| 31 | |
| 32 | alloc_last(const alloc_last& d, const A1<int>& a) |
| 33 | : data_(d.data_) |
| 34 | { |
| 35 | assert(a.id() == 5); |
| 36 | allocator_constructed = true; |
| 37 | } |
| 38 | |
| 39 | ~alloc_last() {data_ = -1;} |
| 40 | |
| 41 | friend bool operator==(const alloc_last& x, const alloc_last& y) |
| 42 | {return x.data_ == y.data_;} |
| 43 | friend bool operator< (const alloc_last& x, const alloc_last& y) |
| 44 | {return x.data_ < y.data_;} |
| 45 | }; |
| 46 | |
| 47 | bool alloc_last::allocator_constructed = false; |
| 48 | |
| 49 | #endif |