annotate DEPENDENCIES/generic/include/boost/container/list.hpp @ 16:2665513ce2d3

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