summaryrefslogtreecommitdiff
path: root/boost/container/slist.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/container/slist.hpp')
-rw-r--r--boost/container/slist.hpp346
1 files changed, 166 insertions, 180 deletions
diff --git a/boost/container/slist.hpp b/boost/container/slist.hpp
index b6b4c388a2..b0901ef086 100644
--- a/boost/container/slist.hpp
+++ b/boost/container/slist.hpp
@@ -11,46 +11,48 @@
#ifndef BOOST_CONTAINER_SLIST_HPP
#define BOOST_CONTAINER_SLIST_HPP
-#if defined(_MSC_VER)
+#ifndef BOOST_CONFIG_HPP
+# include <boost/config.hpp>
+#endif
+
+#if defined(BOOST_HAS_PRAGMA_ONCE)
# pragma once
#endif
#include <boost/container/detail/config_begin.hpp>
#include <boost/container/detail/workaround.hpp>
+// container
#include <boost/container/container_fwd.hpp>
+#include <boost/container/new_allocator.hpp> //new_allocator
#include <boost/container/throw_exception.hpp>
-#include <boost/move/utility_core.hpp>
-#include <boost/move/detail/move_helpers.hpp>
-#include <boost/move/traits.hpp>
-#include <boost/intrusive/pointer_traits.hpp>
-#include <boost/container/detail/utilities.hpp>
+// container/detail
+#include <boost/container/detail/algorithm.hpp> //algo_equal(), algo_lexicographical_compare
+#include <boost/container/detail/compare_functors.hpp>
+#include <boost/container/detail/iterator.hpp>
#include <boost/container/detail/iterators.hpp>
#include <boost/container/detail/mpl.hpp>
-#include <boost/container/detail/type_traits.hpp>
-#include <boost/core/no_exceptions_support.hpp>
#include <boost/container/detail/node_alloc_holder.hpp>
+#include <boost/container/detail/type_traits.hpp>
+// intrusive
+#include <boost/intrusive/pointer_traits.hpp>
#include <boost/intrusive/slist.hpp>
-#include <iterator>
-
-
-#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-//Preprocessor library to emulate perfect forwarding
-#else
-#include <boost/container/detail/preprocessor.hpp>
+// move
+#include <boost/move/iterator.hpp>
+#include <boost/move/traits.hpp>
+#include <boost/move/utility_core.hpp>
+// move/detail
+#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+#include <boost/move/detail/fwd_macros.hpp>
#endif
-
-#include <iterator>
-#include <utility>
-#include <memory>
-#include <functional>
-#include <algorithm>
-
+#include <boost/move/detail/move_helpers.hpp>
+// other
+#include <boost/core/no_exceptions_support.hpp>
+// std
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
#include <initializer_list>
#endif
-
namespace boost {
namespace container {
@@ -155,7 +157,7 @@ struct intrusive_slist_type
//! \tparam T The type of object that is stored in the list
//! \tparam Allocator The allocator used for all internal memory management
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class T, class Allocator = std::allocator<T> >
+template <class T, class Allocator = new_allocator<T> >
#else
template <class T, class Allocator>
#endif
@@ -167,48 +169,19 @@ class slist
typedef typename
container_detail::intrusive_slist_type<Allocator>::type Icont;
typedef container_detail::node_alloc_holder<Allocator, Icont> AllocHolder;
- typedef typename AllocHolder::NodePtr NodePtr;
- typedef typename AllocHolder::NodeAlloc NodeAlloc;
- typedef typename AllocHolder::ValAlloc ValAlloc;
- typedef typename AllocHolder::Node Node;
- typedef container_detail::allocator_destroyer<NodeAlloc> Destroyer;
- typedef typename AllocHolder::allocator_v1 allocator_v1;
- typedef typename AllocHolder::allocator_v2 allocator_v2;
- typedef typename AllocHolder::alloc_version alloc_version;
- typedef boost::container::allocator_traits<Allocator> allocator_traits_type;
-
- class equal_to_value
- {
- typedef typename AllocHolder::value_type value_type;
- const value_type &t_;
-
- public:
- equal_to_value(const value_type &t)
- : t_(t)
- {}
-
- bool operator()(const value_type &t)const
- { return t_ == t; }
- };
-
- template<class Pred>
- struct ValueCompareToNodeCompare
- : Pred
- {
- ValueCompareToNodeCompare(Pred pred)
- : Pred(pred)
- {}
-
- bool operator()(const Node &a, const Node &b) const
- { return static_cast<const Pred&>(*this)(a.m_data, b.m_data); }
-
- bool operator()(const Node &a) const
- { return static_cast<const Pred&>(*this)(a.m_data); }
- };
+ typedef typename AllocHolder::NodePtr NodePtr;
+ typedef typename AllocHolder::NodeAlloc NodeAlloc;
+ typedef typename AllocHolder::ValAlloc ValAlloc;
+ typedef typename AllocHolder::Node Node;
+ typedef container_detail::allocator_destroyer<NodeAlloc> Destroyer;
+ typedef typename AllocHolder::alloc_version alloc_version;
+ typedef boost::container::
+ allocator_traits<Allocator> allocator_traits_type;
+ typedef boost::container::equal_to_value<Allocator> equal_to_value_type;
BOOST_COPYABLE_AND_MOVABLE(slist)
- typedef container_detail::iterator<typename Icont::iterator, false> iterator_impl;
- typedef container_detail::iterator<typename Icont::iterator, true > const_iterator_impl;
+ typedef container_detail::iterator_from_iiterator<typename Icont::iterator, false> iterator_impl;
+ typedef container_detail::iterator_from_iiterator<typename Icont::iterator, true > const_iterator_impl;
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
public:
@@ -252,10 +225,17 @@ class slist
//! <b>Throws</b>: Nothing
//!
//! <b>Complexity</b>: Constant.
- explicit slist(const allocator_type& a) BOOST_CONTAINER_NOEXCEPT
+ explicit slist(const allocator_type& a) BOOST_NOEXCEPT_OR_NOTHROW
: AllocHolder(a)
{}
+ //! <b>Effects</b>: Constructs a list
+ //! and inserts n value-initialized value_types.
+ //!
+ //! <b>Throws</b>: If allocator_type's default constructor
+ //! throws or T's default or copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to n.
explicit slist(size_type n)
: AllocHolder(allocator_type())
{ this->resize(n); }
@@ -267,6 +247,17 @@ class slist
//! throws or T's default or copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
+ slist(size_type n, const allocator_type &a)
+ : AllocHolder(a)
+ { this->resize(n); }
+
+ //! <b>Effects</b>: Constructs a list that will use a copy of allocator a
+ //! and inserts n copies of value.
+ //!
+ //! <b>Throws</b>: If allocator_type's default constructor
+ //! throws or T's default or copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to n.
explicit slist(size_type n, const value_type& x, const allocator_type& a = allocator_type())
: AllocHolder(a)
{ this->insert_after(this->cbefore_begin(), n, x); }
@@ -307,13 +298,13 @@ class slist
: AllocHolder(x)
{ this->insert_after(this->cbefore_begin(), x.begin(), x.end()); }
- //! <b>Effects</b>: Move constructor. Moves mx's resources to *this.
+ //! <b>Effects</b>: Move constructor. Moves x's resources to *this.
//!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
//!
//! <b>Complexity</b>: Constant.
slist(BOOST_RV_REF(slist) x)
- : AllocHolder(boost::move(static_cast<AllocHolder&>(x)))
+ : AllocHolder(BOOST_MOVE_BASE(AllocHolder, x))
{}
//! <b>Effects</b>: Copy constructs a list using the specified allocator.
@@ -340,7 +331,7 @@ class slist
this->icont().swap(x.icont());
}
else{
- this->insert_after(this->cbefore_begin(), x.begin(), x.end());
+ this->insert_after(this->cbefore_begin(), boost::make_move_iterator(x.begin()), boost::make_move_iterator(x.end()));
}
}
@@ -350,7 +341,7 @@ class slist
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Linear to the number of elements.
- ~slist() BOOST_CONTAINER_NOEXCEPT
+ ~slist() BOOST_NOEXCEPT_OR_NOTHROW
{} //AllocHolder clears the slist
//! <b>Effects</b>: Makes *this contain the same elements as x.
@@ -389,7 +380,8 @@ class slist
//! propagate_on_container_move_assignment is true or
//! this->get>allocator() == x.get_allocator(). Linear otherwise.
slist& operator= (BOOST_RV_REF(slist) x)
- BOOST_CONTAINER_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value)
+ BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value
+ || allocator_traits_type::is_always_equal::value)
{
BOOST_ASSERT(this != &x);
NodeAlloc &this_alloc = this->node_alloc();
@@ -489,7 +481,7 @@ class slist
//! <b>Throws</b>: If allocator's copy constructor throws.
//!
//! <b>Complexity</b>: Constant.
- allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
+ allocator_type get_allocator() const BOOST_NOEXCEPT_OR_NOTHROW
{ return allocator_type(this->node_alloc()); }
//! <b>Effects</b>: Returns a reference to the internal allocator.
@@ -499,7 +491,7 @@ class slist
//! <b>Complexity</b>: Constant.
//!
//! <b>Note</b>: Non-standard extension.
- stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
+ stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW
{ return this->node_alloc(); }
//! <b>Effects</b>: Returns a reference to the internal allocator.
@@ -509,7 +501,7 @@ class slist
//! <b>Complexity</b>: Constant.
//!
//! <b>Note</b>: Non-standard extension.
- const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
+ const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->node_alloc(); }
//////////////////////////////////////////////
@@ -525,7 +517,7 @@ class slist
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- iterator before_begin() BOOST_CONTAINER_NOEXCEPT
+ iterator before_begin() BOOST_NOEXCEPT_OR_NOTHROW
{ return iterator(end()); }
//! <b>Effects</b>: Returns a non-dereferenceable const_iterator
@@ -535,7 +527,7 @@ class slist
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_iterator before_begin() const BOOST_CONTAINER_NOEXCEPT
+ const_iterator before_begin() const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->cbefore_begin(); }
//! <b>Effects</b>: Returns an iterator to the first element contained in the list.
@@ -543,7 +535,7 @@ class slist
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- iterator begin() BOOST_CONTAINER_NOEXCEPT
+ iterator begin() BOOST_NOEXCEPT_OR_NOTHROW
{ return iterator(this->icont().begin()); }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
@@ -551,7 +543,7 @@ class slist
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
+ const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->cbegin(); }
//! <b>Effects</b>: Returns an iterator to the end of the list.
@@ -559,7 +551,7 @@ class slist
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- iterator end() BOOST_CONTAINER_NOEXCEPT
+ iterator end() BOOST_NOEXCEPT_OR_NOTHROW
{ return iterator(this->icont().end()); }
//! <b>Effects</b>: Returns a const_iterator to the end of the list.
@@ -567,7 +559,7 @@ class slist
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_iterator end() const BOOST_CONTAINER_NOEXCEPT
+ const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->cend(); }
//! <b>Effects</b>: Returns a non-dereferenceable const_iterator
@@ -577,7 +569,7 @@ class slist
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_iterator cbefore_begin() const BOOST_CONTAINER_NOEXCEPT
+ const_iterator cbefore_begin() const BOOST_NOEXCEPT_OR_NOTHROW
{ return const_iterator(end()); }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
@@ -585,7 +577,7 @@ class slist
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
+ const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW
{ return const_iterator(this->non_const_icont().begin()); }
//! <b>Effects</b>: Returns a const_iterator to the end of the list.
@@ -593,7 +585,7 @@ class slist
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
+ const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW
{ return const_iterator(this->non_const_icont().end()); }
//! <b>Returns</b>: The iterator to the element before i in the sequence.
@@ -605,7 +597,7 @@ class slist
//! <b>Complexity</b>: Linear to the number of elements before i.
//!
//! <b>Note</b>: Non-standard extension.
- iterator previous(iterator p) BOOST_CONTAINER_NOEXCEPT
+ iterator previous(iterator p) BOOST_NOEXCEPT_OR_NOTHROW
{ return iterator(this->icont().previous(p.get())); }
//! <b>Returns</b>: The const_iterator to the element before i in the sequence.
@@ -713,7 +705,7 @@ class slist
//
//////////////////////////////////////////////
- #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//! <b>Effects</b>: Inserts an object of type T constructed with
//! std::forward<Args>(args)... in the front of the list
@@ -723,7 +715,7 @@ class slist
//!
//! <b>Complexity</b>: Amortized constant time.
template <class... Args>
- void emplace_front(Args&&... args)
+ void emplace_front(BOOST_FWD_REF(Args)... args)
{ this->emplace_after(this->cbefore_begin(), boost::forward<Args>(args)...); }
//! <b>Effects</b>: Inserts an object of type T constructed with
@@ -734,35 +726,30 @@ class slist
//!
//! <b>Complexity</b>: Constant
template <class... Args>
- iterator emplace_after(const_iterator prev, Args&&... args)
+ iterator emplace_after(const_iterator prev, BOOST_FWD_REF(Args)... args)
{
NodePtr pnode(AllocHolder::create_node(boost::forward<Args>(args)...));
return iterator(this->icont().insert_after(prev.get(), *pnode));
}
- #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-
- #define BOOST_PP_LOCAL_MACRO(n) \
- BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
- void emplace_front(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { \
- this->emplace(this->cbegin() \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
- } \
- \
- BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
- iterator emplace_after(const_iterator prev \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { \
- NodePtr pnode (AllocHolder::create_node \
- (BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \
- return iterator(this->icont().insert_after(prev.get(), *pnode)); \
- } \
- //!
- #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
- #include BOOST_PP_LOCAL_ITERATE()
-
- #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
+ #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+
+ #define BOOST_CONTAINER_SLIST_EMPLACE_CODE(N) \
+ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
+ void emplace_front(BOOST_MOVE_UREF##N)\
+ { this->emplace_after(this->cbefore_begin() BOOST_MOVE_I##N BOOST_MOVE_FWD##N);}\
+ \
+ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
+ iterator emplace_after(const_iterator p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
+ {\
+ NodePtr pnode (AllocHolder::create_node(BOOST_MOVE_FWD##N));\
+ return iterator(this->icont().insert_after(p.get(), *pnode));\
+ }\
+ //
+ BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_SLIST_EMPLACE_CODE)
+ #undef BOOST_CONTAINER_SLIST_EMPLACE_CODE
+
+ #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//! <b>Effects</b>: Inserts a copy of x at the beginning of the list.
@@ -774,7 +761,7 @@ class slist
void push_front(const T &x);
//! <b>Effects</b>: Constructs a new element in the beginning of the list
- //! and moves the resources of mx to this new element.
+ //! and moves the resources of x to this new element.
//!
//! <b>Throws</b>: If memory allocation throws.
//!
@@ -856,7 +843,7 @@ class slist
, typename container_detail::enable_if_c
< !container_detail::is_convertible<InpIt, size_type>::value
&& (container_detail::is_input_iterator<InpIt>::value
- || container_detail::is_same<alloc_version, allocator_v1>::value
+ || container_detail::is_same<alloc_version, version_1>::value
)
>::type * = 0
#endif
@@ -894,14 +881,14 @@ class slist
, typename container_detail::enable_if_c
< !container_detail::is_convertible<FwdIt, size_type>::value
&& !(container_detail::is_input_iterator<FwdIt>::value
- || container_detail::is_same<alloc_version, allocator_v1>::value
+ || container_detail::is_same<alloc_version, version_1>::value
)
>::type * = 0
)
{
//Optimized allocation and construction
insertion_functor func(this->icont(), prev.get());
- this->allocate_many_and_construct(first, std::distance(first, last), func);
+ this->allocate_many_and_construct(first, boost::container::iterator_distance(first, last), func);
return iterator(func.inserted_first());
}
#endif
@@ -952,6 +939,8 @@ class slist
//!
//! <b>Complexity</b>: Linear to the number of elements on *this and x.
void swap(slist& x)
+ BOOST_NOEXCEPT_IF( allocator_traits_type::propagate_on_container_swap::value
+ || allocator_traits_type::is_always_equal::value)
{ AllocHolder::swap(x); }
//! <b>Effects</b>: Erases all the elements of the list.
@@ -981,7 +970,7 @@ class slist
//!
//! <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_after(const_iterator prev_p, slist& x) BOOST_CONTAINER_NOEXCEPT
+ void splice_after(const_iterator prev_p, slist& x) BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(this != &x);
BOOST_ASSERT(this->node_alloc() == x.node_alloc());
@@ -1001,7 +990,7 @@ class slist
//!
//! <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_after(const_iterator prev_p, BOOST_RV_REF(slist) x) BOOST_CONTAINER_NOEXCEPT
+ void splice_after(const_iterator prev_p, BOOST_RV_REF(slist) x) BOOST_NOEXCEPT_OR_NOTHROW
{ this->splice_after(prev_p, static_cast<slist&>(x)); }
//! <b>Requires</b>: prev_p must be a valid iterator of this.
@@ -1018,7 +1007,7 @@ class slist
//!
//! <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_after(const_iterator prev_p, slist& x, const_iterator prev) BOOST_CONTAINER_NOEXCEPT
+ void splice_after(const_iterator prev_p, slist& x, const_iterator prev) BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(this->node_alloc() == x.node_alloc());
this->icont().splice_after(prev_p.get(), x.icont(), prev.get());
@@ -1038,7 +1027,7 @@ class slist
//!
//! <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_after(const_iterator prev_p, BOOST_RV_REF(slist) x, const_iterator prev) BOOST_CONTAINER_NOEXCEPT
+ void splice_after(const_iterator prev_p, BOOST_RV_REF(slist) x, const_iterator prev) BOOST_NOEXCEPT_OR_NOTHROW
{ this->splice_after(prev_p, static_cast<slist&>(x), prev); }
//! <b>Requires</b>: prev_p must be a valid iterator of this.
@@ -1056,7 +1045,7 @@ class slist
//! <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_after(const_iterator prev_p, slist& x,
- const_iterator before_first, const_iterator before_last) BOOST_CONTAINER_NOEXCEPT
+ const_iterator before_first, const_iterator before_last) BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(this->node_alloc() == x.node_alloc());
this->icont().splice_after
@@ -1078,13 +1067,13 @@ class slist
//! <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_after(const_iterator prev_p, BOOST_RV_REF(slist) x,
- const_iterator before_first, const_iterator before_last) BOOST_CONTAINER_NOEXCEPT
+ const_iterator before_first, const_iterator before_last) BOOST_NOEXCEPT_OR_NOTHROW
{ this->splice_after(prev_p, static_cast<slist&>(x), before_first, before_last); }
//! <b>Requires</b>: prev_p must be a valid iterator of this.
//! before_first and before_last must be valid iterators of x.
//! prev_p must not be contained in [before_first, before_last) range.
- //! n == std::distance(before_first, before_last).
+ //! n == distance(before_first, before_last).
//! this' allocator and x's allocator shall compare equal.
//!
//! <b>Effects</b>: Transfers the range [before_first + 1, before_last + 1)
@@ -1098,7 +1087,7 @@ class slist
//! list. Iterators of this list and all the references are not invalidated.
void splice_after(const_iterator prev_p, slist& x,
const_iterator before_first, const_iterator before_last,
- size_type n) BOOST_CONTAINER_NOEXCEPT
+ size_type n) BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(this->node_alloc() == x.node_alloc());
this->icont().splice_after
@@ -1108,7 +1097,7 @@ class slist
//! <b>Requires</b>: prev_p must be a valid iterator of this.
//! before_first and before_last must be valid iterators of x.
//! prev_p must not be contained in [before_first, before_last) range.
- //! n == std::distance(before_first, before_last).
+ //! n == distance(before_first, before_last).
//! this' allocator and x's allocator shall compare equal.
//!
//! <b>Effects</b>: Transfers the range [before_first + 1, before_last + 1)
@@ -1122,7 +1111,7 @@ class slist
//! list. Iterators of this list and all the references are not invalidated.
void splice_after(const_iterator prev_p, BOOST_RV_REF(slist) x,
const_iterator before_first, const_iterator before_last,
- size_type n) BOOST_CONTAINER_NOEXCEPT
+ size_type n) BOOST_NOEXCEPT_OR_NOTHROW
{ this->splice_after(prev_p, static_cast<slist&>(x), before_first, before_last, n); }
//! <b>Effects</b>: Removes all the elements that compare equal to value.
@@ -1134,7 +1123,7 @@ class slist
//! <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)
- { this->remove_if(equal_to_value(value)); }
+ { this->remove_if(equal_to_value_type(value)); }
//! <b>Effects</b>: Removes all the elements for which a specified
//! predicate is satisfied.
@@ -1148,8 +1137,8 @@ class slist
template <class Pred>
void remove_if(Pred pred)
{
- typedef ValueCompareToNodeCompare<Pred> Predicate;
- this->icont().remove_and_dispose_if(Predicate(pred), Destroyer(this->node_alloc()));
+ typedef value_to_node_compare<Node, Pred> value_to_node_compare_type;
+ this->icont().remove_and_dispose_if(value_to_node_compare_type(pred), Destroyer(this->node_alloc()));
}
//! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
@@ -1176,8 +1165,8 @@ class slist
template <class Pred>
void unique(Pred pred)
{
- typedef ValueCompareToNodeCompare<Pred> Predicate;
- this->icont().unique_and_dispose(Predicate(pred), Destroyer(this->node_alloc()));
+ typedef value_to_node_compare<Node, Pred> value_to_node_compare_type;
+ this->icont().unique_and_dispose(value_to_node_compare_type(pred), Destroyer(this->node_alloc()));
}
//! <b>Requires</b>: The lists x and *this must be distinct.
@@ -1225,9 +1214,9 @@ class slist
template <class StrictWeakOrdering>
void merge(slist& x, StrictWeakOrdering comp)
{
+ typedef value_to_node_compare<Node, StrictWeakOrdering> value_to_node_compare_type;
BOOST_ASSERT(this->node_alloc() == x.node_alloc());
- this->icont().merge(x.icont(),
- ValueCompareToNodeCompare<StrictWeakOrdering>(comp));
+ this->icont().merge(x.icont(), value_to_node_compare_type(comp));
}
//! <b>Requires</b>: p must be a comparison function that induces a strict weak
@@ -1272,10 +1261,11 @@ class slist
template <class StrictWeakOrdering>
void sort(StrictWeakOrdering comp)
{
+ typedef value_to_node_compare<Node, StrictWeakOrdering> value_to_node_compare_type;
// nothing if the slist has length 0 or 1.
if (this->size() < 2)
return;
- this->icont().sort(ValueCompareToNodeCompare<StrictWeakOrdering>(comp));
+ this->icont().sort(value_to_node_compare_type(comp));
}
//! <b>Effects</b>: Reverses the order of elements in the list.
@@ -1285,7 +1275,7 @@ class slist
//! <b>Complexity</b>: This function is linear time.
//!
//! <b>Note</b>: Iterators and references are not invalidated
- void reverse() BOOST_CONTAINER_NOEXCEPT
+ void reverse() BOOST_NOEXCEPT_OR_NOTHROW
{ this->icont().reverse(); }
//////////////////////////////////////////////
@@ -1294,7 +1284,7 @@ class slist
//
//////////////////////////////////////////////
- #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//! <b>Effects</b>: Inserts an object of type T constructed with
//! std::forward<Args>(args)... before p
@@ -1304,24 +1294,22 @@ class slist
//!
//! <b>Complexity</b>: Linear to the elements before p
template <class... Args>
- iterator emplace(const_iterator p, Args&&... args)
+ iterator emplace(const_iterator p, BOOST_FWD_REF(Args)... args)
{ return this->emplace_after(this->previous(p), boost::forward<Args>(args)...); }
- #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
+ #else
- #define BOOST_PP_LOCAL_MACRO(n) \
- BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
- iterator emplace (const_iterator p \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { \
- return this->emplace_after \
- (this->previous(p) \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
- } \
- //!
- #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
- #include BOOST_PP_LOCAL_ITERATE()
- #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
+ #define BOOST_CONTAINER_SLIST_EMPLACE_CODE(N) \
+ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
+ iterator emplace(const_iterator p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
+ {\
+ return this->emplace_after(this->previous(p) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
+ }\
+ //
+ BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_SLIST_EMPLACE_CODE)
+ #undef BOOST_CONTAINER_SLIST_EMPLACE_CODE
+
+ #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//! <b>Requires</b>: p must be a valid iterator of *this.
@@ -1337,7 +1325,7 @@ class slist
//! <b>Requires</b>: p must be a valid iterator of *this.
//!
- //! <b>Effects</b>: Insert a new element before p with mx's resources.
+ //! <b>Effects</b>: Insert a new element before p with x's resources.
//!
//! <b>Returns</b>: an iterator to the inserted element.
//!
@@ -1374,7 +1362,7 @@ class slist
//! <b>Throws</b>: If memory allocation throws, T's constructor from a
//! dereferenced InpIt throws.
//!
- //! <b>Complexity</b>: Linear to std::distance [first, last) plus
+ //! <b>Complexity</b>: Linear to distance [first, last) plus
//! linear to the elements before p.
template <class InIter>
iterator insert(const_iterator p, InIter first, InIter last)
@@ -1409,7 +1397,7 @@ class slist
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Linear to the number of elements before p.
- iterator erase(const_iterator p) BOOST_CONTAINER_NOEXCEPT
+ iterator erase(const_iterator p) BOOST_NOEXCEPT_OR_NOTHROW
{ return iterator(this->erase_after(previous(p))); }
//! <b>Requires</b>: first and last must be valid iterator to elements in *this.
@@ -1420,7 +1408,7 @@ class slist
//!
//! <b>Complexity</b>: Linear to the distance between first and last plus
//! linear to the elements before first.
- iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
+ iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
{ return iterator(this->erase_after(previous(first), last)); }
//! <b>Requires</b>: p must point to an element contained
@@ -1435,7 +1423,7 @@ class slist
//!
//! <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, slist& x) BOOST_CONTAINER_NOEXCEPT
+ void splice(const_iterator p, slist& x) BOOST_NOEXCEPT_OR_NOTHROW
{ this->splice_after(this->previous(p), x); }
//! <b>Requires</b>: p must point to an element contained
@@ -1450,7 +1438,7 @@ class slist
//!
//! <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, BOOST_RV_REF(slist) x) BOOST_CONTAINER_NOEXCEPT
+ void splice(const_iterator p, BOOST_RV_REF(slist) x) BOOST_NOEXCEPT_OR_NOTHROW
{ this->splice(p, static_cast<slist&>(x)); }
//! <b>Requires</b>: p must point to an element contained
@@ -1467,7 +1455,7 @@ class slist
//!
//! <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, slist& x, const_iterator i) BOOST_CONTAINER_NOEXCEPT
+ void splice(const_iterator p, slist& x, const_iterator i) BOOST_NOEXCEPT_OR_NOTHROW
{ this->splice_after(this->previous(p), x, this->previous(i)); }
//! <b>Requires</b>: p must point to an element contained
@@ -1484,7 +1472,7 @@ class slist
//!
//! <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, BOOST_RV_REF(slist) x, const_iterator i) BOOST_CONTAINER_NOEXCEPT
+ void splice(const_iterator p, BOOST_RV_REF(slist) x, const_iterator i) BOOST_NOEXCEPT_OR_NOTHROW
{ this->splice(p, static_cast<slist&>(x), i); }
//! <b>Requires</b>: p must point to an element contained
@@ -1501,7 +1489,7 @@ class slist
//!
//! <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, slist& x, const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
+ void splice(const_iterator p, slist& x, const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
{ this->splice_after(this->previous(p), x, this->previous(first), this->previous(last)); }
//! <b>Requires</b>: p must point to an element contained
@@ -1518,28 +1506,14 @@ class slist
//!
//! <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, BOOST_RV_REF(slist) x, const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
+ void splice(const_iterator p, BOOST_RV_REF(slist) x, const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
{ this->splice(p, static_cast<slist&>(x), first, last); }
//! <b>Effects</b>: Returns true if x and y are equal
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator==(const slist& x, const slist& y)
- {
- if(x.size() != y.size()){
- return false;
- }
- typedef typename slist<T,Allocator>::const_iterator const_iterator;
- const_iterator end1 = x.end();
-
- const_iterator i1 = x.begin();
- const_iterator i2 = y.begin();
- while (i1 != end1 && *i1 == *i2){
- ++i1;
- ++i2;
- }
- return i1 == end1;
- }
+ { return x.size() == y.size() && ::boost::container::algo_equal(x.begin(), x.end(), y.begin()); }
//! <b>Effects</b>: Returns true if x and y are unequal
//!
@@ -1551,7 +1525,7 @@ class slist
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<(const slist& x, const slist& y)
- { return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
+ { return ::boost::container::algo_lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
//! <b>Effects</b>: Returns true if x is greater than y
//!
@@ -1672,8 +1646,11 @@ namespace boost {
//!specialization for optimizations
template <class T, class Allocator>
struct has_trivial_destructor_after_move<boost::container::slist<T, Allocator> >
- : public ::boost::has_trivial_destructor_after_move<Allocator>
-{};
+{
+ typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
+ static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
+ ::boost::has_trivial_destructor_after_move<pointer>::value;
+};
namespace container {
@@ -1686,9 +1663,13 @@ namespace container {
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
-//Ummm, I don't like to define things in namespace std, but
-//there is no other way
-namespace std {
+#if defined(__clang__) && defined(_LIBCPP_VERSION)
+ #define BOOST_CONTAINER_CLANG_INLINE_STD_NS
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wc++11-extensions"
+#endif
+
+BOOST_CONTAINER_STD_NS_BEG
template <class T, class Allocator>
class insert_iterator<boost::container::slist<T, Allocator> >
@@ -1721,7 +1702,12 @@ class insert_iterator<boost::container::slist<T, Allocator> >
insert_iterator<Container>& operator++(int){ return *this; }
};
-} //namespace std;
+BOOST_CONTAINER_STD_NS_END
+
+#ifdef BOOST_CONTAINER_CLANG_INLINE_STD_NS
+ #pragma GCC diagnostic pop
+ #undef BOOST_CONTAINER_CLANG_INLINE_STD_NS
+#endif //BOOST_CONTAINER_CLANG_INLINE_STD_NS
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED