| #ifndef STACK_ALLOCATOR_H |
| #define STACK_ALLOCATOR_H |
| template <class T, std::size_t N> |
| typedef value_type* pointer; |
| typedef const value_type* const_pointer; |
| typedef value_type& reference; |
| typedef const value_type& const_reference; |
| typedef std::size_t size_type; |
| typedef std::ptrdiff_t difference_type; |
| template <class U> struct rebind {typedef stack_allocator<U, N> other;}; |
| stack_allocator() : ptr_(buf_) {} |
| stack_allocator(const stack_allocator&);// = delete; |
| stack_allocator& operator=(const stack_allocator&);// = delete; |
| pointer allocate(size_type n, const void* = 0) |
| if (n > N - (ptr_ - buf_) / sizeof(value_type)) { |
| #ifndef _LIBCPP_NO_EXCEPTIONS |
| void deallocate(pointer p, size_type n) |
| if ((char*)(p + n) == ptr_) |
| size_type max_size() const {return N;} |
| template <class T, std::size_t N> |
| swap(stack_allocator<T, N>& x, stack_allocator<T, N>& y) {} |
| #endif // STACK_ALLOCATOR_H |