comparison DEPENDENCIES/generic/include/boost/container/list.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
comparison
equal deleted inserted replaced
100:793467b5e61c 101:c530137014c0
1 ////////////////////////////////////////////////////////////////////////////// 1 //////////////////////////////////////////////////////////////////////////////
2 // 2 //
3 // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost 3 // (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file 4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 // 6 //
7 // See http://www.boost.org/libs/container for documentation. 7 // See http://www.boost.org/libs/container for documentation.
8 // 8 //
9 9 //////////////////////////////////////////////////////////////////////////////
10 #ifndef BOOST_CONTAINER_LIST_HPP 10 #ifndef BOOST_CONTAINER_LIST_HPP
11 #define BOOST_CONTAINER_LIST_HPP 11 #define BOOST_CONTAINER_LIST_HPP
12 12
13 #if defined(_MSC_VER) 13 #ifndef BOOST_CONFIG_HPP
14 # include <boost/config.hpp>
15 #endif
16
17 #if defined(BOOST_HAS_PRAGMA_ONCE)
14 # pragma once 18 # pragma once
15 #endif 19 #endif
16 20
17 #include <boost/container/detail/config_begin.hpp> 21 #include <boost/container/detail/config_begin.hpp>
18 #include <boost/container/detail/workaround.hpp> 22 #include <boost/container/detail/workaround.hpp>
23
24 // container
19 #include <boost/container/container_fwd.hpp> 25 #include <boost/container/container_fwd.hpp>
20 #include <boost/container/detail/version_type.hpp> 26 #include <boost/container/new_allocator.hpp> //new_allocator
27 #include <boost/container/throw_exception.hpp>
28 // container/detail
29 #include <boost/container/detail/algorithm.hpp>
30 #include <boost/container/detail/compare_functors.hpp>
31 #include <boost/container/detail/iterator.hpp>
21 #include <boost/container/detail/iterators.hpp> 32 #include <boost/container/detail/iterators.hpp>
22 #include <boost/container/detail/mpl.hpp> 33 #include <boost/container/detail/mpl.hpp>
23 #include <boost/container/throw_exception.hpp> 34 #include <boost/container/detail/node_alloc_holder.hpp>
24 #include <boost/move/utility.hpp> 35 #include <boost/container/detail/version_type.hpp>
36 // move
37 #include <boost/move/utility_core.hpp>
25 #include <boost/move/iterator.hpp> 38 #include <boost/move/iterator.hpp>
39 #include <boost/move/traits.hpp>
40 // move/detail
41 #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
42 # include <boost/move/detail/fwd_macros.hpp>
43 #endif
26 #include <boost/move/detail/move_helpers.hpp> 44 #include <boost/move/detail/move_helpers.hpp>
45
46 // intrusive
27 #include <boost/intrusive/pointer_traits.hpp> 47 #include <boost/intrusive/pointer_traits.hpp>
28 #include <boost/container/detail/utilities.hpp>
29 #include <boost/container/detail/algorithms.hpp>
30 #include <boost/type_traits/has_trivial_destructor.hpp>
31 #include <boost/intrusive/list.hpp> 48 #include <boost/intrusive/list.hpp>
49 // other
32 #include <boost/assert.hpp> 50 #include <boost/assert.hpp>
33 #include <boost/container/detail/node_alloc_holder.hpp> 51 // std
34 52 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
35 #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) 53 #include <initializer_list>
36 #else
37 //Preprocessor library to emulate perfect forwarding
38 #include <boost/container/detail/preprocessor.hpp>
39 #endif 54 #endif
40
41 #include <iterator>
42 #include <utility>
43 #include <memory>
44 #include <functional>
45 #include <algorithm>
46 55
47 namespace boost { 56 namespace boost {
48 namespace container { 57 namespace container {
49 58
50 /// @cond 59 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
51 namespace container_detail { 60 namespace container_detail {
52 61
53 template<class VoidPointer> 62 template<class VoidPointer>
54 struct list_hook 63 struct list_hook
55 { 64 {
73 T &get_data() 82 T &get_data()
74 { return this->m_data; } 83 { return this->m_data; }
75 84
76 const T &get_data() const 85 const T &get_data() const
77 { return this->m_data; } 86 { return this->m_data; }
87 };
88
89 template <class T, class VoidPointer>
90 struct iiterator_node_value_type< list_node<T,VoidPointer> > {
91 typedef T type;
78 }; 92 };
79 93
80 template<class Allocator> 94 template<class Allocator>
81 struct intrusive_list_type 95 struct intrusive_list_type
82 { 96 {
97 >::type container_type; 111 >::type container_type;
98 typedef container_type type ; 112 typedef container_type type ;
99 }; 113 };
100 114
101 } //namespace container_detail { 115 } //namespace container_detail {
102 /// @endcond 116 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
103 117
104 //! A list is a doubly linked list. That is, it is a Sequence that supports both 118 //! A list is a doubly linked list. That is, it is a Sequence that supports both
105 //! forward and backward traversal, and (amortized) constant time insertion and 119 //! forward and backward traversal, and (amortized) constant time insertion and
106 //! removal of elements at the beginning or the end, or in the middle. Lists have 120 //! removal of elements at the beginning or the end, or in the middle. Lists have
107 //! the important property that insertion and splicing do not invalidate iterators 121 //! the important property that insertion and splicing do not invalidate iterators
109 //! to the elements that are removed. The ordering of iterators may be changed 123 //! to the elements that are removed. The ordering of iterators may be changed
110 //! (that is, list<T>::iterator might have a different predecessor or successor 124 //! (that is, list<T>::iterator might have a different predecessor or successor
111 //! after a list operation than it did before), but the iterators themselves will 125 //! after a list operation than it did before), but the iterators themselves will
112 //! not be invalidated or made to point to different elements unless that invalidation 126 //! not be invalidated or made to point to different elements unless that invalidation
113 //! or mutation is explicit. 127 //! or mutation is explicit.
128 //!
129 //! \tparam T The type of object that is stored in the list
130 //! \tparam Allocator The allocator used for all internal memory management
114 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED 131 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
115 template <class T, class Allocator = std::allocator<T> > 132 template <class T, class Allocator = new_allocator<T> >
116 #else 133 #else
117 template <class T, class Allocator> 134 template <class T, class Allocator>
118 #endif 135 #endif
119 class list 136 class list
120 : protected container_detail::node_alloc_holder 137 : protected container_detail::node_alloc_holder
121 <Allocator, typename container_detail::intrusive_list_type<Allocator>::type> 138 <Allocator, typename container_detail::intrusive_list_type<Allocator>::type>
122 { 139 {
123 /// @cond 140 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
124 typedef typename 141 typedef typename
125 container_detail::intrusive_list_type<Allocator>::type Icont; 142 container_detail::intrusive_list_type<Allocator>::type Icont;
126 typedef container_detail::node_alloc_holder<Allocator, Icont> AllocHolder; 143 typedef container_detail::node_alloc_holder<Allocator, Icont> AllocHolder;
127 typedef typename AllocHolder::NodePtr NodePtr; 144 typedef typename AllocHolder::NodePtr NodePtr;
128 typedef typename AllocHolder::NodeAlloc NodeAlloc; 145 typedef typename AllocHolder::NodeAlloc NodeAlloc;
129 typedef typename AllocHolder::ValAlloc ValAlloc; 146 typedef typename AllocHolder::ValAlloc ValAlloc;
130 typedef typename AllocHolder::Node Node; 147 typedef typename AllocHolder::Node Node;
131 typedef container_detail::allocator_destroyer<NodeAlloc> Destroyer; 148 typedef container_detail::allocator_destroyer<NodeAlloc> Destroyer;
132 typedef typename AllocHolder::allocator_v1 allocator_v1;
133 typedef typename AllocHolder::allocator_v2 allocator_v2;
134 typedef typename AllocHolder::alloc_version alloc_version; 149 typedef typename AllocHolder::alloc_version alloc_version;
135 typedef boost::container::allocator_traits<Allocator> allocator_traits_type; 150 typedef boost::container::allocator_traits<Allocator> allocator_traits_type;
136 151 typedef boost::container::equal_to_value<Allocator> equal_to_value_type;
137 class equal_to_value
138 {
139 typedef typename AllocHolder::value_type value_type;
140 const value_type &t_;
141
142 public:
143 equal_to_value(const value_type &t)
144 : t_(t)
145 {}
146
147 bool operator()(const value_type &t)const
148 { return t_ == t; }
149 };
150
151 template<class Pred>
152 struct ValueCompareToNodeCompare
153 : Pred
154 {
155 ValueCompareToNodeCompare(Pred pred)
156 : Pred(pred)
157 {}
158
159 bool operator()(const Node &a, const Node &b) const
160 { return static_cast<const Pred&>(*this)(a.m_data, b.m_data); }
161
162 bool operator()(const Node &a) const
163 { return static_cast<const Pred&>(*this)(a.m_data); }
164 };
165 152
166 BOOST_COPYABLE_AND_MOVABLE(list) 153 BOOST_COPYABLE_AND_MOVABLE(list)
167 154
168 typedef container_detail::iterator<typename Icont::iterator, false> iterator_impl; 155 typedef container_detail::iterator_from_iiterator<typename Icont::iterator, false> iterator_impl;
169 typedef container_detail::iterator<typename Icont::iterator, true> const_iterator_impl; 156 typedef container_detail::iterator_from_iiterator<typename Icont::iterator, true> const_iterator_impl;
170 /// @endcond 157 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
171 158
172 public: 159 public:
173 ////////////////////////////////////////////// 160 //////////////////////////////////////////////
174 // 161 //
175 // types 162 // types
185 typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type; 172 typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type;
186 typedef Allocator allocator_type; 173 typedef Allocator allocator_type;
187 typedef BOOST_CONTAINER_IMPDEF(NodeAlloc) stored_allocator_type; 174 typedef BOOST_CONTAINER_IMPDEF(NodeAlloc) stored_allocator_type;
188 typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator; 175 typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator;
189 typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator; 176 typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator;
190 typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<iterator>) reverse_iterator; 177 typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator<iterator>) reverse_iterator;
191 typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<const_iterator>) const_reverse_iterator; 178 typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator<const_iterator>) const_reverse_iterator;
192 179
193 ////////////////////////////////////////////// 180 //////////////////////////////////////////////
194 // 181 //
195 // construct/copy/destroy 182 // construct/copy/destroy
196 // 183 //
208 //! <b>Effects</b>: Constructs a list taking the allocator as parameter. 195 //! <b>Effects</b>: Constructs a list taking the allocator as parameter.
209 //! 196 //!
210 //! <b>Throws</b>: Nothing 197 //! <b>Throws</b>: Nothing
211 //! 198 //!
212 //! <b>Complexity</b>: Constant. 199 //! <b>Complexity</b>: Constant.
213 explicit list(const allocator_type &a) BOOST_CONTAINER_NOEXCEPT 200 explicit list(const allocator_type &a) BOOST_NOEXCEPT_OR_NOTHROW
214 : AllocHolder(a) 201 : AllocHolder(a)
215 {} 202 {}
216 203
217 //! <b>Effects</b>: Constructs a list that will use a copy of allocator a 204 //! <b>Effects</b>: Constructs a list
218 //! and inserts n copies of value. 205 //! and inserts n value-initialized value_types.
219 //! 206 //!
220 //! <b>Throws</b>: If allocator_type's default constructor or copy constructor 207 //! <b>Throws</b>: If allocator_type's default constructor
221 //! throws or T's default or copy constructor throws. 208 //! throws or T's default or copy constructor throws.
222 //! 209 //!
223 //! <b>Complexity</b>: Linear to n. 210 //! <b>Complexity</b>: Linear to n.
224 explicit list(size_type n) 211 explicit list(size_type n)
225 : AllocHolder(Allocator()) 212 : AllocHolder(Allocator())
226 { this->resize(n); } 213 { this->resize(n); }
227 214
228 //! <b>Effects</b>: Constructs a list that will use a copy of allocator a 215 //! <b>Effects</b>: Constructs a list that will use a copy of allocator a
229 //! and inserts n copies of value. 216 //! and inserts n copies of value.
230 //! 217 //!
231 //! <b>Throws</b>: If allocator_type's default constructor or copy constructor 218 //! <b>Throws</b>: If allocator_type's default constructor
219 //! throws or T's default or copy constructor throws.
220 //!
221 //! <b>Complexity</b>: Linear to n.
222 list(size_type n, const allocator_type &a)
223 : AllocHolder(a)
224 { this->resize(n); }
225
226 //! <b>Effects</b>: Constructs a list that will use a copy of allocator a
227 //! and inserts n copies of value.
228 //!
229 //! <b>Throws</b>: If allocator_type's default constructor
232 //! throws or T's default or copy constructor throws. 230 //! throws or T's default or copy constructor throws.
233 //! 231 //!
234 //! <b>Complexity</b>: Linear to n. 232 //! <b>Complexity</b>: Linear to n.
235 list(size_type n, const T& value, const Allocator& a = Allocator()) 233 list(size_type n, const T& value, const Allocator& a = Allocator())
236 : AllocHolder(a) 234 : AllocHolder(a)
238 236
239 //! <b>Effects</b>: Copy constructs a list. 237 //! <b>Effects</b>: Copy constructs a list.
240 //! 238 //!
241 //! <b>Postcondition</b>: x == *this. 239 //! <b>Postcondition</b>: x == *this.
242 //! 240 //!
243 //! <b>Throws</b>: If allocator_type's default constructor or copy constructor throws. 241 //! <b>Throws</b>: If allocator_type's default constructor throws.
244 //! 242 //!
245 //! <b>Complexity</b>: Linear to the elements x contains. 243 //! <b>Complexity</b>: Linear to the elements x contains.
246 list(const list& x) 244 list(const list& x)
247 : AllocHolder(x) 245 : AllocHolder(x)
248 { this->insert(this->cbegin(), x.begin(), x.end()); } 246 { this->insert(this->cbegin(), x.begin(), x.end()); }
249 247
250 //! <b>Effects</b>: Move constructor. Moves mx's resources to *this. 248 //! <b>Effects</b>: Move constructor. Moves x's resources to *this.
251 //! 249 //!
252 //! <b>Throws</b>: If allocator_type's copy constructor throws. 250 //! <b>Throws</b>: If allocator_type's copy constructor throws.
253 //! 251 //!
254 //! <b>Complexity</b>: Constant. 252 //! <b>Complexity</b>: Constant.
255 list(BOOST_RV_REF(list) x) 253 list(BOOST_RV_REF(list) x)
256 : AllocHolder(boost::move(static_cast<AllocHolder&>(x))) 254 : AllocHolder(BOOST_MOVE_BASE(AllocHolder, x))
257 {} 255 {}
258 256
259 //! <b>Effects</b>: Copy constructs a list using the specified allocator. 257 //! <b>Effects</b>: Copy constructs a list using the specified allocator.
260 //! 258 //!
261 //! <b>Postcondition</b>: x == *this. 259 //! <b>Postcondition</b>: x == *this.
266 list(const list& x, const allocator_type &a) 264 list(const list& x, const allocator_type &a)
267 : AllocHolder(a) 265 : AllocHolder(a)
268 { this->insert(this->cbegin(), x.begin(), x.end()); } 266 { this->insert(this->cbegin(), x.begin(), x.end()); }
269 267
270 //! <b>Effects</b>: Move constructor sing the specified allocator. 268 //! <b>Effects</b>: Move constructor sing the specified allocator.
271 //! Moves mx's resources to *this. 269 //! Moves x's resources to *this.
272 //! 270 //!
273 //! <b>Throws</b>: If allocation or value_type's copy constructor throws. 271 //! <b>Throws</b>: If allocation or value_type's copy constructor throws.
274 //! 272 //!
275 //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise. 273 //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise.
276 list(BOOST_RV_REF(list) x, const allocator_type &a) 274 list(BOOST_RV_REF(list) x, const allocator_type &a)
278 { 276 {
279 if(this->node_alloc() == x.node_alloc()){ 277 if(this->node_alloc() == x.node_alloc()){
280 this->icont().swap(x.icont()); 278 this->icont().swap(x.icont());
281 } 279 }
282 else{ 280 else{
283 this->insert(this->cbegin(), x.begin(), x.end()); 281 this->insert(this->cbegin(), boost::make_move_iterator(x.begin()), boost::make_move_iterator(x.end()));
284 } 282 }
285 } 283 }
286 284
287 //! <b>Effects</b>: Constructs a list that will use a copy of allocator a 285 //! <b>Effects</b>: Constructs a list that will use a copy of allocator a
288 //! and inserts a copy of the range [first, last) in the list. 286 //! and inserts a copy of the range [first, last) in the list.
289 //! 287 //!
290 //! <b>Throws</b>: If allocator_type's default constructor or copy constructor 288 //! <b>Throws</b>: If allocator_type's default constructor
291 //! throws or T's constructor taking an dereferenced InIt throws. 289 //! throws or T's constructor taking a dereferenced InIt throws.
292 //! 290 //!
293 //! <b>Complexity</b>: Linear to the range [first, last). 291 //! <b>Complexity</b>: Linear to the range [first, last).
294 template <class InpIt> 292 template <class InpIt>
295 list(InpIt first, InpIt last, const Allocator &a = Allocator()) 293 list(InpIt first, InpIt last, const Allocator &a = Allocator())
296 : AllocHolder(a) 294 : AllocHolder(a)
297 { this->insert(this->cbegin(), first, last); } 295 { this->insert(this->cbegin(), first, last); }
298 296
297
298 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
299 //! <b>Effects</b>: Constructs a list that will use a copy of allocator a
300 //! and inserts a copy of the range [il.begin(), il.end()) in the list.
301 //!
302 //! <b>Throws</b>: If allocator_type's default constructor
303 //! throws or T's constructor taking a dereferenced
304 //! std::initializer_list iterator throws.
305 //!
306 //! <b>Complexity</b>: Linear to the range [il.begin(), il.end()).
307 list(std::initializer_list<value_type> il, const Allocator &a = Allocator())
308 : AllocHolder(a)
309 { this->insert(this->cbegin(), il.begin(), il.end()); }
310 #endif
311
299 //! <b>Effects</b>: Destroys the list. All stored values are destroyed 312 //! <b>Effects</b>: Destroys the list. All stored values are destroyed
300 //! and used memory is deallocated. 313 //! and used memory is deallocated.
301 //! 314 //!
302 //! <b>Throws</b>: Nothing. 315 //! <b>Throws</b>: Nothing.
303 //! 316 //!
304 //! <b>Complexity</b>: Linear to the number of elements. 317 //! <b>Complexity</b>: Linear to the number of elements.
305 ~list() BOOST_CONTAINER_NOEXCEPT 318 ~list() BOOST_NOEXCEPT_OR_NOTHROW
306 {} //AllocHolder clears the list 319 {} //AllocHolder clears the list
307 320
308 //! <b>Effects</b>: Makes *this contain the same elements as x. 321 //! <b>Effects</b>: Makes *this contain the same elements as x.
309 //! 322 //!
310 //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy 323 //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
327 this->assign(x.begin(), x.end()); 340 this->assign(x.begin(), x.end());
328 } 341 }
329 return *this; 342 return *this;
330 } 343 }
331 344
332 //! <b>Effects</b>: Move assignment. All mx's values are transferred to *this. 345 //! <b>Effects</b>: Move assignment. All x's values are transferred to *this.
333 //! 346 //!
334 //! <b>Postcondition</b>: x.empty(). *this contains a the elements x had 347 //! <b>Postcondition</b>: x.empty(). *this contains a the elements x had
335 //! before the function. 348 //! before the function.
336 //! 349 //!
337 //! <b>Throws</b>: If allocator_type's copy constructor throws. 350 //! <b>Throws</b>: If allocator_traits_type::propagate_on_container_move_assignment
338 //! 351 //! is false and (allocation throws or value_type's move constructor throws)
339 //! <b>Complexity</b>: Constant. 352 //!
353 //! <b>Complexity</b>: Constant if allocator_traits_type::
354 //! propagate_on_container_move_assignment is true or
355 //! this->get>allocator() == x.get_allocator(). Linear otherwise.
340 list& operator=(BOOST_RV_REF(list) x) 356 list& operator=(BOOST_RV_REF(list) x)
341 { 357 BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value
342 if (&x != this){ 358 || allocator_traits_type::is_always_equal::value)
343 NodeAlloc &this_alloc = this->node_alloc(); 359 {
344 NodeAlloc &x_alloc = x.node_alloc(); 360 BOOST_ASSERT(this != &x);
345 //If allocators are equal we can just swap pointers 361 NodeAlloc &this_alloc = this->node_alloc();
346 if(this_alloc == x_alloc){ 362 NodeAlloc &x_alloc = x.node_alloc();
347 //Destroy and swap pointers 363 const bool propagate_alloc = allocator_traits_type::
348 this->clear(); 364 propagate_on_container_move_assignment::value;
349 this->icont() = boost::move(x.icont()); 365 const bool allocators_equal = this_alloc == x_alloc; (void)allocators_equal;
350 //Move allocator if needed 366 //Resources can be transferred if both allocators are
351 this->AllocHolder::move_assign_alloc(x); 367 //going to be equal after this function (either propagated or already equal)
352 } 368 if(propagate_alloc || allocators_equal){
353 //If unequal allocators, then do a one by one move 369 //Destroy
354 else{ 370 this->clear();
355 this->assign( boost::make_move_iterator(x.begin()) 371 //Move allocator if needed
356 , boost::make_move_iterator(x.end())); 372 this->AllocHolder::move_assign_alloc(x);
357 } 373 //Obtain resources
374 this->icont() = boost::move(x.icont());
375 }
376 //Else do a one by one move
377 else{
378 this->assign( boost::make_move_iterator(x.begin())
379 , boost::make_move_iterator(x.end()));
358 } 380 }
359 return *this; 381 return *this;
360 } 382 }
383
384 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
385 //! <b>Effects</b>: Makes *this contain the same elements as il.
386 //!
387 //! <b>Postcondition</b>: this->size() == il.size(). *this contains a copy
388 //! of each of x's elements.
389 //!
390 //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
391 //!
392 //! <b>Complexity</b>: Linear to the number of elements in x.
393 list& operator=(std::initializer_list<value_type> il)
394 {
395 assign(il.begin(), il.end());
396 return *this;
397 }
398 #endif
361 399
362 //! <b>Effects</b>: Assigns the n copies of val to *this. 400 //! <b>Effects</b>: Assigns the n copies of val to *this.
363 //! 401 //!
364 //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws. 402 //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
365 //! 403 //!
394 else{ 432 else{
395 this->insert(last1, first, last); 433 this->insert(last1, first, last);
396 } 434 }
397 } 435 }
398 436
437 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
438 //! <b>Effects</b>: Assigns the the range [il.begin(), il.end()) to *this.
439 //!
440 //! <b>Throws</b>: If memory allocation throws or
441 //! T's constructor from dereferencing std::initializer_list iterator throws.
442 //!
443 //! <b>Complexity</b>: Linear to n.
444 void assign(std::initializer_list<value_type> il)
445 { assign(il.begin(), il.end()); }
446 #endif
447
399 //! <b>Effects</b>: Returns a copy of the internal allocator. 448 //! <b>Effects</b>: Returns a copy of the internal allocator.
400 //! 449 //!
401 //! <b>Throws</b>: If allocator's copy constructor throws. 450 //! <b>Throws</b>: If allocator's copy constructor throws.
402 //! 451 //!
403 //! <b>Complexity</b>: Constant. 452 //! <b>Complexity</b>: Constant.
404 allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT 453 allocator_type get_allocator() const BOOST_NOEXCEPT_OR_NOTHROW
405 { return allocator_type(this->node_alloc()); } 454 { return allocator_type(this->node_alloc()); }
406 455
407 //! <b>Effects</b>: Returns a reference to the internal allocator. 456 //! <b>Effects</b>: Returns a reference to the internal allocator.
408 //! 457 //!
409 //! <b>Throws</b>: Nothing 458 //! <b>Throws</b>: Nothing
410 //! 459 //!
411 //! <b>Complexity</b>: Constant. 460 //! <b>Complexity</b>: Constant.
412 //! 461 //!
413 //! <b>Note</b>: Non-standard extension. 462 //! <b>Note</b>: Non-standard extension.
414 stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT 463 stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW
415 { return this->node_alloc(); } 464 { return this->node_alloc(); }
416 465
417 //! <b>Effects</b>: Returns a reference to the internal allocator. 466 //! <b>Effects</b>: Returns a reference to the internal allocator.
418 //! 467 //!
419 //! <b>Throws</b>: Nothing 468 //! <b>Throws</b>: Nothing
420 //! 469 //!
421 //! <b>Complexity</b>: Constant. 470 //! <b>Complexity</b>: Constant.
422 //! 471 //!
423 //! <b>Note</b>: Non-standard extension. 472 //! <b>Note</b>: Non-standard extension.
424 const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT 473 const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW
425 { return this->node_alloc(); } 474 { return this->node_alloc(); }
426 475
427 ////////////////////////////////////////////// 476 //////////////////////////////////////////////
428 // 477 //
429 // iterators 478 // iterators
433 //! <b>Effects</b>: Returns an iterator to the first element contained in the list. 482 //! <b>Effects</b>: Returns an iterator to the first element contained in the list.
434 //! 483 //!
435 //! <b>Throws</b>: Nothing. 484 //! <b>Throws</b>: Nothing.
436 //! 485 //!
437 //! <b>Complexity</b>: Constant. 486 //! <b>Complexity</b>: Constant.
438 iterator begin() BOOST_CONTAINER_NOEXCEPT 487 iterator begin() BOOST_NOEXCEPT_OR_NOTHROW
439 { return iterator(this->icont().begin()); } 488 { return iterator(this->icont().begin()); }
440 489
441 //! <b>Effects</b>: Returns a const_iterator to the first element contained in the list. 490 //! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
442 //! 491 //!
443 //! <b>Throws</b>: Nothing. 492 //! <b>Throws</b>: Nothing.
444 //! 493 //!
445 //! <b>Complexity</b>: Constant. 494 //! <b>Complexity</b>: Constant.
446 const_iterator begin() const BOOST_CONTAINER_NOEXCEPT 495 const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW
447 { return this->cbegin(); } 496 { return this->cbegin(); }
448 497
449 //! <b>Effects</b>: Returns an iterator to the end of the list. 498 //! <b>Effects</b>: Returns an iterator to the end of the list.
450 //! 499 //!
451 //! <b>Throws</b>: Nothing. 500 //! <b>Throws</b>: Nothing.
452 //! 501 //!
453 //! <b>Complexity</b>: Constant. 502 //! <b>Complexity</b>: Constant.
454 iterator end() BOOST_CONTAINER_NOEXCEPT 503 iterator end() BOOST_NOEXCEPT_OR_NOTHROW
455 { return iterator(this->icont().end()); } 504 { return iterator(this->icont().end()); }
456 505
457 //! <b>Effects</b>: Returns a const_iterator to the end of the list. 506 //! <b>Effects</b>: Returns a const_iterator to the end of the list.
458 //! 507 //!
459 //! <b>Throws</b>: Nothing. 508 //! <b>Throws</b>: Nothing.
460 //! 509 //!
461 //! <b>Complexity</b>: Constant. 510 //! <b>Complexity</b>: Constant.
462 const_iterator end() const BOOST_CONTAINER_NOEXCEPT 511 const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW
463 { return this->cend(); } 512 { return this->cend(); }
464 513
465 //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning 514 //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
466 //! of the reversed list. 515 //! of the reversed list.
467 //! 516 //!
468 //! <b>Throws</b>: Nothing. 517 //! <b>Throws</b>: Nothing.
469 //! 518 //!
470 //! <b>Complexity</b>: Constant. 519 //! <b>Complexity</b>: Constant.
471 reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT 520 reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW
472 { return reverse_iterator(end()); } 521 { return reverse_iterator(end()); }
473 522
474 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning 523 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
475 //! of the reversed list. 524 //! of the reversed list.
476 //! 525 //!
477 //! <b>Throws</b>: Nothing. 526 //! <b>Throws</b>: Nothing.
478 //! 527 //!
479 //! <b>Complexity</b>: Constant. 528 //! <b>Complexity</b>: Constant.
480 const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT 529 const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW
481 { return this->crbegin(); } 530 { return this->crbegin(); }
482 531
483 //! <b>Effects</b>: Returns a reverse_iterator pointing to the end 532 //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
484 //! of the reversed list. 533 //! of the reversed list.
485 //! 534 //!
486 //! <b>Throws</b>: Nothing. 535 //! <b>Throws</b>: Nothing.
487 //! 536 //!
488 //! <b>Complexity</b>: Constant. 537 //! <b>Complexity</b>: Constant.
489 reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT 538 reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW
490 { return reverse_iterator(begin()); } 539 { return reverse_iterator(begin()); }
491 540
492 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end 541 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
493 //! of the reversed list. 542 //! of the reversed list.
494 //! 543 //!
495 //! <b>Throws</b>: Nothing. 544 //! <b>Throws</b>: Nothing.
496 //! 545 //!
497 //! <b>Complexity</b>: Constant. 546 //! <b>Complexity</b>: Constant.
498 const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT 547 const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW
499 { return this->crend(); } 548 { return this->crend(); }
500 549
501 //! <b>Effects</b>: Returns a const_iterator to the first element contained in the list. 550 //! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
502 //! 551 //!
503 //! <b>Throws</b>: Nothing. 552 //! <b>Throws</b>: Nothing.
504 //! 553 //!
505 //! <b>Complexity</b>: Constant. 554 //! <b>Complexity</b>: Constant.
506 const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT 555 const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW
507 { return const_iterator(this->non_const_icont().begin()); } 556 { return const_iterator(this->non_const_icont().begin()); }
508 557
509 //! <b>Effects</b>: Returns a const_iterator to the end of the list. 558 //! <b>Effects</b>: Returns a const_iterator to the end of the list.
510 //! 559 //!
511 //! <b>Throws</b>: Nothing. 560 //! <b>Throws</b>: Nothing.
512 //! 561 //!
513 //! <b>Complexity</b>: Constant. 562 //! <b>Complexity</b>: Constant.
514 const_iterator cend() const BOOST_CONTAINER_NOEXCEPT 563 const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW
515 { return const_iterator(this->non_const_icont().end()); } 564 { return const_iterator(this->non_const_icont().end()); }
516 565
517 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning 566 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
518 //! of the reversed list. 567 //! of the reversed list.
519 //! 568 //!
520 //! <b>Throws</b>: Nothing. 569 //! <b>Throws</b>: Nothing.
521 //! 570 //!
522 //! <b>Complexity</b>: Constant. 571 //! <b>Complexity</b>: Constant.
523 const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT 572 const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW
524 { return const_reverse_iterator(this->cend()); } 573 { return const_reverse_iterator(this->cend()); }
525 574
526 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end 575 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
527 //! of the reversed list. 576 //! of the reversed list.
528 //! 577 //!
529 //! <b>Throws</b>: Nothing. 578 //! <b>Throws</b>: Nothing.
530 //! 579 //!
531 //! <b>Complexity</b>: Constant. 580 //! <b>Complexity</b>: Constant.
532 const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT 581 const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW
533 { return const_reverse_iterator(this->cbegin()); } 582 { return const_reverse_iterator(this->cbegin()); }
534 583
535 ////////////////////////////////////////////// 584 //////////////////////////////////////////////
536 // 585 //
537 // capacity 586 // capacity
541 //! <b>Effects</b>: Returns true if the list contains no elements. 590 //! <b>Effects</b>: Returns true if the list contains no elements.
542 //! 591 //!
543 //! <b>Throws</b>: Nothing. 592 //! <b>Throws</b>: Nothing.
544 //! 593 //!
545 //! <b>Complexity</b>: Constant. 594 //! <b>Complexity</b>: Constant.
546 bool empty() const BOOST_CONTAINER_NOEXCEPT 595 bool empty() const BOOST_NOEXCEPT_OR_NOTHROW
547 { return !this->size(); } 596 { return !this->size(); }
548 597
549 //! <b>Effects</b>: Returns the number of the elements contained in the list. 598 //! <b>Effects</b>: Returns the number of the elements contained in the list.
550 //! 599 //!
551 //! <b>Throws</b>: Nothing. 600 //! <b>Throws</b>: Nothing.
552 //! 601 //!
553 //! <b>Complexity</b>: Constant. 602 //! <b>Complexity</b>: Constant.
554 size_type size() const BOOST_CONTAINER_NOEXCEPT 603 size_type size() const BOOST_NOEXCEPT_OR_NOTHROW
555 { return this->icont().size(); } 604 { return this->icont().size(); }
556 605
557 //! <b>Effects</b>: Returns the largest possible size of the list. 606 //! <b>Effects</b>: Returns the largest possible size of the list.
558 //! 607 //!
559 //! <b>Throws</b>: Nothing. 608 //! <b>Throws</b>: Nothing.
560 //! 609 //!
561 //! <b>Complexity</b>: Constant. 610 //! <b>Complexity</b>: Constant.
562 size_type max_size() const BOOST_CONTAINER_NOEXCEPT 611 size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW
563 { return AllocHolder::max_size(); } 612 { return AllocHolder::max_size(); }
564 613
565 //! <b>Effects</b>: Inserts or erases elements at the end such that 614 //! <b>Effects</b>: Inserts or erases elements at the end such that
566 //! the size becomes n. New elements are value initialized. 615 //! the size becomes n. New elements are value initialized.
567 //! 616 //!
601 //! from the beginning of the container. 650 //! from the beginning of the container.
602 //! 651 //!
603 //! <b>Throws</b>: Nothing. 652 //! <b>Throws</b>: Nothing.
604 //! 653 //!
605 //! <b>Complexity</b>: Constant. 654 //! <b>Complexity</b>: Constant.
606 reference front() BOOST_CONTAINER_NOEXCEPT 655 reference front() BOOST_NOEXCEPT_OR_NOTHROW
607 { return *this->begin(); } 656 { return *this->begin(); }
608 657
609 //! <b>Requires</b>: !empty() 658 //! <b>Requires</b>: !empty()
610 //! 659 //!
611 //! <b>Effects</b>: Returns a const reference to the first element 660 //! <b>Effects</b>: Returns a const reference to the first element
612 //! from the beginning of the container. 661 //! from the beginning of the container.
613 //! 662 //!
614 //! <b>Throws</b>: Nothing. 663 //! <b>Throws</b>: Nothing.
615 //! 664 //!
616 //! <b>Complexity</b>: Constant. 665 //! <b>Complexity</b>: Constant.
617 const_reference front() const BOOST_CONTAINER_NOEXCEPT 666 const_reference front() const BOOST_NOEXCEPT_OR_NOTHROW
618 { return *this->begin(); } 667 { return *this->begin(); }
619 668
620 //! <b>Requires</b>: !empty() 669 //! <b>Requires</b>: !empty()
621 //! 670 //!
622 //! <b>Effects</b>: Returns a reference to the first element 671 //! <b>Effects</b>: Returns a reference to the first element
623 //! from the beginning of the container. 672 //! from the beginning of the container.
624 //! 673 //!
625 //! <b>Throws</b>: Nothing. 674 //! <b>Throws</b>: Nothing.
626 //! 675 //!
627 //! <b>Complexity</b>: Constant. 676 //! <b>Complexity</b>: Constant.
628 reference back() BOOST_CONTAINER_NOEXCEPT 677 reference back() BOOST_NOEXCEPT_OR_NOTHROW
629 { return *(--this->end()); } 678 { return *(--this->end()); }
630 679
631 //! <b>Requires</b>: !empty() 680 //! <b>Requires</b>: !empty()
632 //! 681 //!
633 //! <b>Effects</b>: Returns a const reference to the first element 682 //! <b>Effects</b>: Returns a const reference to the first element
634 //! from the beginning of the container. 683 //! from the beginning of the container.
635 //! 684 //!
636 //! <b>Throws</b>: Nothing. 685 //! <b>Throws</b>: Nothing.
637 //! 686 //!
638 //! <b>Complexity</b>: Constant. 687 //! <b>Complexity</b>: Constant.
639 const_reference back() const BOOST_CONTAINER_NOEXCEPT 688 const_reference back() const BOOST_NOEXCEPT_OR_NOTHROW
640 { return *(--this->end()); } 689 { return *(--this->end()); }
641 690
642 ////////////////////////////////////////////// 691 //////////////////////////////////////////////
643 // 692 //
644 // modifiers 693 // modifiers
645 // 694 //
646 ////////////////////////////////////////////// 695 //////////////////////////////////////////////
647 696
648 #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) 697 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
649 698
650 //! <b>Effects</b>: Inserts an object of type T constructed with 699 //! <b>Effects</b>: Inserts an object of type T constructed with
651 //! std::forward<Args>(args)... in the end of the list. 700 //! std::forward<Args>(args)... in the end of the list.
652 //! 701 //!
653 //! <b>Throws</b>: If memory allocation throws or 702 //! <b>Throws</b>: If memory allocation throws or
654 //! T's in-place constructor throws. 703 //! T's in-place constructor throws.
655 //! 704 //!
656 //! <b>Complexity</b>: Constant 705 //! <b>Complexity</b>: Constant
657 template <class... Args> 706 template <class... Args>
658 void emplace_back(Args&&... args) 707 void emplace_back(BOOST_FWD_REF(Args)... args)
659 { this->emplace(this->cend(), boost::forward<Args>(args)...); } 708 { this->emplace(this->cend(), boost::forward<Args>(args)...); }
660 709
661 //! <b>Effects</b>: Inserts an object of type T constructed with 710 //! <b>Effects</b>: Inserts an object of type T constructed with
662 //! std::forward<Args>(args)... in the beginning of the list. 711 //! std::forward<Args>(args)... in the beginning of the list.
663 //! 712 //!
664 //! <b>Throws</b>: If memory allocation throws or 713 //! <b>Throws</b>: If memory allocation throws or
665 //! T's in-place constructor throws. 714 //! T's in-place constructor throws.
666 //! 715 //!
667 //! <b>Complexity</b>: Constant 716 //! <b>Complexity</b>: Constant
668 template <class... Args> 717 template <class... Args>
669 void emplace_front(Args&&... args) 718 void emplace_front(BOOST_FWD_REF(Args)... args)
670 { this->emplace(this->cbegin(), boost::forward<Args>(args)...); } 719 { this->emplace(this->cbegin(), boost::forward<Args>(args)...); }
671 720
672 //! <b>Effects</b>: Inserts an object of type T constructed with 721 //! <b>Effects</b>: Inserts an object of type T constructed with
673 //! std::forward<Args>(args)... before p. 722 //! std::forward<Args>(args)... before p.
674 //! 723 //!
675 //! <b>Throws</b>: If memory allocation throws or 724 //! <b>Throws</b>: If memory allocation throws or
676 //! T's in-place constructor throws. 725 //! T's in-place constructor throws.
677 //! 726 //!
678 //! <b>Complexity</b>: Constant 727 //! <b>Complexity</b>: Constant
679 template <class... Args> 728 template <class... Args>
680 iterator emplace(const_iterator p, Args&&... args) 729 iterator emplace(const_iterator p, BOOST_FWD_REF(Args)... args)
681 { 730 {
682 NodePtr pnode(AllocHolder::create_node(boost::forward<Args>(args)...)); 731 NodePtr pnode(AllocHolder::create_node(boost::forward<Args>(args)...));
683 return iterator(this->icont().insert(p.get(), *pnode)); 732 return iterator(this->icont().insert(p.get(), *pnode));
684 } 733 }
685 734
686 #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING 735 #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
687 736
688 #define BOOST_PP_LOCAL_MACRO(n) \ 737 #define BOOST_CONTAINER_LIST_EMPLACE_CODE(N) \
689 BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ 738 BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
690 void emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ 739 void emplace_back(BOOST_MOVE_UREF##N)\
691 { \ 740 { this->emplace(this->cend() BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
692 this->emplace(this->cend() \ 741 \
693 BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ 742 BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
694 } \ 743 void emplace_front(BOOST_MOVE_UREF##N)\
695 \ 744 { this->emplace(this->cbegin() BOOST_MOVE_I##N BOOST_MOVE_FWD##N);}\
696 BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ 745 \
697 void emplace_front(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ 746 BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
698 { \ 747 iterator emplace(const_iterator p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
699 this->emplace(this->cbegin() \ 748 {\
700 BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ 749 NodePtr pnode (AllocHolder::create_node(BOOST_MOVE_FWD##N));\
701 } \ 750 return iterator(this->icont().insert(p.get(), *pnode));\
702 \ 751 }\
703 BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ 752 //
704 iterator emplace(const_iterator p \ 753 BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_LIST_EMPLACE_CODE)
705 BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ 754 #undef BOOST_CONTAINER_LIST_EMPLACE_CODE
706 { \ 755
707 NodePtr pnode (AllocHolder::create_node \ 756 #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
708 (BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \
709 return iterator(this->icont().insert(p.get(), *pnode)); \
710 } \
711 //!
712 #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
713 #include BOOST_PP_LOCAL_ITERATE()
714
715 #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
716 757
717 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) 758 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
718 //! <b>Effects</b>: Inserts a copy of x at the beginning of the list. 759 //! <b>Effects</b>: Inserts a copy of x at the beginning of the list.
719 //! 760 //!
720 //! <b>Throws</b>: If memory allocation throws or 761 //! <b>Throws</b>: If memory allocation throws or
722 //! 763 //!
723 //! <b>Complexity</b>: Amortized constant time. 764 //! <b>Complexity</b>: Amortized constant time.
724 void push_front(const T &x); 765 void push_front(const T &x);
725 766
726 //! <b>Effects</b>: Constructs a new element in the beginning of the list 767 //! <b>Effects</b>: Constructs a new element in the beginning of the list
727 //! and moves the resources of mx to this new element. 768 //! and moves the resources of x to this new element.
728 //! 769 //!
729 //! <b>Throws</b>: If memory allocation throws. 770 //! <b>Throws</b>: If memory allocation throws.
730 //! 771 //!
731 //! <b>Complexity</b>: Amortized constant time. 772 //! <b>Complexity</b>: Amortized constant time.
732 void push_front(T &&x); 773 void push_front(T &&x);
742 //! 783 //!
743 //! <b>Complexity</b>: Amortized constant time. 784 //! <b>Complexity</b>: Amortized constant time.
744 void push_back(const T &x); 785 void push_back(const T &x);
745 786
746 //! <b>Effects</b>: Constructs a new element in the end of the list 787 //! <b>Effects</b>: Constructs a new element in the end of the list
747 //! and moves the resources of mx to this new element. 788 //! and moves the resources of x to this new element.
748 //! 789 //!
749 //! <b>Throws</b>: If memory allocation throws. 790 //! <b>Throws</b>: If memory allocation throws.
750 //! 791 //!
751 //! <b>Complexity</b>: Amortized constant time. 792 //! <b>Complexity</b>: Amortized constant time.
752 void push_back(T &&x); 793 void push_back(T &&x);
753 #else 794 #else
754 BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back) 795 BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
755 #endif 796 #endif
756 797
757 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) 798 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
758 //! <b>Requires</b>: position must be a valid iterator of *this. 799 //! <b>Requires</b>: p must be a valid iterator of *this.
759 //! 800 //!
760 //! <b>Effects</b>: Insert a copy of x before position. 801 //! <b>Effects</b>: Insert a copy of x before p.
761 //! 802 //!
762 //! <b>Returns</b>: an iterator to the inserted element. 803 //! <b>Returns</b>: an iterator to the inserted element.
763 //! 804 //!
764 //! <b>Throws</b>: If memory allocation throws or x's copy constructor throws. 805 //! <b>Throws</b>: If memory allocation throws or x's copy constructor throws.
765 //! 806 //!
766 //! <b>Complexity</b>: Amortized constant time. 807 //! <b>Complexity</b>: Amortized constant time.
767 iterator insert(const_iterator position, const T &x); 808 iterator insert(const_iterator p, const T &x);
768 809
769 //! <b>Requires</b>: position must be a valid iterator of *this. 810 //! <b>Requires</b>: p must be a valid iterator of *this.
770 //! 811 //!
771 //! <b>Effects</b>: Insert a new element before position with mx's resources. 812 //! <b>Effects</b>: Insert a new element before p with x's resources.
772 //! 813 //!
773 //! <b>Returns</b>: an iterator to the inserted element. 814 //! <b>Returns</b>: an iterator to the inserted element.
774 //! 815 //!
775 //! <b>Throws</b>: If memory allocation throws. 816 //! <b>Throws</b>: If memory allocation throws.
776 //! 817 //!
777 //! <b>Complexity</b>: Amortized constant time. 818 //! <b>Complexity</b>: Amortized constant time.
778 iterator insert(const_iterator position, T &&x); 819 iterator insert(const_iterator p, T &&x);
779 #else 820 #else
780 BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator, const_iterator) 821 BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator, const_iterator)
781 #endif 822 #endif
782 823
783 //! <b>Requires</b>: p must be a valid iterator of *this. 824 //! <b>Requires</b>: p must be a valid iterator of *this.
802 //! <b>Returns</b>: an iterator to the first inserted element or p if first == last. 843 //! <b>Returns</b>: an iterator to the first inserted element or p if first == last.
803 //! 844 //!
804 //! <b>Throws</b>: If memory allocation throws, T's constructor from a 845 //! <b>Throws</b>: If memory allocation throws, T's constructor from a
805 //! dereferenced InpIt throws. 846 //! dereferenced InpIt throws.
806 //! 847 //!
807 //! <b>Complexity</b>: Linear to std::distance [first, last). 848 //! <b>Complexity</b>: Linear to distance [first, last).
808 template <class InpIt> 849 template <class InpIt>
809 iterator insert(const_iterator p, InpIt first, InpIt last 850 iterator insert(const_iterator p, InpIt first, InpIt last
810 #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) 851 #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
811 , typename container_detail::enable_if_c 852 , typename container_detail::enable_if_c
812 < !container_detail::is_convertible<InpIt, size_type>::value 853 < !container_detail::is_convertible<InpIt, size_type>::value
813 && (container_detail::is_input_iterator<InpIt>::value 854 && (container_detail::is_input_iterator<InpIt>::value
814 || container_detail::is_same<alloc_version, allocator_v1>::value 855 || container_detail::is_same<alloc_version, version_1>::value
815 ) 856 )
816 >::type * = 0 857 >::type * = 0
817 #endif 858 #endif
818 ) 859 )
819 { 860 {
833 template <class FwdIt> 874 template <class FwdIt>
834 iterator insert(const_iterator p, FwdIt first, FwdIt last 875 iterator insert(const_iterator p, FwdIt first, FwdIt last
835 , typename container_detail::enable_if_c 876 , typename container_detail::enable_if_c
836 < !container_detail::is_convertible<FwdIt, size_type>::value 877 < !container_detail::is_convertible<FwdIt, size_type>::value
837 && !(container_detail::is_input_iterator<FwdIt>::value 878 && !(container_detail::is_input_iterator<FwdIt>::value
838 || container_detail::is_same<alloc_version, allocator_v1>::value 879 || container_detail::is_same<alloc_version, version_1>::value
839 ) 880 )
840 >::type * = 0 881 >::type * = 0
841 ) 882 )
842 { 883 {
843 //Optimized allocation and construction 884 //Optimized allocation and construction
844 insertion_functor func(this->icont(), p.get()); 885 insertion_functor func(this->icont(), p.get());
845 iterator before_p(p.get()); 886 iterator before_p(p.get());
846 --before_p; 887 --before_p;
847 this->allocate_many_and_construct(first, std::distance(first, last), func); 888 this->allocate_many_and_construct(first, boost::container::iterator_distance(first, last), func);
848 return ++before_p; 889 return ++before_p;
849 } 890 }
850 #endif 891 #endif
851 892
893 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
894 //! <b>Requires</b>: p must be a valid iterator of *this.
895 //!
896 //! <b>Effects</b>: Insert a copy of the [il.begin(), il.end()) range before p.
897 //!
898 //! <b>Returns</b>: an iterator to the first inserted element or p if if.begin() == il.end().
899 //!
900 //! <b>Throws</b>: If memory allocation throws, T's constructor from a
901 //! dereferenced std::initializer_list iterator throws.
902 //!
903 //! <b>Complexity</b>: Linear to distance [il.begin(), il.end()).
904 iterator insert(const_iterator p, std::initializer_list<value_type> il)
905 { return insert(p, il.begin(), il.end()); }
906 #endif
907
852 //! <b>Effects</b>: Removes the first element from the list. 908 //! <b>Effects</b>: Removes the first element from the list.
853 //! 909 //!
854 //! <b>Throws</b>: Nothing. 910 //! <b>Throws</b>: Nothing.
855 //! 911 //!
856 //! <b>Complexity</b>: Amortized constant time. 912 //! <b>Complexity</b>: Amortized constant time.
857 void pop_front() BOOST_CONTAINER_NOEXCEPT 913 void pop_front() BOOST_NOEXCEPT_OR_NOTHROW
858 { this->erase(this->cbegin()); } 914 { this->erase(this->cbegin()); }
859 915
860 //! <b>Effects</b>: Removes the last element from the list. 916 //! <b>Effects</b>: Removes the last element from the list.
861 //! 917 //!
862 //! <b>Throws</b>: Nothing. 918 //! <b>Throws</b>: Nothing.
863 //! 919 //!
864 //! <b>Complexity</b>: Amortized constant time. 920 //! <b>Complexity</b>: Amortized constant time.
865 void pop_back() BOOST_CONTAINER_NOEXCEPT 921 void pop_back() BOOST_NOEXCEPT_OR_NOTHROW
866 { const_iterator tmp = this->cend(); this->erase(--tmp); } 922 { const_iterator tmp = this->cend(); this->erase(--tmp); }
867 923
868 //! <b>Requires</b>: p must be a valid iterator of *this. 924 //! <b>Requires</b>: p must be a valid iterator of *this.
869 //! 925 //!
870 //! <b>Effects</b>: Erases the element at p p. 926 //! <b>Effects</b>: Erases the element at p p.
871 //! 927 //!
872 //! <b>Throws</b>: Nothing. 928 //! <b>Throws</b>: Nothing.
873 //! 929 //!
874 //! <b>Complexity</b>: Amortized constant time. 930 //! <b>Complexity</b>: Amortized constant time.
875 iterator erase(const_iterator p) BOOST_CONTAINER_NOEXCEPT 931 iterator erase(const_iterator p) BOOST_NOEXCEPT_OR_NOTHROW
876 { return iterator(this->icont().erase_and_dispose(p.get(), Destroyer(this->node_alloc()))); } 932 { return iterator(this->icont().erase_and_dispose(p.get(), Destroyer(this->node_alloc()))); }
877 933
878 //! <b>Requires</b>: first and last must be valid iterator to elements in *this. 934 //! <b>Requires</b>: first and last must be valid iterator to elements in *this.
879 //! 935 //!
880 //! <b>Effects</b>: Erases the elements pointed by [first, last). 936 //! <b>Effects</b>: Erases the elements pointed by [first, last).
881 //! 937 //!
882 //! <b>Throws</b>: Nothing. 938 //! <b>Throws</b>: Nothing.
883 //! 939 //!
884 //! <b>Complexity</b>: Linear to the distance between first and last. 940 //! <b>Complexity</b>: Linear to the distance between first and last.
885 iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT 941 iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
886 { return iterator(AllocHolder::erase_range(first.get(), last.get(), alloc_version())); } 942 { return iterator(AllocHolder::erase_range(first.get(), last.get(), alloc_version())); }
887 943
888 //! <b>Effects</b>: Swaps the contents of *this and x. 944 //! <b>Effects</b>: Swaps the contents of *this and x.
889 //! 945 //!
890 //! <b>Throws</b>: Nothing. 946 //! <b>Throws</b>: Nothing.
891 //! 947 //!
892 //! <b>Complexity</b>: Constant. 948 //! <b>Complexity</b>: Constant.
893 void swap(list& x) 949 void swap(list& x)
950 BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_swap::value
951 || allocator_traits_type::is_always_equal::value)
894 { AllocHolder::swap(x); } 952 { AllocHolder::swap(x); }
895 953
896 //! <b>Effects</b>: Erases all the elements of the list. 954 //! <b>Effects</b>: Erases all the elements of the list.
897 //! 955 //!
898 //! <b>Throws</b>: Nothing. 956 //! <b>Throws</b>: Nothing.
899 //! 957 //!
900 //! <b>Complexity</b>: Linear to the number of elements in the list. 958 //! <b>Complexity</b>: Linear to the number of elements in the list.
901 void clear() BOOST_CONTAINER_NOEXCEPT 959 void clear() BOOST_NOEXCEPT_OR_NOTHROW
902 { AllocHolder::clear(alloc_version()); } 960 { AllocHolder::clear(alloc_version()); }
903 961
904 ////////////////////////////////////////////// 962 //////////////////////////////////////////////
905 // 963 //
906 // slist operations 964 // slist operations
917 //! 975 //!
918 //! <b>Complexity</b>: Constant. 976 //! <b>Complexity</b>: Constant.
919 //! 977 //!
920 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of 978 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of
921 //! this list. Iterators of this list and all the references are not invalidated. 979 //! this list. Iterators of this list and all the references are not invalidated.
922 void splice(const_iterator p, list& x) BOOST_CONTAINER_NOEXCEPT 980 void splice(const_iterator p, list& x) BOOST_NOEXCEPT_OR_NOTHROW
923 { 981 {
924 BOOST_ASSERT(this != &x); 982 BOOST_ASSERT(this != &x);
925 BOOST_ASSERT(this->node_alloc() == x.node_alloc()); 983 BOOST_ASSERT(this->node_alloc() == x.node_alloc());
926 this->icont().splice(p.get(), x.icont()); 984 this->icont().splice(p.get(), x.icont());
927 } 985 }
936 //! 994 //!
937 //! <b>Complexity</b>: Constant. 995 //! <b>Complexity</b>: Constant.
938 //! 996 //!
939 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of 997 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of
940 //! this list. Iterators of this list and all the references are not invalidated. 998 //! this list. Iterators of this list and all the references are not invalidated.
941 void splice(const_iterator p, BOOST_RV_REF(list) x) BOOST_CONTAINER_NOEXCEPT 999 void splice(const_iterator p, BOOST_RV_REF(list) x) BOOST_NOEXCEPT_OR_NOTHROW
942 { this->splice(p, static_cast<list&>(x)); } 1000 { this->splice(p, static_cast<list&>(x)); }
943 1001
944 //! <b>Requires</b>: p must point to an element contained 1002 //! <b>Requires</b>: p must point to an element contained
945 //! by this list. i must point to an element contained in list x. 1003 //! by this list. i must point to an element contained in list x.
946 //! this' allocator and x's allocator shall compare equal 1004 //! this' allocator and x's allocator shall compare equal
953 //! 1011 //!
954 //! <b>Complexity</b>: Constant. 1012 //! <b>Complexity</b>: Constant.
955 //! 1013 //!
956 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this 1014 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
957 //! list. Iterators of this list and all the references are not invalidated. 1015 //! list. Iterators of this list and all the references are not invalidated.
958 void splice(const_iterator p, list &x, const_iterator i) BOOST_CONTAINER_NOEXCEPT 1016 void splice(const_iterator p, list &x, const_iterator i) BOOST_NOEXCEPT_OR_NOTHROW
959 { 1017 {
960 //BOOST_ASSERT(this != &x); 1018 //BOOST_ASSERT(this != &x);
961 BOOST_ASSERT(this->node_alloc() == x.node_alloc()); 1019 BOOST_ASSERT(this->node_alloc() == x.node_alloc());
962 this->icont().splice(p.get(), x.icont(), i.get()); 1020 this->icont().splice(p.get(), x.icont(), i.get());
963 } 1021 }
974 //! 1032 //!
975 //! <b>Complexity</b>: Constant. 1033 //! <b>Complexity</b>: Constant.
976 //! 1034 //!
977 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this 1035 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
978 //! list. Iterators of this list and all the references are not invalidated. 1036 //! list. Iterators of this list and all the references are not invalidated.
979 void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator i) BOOST_CONTAINER_NOEXCEPT 1037 void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator i) BOOST_NOEXCEPT_OR_NOTHROW
980 { this->splice(p, static_cast<list&>(x), i); } 1038 { this->splice(p, static_cast<list&>(x), i); }
981 1039
982 //! <b>Requires</b>: p must point to an element contained 1040 //! <b>Requires</b>: p must point to an element contained
983 //! by this list. first and last must point to elements contained in list x. 1041 //! by this list. first and last must point to elements contained in list x.
984 //! this' allocator and x's allocator shall compare equal 1042 //! this' allocator and x's allocator shall compare equal
990 //! 1048 //!
991 //! <b>Complexity</b>: Linear to the number of elements transferred. 1049 //! <b>Complexity</b>: Linear to the number of elements transferred.
992 //! 1050 //!
993 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this 1051 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
994 //! list. Iterators of this list and all the references are not invalidated. 1052 //! list. Iterators of this list and all the references are not invalidated.
995 void splice(const_iterator p, list &x, const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT 1053 void splice(const_iterator p, list &x, const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
996 { 1054 {
997 BOOST_ASSERT(this->node_alloc() == x.node_alloc()); 1055 BOOST_ASSERT(this->node_alloc() == x.node_alloc());
998 this->icont().splice(p.get(), x.icont(), first.get(), last.get()); 1056 this->icont().splice(p.get(), x.icont(), first.get(), last.get());
999 } 1057 }
1000 1058
1009 //! 1067 //!
1010 //! <b>Complexity</b>: Linear to the number of elements transferred. 1068 //! <b>Complexity</b>: Linear to the number of elements transferred.
1011 //! 1069 //!
1012 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this 1070 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
1013 //! list. Iterators of this list and all the references are not invalidated. 1071 //! list. Iterators of this list and all the references are not invalidated.
1014 void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT 1072 void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
1015 { this->splice(p, static_cast<list&>(x), first, last); } 1073 { this->splice(p, static_cast<list&>(x), first, last); }
1016 1074
1017 //! <b>Requires</b>: p must point to an element contained 1075 //! <b>Requires</b>: p must point to an element contained
1018 //! by this list. first and last must point to elements contained in list x. 1076 //! by this list. first and last must point to elements contained in list x.
1019 //! n == std::distance(first, last). this' allocator and x's allocator shall compare equal 1077 //! n == distance(first, last). this' allocator and x's allocator shall compare equal
1020 //! 1078 //!
1021 //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list, 1079 //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
1022 //! before the the element pointed by p. No destructors or copy constructors are called. 1080 //! before the the element pointed by p. No destructors or copy constructors are called.
1023 //! 1081 //!
1024 //! <b>Throws</b>: Nothing 1082 //! <b>Throws</b>: Nothing
1027 //! 1085 //!
1028 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this 1086 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
1029 //! list. Iterators of this list and all the references are not invalidated. 1087 //! list. Iterators of this list and all the references are not invalidated.
1030 //! 1088 //!
1031 //! <b>Note</b>: Non-standard extension 1089 //! <b>Note</b>: Non-standard extension
1032 void splice(const_iterator p, list &x, const_iterator first, const_iterator last, size_type n) BOOST_CONTAINER_NOEXCEPT 1090 void splice(const_iterator p, list &x, const_iterator first, const_iterator last, size_type n) BOOST_NOEXCEPT_OR_NOTHROW
1033 { 1091 {
1034 BOOST_ASSERT(this->node_alloc() == x.node_alloc()); 1092 BOOST_ASSERT(this->node_alloc() == x.node_alloc());
1035 this->icont().splice(p.get(), x.icont(), first.get(), last.get(), n); 1093 this->icont().splice(p.get(), x.icont(), first.get(), last.get(), n);
1036 } 1094 }
1037 1095
1038 //! <b>Requires</b>: p must point to an element contained 1096 //! <b>Requires</b>: p must point to an element contained
1039 //! by this list. first and last must point to elements contained in list x. 1097 //! by this list. first and last must point to elements contained in list x.
1040 //! n == std::distance(first, last). this' allocator and x's allocator shall compare equal 1098 //! n == distance(first, last). this' allocator and x's allocator shall compare equal
1041 //! 1099 //!
1042 //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list, 1100 //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
1043 //! before the the element pointed by p. No destructors or copy constructors are called. 1101 //! before the the element pointed by p. No destructors or copy constructors are called.
1044 //! 1102 //!
1045 //! <b>Throws</b>: Nothing 1103 //! <b>Throws</b>: Nothing
1048 //! 1106 //!
1049 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this 1107 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
1050 //! list. Iterators of this list and all the references are not invalidated. 1108 //! list. Iterators of this list and all the references are not invalidated.
1051 //! 1109 //!
1052 //! <b>Note</b>: Non-standard extension 1110 //! <b>Note</b>: Non-standard extension
1053 void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator first, const_iterator last, size_type n) BOOST_CONTAINER_NOEXCEPT 1111 void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator first, const_iterator last, size_type n) BOOST_NOEXCEPT_OR_NOTHROW
1054 { this->splice(p, static_cast<list&>(x), first, last, n); } 1112 { this->splice(p, static_cast<list&>(x), first, last, n); }
1055 1113
1056 //! <b>Effects</b>: Removes all the elements that compare equal to value. 1114 //! <b>Effects</b>: Removes all the elements that compare equal to value.
1057 //! 1115 //!
1058 //! <b>Throws</b>: If comparison throws. 1116 //! <b>Throws</b>: If comparison throws.
1060 //! <b>Complexity</b>: Linear time. It performs exactly size() comparisons for equality. 1118 //! <b>Complexity</b>: Linear time. It performs exactly size() comparisons for equality.
1061 //! 1119 //!
1062 //! <b>Note</b>: The relative order of elements that are not removed is unchanged, 1120 //! <b>Note</b>: The relative order of elements that are not removed is unchanged,
1063 //! and iterators to elements that are not removed remain valid. 1121 //! and iterators to elements that are not removed remain valid.
1064 void remove(const T& value) 1122 void remove(const T& value)
1065 { this->remove_if(equal_to_value(value)); } 1123 { this->remove_if(equal_to_value_type(value)); }
1066 1124
1067 //! <b>Effects</b>: Removes all the elements for which a specified 1125 //! <b>Effects</b>: Removes all the elements for which a specified
1068 //! predicate is satisfied. 1126 //! predicate is satisfied.
1069 //! 1127 //!
1070 //! <b>Throws</b>: If pred throws. 1128 //! <b>Throws</b>: If pred throws.
1074 //! <b>Note</b>: The relative order of elements that are not removed is unchanged, 1132 //! <b>Note</b>: The relative order of elements that are not removed is unchanged,
1075 //! and iterators to elements that are not removed remain valid. 1133 //! and iterators to elements that are not removed remain valid.
1076 template <class Pred> 1134 template <class Pred>
1077 void remove_if(Pred pred) 1135 void remove_if(Pred pred)
1078 { 1136 {
1079 typedef ValueCompareToNodeCompare<Pred> Predicate; 1137 typedef value_to_node_compare<Node, Pred> value_to_node_compare_type;
1080 this->icont().remove_and_dispose_if(Predicate(pred), Destroyer(this->node_alloc())); 1138 this->icont().remove_and_dispose_if(value_to_node_compare_type(pred), Destroyer(this->node_alloc()));
1081 } 1139 }
1082 1140
1083 //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent 1141 //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
1084 //! elements that are equal from the list. 1142 //! elements that are equal from the list.
1085 //! 1143 //!
1102 //! <b>Note</b>: The relative order of elements that are not removed is unchanged, 1160 //! <b>Note</b>: The relative order of elements that are not removed is unchanged,
1103 //! and iterators to elements that are not removed remain valid. 1161 //! and iterators to elements that are not removed remain valid.
1104 template <class BinaryPredicate> 1162 template <class BinaryPredicate>
1105 void unique(BinaryPredicate binary_pred) 1163 void unique(BinaryPredicate binary_pred)
1106 { 1164 {
1107 typedef ValueCompareToNodeCompare<BinaryPredicate> Predicate; 1165 typedef value_to_node_compare<Node, BinaryPredicate> value_to_node_compare_type;
1108 this->icont().unique_and_dispose(Predicate(binary_pred), Destroyer(this->node_alloc())); 1166 this->icont().unique_and_dispose(value_to_node_compare_type(binary_pred), Destroyer(this->node_alloc()));
1109 } 1167 }
1110 1168
1111 //! <b>Requires</b>: The lists x and *this must be distinct. 1169 //! <b>Requires</b>: The lists x and *this must be distinct.
1112 //! 1170 //!
1113 //! <b>Effects</b>: This function removes all of x's elements and inserts them 1171 //! <b>Effects</b>: This function removes all of x's elements and inserts them
1152 //! <b>Note</b>: Iterators and references to *this are not invalidated. 1210 //! <b>Note</b>: Iterators and references to *this are not invalidated.
1153 template <class StrictWeakOrdering> 1211 template <class StrictWeakOrdering>
1154 void merge(list &x, const StrictWeakOrdering &comp) 1212 void merge(list &x, const StrictWeakOrdering &comp)
1155 { 1213 {
1156 BOOST_ASSERT(this->node_alloc() == x.node_alloc()); 1214 BOOST_ASSERT(this->node_alloc() == x.node_alloc());
1157 this->icont().merge(x.icont(), 1215 typedef value_to_node_compare<Node, StrictWeakOrdering> value_to_node_compare_type;
1158 ValueCompareToNodeCompare<StrictWeakOrdering>(comp)); 1216 this->icont().merge(x.icont(), value_to_node_compare_type(comp));
1159 } 1217 }
1160 1218
1161 //! <b>Requires</b>: p must be a comparison function that induces a strict weak 1219 //! <b>Requires</b>: p must be a comparison function that induces a strict weak
1162 //! ordering and both *this and x must be sorted according to that ordering 1220 //! ordering and both *this and x must be sorted according to that ordering
1163 //! The lists x and *this must be distinct. 1221 //! The lists x and *this must be distinct.
1180 //! The sort is stable, that is, the relative order of equivalent elements is preserved. 1238 //! The sort is stable, that is, the relative order of equivalent elements is preserved.
1181 //! 1239 //!
1182 //! <b>Throws</b>: If comparison throws. 1240 //! <b>Throws</b>: If comparison throws.
1183 //! 1241 //!
1184 //! <b>Notes</b>: Iterators and references are not invalidated. 1242 //! <b>Notes</b>: Iterators and references are not invalidated.
1185 //! 1243 //!
1186 //! <b>Complexity</b>: The number of comparisons is approximately N log N, where N 1244 //! <b>Complexity</b>: The number of comparisons is approximately N log N, where N
1187 //! is the list's size. 1245 //! is the list's size.
1188 void sort() 1246 void sort()
1189 { this->sort(value_less()); } 1247 { this->sort(value_less()); }
1190 1248
1201 void sort(StrictWeakOrdering comp) 1259 void sort(StrictWeakOrdering comp)
1202 { 1260 {
1203 // nothing if the list has length 0 or 1. 1261 // nothing if the list has length 0 or 1.
1204 if (this->size() < 2) 1262 if (this->size() < 2)
1205 return; 1263 return;
1206 this->icont().sort(ValueCompareToNodeCompare<StrictWeakOrdering>(comp)); 1264 typedef value_to_node_compare<Node, StrictWeakOrdering> value_to_node_compare_type;
1265 this->icont().sort(value_to_node_compare_type(comp));
1207 } 1266 }
1208 1267
1209 //! <b>Effects</b>: Reverses the order of elements in the list. 1268 //! <b>Effects</b>: Reverses the order of elements in the list.
1210 //! 1269 //!
1211 //! <b>Throws</b>: Nothing. 1270 //! <b>Throws</b>: Nothing.
1212 //! 1271 //!
1213 //! <b>Complexity</b>: This function is linear time. 1272 //! <b>Complexity</b>: This function is linear time.
1214 //! 1273 //!
1215 //! <b>Note</b>: Iterators and references are not invalidated 1274 //! <b>Note</b>: Iterators and references are not invalidated
1216 void reverse() BOOST_CONTAINER_NOEXCEPT 1275 void reverse() BOOST_NOEXCEPT_OR_NOTHROW
1217 { this->icont().reverse(); } 1276 { this->icont().reverse(); }
1218 1277
1219 /// @cond 1278 //! <b>Effects</b>: Returns true if x and y are equal
1279 //!
1280 //! <b>Complexity</b>: Linear to the number of elements in the container.
1281 friend bool operator==(const list& x, const list& y)
1282 { return x.size() == y.size() && ::boost::container::algo_equal(x.begin(), x.end(), y.begin()); }
1283
1284 //! <b>Effects</b>: Returns true if x and y are unequal
1285 //!
1286 //! <b>Complexity</b>: Linear to the number of elements in the container.
1287 friend bool operator!=(const list& x, const list& y)
1288 { return !(x == y); }
1289
1290 //! <b>Effects</b>: Returns true if x is less than y
1291 //!
1292 //! <b>Complexity</b>: Linear to the number of elements in the container.
1293 friend bool operator<(const list& x, const list& y)
1294 { return boost::container::algo_lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
1295
1296 //! <b>Effects</b>: Returns true if x is greater than y
1297 //!
1298 //! <b>Complexity</b>: Linear to the number of elements in the container.
1299 friend bool operator>(const list& x, const list& y)
1300 { return y < x; }
1301
1302 //! <b>Effects</b>: Returns true if x is equal or less than y
1303 //!
1304 //! <b>Complexity</b>: Linear to the number of elements in the container.
1305 friend bool operator<=(const list& x, const list& y)
1306 { return !(y < x); }
1307
1308 //! <b>Effects</b>: Returns true if x is equal or greater than y
1309 //!
1310 //! <b>Complexity</b>: Linear to the number of elements in the container.
1311 friend bool operator>=(const list& x, const list& y)
1312 { return !(x < y); }
1313
1314 //! <b>Effects</b>: x.swap(y)
1315 //!
1316 //! <b>Complexity</b>: Constant.
1317 friend void swap(list& x, list& y)
1318 { x.swap(y); }
1319
1320 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
1220 private: 1321 private:
1221 1322
1222 bool priv_try_shrink(size_type new_size) 1323 bool priv_try_shrink(size_type new_size)
1223 { 1324 {
1224 const size_type len = this->size(); 1325 const size_type len = this->size();
1257 { 1358 {
1258 NodePtr tmp = AllocHolder::create_node(boost::move(x)); 1359 NodePtr tmp = AllocHolder::create_node(boost::move(x));
1259 return iterator(this->icont().insert(p.get(), *tmp)); 1360 return iterator(this->icont().insert(p.get(), *tmp));
1260 } 1361 }
1261 1362
1262 void priv_push_back (const T &x) 1363 void priv_push_back (const T &x)
1263 { this->insert(this->cend(), x); } 1364 { this->insert(this->cend(), x); }
1264 1365
1265 void priv_push_back (BOOST_RV_REF(T) x) 1366 void priv_push_back (BOOST_RV_REF(T) x)
1266 { this->insert(this->cend(), boost::move(x)); } 1367 { this->insert(this->cend(), boost::move(x)); }
1267 1368
1268 void priv_push_front (const T &x) 1369 void priv_push_front (const T &x)
1269 { this->insert(this->cbegin(), x); } 1370 { this->insert(this->cbegin(), x); }
1270 1371
1271 void priv_push_front (BOOST_RV_REF(T) x) 1372 void priv_push_front (BOOST_RV_REF(T) x)
1272 { this->insert(this->cbegin(), boost::move(x)); } 1373 { this->insert(this->cbegin(), boost::move(x)); }
1273 1374
1301 struct value_equal 1402 struct value_equal
1302 { 1403 {
1303 bool operator()(const value_type &a, const value_type &b) const 1404 bool operator()(const value_type &a, const value_type &b) const
1304 { return a == b; } 1405 { return a == b; }
1305 }; 1406 };
1306 /// @endcond 1407 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
1307 1408
1308 }; 1409 };
1309 1410
1310 template <class T, class Allocator> 1411 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
1311 inline bool operator==(const list<T,Allocator>& x, const list<T,Allocator>& y)
1312 {
1313 if(x.size() != y.size()){
1314 return false;
1315 }
1316 typedef typename list<T,Allocator>::const_iterator const_iterator;
1317 const_iterator end1 = x.end();
1318
1319 const_iterator i1 = x.begin();
1320 const_iterator i2 = y.begin();
1321 while (i1 != end1 && *i1 == *i2) {
1322 ++i1;
1323 ++i2;
1324 }
1325 return i1 == end1;
1326 }
1327
1328 template <class T, class Allocator>
1329 inline bool operator<(const list<T,Allocator>& x,
1330 const list<T,Allocator>& y)
1331 {
1332 return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
1333 }
1334
1335 template <class T, class Allocator>
1336 inline bool operator!=(const list<T,Allocator>& x, const list<T,Allocator>& y)
1337 {
1338 return !(x == y);
1339 }
1340
1341 template <class T, class Allocator>
1342 inline bool operator>(const list<T,Allocator>& x, const list<T,Allocator>& y)
1343 {
1344 return y < x;
1345 }
1346
1347 template <class T, class Allocator>
1348 inline bool operator<=(const list<T,Allocator>& x, const list<T,Allocator>& y)
1349 {
1350 return !(y < x);
1351 }
1352
1353 template <class T, class Allocator>
1354 inline bool operator>=(const list<T,Allocator>& x, const list<T,Allocator>& y)
1355 {
1356 return !(x < y);
1357 }
1358
1359 template <class T, class Allocator>
1360 inline void swap(list<T, Allocator>& x, list<T, Allocator>& y)
1361 {
1362 x.swap(y);
1363 }
1364
1365 /// @cond
1366 1412
1367 } //namespace container { 1413 } //namespace container {
1368 1414
1369 //!has_trivial_destructor_after_move<> == true_type 1415 //!has_trivial_destructor_after_move<> == true_type
1370 //!specialization for optimizations 1416 //!specialization for optimizations
1371 template <class T, class Allocator> 1417 template <class T, class Allocator>
1372 struct has_trivial_destructor_after_move<boost::container::list<T, Allocator> > 1418 struct has_trivial_destructor_after_move<boost::container::list<T, Allocator> >
1373 : public ::boost::has_trivial_destructor_after_move<Allocator> 1419 {
1374 {}; 1420 typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
1421 static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
1422 ::boost::has_trivial_destructor_after_move<pointer>::value;
1423 };
1375 1424
1376 namespace container { 1425 namespace container {
1377 1426
1378 /// @endcond 1427 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
1379 1428
1380 }} 1429 }}
1381 1430
1382 #include <boost/container/detail/config_end.hpp> 1431 #include <boost/container/detail/config_end.hpp>
1383 1432