| 107 | size_type capacity() const noexcept { return capacity_; } |
| 108 | |
| 109 | void shrink_to_fit() { |
| 110 | if (size_ < capacity_) { |
| 111 | T* new_data = allocate(size_); |
| 112 | |
| 113 | if (!new_data) { |
| 114 | for(;;); |
| 115 | } |
| 116 | |
| 117 | for (size_type i = 0; i < size_; ++i) { |
| 118 | new (&new_data[i]) T(std::move(data_[i])); |
| 119 | data_[i].~T(); |
| 120 | } |
| 121 | |
| 122 | deallocate(data_); |
| 123 | data_ = new_data; |
| 124 | capacity_ = size_; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | void reserve(size_type new_capacity) { |
| 129 | if (new_capacity > capacity_) { |