Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | #ifndef _LIBCPP_SPLIT_BUFFER |
| 3 | #define _LIBCPP_SPLIT_BUFFER |
| 4 | |
| 5 | #include <__config> |
| 6 | #include <type_traits> |
| 7 | #include <algorithm> |
| 8 | |
| 9 | #pragma GCC system_header |
| 10 | |
| 11 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 12 | |
| 13 | template <bool> |
| 14 | class __split_buffer_common |
| 15 | { |
| 16 | protected: |
| 17 | void __throw_length_error() const; |
| 18 | void __throw_out_of_range() const; |
| 19 | }; |
| 20 | |
Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 +0000 | [diff] [blame] | 21 | template <class _Tp, class _Allocator = allocator<_Tp> > |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 22 | struct __split_buffer |
| 23 | : private __split_buffer_common<true> |
| 24 | { |
| 25 | private: |
| 26 | __split_buffer(const __split_buffer&); |
| 27 | __split_buffer& operator=(const __split_buffer&); |
| 28 | public: |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 29 | typedef _Tp value_type; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 30 | typedef _Allocator allocator_type; |
| 31 | typedef typename remove_reference<allocator_type>::type __alloc_rr; |
| 32 | typedef allocator_traits<__alloc_rr> __alloc_traits; |
| 33 | typedef value_type& reference; |
| 34 | typedef const value_type& const_reference; |
| 35 | typedef typename __alloc_traits::size_type size_type; |
| 36 | typedef typename __alloc_traits::difference_type difference_type; |
| 37 | typedef typename __alloc_traits::pointer pointer; |
| 38 | typedef typename __alloc_traits::const_pointer const_pointer; |
| 39 | typedef pointer iterator; |
| 40 | typedef const_pointer const_iterator; |
| 41 | |
| 42 | pointer __first_; |
| 43 | pointer __begin_; |
| 44 | pointer __end_; |
| 45 | __compressed_pair<pointer, allocator_type> __end_cap_; |
| 46 | |
| 47 | typedef typename add_lvalue_reference<allocator_type>::type __alloc_ref; |
| 48 | typedef typename add_lvalue_reference<allocator_type>::type __alloc_const_ref; |
| 49 | |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 50 | _LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();} |
| 51 | _LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();} |
| 52 | _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();} |
| 53 | _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 54 | |
Howard Hinnant | 009b2c4 | 2011-06-03 15:16:49 +0000 | [diff] [blame] | 55 | __split_buffer() |
| 56 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 57 | explicit __split_buffer(__alloc_rr& __a); |
| 58 | explicit __split_buffer(const __alloc_rr& __a); |
| 59 | __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a); |
| 60 | ~__split_buffer(); |
| 61 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 62 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 63 | __split_buffer(__split_buffer&& __c) |
| 64 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 65 | __split_buffer(__split_buffer&& __c, const __alloc_rr& __a); |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 66 | __split_buffer& operator=(__split_buffer&& __c) |
| 67 | _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value && |
| 68 | is_nothrow_move_assignable<allocator_type>::value) || |
| 69 | !__alloc_traits::propagate_on_container_move_assignment::value); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 70 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 71 | |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 72 | _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;} |
| 73 | _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;} |
| 74 | _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;} |
| 75 | _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 76 | |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 77 | _LIBCPP_INLINE_VISIBILITY |
| 78 | void clear() _NOEXCEPT |
| 79 | {__destruct_at_end(__begin_);} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 80 | _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);} |
| 81 | _LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;} |
| 82 | _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);} |
| 83 | _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);} |
| 84 | _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);} |
| 85 | |
| 86 | _LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;} |
| 87 | _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;} |
| 88 | _LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);} |
| 89 | _LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);} |
| 90 | |
| 91 | void reserve(size_type __n); |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 92 | void shrink_to_fit() _NOEXCEPT; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 93 | void push_front(const_reference __x); |
| 94 | void push_back(const_reference __x); |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 95 | #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 96 | void push_front(value_type&& __x); |
| 97 | void push_back(value_type&& __x); |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 98 | #if !defined(_LIBCPP_HAS_NO_VARIADICS) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 99 | template <class... _Args> |
| 100 | void emplace_back(_Args&&... __args); |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 101 | #endif // !defined(_LIBCPP_HAS_NO_VARIADICS) |
| 102 | #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 103 | |
| 104 | _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);} |
| 105 | _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);} |
| 106 | |
| 107 | void __construct_at_end(size_type __n); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 108 | void __construct_at_end(size_type __n, const_reference __x); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 109 | template <class _InputIter> |
| 110 | typename enable_if |
| 111 | < |
| 112 | __is_input_iterator<_InputIter>::value && |
| 113 | !__is_forward_iterator<_InputIter>::value, |
| 114 | void |
| 115 | >::type |
| 116 | __construct_at_end(_InputIter __first, _InputIter __last); |
| 117 | template <class _ForwardIterator> |
| 118 | typename enable_if |
| 119 | < |
| 120 | __is_forward_iterator<_ForwardIterator>::value, |
| 121 | void |
| 122 | >::type |
| 123 | __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); |
| 124 | |
| 125 | _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin) |
Howard Hinnant | 1468b66 | 2010-11-19 22:17:28 +0000 | [diff] [blame] | 126 | {__destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 127 | void __destruct_at_begin(pointer __new_begin, false_type); |
| 128 | void __destruct_at_begin(pointer __new_begin, true_type); |
| 129 | |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 130 | _LIBCPP_INLINE_VISIBILITY |
| 131 | void __destruct_at_end(pointer __new_last) _NOEXCEPT |
Howard Hinnant | 1468b66 | 2010-11-19 22:17:28 +0000 | [diff] [blame] | 132 | {__destruct_at_end(__new_last, is_trivially_destructible<value_type>());} |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 133 | void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT; |
| 134 | void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 135 | |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 136 | void swap(__split_buffer& __x) |
| 137 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| |
| 138 | __is_nothrow_swappable<__alloc_rr>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 139 | |
| 140 | bool __invariants() const; |
| 141 | |
| 142 | private: |
Howard Hinnant | 333f50d | 2010-09-21 20:16:37 +0000 | [diff] [blame] | 143 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 144 | void __move_assign_alloc(const __split_buffer& __c, true_type) |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 145 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 146 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 147 | __alloc() = _VSTD::move(__c.__alloc()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 148 | } |
| 149 | |
Howard Hinnant | 333f50d | 2010-09-21 20:16:37 +0000 | [diff] [blame] | 150 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 151 | void __move_assign_alloc(const __split_buffer& __c, false_type) _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 152 | {} |
| 153 | |
Howard Hinnant | 333f50d | 2010-09-21 20:16:37 +0000 | [diff] [blame] | 154 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 155 | static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y) |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 156 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| |
| 157 | __is_nothrow_swappable<__alloc_rr>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 158 | {__swap_alloc(__x, __y, integral_constant<bool, |
| 159 | __alloc_traits::propagate_on_container_swap::value>());} |
| 160 | |
Howard Hinnant | 333f50d | 2010-09-21 20:16:37 +0000 | [diff] [blame] | 161 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 162 | static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y, true_type) |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 163 | _NOEXCEPT_(__is_nothrow_swappable<__alloc_rr>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 164 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 165 | using _VSTD::swap; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 166 | swap(__x, __y); |
| 167 | } |
Howard Hinnant | 333f50d | 2010-09-21 20:16:37 +0000 | [diff] [blame] | 168 | |
| 169 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 170 | static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y, false_type) _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 171 | {} |
| 172 | }; |
| 173 | |
| 174 | template <class _Tp, class _Allocator> |
| 175 | bool |
| 176 | __split_buffer<_Tp, _Allocator>::__invariants() const |
| 177 | { |
| 178 | if (__first_ == nullptr) |
| 179 | { |
| 180 | if (__begin_ != nullptr) |
| 181 | return false; |
| 182 | if (__end_ != nullptr) |
| 183 | return false; |
| 184 | if (__end_cap() != nullptr) |
| 185 | return false; |
| 186 | } |
| 187 | else |
| 188 | { |
| 189 | if (__begin_ < __first_) |
| 190 | return false; |
| 191 | if (__end_ < __begin_) |
| 192 | return false; |
| 193 | if (__end_cap() < __end_) |
| 194 | return false; |
| 195 | } |
| 196 | return true; |
| 197 | } |
| 198 | |
| 199 | // Default constructs __n objects starting at __end_ |
| 200 | // throws if construction throws |
| 201 | // Precondition: __n > 0 |
| 202 | // Precondition: size() + __n <= capacity() |
| 203 | // Postcondition: size() == size() + __n |
| 204 | template <class _Tp, class _Allocator> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 205 | void |
| 206 | __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n) |
| 207 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 208 | __alloc_rr& __a = this->__alloc(); |
| 209 | do |
| 210 | { |
Howard Hinnant | 5f25594 | 2011-08-28 15:21:29 +0000 | [diff] [blame^] | 211 | __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_)); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 212 | ++this->__end_; |
| 213 | --__n; |
| 214 | } while (__n > 0); |
| 215 | } |
| 216 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 217 | // Copy constructs __n objects starting at __end_ from __x |
| 218 | // throws if construction throws |
| 219 | // Precondition: __n > 0 |
| 220 | // Precondition: size() + __n <= capacity() |
| 221 | // Postcondition: size() == old size() + __n |
| 222 | // Postcondition: [i] == __x for all i in [size() - __n, __n) |
| 223 | template <class _Tp, class _Allocator> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 224 | void |
| 225 | __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) |
| 226 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 227 | __alloc_rr& __a = this->__alloc(); |
| 228 | do |
| 229 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 230 | __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), __x); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 231 | ++this->__end_; |
| 232 | --__n; |
| 233 | } while (__n > 0); |
| 234 | } |
| 235 | |
| 236 | template <class _Tp, class _Allocator> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 237 | template <class _InputIter> |
| 238 | typename enable_if |
| 239 | < |
| 240 | __is_input_iterator<_InputIter>::value && |
| 241 | !__is_forward_iterator<_InputIter>::value, |
| 242 | void |
| 243 | >::type |
| 244 | __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last) |
| 245 | { |
| 246 | __alloc_rr& __a = this->__alloc(); |
| 247 | for (; __first != __last; ++__first) |
| 248 | { |
| 249 | if (__end_ == __end_cap()) |
| 250 | { |
| 251 | size_type __old_cap = __end_cap() - __first_; |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 252 | size_type __new_cap = _VSTD::max<size_type>(2 * __old_cap, 8); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 253 | __split_buffer __buf(__new_cap, 0, __a); |
| 254 | for (pointer __p = __begin_; __p != __end_; ++__p, ++__buf.__end_) |
| 255 | __alloc_traits::construct(__buf.__alloc(), |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 256 | _VSTD::__to_raw_pointer(__buf.__end_), _VSTD::move(*__p)); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 257 | swap(__buf); |
| 258 | } |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 259 | __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 260 | ++this->__end_; |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | template <class _Tp, class _Allocator> |
| 265 | template <class _ForwardIterator> |
| 266 | typename enable_if |
| 267 | < |
| 268 | __is_forward_iterator<_ForwardIterator>::value, |
| 269 | void |
| 270 | >::type |
| 271 | __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) |
| 272 | { |
| 273 | __alloc_rr& __a = this->__alloc(); |
| 274 | for (; __first != __last; ++__first) |
| 275 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 276 | __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 277 | ++this->__end_; |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | template <class _Tp, class _Allocator> |
| 282 | _LIBCPP_INLINE_VISIBILITY inline |
| 283 | void |
| 284 | __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) |
| 285 | { |
| 286 | while (__begin_ < __new_begin) |
| 287 | __alloc_traits::destroy(__alloc(), __begin_++); |
| 288 | } |
| 289 | |
| 290 | template <class _Tp, class _Allocator> |
| 291 | _LIBCPP_INLINE_VISIBILITY inline |
| 292 | void |
| 293 | __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type) |
| 294 | { |
| 295 | __begin_ = __new_begin; |
| 296 | } |
| 297 | |
| 298 | template <class _Tp, class _Allocator> |
| 299 | _LIBCPP_INLINE_VISIBILITY inline |
| 300 | void |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 301 | __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 302 | { |
| 303 | while (__new_last < __end_) |
| 304 | __alloc_traits::destroy(__alloc(), --__end_); |
| 305 | } |
| 306 | |
| 307 | template <class _Tp, class _Allocator> |
| 308 | _LIBCPP_INLINE_VISIBILITY inline |
| 309 | void |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 310 | __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 311 | { |
| 312 | __end_ = __new_last; |
| 313 | } |
| 314 | |
| 315 | template <class _Tp, class _Allocator> |
| 316 | __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a) |
| 317 | : __end_cap_(0, __a) |
| 318 | { |
| 319 | __first_ = __cap != 0 ? __alloc_traits::allocate(__alloc(), __cap) : nullptr; |
| 320 | __begin_ = __end_ = __first_ + __start; |
| 321 | __end_cap() = __first_ + __cap; |
| 322 | } |
| 323 | |
| 324 | template <class _Tp, class _Allocator> |
| 325 | _LIBCPP_INLINE_VISIBILITY inline |
| 326 | __split_buffer<_Tp, _Allocator>::__split_buffer() |
Howard Hinnant | 009b2c4 | 2011-06-03 15:16:49 +0000 | [diff] [blame] | 327 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 328 | : __first_(0), __begin_(0), __end_(0), __end_cap_(0) |
| 329 | { |
| 330 | } |
| 331 | |
| 332 | template <class _Tp, class _Allocator> |
| 333 | _LIBCPP_INLINE_VISIBILITY inline |
| 334 | __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a) |
| 335 | : __first_(0), __begin_(0), __end_(0), __end_cap_(0, __a) |
| 336 | { |
| 337 | } |
| 338 | |
| 339 | template <class _Tp, class _Allocator> |
| 340 | _LIBCPP_INLINE_VISIBILITY inline |
| 341 | __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a) |
| 342 | : __first_(0), __begin_(0), __end_(0), __end_cap_(0, __a) |
| 343 | { |
| 344 | } |
| 345 | |
| 346 | template <class _Tp, class _Allocator> |
| 347 | __split_buffer<_Tp, _Allocator>::~__split_buffer() |
| 348 | { |
| 349 | clear(); |
| 350 | if (__first_) |
| 351 | __alloc_traits::deallocate(__alloc(), __first_, capacity()); |
| 352 | } |
| 353 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 354 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 355 | |
| 356 | template <class _Tp, class _Allocator> |
| 357 | __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c) |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 358 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 359 | : __first_(_VSTD::move(__c.__first_)), |
| 360 | __begin_(_VSTD::move(__c.__begin_)), |
| 361 | __end_(_VSTD::move(__c.__end_)), |
| 362 | __end_cap_(_VSTD::move(__c.__end_cap_)) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 363 | { |
| 364 | __c.__first_ = nullptr; |
| 365 | __c.__begin_ = nullptr; |
| 366 | __c.__end_ = nullptr; |
| 367 | __c.__end_cap() = nullptr; |
| 368 | } |
| 369 | |
| 370 | template <class _Tp, class _Allocator> |
| 371 | __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a) |
| 372 | : __end_cap_(__a) |
| 373 | { |
| 374 | if (__a == __c.__alloc()) |
| 375 | { |
| 376 | __first_ = __c.__first_; |
| 377 | __begin_ = __c.__begin_; |
| 378 | __end_ = __c.__end_; |
| 379 | __end_cap() = __c.__end_cap(); |
| 380 | __c.__first_ = nullptr; |
| 381 | __c.__begin_ = nullptr; |
| 382 | __c.__end_ = nullptr; |
| 383 | __c.__end_cap() = nullptr; |
| 384 | } |
| 385 | else |
| 386 | { |
| 387 | size_type __cap = __c.size(); |
| 388 | __first_ = __alloc_traits::allocate(__alloc(), __cap); |
| 389 | __begin_ = __end_ = __first_; |
| 390 | __end_cap() = __first_ + __cap; |
| 391 | typedef move_iterator<iterator> _I; |
| 392 | __construct_at_end(_I(__c.begin()), _I(__c.end())); |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | template <class _Tp, class _Allocator> |
| 397 | __split_buffer<_Tp, _Allocator>& |
| 398 | __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c) |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 399 | _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value && |
| 400 | is_nothrow_move_assignable<allocator_type>::value) || |
| 401 | !__alloc_traits::propagate_on_container_move_assignment::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 402 | { |
| 403 | clear(); |
| 404 | shrink_to_fit(); |
| 405 | __first_ = __c.__first_; |
| 406 | __begin_ = __c.__begin_; |
| 407 | __end_ = __c.__end_; |
| 408 | __end_cap() = __c.__end_cap(); |
| 409 | __move_assign_alloc(__c, |
| 410 | integral_constant<bool, |
| 411 | __alloc_traits::propagate_on_container_move_assignment::value>()); |
| 412 | __c.__first_ = __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr; |
| 413 | return *this; |
| 414 | } |
| 415 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 416 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 417 | |
| 418 | template <class _Tp, class _Allocator> |
| 419 | void |
| 420 | __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x) |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 421 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| |
| 422 | __is_nothrow_swappable<__alloc_rr>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 423 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 424 | _VSTD::swap(__first_, __x.__first_); |
| 425 | _VSTD::swap(__begin_, __x.__begin_); |
| 426 | _VSTD::swap(__end_, __x.__end_); |
| 427 | _VSTD::swap(__end_cap(), __x.__end_cap()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 428 | __swap_alloc(__alloc(), __x.__alloc()); |
| 429 | } |
| 430 | |
| 431 | template <class _Tp, class _Allocator> |
| 432 | void |
| 433 | __split_buffer<_Tp, _Allocator>::reserve(size_type __n) |
| 434 | { |
| 435 | if (__n < capacity()) |
| 436 | { |
| 437 | __split_buffer<value_type, __alloc_rr&> __t(__n, 0, __alloc()); |
| 438 | __t.__construct_at_end(move_iterator<pointer>(__begin_), |
| 439 | move_iterator<pointer>(__end_)); |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 440 | _VSTD::swap(__first_, __t.__first_); |
| 441 | _VSTD::swap(__begin_, __t.__begin_); |
| 442 | _VSTD::swap(__end_, __t.__end_); |
| 443 | _VSTD::swap(__end_cap(), __t.__end_cap()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 444 | } |
| 445 | } |
| 446 | |
| 447 | template <class _Tp, class _Allocator> |
| 448 | void |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 449 | __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 450 | { |
| 451 | if (capacity() > size()) |
| 452 | { |
| 453 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 454 | try |
| 455 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 456 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 457 | __split_buffer<value_type, __alloc_rr&> __t(size(), 0, __alloc()); |
| 458 | __t.__construct_at_end(move_iterator<pointer>(__begin_), |
| 459 | move_iterator<pointer>(__end_)); |
| 460 | __t.__end_ = __t.__begin_ + (__end_ - __begin_); |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 461 | _VSTD::swap(__first_, __t.__first_); |
| 462 | _VSTD::swap(__begin_, __t.__begin_); |
| 463 | _VSTD::swap(__end_, __t.__end_); |
| 464 | _VSTD::swap(__end_cap(), __t.__end_cap()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 465 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 466 | } |
| 467 | catch (...) |
| 468 | { |
| 469 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 470 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 471 | } |
| 472 | } |
| 473 | |
| 474 | template <class _Tp, class _Allocator> |
| 475 | void |
| 476 | __split_buffer<_Tp, _Allocator>::push_front(const_reference __x) |
| 477 | { |
| 478 | if (__begin_ == __first_) |
| 479 | { |
| 480 | if (__end_ < __end_cap()) |
| 481 | { |
| 482 | difference_type __d = __end_cap() - __end_; |
| 483 | __d = (__d + 1) / 2; |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 484 | __begin_ = _VSTD::move_backward(__begin_, __end_, __end_ + __d); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 485 | __end_ += __d; |
| 486 | } |
| 487 | else |
| 488 | { |
| 489 | size_type __c = max<size_type>(2 * (__end_cap() - __first_), 1); |
Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 +0000 | [diff] [blame] | 490 | __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 491 | __t.__construct_at_end(move_iterator<pointer>(__begin_), |
| 492 | move_iterator<pointer>(__end_)); |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 493 | _VSTD::swap(__first_, __t.__first_); |
| 494 | _VSTD::swap(__begin_, __t.__begin_); |
| 495 | _VSTD::swap(__end_, __t.__end_); |
| 496 | _VSTD::swap(__end_cap(), __t.__end_cap()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 497 | } |
| 498 | } |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 499 | __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__begin_-1), __x); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 500 | --__begin_; |
| 501 | } |
| 502 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 503 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 504 | |
| 505 | template <class _Tp, class _Allocator> |
| 506 | void |
| 507 | __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x) |
| 508 | { |
| 509 | if (__begin_ == __first_) |
| 510 | { |
| 511 | if (__end_ < __end_cap()) |
| 512 | { |
| 513 | difference_type __d = __end_cap() - __end_; |
| 514 | __d = (__d + 1) / 2; |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 515 | __begin_ = _VSTD::move_backward(__begin_, __end_, __end_ + __d); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 516 | __end_ += __d; |
| 517 | } |
| 518 | else |
| 519 | { |
| 520 | size_type __c = max<size_type>(2 * (__end_cap() - __first_), 1); |
Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 +0000 | [diff] [blame] | 521 | __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 522 | __t.__construct_at_end(move_iterator<pointer>(__begin_), |
| 523 | move_iterator<pointer>(__end_)); |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 524 | _VSTD::swap(__first_, __t.__first_); |
| 525 | _VSTD::swap(__begin_, __t.__begin_); |
| 526 | _VSTD::swap(__end_, __t.__end_); |
| 527 | _VSTD::swap(__end_cap(), __t.__end_cap()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 528 | } |
| 529 | } |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 530 | __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__begin_-1), |
| 531 | _VSTD::move(__x)); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 532 | --__begin_; |
| 533 | } |
| 534 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 535 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 536 | |
| 537 | template <class _Tp, class _Allocator> |
| 538 | _LIBCPP_INLINE_VISIBILITY inline |
| 539 | void |
| 540 | __split_buffer<_Tp, _Allocator>::push_back(const_reference __x) |
| 541 | { |
| 542 | if (__end_ == __end_cap()) |
| 543 | { |
| 544 | if (__begin_ > __first_) |
| 545 | { |
| 546 | difference_type __d = __begin_ - __first_; |
| 547 | __d = (__d + 1) / 2; |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 548 | __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 549 | __begin_ -= __d; |
| 550 | } |
| 551 | else |
| 552 | { |
| 553 | size_type __c = max<size_type>(2 * (__end_cap() - __first_), 1); |
| 554 | __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc()); |
| 555 | __t.__construct_at_end(move_iterator<pointer>(__begin_), |
| 556 | move_iterator<pointer>(__end_)); |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 557 | _VSTD::swap(__first_, __t.__first_); |
| 558 | _VSTD::swap(__begin_, __t.__begin_); |
| 559 | _VSTD::swap(__end_, __t.__end_); |
| 560 | _VSTD::swap(__end_cap(), __t.__end_cap()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 561 | } |
| 562 | } |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 563 | __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_), __x); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 564 | ++__end_; |
| 565 | } |
| 566 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 567 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 568 | |
| 569 | template <class _Tp, class _Allocator> |
| 570 | void |
| 571 | __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x) |
| 572 | { |
| 573 | if (__end_ == __end_cap()) |
| 574 | { |
| 575 | if (__begin_ > __first_) |
| 576 | { |
| 577 | difference_type __d = __begin_ - __first_; |
| 578 | __d = (__d + 1) / 2; |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 579 | __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 580 | __begin_ -= __d; |
| 581 | } |
| 582 | else |
| 583 | { |
| 584 | size_type __c = max<size_type>(2 * (__end_cap() - __first_), 1); |
| 585 | __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc()); |
| 586 | __t.__construct_at_end(move_iterator<pointer>(__begin_), |
| 587 | move_iterator<pointer>(__end_)); |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 588 | _VSTD::swap(__first_, __t.__first_); |
| 589 | _VSTD::swap(__begin_, __t.__begin_); |
| 590 | _VSTD::swap(__end_, __t.__end_); |
| 591 | _VSTD::swap(__end_cap(), __t.__end_cap()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 592 | } |
| 593 | } |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 594 | __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_), |
| 595 | _VSTD::move(__x)); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 596 | ++__end_; |
| 597 | } |
| 598 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 599 | #ifndef _LIBCPP_HAS_NO_VARIADICS |
| 600 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 601 | template <class _Tp, class _Allocator> |
| 602 | template <class... _Args> |
| 603 | void |
| 604 | __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) |
| 605 | { |
| 606 | if (__end_ == __end_cap()) |
| 607 | { |
| 608 | if (__begin_ > __first_) |
| 609 | { |
| 610 | difference_type __d = __begin_ - __first_; |
| 611 | __d = (__d + 1) / 2; |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 612 | __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 613 | __begin_ -= __d; |
| 614 | } |
| 615 | else |
| 616 | { |
| 617 | size_type __c = max<size_type>(2 * (__end_cap() - __first_), 1); |
| 618 | __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc()); |
| 619 | __t.__construct_at_end(move_iterator<pointer>(__begin_), |
| 620 | move_iterator<pointer>(__end_)); |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 621 | _VSTD::swap(__first_, __t.__first_); |
| 622 | _VSTD::swap(__begin_, __t.__begin_); |
| 623 | _VSTD::swap(__end_, __t.__end_); |
| 624 | _VSTD::swap(__end_cap(), __t.__end_cap()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 625 | } |
| 626 | } |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 627 | __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_), |
| 628 | _VSTD::forward<_Args>(__args)...); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 629 | ++__end_; |
| 630 | } |
| 631 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 632 | #endif // _LIBCPP_HAS_NO_VARIADICS |
| 633 | |
| 634 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 635 | |
Howard Hinnant | 0a612b0 | 2011-06-02 20:00:14 +0000 | [diff] [blame] | 636 | template <class _Tp, class _Allocator> |
| 637 | _LIBCPP_INLINE_VISIBILITY inline |
| 638 | void |
| 639 | swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y) |
| 640 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
| 641 | { |
| 642 | __x.swap(__y); |
| 643 | } |
| 644 | |
| 645 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 646 | _LIBCPP_END_NAMESPACE_STD |
| 647 | |
| 648 | #endif // _LIBCPP_SPLIT_BUFFER |