summaryrefslogtreecommitdiff
path: root/boost/container/list.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/container/list.hpp')
-rw-r--r--boost/container/list.hpp395
1 files changed, 202 insertions, 193 deletions
diff --git a/boost/container/list.hpp b/boost/container/list.hpp
index 6df999bb51..c3e3562988 100644
--- a/boost/container/list.hpp
+++ b/boost/container/list.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -32,7 +32,7 @@
#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
#else
//Preprocessor library to emulate perfect forwarding
-#include <boost/container/detail/preprocessor.hpp>
+#include <boost/container/detail/preprocessor.hpp>
#endif
#include <stdexcept>
@@ -65,30 +65,11 @@ template <class T, class VoidPointer>
struct list_node
: public list_hook<VoidPointer>::type
{
+ private:
+ list_node();
- list_node()
- : m_data()
- {}
- #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
- template<class ...Args>
- list_node(Args &&...args)
- : m_data(boost::forward<Args>(args)...)
- {}
-
- #else //#ifndef BOOST_CONTAINER_PERFECT_FORWARDING
-
- #define BOOST_PP_LOCAL_MACRO(n) \
- template<BOOST_PP_ENUM_PARAMS(n, class P)> \
- list_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- : m_data(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)) \
- {} \
- //!
- #define BOOST_PP_LOCAL_LIMITS (1, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
- #include BOOST_PP_LOCAL_ITERATE()
-
- #endif//#ifndef BOOST_CONTAINER_PERFECT_FORWARDING
-
+ public:
+ typedef typename list_hook<VoidPointer>::type hook_type;
T m_data;
};
@@ -117,26 +98,26 @@ struct intrusive_list_type
/// @endcond
//! A list is a doubly linked list. That is, it is a Sequence that supports both
-//! forward and backward traversal, and (amortized) constant time insertion and
-//! removal of elements at the beginning or the end, or in the middle. Lists have
-//! the important property that insertion and splicing do not invalidate iterators
-//! to list elements, and that even removal invalidates only the iterators that point
-//! to the elements that are removed. The ordering of iterators may be changed
-//! (that is, list<T>::iterator might have a different predecessor or successor
-//! after a list operation than it did before), but the iterators themselves will
-//! not be invalidated or made to point to different elements unless that invalidation
+//! forward and backward traversal, and (amortized) constant time insertion and
+//! removal of elements at the beginning or the end, or in the middle. Lists have
+//! the important property that insertion and splicing do not invalidate iterators
+//! to list elements, and that even removal invalidates only the iterators that point
+//! to the elements that are removed. The ordering of iterators may be changed
+//! (that is, list<T>::iterator might have a different predecessor or successor
+//! after a list operation than it did before), but the iterators themselves will
+//! not be invalidated or made to point to different elements unless that invalidation
//! or mutation is explicit.
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
template <class T, class A = std::allocator<T> >
#else
template <class T, class A>
#endif
-class list
+class list
: protected container_detail::node_alloc_holder
<A, typename container_detail::intrusive_list_type<A>::type>
{
/// @cond
- typedef typename
+ typedef typename
container_detail::intrusive_list_type<A>::type Icont;
typedef list <T, A> ThisType;
typedef container_detail::node_alloc_holder<A, Icont> AllocHolder;
@@ -211,11 +192,11 @@ class list
/// @endcond
public:
- //! Const iterator used to iterate through a list.
+ //! Const iterator used to iterate through a list.
class const_iterator
/// @cond
- : public std::iterator<std::bidirectional_iterator_tag,
- value_type, list_difference_type,
+ : public std::iterator<std::bidirectional_iterator_tag,
+ value_type, list_difference_type,
list_const_pointer, list_const_reference>
{
@@ -239,17 +220,17 @@ class list
{}
//Pointer like operators
- const_reference operator*() const
+ const_reference operator*() const
{ return m_it->m_data; }
- const_pointer operator->() const
+ const_pointer operator->() const
{ return const_pointer(&m_it->m_data); }
//Increment / Decrement
- const_iterator& operator++()
+ const_iterator& operator++()
{ prot_incr(); return *this; }
- const_iterator operator++(int)
+ const_iterator operator++(int)
{ typename Icont::iterator tmp = m_it; ++*this; return const_iterator(tmp); }
const_iterator& operator--()
@@ -278,7 +259,7 @@ class list
explicit iterator(typename Icont::iterator it)
: const_iterator(it)
{}
-
+
typename Icont::iterator get()
{ return this->m_it; }
@@ -295,12 +276,12 @@ class list
pointer operator->() const { return pointer(&this->m_it->m_data); }
//Increment / Decrement
- iterator& operator++()
+ iterator& operator++()
{ this->prot_incr(); return *this; }
iterator operator++(int)
{ typename Icont::iterator tmp = this->m_it; ++*this; return iterator(tmp); }
-
+
iterator& operator--()
{ this->prot_decr(); return *this; }
@@ -309,24 +290,24 @@ class list
};
/// @endcond
- //! Iterator used to iterate backwards through a list.
+ //! Iterator used to iterate backwards through a list.
typedef std::reverse_iterator<iterator> reverse_iterator;
- //! Const iterator used to iterate backwards through a list.
+ //! Const iterator used to iterate backwards through a list.
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
//! <b>Effects</b>: Default constructs a list.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's default constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- list()
+ list()
: AllocHolder()
{}
//! <b>Effects</b>: Constructs a list taking the allocator as parameter.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
explicit list(const allocator_type &a)
: AllocHolder(a)
@@ -337,7 +318,7 @@ class list
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! throws or T's default or copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Linear to n.
explicit list(size_type n)
: AllocHolder(A())
@@ -348,7 +329,7 @@ class list
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! throws or T's default or copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Linear to n.
list(size_type n, const T& value, const A& a = A())
: AllocHolder(a)
@@ -357,23 +338,51 @@ class list
//! <b>Effects</b>: Copy constructs a list.
//!
//! <b>Postcondition</b>: x == *this.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Linear to the elements x contains.
- list(const list& x)
+ list(const list& x)
: AllocHolder(x)
{ this->insert(this->cbegin(), x.begin(), x.end()); }
//! <b>Effects</b>: Move constructor. Moves mx's resources to *this.
//!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
list(BOOST_RV_REF(list) x)
: AllocHolder(boost::move(static_cast<AllocHolder&>(x)))
{}
+ //! <b>Effects</b>: Copy constructs a list using the specified allocator.
+ //!
+ //! <b>Postcondition</b>: x == *this.
+ //!
+ //! <b>Throws</b>: If allocator_type's default constructor or copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to the elements x contains.
+ list(const list& x, const allocator_type &a)
+ : AllocHolder(a)
+ { this->insert(this->cbegin(), x.begin(), x.end()); }
+
+ //! <b>Effects</b>: Move constructor sing the specified allocator.
+ //! Moves mx's resources to *this.
+ //!
+ //! <b>Throws</b>: If allocation or value_type's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise.
+ list(BOOST_RV_REF(list) x, const allocator_type &a)
+ : AllocHolder(a)
+ {
+ if(this->node_alloc() == x.node_alloc()){
+ this->icont().swap(x.icont());
+ }
+ else{
+ this->insert(this->cbegin(), x.begin(), x.end());
+ }
+ }
+
//! <b>Effects</b>: Constructs a list that will use a copy of allocator a
//! and inserts a copy of the range [first, last) in the list.
//!
@@ -396,14 +405,14 @@ class list
{} //AllocHolder clears the list
//! <b>Effects</b>: Returns a copy of the internal allocator.
- //!
+ //!
//! <b>Throws</b>: If allocator's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
allocator_type get_allocator() const
{ return allocator_type(this->node_alloc()); }
- const stored_allocator_type &get_stored_allocator() const
+ const stored_allocator_type &get_stored_allocator() const
{ return this->node_alloc(); }
stored_allocator_type &get_stored_allocator()
@@ -418,129 +427,129 @@ class list
{ AllocHolder::clear(alloc_version()); }
//! <b>Effects</b>: Returns an iterator to the first element contained in the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
iterator begin()
{ return iterator(this->icont().begin()); }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator begin() const
{ return this->cbegin(); }
//! <b>Effects</b>: Returns an iterator to the end of the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
iterator end()
{ return iterator(this->icont().end()); }
//! <b>Effects</b>: Returns a const_iterator to the end of the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator end() const
{ return this->cend(); }
- //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
- //! of the reversed list.
- //!
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
+ //! of the reversed list.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reverse_iterator rbegin()
{ return reverse_iterator(end()); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed list.
- //!
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed list.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator rbegin() const
{ return this->crbegin(); }
//! <b>Effects</b>: Returns a reverse_iterator pointing to the end
- //! of the reversed list.
- //!
+ //! of the reversed list.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reverse_iterator rend()
{ return reverse_iterator(begin()); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed list.
- //!
+ //! of the reversed list.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator rend() const
{ return this->crend(); }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator cbegin() const
{ return const_iterator(this->non_const_icont().begin()); }
//! <b>Effects</b>: Returns a const_iterator to the end of the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator cend() const
{ return const_iterator(this->non_const_icont().end()); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed list.
- //!
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed list.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator crbegin() const
{ return const_reverse_iterator(this->cend()); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed list.
- //!
+ //! of the reversed list.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator crend() const
{ return const_reverse_iterator(this->cbegin()); }
//! <b>Effects</b>: Returns true if the list contains no elements.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- bool empty() const
+ bool empty() const
{ return !this->size(); }
//! <b>Effects</b>: Returns the number of the elements contained in the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type size() const
+ size_type size() const
{ return this->icont().size(); }
//! <b>Effects</b>: Returns the largest possible size of the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type max_size() const
+ size_type max_size() const
{ return AllocHolder::max_size(); }
#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -588,7 +597,7 @@ class list
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Amortized constant time.
- void pop_front()
+ void pop_front()
{ this->erase(this->cbegin()); }
//! <b>Effects</b>: Removes the last element from the list.
@@ -596,51 +605,51 @@ class list
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Amortized constant time.
- void pop_back()
+ void pop_back()
{ const_iterator tmp = this->cend(); this->erase(--tmp); }
//! <b>Requires</b>: !empty()
//!
- //! <b>Effects</b>: Returns a reference to the first element
+ //! <b>Effects</b>: Returns a reference to the first element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reference front()
+ reference front()
{ return *this->begin(); }
//! <b>Requires</b>: !empty()
//!
- //! <b>Effects</b>: Returns a const reference to the first element
+ //! <b>Effects</b>: Returns a const reference to the first element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reference front() const
+ const_reference front() const
{ return *this->begin(); }
//! <b>Requires</b>: !empty()
//!
- //! <b>Effects</b>: Returns a reference to the first element
+ //! <b>Effects</b>: Returns a reference to the first element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reference back()
+ reference back()
{ return *(--this->end()); }
//! <b>Requires</b>: !empty()
//!
- //! <b>Effects</b>: Returns a const reference to the first element
+ //! <b>Effects</b>: Returns a const reference to the first element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reference back() const
+ const_reference back() const
{ return *(--this->end()); }
//! <b>Effects</b>: Inserts or erases elements at the end such that
@@ -653,7 +662,7 @@ class list
{
const_iterator iend = this->cend();
size_type len = this->size();
-
+
if(len > new_size){
size_type to_erase = len - new_size;
while(to_erase--){
@@ -676,7 +685,7 @@ class list
{
const_iterator iend = this->end();
size_type len = this->size();
-
+
if(len > new_size){
size_type to_erase = len - new_size;
const_iterator ifirst;
@@ -710,8 +719,8 @@ class list
//! <b>Effects</b>: Makes *this contain the same elements as x.
//!
- //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
- //! of each of x's elements.
+ //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
+ //! of each of x's elements.
//!
//! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
//!
@@ -782,7 +791,7 @@ class list
//!
//! <b>Complexity</b>: Linear to std::distance [first, last).
template <class InpIt>
- void insert(const_iterator p, InpIt first, InpIt last)
+ void insert(const_iterator p, InpIt first, InpIt last)
{
const bool aux_boolean = container_detail::is_convertible<InpIt, size_type>::value;
typedef container_detail::bool_<aux_boolean> Result;
@@ -891,7 +900,7 @@ class list
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Amortized constant time.
- iterator erase(const_iterator p)
+ iterator erase(const_iterator p)
{ return iterator(this->icont().erase_and_dispose(p.get(), Destroyer(this->node_alloc()))); }
//! <b>Requires</b>: first and last must be valid iterator to elements in *this.
@@ -909,7 +918,7 @@ class list
//! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
- void assign(size_type n, const T& val)
+ void assign(size_type n, const T& val)
{ this->priv_fill_assign(n, val); }
//! <b>Effects</b>: Assigns the the range [first, last) to *this.
@@ -919,7 +928,7 @@ class list
//!
//! <b>Complexity</b>: Linear to n.
template <class InpIt>
- void assign(InpIt first, InpIt last)
+ void assign(InpIt first, InpIt last)
{
const bool aux_boolean = container_detail::is_convertible<InpIt, size_type>::value;
typedef container_detail::bool_<aux_boolean> Result;
@@ -936,7 +945,7 @@ class list
//! are not equal.
//!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of
//! this list. Iterators of this list and all the references are not invalidated.
void splice(const_iterator p, ThisType& x) BOOST_CONTAINER_NOEXCEPT
@@ -947,16 +956,16 @@ class list
//! <b>Requires</b>: p must point to an element contained
//! by this list. i must point to an element contained in list x.
- //!
- //! <b>Effects</b>: Transfers the value pointed by i, from list x to this list,
+ //!
+ //! <b>Effects</b>: Transfers the value pointed by i, from list x to this list,
//! before the the element pointed by p. No destructors or copy constructors are called.
- //! If p == i or p == ++i, this function is a null operation.
- //!
+ //! If p == i or p == ++i, this function is a null operation.
+ //!
//! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
//! are not equal.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated.
void splice(const_iterator p, ThisType &x, const_iterator i) BOOST_CONTAINER_NOEXCEPT
@@ -967,15 +976,15 @@ class list
//! <b>Requires</b>: p must point to an element contained
//! by this list. first and last must point to elements contained in list x.
- //!
- //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
+ //!
+ //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
//! before the the element pointed by p. No destructors or copy constructors are called.
- //!
+ //!
//! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
//! are not equal.
- //!
+ //!
//! <b>Complexity</b>: Linear to the number of elements transferred.
- //!
+ //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated.
void splice(const_iterator p, ThisType &x, const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
@@ -987,15 +996,15 @@ class list
//! <b>Requires</b>: p must point to an element contained
//! by this list. first and last must point to elements contained in list x.
//! n == std::distance(first, last)
- //!
- //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
+ //!
+ //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
//! before the the element pointed by p. No destructors or copy constructors are called.
- //!
+ //!
//! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
//! are not equal.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated.
void splice(const_iterator p, ThisType &x, const_iterator first, const_iterator last, size_type n) BOOST_CONTAINER_NOEXCEPT
@@ -1004,22 +1013,22 @@ class list
this->icont().splice(p.get(), x.icont(), first.get(), last.get(), n);
}
- //! <b>Effects</b>: Reverses the order of elements in the list.
- //!
+ //! <b>Effects</b>: Reverses the order of elements in the list.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: This function is linear time.
- //!
+ //!
//! <b>Note</b>: Iterators and references are not invalidated
void reverse()
- { this->icont().reverse(); }
+ { this->icont().reverse(); }
//! <b>Effects</b>: Removes all the elements that compare equal to value.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Linear time. It performs exactly size() comparisons for equality.
- //!
+ //!
//! <b>Note</b>: The relative order of elements that are not removed is unchanged,
//! and iterators to elements that are not removed remain valid.
void remove(const T& value)
@@ -1027,11 +1036,11 @@ class list
//! <b>Effects</b>: Removes all the elements for which a specified
//! predicate is satisfied.
- //!
+ //!
//! <b>Throws</b>: If pred throws.
- //!
+ //!
//! <b>Complexity</b>: Linear time. It performs exactly size() calls to the predicate.
- //!
+ //!
//! <b>Note</b>: The relative order of elements that are not removed is unchanged,
//! and iterators to elements that are not removed remain valid.
template <class Pred>
@@ -1041,25 +1050,25 @@ class list
this->icont().remove_and_dispose_if(Predicate(pred), Destroyer(this->node_alloc()));
}
- //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
+ //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
//! elements that are equal from the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Linear time (size()-1 comparisons calls to pred()).
- //!
+ //!
//! <b>Note</b>: The relative order of elements that are not removed is unchanged,
//! and iterators to elements that are not removed remain valid.
void unique()
{ this->unique(value_equal()); }
- //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
+ //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
//! elements that satisfy some binary predicate from the list.
- //!
+ //!
//! <b>Throws</b>: If pred throws.
- //!
+ //!
//! <b>Complexity</b>: Linear time (size()-1 comparisons equality comparisons).
- //!
+ //!
//! <b>Note</b>: The relative order of elements that are not removed is unchanged,
//! and iterators to elements that are not removed remain valid.
template <class BinaryPredicate>
@@ -1069,15 +1078,15 @@ class list
this->icont().unique_and_dispose(Predicate(binary_pred), Destroyer(this->node_alloc()));
}
- //! <b>Requires</b>: The lists x and *this must be distinct.
+ //! <b>Requires</b>: The lists x and *this must be distinct.
//!
//! <b>Effects</b>: This function removes all of x's elements and inserts them
- //! in order into *this according to std::less<value_type>. The merge is stable;
- //! that is, if an element from *this is equivalent to one from x, then the element
- //! from *this will precede the one from x.
- //!
+ //! in order into *this according to std::less<value_type>. The merge is stable;
+ //! that is, if an element from *this is equivalent to one from x, then the element
+ //! from *this will precede the one from x.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: This function is linear time: it performs at most
//! size() + x.size() - 1 comparisons.
void merge(list<T, A>& x)
@@ -1085,17 +1094,17 @@ class list
//! <b>Requires</b>: p must be a comparison function that induces a strict weak
//! ordering and both *this and x must be sorted according to that ordering
- //! The lists x and *this must be distinct.
- //!
+ //! The lists x and *this must be distinct.
+ //!
//! <b>Effects</b>: This function removes all of x's elements and inserts them
- //! in order into *this. The merge is stable; that is, if an element from *this is
- //! equivalent to one from x, then the element from *this will precede the one from x.
- //!
+ //! in order into *this. The merge is stable; that is, if an element from *this is
+ //! equivalent to one from x, then the element from *this will precede the one from x.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: This function is linear time: it performs at most
//! size() + x.size() - 1 comparisons.
- //!
+ //!
//! <b>Note</b>: Iterators and references to *this are not invalidated.
template <class StrictWeakOrdering>
void merge(list &x, StrictWeakOrdering comp)
@@ -1109,25 +1118,25 @@ class list
}
}
- //! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>.
+ //! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>.
//! The sort is stable, that is, the relative order of equivalent elements is preserved.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Notes</b>: Iterators and references are not invalidated.
- //!
+ //!
//! <b>Complexity</b>: The number of comparisons is approximately N log N, where N
//! is the list's size.
void sort()
{ this->sort(value_less()); }
- //! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>.
+ //! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>.
//! The sort is stable, that is, the relative order of equivalent elements is preserved.
- //!
+ //!
//! <b>Throws</b>: Nothing.
//!
//! <b>Notes</b>: Iterators and references are not invalidated.
- //!
+ //!
//! <b>Complexity</b>: The number of comparisons is approximately N log N, where N
//! is the list's size.
template <class StrictWeakOrdering>
@@ -1142,25 +1151,25 @@ class list
/// @cond
private:
- iterator priv_insert(const_iterator p, const T &x)
+ iterator priv_insert(const_iterator p, const T &x)
{
NodePtr tmp = AllocHolder::create_node(x);
return iterator(this->icont().insert(p.get(), *tmp));
}
- iterator priv_insert(const_iterator p, BOOST_RV_REF(T) x)
+ iterator priv_insert(const_iterator p, BOOST_RV_REF(T) x)
{
NodePtr tmp = AllocHolder::create_node(boost::move(x));
return iterator(this->icont().insert(p.get(), *tmp));
}
- void priv_push_back (const T &x)
+ void priv_push_back (const T &x)
{ this->insert(this->cend(), x); }
void priv_push_back (BOOST_RV_REF(T) x)
{ this->insert(this->cend(), boost::move(x)); }
- void priv_push_front (const T &x)
+ void priv_push_front (const T &x)
{ this->insert(this->cbegin(), x); }
void priv_push_front (BOOST_RV_REF(T) x)
@@ -1242,10 +1251,10 @@ class list
{ this->priv_create_and_insert_nodes(p, first, last); }
template<class Integer>
- void priv_insert_dispatch(const_iterator p, Integer n, Integer x, container_detail::true_)
+ void priv_insert_dispatch(const_iterator p, Integer n, Integer x, container_detail::true_)
{ this->insert(p, (size_type)n, x); }
- void priv_fill_assign(size_type n, const T& val)
+ void priv_fill_assign(size_type n, const T& val)
{
iterator i = this->begin(), iend = this->end();
@@ -1319,25 +1328,25 @@ inline bool operator<(const list<T,A>& x,
}
template <class T, class A>
-inline bool operator!=(const list<T,A>& x, const list<T,A>& y)
+inline bool operator!=(const list<T,A>& x, const list<T,A>& y)
{
return !(x == y);
}
template <class T, class A>
-inline bool operator>(const list<T,A>& x, const list<T,A>& y)
+inline bool operator>(const list<T,A>& x, const list<T,A>& y)
{
return y < x;
}
template <class T, class A>
-inline bool operator<=(const list<T,A>& x, const list<T,A>& y)
+inline bool operator<=(const list<T,A>& x, const list<T,A>& y)
{
return !(y < x);
}
template <class T, class A>
-inline bool operator>=(const list<T,A>& x, const list<T,A>& y)
+inline bool operator>=(const list<T,A>& x, const list<T,A>& y)
{
return !(x < y);
}