From 3143f0c6b8db6d88d70d3923b5d9cbde31280112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Fri, 30 Dec 2011 09:03:25 +0000 Subject: [PATCH 01/93] Code simplification to support gcc-3.4 & gcc-4.0 [SVN r76225] --- .../boost/container/allocator/allocator_traits.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/boost/container/allocator/allocator_traits.hpp b/include/boost/container/allocator/allocator_traits.hpp index 34f526e..bf0fe74 100644 --- a/include/boost/container/allocator/allocator_traits.hpp +++ b/include/boost/container/allocator/allocator_traits.hpp @@ -118,9 +118,9 @@ struct allocator_traits pointer, value_type*) pointer; //const_pointer - typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc, const_pointer, typename boost::intrusive::pointer_traits::template - rebind_pointer::type) + rebind_pointer) const_pointer; //reference typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, @@ -131,14 +131,14 @@ struct allocator_traits const_reference, const value_type&) const_reference; //void_pointer - typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc, void_pointer, typename boost::intrusive::pointer_traits::template - rebind_pointer::type) + rebind_pointer) void_pointer; //const_void_pointer - typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc, const_void_pointer, typename boost::intrusive::pointer_traits::template - rebind_pointer::type) + rebind_pointer) const_void_pointer; //difference_type typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, From cd25b32744cc8d747b5088bf761923908f1dc029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Fri, 30 Dec 2011 23:38:12 +0000 Subject: [PATCH 02/93] Bugs #6335 & #6336 [SVN r76236] --- .../container/allocator/allocator_traits.hpp | 5 +- include/boost/container/detail/flat_tree.hpp | 48 ++++++------------ include/boost/container/detail/mpl.hpp | 4 ++ include/boost/container/detail/tree.hpp | 26 +++++----- include/boost/container/flat_map.hpp | 50 ++++++++++--------- include/boost/container/flat_set.hpp | 23 +++++---- include/boost/container/map.hpp | 25 +++++----- include/boost/container/set.hpp | 38 ++++++++------ include/boost/container/slist.hpp | 9 ++-- include/boost/container/stable_vector.hpp | 19 +++---- include/boost/container/vector.hpp | 18 +++---- 11 files changed, 137 insertions(+), 128 deletions(-) diff --git a/include/boost/container/allocator/allocator_traits.hpp b/include/boost/container/allocator/allocator_traits.hpp index bf0fe74..0192161 100644 --- a/include/boost/container/allocator/allocator_traits.hpp +++ b/include/boost/container/allocator/allocator_traits.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include //numeric_limits<>::max() #include //placement new @@ -124,11 +125,11 @@ struct allocator_traits const_pointer; //reference typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, - reference, value_type&) + reference, typename container_detail::unvoid::type&) reference; //const_reference typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, - const_reference, const value_type&) + const_reference, const typename container_detail::unvoid::type&) const_reference; //void_pointer typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc, diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp index 9ad5c0d..4443838 100644 --- a/include/boost/container/detail/flat_tree.hpp +++ b/include/boost/container/detail/flat_tree.hpp @@ -352,7 +352,7 @@ class flat_tree #ifdef BOOST_CONTAINER_PERFECT_FORWARDING template - iterator emplace_unique(Args&&... args) + std::pair emplace_unique(Args&&... args) { value_type && val = value_type(boost::forward(args)...); insert_commit_data data; @@ -361,7 +361,7 @@ class flat_tree if(ret.second){ ret.first = priv_insert_commit(data, boost::move(val)); } - return ret.first; + return ret; } template @@ -398,27 +398,28 @@ class flat_tree #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_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + std::pair \ + emplace_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { \ - BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), container_detail::value_init<) value_type \ + BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), container_detail::value_init<) value_type \ BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), >) vval BOOST_PP_LPAREN_IF(n) \ - BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) BOOST_PP_RPAREN_IF(n); \ + BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) BOOST_PP_RPAREN_IF(n); \ value_type &val = vval; \ insert_commit_data data; \ std::pair ret = priv_insert_unique_prepare(val, data); \ if(ret.second){ \ ret.first = priv_insert_commit(data, boost::move(val)); \ } \ - return ret.first; \ + return ret; \ } \ \ BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ iterator emplace_hint_unique(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { \ - BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), container_detail::value_init<) value_type \ + BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), container_detail::value_init<) value_type \ BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), >) vval BOOST_PP_LPAREN_IF(n) \ - BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) BOOST_PP_RPAREN_IF(n); \ + BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) BOOST_PP_RPAREN_IF(n); \ value_type &val = vval; \ insert_commit_data data; \ std::pair ret = priv_insert_unique_prepare(hint, val, data); \ @@ -429,11 +430,11 @@ class flat_tree } \ \ BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - iterator emplace_equal(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + iterator emplace_equal(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { \ - BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), container_detail::value_init<) value_type \ + BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), container_detail::value_init<) value_type \ BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), >) vval BOOST_PP_LPAREN_IF(n) \ - BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) BOOST_PP_RPAREN_IF(n); \ + BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) BOOST_PP_RPAREN_IF(n); \ value_type &val = vval; \ iterator i = this->upper_bound(KeyOfValue()(val)); \ i = this->m_data.m_vect.insert(i, boost::move(val)); \ @@ -442,11 +443,11 @@ class flat_tree \ BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ iterator emplace_hint_equal(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { \ - BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), container_detail::value_init<) value_type \ + BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), container_detail::value_init<) value_type \ BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), >) vval BOOST_PP_LPAREN_IF(n) \ - BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) BOOST_PP_RPAREN_IF(n); \ + BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) BOOST_PP_RPAREN_IF(n); \ value_type &val = vval; \ insert_commit_data data; \ priv_insert_equal_prepare(hint, val, data); \ @@ -743,23 +744,6 @@ class flat_tree for ( ; first != last; ++first) this->insert_equal(*first); } - -/* - template - void priv_insert_unique(FwdIt first, FwdIt last, std::forward_iterator_tag) - { - size_type len = static_cast(std::distance(first, last)); - this->reserve(this->size()+len); - priv_insert_unique(first, last, std::input_iterator_tag()); - } - - template - void priv_insert_unique(InIt first, InIt last, std::input_iterator_tag) - { - for ( ; first != last; ++first) - this->insert_unique(*first); - } -*/ }; template static const std::size_t value = 0; }; +template struct unvoid { typedef T type; }; +template <> struct unvoid { struct type { }; }; +template <> struct unvoid { struct type { }; }; + } //namespace container_detail { } //namespace container { } //namespace boost { diff --git a/include/boost/container/detail/tree.hpp b/include/boost/container/detail/tree.hpp index 2a60e11..6cd91ed 100644 --- a/include/boost/container/detail/tree.hpp +++ b/include/boost/container/detail/tree.hpp @@ -753,7 +753,7 @@ class rbtree } private: - iterator emplace_unique_impl(NodePtr p) + std::pair emplace_unique_impl(NodePtr p) { value_type &v = p->get_data(); insert_commit_data data; @@ -761,9 +761,11 @@ class rbtree this->insert_unique_check(KeyOfValue()(v), data); if(!ret.second){ Destroyer(this->node_alloc())(p); - return ret.first; + return ret; } - return iterator(iiterator(this->icont().insert_unique_commit(*p, data))); + return std::pair + ( iterator(iiterator(this->icont().insert_unique_commit(*p, data))) + , true ); } iterator emplace_unique_hint_impl(const_iterator hint, NodePtr p) @@ -784,7 +786,7 @@ class rbtree #ifdef BOOST_CONTAINER_PERFECT_FORWARDING template - iterator emplace_unique(Args&&... args) + std::pair emplace_unique(Args&&... args) { return this->emplace_unique_impl(AllocHolder::create_node(boost::forward(args)...)); } template @@ -809,32 +811,32 @@ class rbtree #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_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + std::pair emplace_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { \ return this->emplace_unique_impl \ - (AllocHolder::create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \ + (AllocHolder::create_node(BOOST_PP_ENUM(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_hint_unique(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { \ return this->emplace_unique_hint_impl \ - (hint, AllocHolder::create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \ + (hint, AllocHolder::create_node(BOOST_PP_ENUM(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_equal(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + iterator emplace_equal(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { \ - NodePtr p(AllocHolder::create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \ + NodePtr p(AllocHolder::create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \ return iterator(this->icont().insert_equal(this->icont().end(), *p)); \ } \ \ BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ iterator emplace_hint_equal(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { \ - NodePtr p(AllocHolder::create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \ + NodePtr p(AllocHolder::create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \ return iterator(this->icont().insert_equal(hint.get(), *p)); \ } \ //! diff --git a/include/boost/container/flat_map.hpp b/include/boost/container/flat_map.hpp index bec26e3..2d4515b 100644 --- a/include/boost/container/flat_map.hpp +++ b/include/boost/container/flat_map.hpp @@ -515,8 +515,8 @@ class flat_map //! //! Note: If an element is inserted it might invalidate elements. iterator insert(const_iterator position, BOOST_RV_REF(value_type) x) - { return container_detail::force_copy( - m_flat_tree.insert_unique(container_detail::force(position), boost::move(container_detail::force(x)))); } + { return container_detail::force_copy + (m_flat_tree.insert_unique(container_detail::force(position), boost::move(container_detail::force(x)))); } //! Effects: Inserts an element move constructed from x in the container. //! p is a hint pointing to where the insert should start to search. @@ -548,7 +548,7 @@ class flat_map #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - //! Effects: Inserts an object of type T constructed with + //! Effects: Inserts an object x of type T constructed with //! std::forward(args)... if and only if there is no element in the container //! with key equivalent to the key of x. //! @@ -561,8 +561,8 @@ class flat_map //! //! Note: If an element is inserted it might invalidate elements. template - iterator emplace(Args&&... args) - { return container_detail::force_copy(m_flat_tree.emplace_unique(boost::forward(args)...)); } + std::pair emplace(Args&&... args) + { return container_detail::force_copy< std::pair >(m_flat_tree.emplace_unique(boost::forward(args)...)); } //! Effects: Inserts an object of type T constructed with //! std::forward(args)... in the container if and only if there is @@ -578,22 +578,23 @@ class flat_map //! Note: If an element is inserted it might invalidate elements. template iterator emplace_hint(const_iterator hint, Args&&... args) - { return container_detail::force_copy(m_flat_tree.emplace_hint_unique(container_detail::force(hint), boost::forward(args)...)); } + { return container_detail::force_copy + (m_flat_tree.emplace_hint_unique(container_detail::force(hint), boost::forward(args)...)); } #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, >) \ - iterator emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return container_detail::force_copy(m_flat_tree.emplace_unique \ - (BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); } \ + std::pair emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return container_detail::force_copy< std::pair > \ + (m_flat_tree.emplace_unique(BOOST_PP_ENUM(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_hint(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return container_detail::force_copy(m_flat_tree.emplace_hint_unique \ - (container_detail::force(hint) \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); } \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return container_detail::force_copy(m_flat_tree.emplace_hint_unique \ + (container_detail::force(hint) \ + 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() @@ -631,7 +632,8 @@ class flat_map //! Complexity: Logarithmic search time plus erasure time //! linear to the elements with bigger keys. iterator erase(const_iterator first, const_iterator last) - { return container_detail::force_copy(m_flat_tree.erase(container_detail::force(first), container_detail::force(last))); } + { return container_detail::force_copy + (m_flat_tree.erase(container_detail::force(first), container_detail::force(last))); } //! Effects: erase(a.begin(),a.end()). //! @@ -1151,7 +1153,8 @@ class flat_multimap //! //! Note: If an element is inserted it might invalidate elements. iterator insert(const_iterator position, const value_type& x) - { return container_detail::force_copy(m_flat_tree.insert_equal(container_detail::force(position), container_detail::force(x))); } + { return container_detail::force_copy + (m_flat_tree.insert_equal(container_detail::force(position), container_detail::force(x))); } //! Effects: Inserts a value move constructed from x in the container. //! p is a hint pointing to where the insert should start to search. @@ -1237,16 +1240,16 @@ class flat_multimap #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(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return container_detail::force_copy(m_flat_tree.emplace_equal \ - (BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); } \ + iterator emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return container_detail::force_copy(m_flat_tree.emplace_equal \ + (BOOST_PP_ENUM(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_hint(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return container_detail::force_copy(m_flat_tree.emplace_hint_equal \ - (container_detail::force(hint) \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); } \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return container_detail::force_copy(m_flat_tree.emplace_hint_equal \ + (container_detail::force(hint) \ + 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() @@ -1284,7 +1287,8 @@ class flat_multimap //! Complexity: Logarithmic search time plus erasure time //! linear to the elements with bigger keys. iterator erase(const_iterator first, const_iterator last) - { return container_detail::force_copy(m_flat_tree.erase(container_detail::force(first), container_detail::force(last))); } + { return container_detail::force_copy + (m_flat_tree.erase(container_detail::force(first), container_detail::force(last))); } //! Effects: erase(a.begin(),a.end()). //! diff --git a/include/boost/container/flat_set.hpp b/include/boost/container/flat_set.hpp index 9d40bdd..f367309 100644 --- a/include/boost/container/flat_set.hpp +++ b/include/boost/container/flat_set.hpp @@ -418,7 +418,7 @@ class flat_set #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - //! Effects: Inserts an object of type T constructed with + //! Effects: Inserts an object x of type T constructed with //! std::forward(args)... if and only if there is no element in the container //! with key equivalent to the key of x. //! @@ -431,7 +431,7 @@ class flat_set //! //! Note: If an element is inserted it might invalidate elements. template - iterator emplace(Args&&... args) + std::pair emplace(Args&&... args) { return m_flat_tree.emplace_unique(boost::forward(args)...); } //! Effects: Inserts an object of type T constructed with @@ -454,14 +454,14 @@ class flat_set #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(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return m_flat_tree.emplace_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + std::pair emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return m_flat_tree.emplace_unique(BOOST_PP_ENUM(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_hint(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { return m_flat_tree.emplace_hint_unique \ - (hint BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + (hint 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() @@ -982,7 +982,8 @@ class flat_multiset { return this->insert(position, const_cast(x)); } template - iterator insert(const_iterator position, const U &u, typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0) + iterator insert( const_iterator position, const U &u + , typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0) { return priv_insert(position, u); } #endif @@ -1044,14 +1045,14 @@ class flat_multiset #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(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return m_flat_tree.emplace_equal(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + iterator emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return m_flat_tree.emplace_equal(BOOST_PP_ENUM(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_hint(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { return m_flat_tree.emplace_hint_equal \ - (hint BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + (hint 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() diff --git a/include/boost/container/map.hpp b/include/boost/container/map.hpp index f77dfa8..8f7ecd4 100644 --- a/include/boost/container/map.hpp +++ b/include/boost/container/map.hpp @@ -504,18 +504,19 @@ class map #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - //! Effects: Inserts an object of type T constructed with + //! Effects: Inserts an object x of type T constructed with //! std::forward(args)... in the container if and only if there is //! no element in the container with an equivalent key. //! p is a hint pointing to where the insert should start to search. //! - //! Returns: An iterator pointing to the element with key equivalent - //! to the key of x. + //! Returns: The bool component of the returned pair is true if and only + //! if the insertion takes place, and the iterator component of the pair + //! points to the element with key equivalent to the key of x. //! //! Complexity: Logarithmic in general, but amortized constant if t //! is inserted right before p. template - iterator emplace(Args&&... args) + std::pair emplace(Args&&... args) { return m_tree.emplace_unique(boost::forward(args)...); } //! Effects: Inserts an object of type T constructed with @@ -536,14 +537,14 @@ class map #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(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return m_tree.emplace_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + std::pair emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return m_tree.emplace_unique(BOOST_PP_ENUM(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_hint(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { return m_tree.emplace_hint_unique(hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));} \ + 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() @@ -1138,14 +1139,14 @@ class multimap #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(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return m_tree.emplace_equal(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + iterator emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return m_tree.emplace_equal(BOOST_PP_ENUM(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_hint(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { return m_tree.emplace_hint_equal(hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));} \ + 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() diff --git a/include/boost/container/set.hpp b/include/boost/container/set.hpp index 3cf22b5..b25e701 100644 --- a/include/boost/container/set.hpp +++ b/include/boost/container/set.hpp @@ -340,7 +340,8 @@ class set { return this->insert(const_cast(x)); } template - std::pair insert(const U &u, typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0) + std::pair insert(const U &u + , typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0) { return priv_insert(u); } #endif @@ -372,7 +373,8 @@ class set { return this->insert(position, const_cast(x)); } template - iterator insert(const_iterator position, const U &u, typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0) + iterator insert( const_iterator position, const U &u + , typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0) { return priv_insert(position, u); } #endif @@ -397,18 +399,22 @@ class set #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - //! Effects: Inserts an object of type T constructed with + //! Effects: Inserts an object x of type T constructed with //! std::forward(args)... if and only if there is //! no element in the container with equivalent value. //! and returns the iterator pointing to the - //! newly inserted element. + //! newly inserted element. + //! + //! Returns: The bool component of the returned pair is true if and only + //! if the insertion takes place, and the iterator component of the pair + //! points to the element with key equivalent to the key of x. //! //! Throws: If memory allocation throws or //! T's in-place constructor throws. //! //! Complexity: Logarithmic. template - iterator emplace(Args&&... args) + std::pair emplace(Args&&... args) { return m_tree.emplace_unique(boost::forward(args)...); } //! Effects: Inserts an object of type T constructed with @@ -428,14 +434,14 @@ class set #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(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return m_tree.emplace_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + std::pair emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return m_tree.emplace_unique(BOOST_PP_ENUM(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_hint(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { return m_tree.emplace_hint_unique(hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));} \ + 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() @@ -902,7 +908,8 @@ class multiset { return this->insert(const_cast(x)); } template - iterator insert(const U &u, typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0) + iterator insert(const U &u + , typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0) { return priv_insert(u); } #endif @@ -932,7 +939,8 @@ class multiset { return this->insert(position, const_cast(x)); } template - iterator insert(const_iterator position, const U &u, typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0) + iterator insert( const_iterator position, const U &u + , typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0) { return priv_insert(position, u); } #endif @@ -983,14 +991,14 @@ class multiset #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(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return m_tree.emplace_equal(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + iterator emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return m_tree.emplace_equal(BOOST_PP_ENUM(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_hint(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { return m_tree.emplace_hint_equal(hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));} \ + 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() diff --git a/include/boost/container/slist.hpp b/include/boost/container/slist.hpp index a3c6dd9..1cdcdf1 100644 --- a/include/boost/container/slist.hpp +++ b/include/boost/container/slist.hpp @@ -638,7 +638,8 @@ class slist void push_front(T &x) { push_front(const_cast(x)); } template - void push_front(const U &u, typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0) + void push_front(const U &u + , typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0) { return priv_push_front(u); } #endif @@ -700,7 +701,8 @@ class slist { return this->insert_after(position, const_cast(x)); } template - iterator insert_after(const_iterator position, const U &u, typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0) + iterator insert_after( const_iterator position, const U &u + , typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0) { return this->priv_insert_after(position, u); } #endif @@ -768,7 +770,8 @@ class slist { return this->insert(position, const_cast(x)); } template - iterator insert(const_iterator position, const U &u, typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0) + iterator insert( const_iterator position, const U &u + , typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0) { return this->priv_insert(position, u); } #endif diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp index f4ea541..8c3287a 100644 --- a/include/boost/container/stable_vector.hpp +++ b/include/boost/container/stable_vector.hpp @@ -7,13 +7,14 @@ // See http://www.boost.org/libs/container for documentation. // ////////////////////////////////////////////////////////////////////////////// -/* Stable vector. - * - * Copyright 2008 Joaquin M Lopez Munoz. - * 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) - */ +// Stable vector. +// +// Copyright 2008 Joaquin M Lopez Munoz. +// 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) +// +////////////////////////////////////////////////////////////////////////////// #ifndef BOOST_CONTAINER_STABLE_VECTOR_HPP #define BOOST_CONTAINER_STABLE_VECTOR_HPP @@ -140,8 +141,8 @@ struct node_type #define BOOST_PP_LOCAL_MACRO(n) \ BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - node_type(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - : value(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)) \ + node_type(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + : value(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)) \ {} \ //! #define BOOST_PP_LOCAL_LIMITS (1, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp index d7b2978..01483f9 100644 --- a/include/boost/container/vector.hpp +++ b/include/boost/container/vector.hpp @@ -1045,32 +1045,32 @@ class vector : private container_detail::vector_alloc_holder #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_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + void emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { \ - T* back_pos = container_detail::to_raw_pointer \ + T* back_pos = container_detail::to_raw_pointer \ (this->members_.m_start) + this->members_.m_size; \ if (this->members_.m_size < this->members_.m_capacity){ \ allocator_traits_type::construct (this->alloc() \ - , back_pos BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ + , back_pos BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ ++this->members_.m_size; \ } \ else{ \ - container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg) \ + container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg) \ proxy \ - (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ + (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ priv_range_insert(back_pos, 1, proxy); \ } \ } \ \ BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ iterator emplace(const_iterator pos \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { \ size_type pos_n = pos - cbegin(); \ - container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg) \ + container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg) \ proxy \ - (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ - priv_range_insert(container_detail::to_raw_pointer(pos.get_ptr()), 1, proxy); \ + (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ + priv_range_insert(container_detail::to_raw_pointer(pos.get_ptr()), 1, proxy); \ return iterator(this->members_.m_start + pos_n); \ } \ //! From 3f3a63d92a1a052ff74d6cc89931f2e99e3c4b6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Fri, 30 Dec 2011 23:47:03 +0000 Subject: [PATCH 03/93] Bugs #6335 & #6336 [SVN r76237] --- doc/container.qbk | 4 +- test/allocator_traits_test.cpp | 68 ++++++++++++++++++++-------------- 2 files changed, 43 insertions(+), 29 deletions(-) diff --git a/doc/container.qbk b/doc/container.qbk index 54f37c3..9038c53 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -590,7 +590,9 @@ use [*Boost.Container]? There are several reasons for that: * Fixed bugs [@https://svn.boost.org/trac/boost/ticket/6205 #6205], [@https://svn.boost.org/trac/boost/ticket/6287 #6287], - [@https://svn.boost.org/trac/boost/ticket/4383 #4383]. + [@https://svn.boost.org/trac/boost/ticket/4383 #4383], + [@https://svn.boost.org/trac/boost/ticket/6336 #6336], + [@https://svn.boost.org/trac/boost/ticket/6335 #6335]. * Added `allocator_traits` support for both C++11 and C++03 compilers through an internal `allocator_traits` clone. diff --git a/test/allocator_traits_test.cpp b/test/allocator_traits_test.cpp index ed109d4..36e5a9e 100644 --- a/test/allocator_traits_test.cpp +++ b/test/allocator_traits_test.cpp @@ -15,6 +15,7 @@ #include #include #include +#include template class SimpleAllocator @@ -63,7 +64,7 @@ class SimpleSmartPtr T *ptr_; }; -template +template class ComplexAllocator { bool allocate_called_; @@ -76,17 +77,19 @@ class ComplexAllocator public: typedef T value_type; - typedef SimpleSmartPtr pointer; - typedef SimpleSmartPtr const_pointer; - typedef T & reference; - typedef const T & const_reference; - typedef SimpleSmartPtr void_pointer; - typedef SimpleSmartPtr const_void_pointer; - typedef signed short difference_type; - typedef unsigned short size_type; - typedef boost::true_type propagate_on_container_copy_assignment; - typedef boost::true_type propagate_on_container_move_assignment; - typedef boost::true_type propagate_on_container_swap; + typedef SimpleSmartPtr pointer; + typedef SimpleSmartPtr const_pointer; + typedef typename boost::container:: + container_detail::unvoid::type & reference; + typedef const typename boost::container:: + container_detail::unvoid::type & const_reference; + typedef SimpleSmartPtr void_pointer; + typedef SimpleSmartPtr const_void_pointer; + typedef signed short difference_type; + typedef unsigned short size_type; + typedef boost::true_type propagate_on_container_copy_assignment; + typedef boost::true_type propagate_on_container_move_assignment; + typedef boost::true_type propagate_on_container_swap; ComplexAllocator() : allocate_called_(false) @@ -120,10 +123,10 @@ class ComplexAllocator #define BOOST_PP_LOCAL_MACRO(n) \ template \ - void construct(U *p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + void construct(U *p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { \ construct_called_ = true; \ - ::new (p) U (BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ + ::new (p) U (BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ } \ // #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) @@ -187,8 +190,17 @@ class copymovable { return moved_; } }; +void test_void_allocator() +{ + boost::container::allocator_traits > stdtraits; (void)stdtraits; + boost::container::allocator_traits > simtraits; (void)simtraits; + boost::container::allocator_traits > comtraits; (void)comtraits; +} + int main() { + test_void_allocator(); + //SimpleAllocator BOOST_STATIC_ASSERT(( boost::is_same >::value_type, int>::value )); @@ -219,33 +231,33 @@ int main() //ComplexAllocator BOOST_STATIC_ASSERT(( boost::is_same >::value_type, int>::value )); + < ComplexAllocator >::value_type, int>::value )); BOOST_STATIC_ASSERT(( boost::is_same >::pointer, SimpleSmartPtr >::value )); + < ComplexAllocator >::pointer, SimpleSmartPtr >::value )); BOOST_STATIC_ASSERT(( boost::is_same >::const_pointer, SimpleSmartPtr >::value )); + < ComplexAllocator >::const_pointer, SimpleSmartPtr >::value )); BOOST_STATIC_ASSERT(( boost::is_same >::void_pointer, SimpleSmartPtr >::value )); + < ComplexAllocator >::void_pointer, SimpleSmartPtr >::value )); BOOST_STATIC_ASSERT(( boost::is_same >::const_void_pointer, SimpleSmartPtr >::value )); + < ComplexAllocator >::const_void_pointer, SimpleSmartPtr >::value )); BOOST_STATIC_ASSERT(( boost::is_same >::difference_type, signed short>::value )); + < ComplexAllocator >::difference_type, signed short>::value )); BOOST_STATIC_ASSERT(( boost::is_same >::size_type, unsigned short>::value )); + < ComplexAllocator >::size_type, unsigned short>::value )); BOOST_STATIC_ASSERT(( boost::container::allocator_traits - < ComplexAllocator >::propagate_on_container_copy_assignment::value == true )); + < ComplexAllocator >::propagate_on_container_copy_assignment::value == true )); BOOST_STATIC_ASSERT(( boost::container::allocator_traits - < ComplexAllocator >::propagate_on_container_move_assignment::value == true )); + < ComplexAllocator >::propagate_on_container_move_assignment::value == true )); BOOST_STATIC_ASSERT(( boost::container::allocator_traits - < ComplexAllocator >::propagate_on_container_swap::value == true )); + < ComplexAllocator >::propagate_on_container_swap::value == true )); BOOST_STATIC_ASSERT(( boost::is_same >::rebind_traits::allocator_type - , ComplexAllocator >::value )); + < ComplexAllocator >::rebind_traits::allocator_type + , ComplexAllocator >::value )); BOOST_STATIC_ASSERT(( boost::is_same >::rebind_alloc::value_type + < ComplexAllocator >::rebind_alloc::value_type , double >::value )); - typedef ComplexAllocator CAlloc; + typedef ComplexAllocator CAlloc; typedef SimpleAllocator SAlloc; typedef boost::container::allocator_traits CAllocTraits; typedef boost::container::allocator_traits SAllocTraits; From ccff43c8fbc8bd838423f192e401f9d91b09b59b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 1 Jan 2012 18:48:00 +0000 Subject: [PATCH 04/93] Fixes for VC2005 and replaced some remaining placement news/destroys with allocator traits [SVN r76262] --- include/boost/container/deque.hpp | 36 +++-- include/boost/container/detail/algorithms.hpp | 123 ------------------ include/boost/container/stable_vector.hpp | 13 +- include/boost/container/string.hpp | 38 +++++- include/boost/container/vector.hpp | 2 +- 5 files changed, 67 insertions(+), 145 deletions(-) diff --git a/include/boost/container/deque.hpp b/include/boost/container/deque.hpp index d3b4732..79d03f9 100644 --- a/include/boost/container/deque.hpp +++ b/include/boost/container/deque.hpp @@ -1069,7 +1069,10 @@ class deque : protected deque_base { if (this->members_.m_finish.m_cur != this->members_.m_finish.m_first) { --this->members_.m_finish.m_cur; - container_detail::to_raw_pointer(this->members_.m_finish.m_cur)->~value_type(); + allocator_traits_type::destroy + ( this->alloc() + , container_detail::to_raw_pointer(this->members_.m_finish.m_cur) + ); } else this->priv_pop_back_aux(); @@ -1083,7 +1086,10 @@ class deque : protected deque_base void pop_front() BOOST_CONTAINER_NOEXCEPT { if (this->members_.m_start.m_cur != this->members_.m_start.m_last - 1) { - container_detail::to_raw_pointer(this->members_.m_start.m_cur)->~value_type(); + allocator_traits_type::destroy + ( this->alloc() + , container_detail::to_raw_pointer(this->members_.m_start.m_cur) + ); ++this->members_.m_start.m_cur; } else @@ -1598,14 +1604,22 @@ class deque : protected deque_base void priv_destroy_range(iterator p, iterator p2) { - for(;p != p2; ++p) - container_detail::to_raw_pointer(&*p)->~value_type(); + for(;p != p2; ++p){ + allocator_traits_type::destroy + ( this->alloc() + , container_detail::to_raw_pointer(&*p) + ); + } } void priv_destroy_range(pointer p, pointer p2) { - for(;p != p2; ++p) - container_detail::to_raw_pointer(&*p)->~value_type(); + for(;p != p2; ++p){ + allocator_traits_type::destroy + ( this->alloc() + , container_detail::to_raw_pointer(&*p) + ); + } } template @@ -1827,7 +1841,10 @@ class deque : protected deque_base this->priv_deallocate_node(this->members_.m_finish.m_first); this->members_.m_finish.priv_set_node(this->members_.m_finish.m_node - 1); this->members_.m_finish.m_cur = this->members_.m_finish.m_last - 1; - container_detail::to_raw_pointer(this->members_.m_finish.m_cur)->~value_type(); + allocator_traits_type::destroy + ( this->alloc() + , container_detail::to_raw_pointer(this->members_.m_finish.m_cur) + ); } // Called only if this->members_.m_start.m_cur == this->members_.m_start.m_last - 1. Note that @@ -1836,7 +1853,10 @@ class deque : protected deque_base // must have at least two nodes. void priv_pop_front_aux() { - container_detail::to_raw_pointer(this->members_.m_start.m_cur)->~value_type(); + allocator_traits_type::destroy + ( this->alloc() + , container_detail::to_raw_pointer(this->members_.m_start.m_cur) + ); this->priv_deallocate_node(this->members_.m_start.m_first); this->members_.m_start.priv_set_node(this->members_.m_start.m_node + 1); this->members_.m_start.m_cur = this->members_.m_start.m_first; diff --git a/include/boost/container/detail/algorithms.hpp b/include/boost/container/detail/algorithms.hpp index f0e897c..a2713f5 100644 --- a/include/boost/container/detail/algorithms.hpp +++ b/include/boost/container/detail/algorithms.hpp @@ -50,130 +50,7 @@ inline void construct_in_place(A &a, T *dest, emplace_iterator ei) { ei.construct_in_place(a, dest); } -/* -template -struct optimize_assign -{ - static const bool value = false; -}; -template -struct optimize_assign -{ - static const bool value = boost::has_trivial_assign::value; -}; - -template -struct optimize_assign - : public optimize_assign -{}; - -template -struct optimize_copy -{ - static const bool value = false; -}; - -template -struct optimize_copy -{ - static const bool value = boost::has_trivial_copy::value; -}; - -template -struct optimize_copy - : public optimize_copy -{}; - -template inline -OutIt copy_n_dispatch(InIt first, typename std::iterator_traits::difference_type length, OutIt dest, container_detail::bool_) -{ - for (; length--; ++dest, ++first) - *dest = *first; - return dest; -} - -template inline -T *copy_n_dispatch(const T *first, typename std::iterator_traits::difference_type length, T *dest, container_detail::bool_) -{ - std::size_t size = length*sizeof(T); - return (static_cast(std::memmove(dest, first, size))) + size; -} - -template inline -OutIt copy_n(InIt first, typename std::iterator_traits::difference_type length, OutIt dest) -{ - const bool do_optimized_assign = optimize_assign::value; - return copy_n_dispatch(first, length, dest, container_detail::bool_()); -} - -template inline -FwdIt uninitialized_copy_n_dispatch - (InIt first, - typename std::iterator_traits::difference_type count, - FwdIt dest, container_detail::bool_) -{ - typedef typename std::iterator_traits::value_type value_type; - //Save initial destination position - FwdIt dest_init = dest; - typename std::iterator_traits::difference_type new_count = count+1; - - BOOST_TRY{ - //Try to build objects - for (; --new_count; ++dest, ++first){ - construct_in_place(container_detail::to_raw_pointer(&*dest), first); - } - } - BOOST_CATCH(...){ - //Call destructors - new_count = count - new_count; - for (; new_count--; ++dest_init){ - container_detail::to_raw_pointer(&*dest_init)->~value_type(); - } - BOOST_RETHROW - } - BOOST_CATCH_END - return dest; -} -template inline -T *uninitialized_copy_n_dispatch(const T *first, typename std::iterator_traits::difference_type length, T *dest, container_detail::bool_) -{ - std::size_t size = length*sizeof(T); - return (static_cast(std::memmove(dest, first, size))) + size; -} - -template inline -FwdIt uninitialized_copy_n - (InIt first, - typename std::iterator_traits::difference_type count, - FwdIt dest) -{ - const bool do_optimized_copy = optimize_copy::value; - return uninitialized_copy_n_dispatch(first, count, dest, container_detail::bool_()); -} - -// uninitialized_copy_copy -// Copies [first1, last1) into [result, result + (last1 - first1)), and -// copies [first2, last2) into -// [result + (last1 - first1), result + (last1 - first1) + (last2 - first2)). -template -FwdIt uninitialized_copy_copy - (InpIt1 first1, InpIt1 last1, InpIt2 first2, InpIt2 last2, FwdIt result) -{ - typedef typename std::iterator_traits::value_type value_type; - FwdIt mid = std::uninitialized_copy(first1, last1, result); - BOOST_TRY { - return std::uninitialized_copy(first2, last2, mid); - } - BOOST_CATCH(...){ - for(;result != mid; ++result){ - container_detail::to_raw_pointer(&*result)->~value_type(); - } - BOOST_RETHROW - } - BOOST_CATCH_END -} -*/ } //namespace container { } //namespace boost { diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp index 8c3287a..a871cee 100644 --- a/include/boost/container/stable_vector.hpp +++ b/include/boost/container/stable_vector.hpp @@ -446,7 +446,7 @@ class stable_vector template node_type_ptr_t allocate_one(AllocatorVersion, typename boost::container::container_detail::enable_if_c - + ::value>::type * = 0) { return node_alloc().allocate_one(); } @@ -463,7 +463,7 @@ class stable_vector template void deallocate_one(node_type_ptr_t p, AllocatorVersion, typename boost::container::container_detail::enable_if_c - + ::value>::type * = 0) { node_alloc().deallocate_one(p); } @@ -1316,7 +1316,7 @@ class stable_vector template void clear_pool(AllocatorVersion, typename boost::container::container_detail::enable_if_c - + ::value>::type * = 0) { if(!impl.empty() && impl.back()){ @@ -1355,7 +1355,7 @@ class stable_vector template void add_to_pool(size_type n, AllocatorVersion, typename boost::container::container_detail::enable_if_c - + ::value>::type * = 0) { void_ptr &pool_first_ref = impl.end()[-2]; @@ -1473,7 +1473,7 @@ class stable_vector template iterator priv_erase(const_iterator first, const_iterator last, AllocatorVersion, typename boost::container::container_detail::enable_if_c - + ::value>::type * = 0) { STABLE_VECTOR_CHECK_INVARIANT; @@ -1542,7 +1542,8 @@ class stable_vector void delete_node(const void_ptr &p) { node_type_ptr_t n(node_ptr_cast(p)); - n->~node_type_t(); + allocator_traits:: + destroy(this->node_alloc(), container_detail::to_raw_pointer(n)); this->put_in_pool(n); } diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp index feb62cf..a81d930 100644 --- a/include/boost/container/string.hpp +++ b/include/boost/container/string.hpp @@ -127,7 +127,10 @@ class basic_string_base { if(!this->is_short()){ this->deallocate_block(); - static_cast(static_cast(&this->members_.m_repr.r))->~long_t(); + allocator_traits_type::destroy + ( this->alloc() + , static_cast(static_cast(&this->members_.m_repr.r)) + ); } } @@ -240,10 +243,16 @@ class basic_string_base void is_short(bool yes) { if(yes && !this->is_short()){ - static_cast(static_cast(&this->members_.m_repr.r))->~long_t(); + allocator_traits_type::destroy + ( this->alloc() + , static_cast(static_cast(&this->members_.m_repr.r)) + ); } else{ - new(static_cast(&this->members_.m_repr.r))long_t(); + allocator_traits_type::construct + ( this->alloc() + , static_cast(static_cast(&this->members_.m_repr.r)) + ); } this->members_.m_repr.s.h.is_short = yes; } @@ -314,16 +323,31 @@ class basic_string_base } void construct(pointer p, const value_type &value = value_type()) - { new((void*)container_detail::to_raw_pointer(p)) value_type(value); } + { + allocator_traits_type::construct + ( this->alloc() + , container_detail::to_raw_pointer(p) + , value + ); + } void destroy(pointer p, size_type n) { - for(; n--; ++p) - container_detail::to_raw_pointer(p)->~value_type(); + for(; n--; ++p){ + allocator_traits_type::destroy + ( this->alloc() + , container_detail::to_raw_pointer(p) + ); + } } void destroy(pointer p) - { container_detail::to_raw_pointer(p)->~value_type(); } + { + allocator_traits_type::destroy + ( this->alloc() + , container_detail::to_raw_pointer(p) + ); + } void allocate_initial_block(size_type n) { diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp index 01483f9..186bee5 100644 --- a/include/boost/container/vector.hpp +++ b/include/boost/container/vector.hpp @@ -1328,7 +1328,7 @@ class vector : private container_detail::vector_alloc_holder template void priv_shrink_to_fit(AllocVersion , typename container_detail::enable_if_c< - container_detail::is_same::value >::type * = 0) + !container_detail::is_same::value >::type * = 0) { if(this->members_.m_capacity){ if(!size()){ From adde6aa9efbdfcd0b1c00cf32946bb4837148f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Mon, 2 Jan 2012 21:53:53 +0000 Subject: [PATCH 05/93] Fixed bug #6347 (extra ';' error) [SVN r76282] --- .../boost/container/allocator/memory_util.hpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/boost/container/allocator/memory_util.hpp b/include/boost/container/allocator/memory_util.hpp index f9cc70a..ea4bc05 100644 --- a/include/boost/container/allocator/memory_util.hpp +++ b/include/boost/container/allocator/memory_util.hpp @@ -56,17 +56,17 @@ namespace container { namespace container_detail { -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(pointer); -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_pointer); -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reference); -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_reference); -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(void_pointer); -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_void_pointer); -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(size_type); -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_copy_assignment); -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_move_assignment); -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_swap); -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type); +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(pointer) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_pointer) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reference) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_reference) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(void_pointer) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_void_pointer) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(size_type) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_copy_assignment) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_move_assignment) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_swap) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type) } //namespace container_detail { } //namespace container { From f3966354389dca87a89ad7b3a28a9a02571904ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Wed, 18 Jan 2012 20:48:49 +0000 Subject: [PATCH 06/93] Added fixed bugs to changeset in container/interprocess/intrusive/move [SVN r76578] --- doc/container.qbk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/container.qbk b/doc/container.qbk index 9038c53..b4b98cb 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -588,11 +588,11 @@ use [*Boost.Container]? There are several reasons for that: [section:release_notes_boost_1_49_00 Boost 1.49 Release] * Fixed bugs - [@https://svn.boost.org/trac/boost/ticket/6205 #6205], - [@https://svn.boost.org/trac/boost/ticket/6287 #6287], - [@https://svn.boost.org/trac/boost/ticket/4383 #4383], [@https://svn.boost.org/trac/boost/ticket/6336 #6336], - [@https://svn.boost.org/trac/boost/ticket/6335 #6335]. + [@https://svn.boost.org/trac/boost/ticket/6335 #6335], + [@https://svn.boost.org/trac/boost/ticket/6287 #6287], + [@https://svn.boost.org/trac/boost/ticket/6205 #6205], + [@https://svn.boost.org/trac/boost/ticket/4383 #4383]. * Added `allocator_traits` support for both C++11 and C++03 compilers through an internal `allocator_traits` clone. From deae817e987fe2752d179c84611295cecdcaaa32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Wed, 1 Feb 2012 22:12:10 +0000 Subject: [PATCH 07/93] Documentation fix. Ticket 6499 [SVN r76829] --- include/boost/container/deque.hpp | 8 ++++---- include/boost/container/stable_vector.hpp | 10 +++++----- include/boost/container/string.hpp | 8 ++++---- include/boost/container/vector.hpp | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/boost/container/deque.hpp b/include/boost/container/deque.hpp index 79d03f9..9ee0ee1 100644 --- a/include/boost/container/deque.hpp +++ b/include/boost/container/deque.hpp @@ -715,7 +715,7 @@ class deque : protected deque_base const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT { return const_reverse_iterator(this->members_.m_start); } - //! Requires: size() < n. + //! Requires: size() > n. //! //! Effects: Returns a reference to the nth element //! from the beginning of the container. @@ -726,7 +726,7 @@ class deque : protected deque_base reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT { return this->members_.m_start[difference_type(n)]; } - //! Requires: size() < n. + //! Requires: size() > n. //! //! Effects: Returns a const reference to the nth element //! from the beginning of the container. @@ -737,7 +737,7 @@ class deque : protected deque_base const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT { return this->members_.m_start[difference_type(n)]; } - //! Requires: size() < n. + //! Requires: size() > n. //! //! Effects: Returns a reference to the nth element //! from the beginning of the container. @@ -748,7 +748,7 @@ class deque : protected deque_base reference at(size_type n) { this->priv_range_check(n); return (*this)[n]; } - //! Requires: size() < n. + //! Requires: size() > n. //! //! Effects: Returns a const reference to the nth element //! from the beginning of the container. diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp index a871cee..851b5f2 100644 --- a/include/boost/container/stable_vector.hpp +++ b/include/boost/container/stable_vector.hpp @@ -927,7 +927,7 @@ class stable_vector } } - //! Requires: size() < n. + //! Requires: size() > n. //! //! Effects: Returns a reference to the nth element //! from the beginning of the container. @@ -937,7 +937,7 @@ class stable_vector //! Complexity: Constant. reference operator[](size_type n){return value(impl[n]);} - //! Requires: size() < n. + //! Requires: size() > n. //! //! Effects: Returns a const reference to the nth element //! from the beginning of the container. @@ -947,7 +947,7 @@ class stable_vector //! Complexity: Constant. const_reference operator[](size_type n)const{return value(impl[n]);} - //! Requires: size() < n. + //! Requires: size() > n. //! //! Effects: Returns a reference to the nth element //! from the beginning of the container. @@ -962,12 +962,12 @@ class stable_vector return operator[](n); } - //! Requires: size() < n. + //! Requires: size() > n. //! //! Effects: Returns a const reference to the nth element //! from the beginning of the container. //! - //! Throws: Nothing. + //! Throws: std::range_error if n >= size() //! //! Complexity: Constant. const_reference at(size_type n)const diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp index a81d930..533735a 100644 --- a/include/boost/container/string.hpp +++ b/include/boost/container/string.hpp @@ -1021,7 +1021,7 @@ class basic_string bool empty() const { return !this->priv_size(); } - //! Requires: size() < n. + //! Requires: size() > n. //! //! Effects: Returns a reference to the nth element //! from the beginning of the container. @@ -1032,7 +1032,7 @@ class basic_string reference operator[](size_type n) { return *(this->priv_addr() + n); } - //! Requires: size() < n. + //! Requires: size() > n. //! //! Effects: Returns a const reference to the nth element //! from the beginning of the container. @@ -1043,7 +1043,7 @@ class basic_string const_reference operator[](size_type n) const { return *(this->priv_addr() + n); } - //! Requires: size() < n. + //! Requires: size() > n. //! //! Effects: Returns a reference to the nth element //! from the beginning of the container. @@ -1057,7 +1057,7 @@ class basic_string return *(this->priv_addr() + n); } - //! Requires: size() < n. + //! Requires: size() > n. //! //! Effects: Returns a const reference to the nth element //! from the beginning of the container. diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp index 186bee5..742d00d 100644 --- a/include/boost/container/vector.hpp +++ b/include/boost/container/vector.hpp @@ -758,7 +758,7 @@ class vector : private container_detail::vector_alloc_holder bool empty() const BOOST_CONTAINER_NOEXCEPT { return !this->members_.m_size; } - //! Requires: size() < n. + //! Requires: size() > n. //! //! Effects: Returns a reference to the nth element //! from the beginning of the container. @@ -769,7 +769,7 @@ class vector : private container_detail::vector_alloc_holder reference operator[](size_type n) { return this->members_.m_start[n]; } - //! Requires: size() < n. + //! Requires: size() > n. //! //! Effects: Returns a const reference to the nth element //! from the beginning of the container. @@ -780,7 +780,7 @@ class vector : private container_detail::vector_alloc_holder const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT { return this->members_.m_start[n]; } - //! Requires: size() < n. + //! Requires: size() > n. //! //! Effects: Returns a reference to the nth element //! from the beginning of the container. @@ -791,7 +791,7 @@ class vector : private container_detail::vector_alloc_holder reference at(size_type n) { this->priv_check_range(n); return this->members_.m_start[n]; } - //! Requires: size() < n. + //! Requires: size() > n. //! //! Effects: Returns a const reference to the nth element //! from the beginning of the container. From 5a62b6e47e514a9b2b6c282f90243135a4d71ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Wed, 1 Feb 2012 22:12:43 +0000 Subject: [PATCH 08/93] Documentation fix. Ticket 6499 [SVN r76830] --- doc/container.qbk | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/container.qbk b/doc/container.qbk index b4b98cb..644718e 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -588,6 +588,7 @@ use [*Boost.Container]? There are several reasons for that: [section:release_notes_boost_1_49_00 Boost 1.49 Release] * Fixed bugs + [@https://svn.boost.org/trac/boost/ticket/6499 #6499], [@https://svn.boost.org/trac/boost/ticket/6336 #6336], [@https://svn.boost.org/trac/boost/ticket/6335 #6335], [@https://svn.boost.org/trac/boost/ticket/6287 #6287], From 852d1b9cb2a4756bce947bb8e33c5ad864c463f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 11 Feb 2012 18:36:23 +0000 Subject: [PATCH 09/93] Ticket #6540: Erroneous default argument in basic_string::compare overload [SVN r76985] --- doc/container.qbk | 1 + include/boost/container/string.hpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/container.qbk b/doc/container.qbk index 644718e..13d34ac 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -588,6 +588,7 @@ use [*Boost.Container]? There are several reasons for that: [section:release_notes_boost_1_49_00 Boost 1.49 Release] * Fixed bugs + [@https://svn.boost.org/trac/boost/ticket/6540 #6540], [@https://svn.boost.org/trac/boost/ticket/6499 #6499], [@https://svn.boost.org/trac/boost/ticket/6336 #6336], [@https://svn.boost.org/trac/boost/ticket/6335 #6335], diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp index 533735a..3a9c55a 100644 --- a/include/boost/container/string.hpp +++ b/include/boost/container/string.hpp @@ -2045,7 +2045,7 @@ class basic_string //! //! Returns: basic_string(*this, pos, n1).compare(basic_string(s, n2)). int compare(size_type pos1, size_type n1, - const CharT* s, size_type n2 = npos) const + const CharT* s, size_type n2) const { if (pos1 > size()) this->throw_out_of_range(); From 4012070a1a803b5662862c8ab087c3b14ea0870c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Thu, 22 Mar 2012 18:46:18 +0000 Subject: [PATCH 10/93] Experimental scoped_allocator support [SVN r77479] --- include/boost/container/allocator_traits.hpp | 385 +++++ .../boost/container/detail/memory_util.hpp | 77 + include/boost/container/scoped_allocator.hpp | 1452 +++++++++++++++++ 3 files changed, 1914 insertions(+) create mode 100644 include/boost/container/allocator_traits.hpp create mode 100644 include/boost/container/detail/memory_util.hpp create mode 100644 include/boost/container/scoped_allocator.hpp diff --git a/include/boost/container/allocator_traits.hpp b/include/boost/container/allocator_traits.hpp new file mode 100644 index 0000000..b4b3b01 --- /dev/null +++ b/include/boost/container/allocator_traits.hpp @@ -0,0 +1,385 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Pablo Halpern 2009. 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) +// +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2011-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) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP +#define BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include //numeric_limits<>::max() +#include //placement new +#include //std::allocator +#include + +///@cond + +namespace boost { +namespace container { +namespace container_detail { + +//workaround needed for C++03 compilers with no construct() +//supporting rvalue references +template +struct is_std_allocator +{ static const bool value = false; }; + +template +struct is_std_allocator< std::allocator > +{ static const bool value = true; }; + +} //namespace container_detail { + +///@endcond + +//! The class template allocator_traits supplies a uniform interface to all allocator types. +//! This class is a C++03-compatible implementation of std::allocator_traits +template +struct allocator_traits +{ + //allocator_type + typedef Alloc allocator_type; + //value_type + typedef typename Alloc::value_type value_type; + + #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + //! Alloc::pointer if such a type exists; otherwise, value_type* + //! + typedef unspecified pointer; + //! Alloc::const_pointer if such a type exists ; otherwise, pointer_traits::rebind::rebind. + //! + typedef unspecified void_pointer; + //! Alloc::const_void_pointer if such a type exists ; otherwis e, pointer_traits::rebind::difference_type. + //! + typedef unspecified difference_type; + //! Alloc::size_type if such a type exists ; otherwise, make_unsigned::type + //! + typedef unspecified size_type; + //! Alloc::propagate_on_container_copy_assignment if such a type exists, otherwise an integral_constant + //! type with internal constant static member `value` == false. + typedef unspecified propagate_on_container_copy_assignment; + //! Alloc::propagate_on_container_move_assignment if such a type exists, otherwise an integral_constant + //! type with internal constant static member `value` == false. + typedef unspecified propagate_on_container_move_assignment; + //! Alloc::propagate_on_container_swap if such a type exists, otherwise an integral_constant + //! type with internal constant static member `value` == false. + typedef unspecified propagate_on_container_swap; + //! Defines an allocator: Alloc::rebind::other if such a type exists; otherwise, Alloc + //! if Alloc is a class template instantiation of the form Alloc, where Args is zero or + //! more type arguments ; otherwise, the instantiation of rebind_alloc is ill-formed. + //! + //! In C++03 compilers `rebind_alloc` is a struct derived from an allocator + //! deduced by previously detailed rules. + template using rebind_alloc = unspecified; + + //! In C++03 compilers `rebind_traits` is a struct derived from + //! `allocator_traits`, where `OtherAlloc` is + //! the allocator deduced by rules explained in `rebind_alloc`. + template using rebind_traits = allocator_traits >; + + //! Non-standard extension: Portable allocator rebind for C++03 and C++11 compilers. + //! `type` is an allocator related to Alloc deduced deduced by rules explained in `rebind_alloc`. + template + struct portable_rebind_alloc + { typedef unspecified_type type; }; + #else + //pointer + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + pointer, value_type*) + pointer; + //const_pointer + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc, + const_pointer, typename boost::intrusive::pointer_traits::template + rebind_pointer) + const_pointer; + //reference + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + reference, typename container_detail::unvoid::type&) + reference; + //const_reference + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + const_reference, const typename container_detail::unvoid::type&) + const_reference; + //void_pointer + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc, + void_pointer, typename boost::intrusive::pointer_traits::template + rebind_pointer) + void_pointer; + //const_void_pointer + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc, + const_void_pointer, typename boost::intrusive::pointer_traits::template + rebind_pointer) + const_void_pointer; + //difference_type + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + difference_type, std::ptrdiff_t) + difference_type; + //size_type + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + size_type, std::size_t) + size_type; + //propagate_on_container_copy_assignment + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + propagate_on_container_copy_assignment, boost::false_type) + propagate_on_container_copy_assignment; + //propagate_on_container_move_assignment + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + propagate_on_container_move_assignment, boost::false_type) + propagate_on_container_move_assignment; + //propagate_on_container_swap + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + propagate_on_container_swap, boost::false_type) + propagate_on_container_swap; + + #if !defined(BOOST_NO_TEMPLATE_ALIASES) + //C++11 + template using rebind_alloc = boost::intrusive::detail::type_rebinder::type; + template using rebind_traits = allocator_traits< rebind_alloc >; + #else // #if !defined(BOOST_NO_TEMPLATE_ALIASES) + //Some workaround for C++03 or C++11 compilers with no template aliases + template + struct rebind_alloc : boost::intrusive::detail::type_rebinder::type + { + typedef typename boost::intrusive::detail::type_rebinder::type Base; + #if !defined(BOOST_NO_VARIADIC_TEMPLATES) + template + rebind_alloc(BOOST_FWD_REF(Args)... args) + : Base(boost::forward(args)...) + {} + #else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) + #define BOOST_PP_LOCAL_MACRO(n) \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + rebind_alloc(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + : Base(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)) \ + {} \ + // + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + #endif // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) + }; + + template + struct rebind_traits + : allocator_traits::type> + {}; + #endif // #if !defined(BOOST_NO_TEMPLATE_ALIASES) + template + struct portable_rebind_alloc + { typedef typename boost::intrusive::detail::type_rebinder::type type; }; + #endif //BOOST_CONTAINER_DOXYGEN_INVOKED + + //! Returns: `a.allocate(n)` + //! + static pointer allocate(Alloc &a, size_type n) + { return a.allocate(n); } + + //! Returns: `a.deallocate(p, n)` + //! + //! Throws: Nothing + static void deallocate(Alloc &a, pointer p, size_type n) + { return a.deallocate(p, n); } + + //! Effects: calls `a.construct(p, std::forward(args)...)` if that call is well-formed; + //! otherwise, invokes `::new (static_cast(p)) T(std::forward(args)...)` + static pointer allocate(Alloc &a, size_type n, const_void_pointer p) + { + const bool value = boost::container::container_detail:: + has_member_function_callable_with_allocate + ::value; + ::boost::integral_constant flag; + return allocator_traits::priv_allocate(flag, a, n, p); + } + + //! Effects: calls `a.destroy(p)` if that call is well-formed; + //! otherwise, invokes `p->~T()`. + template + static void destroy(Alloc &a, T*p) + { + typedef T* destroy_pointer; + const bool value = boost::container::container_detail:: + has_member_function_callable_with_destroy + ::value; + ::boost::integral_constant flag; + allocator_traits::priv_destroy(flag, a, p); + } + + //! Returns: `a.max_size()` if that expression is well-formed; otherwise, + //! `numeric_limits::max()`. + static size_type max_size(const Alloc &a) + { + const bool value = boost::container::container_detail:: + has_member_function_callable_with_max_size + ::value; + ::boost::integral_constant flag; + return allocator_traits::priv_max_size(flag, a); + } + + //! Returns: `a.select_on_container_copy_construction()` if that expression is well-formed; + //! otherwise, a. + static Alloc select_on_container_copy_construction(const Alloc &a) + { + const bool value = boost::container::container_detail:: + has_member_function_callable_with_select_on_container_copy_construction + ::value; + ::boost::integral_constant flag; + return allocator_traits::priv_select_on_container_copy_construction(flag, a); + } + + #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + //! Effects: calls `a.construct(p, std::forward(args)...)` if that call is well-formed; + //! otherwise, invokes `::new (static_cast(p)) T(std::forward(args)...)` + template + static void construct(Alloc & a, T* p, BOOST_FWD_REF(Args)... args) + { + ::boost::integral_constant::value> flag; + allocator_traits::priv_construct(flag, a, p, ::boost::forward(args)...); + } + #endif + ///@cond + #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + private: + static pointer priv_allocate(boost::true_type, Alloc &a, size_type n, const_void_pointer p) + { return a.allocate(n, p); } + + static pointer priv_allocate(boost::false_type, Alloc &a, size_type n, const_void_pointer) + { return allocator_traits::allocate(a, n); } + + template + static void priv_destroy(boost::true_type, Alloc &a, T* p) + { a.destroy(p); } + + template + static void priv_destroy(boost::false_type, Alloc &, T* p) + { p->~T(); (void)p; } + + static size_type priv_max_size(boost::true_type, const Alloc &a) + { return a.max_size(); } + + static size_type priv_max_size(boost::false_type, const Alloc &) + { return (std::numeric_limits::max)(); } + + static Alloc priv_select_on_container_copy_construction(boost::true_type, const Alloc &a) + { return a.select_on_container_copy_construction(); } + + static Alloc priv_select_on_container_copy_construction(boost::false_type, const Alloc &a) + { return a; } + + #if !defined(BOOST_NO_VARIADIC_TEMPLATES) + template + static void priv_construct(boost::false_type, Alloc &a, T *p, BOOST_FWD_REF(Args) ...args) + { + const bool value = boost::container::container_detail:: + has_member_function_callable_with_construct + < Alloc, T*, Args... >::value; + ::boost::integral_constant flag; + priv_construct_dispatch2(flag, a, p, ::boost::forward(args)...); + } + + template + static void priv_construct(boost::true_type, Alloc &a, T *p, BOOST_FWD_REF(Args) ...args) + { + priv_construct_dispatch2(boost::false_type(), a, p, ::boost::forward(args)...); + } + + template + static void priv_construct_dispatch2(boost::true_type, Alloc &a, T *p, BOOST_FWD_REF(Args) ...args) + { a.construct( p, ::boost::forward(args)...); } + + template + static void priv_construct_dispatch2(boost::false_type, Alloc &, T *p, BOOST_FWD_REF(Args) ...args) + { ::new((void*)p) T(::boost::forward(args)...); } + #else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) + public: + #define BOOST_PP_LOCAL_MACRO(n) \ + template \ + static void construct(Alloc &a, T *p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + ::boost::integral_constant::value> flag; \ + allocator_traits::priv_construct(flag, a, 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() + + private: + #define BOOST_PP_LOCAL_MACRO(n) \ + template \ + static void priv_construct(boost::false_type, Alloc &a, T *p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST,_)) \ + { \ + const bool value = \ + boost::container::container_detail::has_member_function_callable_with_construct \ + < Alloc, T* BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_FWD_TYPE, _) >::value; \ + ::boost::integral_constant flag; \ + priv_construct_dispatch2(flag, a, p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ + } \ + \ + template \ + static void priv_construct(boost::true_type, Alloc &a, T *p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST,_)) \ + { \ + priv_construct_dispatch2(boost::false_type(), a, p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ + } \ + \ + template \ + static void priv_construct_dispatch2(boost::true_type, Alloc &a, T *p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST,_)) \ + { a.construct( p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); } \ + \ + template \ + static void priv_construct_dispatch2(boost::false_type, Alloc &, T *p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _) ) \ + { ::new((void*)p) T(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + // + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + #endif // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) + #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + + ///@endcond +}; + +} //namespace container { +} //namespace boost { + +#include + +#endif // ! defined(BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP) diff --git a/include/boost/container/detail/memory_util.hpp b/include/boost/container/detail/memory_util.hpp new file mode 100644 index 0000000..c00172c --- /dev/null +++ b/include/boost/container/detail/memory_util.hpp @@ -0,0 +1,77 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2011-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) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_CONTAINER_ALLOCATOR_MEMORY_UTIL_HPP +#define BOOST_CONTAINER_ALLOCATOR_MEMORY_UTIL_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include +#include +#include +#include + + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME allocate +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 2, )) +#include BOOST_PP_ITERATE() + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME destroy +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 3, )) +#include BOOST_PP_ITERATE() + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME max_size +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 0, )) +#include BOOST_PP_ITERATE() + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME select_on_container_copy_construction +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 0, )) +#include BOOST_PP_ITERATE() + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME construct +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS+1, )) +#include BOOST_PP_ITERATE() + +namespace boost { +namespace container { +namespace container_detail { + + +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(pointer) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_pointer) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reference) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_reference) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(void_pointer) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_void_pointer) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(size_type) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_copy_assignment) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_move_assignment) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_swap) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type) + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#include + +#endif // ! defined(BOOST_CONTAINER_ALLOCATOR_MEMORY_UTIL_HPP) diff --git a/include/boost/container/scoped_allocator.hpp b/include/boost/container/scoped_allocator.hpp new file mode 100644 index 0000000..88bbeb0 --- /dev/null +++ b/include/boost/container/scoped_allocator.hpp @@ -0,0 +1,1452 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Pablo Halpern 2009. 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) +// +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2011-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) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_HPP +#define BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_HPP + +#if (defined MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(BOOST_NO_VARIADIC_TEMPLATES) +#include +#endif + +namespace boost { namespace container { + +#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) + +#if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST) + +template +class scoped_allocator_adaptor; + +#else // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST) + +template +class scoped_allocator_adaptor; + +template +class scoped_allocator_adaptor; + +#endif // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST) + + +#else // #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + +template +class scoped_allocator_adaptor; + +#endif + +//! The allocator_arg_t struct is an empty structure type used as a unique type to +//! disambiguate constructor and function overloading. Specifically, several types +//! have constructors with allocator_arg_t as the first argument, immediately followed +//! by an argument of a type that satisfies the Allocator requirements +struct allocator_arg_t{}; + +static const allocator_arg_t allocator_arg = allocator_arg_t(); + +//! Remark: Automatically detects if T has a nested allocator_type that is convertible from +//! Alloc. Meets the BinaryTypeTrait requirements ([meta.rqmts] 20.4.1). A program may +//! specialize this type to derive from true_type for a T of user-defined type if T does not +//! have a nested allocator_type but is nonetheless constructible using the specified Alloc. +//! +//! Result: derived from true_type if Convertible and +//! derived from false_type otherwise. +template +struct uses_allocator; + +//! Remark: if a specialization is derived from true_type, indicates that T may be constructed +//! with an allocator as its last constructor argument. Ideally, all constructors of T (including the +//! copy and move constructors) should have a variant that accepts a final argument of +//! allocator_type. +//! +//! Requires: if a specialization is derived from true_type, T must have a nested type, +//! allocator_type and at least one constructor for which allocator_type is the last +//! parameter. If not all constructors of T can be called with a final allocator_type argument, +//! and if T is used in a context where a container must call such a constructor, then the program is +//! ill-formed. +//! +//! [Example: +//! template > +//! class Z { +//! public: +//! typedef A allocator_type; +//! +//! // Default constructor with optional allocator suffix +//! Z(const allocator_type& a = allocator_type()); +//! +//! // Copy constructor and allocator-extended copy constructor +//! Z(const Z& zz); +//! Z(const Z& zz, const allocator_type& a); +//! }; +//! +//! // Specialize trait for class template Z +//! template > +//! struct constructible_with_allocator_suffix > +//! : ::boost::true_type { }; +//! -- end example] +//! +//! Note: This trait is a workaround inspired by "N2554: The Scoped Allocator Model (Rev 2)" +//! (Pablo Halpern, 2008-02-29) to backport the scoped allocator model to C++03, as +//! in C++03 there is no mechanism to detect if a type can be constructed from arbitrary arguments. +//! Applications aiming portability with several compilers should always define this trait. +//! +//! In conforming C++11 compilers or compilers supporting SFINAE expressions +//! (when BOOST_NO_SFINAE_EXPR is NOT defined), this trait is ignored and C++11 rules will be used +//! to detect if a type should be constructed with suffix or prefix allocator arguments. +template +struct constructible_with_allocator_suffix + : ::boost::false_type +{}; + +//! Remark: if a specialization is derived from true_type, indicates that T may be constructed +//! with allocator_arg and T::allocator_type as its first two constructor arguments. +//! Ideally, all constructors of T (including the copy and move constructors) should have a variant +//! that accepts these two initial arguments. +//! +//! Requires: if a specialization is derived from true_type, T must have a nested type, +//! allocator_type and at least one constructor for which allocator_arg_t is the first +//! parameter and allocator_type is the second parameter. If not all constructors of T can be +//! called with these initial arguments, and if T is used in a context where a container must call such +//! a constructor, then the program is ill-formed. +//! +//! [Example: +//! template > +//! class Y { +//! public: +//! typedef A allocator_type; +//! +//! // Default constructor with and allocator-extended default constructor +//! Y(); +//! Y(allocator_arg_t, const allocator_type& a); +//! +//! // Copy constructor and allocator-extended copy constructor +//! Y(const Y& yy); +//! Y(allocator_arg_t, const allocator_type& a, const Y& yy); +//! +//! // Variadic constructor and allocator-extended variadic constructor +//! template Y(Args&& args...); +//! template +//! Y(allocator_arg_t, const allocator_type& a, Args&&... args); +//! }; +//! +//! // Specialize trait for class template Y +//! template > +//! struct constructible_with_allocator_prefix > +//! : ::boost::true_type { }; +//! +//! -- end example] +//! +//! Note: This trait is a workaround inspired by "N2554: The Scoped Allocator Model (Rev 2)" +//! (Pablo Halpern, 2008-02-29) to backport the scoped allocator model to C++03, as +//! in C++03 there is no mechanism to detect if a type can be constructed from arbitrary arguments. +//! Applications aiming portability with several compilers should always define this trait. +//! +//! In conforming C++11 compilers or compilers supporting SFINAE expressions +//! (when BOOST_NO_SFINAE_EXPR is NOT defined), this trait is ignored and C++11 rules will be used +//! to detect if a type should be constructed with suffix or prefix allocator arguments. +template +struct constructible_with_allocator_prefix + : ::boost::false_type +{}; + +///@cond + +namespace container_detail { + +template +struct uses_allocator_imp +{ + // Use SFINAE (Substitution Failure Is Not An Error) to detect the + // presence of an 'allocator_type' nested type convertilble from Alloc. + + private: + // Match this function if TypeT::allocator_type exists and is + // implicitly convertible from Alloc + template + static char test(int, typename U::allocator_type); + + // Match this function if TypeT::allocator_type does not exist or is + // not convertible from Alloc. + template + static int test(LowPriorityConversion, LowPriorityConversion); + + static Alloc alloc; // Declared but not defined + + public: + enum { value = sizeof(test(0, alloc)) == sizeof(char) }; +}; + +} //namespace container_detail { + +template +struct uses_allocator + : boost::integral_constant::value> +{}; + +namespace container_detail { + +template +struct is_scoped_allocator_imp +{ + template + static char test(int, typename T::outer_allocator_type*); + + template + static int test(LowPriorityConversion, void*); + + static const bool value = (sizeof(char) == sizeof(test(0, 0))); +}; + +template::value > +struct outermost_allocator_type_impl +{ + typedef typename MaybeScopedAlloc::outer_allocator_type outer_type; + typedef typename outermost_allocator_type_impl::type type; +}; + +template +struct outermost_allocator_type_impl +{ + typedef MaybeScopedAlloc type; +}; + +template::value > +struct outermost_allocator_imp +{ + typedef MaybeScopedAlloc type; + + static type &get(MaybeScopedAlloc &a) + { return a; } + + static const type &get(const MaybeScopedAlloc &a) + { return a; } +}; + +template +struct outermost_allocator_imp +{ + typedef typename MaybeScopedAlloc::outer_allocator_type outer_type; + typedef typename outermost_allocator_type_impl::type type; + + static type &get(MaybeScopedAlloc &a) + { return outermost_allocator_imp::get(a.outer_allocator()); } + + static const type &get(const MaybeScopedAlloc &a) + { return outermost_allocator_imp::get(a.outer_allocator()); } +}; + +} //namespace container_detail { + +template +struct is_scoped_allocator + : boost::integral_constant::value> +{}; + +template +struct outermost_allocator + : container_detail::outermost_allocator_imp +{}; + +template +typename container_detail::outermost_allocator_imp::type & + get_outermost_allocator(Alloc &a) +{ return container_detail::outermost_allocator_imp::get(a); } + +template +const typename container_detail::outermost_allocator_imp::type & + get_outermost_allocator(const Alloc &a) +{ return container_detail::outermost_allocator_imp::get(a); } + +namespace container_detail { + +// Check if we can detect is_convertible using advanced SFINAE expressions +#if !defined(BOOST_NO_SFINAE_EXPR) + + #define BOOST_CONTAINER_IS_CONSTRUCTIBLE_AVAILABLE + + //! Code inspired by Mathias Gaunard's is_convertible.cpp found in the Boost mailing list + //! http://boost.2283326.n4.nabble.com/type-traits-is-constructible-when-decltype-is-supported-td3575452.html + //! Thanks Mathias! + + //With variadic templates, we need a single class to implement the trait + #if !defined(BOOST_NO_VARIADIC_TEMPLATES) + + template + struct is_constructible_impl + { + typedef char yes_type; + struct no_type + { char padding[2]; }; + + template + struct dummy; + + template + static yes_type test(dummy()...))>*); + + template + static no_type test(...); + + static const bool value = sizeof(test(0)) == sizeof(yes_type); + }; + + template + struct is_constructible + : boost::integral_constant::value> + {}; + + template + struct is_constructible_with_allocator_prefix + : is_constructible + {}; + + #else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) + + //Without variadic templates, we need to use de preprocessor to generate + //some specializations. + + #define BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS \ + BOOST_PP_ADD(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, 3) + //! + + //Generate N+1 template parameters so that we can specialize N + template + struct is_constructible_impl; + + //Generate N specializations, from 0 to + //BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS parameters + #define BOOST_PP_LOCAL_MACRO(n) \ + template \ + struct is_constructible_impl \ + \ + { \ + typedef char yes_type; \ + struct no_type \ + { char padding[2]; }; \ + \ + template \ + struct dummy; \ + \ + template \ + static yes_type test(dummy*); \ + \ + template \ + static no_type test(...); \ + \ + static const bool value = sizeof(test(0)) == sizeof(yes_type); \ + }; \ + //! + + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + + //Finally just inherit from the implementation to define he trait + template< class T + BOOST_PP_ENUM_TRAILING( BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS + , BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT + , void) + > + struct is_constructible + : boost::integral_constant + < bool + , is_constructible_impl + < T + BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS, P) + , void>::value + > + {}; + + //Finally just inherit from the implementation to define he trait + template + struct is_constructible_with_allocator_prefix + : is_constructible + < T, allocator_arg_t, InnerAlloc + BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS, 2), P) + > + {}; +/* + template + struct is_constructible_with_allocator_suffix + : is_constructible + < T + BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS, 1), P) + , InnerAlloc + > + {};*/ + + #endif // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) + +#else // #if !defined(BOOST_NO_SFINAE_EXPR) + + //Without advanced SFINAE expressions, we can't use is_constructible + //so backup to constructible_with_allocator_xxx + + #if !defined(BOOST_NO_VARIADIC_TEMPLATES) + + template < class T, class InnerAlloc, class ...Args> + struct is_constructible_with_allocator_prefix + : constructible_with_allocator_prefix + {}; +/* + template < class T, class InnerAlloc, class ...Args> + struct is_constructible_with_allocator_suffix + : constructible_with_allocator_suffix + {};*/ + + #else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) + + template < class T + , class InnerAlloc + BOOST_PP_ENUM_TRAILING( BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS + , BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT + , void) + > + struct is_constructible_with_allocator_prefix + : constructible_with_allocator_prefix + {}; +/* + template < class T + , class InnerAlloc + BOOST_PP_ENUM_TRAILING( BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS + , BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT + , void) + > + struct is_constructible_with_allocator_suffix + : constructible_with_allocator_suffix + {};*/ + + #endif // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) + +#endif // #if !defined(BOOST_NO_SFINAE_EXPR) + +#if !defined(BOOST_NO_VARIADIC_TEMPLATES) + +template < typename OutermostAlloc + , typename InnerAlloc + , typename T + , class ...Args + > +inline void dispatch_allocator_prefix_suffix + ( boost::true_type use_alloc_prefix, OutermostAlloc& outermost_alloc + , InnerAlloc& inner_alloc, T* p, BOOST_FWD_REF(Args) ...args) +{ + (void)use_alloc_prefix; + allocator_traits::construct + ( outermost_alloc, p, allocator_arg, inner_alloc, ::boost::forward(args)...); +} + +template < typename OutermostAlloc + , typename InnerAlloc + , typename T + , class ...Args + > +inline void dispatch_allocator_prefix_suffix + ( boost::false_type use_alloc_prefix, OutermostAlloc& outermost_alloc + , InnerAlloc &inner_alloc, T* p, BOOST_FWD_REF(Args)...args) +{ + (void)use_alloc_prefix; + allocator_traits::construct + (outermost_alloc, p, ::boost::forward(args)..., inner_alloc); +} + +template < typename OutermostAlloc + , typename InnerAlloc + , typename T + , class ...Args + > +inline void dispatch_uses_allocator + ( boost::true_type uses_allocator, OutermostAlloc& outermost_alloc + , InnerAlloc& inner_alloc, T* p, BOOST_FWD_REF(Args)...args) +{ + (void)uses_allocator; + //BOOST_STATIC_ASSERT((is_constructible_with_allocator_prefix::value || + // is_constructible_with_allocator_suffix::value )); + dispatch_allocator_prefix_suffix + ( is_constructible_with_allocator_prefix() + , outermost_alloc, inner_alloc, p, ::boost::forward(args)...); +} + +template < typename OutermostAlloc + , typename InnerAlloc + , typename T + , class ...Args + > +inline void dispatch_uses_allocator + ( boost::false_type uses_allocator, OutermostAlloc & outermost_alloc + , InnerAlloc & inner_alloc + ,T* p, BOOST_FWD_REF(Args)...args) +{ + (void)uses_allocator; (void)inner_alloc; + allocator_traits::construct + (outermost_alloc, p, ::boost::forward(args)...); +} + +#else //#if !defined(BOOST_NO_VARIADIC_TEMPLATES) + +#define BOOST_PP_LOCAL_MACRO(n) \ +template < typename OutermostAlloc \ + , typename InnerAlloc \ + , typename T \ + BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) \ + > \ +inline void dispatch_allocator_prefix_suffix( \ + boost::true_type use_alloc_prefix, \ + OutermostAlloc& outermost_alloc, \ + InnerAlloc& inner_alloc, \ + T* p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ +{ \ + (void)use_alloc_prefix, \ + allocator_traits::construct \ + (outermost_alloc, p, allocator_arg, inner_alloc \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ +} \ + \ +template < typename OutermostAlloc \ + , typename InnerAlloc \ + , typename T \ + BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) \ + > \ +inline void dispatch_allocator_prefix_suffix( \ + boost::false_type use_alloc_prefix, \ + OutermostAlloc& outermost_alloc, \ + InnerAlloc& inner_alloc, \ + T* p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ +{ \ + (void)use_alloc_prefix; \ + allocator_traits::construct \ + (outermost_alloc, p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) \ + , inner_alloc); \ +} \ + \ +template < typename OutermostAlloc \ + , typename InnerAlloc \ + , typename T \ + BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) \ + > \ +inline void dispatch_uses_allocator(boost::true_type uses_allocator, \ + OutermostAlloc& outermost_alloc, \ + InnerAlloc& inner_alloc, \ + T* p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ +{ \ + (void)uses_allocator; \ + dispatch_allocator_prefix_suffix \ + (is_constructible_with_allocator_prefix \ + < T, InnerAlloc BOOST_PP_ENUM_TRAILING_PARAMS(n, P)>() \ + , outermost_alloc, inner_alloc, p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ +} \ + \ +template < typename OutermostAlloc \ + , typename InnerAlloc \ + , typename T \ + BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) \ + > \ +inline void dispatch_uses_allocator(boost::false_type uses_allocator \ + ,OutermostAlloc & outermost_alloc \ + ,InnerAlloc & inner_alloc \ + ,T* p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ +{ \ + (void)uses_allocator; (void)inner_alloc; \ + allocator_traits::construct \ + (outermost_alloc, 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 //#if !defined(BOOST_NO_VARIADIC_TEMPLATES) + +#if !defined(BOOST_NO_VARIADIC_TEMPLATES) + +template +class scoped_allocator_adaptor_base + : public OuterAlloc +{ + typedef allocator_traits outer_traits_type; + BOOST_COPYABLE_AND_MOVABLE(scoped_allocator_adaptor_base) + + public: + template + struct rebind_base + { + typedef scoped_allocator_adaptor_base other; + }; + + typedef OuterAlloc outer_allocator_type; + typedef scoped_allocator_adaptor inner_allocator_type; + typedef boost::integral_constant< + bool, + outer_traits_type::propagate_on_container_copy_assignment::value || + inner_allocator_type::propagate_on_container_copy_assignment::value + > propagate_on_container_copy_assignment; + typedef boost::integral_constant< + bool, + outer_traits_type::propagate_on_container_move_assignment::value || + inner_allocator_type::propagate_on_container_move_assignment::value + > propagate_on_container_move_assignment; + typedef boost::integral_constant< + bool, + outer_traits_type::propagate_on_container_swap::value || + inner_allocator_type::propagate_on_container_swap::value + > propagate_on_container_swap; + + scoped_allocator_adaptor_base() + {} + + template + scoped_allocator_adaptor_base(BOOST_FWD_REF(OuterA2) outerAlloc, const InnerAllocs &...args) + : outer_allocator_type(::boost::forward(outerAlloc)) + , inner(args...) + {} + + scoped_allocator_adaptor_base(const scoped_allocator_adaptor_base& other) + : outer_allocator_type(other.outer_allocator()) + , inner(other.inner_allocator()) + {} + + scoped_allocator_adaptor_base(BOOST_RV_REF(scoped_allocator_adaptor_base) other) + : outer_allocator_type(::boost::move(other.outer_allocator())) + , inner(::boost::move(other.inner_allocator())) + {} + + template + scoped_allocator_adaptor_base + (const scoped_allocator_adaptor_base& other) + : outer_allocator_type(other.outer_allocator()) + , inner(other.inner_allocator()) + {} + + template + scoped_allocator_adaptor_base + (BOOST_RV_REF_BEG scoped_allocator_adaptor_base + BOOST_RV_REF_END other) + : outer_allocator_type(other.outer_allocator()) + , inner(other.inner_allocator()) + {} + + scoped_allocator_adaptor_base &operator= + (BOOST_COPY_ASSIGN_REF(scoped_allocator_adaptor_base) other) + { + outer_allocator_type::operator=(other.outer_allocator()); + inner = other.inner_allocator(); + return *this; + } + + scoped_allocator_adaptor_base &operator=(BOOST_RV_REF(scoped_allocator_adaptor_base) other) + { + outer_allocator_type::operator=(boost::move(other.outer_allocator())); + inner = ::boost::move(other.inner_allocator()); + return *this; + } + + inner_allocator_type& inner_allocator() + { return inner; } + + inner_allocator_type const& inner_allocator() const + { return inner; } + + outer_allocator_type & outer_allocator() + { return static_cast(*this); } + + const outer_allocator_type &outer_allocator() const + { return static_cast(*this); } + + private: + inner_allocator_type inner; +}; + +#else //#if !defined(BOOST_NO_VARIADIC_TEMPLATES) + +//Let's add a dummy first template parameter to allow creating +//specializations up to maximum InnerAlloc count +template < + typename OuterAlloc + , bool Dummy + BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, class Q) + > +class scoped_allocator_adaptor_base; + +//Specializations for the adaptor with InnerAlloc allocators + +#define BOOST_PP_LOCAL_MACRO(n) \ +template \ +class scoped_allocator_adaptor_base \ + : public OuterAlloc \ +{ \ + typedef allocator_traits outer_traits_type; \ + BOOST_COPYABLE_AND_MOVABLE(scoped_allocator_adaptor_base) \ + \ + public: \ + template \ + struct rebind_base \ + { \ + typedef scoped_allocator_adaptor_base other; \ + }; \ + \ + typedef OuterAlloc outer_allocator_type; \ + typedef scoped_allocator_adaptor inner_allocator_type; \ + typedef boost::integral_constant< \ + bool, \ + outer_traits_type::propagate_on_container_copy_assignment::value || \ + inner_allocator_type::propagate_on_container_copy_assignment::value \ + > propagate_on_container_copy_assignment; \ + typedef boost::integral_constant< \ + bool, \ + outer_traits_type::propagate_on_container_move_assignment::value || \ + inner_allocator_type::propagate_on_container_move_assignment::value \ + > propagate_on_container_move_assignment; \ + typedef boost::integral_constant< \ + bool, \ + outer_traits_type::propagate_on_container_swap::value || \ + inner_allocator_type::propagate_on_container_swap::value \ + > propagate_on_container_swap; \ + \ + scoped_allocator_adaptor_base() \ + {} \ + \ + template \ + scoped_allocator_adaptor_base(BOOST_FWD_REF(OuterA2) outerAlloc \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_CONST_REF_PARAM_LIST_Q, _)) \ + : outer_allocator_type(::boost::forward(outerAlloc)) \ + , inner(BOOST_PP_ENUM_PARAMS(n, q)) \ + {} \ + \ + scoped_allocator_adaptor_base(const scoped_allocator_adaptor_base& other) \ + : outer_allocator_type(other.outer_allocator()) \ + , inner(other.inner_allocator()) \ + {} \ + \ + scoped_allocator_adaptor_base(BOOST_RV_REF(scoped_allocator_adaptor_base) other) \ + : outer_allocator_type(::boost::move(other.outer_allocator())) \ + , inner(::boost::move(other.inner_allocator())) \ + {} \ + \ + template \ + scoped_allocator_adaptor_base(const scoped_allocator_adaptor_base& other) \ + : outer_allocator_type(other.outer_allocator()) \ + , inner(other.inner_allocator()) \ + {} \ + \ + template \ + scoped_allocator_adaptor_base \ + (BOOST_RV_REF_BEG scoped_allocator_adaptor_base BOOST_RV_REF_END other) \ + : outer_allocator_type(other.outer_allocator()) \ + , inner(other.inner_allocator()) \ + {} \ + \ + scoped_allocator_adaptor_base &operator= \ + (BOOST_COPY_ASSIGN_REF(scoped_allocator_adaptor_base) other) \ + { \ + outer_allocator_type::operator=(other.outer_allocator()); \ + inner = other.inner_allocator(); \ + return *this; \ + } \ + \ + scoped_allocator_adaptor_base &operator=(BOOST_RV_REF(scoped_allocator_adaptor_base) other) \ + { \ + outer_allocator_type::operator=(boost::move(other.outer_allocator())); \ + inner = ::boost::move(other.inner_allocator()); \ + return *this; \ + } \ + \ + inner_allocator_type& inner_allocator() \ + { return inner; } \ + \ + inner_allocator_type const& inner_allocator() const \ + { return inner; } \ + \ + outer_allocator_type & outer_allocator() \ + { return static_cast(*this); } \ + \ + const outer_allocator_type &outer_allocator() const \ + { return static_cast(*this); } \ + \ + private: \ + inner_allocator_type inner; \ +}; \ +//! +#define BOOST_PP_LOCAL_LIMITS (1, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) +#include BOOST_PP_LOCAL_ITERATE() + +#endif //#if !defined(BOOST_NO_VARIADIC_TEMPLATES) + +//Specialization for adaptor without any InnerAlloc +template +class scoped_allocator_adaptor_base + < OuterAlloc + #if defined(BOOST_NO_VARIADIC_TEMPLATES) + , true + BOOST_PP_ENUM_TRAILING(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, BOOST_CONTAINER_PP_IDENTITY, nat) + #endif + > + : public OuterAlloc +{ + BOOST_COPYABLE_AND_MOVABLE(scoped_allocator_adaptor_base) + public: + + template + struct rebind_base + { + typedef scoped_allocator_adaptor_base + ::template portable_rebind_alloc::type + #if defined(BOOST_NO_VARIADIC_TEMPLATES) + , true + BOOST_PP_ENUM_TRAILING(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, BOOST_CONTAINER_PP_IDENTITY, container_detail::nat) + #endif + > other; + }; + + typedef OuterAlloc outer_allocator_type; + typedef allocator_traits outer_traits_type; + typedef scoped_allocator_adaptor inner_allocator_type; + typedef typename outer_traits_type:: + propagate_on_container_copy_assignment propagate_on_container_copy_assignment; + typedef typename outer_traits_type:: + propagate_on_container_move_assignment propagate_on_container_move_assignment; + typedef typename outer_traits_type:: + propagate_on_container_swap propagate_on_container_swap; + + scoped_allocator_adaptor_base() + {} + + template + scoped_allocator_adaptor_base(BOOST_FWD_REF(OuterA2) outerAlloc) + : outer_allocator_type(::boost::forward(outerAlloc)) + {} + + scoped_allocator_adaptor_base(const scoped_allocator_adaptor_base& other) + : outer_allocator_type(other.outer_allocator()) + {} + + scoped_allocator_adaptor_base(BOOST_RV_REF(scoped_allocator_adaptor_base) other) + : outer_allocator_type(::boost::move(other.outer_allocator())) + {} + + template + scoped_allocator_adaptor_base + (const scoped_allocator_adaptor_base< + OuterA2 + #if defined(BOOST_NO_VARIADIC_TEMPLATES) + , true + BOOST_PP_ENUM_TRAILING(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, BOOST_CONTAINER_PP_IDENTITY, container_detail::nat) + #endif + >& other) + : outer_allocator_type(other.outer_allocator()) + {} + + template + scoped_allocator_adaptor_base + (BOOST_RV_REF_BEG scoped_allocator_adaptor_base< + OuterA2 + #if defined(BOOST_NO_VARIADIC_TEMPLATES) + , true + BOOST_PP_ENUM_TRAILING(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, BOOST_CONTAINER_PP_IDENTITY, container_detail::nat) + #endif + > BOOST_RV_REF_END other) + : outer_allocator_type(other.outer_allocator()) + {} + + scoped_allocator_adaptor_base &operator=(BOOST_COPY_ASSIGN_REF(scoped_allocator_adaptor_base) other) + { + outer_allocator_type::operator=(other.outer_allocator()); + return *this; + } + + scoped_allocator_adaptor_base &operator=(BOOST_RV_REF(scoped_allocator_adaptor_base) other) + { + outer_allocator_type::operator=(boost::move(other.outer_allocator())); + return *this; + } + + inner_allocator_type& inner_allocator() + { return static_cast(*this); } + + inner_allocator_type const& inner_allocator() const + { return static_cast(*this); } + + outer_allocator_type & outer_allocator() + { return static_cast(*this); } + + const outer_allocator_type &outer_allocator() const + { return static_cast(*this); } +}; + +} //namespace container_detail { + +///@endcond + +//Scoped allocator +#if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + + #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST) + + //! This class is a C++03-compatible implementation of std::scoped_allocator_adaptor. + //! The class template scoped_allocator_adaptor is an allocator template that specifies + //! the memory resource (the outer allocator) to be used by a container (as any other + //! allocator does) and also specifies an inner allocator resource to be passed to + //! the constructor of every element within the container. + //! + //! This adaptor is + //! instantiated with one outer and zero or more inner allocator types. If + //! instantiated with only one allocator type, the inner allocator becomes the + //! scoped_allocator_adaptor itself, thus using the same allocator resource for the + //! container and every element within the container and, if the elements themselves + //! are containers, each of their elements recursively. If instantiated with more than + //! one allocator, the first allocator is the outer allocator for use by the container, + //! the second allocator is passed to the constructors of the container's elements, + //! and, if the elements themselves are containers, the third allocator is passed to + //! the elements' elements, and so on. If containers are nested to a depth greater + //! than the number of allocators, the last allocator is used repeatedly, as in the + //! single-allocator case, for any remaining recursions. [Note: The + //! scoped_allocator_adaptor is derived from the outer allocator type so it can be + //! substituted for the outer allocator type in most expressions. -end note] + //! + //! In the construct member functions, `OUTERMOST(x)` is x if x does not have + //! an `outer_allocator()` member function and + //! `OUTERMOST(x.outer_allocator())` otherwise; `OUTERMOST_ALLOC_TRAITS(x)` is + //! `allocator_traits`. [Note: `OUTERMOST(x)` and + //! `OUTERMOST_ALLOC_TRAITS(x)` are recursive operations. It is incumbent upon + //! the definition of `outer_allocator()` to ensure that the recursion terminates. + //! It will terminate for all instantiations of scoped_allocator_adaptor. -end note] + template + class scoped_allocator_adaptor + + #else // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST) + + template + class scoped_allocator_adaptor + + #endif // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST) + +#else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + +template +class scoped_allocator_adaptor +#endif + : public container_detail::scoped_allocator_adaptor_base + +{ + BOOST_COPYABLE_AND_MOVABLE(scoped_allocator_adaptor) + + public: + /// @cond + typedef container_detail::scoped_allocator_adaptor_base + base_type; + /// @endcond + typedef OuterAlloc outer_allocator_type; + //! Type: For exposition only + //! + typedef allocator_traits outer_traits_type; + //! Type: `scoped_allocator_adaptor` if `sizeof...(InnerAllocs)` is zero; otherwise, + //! `scoped_allocator_adaptor`. + typedef typename base_type::inner_allocator_type inner_allocator_type; + typedef typename outer_traits_type::value_type value_type; + typedef typename outer_traits_type::size_type size_type; + typedef typename outer_traits_type::difference_type difference_type; + typedef typename outer_traits_type::pointer pointer; + typedef typename outer_traits_type::const_pointer const_pointer; + typedef typename outer_traits_type::void_pointer void_pointer; + typedef typename outer_traits_type::const_void_pointer const_void_pointer; + //! Type: `true_type` if `allocator_traits::propagate_on_container_copy_assignment::value` is + //! true for any `A` in the set of `OuterAlloc` and `InnerAllocs...`; otherwise, false_type. + typedef typename base_type:: + propagate_on_container_copy_assignment propagate_on_container_copy_assignment; + //! Type: `true_type` if `allocator_traits::propagate_on_container_move_assignment::value` is + //! true for any `A` in the set of `OuterAlloc` and `InnerAllocs...`; otherwise, false_type. + typedef typename base_type:: + propagate_on_container_move_assignment propagate_on_container_move_assignment; + //! Type: `true_type` if `allocator_traits::propagate_on_container_swap::value` is true for any + //! `A` in the set of `OuterAlloc` and `InnerAllocs...`; otherwise, false_type. + typedef typename base_type:: + propagate_on_container_swap propagate_on_container_swap; + + //! Type: Rebinds scoped allocator to + //! `typedef scoped_allocator_adaptor + //! < typename outer_traits_type::template portable_rebind_alloc::type + //! , InnerAllocs... >` + template + struct rebind + { + typedef scoped_allocator_adaptor + < typename outer_traits_type::template portable_rebind_alloc::type + #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + , InnerAllocs... + #else + BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, Q) + #endif + > other; + }; + + //! Effects: value-initializes the OuterAlloc base class + //! and the inner allocator object. + scoped_allocator_adaptor() + {} + + ~scoped_allocator_adaptor() + {} + + //! Effects: initializes each allocator within the adaptor with + //! the corresponding allocator from other. + scoped_allocator_adaptor(const scoped_allocator_adaptor& other) + : base_type(other.base()) + {} + + //! Effects: move constructs each allocator within the adaptor with + //! the corresponding allocator from other. + scoped_allocator_adaptor(BOOST_RV_REF(scoped_allocator_adaptor) other) + : base_type(::boost::move(other.base())) + {} + + #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + + //! Requires: OuterAlloc shall be constructible from OuterA2. + //! Effects: initializes the OuterAlloc base class with boost::forward(outerAlloc) and inner + //! with innerAllocs...(hence recursively initializing each allocator within the adaptor with the + //! corresponding allocator from the argument list). + template + scoped_allocator_adaptor(BOOST_FWD_REF(OuterA2) outerAlloc, const InnerAllocs & ...innerAllocs) + : base_type(::boost::forward(outerAlloc), innerAllocs...) + {} + #else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + + #define BOOST_PP_LOCAL_MACRO(n) \ + template \ + scoped_allocator_adaptor(BOOST_FWD_REF(OuterA2) outerAlloc \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_CONST_REF_PARAM_LIST_Q, _)) \ + : base_type(::boost::forward(outerAlloc) \ + BOOST_PP_ENUM_TRAILING_PARAMS(n, q) \ + ) \ + {} \ + //! + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + + #endif // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + + //! Requires: OuterAlloc shall be constructible from OuterA2. + //! Effects: initializes each allocator within the adaptor with the corresponding allocator from other. + template + scoped_allocator_adaptor(const scoped_allocator_adaptor &other) + : base_type(other.base()) + {} + + //! Requires: OuterAlloc shall be constructible from OuterA2. + //! Effects: initializes each allocator within the adaptor with the corresponding allocator + //! rvalue from other. + template + scoped_allocator_adaptor(BOOST_RV_REF_BEG scoped_allocator_adaptor BOOST_RV_REF_END other) + : base_type(::boost::move(other.base())) + {} + + scoped_allocator_adaptor &operator=(BOOST_COPY_ASSIGN_REF(scoped_allocator_adaptor) other) + { + base_type::operator=(static_cast(other)); + return *this; + } + + scoped_allocator_adaptor &operator=(BOOST_RV_REF(scoped_allocator_adaptor) other) + { + base_type::operator=(boost::move(static_cast(other))); + return *this; + } + + //! Returns: + //! static_cast(*this). + outer_allocator_type & outer_allocator() + { return *this; } + + //! Returns: + //! static_cast(*this). + const outer_allocator_type &outer_allocator() const + { return *this; } + + //! Returns: + //! *this if sizeof...(InnerAllocs) is zero; otherwise, inner. + inner_allocator_type& inner_allocator() + { return base_type::inner_allocator(); } + + //! Returns: + //! *this if sizeof...(InnerAllocs) is zero; otherwise, inner. + inner_allocator_type const& inner_allocator() const + { return base_type::inner_allocator(); } + + //! Returns: + //! allocator_traits::max_size(outer_allocator()). + size_type max_size() const + { + return outer_traits_type::max_size(this->outer_allocator()); + } + + //! Effects: + //! calls OUTERMOST_ALLOC_TRAITS(*this)::destroy(OUTERMOST(*this), p). + template + void destroy(T* p) + { + allocator_traits::type> + ::destroy(get_outermost_allocator(this->outer_allocator()), p); + } + + //! Returns: + //! allocator_traits::allocate(outer_allocator(), n). + pointer allocate(size_type n) + { + return outer_traits_type::allocate(this->outer_allocator(), n); + } + + //! Returns: + //! allocator_traits::allocate(outer_allocator(), n, hint). + pointer allocate(size_type n, const_void_pointer hint) + { + return outer_traits_type::allocate(this->outer_allocator(), n, hint); + } + + //! Effects: + //! allocator_traits::deallocate(outer_allocator(), p, n); + void deallocate(pointer p, size_type n) + { + outer_traits_type::deallocate(this->outer_allocator(), p, n); + } + + //! Returns: A new scoped_allocator_adaptor object where each allocator + //! A in the adaptor is initialized from the result of calling + //! allocator_traits::select_on_container_copy_construction() on + //! the corresponding allocator in *this. + scoped_allocator_adaptor select_on_container_copy_construction() const + { + return scoped_allocator_adaptor + (outer_traits_type::select_on_container_copy_construction(this->outer_allocator()), + outer_traits_type::select_on_container_copy_construction(this->inner_allocator()) + ); + } + /// @cond + base_type &base() { return *this; } + + const base_type &base() const { return *this; } + /// @endcond + + #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + + //! Effects: + //! 1) If uses_allocator::value is false calls + //! OUTERMOST_ALLOC_TRAITS(*this)::construct + //! (OUTERMOST(*this), p, std::forward(args)...). + //! + //! 2) Otherwise, if uses_allocator::value is true and + //! is_constructible::value is true, calls + //! OUTERMOST_ALLOC_TRAITS(*this)::construct(OUTERMOST(*this), p, allocator_arg, + //! inner_allocator(), std::forward(args)...). + //! + //! [Note: In compilers without advanced decltype SFINAE support, is_constructible can't be, + //! implemented so that condition will be replaced by + //! constructible_with_allocator_prefix::value. -end note] + //! + //! 3) Otherwise, if uses_allocator::value is true and + //! is_constructible::value is true, calls + //! OUTERMOST_ALLOC_TRAITS(*this)::construct(OUTERMOST(*this), p, + //! std::forward(args)..., inner_allocator()). + //! + //! [Note: In compilers without advanced decltype SFINAE support, is_constructible can't be, + //! implemented so that condition will be replaced by + //! constructible_with_allocator_suffix::value. -end note] + //! + //! 4) Otherwise, the program is ill-formed. [Note: An error will result if uses_allocator evaluates + //! to true but the specific constructor does not take an allocator. This definition prevents a silent + //! failure to pass an inner allocator to a contained element. -end note] + template < typename T, class ...Args> + #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + void + #else + typename container_detail::enable_if_c::value, void>::type + #endif + construct(T* p, BOOST_FWD_REF(Args)...args) + { + container_detail::dispatch_uses_allocator + ( uses_allocator() + , get_outermost_allocator(this->outer_allocator()) + , this->inner_allocator() + , p, ::boost::forward(args)...); + } + + #else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + + //Disable this overload if the first argument is pair as some compilers have + //overload selection problems when the first parameter is a pair. + #define BOOST_PP_LOCAL_MACRO(n) \ + template < typename T \ + BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) \ + > \ + typename container_detail::enable_if_c::value, void>::type \ + construct(T* p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + container_detail::dispatch_uses_allocator \ + ( uses_allocator() \ + , get_outermost_allocator(this->outer_allocator()) \ + , this->inner_allocator() \ + , 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 // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + + template + void construct(std::pair* p) + { this->construct_pair(p); } + + template + void construct(container_detail::pair* p) + { this->construct_pair(p); } + + template + void construct(std::pair* p, BOOST_FWD_REF(U) x, BOOST_FWD_REF(V) y) + { this->construct_pair(p, ::boost::forward(x), ::boost::forward(y)); } + + template + void construct(container_detail::pair* p, BOOST_FWD_REF(U) x, BOOST_FWD_REF(V) y) + { this->construct_pair(p, ::boost::forward(x), ::boost::forward(y)); } + + template + void construct(std::pair* p, const std::pair& x) + { this->construct_pair(p, x); } + + template + void construct( container_detail::pair* p + , const container_detail::pair& x) + { this->construct_pair(p, x); } + + template + void construct( std::pair* p + , BOOST_RV_REF_BEG std::pair BOOST_RV_REF_END x) + { this->construct_pair(p, x); } + + template + void construct( container_detail::pair* p + , BOOST_RV_REF_BEG container_detail::pair BOOST_RV_REF_END x) + { this->construct_pair(p, x); } + + /// @cond + private: + template + void construct_pair(Pair* p) + { + this->construct(container_detail::addressof(p->first)); + try { + this->construct(container_detail::addressof(p->second)); + } + catch (...) { + this->destroy(container_detail::addressof(p->first)); + throw; + } + } + + template + void construct_pair(Pair* p, BOOST_FWD_REF(U) x, BOOST_FWD_REF(V) y) + { + this->construct(container_detail::addressof(p->first), ::boost::forward(x)); + try { + this->construct(container_detail::addressof(p->second), ::boost::forward(y)); + } + catch (...) { + this->destroy(container_detail::addressof(p->first)); + throw; + } + } + + template + void construct_pair(Pair* p, const Pair2& pr) + { + this->construct(container_detail::addressof(p->first), pr.first); + try { + this->construct(container_detail::addressof(p->second), pr.second); + } + catch (...) { + this->destroy(container_detail::addressof(p->first)); + throw; + } + } + + template + void construct_pair(Pair* p, BOOST_RV_REF(Pair2) pr) + { + this->construct(container_detail::addressof(p->first), ::boost::move(pr.first)); + try { + this->construct(container_detail::addressof(p->second), ::boost::move(pr.second)); + } + catch (...) { + this->destroy(container_detail::addressof(p->first)); + throw; + } + } + + //template + //void construct(pair* p, piecewise_construct_t, tuple x, tuple y); + + /// @endcond +}; + +template +inline bool operator==( + const scoped_allocator_adaptor& a, + const scoped_allocator_adaptor& b) +{ + #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + const bool has_zero_inner = sizeof...(InnerAllocs) == 0u; + #else + const bool has_zero_inner = + boost::container::container_detail::is_same + ::value; + #endif + + return a.outer_allocator() == b.outer_allocator() + && (has_zero_inner || a.inner_allocator() == b.inner_allocator()); +} + +template +inline bool operator!=( + const scoped_allocator_adaptor& a, + const scoped_allocator_adaptor& b) +{ + return ! (a == b); +} + +}} // namespace boost { namespace container { + +#include + +#endif // BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_HPP From c5bdec851e0a7b9444831ca90652064f5c1310ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Thu, 22 Mar 2012 18:46:55 +0000 Subject: [PATCH 11/93] Experimental scoped_allocator support [SVN r77480] --- .../container/allocator/allocator_traits.hpp | 382 ---------- .../boost/container/allocator/memory_util.hpp | 77 --- .../container/allocator/scoped_allocator.hpp | 651 ------------------ include/boost/container/container_fwd.hpp | 2 +- include/boost/container/deque.hpp | 44 +- .../detail/adaptive_node_pool_impl.hpp | 2 +- .../container/detail/advanced_insert_int.hpp | 129 ++-- include/boost/container/detail/algorithms.hpp | 2 +- .../container/detail/allocation_type.hpp | 2 +- .../boost/container/detail/config_begin.hpp | 3 +- include/boost/container/detail/config_end.hpp | 2 +- include/boost/container/detail/destroyers.hpp | 35 +- include/boost/container/detail/flat_tree.hpp | 22 +- .../container/detail/function_detector.hpp | 2 +- include/boost/container/detail/iterators.hpp | 14 +- .../boost/container/detail/math_functions.hpp | 2 +- include/boost/container/detail/mpl.hpp | 2 +- .../detail/multiallocation_chain.hpp | 2 +- .../container/detail/node_alloc_holder.hpp | 57 +- .../boost/container/detail/node_pool_impl.hpp | 2 +- include/boost/container/detail/pair.hpp | 107 +-- .../boost/container/detail/pool_common.hpp | 2 +- .../boost/container/detail/preprocessor.hpp | 12 +- include/boost/container/detail/stored_ref.hpp | 2 +- .../container/detail/transform_iterator.hpp | 2 +- include/boost/container/detail/tree.hpp | 92 ++- .../boost/container/detail/type_traits.hpp | 9 +- include/boost/container/detail/utilities.hpp | 15 +- include/boost/container/detail/value_init.hpp | 2 +- .../detail/variadic_templates_tools.hpp | 2 +- .../boost/container/detail/version_type.hpp | 2 +- include/boost/container/detail/workaround.hpp | 7 +- include/boost/container/flat_map.hpp | 50 +- include/boost/container/flat_set.hpp | 88 ++- include/boost/container/list.hpp | 59 +- include/boost/container/map.hpp | 72 +- include/boost/container/set.hpp | 40 +- include/boost/container/slist.hpp | 60 +- include/boost/container/stable_vector.hpp | 170 ++--- include/boost/container/string.hpp | 34 +- include/boost/container/vector.hpp | 120 +++- 41 files changed, 888 insertions(+), 1493 deletions(-) delete mode 100644 include/boost/container/allocator/allocator_traits.hpp delete mode 100644 include/boost/container/allocator/memory_util.hpp delete mode 100644 include/boost/container/allocator/scoped_allocator.hpp diff --git a/include/boost/container/allocator/allocator_traits.hpp b/include/boost/container/allocator/allocator_traits.hpp deleted file mode 100644 index 0192161..0000000 --- a/include/boost/container/allocator/allocator_traits.hpp +++ /dev/null @@ -1,382 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Pablo Halpern 2009. 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) -// -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2011-2011. 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) -// -// See http://www.boost.org/libs/container for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP -#define BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP - -#if (defined _MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif - -#include -#include -#include -#include -#include -#include -#include -#include //numeric_limits<>::max() -#include //placement new -#include //std::allocator -#include - -///@cond - -namespace boost { -namespace container { -namespace container_detail { - -//workaround needed for C++03 compilers with no construct() -//supporting rvalue references -template -struct is_std_allocator -{ static const bool value = false; }; - -template -struct is_std_allocator< std::allocator > -{ static const bool value = true; }; - -} //namespace container_detail { - -///@endcond - -template -struct allocator_traits -{ - //allocator_type - typedef Alloc allocator_type; - //value_type - typedef typename Alloc::value_type value_type; - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - //!Alloc::pointer if such a type exists; otherwise, value_type* - //! - typedef unspecified pointer; - //!Alloc::const_pointer if such a type exists ; otherwise, pointer_traits::rebind::rebind. - //! - typedef unspecified void_pointer; - //!Alloc::const_void_pointer if such a type exists ; otherwis e, pointer_traits::rebind::difference_type. - //! - typedef unspecified difference_type; - //!Alloc::size_type if such a type exists ; otherwise, make_unsigned::type - //! - typedef unspecified size_type; - //!Alloc::propagate_on_container_copy_assignment if such a type exists, otherwise an integral_constant - //!type with internal constant static member
value
== false. - typedef unspecified propagate_on_container_copy_assignment; - //!Alloc::propagate_on_container_move_assignment if such a type exists, otherwise an integral_constant - //!type with internal constant static member
value
== false. - typedef unspecified propagate_on_container_move_assignment; - //!Alloc::propagate_on_container_swap if such a type exists, otherwise an integral_constant - //!type with internal constant static member
value
== false. - typedef unspecified propagate_on_container_swap; - //!Defines an allocator: Alloc::rebind::other if such a type exists; otherwise, Alloc - //!if Alloc is a class template instantiation of the form Alloc, where Args is zero or - //!more type arguments ; otherwise, the instantiation of rebind_alloc is ill-formed. - //! - //!In C++03 compilers
rebind_alloc
is a struct derived from an allocator - //!deduced by previously detailed rules. - template using rebind_alloc = unspecified; - - //!In C++03 compilers
rebind_traits
is a struct derived from - //!
allocator_traits
, where `OtherAlloc` is
-      //!the allocator deduced by rules explained in `rebind_alloc`.
-      template  using rebind_traits = allocator_traits >;
-
-      //!Non-standard extension: Portable allocator rebind for C++03 and C++11 compilers.
-      //!`type` is an allocator related to Alloc deduced deduced by rules explained in `rebind_alloc`.
-      template 
-      struct portable_rebind_alloc
-      {  typedef unspecified_type type;  };
-   #else
-      //pointer
-      typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc,
-         pointer, value_type*)
-            pointer;
-      //const_pointer
-      typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc, 
-         const_pointer, typename boost::intrusive::pointer_traits::template
-            rebind_pointer)
-               const_pointer;
-      //reference
-      typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc,
-         reference, typename container_detail::unvoid::type&)
-            reference;
-      //const_reference
-      typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, 
-         const_reference, const typename container_detail::unvoid::type&)
-               const_reference;
-      //void_pointer
-      typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc, 
-         void_pointer, typename boost::intrusive::pointer_traits::template
-            rebind_pointer)
-               void_pointer;
-      //const_void_pointer
-      typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc,
-         const_void_pointer, typename boost::intrusive::pointer_traits::template
-            rebind_pointer)
-               const_void_pointer;
-      //difference_type
-      typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc,
-         difference_type, std::ptrdiff_t)
-            difference_type;
-      //size_type
-      typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc,
-         size_type, std::size_t)
-            size_type;
-      //propagate_on_container_copy_assignment
-      typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc,
-         propagate_on_container_copy_assignment, boost::false_type)
-            propagate_on_container_copy_assignment;
-      //propagate_on_container_move_assignment
-      typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc,
-         propagate_on_container_move_assignment, boost::false_type)
-            propagate_on_container_move_assignment;
-      //propagate_on_container_swap
-      typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc,
-         propagate_on_container_swap, boost::false_type)
-            propagate_on_container_swap;
-
-      #if !defined(BOOST_NO_TEMPLATE_ALIASES)
-         //C++11
-         template  using rebind_alloc  = boost::intrusive::detail::type_rebinder::type;
-         template  using rebind_traits = allocator_traits< rebind_alloc >;
-      #else    //!defined(BOOST_NO_TEMPLATE_ALIASES)
-         //Some workaround for C++03 or C++11 compilers with no template aliases
-         template 
-         struct rebind_alloc : boost::intrusive::detail::type_rebinder::type
-         {
-            typedef typename boost::intrusive::detail::type_rebinder::type Base;
-            #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
-            template 
-            rebind_alloc(Args&&... args)
-               : Base(boost::forward(args)...)
-            {}
-            #else    //!defined(BOOST_NO_VARIADIC_TEMPLATES)
-            #define BOOST_PP_LOCAL_MACRO(n)                                                        \
-            BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
-            rebind_alloc(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                       \
-               : Base(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))                       \
-            {}                                                                                     \
-            //
-            #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
-            #include BOOST_PP_LOCAL_ITERATE()
-            #endif   //!defined(BOOST_NO_VARIADIC_TEMPLATES)
-         };
-
-         template 
-         struct rebind_traits
-            : allocator_traits::type>
-         {};
-      #endif   //!defined(BOOST_NO_TEMPLATE_ALIASES)
-      template 
-      struct portable_rebind_alloc
-      {  typedef typename boost::intrusive::detail::type_rebinder::type type;  };
-   #endif   //BOOST_CONTAINER_DOXYGEN_INVOKED
-
-   //!Returns: a.allocate(n)
-   //!
-   static pointer allocate(Alloc &a, size_type n)
-   {  return a.allocate(n);  }
-
-   //!Returns: a.deallocate(p, n)
-   //!
-   //!Throws: Nothing
-   static void deallocate(Alloc &a, pointer p, size_type n)
-   {  return a.deallocate(p, n);  }
-
-   //!Effects: calls `a.construct(p, std::forward(args)...)` if that call is well-formed;
-   //!otherwise, invokes `::new (static_cast(p)) T(std::forward(args)...)`
-   static pointer allocate(Alloc &a, size_type n, const_void_pointer p)
-   {
-      const bool value = boost::container::container_detail::
-         has_member_function_callable_with_allocate
-            ::value;
-      ::boost::integral_constant flag;
-      return allocator_traits::priv_allocate(flag, a, n, p);
-   }
-
-   //!Effects: calls a.destroy(p) if that call is well-formed;
-   //!otherwise, invokes `p->~T()`.
-   template
-   static void destroy(Alloc &a, T*p)
-   {
-      typedef T* destroy_pointer;
-      const bool value = boost::container::container_detail::
-         has_member_function_callable_with_destroy
-            ::value;
-      ::boost::integral_constant flag;
-      allocator_traits::priv_destroy(flag, a, p);
-   }
-
-   //!Returns: a.max_size() if that expression is well-formed; otherwise,
-   //!`numeric_limits::max()`.
-   static size_type max_size(const Alloc &a)
-   {
-      const bool value = boost::container::container_detail::
-         has_member_function_callable_with_max_size
-            ::value;
-      ::boost::integral_constant flag;
-      return allocator_traits::priv_max_size(flag, a);
-   }
-
-   //!Returns: a.select_on_container_copy_construction() if that expres sion is well- formed;
-   //!otherwise, a.
-   static Alloc select_on_container_copy_construction(const Alloc &a)
-   {
-      const bool value = boost::container::container_detail::
-         has_member_function_callable_with_select_on_container_copy_construction
-            ::value;
-      ::boost::integral_constant flag;
-      return allocator_traits::priv_select_on_container_copy_construction(flag, a);
-   }
-
-   #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-      //!Effects: calls a.construct(p, std::forward(args)...) if that call is well-formed; 
-      //!otherwise, invokes `::new (static_cast(p)) T(std::forward(args)...)`
-      template 
-      static void construct(Alloc & a, T* p, Args&&... args)
-      {
-         ::boost::integral_constant::value> flag;
-         allocator_traits::priv_construct(flag, a, p, ::boost::forward(args)...);
-      }
-   #endif
-
-   #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-      private:
-      static pointer priv_allocate(boost::true_type, Alloc &a, size_type n, const_void_pointer p)
-      {  return a.allocate(n, p);  }
-
-      static pointer priv_allocate(boost::false_type, Alloc &a, size_type n, const_void_pointer)
-      {  return allocator_traits::allocate(a, n);  }
-
-      template
-      static void priv_destroy(boost::true_type, Alloc &a, T* p)
-      {  a.destroy(p);  }
-
-      template
-      static void priv_destroy(boost::false_type, Alloc &, T* p)
-      {  p->~T(); (void)p;  }
-
-      static size_type priv_max_size(boost::true_type, const Alloc &a)
-      {  return a.max_size();  }
-
-      static size_type priv_max_size(boost::false_type, const Alloc &)
-      {  return (std::numeric_limits::max)();  }
-
-      static Alloc priv_select_on_container_copy_construction(boost::true_type, const Alloc &a)
-      {  return a.select_on_container_copy_construction();  }
-
-      static Alloc priv_select_on_container_copy_construction(boost::false_type, const Alloc &a)
-      {  return a;  }
-
-      #if defined(BOOST_CONTAINER_PERFECT_FORWARDING)
-         template
-         static void priv_construct(boost::false_type, Alloc &a, T *p, Args && ...args)                    
-         {                                                                                                  
-            const bool value = boost::container::container_detail::
-                  has_member_function_callable_with_construct
-                     < Alloc, T*, Args... >::value;
-            ::boost::integral_constant flag;
-            priv_construct_dispatch2(flag, a, p, ::boost::forward(args)...);
-         }
-
-         template
-         static void priv_construct(boost::true_type, Alloc &a, T *p, Args && ...args)
-         {
-            priv_construct_dispatch2(boost::false_type(), a, p, ::boost::forward(args)...);
-         }
-
-         template
-         static void priv_construct_dispatch2(boost::true_type, Alloc &a, T *p, Args && ...args)
-         {  a.construct( p, ::boost::forward(args)...);  }
-
-         template
-         static void priv_construct_dispatch2(boost::false_type, Alloc &, T *p, Args && ...args)
-         {  ::new((void*)p) T(::boost::forward(args)...); }
-      #else
-         public:
-         #define BOOST_PP_LOCAL_MACRO(n)                                                              \
-         template                                 \
-         static void construct(Alloc &a, T *p                                                         \
-                              BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _))            \
-         {                                                                                            \
-            ::boost::integral_constant::value> flag;  \
-            allocator_traits::priv_construct(flag, a, 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()
-      
-         private:
-         #define BOOST_PP_LOCAL_MACRO(n)                                                                    \
-         template                                      \
-         static void priv_construct(boost::false_type, Alloc &a, T *p                                       \
-                        BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST,_))                         \
-         {                                                                                                  \
-            const bool value =                                                                              \
-               boost::container::container_detail::has_member_function_callable_with_construct              \
-                     < Alloc, T* BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_FWD_TYPE, _) >::value;        \
-            ::boost::integral_constant flag;                                                   \
-            priv_construct_dispatch2(flag, a, p                                                             \
-               BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) );                            \
-         }                                                                                                  \
-                                                                                                            \
-         template                                      \
-         static void priv_construct(boost::true_type, Alloc &a, T *p                                        \
-                        BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST,_))                         \
-         {                                                                                                  \
-            priv_construct_dispatch2(boost::false_type(), a, p                                              \
-               BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) );                            \
-         }                                                                                                  \
-                                                                                                            \
-         template                                      \
-         static void priv_construct_dispatch2(boost::true_type, Alloc &a, T *p                              \
-                        BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST,_))                         \
-         {  a.construct( p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) );  }             \
-                                                                                                            \
-         template                                      \
-         static void priv_construct_dispatch2(boost::false_type, Alloc &, T *p                              \
-                        BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _) )                       \
-         {  ::new((void*)p) T(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); }                     \
-         //
-         #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
-         #include BOOST_PP_LOCAL_ITERATE()
-      #endif   //BOOST_CONTAINER_PERFECT_FORWARDING
-   #endif   //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-   ///@endcond
-};
-
-}  //namespace container {
-}  //namespace boost {
-
-#include 
-
-#endif // ! defined(BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP)
diff --git a/include/boost/container/allocator/memory_util.hpp b/include/boost/container/allocator/memory_util.hpp
deleted file mode 100644
index ea4bc05..0000000
--- a/include/boost/container/allocator/memory_util.hpp
+++ /dev/null
@@ -1,77 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Ion Gaztanaga 2011-2011. 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)
-//
-// See http://www.boost.org/libs/container for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef BOOST_CONTAINER_ALLOCATOR_MEMORY_UTIL_HPP
-#define BOOST_CONTAINER_ALLOCATOR_MEMORY_UTIL_HPP
-
-#if (defined _MSC_VER) && (_MSC_VER >= 1200)
-#  pragma once
-#endif
-
-#include 
-#include 
-#include 
-#include 
-
-
-#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME allocate
-#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail {
-#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END   }}}
-#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 2, ))
-#include BOOST_PP_ITERATE()
-
-#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME destroy
-#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail {
-#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END   }}}
-#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 3, ))
-#include BOOST_PP_ITERATE()
-
-#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME max_size
-#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail {
-#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END   }}}
-#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 0, ))
-#include BOOST_PP_ITERATE()
-
-#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME select_on_container_copy_construction
-#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail {
-#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END   }}}
-#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 0, ))
-#include BOOST_PP_ITERATE()
-
-#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME construct
-#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail {
-#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END   }}}
-#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS+1, ))
-#include BOOST_PP_ITERATE()
-
-namespace boost {
-namespace container {
-namespace container_detail {
-
-
-BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(pointer)
-BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_pointer)
-BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reference)
-BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_reference)
-BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(void_pointer)
-BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_void_pointer)
-BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(size_type)
-BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_copy_assignment)
-BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_move_assignment)
-BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_swap)
-BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type)
-
-}  //namespace container_detail {
-}  //namespace container {
-}  //namespace boost {
-
-#include 
-
-#endif // ! defined(BOOST_CONTAINER_ALLOCATOR_MEMORY_UTIL_HPP)
diff --git a/include/boost/container/allocator/scoped_allocator.hpp b/include/boost/container/allocator/scoped_allocator.hpp
deleted file mode 100644
index 03e12d1..0000000
--- a/include/boost/container/allocator/scoped_allocator.hpp
+++ /dev/null
@@ -1,651 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Pablo Halpern 2009. 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)
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Ion Gaztanaga 2011-2011. 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)
-//
-// See http://www.boost.org/libs/container for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_HPP
-#define BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_HPP
-
-#if (defined _MSC_VER) && (_MSC_VER >= 1200)
-#  pragma once
-#endif
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-namespace boost { namespace container {
-
-template 
-class scoped_allocator_adaptor;
-
-template 
-scoped_allocator_adaptor make_scoped();
-
-template 
-class scoped_allocator_adaptor_base : public OuterAlloc
-{
-    typedef allocator_traits OuterTraits;
-
-public:
-    // Workaround for inability of gcc-4.4.1 to expand InnerAllocs...
-//    typedef scoped_allocator_adaptor inner_allocator_type;
-    typedef decltype(make_scoped()) inner_allocator_type;
-
-    scoped_allocator_adaptor_base();
-
-    template 
-      scoped_allocator_adaptor_base(OuterA2&& outerAlloc, const InnerAllocs&... innerAllocs);
-
-    template 
-      scoped_allocator_adaptor_base(const scoped_allocator_adaptor& other);
-    template 
-      scoped_allocator_adaptor_base(scoped_allocator_adaptor&& other);
-    
-    inner_allocator_type&       inner_allocator()
-        { return _M_inner_allocs; }
-    inner_allocator_type const& inner_allocator() const
-        { return _M_inner_allocs; }
-
-    // Allocator propagation functions.
-    scoped_allocator_adaptor
-    select_on_container_copy_construction() const;
-
-    typedef std::integral_constant<
-        bool,
-        OuterTraits::propagate_on_container_copy_assignment::value ||
-        inner_allocator_type::propagate_on_container_copy_assignment::value
-        > propagate_on_container_copy_assignment;
-    typedef std::integral_constant<
-        bool,
-        OuterTraits::propagate_on_container_move_assignment::value ||
-        inner_allocator_type::propagate_on_container_move_assignment::value
-        > propagate_on_container_move_assignment;
-    typedef std::integral_constant<
-        bool,
-        OuterTraits::propagate_on_container_swap::value ||
-        inner_allocator_type::propagate_on_container_swap::value
-        > propagate_on_container_swap;
-
-private:
-    inner_allocator_type _M_inner_allocs;
-};
-
-// Specialization with only one parameter.
-template 
-class scoped_allocator_adaptor_base : public OuterAlloc
-{
-    typedef allocator_traits OuterTraits;
-public:
-    typedef scoped_allocator_adaptor inner_allocator_type;
-
-    scoped_allocator_adaptor_base();
-
-    template 
-      scoped_allocator_adaptor_base(OuterA2&& outerAlloc);
-
-    template 
-      scoped_allocator_adaptor_base(const scoped_allocator_adaptor& other);
-    template 
-      scoped_allocator_adaptor_base(scoped_allocator_adaptor&& other);
-    
-    inner_allocator_type&       inner_allocator()
-        { return static_cast(*this); }
-
-    inner_allocator_type const& inner_allocator() const
-        { return static_cast(*this); }
-
-    // Allocator propagation functions.
-    scoped_allocator_adaptor
-      select_on_container_copy_construction() const;
-
-    typedef typename OuterTraits::propagate_on_container_copy_assignment propagate_on_container_copy_assignment;
-    typedef typename OuterTraits::propagate_on_container_move_assignment propagate_on_container_move_assignment;
-    typedef typename OuterTraits::propagate_on_container_swap propagate_on_container_swap;
-};
-
-template 
-class scoped_allocator_adaptor
-    : public scoped_allocator_adaptor_base
-{
-    typedef scoped_allocator_adaptor_base _Base;
-    typedef allocator_traits                              _Traits;
-
-public:
-    typedef OuterAlloc                           outer_allocator_type;
-    typedef typename _Base::inner_allocator_type inner_allocator_type;
-    
-    typedef typename allocator_traits::size_type          size_type;
-    typedef typename allocator_traits::difference_type    difference_type;
-    typedef typename allocator_traits::pointer            pointer;
-    typedef typename allocator_traits::const_pointer      const_pointer;
-    typedef typename allocator_traits::void_pointer       void_pointer;
-    typedef typename allocator_traits::const_void_pointer const_void_pointer;
-    typedef typename allocator_traits::value_type          value_type;
-
-    template 
-    struct rebind {
-        typedef typename allocator_traits::template rebind_traits rebound_traits;
-        typedef typename rebound_traits::allocator_type rebound_outer; // exposition only
-        typedef scoped_allocator_adaptor other;
-    };
-
-    scoped_allocator_adaptor();
-    scoped_allocator_adaptor(const scoped_allocator_adaptor& other);
-
-    template 
-      scoped_allocator_adaptor(const scoped_allocator_adaptor& other);
-    template 
-      scoped_allocator_adaptor(scoped_allocator_adaptor&& other);
-    
-    template 
-      scoped_allocator_adaptor(OuterA2&& outerAlloc, const InnerAllocs&... innerAllocs);
-
-    ~scoped_allocator_adaptor();
-
-    inner_allocator_type      & inner_allocator()
-        { return _Base::inner_allocator(); }
-    inner_allocator_type const& inner_allocator() const
-        { return _Base::inner_allocator(); }
-    outer_allocator_type      & outer_allocator()
-        { return *this; }
-    outer_allocator_type const& outer_allocator() const
-        { return *this; }
-
-    pointer allocate(size_type n);
-    pointer allocate(size_type n, const_void_pointer hint);
-    void deallocate(pointer p, size_type n);
-    size_type max_size() const;
-
-    template 
-      void construct(T* p, Args&&... args);
-
-    // Specializations to pass inner_allocator to pair::first and pair::second
-    template 
-      void construct(std::pair* p);
-    template 
-      void construct(std::pair* p, U&& x, V&& y);
-    template 
-      void construct(std::pair* p, const std::pair& pr);
-    template 
-      void construct(std::pair* p, std::pair&& pr);
-
-    template 
-      void destroy(T* p);
-};
-
-template 
-inline
-bool operator==(const scoped_allocator_adaptor& a,
-                const scoped_allocator_adaptor& b);
-
-template 
-inline
-bool operator!=(const scoped_allocator_adaptor& a,
-                const scoped_allocator_adaptor& b);
-
-///////////////////////////////////////////////////////////////////////////////
-// Implementation of scoped_allocator_adaptor_base
-///////////////////////////////////////////////////////////////////////////////
-
-template 
-inline
-scoped_allocator_adaptor_base::
-    scoped_allocator_adaptor_base()
-{
-}
-
-template 
-  template 
-    scoped_allocator_adaptor_base::
-      scoped_allocator_adaptor_base(OuterA2&&        outerAlloc,
-                                    const InnerAllocs&... innerAllocs)
-          : OuterAlloc(std::forward(outerAlloc))
-          , _M_inner_allocs(innerAllocs...)
-{
-}
-
-template 
-  template 
-    scoped_allocator_adaptor_base::
-      scoped_allocator_adaptor_base(
-          const scoped_allocator_adaptor& other)
-          : OuterAlloc(other.outer_allocator())
-          , _M_inner_allocs(other.inner_allocator())
-{
-}
-
-template 
-  template 
-    scoped_allocator_adaptor_base::
-      scoped_allocator_adaptor_base(
-          scoped_allocator_adaptor&& other)
-          : OuterAlloc(std::move(other.outer_allocator()))
-          , _M_inner_allocs(std::move(other.inner_allocator()))
-{
-}
-
-template 
-inline
-scoped_allocator_adaptor
-scoped_allocator_adaptor_base::
-  select_on_container_copy_construction() const
-{
-    return scoped_allocator_adaptor(
-        allocator_traits::select_on_container_copy_construction(
-            this->outer_allocator()),
-        allocator_traits::select_on_container_copy_construction(
-            this->inner_allocator()));
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Implementation of scoped_allocator_adaptor_base specialization
-///////////////////////////////////////////////////////////////////////////////
-
-template 
-inline
-scoped_allocator_adaptor_base::
-    scoped_allocator_adaptor_base()
-{
-}
-
-template 
-  template 
-    scoped_allocator_adaptor_base::
-     scoped_allocator_adaptor_base(OuterA2&& outerAlloc)
-         : OuterAlloc(std::forward(outerAlloc))
-{
-}
-
-template 
-  template 
-    scoped_allocator_adaptor_base::
-      scoped_allocator_adaptor_base(
-          const scoped_allocator_adaptor& other)
-          : OuterAlloc(other.outer_allocator())
-{
-}
-
-template 
-  template 
-    scoped_allocator_adaptor_base::
-      scoped_allocator_adaptor_base(
-          scoped_allocator_adaptor&& other)
-          : OuterAlloc(std::move(other.outer_allocator()))
-{
-}
-
-// template 
-// inline
-// scoped_allocator_adaptor& 
-// scoped_allocator_adaptor_base::inner_allocator()
-// {
-//     return *this;
-// }
-
-// template 
-// inline
-// scoped_allocator_adaptor const& 
-// scoped_allocator_adaptor_base::inner_allocator() cosnt
-// {
-//     return *this;
-// }
-
-template 
-inline
-scoped_allocator_adaptor
-scoped_allocator_adaptor_base::
-select_on_container_copy_construction() const
-{
-    return
-        allocator_traits::select_on_container_copy_construction(
-            this->outer_allocator());
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Implementation of scoped_allocator_adaptor details
-///////////////////////////////////////////////////////////////////////////////
-
-namespace __details {
-
-    // Overload resolution for __has_ctor resolves to this function
-    // when _Tp is constructible with _Args.  Returns true_type().
-    
-    static void* __void_p; // Declared but not defined
-
-    template 
-    inline
-    auto __has_ctor(int, _Args&&... __args) ->
-        decltype((new (__void_p) _Tp(__args...), std::true_type()))
-        { return std::true_type(); }
-
-    // Overload resolution for __has_ctor resolves to this function
-    // when _Tp is not constructible with _Args. Returns false_type().
-    template 
-    auto __has_ctor(_LowPriorityConversion, _Args&&...) ->
-        std::false_type
-        { return std::false_type(); }
-
-    template 
-    struct __is_scoped_allocator_imp {
-        template 
-        static char test(int, typename T::outer_allocator_type*);
-        template 
-        static int test(_LowPriorityConversion, void*);
-        static const bool value = (1 == sizeof(test<_Alloc>(0, 0)));
-    };
-
-    template 
-    struct __is_scoped_allocator
-        : std::integral_constant::value>
-    {
-    };
-
-#if 0
-    // Called when outer_allocator_type is not a scoped allocator
-    // (recursion stop).
-    template 
-    inline
-    auto __outermost_alloc(_LowPriorityConversion, _Alloc& __a) ->
-        _Alloc&
-    {
-        return __a;
-    }
-
-    // Called when outer_allocator_type is a scoped allocator to
-    // return the outermost allocator type.
-    template 
-    inline auto __outermost_alloc(int, _Alloc& __a) ->
-        decltype(__outermost_alloc(0,__a.outer_allocator())) 
-    {
-        return __a.outer_allocator();
-    }
-#endif
-
-    template 
-    inline void __dispatch_scoped_construct(std::false_type __uses_alloc,
-                                            _Ignore         __use_alloc_prefix,
-                                            _OuterAlloc&    __outer_alloc,
-                                            _InnerAlloc&    __inner_alloc,
-                                            _Tp* __p, _Args&&... __args)
-    {
-        // _Tp doesn't use allocators.  Construct without an
-        // allocator argument.
-        allocator_traits<_OuterAlloc>::construct(__outer_alloc, __p,
-                                               std::forward<_Args>(__args)...);
-    }
-
-    template 
-    inline void __dispatch_scoped_construct(std::true_type  __uses_alloc,
-                                            std::true_type  __use_alloc_prefix,
-                                            _OuterAlloc&    __outer_alloc,
-                                            _InnerAlloc&    __inner_alloc,
-                                            _Tp* __p, _Args&&... __args)
-    {
-        // _Tp doesn't use allocators.  Construct without an
-        // allocator argument.
-        allocator_traits<_OuterAlloc>::construct(__outer_alloc, __p,
-                                                 allocator_arg, __inner_alloc,
-                                               std::forward<_Args>(__args)...);
-    }
-
-    template 
-    inline void __dispatch_scoped_construct(std::true_type  __uses_alloc,
-                                            std::false_type __use_alloc_prefix,
-                                            _OuterAlloc&    __outer_alloc,
-                                            _InnerAlloc&    __inner_alloc,
-                                            _Tp* __p, _Args&&... __args)
-    {
-        // If _Tp uses an allocator compatible with _InnerAlloc,
-        // but the specific constructor does not have a variant that
-        // takes an allocator argument, then program is malformed.
-//         static_assert(has_constructor<_Tp, _Args...>::value,
-//                       "Cannot pass inner allocator to this constructor");
-
-        allocator_traits<_OuterAlloc>::construct(
-            __outer_alloc, __p, std::forward<_Args>(__args)...,
-            __inner_alloc);
-    }
-
-    template 
-    inline void __do_scoped_construct(std::false_type __scoped_outer,
-                                      _OuterAlloc&    __outer_alloc,
-                                      _InnerAlloc&    __inner_alloc,
-                                      _Tp* __p, _Args&&... __args)
-    {
-        // Dispatch construction to the correct __dispatch_scoped_construct()
-        // function based on whether _Tp uses an allocator of type
-        // _InnerAlloc and, if so, whether there exists the following
-        // constructor:
-        //   _Tp(allocator_arg_t, _InnerAlloc, Args...).
-        auto __uses_alloc = uses_allocator<_Tp, _InnerAlloc>();
-        auto __use_alloc_prefix = __has_ctor<_Tp>(0, allocator_arg,
-                                               __inner_alloc,
-                                               std::forward<_Args>(__args)...);
-        __dispatch_scoped_construct(__uses_alloc, __use_alloc_prefix,
-                                    __outer_alloc,
-                                    __inner_alloc,
-                                    __p, std::forward<_Args>(__args)...);
-    }
-
-    template 
-    void __do_scoped_construct(std::true_type  __scoped_outer,
-                               _OuterAlloc&    __outer_alloc,
-                               _InnerAlloc&    __inner_alloc,
-                               _Tp* __p, _Args&&... __args)
-    {
-        // Use outermost allocator if __outer_alloc is scoped
-        typedef typename _OuterAlloc::outer_allocator_type outerouter;
-        __do_scoped_construct(__is_scoped_allocator(),
-                              __outer_alloc.outer_allocator(),
-                              __inner_alloc,
-                              __p, std::forward<_Args>(__args)...);
-    }
-
-} // end namespace __details
-
-///////////////////////////////////////////////////////////////////////////////
-// Implementation of scoped_allocator_adaptor
-///////////////////////////////////////////////////////////////////////////////
-
-template 
-scoped_allocator_adaptor::
-    scoped_allocator_adaptor()
-{
-}
-
-template 
-scoped_allocator_adaptor::
-    scoped_allocator_adaptor(const scoped_allocator_adaptor& other)
-        : _Base(other)
-{
-}
-
-template 
-  template 
-    scoped_allocator_adaptor::
-      scoped_allocator_adaptor(const scoped_allocator_adaptor& other)
-        : _Base(other)
-{
-}
-
-template 
-  template 
-    scoped_allocator_adaptor::
-      scoped_allocator_adaptor(scoped_allocator_adaptor&& other)
-          : _Base(std::move(other))
-{
-}
-    
-template 
-  template 
-    scoped_allocator_adaptor::
-      scoped_allocator_adaptor(OuterA2&& outerAlloc, const InnerAllocs&... innerAllocs)
-          : _Base(std::forward(outerAlloc), innerAllocs...)
-{
-}
-
-template 
-scoped_allocator_adaptor::
-    ~scoped_allocator_adaptor()
-{
-}
-
-template 
-inline typename allocator_traits::pointer
-scoped_allocator_adaptor::
-    allocate(size_type n)
-{
-    return allocator_traits::allocate(outer_allocator(), n);
-}
-
-template 
-inline typename allocator_traits::pointer
-scoped_allocator_adaptor::
-    allocate(size_type n, const_void_pointer hint)
-{
-    return allocator_traits::allocate(outer_allocator(), n, hint);
-}
-
-template 
-inline void scoped_allocator_adaptor::
-    deallocate(pointer p, size_type n)
-{
-    allocator_traits::deallocate(outer_allocator(), p, n);
-}
-
-template 
-inline typename allocator_traits::size_type
-scoped_allocator_adaptor::max_size() const
-{
-    return allocator_traits::max_size(outer_allocator());
-}
-
-template 
-  template 
-    inline void scoped_allocator_adaptor::
-    destroy(T* p)
-{
-    allocator_traits::destroy(outer_allocator(), p);
-}
-
-template 
-  template 
-    inline
-    void scoped_allocator_adaptor::construct(T* p,
-                                                             Args&&... args)
-{
-    __do_scoped_construct(__details::__is_scoped_allocator(),
-                          this->outer_allocator(), this->inner_allocator(),
-                          p, std::forward(args)...);
-}
-
-template 
-  template 
-  void scoped_allocator_adaptor::construct(
-      std::pair* p)
-{
-    construct(addressof(p->first));
-    try {
-        construct(addressof(p->second));
-    }
-    catch (...) {
-        destroy(addressof(p->first));
-        throw;
-    }
-}
-
-template 
-  template 
-  void scoped_allocator_adaptor::construct(
-      std::pair* p, U&& x, V&& y)
-{
-    construct(addressof(p->first), std::forward(x));
-    try {
-        construct(addressof(p->second), std::forward(y));
-    }
-    catch (...) {
-        destroy(addressof(p->first));
-        throw;
-    }
-}
-
-template 
-  template 
-  void scoped_allocator_adaptor::construct(
-      std::pair* p, const std::pair& pr)
-{
-    construct(addressof(p->first), pr.first);
-    try {
-        construct(addressof(p->second), pr.second);
-    }
-    catch (...) {
-        destroy(addressof(p->first));
-        throw;
-    }
-}
-
-template 
-  template 
-  void scoped_allocator_adaptor::construct(
-      std::pair* p, std::pair&& pr)
-{
-    construct(addressof(p->first), std::move(pr.first));
-    try {
-        construct(addressof(p->second), std::move(pr.second));
-    }
-    catch (...) {
-        destroy(addressof(p->first));
-        throw;
-    }
-}
-
-template 
-inline
-bool operator==(const scoped_allocator_adaptor& a,
-                const scoped_allocator_adaptor& b)
-{
-    return a.outer_allocator() == b.outer_allocator()
-        && a.inner_allocator() == b.inner_allocator();
-}
-
-template 
-inline
-bool operator==(const scoped_allocator_adaptor& a,
-                const scoped_allocator_adaptor& b)
-{
-    return a.outer_allocator() == b.outer_allocator();
-}
-
-template 
-inline
-bool operator!=(const scoped_allocator_adaptor& a,
-                const scoped_allocator_adaptor& b)
-{
-    return ! (a == b);
-}
-
-}} // namespace boost { namespace container {
-
-#include 
-
-#endif //  BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_HPP
diff --git a/include/boost/container/container_fwd.hpp b/include/boost/container/container_fwd.hpp
index da325e4..affea83 100644
--- a/include/boost/container/container_fwd.hpp
+++ b/include/boost/container/container_fwd.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)
 //
diff --git a/include/boost/container/deque.hpp b/include/boost/container/deque.hpp
index 9ee0ee1..92bf0d4 100644
--- a/include/boost/container/deque.hpp
+++ b/include/boost/container/deque.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)
 //
@@ -44,7 +44,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -896,6 +896,46 @@ class deque : protected deque_base
       :  Base(boost::move(static_cast(x)))
    {  this->swap_members(x);   }
 
+   //! Effects: Copy constructs a vector using the specified allocator.
+   //!
+   //! Postcondition: x == *this.
+   //! 
+   //! Throws: If allocation
+   //!   throws or T's copy constructor throws.
+   //! 
+   //! Complexity: Linear to the elements x contains.
+   deque(const deque& x, const allocator_type &a)
+      :  Base(a)
+   {
+      if(x.size()){
+         this->priv_initialize_map(x.size());
+         boost::container::uninitialized_copy_alloc
+            (this->alloc(), x.begin(), x.end(), this->members_.m_start);
+      }
+   }
+
+   //! Effects: Move constructor using the specified allocator.
+   //!                 Moves mx's resources to *this if a == allocator_type().
+   //!                 Otherwise copies values from x to *this.
+   //!
+   //! Throws: If allocation or T's copy constructor throws.
+   //! 
+   //! Complexity: Constant if a == mx.get_allocator(), linear otherwise.
+   deque(BOOST_RV_REF(deque) mx, const allocator_type &a) 
+      :  Base(a)
+   {
+      if(mx.alloc() == a){
+         this->swap_members(mx);
+      }
+      else{
+         if(mx.size()){
+            this->priv_initialize_map(mx.size());
+            boost::container::uninitialized_copy_alloc
+               (this->alloc(), mx.begin(), mx.end(), this->members_.m_start);
+         }
+      }
+   }
+
    //! Effects: Constructs a deque that will use a copy of allocator a
    //!   and inserts a copy of the range [first, last) in the deque.
    //!
diff --git a/include/boost/container/detail/adaptive_node_pool_impl.hpp b/include/boost/container/detail/adaptive_node_pool_impl.hpp
index 3649579..92b6133 100644
--- a/include/boost/container/detail/adaptive_node_pool_impl.hpp
+++ b/include/boost/container/detail/adaptive_node_pool_impl.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)
 //
diff --git a/include/boost/container/detail/advanced_insert_int.hpp b/include/boost/container/detail/advanced_insert_int.hpp
index 58199c7..978a819 100644
--- a/include/boost/container/detail/advanced_insert_int.hpp
+++ b/include/boost/container/detail/advanced_insert_int.hpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-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)
 //
@@ -17,7 +17,9 @@
 
 #include "config_begin.hpp"
 #include 
-#include 
+#include 
+#include 
+#include 
 #include 
 #include   //std::iterator_traits
 #include 
@@ -41,7 +43,6 @@ template
 struct advanced_insert_aux_proxy
    :  public advanced_insert_aux_int
 {
-   typedef boost::container::allocator_traits alloc_traits;
    typedef typename allocator_traits::size_type size_type;
    typedef typename allocator_traits::value_type value_type;
    typedef typename advanced_insert_aux_int::difference_type difference_type;
@@ -54,36 +55,36 @@ struct advanced_insert_aux_proxy
    {}
 
    virtual void copy_remaining_to(Iterator p)
-   {  ::boost::copy_or_move(first_, last_, p);  }
+   {  ::boost::copy_or_move(this->first_, this->last_, p);  }
 
    virtual void uninitialized_copy_remaining_to(Iterator p)
-   {  ::boost::container::uninitialized_copy_or_move_alloc(a_, first_, last_, p);  }
+   {  ::boost::container::uninitialized_copy_or_move_alloc(this->a_, this->first_, this->last_, p);  }
 
    virtual void uninitialized_copy_some_and_update(Iterator pos, difference_type division_count, bool first_n)
    {
-      FwdIt mid = first_;
+      FwdIt mid = this->first_;
       std::advance(mid, division_count);
       if(first_n){
-         ::boost::container::uninitialized_copy_or_move_alloc(a_, first_, mid, pos);
-         first_ = mid;
+         ::boost::container::uninitialized_copy_or_move_alloc(this->a_, this->first_, mid, pos);
+         this->first_ = mid;
       }
       else{
-         ::boost::container::uninitialized_copy_or_move_alloc(a_, mid, last_, pos);
-         last_ = mid;
+         ::boost::container::uninitialized_copy_or_move_alloc(this->a_, mid, this->last_, pos);
+         this->last_ = mid;
       }
    }
 
    virtual void copy_some_and_update(Iterator pos, difference_type division_count, bool first_n)
    {
-      FwdIt mid = first_;
+      FwdIt mid = this->first_;
       std::advance(mid, division_count);
       if(first_n){
-         ::boost::copy_or_move(first_, mid, pos);
-         first_ = mid;
+         ::boost::copy_or_move(this->first_, mid, pos);
+         this->first_ = mid;
       }
       else{
-         ::boost::copy_or_move(mid, last_, pos);
-         last_ = mid;
+         ::boost::copy_or_move(mid, this->last_, pos);
+         this->last_ = mid;
       }
    }
    A &a_;
@@ -95,7 +96,7 @@ template
 struct default_construct_aux_proxy
    :  public advanced_insert_aux_int
 {
-   typedef boost::container::allocator_traits alloc_traits;
+   typedef ::boost::container::allocator_traits alloc_traits;
    typedef typename allocator_traits::size_type size_type;
    typedef typename allocator_traits::value_type value_type;
    typedef typename advanced_insert_aux_int::difference_type difference_type;
@@ -109,11 +110,11 @@ struct default_construct_aux_proxy
 
    virtual void copy_remaining_to(Iterator)
    {  //This should never be called with any count
-      BOOST_ASSERT(count_ == 0);
+      BOOST_ASSERT(this->count_ == 0);
    }
 
    virtual void uninitialized_copy_remaining_to(Iterator p)
-   {  this->priv_uninitialized_copy(p, count_); }
+   {  this->priv_uninitialized_copy(p, this->count_); }
 
    virtual void uninitialized_copy_some_and_update(Iterator pos, difference_type division_count, bool first_n)
    {
@@ -122,22 +123,22 @@ struct default_construct_aux_proxy
          new_count = division_count;
       }
       else{
-         BOOST_ASSERT(difference_type(count_)>= division_count);
-         new_count = count_ - division_count;
+         BOOST_ASSERT(difference_type(this->count_)>= division_count);
+         new_count = this->count_ - division_count;
       }
       this->priv_uninitialized_copy(pos, new_count);
    }
 
    virtual void copy_some_and_update(Iterator , difference_type division_count, bool first_n)
    {
-      BOOST_ASSERT(count_ == 0);
+      BOOST_ASSERT(this->count_ == 0);
       size_type new_count;
       if(first_n){
          new_count = division_count;
       }
       else{
-         BOOST_ASSERT(difference_type(count_)>= division_count);
-         new_count = count_ - division_count;
+         BOOST_ASSERT(difference_type(this->count_)>= division_count);
+         new_count = this->count_ - division_count;
       }
       //This function should never called with a count different to zero
       BOOST_ASSERT(new_count == 0);
@@ -147,21 +148,21 @@ struct default_construct_aux_proxy
    private:
    void priv_uninitialized_copy(Iterator p, const size_type n)
    {
-      BOOST_ASSERT(n <= count_);
+      BOOST_ASSERT(n <= this->count_);
       Iterator orig_p = p;
       size_type i = 0;
       try{
          for(; i < n; ++i, ++p){
-            alloc_traits::construct(a_, container_detail::to_raw_pointer(&*p));
+            alloc_traits::construct(this->a_, container_detail::to_raw_pointer(&*p));
          }
       }
       catch(...){
          while(i--){
-            alloc_traits::destroy(a_, container_detail::to_raw_pointer(&*orig_p++));
+            alloc_traits::destroy(this->a_, container_detail::to_raw_pointer(&*orig_p++));
          }
          throw;
       }
-      count_ -= n;
+      this->count_ -= n;
    }
    A &a_;
    size_type count_;
@@ -223,13 +224,13 @@ struct advanced_insert_aux_non_movable_emplace
    {
       BOOST_ASSERT(division_count <=1);
       if((first_n && division_count == 1) || (!first_n && division_count == 0)){
-         if(!used_){
-            alloc_traits::construct( a_
+         if(!this->used_){
+            alloc_traits::construct( this->a_
                                    , container_detail::to_raw_pointer(&*p)
                                    , ::boost::container::container_detail::
-                                       stored_ref::forward(get(args_))...
+                                       stored_ref::forward(get(this->args_))...
                                    );
-            used_ = true;
+            this->used_ = true;
          }
       }
    }
@@ -237,13 +238,13 @@ struct advanced_insert_aux_non_movable_emplace
    template
    void priv_uninitialized_copy_remaining_to(const index_tuple&, Iterator p)
    {
-      if(!used_){
-         alloc_traits::construct( a_
+      if(!this->used_){
+         alloc_traits::construct( this->a_
                                 , container_detail::to_raw_pointer(&*p)
                                 , ::boost::container::container_detail::
-                                    stored_ref::forward(get(args_))...
+                                    stored_ref::forward(get(this->args_))...
                                 );
-         used_ = true;
+         this->used_ = true;
       }
    }
 
@@ -260,6 +261,7 @@ struct advanced_insert_aux_emplace
    :  public advanced_insert_aux_non_movable_emplace
 {
    typedef advanced_insert_aux_non_movable_emplace base_t;
+   typedef boost::container::allocator_traits alloc_traits;
    typedef typename base_t::value_type       value_type;
    typedef typename base_t::difference_type  difference_type;
    typedef typename base_t::index_tuple_t    index_tuple_t;
@@ -283,8 +285,13 @@ struct advanced_insert_aux_emplace
    void priv_copy_remaining_to(const index_tuple&, Iterator p)
    {
       if(!this->used_){
-         *p = boost::move(value_type (
-            ::boost::container::container_detail::stored_ref::forward(get(this->args_))...));
+         aligned_storage::value> v;
+         value_type *vp = static_cast(static_cast(&v));
+         alloc_traits::construct(this->a_, vp,
+            ::boost::container::container_detail::stored_ref::forward(get(this->args_))...);
+         scoped_destructor d(this->a_, vp);
+         *p = boost::move(*vp);
+         d.release();
          this->used_ = true;
       }
    }
@@ -295,8 +302,17 @@ struct advanced_insert_aux_emplace
       BOOST_ASSERT(division_count <=1);
       if((first_n && division_count == 1) || (!first_n && division_count == 0)){
          if(!this->used_){
-            *p = boost::move(value_type(
-               ::boost::container::container_detail::stored_ref::forward(get(this->args_))...));
+            aligned_storage::value> v;
+            value_type *vp = static_cast(static_cast(&v));
+            alloc_traits::construct(this->a_, vp,
+               ::boost::container::container_detail::stored_ref::forward(get(this->args_))...);
+            try {
+               *p = boost::move(*vp);
+            } catch (...) {
+               alloc_traits::destroy(this->a_, vp);
+               throw;
+            }
+            alloc_traits::destroy(this->a_, vp);
             this->used_ = true;
          }
       }
@@ -337,13 +353,13 @@ struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_non_movable_emplace, n), ar
                                                                                     \
    virtual void uninitialized_copy_remaining_to(Iterator p)                         \
    {                                                                                \
-      if(!used_){                                                                   \
+      if(!this->used_){                                                             \
          alloc_traits::construct                                                    \
-            ( a_                                                                    \
+            ( this->a_                                                              \
             , container_detail::to_raw_pointer(&*p)                                 \
             BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _)         \
             );                                                                      \
-         used_ = true;                                                              \
+         this->used_ = true;                                                        \
       }                                                                             \
    }                                                                                \
                                                                                     \
@@ -352,13 +368,13 @@ struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_non_movable_emplace, n), ar
    {                                                                                \
       BOOST_ASSERT(division_count <=1);                                             \
       if((first_n && division_count == 1) || (!first_n && division_count == 0)){    \
-         if(!used_){                                                                \
+         if(!this->used_){                                                          \
             alloc_traits::construct                                                 \
-               ( a_                                                                 \
+               ( this->a_                                                           \
                , container_detail::to_raw_pointer(&*p)                              \
                BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _)      \
                );                                                                   \
-            used_ = true;                                                           \
+            this->used_ = true;                                                     \
          }                                                                          \
       }                                                                             \
    }                                                                                \
@@ -382,6 +398,7 @@ struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)
           base_t;                 \
    typedef typename base_t::value_type       value_type;                            \
    typedef typename base_t::difference_type  difference_type;                       \
+   typedef boost::container::allocator_traits alloc_traits;                      \
                                                                                     \
    BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)                  \
       ( A &a BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _) )          \
@@ -391,10 +408,13 @@ struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)
    virtual void copy_remaining_to(Iterator p)                                       \
    {                                                                                \
       if(!this->used_){                                                             \
-         value_type v BOOST_PP_LPAREN_IF(n)                                         \
-            BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _)                  \
-            BOOST_PP_RPAREN_IF(n);                                                  \
-         *p = boost::move(v);                                                       \
+         aligned_storage::value> v;    \
+         value_type *vp = static_cast(static_cast(&v));       \
+         alloc_traits::construct(this->a_, vp                                       \
+            BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _));       \
+         scoped_destructor d(this->a_, vp);                                      \
+         *p = boost::move(*vp);                                                     \
+         d.release();                                                               \
          this->used_ = true;                                                        \
       }                                                                             \
    }                                                                                \
@@ -405,10 +425,13 @@ struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)
       BOOST_ASSERT(division_count <=1);                                             \
       if((first_n && division_count == 1) || (!first_n && division_count == 0)){    \
          if(!this->used_){                                                          \
-            value_type v BOOST_PP_LPAREN_IF(n)                                      \
-                  BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _)            \
-                BOOST_PP_RPAREN_IF(n);                                              \
-            *p = boost::move(v);                                                    \
+            aligned_storage::value> v; \
+            value_type *vp = static_cast(static_cast(&v));    \
+            alloc_traits::construct(this->a_, vp                                    \
+               BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _));    \
+            scoped_destructor d(this->a_, vp);                                   \
+            *p = boost::move(*vp);                                                  \
+            d.release();                                                            \
             this->used_ = true;                                                     \
          }                                                                          \
       }                                                                             \
diff --git a/include/boost/container/detail/algorithms.hpp b/include/boost/container/detail/algorithms.hpp
index a2713f5..5735f4d 100644
--- a/include/boost/container/detail/algorithms.hpp
+++ b/include/boost/container/detail/algorithms.hpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (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
diff --git a/include/boost/container/detail/allocation_type.hpp b/include/boost/container/detail/allocation_type.hpp
index edad487..3988fda 100644
--- a/include/boost/container/detail/allocation_type.hpp
+++ b/include/boost/container/detail/allocation_type.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)
 //
diff --git a/include/boost/container/detail/config_begin.hpp b/include/boost/container/detail/config_begin.hpp
index bd44daa..83c2cfe 100644
--- a/include/boost/container/detail/config_begin.hpp
+++ b/include/boost/container/detail/config_begin.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)
 //
@@ -45,4 +45,5 @@
                                     //    with /GR-; unpredictable behavior may result
    #pragma warning (disable : 4673) //  throwing '' the following types will not be considered at the catch site
    #pragma warning (disable : 4671) //  the copy constructor is inaccessible
+   #pragma warning (disable : 4584) //  X is already a base-class of Y
 #endif   //BOOST_MSVC
diff --git a/include/boost/container/detail/config_end.hpp b/include/boost/container/detail/config_end.hpp
index b71fabc..3451371 100644
--- a/include/boost/container/detail/config_end.hpp
+++ b/include/boost/container/detail/config_end.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)
 //
diff --git a/include/boost/container/detail/destroyers.hpp b/include/boost/container/detail/destroyers.hpp
index 26ae089..55b811d 100644
--- a/include/boost/container/detail/destroyers.hpp
+++ b/include/boost/container/detail/destroyers.hpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (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
@@ -21,7 +21,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 namespace boost {
 namespace container { 
@@ -85,6 +85,9 @@ struct scoped_destructor_n
 
    void increment_size(size_type inc)
    {  m_n += inc;   }
+
+   void increment_size_backwards(size_type inc)
+   {  m_n += inc;   m_p -= inc;  }
    
    ~scoped_destructor_n()
    {
@@ -115,10 +118,38 @@ struct null_scoped_destructor_n
    void increment_size(size_type)
    {}
 
+   void increment_size_backwards(size_type)
+   {}
+
    void release()
    {}
 };
 
+template
+class scoped_destructor
+{
+   typedef boost::container::allocator_traits AllocTraits;
+   public:
+   typedef typename A::value_type value_type;
+   scoped_destructor(A &a, value_type *pv)
+      : pv_(pv), a_(a)
+   {}
+
+   ~scoped_destructor()
+   {
+      if(pv_){
+         AllocTraits::destroy(a_, pv_);
+      }
+   }
+
+   void release()
+   {  pv_ = 0; }
+
+   private:
+   value_type *pv_;
+   A &a_;
+};
+
 template 
 class allocator_destroyer
 {
diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp
index 4443838..1cbe8da 100644
--- a/include/boost/container/detail/flat_tree.hpp
+++ b/include/boost/container/detail/flat_tree.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)
 //
@@ -102,11 +102,19 @@ class flat_tree
       {}
 
       Data(const Data &d)
-         : value_compare(d), m_vect(d.m_vect)
+         : value_compare(static_cast(d)), m_vect(d.m_vect)
       {}
 
       Data(BOOST_RV_REF(Data) d)
-         : value_compare(boost::move(d)), m_vect(boost::move(d.m_vect))
+         : value_compare(boost::move(static_cast(d))), m_vect(boost::move(d.m_vect))
+      {}
+
+      Data(const Data &d, const A &a)
+         : value_compare(static_cast(d)), m_vect(d.m_vect, a)
+      {}
+
+      Data(BOOST_RV_REF(Data) d, const A &a)
+         : value_compare(boost::move(static_cast(d))), m_vect(boost::move(d.m_vect), a)
       {}
 
       Data(const Compare &comp) 
@@ -185,6 +193,14 @@ class flat_tree
       :  m_data(boost::move(x.m_data))
    { }
 
+   flat_tree(const flat_tree& x, const allocator_type &a) 
+      :  m_data(x.m_data, a)
+   { }
+
+   flat_tree(BOOST_RV_REF(flat_tree) x, const allocator_type &a)
+      :  m_data(boost::move(x.m_data), a)
+   { }
+
    template 
    flat_tree( ordered_range_t, InputIterator first, InputIterator last
             , const Compare& comp     = Compare()
diff --git a/include/boost/container/detail/function_detector.hpp b/include/boost/container/detail/function_detector.hpp
index c37c766..c30ed81 100644
--- a/include/boost/container/detail/function_detector.hpp
+++ b/include/boost/container/detail/function_detector.hpp
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga  2009-2011.
+// (C) Copyright Ion Gaztanaga  2009-2012.
 //
 // Distributed under the Boost Software License, Version 1.0.
 //    (See accompanying file LICENSE_1_0.txt or copy at
diff --git a/include/boost/container/detail/iterators.hpp b/include/boost/container/detail/iterators.hpp
index 899cbe4..53a3ef5 100644
--- a/include/boost/container/detail/iterators.hpp
+++ b/include/boost/container/detail/iterators.hpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (C) Copyright Ion Gaztanaga 2005-2012.
 // (C) Copyright Gennaro Prota 2003 - 2004.
 //
 // Distributed under the Boost Software License, Version 1.0.
@@ -21,7 +21,7 @@
 #include "config_begin.hpp"
 #include 
 #include 
-#include 
+#include 
 
 #ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 #include 
@@ -513,7 +513,7 @@ struct emplace_functor
    container_detail::tuple args_;
 };
 
-#else
+#else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
 #define BOOST_PP_LOCAL_MACRO(n)                                                        \
    BOOST_PP_EXPR_IF(n, template <)                                                     \
@@ -522,16 +522,16 @@ struct emplace_functor
    struct BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg)                          \
    {                                                                                   \
       BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg)                              \
-         ( BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _) )                       \
-      BOOST_PP_EXPR_IF(n, :) BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_INIT, _){}    \
+         ( BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _) )                        \
+      BOOST_PP_EXPR_IF(n, :) BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_INIT, _){}      \
                                                                                        \
       template                                                       \
       void operator()(A &a, T *ptr)                                                    \
       {                                                                                \
          allocator_traits::construct                                                \
-            (a, ptr BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _) );\
+            (a, ptr BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _) ); \
       }                                                                                \
-      BOOST_PP_REPEAT(n, BOOST_CONTAINER_PP_PARAM_DEFINE, _)                         \
+      BOOST_PP_REPEAT(n, BOOST_CONTAINER_PP_PARAM_DEFINE, _)                           \
    };                                                                                  \
    //!
 #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
diff --git a/include/boost/container/detail/math_functions.hpp b/include/boost/container/detail/math_functions.hpp
index 4613573..609e1d4 100644
--- a/include/boost/container/detail/math_functions.hpp
+++ b/include/boost/container/detail/math_functions.hpp
@@ -1,7 +1,7 @@
 //////////////////////////////////////////////////////////////////////////////
 //
 // (C) Copyright Stephen Cleary 2000.
-// (C) Copyright Ion Gaztanaga 2007-2011.
+// (C) Copyright Ion Gaztanaga 2007-2012.
 //
 // Distributed under the Boost Software License, Version 1.0.
 //    (See accompanying file LICENSE_1_0.txt or copy at 
diff --git a/include/boost/container/detail/mpl.hpp b/include/boost/container/detail/mpl.hpp
index c2d0ce4..032110a 100644
--- a/include/boost/container/detail/mpl.hpp
+++ b/include/boost/container/detail/mpl.hpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (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
diff --git a/include/boost/container/detail/multiallocation_chain.hpp b/include/boost/container/detail/multiallocation_chain.hpp
index a67fd77..c995253 100644
--- a/include/boost/container/detail/multiallocation_chain.hpp
+++ b/include/boost/container/detail/multiallocation_chain.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)
 //
diff --git a/include/boost/container/detail/node_alloc_holder.hpp b/include/boost/container/detail/node_alloc_holder.hpp
index 9b0a0a5..022a54f 100644
--- a/include/boost/container/detail/node_alloc_holder.hpp
+++ b/include/boost/container/detail/node_alloc_holder.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)
 //
@@ -27,7 +27,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
@@ -36,6 +36,7 @@
 #endif
 
 #include 
+#include 
 
 
 namespace boost {
@@ -259,47 +260,21 @@ struct node_alloc_holder
 
    void deallocate_one(const NodePtr &p, allocator_v2)
    {  this->node_alloc().deallocate_one(p);   }
-/*
-   template
-   static void construct(A &a, const NodePtr &ptr,
-      BOOST_RV_REF_2_TEMPL_ARGS(std::pair, Convertible1, Convertible2) value)
-   {
-      typedef typename Node::hook_type                hook_type;
-      typedef typename Node::value_type::first_type   first_type;
-      typedef typename Node::value_type::second_type  second_type;
-      Node *nodeptr = container_detail::to_raw_pointer(ptr);
 
-      //Hook constructor does not throw
-      allocator_traits::construct(a, static_cast(nodeptr));
-
-      //Now construct pair members_holder
-      value_type *valueptr = &nodeptr->get_data();
-      allocator_traits::construct(a, &valueptr->first, boost::move(value.first));
-      BOOST_TRY{
-         allocator_traits::construct(a, &valueptr->second, boost::move(value.second));
-      }
-      BOOST_CATCH(...){
-         allocator_traits::destroy(a, &valueptr->first);
-         BOOST_RETHROW
-      }
-      BOOST_CATCH_END
-   }
-*/
    #ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-/*
-   template
-   static void construct(A &a, const NodePtr &ptr, Args &&...args)
-   {  
-   }
-*/
+
    template
    NodePtr create_node(Args &&...args)
    {
       NodePtr p = this->allocate_one();
       Deallocator node_deallocator(p, this->node_alloc());
       allocator_traits::construct
-         (this->node_alloc(), container_detail::to_raw_pointer(p), boost::forward(args)...);
+         ( this->node_alloc()
+         , container_detail::addressof(p->m_data), boost::forward(args)...);
       node_deallocator.release();
+      //This does not throw
+      typedef typename Node::hook_type hook_type;
+      ::new(static_cast(container_detail::to_raw_pointer(p))) hook_type;
       return (p);
    }
 
@@ -313,9 +288,11 @@ struct node_alloc_holder
       NodePtr p = this->allocate_one();                                                   \
       Deallocator node_deallocator(p, this->node_alloc());                                \
       allocator_traits::construct                                              \
-         (this->node_alloc(), container_detail::to_raw_pointer(p)                         \
+         (this->node_alloc(), container_detail::addressof(p->m_data)                      \
             BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));              \
       node_deallocator.release();                                                         \
+      typedef typename Node::hook_type hook_type;                                         \
+      ::new(static_cast(container_detail::to_raw_pointer(p))) hook_type;      \
       return (p);                                                                         \
    }                                                                                      \
    //!
@@ -329,8 +306,11 @@ struct node_alloc_holder
    {
       NodePtr p = this->allocate_one();
       Deallocator node_deallocator(p, this->node_alloc());
-      ::boost::container::construct_in_place(this->node_alloc(), container_detail::to_raw_pointer(p), it);
+      ::boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->m_data), it);
       node_deallocator.release();
+      //This does not throw
+      typedef typename Node::hook_type hook_type;
+      ::new(static_cast(container_detail::to_raw_pointer(p))) hook_type;
       return (p);
    }
 
@@ -364,8 +344,11 @@ struct node_alloc_holder
                mem.pop_front();
                //This can throw
                constructed = 0;
-               boost::container::construct_in_place(this->node_alloc(), p, beg);
+               boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->m_data), beg);
                ++constructed;
+               //This does not throw
+               typedef typename Node::hook_type hook_type;
+               ::new(static_cast(container_detail::to_raw_pointer(p))) hook_type;
                //This can throw in some containers (predicate might throw)
                inserter(*p);
             }
diff --git a/include/boost/container/detail/node_pool_impl.hpp b/include/boost/container/detail/node_pool_impl.hpp
index 9ee9e31..b7fb511 100644
--- a/include/boost/container/detail/node_pool_impl.hpp
+++ b/include/boost/container/detail/node_pool_impl.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)
 //
diff --git a/include/boost/container/detail/pair.hpp b/include/boost/container/detail/pair.hpp
index 1aeff91..3c3ae38 100644
--- a/include/boost/container/detail/pair.hpp
+++ b/include/boost/container/detail/pair.hpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (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
@@ -62,6 +62,33 @@ struct pair_nat;
 struct piecewise_construct_t { };
 static const piecewise_construct_t piecewise_construct = piecewise_construct_t();
 
+/*
+template 
+struct pair
+{
+    template  pair(pair&& p);
+    template 
+        pair(piecewise_construct_t, tuple first_args,
+             tuple second_args);
+
+    template  pair& operator=(const pair& p);
+    pair& operator=(pair&& p) noexcept(is_nothrow_move_assignable::value &&
+                                       is_nothrow_move_assignable::value);
+    template  pair& operator=(pair&& p);
+
+    void swap(pair& p) noexcept(noexcept(swap(first, p.first)) &&
+                                noexcept(swap(second, p.second)));
+};
+
+template  bool operator==(const pair&, const pair&);
+template  bool operator!=(const pair&, const pair&);
+template  bool operator< (const pair&, const pair&);
+template  bool operator> (const pair&, const pair&);
+template  bool operator>=(const pair&, const pair&);
+template  bool operator<=(const pair&, const pair&);
+*/
+
+
 template 
 struct pair
 {
@@ -79,47 +106,40 @@ struct pair
    pair()
       : first(), second()
    {}
-/*
-   //pair from two values
-   pair(const T1 &t1, const T2 &t2)
-      : first(t1)
-      , second(t2)
-   {}
-
-
-   //pair from two values
-   pair(BOOST_RV_REF(T1) t1, BOOST_RV_REF(T2) t2)
-      : first(::boost::move(t1))
-      , second(::boost::move(t2))
-   {}
-*/
-   template
-   pair(BOOST_FWD_REF(U) u, BOOST_FWD_REF(V) v)
-      : first(::boost::forward(u))
-      , second(::boost::forward(v))
-   {}
 
    //pair copy assignment
    pair(const pair& x)
       : first(x.first), second(x.second)
    {}
 
-   template 
-   pair(const pair &p)
-      : first(p.first), second(p.second)
-   {}
-
    //pair move constructor
    pair(BOOST_RV_REF(pair) p)
       : first(::boost::move(p.first)), second(::boost::move(p.second))
    {}
 
    template 
-   pair(BOOST_RV_REF_2_TEMPL_ARGS(pair, D, S) p)
+   pair(const pair &p)
+      : first(p.first), second(p.second)
+   {}
+
+   template 
+   pair(BOOST_RV_REF_BEG pair BOOST_RV_REF_END p)
       : first(::boost::move(p.first)), second(::boost::move(p.second))
    {}
 
-   //std::pair copy constructor
+   //pair from two values
+   pair(const T1 &t1, const T2 &t2)
+      : first(t1)
+      , second(t2)
+   {}
+
+   template
+   pair(BOOST_FWD_REF(U) u, BOOST_FWD_REF(V) v)
+      : first(::boost::forward(u))
+      , second(::boost::forward(v))
+   {}
+
+   //And now compatibility with std::pair
    pair(const std::pair& x)
       : first(x.first), second(x.second)
    {}
@@ -129,17 +149,20 @@ struct pair
       : first(p.first), second(p.second)
    {}
 
-   //std::pair move constructor
-   template 
-   pair(BOOST_RV_REF_2_TEMPL_ARGS(std::pair, D, S) p)
+   pair(BOOST_RV_REF_BEG std::pair BOOST_RV_REF_END p)
       : first(::boost::move(p.first)), second(::boost::move(p.second))
    {}
 
-   pair(BOOST_RV_REF_2_TEMPL_ARGS(std::pair, T1, T2) p)
+   template 
+   pair(BOOST_RV_REF_BEG std::pair BOOST_RV_REF_END p)
       : first(::boost::move(p.first)), second(::boost::move(p.second))
    {}
 
    //piecewise_construct missing
+   //template  pair(pair&& p);
+   //template 
+   //   pair(piecewise_construct_t, tuple first_args,
+   //        tuple second_args);
 /*
    //Variadic versions
    template
@@ -179,14 +202,6 @@ struct pair
       return *this;
    }
 
-   template 
-   pair& operator=(const pair&p)
-   {
-      first  = p.first;
-      second = p.second;
-      return *this;
-   }
-
    //pair move assignment
    pair& operator=(BOOST_RV_REF(pair) p)
    {
@@ -196,7 +211,15 @@ struct pair
    }
 
    template 
-   pair& operator=(BOOST_RV_REF_2_TEMPL_ARGS(pair, D, S) p)
+   pair& operator=(const pair&p)
+   {
+      first  = p.first;
+      second = p.second;
+      return *this;
+   }
+
+   template 
+   pair& operator=(BOOST_RV_REF_BEG pair BOOST_RV_REF_END p)
    {
       first  = ::boost::move(p.first);
       second = ::boost::move(p.second);
@@ -220,7 +243,7 @@ struct pair
    }
 
    //std::pair move assignment
-   pair& operator=(BOOST_RV_REF_2_TEMPL_ARGS(std::pair, T1, T2) p)
+   pair& operator=(BOOST_RV_REF_BEG std::pair BOOST_RV_REF_END p)
    {
       first  = ::boost::move(p.first);
       second = ::boost::move(p.second);
@@ -228,7 +251,7 @@ struct pair
    }
 
    template 
-   pair& operator=(BOOST_RV_REF_2_TEMPL_ARGS(std::pair, D, S) p)
+   pair& operator=(BOOST_RV_REF_BEG std::pair BOOST_RV_REF_END p)
    {
       first  = ::boost::move(p.first);
       second = ::boost::move(p.second);
diff --git a/include/boost/container/detail/pool_common.hpp b/include/boost/container/detail/pool_common.hpp
index c66e2cd..500b912 100644
--- a/include/boost/container/detail/pool_common.hpp
+++ b/include/boost/container/detail/pool_common.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)
 //
diff --git a/include/boost/container/detail/preprocessor.hpp b/include/boost/container/detail/preprocessor.hpp
index 9916fba..edea7a0 100644
--- a/include/boost/container/detail/preprocessor.hpp
+++ b/include/boost/container/detail/preprocessor.hpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-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)
 //
@@ -62,6 +62,10 @@
    //!
 #endif   //#ifndef BOOST_NO_RVALUE_REFERENCES
 
+#define BOOST_CONTAINER_PP_CONST_REF_PARAM_LIST_Q(z, n, Data) \
+const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \
+//!
+
 #ifndef BOOST_NO_RVALUE_REFERENCES
    #define BOOST_CONTAINER_PP_PARAM(U, u) \
    U && u \
@@ -152,7 +156,11 @@ BOOST_PP_CAT(*this->m_p, n) \
 //!
 
 #define BOOST_CONTAINER_PP_TEMPLATE_PARAM_VOID_DEFAULT(z, n, data)   \
-  BOOST_PP_CAT(class P, n) = void                                      \
+  BOOST_PP_CAT(class P, n) = void                                    \
+//!
+
+#define BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT(z, n, default_type) \
+  BOOST_PP_CAT(class P, n) = default_type                                  \
 //!
 
 #define BOOST_CONTAINER_PP_STATIC_PARAM_REF_DECLARE(z, n, data) \
diff --git a/include/boost/container/detail/stored_ref.hpp b/include/boost/container/detail/stored_ref.hpp
index df0faa8..80fda89 100644
--- a/include/boost/container/detail/stored_ref.hpp
+++ b/include/boost/container/detail/stored_ref.hpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-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)
 //
diff --git a/include/boost/container/detail/transform_iterator.hpp b/include/boost/container/detail/transform_iterator.hpp
index 17eca9e..bc558ba 100644
--- a/include/boost/container/detail/transform_iterator.hpp
+++ b/include/boost/container/detail/transform_iterator.hpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (C) Copyright Ion Gaztanaga 2005-2012.
 // (C) Copyright Gennaro Prota 2003 - 2004.
 //
 // Distributed under the Boost Software License, Version 1.0.
diff --git a/include/boost/container/detail/tree.hpp b/include/boost/container/detail/tree.hpp
index 6cd91ed..e9a4bdd 100644
--- a/include/boost/container/detail/tree.hpp
+++ b/include/boost/container/detail/tree.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)
 //
@@ -27,7 +27,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #ifndef BOOST_CONTAINER_PERFECT_FORWARDING
 #include 
 #endif
@@ -90,43 +90,49 @@ struct rbtree_hook
       >::type  type;
 };
 
+//This trait is used to type-pun std::pair because in C++03
+//compilers std::pair is useless for C++11 features
 template
-struct rbtree_type
+struct rbtree_internal_data_type
 {
    typedef T type;
 };
 
 template
-struct rbtree_type< std::pair >
+struct rbtree_internal_data_type< std::pair >
 {
    typedef pair type;
 };
 
+
+//The node to be store in the tree
 template 
 struct rbtree_node
    :  public rbtree_hook::type
 {
-   private:
-   BOOST_COPYABLE_AND_MOVABLE(rbtree_node)
+   //private:
+   //BOOST_COPYABLE_AND_MOVABLE(rbtree_node)
 
    public:
    typedef typename rbtree_hook::type hook_type;
 
    typedef T value_type;
-   typedef typename rbtree_type::type internal_type;
+   typedef typename rbtree_internal_data_type::type internal_type;
 
    typedef rbtree_node node_type;
 
-   rbtree_node()
-      : m_data()
-   {}
+   private:
+   rbtree_node();
+   rbtree_node (const rbtree_node &);
+   rbtree_node & operator=(const rbtree_node &);
 
+/*
    rbtree_node(const rbtree_node &other)
       : m_data(other.m_data)
    {}
 
    rbtree_node(BOOST_RV_REF(rbtree_node) other)
-      : m_data(boost::move(other.m_data))
+      : m_data(::boost::move(other.m_data))
    {}
 
    #ifndef BOOST_CONTAINER_PERFECT_FORWARDING
@@ -152,8 +158,9 @@ struct rbtree_node
    {  do_assign(other.m_data);   return *this;  }
 
    rbtree_node &operator=(BOOST_RV_REF(rbtree_node) other)
-   {  do_move(other.m_data);   return *this;  }
-
+   {  do_move_assign(other.m_data);   return *this;  }
+*/
+   public:
    T &get_data()
    {
       T* ptr = reinterpret_cast(&this->m_data);
@@ -166,7 +173,7 @@ struct rbtree_node
       return *ptr;
    }
 
-   private:
+//   private:
    internal_type m_data;
 
    template
@@ -188,22 +195,22 @@ struct rbtree_node
    {  m_data = v; }
 
    template
-   void do_move(std::pair &p)
+   void do_move_assign(std::pair &p)
    {
-      const_cast(m_data.first) = boost::move(p.first);
-      m_data.second  = boost::move(p.second);
+      const_cast(m_data.first) = ::boost::move(p.first);
+      m_data.second = ::boost::move(p.second);
    }
 
    template
-   void do_move(pair &p)
+   void do_move_assign(pair &p)
    {
-      const_cast(m_data.first) = boost::move(p.first);
-      m_data.second  = boost::move(p.second);
+      const_cast(m_data.first) = ::boost::move(p.first);
+      m_data.second  = ::boost::move(p.second);
    }
 
    template
-   void do_move(V &v)
-   {  m_data = boost::move(v); }
+   void do_move_assign(V &v)
+   {  m_data = ::boost::move(v); }
 };
 
 }//namespace container_detail {
@@ -282,7 +289,7 @@ class rbtree
             //First recycle a node (this can't throw)
             try{
                //This can throw
-               *p = other;
+               p->do_assign(other.m_data);
                return p;
             }
             catch(...){
@@ -295,7 +302,7 @@ class rbtree
             }
          }
          else{
-            return m_holder.create_node(other);
+            return m_holder.create_node(other.m_data);
          }
       }
 
@@ -319,7 +326,7 @@ class rbtree
             //First recycle a node (this can't throw)
             try{
                //This can throw
-               *p = boost::move(other);
+               p->do_move_assign(const_cast(other).m_data);
                return p;
             }
             catch(...){
@@ -332,7 +339,7 @@ class rbtree
             }
          }
          else{
-            return m_holder.create_node(other);
+            return m_holder.create_node(other.m_data);
          }
       }
 
@@ -478,8 +485,10 @@ class rbtree
       iterator(){}
 
       //Pointer like operators
-      reference operator*()  const {  return  this->m_it->get_data();  }
-      pointer   operator->() const {  return  pointer(&this->m_it->get_data());  }
+      reference operator*()  const
+         {  return this->m_it->get_data();  }
+      pointer   operator->() const
+         {  return boost::intrusive::pointer_traits::pointer_to(this->m_it->get_data());  }
 
       //Increment / Decrement
       iterator& operator++()  
@@ -532,9 +541,28 @@ class rbtree
    }
 
    rbtree(BOOST_RV_REF(rbtree) x) 
-      :  AllocHolder(boost::move(static_cast(x)), x.key_comp())
+      :  AllocHolder(::boost::move(static_cast(x)), x.key_comp())
    {}
 
+   rbtree(const rbtree& x, const allocator_type &a) 
+      :  AllocHolder(a, x.key_comp())
+   {
+      this->icont().clone_from
+         (x.icont(), typename AllocHolder::cloner(*this), Destroyer(this->node_alloc()));
+   }
+
+   rbtree(BOOST_RV_REF(rbtree) x, const allocator_type &a)
+      :  AllocHolder(a, x.key_comp())
+   {
+      if(this->node_alloc() == x.node_alloc()){
+         this->icont().swap(x.icont());
+      }
+      else{
+         this->icont().clone_from
+            (x.icont(), typename AllocHolder::cloner(*this), Destroyer(this->node_alloc()));
+      }
+   }
+
    ~rbtree()
    {} //AllocHolder clears the tree
 
@@ -552,7 +580,7 @@ class rbtree
          //Transfer all the nodes to a temporary tree
          //If anything goes wrong, all the nodes will be destroyed
          //automatically
-         Icont other_tree(boost::move(this->icont()));
+         Icont other_tree(::boost::move(this->icont()));
 
          //Now recreate the source tree reusing nodes stored by other_tree
          this->icont().clone_from
@@ -578,7 +606,7 @@ class rbtree
          if(this_alloc == x_alloc){
             //Destroy and swap pointers
             this->clear();
-            this->icont() = boost::move(x.icont());
+            this->icont() = ::boost::move(x.icont());
             //Move allocator if needed
             this->AllocHolder::move_assign_alloc(x);
          }
@@ -587,7 +615,7 @@ class rbtree
             //Transfer all the nodes to a temporary tree
             //If anything goes wrong, all the nodes will be destroyed
             //automatically
-            Icont other_tree(boost::move(this->icont()));
+            Icont other_tree(::boost::move(this->icont()));
 
             //Now recreate the source tree reusing nodes stored by other_tree
             this->icont().clone_from
diff --git a/include/boost/container/detail/type_traits.hpp b/include/boost/container/detail/type_traits.hpp
index 6a0b3ed..2940f72 100644
--- a/include/boost/container/detail/type_traits.hpp
+++ b/include/boost/container/detail/type_traits.hpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 // (C) Copyright John Maddock 2000.
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (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
@@ -29,6 +29,13 @@ namespace container_detail {
 
 struct nat{};
 
+template 
+struct LowPriorityConversion
+{
+   // Convertible from T with user-defined-conversion rank.
+   LowPriorityConversion(const U&) { }
+};
+
 //boost::alignment_of yields to 10K lines of preprocessed code, so we
 //need an alternative
 template  struct alignment_of;
diff --git a/include/boost/container/detail/utilities.hpp b/include/boost/container/detail/utilities.hpp
index ee0fe99..57ce356 100644
--- a/include/boost/container/detail/utilities.hpp
+++ b/include/boost/container/detail/utilities.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)
 //
@@ -21,13 +21,23 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 namespace boost {
 namespace container {
 namespace container_detail {
 
+template 
+inline T* addressof(T& obj)
+{
+   return static_cast(
+	   static_cast(
+	      const_cast(
+            &reinterpret_cast(obj)
+   )));
+}
+
 template
 const T &max_value(const T &a, const T &b)
 {  return a > b ? a : b;   }
@@ -262,6 +272,7 @@ F uninitialized_copy_or_move_alloc
    return ::boost::container::uninitialized_copy_alloc(a, f, l, r);
 }
 
+
 }  //namespace container {
 }  //namespace boost {
 
diff --git a/include/boost/container/detail/value_init.hpp b/include/boost/container/detail/value_init.hpp
index afbc9c1..f164d21 100644
--- a/include/boost/container/detail/value_init.hpp
+++ b/include/boost/container/detail/value_init.hpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (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
diff --git a/include/boost/container/detail/variadic_templates_tools.hpp b/include/boost/container/detail/variadic_templates_tools.hpp
index f21f972..e24a2e0 100644
--- a/include/boost/container/detail/variadic_templates_tools.hpp
+++ b/include/boost/container/detail/variadic_templates_tools.hpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-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)
 //
diff --git a/include/boost/container/detail/version_type.hpp b/include/boost/container/detail/version_type.hpp
index 46344fa..aac704f 100644
--- a/include/boost/container/detail/version_type.hpp
+++ b/include/boost/container/detail/version_type.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)
 //
diff --git a/include/boost/container/detail/workaround.hpp b/include/boost/container/detail/workaround.hpp
index 45ab2f2..c444074 100644
--- a/include/boost/container/detail/workaround.hpp
+++ b/include/boost/container/detail/workaround.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)
 //
@@ -26,6 +26,11 @@
    #define BOOST_CONTAINER_NOEXCEPT_IF(x) noexcept(x)
 #endif
 
+#if !defined(BOOST_NO_VARIADIC_TEMPLATES) && defined(__GXX_EXPERIMENTAL_CXX0X__)\
+    && (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__ < 40700)
+   #define BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST
+#endif
+
 #include 
 
 #endif   //#ifndef BOOST_CONTAINER_DETAIL_WORKAROUND_HPP
diff --git a/include/boost/container/flat_map.hpp b/include/boost/container/flat_map.hpp
index 2d4515b..93429f3 100644
--- a/include/boost/container/flat_map.hpp
+++ b/include/boost/container/flat_map.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)
 //
@@ -26,7 +26,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
@@ -209,23 +209,38 @@ class flat_map
    //! Effects: Copy constructs a flat_map.
    //! 
    //! Complexity: Linear in x.size().
-   flat_map(const flat_map& x) 
+   flat_map(const flat_map& x) 
       : m_flat_tree(x.m_flat_tree) {}
 
    //! Effects: Move constructs a flat_map.
    //!   Constructs *this using x's resources.
    //! 
-   //! Complexity: Construct.
+   //! Complexity: Constant.
    //! 
    //! Postcondition: x is emptied.
    flat_map(BOOST_RV_REF(flat_map) x) 
       : m_flat_tree(boost::move(x.m_flat_tree))
    {}
 
+   //! Effects: Copy constructs a flat_map using the specified allocator.
+   //! 
+   //! Complexity: Linear in x.size().
+   flat_map(const flat_map& x, const allocator_type &a)
+      : m_flat_tree(x.m_flat_tree, a)
+   {}
+
+   //! Effects: Move constructs a flat_map using the specified allocator.
+   //!   Constructs *this using x's resources.
+   //! 
+   //! Complexity: Constant if x.get_allocator() == a, linear otherwise.
+   flat_map(BOOST_RV_REF(flat_map) x, const allocator_type &a) 
+      : m_flat_tree(boost::move(x.m_flat_tree), a)
+   {}
+
    //! Effects: Makes *this a copy of x.
    //! 
    //! Complexity: Linear in x.size().
-   flat_map& operator=(BOOST_COPY_ASSIGN_REF(flat_map) x)
+   flat_map& operator=(BOOST_COPY_ASSIGN_REF(flat_map) x)
    {  m_flat_tree = x.m_flat_tree;   return *this;  }
 
    //! Effects: Move constructs a flat_map.
@@ -234,7 +249,7 @@ class flat_map
    //! Complexity: Construct.
    //! 
    //! Postcondition: x is emptied.
-   flat_map& operator=(BOOST_RV_REF(flat_map) mx)
+   flat_map& operator=(BOOST_RV_REF(flat_map) mx)
    {  m_flat_tree = boost::move(mx.m_flat_tree);   return *this;  }
 
    //! Effects: Returns the comparison object out
@@ -960,28 +975,43 @@ class flat_multimap
    //! Effects: Copy constructs a flat_multimap.
    //! 
    //! Complexity: Linear in x.size().
-   flat_multimap(const flat_multimap& x) 
+   flat_multimap(const flat_multimap& x) 
       : m_flat_tree(x.m_flat_tree) { }
 
    //! Effects: Move constructs a flat_multimap. Constructs *this using x's resources.
    //! 
-   //! Complexity: Construct.
+   //! Complexity: Constant.
    //! 
    //! Postcondition: x is emptied.
    flat_multimap(BOOST_RV_REF(flat_multimap) x) 
       : m_flat_tree(boost::move(x.m_flat_tree))
    { }
 
+   //! Effects: Copy constructs a flat_multimap using the specified allocator.
+   //! 
+   //! Complexity: Linear in x.size().
+   flat_multimap(const flat_multimap& x, const allocator_type &a) 
+      : m_flat_tree(x.m_flat_tree, a)
+   {}
+
+   //! Effects: Move constructs a flat_multimap using the specified allocator.
+   //!                 Constructs *this using x's resources.
+   //!
+   //! Complexity: Constant if a == x.get_allocator(), linear otherwise.
+   flat_multimap(BOOST_RV_REF(flat_multimap) x, const allocator_type &a) 
+      : m_flat_tree(boost::move(x.m_flat_tree), a)
+   { }
+
    //! Effects: Makes *this a copy of x.
    //! 
    //! Complexity: Linear in x.size().
-   flat_multimap& operator=(BOOST_COPY_ASSIGN_REF(flat_multimap) x) 
+   flat_multimap& operator=(BOOST_COPY_ASSIGN_REF(flat_multimap) x) 
       {  m_flat_tree = x.m_flat_tree;   return *this;  }
 
    //! Effects: this->swap(x.get()).
    //! 
    //! Complexity: Constant.
-   flat_multimap& operator=(BOOST_RV_REF(flat_multimap) mx) 
+   flat_multimap& operator=(BOOST_RV_REF(flat_multimap) mx) 
       {  m_flat_tree = boost::move(mx.m_flat_tree);   return *this;  }
 
    //! Effects: Returns the comparison object out
diff --git a/include/boost/container/flat_set.hpp b/include/boost/container/flat_set.hpp
index f367309..e10e7be 100644
--- a/include/boost/container/flat_set.hpp
+++ b/include/boost/container/flat_set.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)
 //
@@ -100,14 +100,14 @@ class flat_set
    typedef typename tree_t::allocator_type         allocator_type;
    typedef typename tree_t::stored_allocator_type  stored_allocator_type;
 
-   //! Effects: Defatuls constructs an empty flat_map.
+   //! Effects: Default constructs an empty flat_set.
    //! 
    //! Complexity: Constant.
    explicit flat_set()
       : m_flat_tree()
    {}
 
-   //! Effects: Constructs an empty flat_map using the specified
+   //! Effects: Constructs an empty flat_set using the specified
    //! comparison object and allocator.
    //! 
    //! Complexity: Constant.
@@ -116,7 +116,7 @@ class flat_set
       : m_flat_tree(comp, a)
    {}
 
-   //! Effects: Constructs an empty map using the specified comparison object and 
+   //! Effects: Constructs an empty set using the specified comparison object and 
    //! allocator, and inserts elements from the range [first ,last ).
    //! 
    //! Complexity: Linear in N if the range [first ,last ) is already sorted using 
@@ -143,31 +143,47 @@ class flat_set
       : m_flat_tree(ordered_range, first, last, comp, a) 
    {}
 
-   //! Effects: Copy constructs a map.
+   //! Effects: Copy constructs a set.
    //! 
    //! Complexity: Linear in x.size().
-   flat_set(const flat_set& x) 
-      : m_flat_tree(x.m_flat_tree) {}
+   flat_set(const flat_set& x) 
+      : m_flat_tree(x.m_flat_tree)
+   {}
 
-   //! Effects: Move constructs a map. Constructs *this using x's resources.
+   //! Effects: Move constructs a set. Constructs *this using x's resources.
    //! 
-   //! Complexity: Construct.
+   //! Complexity: Constant.
    //! 
    //! Postcondition: x is emptied.
    flat_set(BOOST_RV_REF(flat_set) mx) 
       : m_flat_tree(boost::move(mx.m_flat_tree))
    {}
 
-   //! Effects: Makes *this a copy of x.
+   //! Effects: Copy constructs a set using the specified allocator.
    //! 
    //! Complexity: Linear in x.size().
-   flat_set& operator=(BOOST_COPY_ASSIGN_REF(flat_set) x)
-      {  m_flat_tree = x.m_flat_tree;   return *this;  }
+   flat_set(const flat_set& x, const allocator_type &a)
+      : m_flat_tree(x.m_flat_tree, a)
+   {}
+
+   //! Effects: Move constructs a set using the specified allocator.
+   //!                 Constructs *this using x's resources.
+   //! 
+   //! Complexity: Constant if a == mx.get_allocator(), linear otherwise
+   flat_set(BOOST_RV_REF(flat_set) mx, const allocator_type &a) 
+      : m_flat_tree(boost::move(mx.m_flat_tree), a)
+   {}
 
    //! Effects: Makes *this a copy of x.
    //! 
    //! Complexity: Linear in x.size().
-   flat_set& operator=(BOOST_RV_REF(flat_set) mx)
+   flat_set& operator=(BOOST_COPY_ASSIGN_REF(flat_set) x)
+      {  m_flat_tree = x.m_flat_tree;   return *this;  }
+
+   //! Effects: Makes *this a copy of the previous value of xx.
+   //! 
+   //! Complexity: Linear in x.size().
+   flat_set& operator=(BOOST_RV_REF(flat_set) mx)
    {  m_flat_tree = boost::move(mx.m_flat_tree);   return *this;  }
 
    //! Effects: Returns the comparison object out
@@ -729,7 +745,7 @@ class flat_multiset
    typedef typename tree_t::allocator_type         allocator_type;
    typedef typename tree_t::stored_allocator_type  stored_allocator_type;
 
-   //! Effects: Defatuls constructs an empty flat_map.
+   //! Effects: Default constructs an empty flat_multiset.
    //! 
    //! Complexity: Constant.
    explicit flat_multiset()
@@ -761,17 +777,47 @@ class flat_multiset
       : m_flat_tree(ordered_range, first, last, comp, a) 
    {}
 
-   flat_multiset(const flat_multiset& x) 
-      : m_flat_tree(x.m_flat_tree) {}
-
-   flat_multiset(BOOST_RV_REF(flat_multiset) x) 
-      : m_flat_tree(boost::move(x.m_flat_tree))
+   //! Effects: Copy constructs a flat_multiset.
+   //! 
+   //! Complexity: Linear in x.size().
+   flat_multiset(const flat_multiset& x) 
+      : m_flat_tree(x.m_flat_tree)
    {}
 
-   flat_multiset& operator=(BOOST_COPY_ASSIGN_REF(flat_multiset) x) 
+   //! Effects: Move constructs a flat_multiset. Constructs *this using x's resources.
+   //! 
+   //! Complexity: Constant.
+   //! 
+   //! Postcondition: x is emptied.
+   flat_multiset(BOOST_RV_REF(flat_multiset) mx) 
+      : m_flat_tree(boost::move(mx.m_flat_tree))
+   {}
+
+   //! Effects: Copy constructs a flat_multiset using the specified allocator.
+   //! 
+   //! Complexity: Linear in x.size().
+   flat_multiset(const flat_multiset& x, const allocator_type &a)
+      : m_flat_tree(x.m_flat_tree, a)
+   {}
+
+   //! Effects: Move constructs a flat_multiset using the specified allocator.
+   //!                 Constructs *this using x's resources.
+   //! 
+   //! Complexity: Constant if a == mx.get_allocator(), linear otherwise
+   flat_multiset(BOOST_RV_REF(flat_multiset) mx, const allocator_type &a) 
+      : m_flat_tree(boost::move(mx.m_flat_tree), a)
+   {}
+
+   //! Effects: Makes *this a copy of x.
+   //! 
+   //! Complexity: Linear in x.size().
+   flat_multiset& operator=(BOOST_COPY_ASSIGN_REF(flat_multiset) x) 
       {  m_flat_tree = x.m_flat_tree;   return *this;  }
 
-   flat_multiset& operator=(BOOST_RV_REF(flat_multiset) mx) 
+   //! Effects: Makes *this a copy of x.
+   //! 
+   //! Complexity: Linear in x.size().
+   flat_multiset& operator=(BOOST_RV_REF(flat_multiset) mx) 
    {  m_flat_tree = boost::move(mx.m_flat_tree);   return *this;  }
 
    //! Effects: Returns the comparison object out
diff --git a/include/boost/container/list.hpp b/include/boost/container/list.hpp
index 6df999b..512835a 100644
--- a/include/boost/container/list.hpp
+++ b/include/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)
 //
@@ -65,30 +65,13 @@ template 
 struct list_node
    :  public list_hook::type
 {
+   private:
+   list_node();
+   list_node(const list_node &);
+   list_node & operator=(const list_node &);
 
-   list_node()
-      : m_data()
-   {}
-   #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-   template
-   list_node(Args &&...args)
-      : m_data(boost::forward(args)...)
-   {}
-
-   #else //#ifndef BOOST_CONTAINER_PERFECT_FORWARDING
-
-   #define BOOST_PP_LOCAL_MACRO(n)                                                           \
-   template                                                \
-   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::type hook_type;
    T m_data;
 };
 
@@ -374,6 +357,34 @@ class list
       : AllocHolder(boost::move(static_cast(x)))
    {}
 
+   //! Effects: Copy constructs a list using the specified allocator.
+   //!
+   //! Postcondition: x == *this.
+   //! 
+   //! Throws: If allocator_type's default constructor or copy constructor throws.
+   //! 
+   //! Complexity: Linear to the elements x contains.
+   list(const list& x, const allocator_type &a) 
+      : AllocHolder(a)
+   {  this->insert(this->cbegin(), x.begin(), x.end());   }
+
+   //! Effects: Move constructor sing the specified allocator.
+   //!                 Moves mx's resources to *this.
+   //!
+   //! Throws: If allocation or value_type's copy constructor throws.
+   //! 
+   //! Complexity: 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());
+      }
+   }
+
    //! Effects: Constructs a list that will use a copy of allocator a
    //!   and inserts a copy of the range [first, last) in the list.
    //!
diff --git a/include/boost/container/map.hpp b/include/boost/container/map.hpp
index 8f7ecd4..25403e0 100644
--- a/include/boost/container/map.hpp
+++ b/include/boost/container/map.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)
 //
@@ -158,7 +158,7 @@ class map
       : m_tree(first, last, comp, a, true) 
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename     A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
    }
 
    //! Effects: Constructs an empty map using the specified comparison object and 
@@ -175,29 +175,52 @@ class map
       : m_tree(ordered_range, first, last, comp, a) 
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename     A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
    }
 
    //! Effects: Copy constructs a map.
    //! 
    //! Complexity: Linear in x.size().
-   map(const map& x) 
+   map(const map& x) 
       : m_tree(x.m_tree)
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename     A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
    }
 
    //! Effects: Move constructs a map. Constructs *this using x's resources.
    //! 
-   //! Complexity: Construct.
+   //! Complexity: Constant.
    //! 
    //! Postcondition: x is emptied.
    map(BOOST_RV_REF(map) x) 
       : m_tree(boost::move(x.m_tree))
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename     A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+   }
+
+   //! Effects: Copy constructs a map using the specified allocator.
+   //! 
+   //! Complexity: Linear in x.size().
+   map(const map& x, const allocator_type &a) 
+      : m_tree(x.m_tree, a)
+   {
+      //Allocator type must be std::pair
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+   }
+
+   //! Effects: Move constructs a map using the specified allocator.
+   //!                 Constructs *this using x's resources.
+   //!
+   //! Complexity: Constant if x == x.get_allocator(), linear otherwise.
+   //! 
+   //! Postcondition: x is emptied.
+   map(BOOST_RV_REF(map) x, const allocator_type &a) 
+      : m_tree(boost::move(x.m_tree), a)
+   {
+      //Allocator type must be std::pair
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
    }
 
    //! Effects: Makes *this a copy of x.
@@ -833,7 +856,7 @@ class multimap
       : m_tree(comp, a)
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename     A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
    }
 
    //! Effects: Constructs an empty multimap using the specified comparison object
@@ -848,7 +871,7 @@ class multimap
       : m_tree(first, last, comp, a, false) 
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename     A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
    }
 
    //! Effects: Constructs an empty multimap using the specified comparison object and 
@@ -864,27 +887,48 @@ class multimap
       : m_tree(ordered_range, first, last, comp, a) 
    {}
 
-
    //! Effects: Copy constructs a multimap.
    //! 
    //! Complexity: Linear in x.size().
-   multimap(const multimap& x) 
+   multimap(const multimap& x) 
       : m_tree(x.m_tree)
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename     A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
    }
 
    //! Effects: Move constructs a multimap. Constructs *this using x's resources.
    //! 
-   //! Complexity: Construct.
+   //! Complexity: Constant.
    //! 
    //! Postcondition: x is emptied.
    multimap(BOOST_RV_REF(multimap) x) 
       : m_tree(boost::move(x.m_tree))
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename     A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+   }
+
+   //! Effects: Copy constructs a multimap.
+   //! 
+   //! Complexity: Linear in x.size().
+   multimap(const multimap& x, const allocator_type &a) 
+      : m_tree(x.m_tree, a)
+   {
+      //Allocator type must be std::pair
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+   }
+
+   //! Effects: Move constructs a multimap using the specified allocator.
+   //!                 Constructs *this using x's resources.
+   //! Complexity: Constant if a == x.get_allocator(), linear otherwise.
+   //! 
+   //! Postcondition: x is emptied.
+   multimap(BOOST_RV_REF(multimap) x, const allocator_type &a)
+      : m_tree(boost::move(x.m_tree), a)
+   {
+      //Allocator type must be std::pair
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
    }
 
    //! Effects: Makes *this a copy of x.
diff --git a/include/boost/container/set.hpp b/include/boost/container/set.hpp
index b25e701..ef3d989 100644
--- a/include/boost/container/set.hpp
+++ b/include/boost/container/set.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)
 //
@@ -144,16 +144,31 @@ class set
 
    //! Effects: Move constructs a set. Constructs *this using x's resources.
    //! 
-   //! Complexity: Construct.
+   //! Complexity: Constant.
    //! 
    //! Postcondition: x is emptied.
    set(BOOST_RV_REF(set) x) 
       : m_tree(boost::move(x.m_tree))
    {}
 
-   //! Effects: Makes *this a copy of x.
+   //! Effects: Copy constructs a set using the specified allocator.
    //! 
    //! Complexity: Linear in x.size().
+   set(const set& x, const allocator_type &a) 
+      : m_tree(x.m_tree, a)
+   {}
+
+   //! Effects: Move constructs a set using the specified allocator.
+   //!                 Constructs *this using x's resources.
+   //!
+   //! Complexity: Constant if a == x.get_allocator(), linear otherwise.
+   set(BOOST_RV_REF(set) x, const allocator_type &a) 
+      : m_tree(boost::move(x.m_tree), a)
+   {}
+
+   //! Effects: Makes *this a copy of x.
+   //!
+   //! Complexity: Linear in x.size().
    set& operator=(BOOST_COPY_ASSIGN_REF(set) x)
    {  m_tree = x.m_tree;   return *this;  }
 
@@ -716,13 +731,30 @@ class multiset
 
    //! Effects: Move constructs a multiset. Constructs *this using x's resources.
    //! 
-   //! Complexity: Construct.
+   //! Complexity: Constant.
    //! 
    //! Postcondition: x is emptied.
    multiset(BOOST_RV_REF(multiset) x) 
       : m_tree(boost::move(x.m_tree))
    {}
 
+   //! Effects: Copy constructs a multiset using the specified allocator.
+   //! 
+   //! Complexity: Linear in x.size().
+   multiset(const multiset& x, const allocator_type &a) 
+      : m_tree(x.m_tree, a)
+   {}
+
+   //! Effects: Move constructs a multiset using the specified allocator.
+   //!                 Constructs *this using x's resources.
+   //! 
+   //! Complexity: Constant if a == x.get_allocator(), linear otherwise.
+   //! 
+   //! Postcondition: x is emptied.
+   multiset(BOOST_RV_REF(multiset) x, const allocator_type &a) 
+      : m_tree(boost::move(x.m_tree), a)
+   {}
+
    //! Effects: Makes *this a copy of x.
    //! 
    //! Complexity: Linear in x.size().
diff --git a/include/boost/container/slist.hpp b/include/boost/container/slist.hpp
index 1cdcdf1..3146c0f 100644
--- a/include/boost/container/slist.hpp
+++ b/include/boost/container/slist.hpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-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)
 //
@@ -65,31 +65,13 @@ template 
 struct slist_node
    :  public slist_hook::type
 {
+   private:
+   slist_node();
+   slist_node(const slist_node &);
+   slist_node & operator=(const slist_node &);
 
-   slist_node()
-      : m_data()
-   {}
-
-   #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-   template
-   slist_node(Args &&...args)
-      : m_data(boost::forward(args)...)
-   {}
-
-   #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-
-   #define BOOST_PP_LOCAL_MACRO(n)                                      \
-   template                           \
-   slist_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//#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-
+   public:
+   typedef typename slist_hook::type hook_type;
    T m_data;
 };
 
@@ -391,6 +373,34 @@ class slist
       : AllocHolder(boost::move(static_cast(x)))
    {}
 
+   //! Effects: Copy constructs a list using the specified allocator.
+   //!
+   //! Postcondition: x == *this.
+   //! 
+   //! Throws: If allocator_type's default constructor or copy constructor throws.
+   //! 
+   //! Complexity: Linear to the elements x contains.
+   slist(const slist& x, const allocator_type &a) 
+      : AllocHolder(a)
+   { this->insert_after(this->before_begin(), x.begin(), x.end()); }
+
+   //! Effects: Move constructor using the specified allocator.
+   //!                 Moves x's resources to *this.
+   //!
+   //! Throws: If allocation or value_type's copy constructor throws.
+   //! 
+   //! Complexity: Constant if a == x.get_allocator(), linear otherwise.
+   slist(BOOST_RV_REF(slist) 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());
+      }
+   }
+
    //! Effects: Makes *this contain the same elements as x.
    //!
    //! Postcondition: this->size() == x.size(). *this contains a copy 
diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp
index 851b5f2..2d15f46 100644
--- a/include/boost/container/stable_vector.hpp
+++ b/include/boost/container/stable_vector.hpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-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)
 //
@@ -34,7 +34,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 #include 
@@ -78,10 +78,6 @@ struct smart_ptr_type
    {  return ptr;}
 };
 
-template
-inline typename smart_ptr_type::pointer to_raw_pointer(const Ptr &ptr)
-{  return smart_ptr_type::get(ptr);   }
-
 template 
 class clear_on_destroy
 {
@@ -110,13 +106,10 @@ class clear_on_destroy
 
 template
 struct node_type_base
-{/*
-   node_type_base(VoidPtr p)
-      : up(p)
-   {}*/
+{
    node_type_base()
    {}
-   void set_pointer(VoidPtr p)
+   void set_pointer(const VoidPtr &p)
    {  up = p; }
 
    VoidPtr up;
@@ -126,33 +119,12 @@ template
 struct node_type
    : public node_type_base
 {
-   node_type()
-      : value()
-   {}
-
-   #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-   template
-   node_type(Args &&...args)
-      : value(boost::forward(args)...)
-   {}
-
-   #else //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, >)    \
-   node_type(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                             \
-      : value(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//BOOST_CONTAINER_PERFECT_FORWARDING
-   
-   void set_pointer(VoidPointer p)
-   {  node_type_base::set_pointer(p); }
+   private:
+   node_type();
+   node_type(const node_type &);
+   node_type & operator=(const node_type &);
 
+   public:
    T value;
 };
 
@@ -206,17 +178,17 @@ class iterator
    private:
    static node_type_ptr_t node_ptr_cast(const void_ptr &p)
    {
-      return node_type_ptr_t(static_cast(stable_vector_detail::to_raw_pointer(p)));
+      return node_type_ptr_t(static_cast(container_detail::to_raw_pointer(p)));
    }
 
    static const_node_type_ptr_t node_ptr_cast(const const_void_ptr &p)
    {
-      return const_node_type_ptr_t(static_cast(stable_vector_detail::to_raw_pointer(p)));
+      return const_node_type_ptr_t(static_cast(container_detail::to_raw_pointer(p)));
    }
 
    static void_ptr_ptr void_ptr_ptr_cast(const void_ptr &p)
    {
-      return void_ptr_ptr(static_cast(stable_vector_detail::to_raw_pointer(p)));
+      return void_ptr_ptr(static_cast(container_detail::to_raw_pointer(p)));
    }
 
    reference dereference() const
@@ -353,35 +325,37 @@ BOOST_JOIN(check_invariant_,__LINE__).touch();
 
 /// @endcond
 
-//!Originally developed by Joaquin M. Lopez Munoz, stable_vector is std::vector
-//!drop-in replacement implemented as a node container, offering iterator and reference
-//!stability.
+//! Originally developed by Joaquin M. Lopez Munoz, stable_vector is std::vector
+//! drop-in replacement implemented as a node container, offering iterator and reference
+//! stability.
 //!
-//!More details taken the author's blog: ( Introducing stable_vector)
+//! More details taken the author's blog:
+//! ( 
+//! Introducing stable_vector)
 //!
-//!We present stable_vector, a fully STL-compliant stable container that provides
-//!most of the features of std::vector except element contiguity. 
+//! We present stable_vector, a fully STL-compliant stable container that provides
+//! most of the features of std::vector except element contiguity. 
 //!
-//!General properties: stable_vector satisfies all the requirements of a container,
-//!a reversible container and a sequence and provides all the optional operations
-//!present in std::vector. Like std::vector,  iterators are random access.
-//!stable_vector does not provide element contiguity; in exchange for this absence,
-//!the container is stable, i.e. references and iterators to an element of a stable_vector
-//!remain valid as long as the element is not erased, and an iterator that has been
-//!assigned the return value of end() always remain valid until the destruction of
-//!the associated  stable_vector.
+//! General properties: stable_vector satisfies all the requirements of a container,
+//! a reversible container and a sequence and provides all the optional operations
+//! present in std::vector. Like std::vector,  iterators are random access.
+//! stable_vector does not provide element contiguity; in exchange for this absence,
+//! the container is stable, i.e. references and iterators to an element of a stable_vector
+//! remain valid as long as the element is not erased, and an iterator that has been
+//! assigned the return value of end() always remain valid until the destruction of
+//! the associated  stable_vector.
 //!
-//!Operation complexity: The big-O complexities of stable_vector operations match
-//!exactly those of std::vector. In general, insertion/deletion is constant time at
-//!the end of the sequence and linear elsewhere. Unlike std::vector, stable_vector
-//!does not internally perform any value_type destruction, copy or assignment
-//!operations other than those exactly corresponding to the insertion of new
-//!elements or deletion of stored elements, which can sometimes compensate in terms
-//!of performance for the extra burden of doing more pointer manipulation and an
-//!additional allocation per element.
+//! Operation complexity: The big-O complexities of stable_vector operations match
+//! exactly those of std::vector. In general, insertion/deletion is constant time at
+//! the end of the sequence and linear elsewhere. Unlike std::vector, stable_vector
+//! does not internally perform any value_type destruction, copy or assignment
+//! operations other than those exactly corresponding to the insertion of new
+//! elements or deletion of stored elements, which can sometimes compensate in terms
+//! of performance for the extra burden of doing more pointer manipulation and an
+//! additional allocation per element.
 //!
-//!Exception safety: As stable_vector does not internally copy elements around, some
-//!operations provide stronger exception safety guarantees than in std::vector:
+//! Exception safety: As stable_vector does not internally copy elements around, some
+//! operations provide stronger exception safety guarantees than in std::vector:
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
 template  >
 #else
@@ -524,7 +498,7 @@ class stable_vector
    //! Throws: If allocator_type's copy constructor throws.
    //! 
    //! Complexity: Constant.
-   explicit stable_vector(const A& al)
+   explicit stable_vector(const allocator_type& al)
       : internal_data(al),impl(al)
    {
       STABLE_VECTOR_CHECK_INVARIANT;
@@ -538,7 +512,7 @@ class stable_vector
    //! 
    //! Complexity: Linear to n.
    explicit stable_vector(size_type n)
-      : internal_data(A()),impl(A())
+      : internal_data(),impl()
    {
       stable_vector_detail::clear_on_destroy cod(*this);
       this->resize(n);
@@ -553,7 +527,7 @@ class stable_vector
    //!   throws or T's default or copy constructor throws.
    //! 
    //! Complexity: Linear to n.
-   stable_vector(size_type n, const T& t, const A& al=A())
+   stable_vector(size_type n, const T& t, const allocator_type& al = allocator_type())
       : internal_data(al),impl(al)
    {
       stable_vector_detail::clear_on_destroy cod(*this);
@@ -570,7 +544,7 @@ class stable_vector
    //!
    //! Complexity: Linear to the range [first, last).
    template 
-   stable_vector(InputIterator first,InputIterator last,const A& al=A())
+   stable_vector(InputIterator first,InputIterator last, const allocator_type& al = allocator_type())
       : internal_data(al),impl(al)
    {
       stable_vector_detail::clear_on_destroy cod(*this);
@@ -607,6 +581,40 @@ class stable_vector
       this->priv_swap_members(x);
    }
 
+   //! Effects: Copy constructs a stable_vector using the specified allocator.
+   //!
+   //! Postcondition: x == *this.
+   //! 
+   //! Complexity: Linear to the elements x contains.
+   stable_vector(const stable_vector& x, const allocator_type &a)
+      : internal_data(a), impl(a)
+   {
+      stable_vector_detail::clear_on_destroy cod(*this);
+      this->insert(this->cbegin(), x.begin(), x.end());
+      STABLE_VECTOR_CHECK_INVARIANT;
+      cod.release();
+   }
+
+   //! Effects: Move constructor using the specified allocator.
+   //!                 Moves mx's resources to *this.
+   //!
+   //! Throws: If allocator_type's copy constructor throws.
+   //! 
+   //! Complexity: Constant if a == x.get_allocator(), linear otherwise
+   stable_vector(BOOST_RV_REF(stable_vector) x, const allocator_type &a)
+      : internal_data(a), impl(a)
+   {
+      if(this->node_alloc() == x.node_alloc()){
+         this->priv_swap_members(x);
+      }
+      else{
+         stable_vector_detail::clear_on_destroy cod(*this);
+         this->insert(this->cbegin(), x.begin(), x.end());
+         STABLE_VECTOR_CHECK_INVARIANT;
+         cod.release();
+      }
+   }
+
    //! Effects: Destroys the stable_vector. All stored values are destroyed
    //!   and used memory is deallocated.
    //!
@@ -709,7 +717,7 @@ class stable_vector
    //! Throws: If allocator's copy constructor throws.
    //! 
    //! Complexity: Constant.
-   allocator_type get_allocator()const  {return node_alloc();}
+   allocator_type get_allocator()const  {return this->node_alloc();}
 
    //! Effects: Returns a reference to the internal allocator.
    //! 
@@ -1137,7 +1145,7 @@ class stable_vector
    void emplace_back(Args &&...args)
    {
       typedef emplace_functor         EmplaceFunctor;
-      typedef emplace_iterator EmplaceIterator;
+      typedef emplace_iterator EmplaceIterator;
       EmplaceFunctor &&ef = EmplaceFunctor(boost::forward(args)...);
       this->insert(this->cend(), EmplaceIterator(ef), EmplaceIterator());
    }
@@ -1157,7 +1165,7 @@ class stable_vector
       //Just call more general insert(pos, size, value) and return iterator
       size_type pos_n = position - cbegin();
       typedef emplace_functor         EmplaceFunctor;
-      typedef emplace_iterator EmplaceIterator;
+      typedef emplace_iterator EmplaceIterator;
       EmplaceFunctor &&ef = EmplaceFunctor(boost::forward(args)...);
       this->insert(position, EmplaceIterator(ef), EmplaceIterator());
       return iterator(this->begin() + pos_n);
@@ -1172,7 +1180,7 @@ class stable_vector
       typedef BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg)                               \
          BOOST_PP_EXPR_IF(n, <) BOOST_PP_ENUM_PARAMS(n, P) BOOST_PP_EXPR_IF(n, >)               \
             EmplaceFunctor;                                                                     \
-      typedef emplace_iterator  EmplaceIterator;  \
+      typedef emplace_iterator  EmplaceIterator;   \
       EmplaceFunctor ef BOOST_PP_LPAREN_IF(n)                                                   \
                         BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)                   \
                         BOOST_PP_RPAREN_IF(n);                                                  \
@@ -1186,7 +1194,7 @@ class stable_vector
       typedef BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg)                               \
          BOOST_PP_EXPR_IF(n, <) BOOST_PP_ENUM_PARAMS(n, P) BOOST_PP_EXPR_IF(n, >)               \
             EmplaceFunctor;                                                                     \
-      typedef emplace_iterator  EmplaceIterator;  \
+      typedef emplace_iterator  EmplaceIterator;   \
       EmplaceFunctor ef BOOST_PP_LPAREN_IF(n)                                                   \
                         BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)                   \
                         BOOST_PP_RPAREN_IF(n);                                                  \
@@ -1482,12 +1490,12 @@ class stable_vector
 
    static node_type_ptr_t node_ptr_cast(const void_ptr &p)
    {
-      return node_type_ptr_t(static_cast(stable_vector_detail::to_raw_pointer(p)));
+      return node_type_ptr_t(static_cast(container_detail::to_raw_pointer(p)));
    }
 
    static node_type_base_ptr_t node_base_ptr_cast(const void_ptr &p)
    {
-      return node_type_base_ptr_t(static_cast(stable_vector_detail::to_raw_pointer(p)));
+      return node_type_base_ptr_t(static_cast(container_detail::to_raw_pointer(p)));
    }
 
    static value_type& value(const void_ptr &p)
@@ -1529,7 +1537,9 @@ class stable_vector
    {
       node_type_ptr_t p = this->allocate_one();
       try{
-         boost::container::construct_in_place(this->node_alloc(), &*p, it);
+         boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->value), it);
+         //This does not throw
+         ::new(static_cast(container_detail::to_raw_pointer(p))) node_type_base_t;
          p->set_pointer(up);
       }
       catch(...){
@@ -1621,7 +1631,9 @@ class stable_vector
             p = mem.front();
             mem.pop_front();
             //This can throw
-            boost::container::construct_in_place(this->node_alloc(), &*p, first);
+            boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->value), first);
+            //This does not throw
+            ::new(static_cast(container_detail::to_raw_pointer(p))) node_type_base_t;
             p->set_pointer(void_ptr_ptr(&it[i]));
             ++first;
             it[i] = p;
@@ -1650,7 +1662,9 @@ class stable_vector
                break;
             }
             //This can throw
-            boost::container::construct_in_place(this->node_alloc(), &*p, first);
+            boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->value), first);
+            //This does not throw
+            ::new(static_cast(container_detail::to_raw_pointer(p))) node_type_base_t;
             p->set_pointer(void_ptr_ptr(&it[i]));
             ++first;
             it[i]=p;
diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp
index 3a9c55a..5821f02 100644
--- a/include/boost/container/string.hpp
+++ b/include/boost/container/string.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)
 //
@@ -43,7 +43,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -620,12 +620,12 @@ class basic_string
    //!
    //! Postcondition: x == *this.
    //! 
-   //! Throws: If allocator_type's default constructor or copy constructor throws.
+   //! Throws: If allocator_type's default constructor throws.
    basic_string(const basic_string& s) 
       :  base_t(allocator_traits_type::select_on_container_copy_construction(s.alloc()))
    { this->priv_range_initialize(s.begin(), s.end()); }
 
-   //! Effects: Move constructor. Moves mx's resources to *this.
+   //! Effects: Move constructor. Moves s's resources to *this.
    //!
    //! Throws: If allocator_type's copy constructor throws.
    //! 
@@ -634,6 +634,32 @@ class basic_string
       : base_t(boost::move((base_t&)s))
    {}
 
+   //! Effects: Copy constructs a basic_string using the specified allocator.
+   //!
+   //! Postcondition: x == *this.
+   //! 
+   //! Throws: If allocation throws.
+   basic_string(const basic_string& s, const allocator_type &a) 
+      :  base_t(a)
+   { this->priv_range_initialize(s.begin(), s.end()); }
+
+   //! Effects: Move constructor using the specified allocator.
+   //!                 Moves s's resources to *this.
+   //!
+   //! Throws: If allocation throws.
+   //! 
+   //! Complexity: Constant if a == s.get_allocator(), linear otherwise.
+   basic_string(BOOST_RV_REF(basic_string) s, const allocator_type &a) 
+      : base_t(a)
+   {
+      if(a == this->alloc()){
+         this->swap_data(s);
+      }
+      else{
+         this->priv_range_initialize(s.begin(), s.end());
+      }
+   }
+
    //! Effects: Constructs a basic_string taking the allocator as parameter,
    //!   and is initialized by a specific number of characters of the s string. 
    basic_string(const basic_string& s, size_type pos, size_type n = npos,
diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp
index 742d00d..66e86ee 100644
--- a/include/boost/container/vector.hpp
+++ b/include/boost/container/vector.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)
 //
@@ -38,7 +38,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -46,6 +46,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace boost {
 namespace container {
@@ -540,6 +541,40 @@ class vector : private container_detail::vector_alloc_holder
       :  base_t(boost::move(mx.alloc()))
    {  this->swap_members(mx);   }
 
+   //! Effects: Copy constructs a vector using the specified allocator.
+   //!
+   //! Postcondition: x == *this.
+   //! 
+   //! Throws: If allocation
+   //!   throws or T's copy constructor throws.
+   //! 
+   //! Complexity: Linear to the elements x contains.
+   vector(const vector &x, const allocator_type &a) 
+      :  base_t(a)
+   {
+      this->assign( container_detail::to_raw_pointer(x.members_.m_start)
+                  , container_detail::to_raw_pointer(x.members_.m_start + x.members_.m_size));
+   }
+
+   //! Effects: Move constructor using the specified allocator.
+   //!                 Moves mx's resources to *this if a == allocator_type().
+   //!                 Otherwise copies values from x to *this.
+   //!
+   //! Throws: If allocation or T's copy constructor throws.
+   //! 
+   //! Complexity: Constant if a == mx.get_allocator(), linear otherwise.
+   vector(BOOST_RV_REF(vector) mx, const allocator_type &a)
+      :  base_t(a)
+   {
+      if(mx.alloc() == a){
+         this->swap_members(mx);
+      }
+      else{
+         this->assign( container_detail::to_raw_pointer(mx.members_.m_start)
+                     , container_detail::to_raw_pointer(mx.members_.m_start + mx.members_.m_size));
+      }
+   }
+
    //! Effects: Constructs a vector that will use a copy of allocator a
    //!   and inserts a copy of the range [first, last) in the vector.
    //!
@@ -1428,6 +1463,87 @@ class vector : private container_detail::vector_alloc_holder
       }
    }
 
+   private:
+   template
+   void insert_at_ordered_positions(const size_type *positions, size_type element_count, BiDirIt end)
+   {
+      const size_type old_size_pos = this->size();
+      this->reserve(old_size_pos + element_count);
+      T* const begin_ptr = container_detail::to_raw_pointer(this->members_.m_start);
+      size_type insertions_left = element_count;
+      size_type next_pos = old_size_pos;
+      size_type hole_size = element_count;
+
+      //Exception rollback. If any copy throws before the hole is filled, values
+      //already inserted/copied at the end of the buffer will be destroyed.
+      typename value_traits::ArrayDestructor past_hole_values_destroyer
+         (begin_ptr + old_size_pos + element_count, this->alloc(), size_type(0u));
+      //Loop for each insertion backwards, first moving the elements after the insertion point,
+      //then inserting the element.
+      while(insertions_left){
+         const size_type pos = positions[insertions_left - 1];
+         BOOST_ASSERT(pos <= old_size_pos);
+         //Shift the range after the insertion point, function will take care if the shift
+         //crosses the size() boundary, using copy/move or uninitialized copy/move if necessary.
+         size_type new_hole_size = shift_range(pos, next_pos, this->size(), insertions_left);
+         if(new_hole_size > 0){
+            //The hole was reduced by shift_range so expand exception rollback range backwards
+            past_hole_values_destroyer.increment_size_backwards(next_pos - pos);
+            //Insert the new value in the hole
+            allocator_traits_type::construct(this->alloc(), begin_ptr + pos + insertions_left - 1, *(--end));
+            --new_hole_size;
+            if(new_hole_size == 0){
+               //Hole was just filled, disable exception rollback and change vector size
+               past_hole_values_destroyer.release();
+               this->members_.m_size += element_count;
+            }
+            else{
+               //The hole was reduced by the new insertion by one
+               past_hole_values_destroyer.increment_size_backwards(size_type(1u));
+            }
+         }
+         else{
+            if(hole_size){
+               //Hole was just filled by shift_range, disable exception rollback and change vector size
+               past_hole_values_destroyer.release();
+               this->members_.m_size += element_count;
+            }
+            //Insert the new value in the already constructed range
+            begin_ptr[pos + insertions_left - 1] = *(--end);
+         }
+         --insertions_left;
+         hole_size = new_hole_size;
+         next_pos = pos;
+      }
+   }
+
+   size_type shift_range(size_type first_pos, size_type last_pos, size_type limit_pos, size_type shift_count)
+   {
+      BOOST_ASSERT(first_pos <= last_pos);
+      BOOST_ASSERT(last_pos <= limit_pos);
+      //
+      T* const begin_ptr = container_detail::to_raw_pointer(this->members_.m_start);
+
+      size_type hole_size = 0;
+      if((last_pos + shift_count) < limit_pos){
+         //All inside
+         boost::move_backward(begin_ptr + first_pos, begin_ptr + last_pos, begin_ptr + last_pos + shift_count);
+      }
+      else if((first_pos + shift_count) >= limit_pos){
+         //All outside
+         ::boost::container::uninitialized_move_alloc
+            (this->alloc(), begin_ptr + first_pos, begin_ptr + last_pos, begin_ptr + first_pos + shift_count);
+         hole_size = last_pos + shift_count - limit_pos;
+      }
+      else{
+         ::boost::container::uninitialized_move_alloc
+            (this->alloc(), begin_ptr + limit_pos - shift_count, begin_ptr + last_pos, begin_ptr + limit_pos);
+         boost::move_backward(begin_ptr + first_pos, begin_ptr + limit_pos - shift_count, begin_ptr + limit_pos + shift_count);
+      }
+      return hole_size;
+   }
+
+   private:
    void priv_range_insert_expand_forward(T* pos, size_type n, advanced_insert_aux_int_t &interf)
    {
       //n can't be 0, because there is nothing to do in that case

From 82fefee743bcb2449d011a5bb9384282d36177cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Thu, 22 Mar 2012 18:48:57 +0000
Subject: [PATCH 12/93] Experimental scoped_allocator support

[SVN r77481]
---
 doc/Jamfile.v2                              |    4 +-
 doc/container.qbk                           |   12 +-
 example/doc_emplace.cpp                     |    2 +-
 example/doc_move_containers.cpp             |    2 +-
 example/doc_recursive_containers.cpp        |    2 +-
 example/doc_type_erasure.cpp                |    2 +-
 index.html                                  |    2 +-
 proj/to-do.txt                              |   17 +-
 proj/vc7ide/container.sln                   |    8 +
 proj/vc7ide/container.vcproj                |   22 +-
 proj/vc7ide/scoped_allocator_adaptor.vcproj |  139 ++
 test/allocator_traits_test.cpp              |    4 +-
 test/deque_test.cpp                         |    2 +-
 test/dummy_test_allocator.hpp               |    6 +-
 test/expand_bwd_test_allocator.hpp          |    6 +-
 test/flat_tree_test.cpp                     |    8 +-
 test/heap_allocator_v1.hpp                  |    2 +-
 test/list_test.cpp                          |    2 +-
 test/pair_test.cpp                          |    2 +-
 test/print_container.hpp                    |    2 +-
 test/scoped_allocator_adaptor_test.cpp      | 1404 +++++++++++++++++++
 test/set_test.hpp                           |    2 +-
 test/slist_test.cpp                         |    2 +-
 test/stable_vector_test.cpp                 |    2 +-
 test/string_test.cpp                        |    2 +-
 test/tree_test.cpp                          |    4 +-
 test/util.hpp                               |    2 +-
 test/vector_test.cpp                        |   25 +-
 test/vector_test.hpp                        |    2 +-
 29 files changed, 1628 insertions(+), 63 deletions(-)
 create mode 100644 proj/vc7ide/scoped_allocator_adaptor.vcproj
 create mode 100644 test/scoped_allocator_adaptor_test.cpp

diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2
index 4ddc031..8e4eb2b 100644
--- a/doc/Jamfile.v2
+++ b/doc/Jamfile.v2
@@ -1,6 +1,6 @@
 #  Boost.Container library documentation Jamfile  ---------------------------------
 #
-#  Copyright Ion Gaztanaga 2009-2011. Use, modification and
+#  Copyright Ion Gaztanaga 2009-2012. Use, modification and
 #  distribution is subject to 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)
@@ -27,6 +27,8 @@ doxygen autodoc
         "PREDEFINED=\"insert_const_ref_type= const T&\" \\
                                    \"BOOST_CONTAINER_DOXYGEN_INVOKED\" \\
                                    \"BOOST_RV_REF(T)=T &&\" \\
+                                   \"BOOST_RV_REF_BEG=\" \\
+                                   \"BOOST_RV_REF_END=&&\" \\
                                    \"BOOST_COPY_ASSIGN_REF(T)=const T &\" \\
                                    \"BOOST_RV_REF_2_TEMPL_ARGS(T,a,b)=T &&\" \\
                                    \"BOOST_RV_REF_3_TEMPL_ARGS(T,a,b,c)=TT &&\" \\
diff --git a/doc/container.qbk b/doc/container.qbk
index 13d34ac..464bd04 100644
--- a/doc/container.qbk
+++ b/doc/container.qbk
@@ -1,5 +1,5 @@
 [/
- / Copyright (c) 2009-2011 Ion Gazta\u00F1aga
+ / Copyright (c) 2009-2012 Ion Gazta\u00F1aga
  /
  / 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)
@@ -8,7 +8,7 @@
 [library Boost.Container
     [quickbook 1.5]
     [authors [Gaztanaga, Ion]]
-    [copyright 2009-2011 Ion Gaztanaga]
+    [copyright 2009-2012 Ion Gaztanaga]
     [id container]
     [dirname container]
     [purpose Containers library]
@@ -37,9 +37,9 @@ In short, what does [*Boost.Container] offer?
   (they can be safely placed in shared memory).
 * The library offers new useful containers:
   * [classref boost::container::flat_map flat_map],
-    [classref boost::container::flat_map flat_set],
-    [classref boost::container::flat_map flat_multiset] and
-    [classref boost::container::flat_map flat_multiset]: drop-in
+    [classref boost::container::flat_set flat_set],
+    [classref boost::container::flat_multiset flat_multiset] and
+    [classref boost::container::flat_multiset flat_multiset]: drop-in
     replacements for standard associative containers but more memory friendly and with faster
     searches.
   * [classref boost::container::stable_vector stable_vector]: a std::list and std::vector hybrid
@@ -378,7 +378,7 @@ adequate for your needs, and that you often need to use insert and erase in the
 should probably use list instead of slist.]]
 
 [*Boost.Container] updates the classic `slist` container with C++11 features like move semantics and placement
-insertion and implements it a bit differently for the standard C++11 `forward_list`. `forward_list` has no `size()`
+insertion and implements it a bit differently than the standard C++ `forward_list`. `forward_list` has no `size()`
 method, so it's been designed to allow (or in practice, encourage) implementations without tracking list size
 with every insertion/erasure, allowing constant-time 
 `splice_after(iterator, forward_list &, iterator, iterator)`-based list merging. On the other hand `slist` offers
diff --git a/example/doc_emplace.cpp b/example/doc_emplace.cpp
index 68e4a66..d494061 100644
--- a/example/doc_emplace.cpp
+++ b/example/doc_emplace.cpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2009-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2009-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)
 //
diff --git a/example/doc_move_containers.cpp b/example/doc_move_containers.cpp
index 02e037c..c0fa618 100644
--- a/example/doc_move_containers.cpp
+++ b/example/doc_move_containers.cpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2009-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2009-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)
 //
diff --git a/example/doc_recursive_containers.cpp b/example/doc_recursive_containers.cpp
index b184d19..e9e67d5 100644
--- a/example/doc_recursive_containers.cpp
+++ b/example/doc_recursive_containers.cpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2009-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2009-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)
 //
diff --git a/example/doc_type_erasure.cpp b/example/doc_type_erasure.cpp
index 04dca80..73c81f1 100644
--- a/example/doc_type_erasure.cpp
+++ b/example/doc_type_erasure.cpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2009-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2009-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)
 //
diff --git a/index.html b/index.html
index ad39f65..1251783 100644
--- a/index.html
+++ b/index.html
@@ -1,5 +1,5 @@
 
diff --git a/proj/to-do.txt b/proj/to-do.txt
index d82bd8a..1152393 100644
--- a/proj/to-do.txt
+++ b/proj/to-do.txt
@@ -1,10 +1,10 @@
 ->Change "insert" and "push_back"/"push_front" to catch non-const rvalues
 ->Add an example with stateful allocators
 ->Add test to check convertible types in push_back/insert
+->Add SCARY iterators.
 
 
 Review allocator traits
--> Explicit instantiation of simple allocator & std::allocator to detect missing allocator_traits calls
 -> Avoid any rebind<>::other
 -> Review select_on_container_copy_xxx
 -> Review propagate_on_xxx
@@ -12,13 +12,13 @@ Review allocator traits
 -> Default + swap move constructors correct?
 -> Review container documentation in swap/copy/move regarding allocators
 
-Check all move constructors: swap might not be a valid idiom, allocators must be move constructed, intrusive containers are now movable
+Check all move constructors: swap might not be a valid idiom, allocators must be move constructed,
+intrusive containers are now movable
 
 Add and test:
 
 Test different propagation values and with inequal allocators
 
-
 propagate_on_container_move_assignment
 select_on_container_copy_construction
 propagate_on_container_swap
@@ -28,19 +28,12 @@ Test move constructors with data values and unequal allocators
 
 An allocator should use a smart allocator not constructible from raw pointers to catch missing pointer_traits calls
 
-Review all internal container swap's to check allocator propagation is correct
-
 Add initializer lists
 
 Write forward_list
 
-Review all move constructors to test if allocator is move constructed
-
 check move if noexcept conditions in vector, deque and stable_vector
 
-Add new allocator propagation copy constructors
+Detect always equal or unequal allocators at compiler time. operator== returns true_type or false_type
 
-Review all destructors (search for "~") to detect placement destruction and replace it with allocator_traits::destroy
-
-All functions from base classes like vector_base, node_alloc_holder, etc., should be named with underscore or
-similar to avoid namespace pollution.
\ No newline at end of file
+change virtual functions with pointers to avoid template instantiation for every type
\ No newline at end of file
diff --git a/proj/vc7ide/container.sln b/proj/vc7ide/container.sln
index 38cb19d..7bc2ee8 100644
--- a/proj/vc7ide/container.sln
+++ b/proj/vc7ide/container.sln
@@ -43,6 +43,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "list_test", "list_test.vcpr
 	ProjectSection(ProjectDependencies) = postProject
 	EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scoped_allocator_adaptor_test", "scoped_allocator_adaptor.vcproj", "{B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}"
+	ProjectSection(ProjectDependencies) = postProject
+	EndProjectSection
+EndProject
 Global
 	GlobalSection(SolutionConfiguration) = preSolution
 		Debug = Debug
@@ -95,6 +99,10 @@ Global
 		{58CCE183-6092-48FE-A4F7-BA0D3A792632}.Debug.Build.0 = Debug|Win32
 		{58CCE183-6092-48FE-A4F7-BA0D3A792632}.Release.ActiveCfg = Release|Win32
 		{58CCE183-6092-48FE-A4F7-BA0D3A792632}.Release.Build.0 = Release|Win32
+		{B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Debug.ActiveCfg = Debug|Win32
+		{B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Debug.Build.0 = Debug|Win32
+		{B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Release.ActiveCfg = Release|Win32
+		{B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Release.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 	EndGlobalSection
diff --git a/proj/vc7ide/container.vcproj b/proj/vc7ide/container.vcproj
index 7588d88..50610a6 100644
--- a/proj/vc7ide/container.vcproj
+++ b/proj/vc7ide/container.vcproj
@@ -179,6 +179,9 @@
 		
+			
+			
 			
 			
@@ -197,6 +200,9 @@
 			
 			
+			
+			
 			
 			
@@ -215,19 +221,6 @@
 			
 			
-			
-				
-				
-				
-				
-				
-				
-			
 			
@@ -264,6 +257,9 @@
 				
 				
+				
+				
 				
 				
diff --git a/proj/vc7ide/scoped_allocator_adaptor.vcproj b/proj/vc7ide/scoped_allocator_adaptor.vcproj
new file mode 100644
index 0000000..f38106c
--- /dev/null
+++ b/proj/vc7ide/scoped_allocator_adaptor.vcproj
@@ -0,0 +1,139 @@
+
+
+	
+		
+	
+	
+		
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+		
+		
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+		
+	
+	
+	
+	
+		
+			
+			
+		
+		
+		
+	
+	
+	
+
diff --git a/test/allocator_traits_test.cpp b/test/allocator_traits_test.cpp
index 36e5a9e..65ce8f3 100644
--- a/test/allocator_traits_test.cpp
+++ b/test/allocator_traits_test.cpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2011-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2011-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)
 //
@@ -9,7 +9,7 @@
 //////////////////////////////////////////////////////////////////////////////
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/test/deque_test.cpp b/test/deque_test.cpp
index bc8bf9e..7190e0a 100644
--- a/test/deque_test.cpp
+++ b/test/deque_test.cpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-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)
 //
diff --git a/test/dummy_test_allocator.hpp b/test/dummy_test_allocator.hpp
index 719d0ca..394b5a9 100644
--- a/test/dummy_test_allocator.hpp
+++ b/test/dummy_test_allocator.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)
 //
@@ -112,10 +112,10 @@ class dummy_test_allocator
    {}
 
    pointer address(reference value) 
-   {  return pointer(addressof(value));  }
+   {  return pointer(container_detail::addressof(value));  }
 
    const_pointer address(const_reference value) const
-   {  return const_pointer(addressof(value));  }
+   {  return const_pointer(container_detail::addressof(value));  }
 
    pointer allocate(size_type, cvoid_ptr = 0)
    {  return 0; }
diff --git a/test/expand_bwd_test_allocator.hpp b/test/expand_bwd_test_allocator.hpp
index 67aea9d..3f499d2 100644
--- a/test/expand_bwd_test_allocator.hpp
+++ b/test/expand_bwd_test_allocator.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)
 //
@@ -86,10 +86,10 @@ class expand_bwd_test_allocator
       , m_offset(other.m_offset),  m_allocations(0){ }
 
    pointer address(reference value)
-   {  return pointer(addressof(value));  }
+   {  return pointer(container_detail::addressof(value));  }
 
    const_pointer address(const_reference value) const
-   {  return const_pointer(addressof(value));  }
+   {  return const_pointer(container_detail::addressof(value));  }
 
    pointer allocate(size_type , cvoid_ptr hint = 0)
    {  (void)hint; return 0; }
diff --git a/test/flat_tree_test.cpp b/test/flat_tree_test.cpp
index 4203704..645a124 100644
--- a/test/flat_tree_test.cpp
+++ b/test/flat_tree_test.cpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-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)
 //
@@ -228,17 +228,17 @@ class recursive_flat_multiset
 {
    public:
    recursive_flat_multiset(const recursive_flat_multiset &c)
-      : id_(c.id_), flat_set_(c.flat_set_)
+      : id_(c.id_), flat_multiset_(c.flat_multiset_)
    {}
 
    recursive_flat_multiset & operator =(const recursive_flat_multiset &c)
    {
       id_ = c.id_;
-      flat_set_= c.flat_set_;
+      flat_multiset_= c.flat_multiset_;
       return *this;
    }
    int id_;
-   flat_multiset flat_set_;
+   flat_multiset flat_multiset_;
    friend bool operator< (const recursive_flat_multiset &a, const recursive_flat_multiset &b)
    {  return a.id_ < b.id_;   }
 };
diff --git a/test/heap_allocator_v1.hpp b/test/heap_allocator_v1.hpp
index 32b46b5..10437b5 100644
--- a/test/heap_allocator_v1.hpp
+++ b/test/heap_allocator_v1.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)
 //
diff --git a/test/list_test.cpp b/test/list_test.cpp
index 602f547..b3fe6b2 100644
--- a/test/list_test.cpp
+++ b/test/list_test.cpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-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)
 //
diff --git a/test/pair_test.cpp b/test/pair_test.cpp
index c44b9d5..6b75b01 100644
--- a/test/pair_test.cpp
+++ b/test/pair_test.cpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2011-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2011-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)
 //
diff --git a/test/print_container.hpp b/test/print_container.hpp
index 9300c3c..f34a9f3 100644
--- a/test/print_container.hpp
+++ b/test/print_container.hpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-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)
 //
diff --git a/test/scoped_allocator_adaptor_test.cpp b/test/scoped_allocator_adaptor_test.cpp
new file mode 100644
index 0000000..cecfade
--- /dev/null
+++ b/test/scoped_allocator_adaptor_test.cpp
@@ -0,0 +1,1404 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2011-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)
+//
+// See http://www.boost.org/libs/container for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+using namespace boost::container;
+
+
+template
+class test_allocator
+{
+   BOOST_COPYABLE_AND_MOVABLE(test_allocator)
+   public:
+
+   template
+   struct rebind
+   {
+      typedef test_allocator other;
+   };
+
+   typedef container_detail::bool_  propagate_on_container_copy_assignment;
+   typedef container_detail::bool_  propagate_on_container_move_assignment;
+   typedef container_detail::bool_  propagate_on_container_swap;
+   typedef T value_type;
+
+   test_allocator()
+   {}
+
+   test_allocator(const test_allocator&)
+   {}
+
+   test_allocator(BOOST_RV_REF(test_allocator) )
+   {}
+
+   template
+   test_allocator(BOOST_RV_REF_BEG test_allocator BOOST_RV_REF_END)
+   {}
+
+   template
+   test_allocator(const test_allocator &)
+   {}
+
+   test_allocator & operator=(BOOST_COPY_ASSIGN_REF(test_allocator))
+   {  return *this;  }
+
+   test_allocator & operator=(BOOST_RV_REF(test_allocator))
+   {  return *this;  }
+
+   std::size_t max_size() const
+   {  return std::size_t(Id);  }
+
+   T* allocate(std::size_t n)
+   {  return (T*)::new char[n*sizeof(T)];  }
+
+   void deallocate(T*p, std::size_t)
+   {  delete []static_cast(static_cast(p));  }
+};
+
+template 
+bool operator==( const test_allocator&
+               , const test_allocator&)
+{  return true;   }
+
+template 
+bool operator!=( const test_allocator&
+               , const test_allocator&)
+{  return false;   }
+
+
+template
+struct tagged_integer
+{};
+
+struct mark_on_destructor
+{
+   mark_on_destructor()
+      : destroyed(false)
+   {}
+
+   ~mark_on_destructor()
+   {
+      destroyed = true;
+   }
+
+   bool destroyed;
+};
+
+//This enum lists the construction options
+//for an allocator-aware type
+enum ConstructionTypeEnum
+{
+   ConstructiblePrefix,
+   ConstructibleSuffix,
+   NotUsesAllocator,
+};
+
+//This base class provices types for
+//the derived class to implement each construction
+//type. If a construction type does not apply
+//the typedef is set to an internal nat
+//so that the class is not constructible from
+//the user arguments.
+template
+struct uses_allocator_base;
+
+template
+struct uses_allocator_base
+{
+   typedef test_allocator allocator_type;
+   typedef allocator_type allocator_constructor_type;
+   struct nat{};
+   typedef nat allocator_arg_type;
+};
+
+template
+struct uses_allocator_base
+{
+   typedef test_allocator allocator_type;
+   typedef allocator_type allocator_constructor_type;
+   typedef allocator_arg_t allocator_arg_type;
+};
+
+template
+struct uses_allocator_base
+{
+   struct nat{};
+   typedef nat allocator_constructor_type;
+   typedef nat allocator_arg_type;
+};
+
+template
+struct mark_on_scoped_allocation
+   : uses_allocator_base
+{
+   private:
+   BOOST_COPYABLE_AND_MOVABLE(mark_on_scoped_allocation)
+
+   public:
+
+   typedef uses_allocator_base base_type;
+
+   //0 user argument constructors
+   mark_on_scoped_allocation()
+      : construction_type(NotUsesAllocator), value(0)
+   {}
+
+   explicit mark_on_scoped_allocation
+      (typename base_type::allocator_constructor_type)
+      : construction_type(ConstructibleSuffix), value(0)
+   {}
+
+   explicit mark_on_scoped_allocation
+      (typename base_type::allocator_arg_type, typename base_type::allocator_constructor_type)
+      : construction_type(ConstructiblePrefix), value(0)
+   {}
+
+   //1 user argument constructors
+   explicit mark_on_scoped_allocation(int i)
+      : construction_type(NotUsesAllocator), value(i)
+   {}
+
+   mark_on_scoped_allocation
+      (int i, typename base_type::allocator_constructor_type)
+      : construction_type(ConstructibleSuffix), value(i)
+   {}
+
+   mark_on_scoped_allocation
+      ( typename base_type::allocator_arg_type
+      , typename base_type::allocator_constructor_type
+      , int i)
+      : construction_type(ConstructiblePrefix), value(i)
+   {}
+
+   //Copy constructors
+   mark_on_scoped_allocation(const mark_on_scoped_allocation &other)
+      : construction_type(NotUsesAllocator), value(other.value)
+   {}
+
+   mark_on_scoped_allocation( const mark_on_scoped_allocation &other
+                            , typename base_type::allocator_constructor_type)
+      : construction_type(ConstructibleSuffix), value(other.value)
+   {}
+
+   mark_on_scoped_allocation( typename base_type::allocator_arg_type
+                            , typename base_type::allocator_constructor_type
+                            , const mark_on_scoped_allocation &other)
+      : construction_type(ConstructiblePrefix), value(other.value)
+   {}
+
+   //Move constructors
+   mark_on_scoped_allocation(BOOST_RV_REF(mark_on_scoped_allocation) other)
+      : construction_type(NotUsesAllocator), value(other.value)
+   {  other.value = 0;  other.construction_type = NotUsesAllocator;  }
+
+   mark_on_scoped_allocation( BOOST_RV_REF(mark_on_scoped_allocation) other
+                            , typename base_type::allocator_constructor_type)
+      : construction_type(ConstructibleSuffix), value(other.value)
+   {  other.value = 0;  other.construction_type = ConstructibleSuffix;  }
+
+   mark_on_scoped_allocation( typename base_type::allocator_arg_type
+                            , typename base_type::allocator_constructor_type
+                            , BOOST_RV_REF(mark_on_scoped_allocation) other)
+      : construction_type(ConstructiblePrefix), value(other.value)
+   {  other.value = 0;  other.construction_type = ConstructiblePrefix;  }
+
+   ConstructionTypeEnum construction_type;
+   int                  value;
+};
+
+namespace boost {
+namespace container {
+
+template
+struct constructible_with_allocator_prefix
+   < ::mark_on_scoped_allocation >
+   : ::boost::true_type
+{};
+
+template
+struct constructible_with_allocator_suffix
+   < ::mark_on_scoped_allocation >
+   : ::boost::true_type
+{};
+
+}  //namespace container {
+}  //namespace boost {
+
+
+int main()
+{
+   typedef test_allocator, 0>   OuterAlloc;
+   typedef test_allocator, 10>  Outer10IdAlloc;
+   typedef test_allocator, 0>   Rebound9OuterAlloc;
+   typedef test_allocator, 1>   InnerAlloc1;
+   typedef test_allocator, 2>   InnerAlloc2;
+   typedef test_allocator, 11>  Inner11IdAlloc1;
+   typedef test_allocator, 12>  Inner12IdAlloc2;
+
+   typedef test_allocator, 0, false>      OuterAllocFalsePropagate;
+   typedef test_allocator, 0, true>       OuterAllocTruePropagate;
+   typedef test_allocator, 1, false>      InnerAlloc1FalsePropagate;
+   typedef test_allocator, 1, true>       InnerAlloc1TruePropagate;
+   typedef test_allocator, 2, false>      InnerAlloc2FalsePropagate;
+   typedef test_allocator, 2, true>       InnerAlloc2TruePropagate;
+
+   //
+   typedef scoped_allocator_adaptor< OuterAlloc  >          Scoped0Inner;
+   typedef scoped_allocator_adaptor< OuterAlloc
+                                   , InnerAlloc1 >          Scoped1Inner;
+   typedef scoped_allocator_adaptor< OuterAlloc
+                                   , InnerAlloc1
+                                   , InnerAlloc2 >          Scoped2Inner;
+   typedef scoped_allocator_adaptor
+      < scoped_allocator_adaptor
+         
+      >                                                     ScopedScoped0Inner;
+   typedef scoped_allocator_adaptor
+      < scoped_allocator_adaptor
+         
+      , InnerAlloc1
+      >                                                     ScopedScoped1Inner;
+   typedef scoped_allocator_adaptor
+      < scoped_allocator_adaptor
+         
+      , InnerAlloc1, InnerAlloc2
+      >                                                     ScopedScoped2Inner;
+   typedef scoped_allocator_adaptor< Rebound9OuterAlloc  >  Rebound9Scoped0Inner;
+   typedef scoped_allocator_adaptor< Rebound9OuterAlloc
+                                   , InnerAlloc1 >          Rebound9Scoped1Inner;
+   typedef scoped_allocator_adaptor< Rebound9OuterAlloc
+                                   , InnerAlloc1
+                                   , InnerAlloc2 >          Rebound9Scoped2Inner;
+
+   //outer_allocator_type
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< OuterAlloc
+                       , Scoped0Inner::outer_allocator_type>::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< OuterAlloc
+                       , Scoped1Inner::outer_allocator_type>::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< OuterAlloc
+                       , Scoped2Inner::outer_allocator_type>::value ));
+   //value_type
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::value_type
+                       , Scoped0Inner::value_type>::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::value_type
+                       , Scoped1Inner::value_type>::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::value_type
+                       , Scoped2Inner::value_type>::value ));
+   //size_type
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::size_type
+                       , Scoped0Inner::size_type>::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::size_type
+                       , Scoped1Inner::size_type>::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::size_type
+                       , Scoped2Inner::size_type>::value ));
+
+   //difference_type
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::difference_type
+                       , Scoped0Inner::difference_type>::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::difference_type
+                       , Scoped1Inner::difference_type>::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::difference_type
+                       , Scoped2Inner::difference_type>::value ));
+
+   //pointer
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::pointer
+                       , Scoped0Inner::pointer>::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::pointer
+                       , Scoped1Inner::pointer>::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::pointer
+                       , Scoped2Inner::pointer>::value ));
+
+   //const_pointer
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::const_pointer
+                       , Scoped0Inner::const_pointer>::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::const_pointer
+                       , Scoped1Inner::const_pointer>::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::const_pointer
+                       , Scoped2Inner::const_pointer>::value ));
+
+   //void_pointer
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::void_pointer
+                       , Scoped0Inner::void_pointer>::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::void_pointer
+                       , Scoped1Inner::void_pointer>::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::void_pointer
+                       , Scoped2Inner::void_pointer>::value ));
+
+   //const_void_pointer
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::const_void_pointer
+                       , Scoped0Inner::const_void_pointer>::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::const_void_pointer
+                       , Scoped1Inner::const_void_pointer>::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits::const_void_pointer
+                       , Scoped2Inner::const_void_pointer>::value ));
+
+   //rebind
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same >::other
+                       , Rebound9Scoped0Inner >::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same >::other
+                       , Rebound9Scoped1Inner >::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same >::other
+                       , Rebound9Scoped2Inner >::value ));
+
+   //inner_allocator_type
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< Scoped0Inner
+                       , Scoped0Inner::inner_allocator_type>::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< scoped_allocator_adaptor
+                       , Scoped1Inner::inner_allocator_type>::value ));
+   BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< scoped_allocator_adaptor
+                       , Scoped2Inner::inner_allocator_type>::value ));
+
+   {
+      //Propagation test
+      typedef scoped_allocator_adaptor< OuterAllocFalsePropagate  >  Scoped0InnerF;
+      typedef scoped_allocator_adaptor< OuterAllocTruePropagate  >   Scoped0InnerT;
+      typedef scoped_allocator_adaptor< OuterAllocFalsePropagate
+                                    , InnerAlloc1FalsePropagate >  Scoped1InnerFF;
+      typedef scoped_allocator_adaptor< OuterAllocFalsePropagate
+                                    , InnerAlloc1TruePropagate >   Scoped1InnerFT;
+      typedef scoped_allocator_adaptor< OuterAllocTruePropagate
+                                    , InnerAlloc1FalsePropagate >  Scoped1InnerTF;
+      typedef scoped_allocator_adaptor< OuterAllocTruePropagate
+                                    , InnerAlloc1TruePropagate >   Scoped1InnerTT;
+      typedef scoped_allocator_adaptor< OuterAllocFalsePropagate
+                                    , InnerAlloc1FalsePropagate
+                                    , InnerAlloc2FalsePropagate >  Scoped2InnerFFF;
+      typedef scoped_allocator_adaptor< OuterAllocFalsePropagate
+                                    , InnerAlloc1FalsePropagate
+                                    , InnerAlloc2TruePropagate >  Scoped2InnerFFT;
+      typedef scoped_allocator_adaptor< OuterAllocFalsePropagate
+                                    , InnerAlloc1TruePropagate
+                                    , InnerAlloc2FalsePropagate >  Scoped2InnerFTF;
+      typedef scoped_allocator_adaptor< OuterAllocFalsePropagate
+                                    , InnerAlloc1TruePropagate
+                                    , InnerAlloc2TruePropagate >  Scoped2InnerFTT;
+      typedef scoped_allocator_adaptor< OuterAllocTruePropagate
+                                    , InnerAlloc1FalsePropagate
+                                    , InnerAlloc2FalsePropagate >  Scoped2InnerTFF;
+      typedef scoped_allocator_adaptor< OuterAllocTruePropagate
+                                    , InnerAlloc1FalsePropagate
+                                    , InnerAlloc2TruePropagate >  Scoped2InnerTFT;
+      typedef scoped_allocator_adaptor< OuterAllocTruePropagate
+                                    , InnerAlloc1TruePropagate
+                                    , InnerAlloc2FalsePropagate >  Scoped2InnerTTF;
+      typedef scoped_allocator_adaptor< OuterAllocTruePropagate
+                                    , InnerAlloc1TruePropagate
+                                    , InnerAlloc2TruePropagate >  Scoped2InnerTTT;
+
+      //propagate_on_container_copy_assignment
+      //0 inner
+      BOOST_STATIC_ASSERT(( !Scoped0InnerF::propagate_on_container_copy_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped0InnerT::propagate_on_container_copy_assignment::value ));
+      //1 inner
+      BOOST_STATIC_ASSERT(( !Scoped1InnerFF::propagate_on_container_copy_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped1InnerFT::propagate_on_container_copy_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped1InnerTF::propagate_on_container_copy_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped1InnerTT::propagate_on_container_copy_assignment::value ));
+      //2 inner
+      BOOST_STATIC_ASSERT(( !Scoped2InnerFFF::propagate_on_container_copy_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerFFT::propagate_on_container_copy_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerFTF::propagate_on_container_copy_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerFTT::propagate_on_container_copy_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerTFF::propagate_on_container_copy_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerTFT::propagate_on_container_copy_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerTTF::propagate_on_container_copy_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerTTT::propagate_on_container_copy_assignment::value ));
+
+      //propagate_on_container_move_assignment
+      //0 inner
+      BOOST_STATIC_ASSERT(( !Scoped0InnerF::propagate_on_container_move_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped0InnerT::propagate_on_container_move_assignment::value ));
+      //1 inner
+      BOOST_STATIC_ASSERT(( !Scoped1InnerFF::propagate_on_container_move_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped1InnerFT::propagate_on_container_move_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped1InnerTF::propagate_on_container_move_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped1InnerTT::propagate_on_container_move_assignment::value ));
+      //2 inner
+      BOOST_STATIC_ASSERT(( !Scoped2InnerFFF::propagate_on_container_move_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerFFT::propagate_on_container_move_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerFTF::propagate_on_container_move_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerFTT::propagate_on_container_move_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerTFF::propagate_on_container_move_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerTFT::propagate_on_container_move_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerTTF::propagate_on_container_move_assignment::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerTTT::propagate_on_container_move_assignment::value ));
+
+      //propagate_on_container_swap
+      //0 inner
+      BOOST_STATIC_ASSERT(( !Scoped0InnerF::propagate_on_container_swap::value ));
+      BOOST_STATIC_ASSERT((  Scoped0InnerT::propagate_on_container_swap::value ));
+      //1 inner
+      BOOST_STATIC_ASSERT(( !Scoped1InnerFF::propagate_on_container_swap::value ));
+      BOOST_STATIC_ASSERT((  Scoped1InnerFT::propagate_on_container_swap::value ));
+      BOOST_STATIC_ASSERT((  Scoped1InnerTF::propagate_on_container_swap::value ));
+      BOOST_STATIC_ASSERT((  Scoped1InnerTT::propagate_on_container_swap::value ));
+      //2 inner
+      BOOST_STATIC_ASSERT(( !Scoped2InnerFFF::propagate_on_container_swap::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerFFT::propagate_on_container_swap::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerFTF::propagate_on_container_swap::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerFTT::propagate_on_container_swap::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerTFF::propagate_on_container_swap::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerTFT::propagate_on_container_swap::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerTTF::propagate_on_container_swap::value ));
+      BOOST_STATIC_ASSERT((  Scoped2InnerTTT::propagate_on_container_swap::value ));
+   }
+
+   //Default constructor
+   {
+      Scoped0Inner s0i;
+      Scoped1Inner s1i;
+   }
+
+   //inner_allocator()
+   {
+      Scoped0Inner s0i;
+      Scoped1Inner s1i;
+      Scoped2Inner s2i;
+      const Scoped0Inner const_s0i;
+      const Scoped1Inner const_s1i;
+      const Scoped2Inner const_s2i;
+
+      Scoped0Inner::inner_allocator_type &s0i_inner =             s0i.inner_allocator();
+      (void)s0i_inner;
+      const Scoped0Inner::inner_allocator_type &const_s0i_inner = const_s0i.inner_allocator();
+      (void)const_s0i_inner;
+      Scoped1Inner::inner_allocator_type &s1i_inner =             s1i.inner_allocator();
+      (void)s1i_inner;
+      const Scoped1Inner::inner_allocator_type &const_s1i_inner = const_s1i.inner_allocator();
+      (void)const_s1i_inner;
+      Scoped2Inner::inner_allocator_type &s2i_inner =             s2i.inner_allocator();
+      (void)s2i_inner;
+      const Scoped2Inner::inner_allocator_type &const_s2i_inner = const_s2i.inner_allocator();
+      (void)const_s2i_inner;
+   }
+
+   //operator==/!=
+   {
+      const Scoped0Inner const_s0i;
+      const Rebound9Scoped0Inner const_rs0i;
+      if(!(const_s0i == const_s0i) ||
+         !(const_rs0i == const_s0i)){
+         return 1;
+      }
+      if(  const_s0i != const_s0i ||
+           const_s0i != const_rs0i ){
+         return 1;
+      }
+
+      const Scoped1Inner const_s1i;
+      const Rebound9Scoped1Inner const_rs1i;
+      if(!(const_s1i == const_s1i) ||
+         !(const_rs1i == const_s1i)){
+         return 1;
+      }
+      if(  const_s1i != const_s1i ||
+           const_s1i != const_rs1i ){
+         return 1;
+      }
+      const Scoped2Inner const_s2i;
+      const Rebound9Scoped2Inner const_rs2i;
+      if(!(const_s2i == const_s2i) ||
+         !(const_s2i == const_rs2i) ){
+         return 1;
+      }
+      if(  const_s2i != const_s2i ||
+           const_s2i != const_rs2i ){
+         return 1;
+      }
+   }
+
+   //outer_allocator()
+   {
+      Scoped0Inner s0i;
+      Scoped1Inner s1i;
+      Scoped2Inner s2i;
+      const Scoped0Inner const_s0i;
+      const Scoped1Inner const_s1i;
+      const Scoped2Inner const_s2i;
+
+      Scoped0Inner::outer_allocator_type &s0i_inner =             s0i.outer_allocator();
+      (void)s0i_inner;
+      const Scoped0Inner::outer_allocator_type &const_s0i_inner = const_s0i.outer_allocator();
+      (void)const_s0i_inner;
+      Scoped1Inner::outer_allocator_type &s1i_inner =             s1i.outer_allocator();
+      (void)s1i_inner;
+      const Scoped1Inner::outer_allocator_type &const_s1i_inner = const_s1i.outer_allocator();
+      (void)const_s1i_inner;
+      Scoped2Inner::outer_allocator_type &s2i_inner =             s2i.outer_allocator();
+      (void)s2i_inner;
+      const Scoped2Inner::outer_allocator_type &const_s2i_inner = const_s2i.outer_allocator();
+      (void)const_s2i_inner;
+   }
+
+   //max_size()
+   {
+      const Scoped0Inner const_s0i;
+      const Scoped1Inner const_s1i;
+      const Scoped2Inner const_s2i;
+      const OuterAlloc  const_oa;
+      const InnerAlloc1 const_ia1;
+      const InnerAlloc2 const_ia2;
+
+      if(const_s0i.max_size() != const_oa.max_size()){
+         return 1;
+      }
+
+      if(const_s1i.max_size() != const_oa.max_size()){
+         return 1;
+      }
+
+      if(const_s2i.max_size() != const_oa.max_size()){
+         return 1;
+      }
+
+      if(const_s1i.inner_allocator().max_size() != const_ia1.max_size()){
+         return 1;
+      }
+
+      if(const_s2i.inner_allocator().inner_allocator().max_size() != const_ia2.max_size()){
+         return 1;
+      }
+   }
+   //Copy and move operations
+   {
+      //Construction
+      {
+         Scoped0Inner s0i_a, s0i_b(s0i_a), s0i_c(::boost::move(s0i_b));
+         Scoped1Inner s1i_a, s1i_b(s1i_a), s1i_c(::boost::move(s1i_b));
+         Scoped2Inner s2i_a, s2i_b(s2i_a), s2i_c(::boost::move(s2i_b));
+      }
+      //Assignment
+      {
+         Scoped0Inner s0i_a, s0i_b;
+         s0i_a = s0i_b;
+         s0i_a = ::boost::move(s0i_b);
+         Scoped1Inner s1i_a, s1i_b;
+         s1i_a = s1i_b;
+         s1i_a = ::boost::move(s1i_b);
+         Scoped2Inner s2i_a, s2i_b;
+         s2i_a = s2i_b;
+         s2i_a = ::boost::move(s2i_b);
+      }
+
+      OuterAlloc  oa;
+      InnerAlloc1 ia1;
+      InnerAlloc2 ia2;
+      Rebound9OuterAlloc roa;
+      Rebound9Scoped0Inner rs0i;
+      Rebound9Scoped1Inner rs1i;
+      Rebound9Scoped2Inner rs2i;
+
+      //Copy from outer
+      {
+         Scoped0Inner s0i(oa);
+         Scoped1Inner s1i(oa, ia1);
+         Scoped2Inner s2i(oa, ia1, ia2);
+      }
+      //Move from outer
+      {
+         Scoped0Inner s0i(::boost::move(oa));
+         Scoped1Inner s1i(::boost::move(oa), ia1);
+         Scoped2Inner s2i(::boost::move(oa), ia1, ia2);
+      }
+      //Copy from rebound outer
+      {
+         Scoped0Inner s0i(roa);
+         Scoped1Inner s1i(roa, ia1);
+         Scoped2Inner s2i(roa, ia1, ia2);
+      }
+      //Move from rebound outer
+      {
+         Scoped0Inner s0i(::boost::move(roa));
+         Scoped1Inner s1i(::boost::move(roa), ia1);
+         Scoped2Inner s2i(::boost::move(roa), ia1, ia2);
+      }
+      //Copy from rebound scoped
+      {
+         Scoped0Inner s0i(rs0i);
+         Scoped1Inner s1i(rs1i);
+         Scoped2Inner s2i(rs2i);
+      }
+      //Move from rebound scoped
+      {
+         Scoped0Inner s0i(::boost::move(rs0i));
+         Scoped1Inner s1i(::boost::move(rs1i));
+         Scoped2Inner s2i(::boost::move(rs2i));
+      }
+   }
+
+   {
+      vector > > dummy;  
+      dummy.push_back(0);
+   }
+
+   //destroy()
+   {
+      {
+         Scoped0Inner s0i;
+         mark_on_destructor mod;
+         s0i.destroy(&mod);
+         if(!mod.destroyed){
+            return 1;
+         }
+      }
+
+      {
+         Scoped1Inner s1i;
+         mark_on_destructor mod;
+         s1i.destroy(&mod);
+         if(!mod.destroyed){
+            return 1;
+         }
+      }
+      {
+         Scoped2Inner s2i;
+         mark_on_destructor mod;
+         s2i.destroy(&mod);
+         if(!mod.destroyed){
+            return 1;
+         }
+      }
+   }
+
+   //construct
+   {
+
+      BOOST_STATIC_ASSERT(( !boost::container::uses_allocator
+                              < ::mark_on_scoped_allocation
+                              , test_allocator 
+                              >::value ));
+      BOOST_STATIC_ASSERT((  boost::container::uses_allocator
+                              < ::mark_on_scoped_allocation
+                              , test_allocator 
+                              >::value ));
+      BOOST_STATIC_ASSERT((  boost::container::uses_allocator
+                              < ::mark_on_scoped_allocation
+                              , test_allocator 
+                              >::value ));
+      BOOST_STATIC_ASSERT(( boost::container::constructible_with_allocator_prefix
+                          < ::mark_on_scoped_allocation >::value ));
+      BOOST_STATIC_ASSERT(( boost::container::constructible_with_allocator_suffix
+                          < ::mark_on_scoped_allocation >::value ));
+
+      ////////////////////////////////////////////////////////////
+      //First check scoped allocator with just OuterAlloc.
+      //In this case OuterAlloc (test_allocator with tag 0) should be
+      //used to construct types.
+      ////////////////////////////////////////////////////////////
+      {
+         Scoped0Inner s0i;
+         //Check construction with 0 user arguments
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            s0i.construct(&dummy);
+            if(dummy.construction_type != NotUsesAllocator ||
+               dummy.value != 0){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            s0i.construct(&dummy);
+            if(dummy.construction_type != ConstructibleSuffix ||
+               dummy.value != 0){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            s0i.construct(&dummy);
+            if(dummy.construction_type != ConstructiblePrefix ||
+               dummy.value != 0){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+
+         //Check construction with 1 user arguments
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            s0i.construct(&dummy, 1);
+            if(dummy.construction_type != NotUsesAllocator ||
+               dummy.value != 1){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            s0i.construct(&dummy, 2);
+            if(dummy.construction_type != ConstructibleSuffix ||
+               dummy.value != 2){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            s0i.construct(&dummy, 3);
+            if(dummy.construction_type != ConstructiblePrefix ||
+               dummy.value != 3){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+      }
+      ////////////////////////////////////////////////////////////
+      //Then check scoped allocator with OuterAlloc and InnerAlloc.
+      //In this case InnerAlloc (test_allocator with tag 1) should be
+      //used to construct types.
+      ////////////////////////////////////////////////////////////
+      {
+         Scoped1Inner s1i;
+         //Check construction with 0 user arguments
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            s1i.construct(&dummy);
+            if(dummy.construction_type != NotUsesAllocator ||
+               dummy.value != 0){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            s1i.construct(&dummy);
+            if(dummy.construction_type != ConstructibleSuffix ||
+               dummy.value != 0){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            s1i.construct(&dummy);
+            if(dummy.construction_type != ConstructiblePrefix ||
+               dummy.value != 0){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+
+         //Check construction with 1 user arguments
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            s1i.construct(&dummy, 1);
+            if(dummy.construction_type != NotUsesAllocator ||
+               dummy.value != 1){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            s1i.construct(&dummy, 2);
+            if(dummy.construction_type != ConstructibleSuffix ||
+               dummy.value != 2){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            s1i.construct(&dummy, 3);
+            if(dummy.construction_type != ConstructiblePrefix ||
+               dummy.value != 3){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+      }
+
+      //////////////////////////////////////////////////////////////////////////////////
+      //Now test recursive OuterAllocator types (OuterAllocator is an scoped_allocator)
+      //////////////////////////////////////////////////////////////////////////////////
+
+      ////////////////////////////////////////////////////////////
+      //First check scoped allocator with just OuterAlloc.
+      //In this case OuterAlloc (test_allocator with tag 0) should be
+      //used to construct types.
+      ////////////////////////////////////////////////////////////
+      {
+         //Check outer_allocator_type is scoped
+         BOOST_STATIC_ASSERT(( boost::container::is_scoped_allocator
+            ::value ));
+         BOOST_STATIC_ASSERT(( ::boost::container::container_detail::is_same
+            < boost::container::outermost_allocator::type
+            , Outer10IdAlloc
+            >::value ));
+         BOOST_STATIC_ASSERT(( ::boost::container::container_detail::is_same
+            < ScopedScoped0Inner::outer_allocator_type
+            , scoped_allocator_adaptor
+            >::value ));
+         BOOST_STATIC_ASSERT(( ::boost::container::container_detail::is_same
+            < scoped_allocator_adaptor::outer_allocator_type
+            , Outer10IdAlloc
+            >::value ));
+         ScopedScoped0Inner ssro0i;
+         Outer10IdAlloc & val = boost::container::outermost_allocator::get(ssro0i);
+         (void)val;
+         //Check construction with 0 user arguments
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            ssro0i.construct(&dummy);
+            if(dummy.construction_type != NotUsesAllocator ||
+               dummy.value != 0){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            ssro0i.construct(&dummy);
+            if(dummy.construction_type != ConstructibleSuffix ||
+               dummy.value != 0){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            ssro0i.construct(&dummy);
+            if(dummy.construction_type != ConstructiblePrefix ||
+               dummy.value != 0){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+
+         //Check construction with 1 user arguments
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            ssro0i.construct(&dummy, 1);
+            if(dummy.construction_type != NotUsesAllocator ||
+               dummy.value != 1){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            ssro0i.construct(&dummy, 2);
+            if(dummy.construction_type != ConstructibleSuffix ||
+               dummy.value != 2){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            ssro0i.construct(&dummy, 3);
+            if(dummy.construction_type != ConstructiblePrefix ||
+               dummy.value != 3){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+      }
+      ////////////////////////////////////////////////////////////
+      //Then check scoped allocator with OuterAlloc and InnerAlloc.
+      //In this case inner_allocator_type is not convertible to
+      //::mark_on_scoped_allocation so uses_allocator
+      //should be false on all tests.
+      ////////////////////////////////////////////////////////////
+      {
+         //Check outer_allocator_type is scoped
+         BOOST_STATIC_ASSERT(( boost::container::is_scoped_allocator
+            ::value ));
+         BOOST_STATIC_ASSERT(( ::boost::container::container_detail::is_same
+            < boost::container::outermost_allocator::type
+            , Outer10IdAlloc
+            >::value ));
+         BOOST_STATIC_ASSERT(( ::boost::container::container_detail::is_same
+            < ScopedScoped1Inner::outer_allocator_type
+            , scoped_allocator_adaptor
+            >::value ));
+         BOOST_STATIC_ASSERT(( ::boost::container::container_detail::is_same
+            < scoped_allocator_adaptor::outer_allocator_type
+            , Outer10IdAlloc
+            >::value ));
+         BOOST_STATIC_ASSERT(( !
+            ::boost::container::uses_allocator
+               < ::mark_on_scoped_allocation
+               , ScopedScoped1Inner::inner_allocator_type::outer_allocator_type
+               >::value ));
+         ScopedScoped1Inner ssro1i;
+         Outer10IdAlloc & val = boost::container::outermost_allocator::get(ssro1i);
+         (void)val;
+
+         //Check construction with 0 user arguments
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            ssro1i.construct(&dummy);
+            if(dummy.construction_type != NotUsesAllocator ||
+               dummy.value != 0){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            ssro1i.construct(&dummy);
+            if(dummy.construction_type != NotUsesAllocator ||
+               dummy.value != 0){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            ssro1i.construct(&dummy);
+            if(dummy.construction_type != NotUsesAllocator ||
+               dummy.value != 0){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+
+         //Check construction with 1 user arguments
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            ssro1i.construct(&dummy, 1);
+            if(dummy.construction_type != NotUsesAllocator ||
+               dummy.value != 1){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            ssro1i.construct(&dummy, 2);
+            if(dummy.construction_type != NotUsesAllocator ||
+               dummy.value != 2){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            MarkType dummy;
+            dummy.~MarkType();
+            ssro1i.construct(&dummy, 3);
+            if(dummy.construction_type != NotUsesAllocator ||
+               dummy.value != 3){
+               dummy.~MarkType();
+               return 1;
+            }
+            dummy.~MarkType();
+         }
+      }
+
+      ////////////////////////////////////////////////////////////
+      //Now check propagation to pair
+      ////////////////////////////////////////////////////////////
+      //First check scoped allocator with just OuterAlloc.
+      //In this case OuterAlloc (test_allocator with tag 0) should be
+      //used to construct types.
+      ////////////////////////////////////////////////////////////
+      {
+         using boost::container::container_detail::pair;
+         typedef test_allocator< pair< tagged_integer<0>
+                               , tagged_integer<0> >, 0> OuterPairAlloc;
+         typedef test_allocator< pair< tagged_integer<1>
+                               , tagged_integer<1> >, 1> InnerPairAlloc1;
+         typedef test_allocator< pair< tagged_integer<2>
+                               , tagged_integer<2> >, 2> InnerPairAlloc2;
+         //
+         typedef scoped_allocator_adaptor < OuterPairAlloc  >  ScopedPair0Inner;
+         typedef scoped_allocator_adaptor < OuterPairAlloc
+                                          , InnerPairAlloc1 >  ScopedPair1Inner;
+         typedef scoped_allocator_adaptor < OuterPairAlloc
+                                          , InnerPairAlloc1
+                                          , InnerPairAlloc2 >  ScopedPair2Inner;
+
+         ScopedPair0Inner s0i;
+         //Check construction with 0 user arguments
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            typedef pair MarkTypePair;
+            MarkTypePair dummy;
+            dummy.~MarkTypePair();
+            s0i.construct(&dummy);
+            if(dummy.first.construction_type  != NotUsesAllocator ||
+               dummy.second.construction_type != NotUsesAllocator ||
+               dummy.first.value  != 0 ||
+               dummy.second.value != 0 ){
+               dummy.~MarkTypePair();
+               return 1;
+            }
+            dummy.~MarkTypePair();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            typedef pair MarkTypePair;
+            MarkTypePair dummy;
+            dummy.~MarkTypePair();
+            s0i.construct(&dummy);
+            if(dummy.first.construction_type  != ConstructibleSuffix ||
+               dummy.second.construction_type != ConstructibleSuffix ||
+               dummy.first.value  != 0 ||
+               dummy.second.value != 0 ){
+               dummy.~MarkTypePair();
+               return 1;
+            }
+            dummy.~MarkTypePair();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            typedef pair MarkTypePair;
+            MarkTypePair dummy;
+            dummy.~MarkTypePair();
+            s0i.construct(&dummy);
+            if(dummy.first.construction_type  != ConstructiblePrefix ||
+               dummy.second.construction_type != ConstructiblePrefix ||
+               dummy.first.value  != 0  ||
+               dummy.second.value != 0 ){
+               dummy.~MarkTypePair();
+               return 1;
+            }
+            dummy.~MarkTypePair();
+         }
+
+         //Check construction with 1 user arguments for each pair
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            typedef pair MarkTypePair;
+            MarkTypePair dummy;
+            dummy.~MarkTypePair();
+            s0i.construct(&dummy, 1, 1);
+            if(dummy.first.construction_type  != NotUsesAllocator ||
+               dummy.second.construction_type != NotUsesAllocator ||
+               dummy.first.value  != 1 ||
+               dummy.second.value != 1 ){
+               dummy.~MarkTypePair();
+               return 1;
+            }
+            dummy.~MarkTypePair();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            typedef pair MarkTypePair;
+            MarkTypePair dummy;
+            dummy.~MarkTypePair();
+            s0i.construct(&dummy, 1, 1);
+            if(dummy.first.construction_type  != ConstructibleSuffix ||
+               dummy.second.construction_type != ConstructibleSuffix ||
+               dummy.first.value  != 1 ||
+               dummy.second.value != 1 ){
+               dummy.~MarkTypePair();
+               return 1;
+            }
+            dummy.~MarkTypePair();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            typedef pair MarkTypePair;
+            MarkTypePair dummy;
+            dummy.~MarkTypePair();
+            s0i.construct(&dummy, 2, 2);
+            if(dummy.first.construction_type  != ConstructiblePrefix ||
+               dummy.second.construction_type != ConstructiblePrefix ||
+               dummy.first.value  != 2 ||
+               dummy.second.value != 2 ){
+               dummy.~MarkTypePair();
+               return 1;
+            }
+            dummy.~MarkTypePair();
+         }
+         //Check construction with pair copy construction
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            typedef pair MarkTypePair;
+            MarkTypePair dummy, dummy2;
+            dummy.~MarkTypePair();
+            s0i.construct(&dummy, dummy2);
+            if(dummy.first.construction_type  != NotUsesAllocator ||
+               dummy.second.construction_type != NotUsesAllocator ||
+               dummy.first.value  != 0 ||
+               dummy.second.value != 0 ){
+               dummy.~MarkTypePair();
+               return 1;
+            }
+            dummy.~MarkTypePair();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            typedef pair MarkTypePair;
+            MarkTypePair dummy, dummy2(1, 1);
+            dummy.~MarkTypePair();
+            s0i.construct(&dummy, dummy2);
+            if(dummy.first.construction_type  != ConstructibleSuffix ||
+               dummy.second.construction_type != ConstructibleSuffix ||
+               dummy.first.value  != 1 ||
+               dummy.second.value != 1 ){
+               dummy.~MarkTypePair();
+               return 1;
+            }
+            dummy.~MarkTypePair();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            typedef pair MarkTypePair;
+            MarkTypePair dummy, dummy2(2, 2);
+            dummy.~MarkTypePair();
+            s0i.construct(&dummy, dummy2);
+            if(dummy.first.construction_type  != ConstructiblePrefix ||
+               dummy.second.construction_type != ConstructiblePrefix ||
+               dummy.first.value  != 2 ||
+               dummy.second.value != 2 ){
+               dummy.~MarkTypePair();
+               return 1;
+            }
+            dummy.~MarkTypePair();
+         }
+         //Check construction with pair move construction
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            typedef pair MarkTypePair;
+            MarkTypePair dummy, dummy2(3, 3);
+            dummy2.first.construction_type = dummy2.second.construction_type = ConstructibleSuffix;
+            dummy.~MarkTypePair();
+            s0i.construct(&dummy, ::boost::move(dummy2));
+            if(dummy.first.construction_type  != NotUsesAllocator ||
+               dummy.second.construction_type != NotUsesAllocator ||
+               dummy.first.value  != 3 ||
+               dummy.second.value != 3 ||
+               dummy2.first.construction_type  != NotUsesAllocator ||
+               dummy2.second.construction_type != NotUsesAllocator ||
+               dummy2.first.value  != 0 ||
+               dummy2.second.value != 0 ){
+               dummy.~MarkTypePair();
+               return 1;
+            }
+            dummy.~MarkTypePair();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            typedef pair MarkTypePair;
+            MarkTypePair dummy, dummy2(1, 1);
+            dummy.~MarkTypePair();
+            s0i.construct(&dummy, ::boost::move(dummy2));
+            if(dummy.first.construction_type  != ConstructibleSuffix ||
+               dummy.second.construction_type != ConstructibleSuffix ||
+               dummy.first.value  != 1 ||
+               dummy.second.value != 1 ||
+               dummy2.first.construction_type  != ConstructibleSuffix ||
+               dummy2.second.construction_type != ConstructibleSuffix ||
+               dummy2.first.value  != 0 ||
+               dummy2.second.value != 0 ){
+               dummy.~MarkTypePair();
+               return 1;
+            }
+            dummy.~MarkTypePair();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            typedef pair MarkTypePair;
+            MarkTypePair dummy, dummy2(2, 2);
+            dummy.~MarkTypePair();
+            s0i.construct(&dummy, ::boost::move(dummy2));
+            if(dummy.first.construction_type  != ConstructiblePrefix ||
+               dummy.second.construction_type != ConstructiblePrefix ||
+               dummy.first.value  != 2 ||
+               dummy.second.value != 2 ||
+               dummy2.first.construction_type  != ConstructiblePrefix ||
+               dummy2.second.construction_type != ConstructiblePrefix ||
+               dummy2.first.value  != 0 ||
+               dummy2.second.value != 0 ){
+               dummy2.~MarkTypePair();
+               return 1;
+            }
+            dummy.~MarkTypePair();
+         }
+         //Check construction with related pair copy construction
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            typedef pair MarkTypePair;
+            MarkTypePair dummy;
+            pair dummy2;
+            dummy.~MarkTypePair();
+            s0i.construct(&dummy, dummy2);
+            if(dummy.first.construction_type  != NotUsesAllocator ||
+               dummy.second.construction_type != NotUsesAllocator ||
+               dummy.first.value  != 0 ||
+               dummy.second.value != 0 ){
+               dummy.~MarkTypePair();
+               return 1;
+            }
+            dummy.~MarkTypePair();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            typedef pair MarkTypePair;
+            MarkTypePair dummy;
+            pair dummy2(1, 1);
+            dummy.~MarkTypePair();
+            s0i.construct(&dummy, dummy2);
+            if(dummy.first.construction_type  != ConstructibleSuffix ||
+               dummy.second.construction_type != ConstructibleSuffix ||
+               dummy.first.value  != 1 ||
+               dummy.second.value != 1 ){
+               dummy.~MarkTypePair();
+               return 1;
+            }
+            dummy.~MarkTypePair();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            typedef pair MarkTypePair;
+            MarkTypePair dummy;
+            pair dummy2(2, 2);
+            dummy.~MarkTypePair();
+            s0i.construct(&dummy, dummy2);
+            if(dummy.first.construction_type  != ConstructiblePrefix ||
+               dummy.second.construction_type != ConstructiblePrefix ||
+               dummy.first.value  != 2 ||
+               dummy.second.value != 2 ){
+               dummy.~MarkTypePair();
+               return 1;
+            }
+            dummy.~MarkTypePair();
+         }
+         //Check construction with related pair move construction
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            typedef pair MarkTypePair;
+            MarkTypePair dummy;
+            pair dummy2(3, 3);
+            dummy.~MarkTypePair();
+            s0i.construct(&dummy, ::boost::move(dummy2));
+            if(dummy.first.construction_type  != NotUsesAllocator ||
+               dummy.second.construction_type != NotUsesAllocator ||
+               dummy.first.value  != 3 ||
+               dummy.second.value != 3 ){
+               dummy.~MarkTypePair();
+               return 1;
+            }
+            dummy.~MarkTypePair();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            typedef pair MarkTypePair;
+            MarkTypePair dummy;
+            pair dummy2(1, 1);
+            dummy.~MarkTypePair();
+            s0i.construct(&dummy, ::boost::move(dummy2));
+            if(dummy.first.construction_type  != ConstructibleSuffix ||
+               dummy.second.construction_type != ConstructibleSuffix ||
+               dummy.first.value  != 1 ||
+               dummy.second.value != 1 ){
+               dummy.~MarkTypePair();
+               return 1;
+            }
+            dummy.~MarkTypePair();
+         }
+         {
+            typedef ::mark_on_scoped_allocation MarkType;
+            typedef pair MarkTypePair;
+            MarkTypePair dummy;
+            pair dummy2(2, 2);
+            dummy.~MarkTypePair();
+            s0i.construct(&dummy, ::boost::move(dummy2));
+            if(dummy.first.construction_type  != ConstructiblePrefix ||
+               dummy.second.construction_type != ConstructiblePrefix ||
+               dummy.first.value  != 2 ||
+               dummy.second.value != 2 ){
+               dummy.~MarkTypePair();
+               return 1;
+            }
+            dummy.~MarkTypePair();
+         }
+      }
+   }
+
+   return 0;
+}
+#include 
diff --git a/test/set_test.hpp b/test/set_test.hpp
index 5dd6a2a..95dfee0 100644
--- a/test/set_test.hpp
+++ b/test/set_test.hpp
@@ -1,6 +1,6 @@
 ////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-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)
 //
diff --git a/test/slist_test.cpp b/test/slist_test.cpp
index fb9f28f..d1c80e3 100644
--- a/test/slist_test.cpp
+++ b/test/slist_test.cpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-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)
 //
diff --git a/test/stable_vector_test.cpp b/test/stable_vector_test.cpp
index edcd404..fe7d9e1 100644
--- a/test/stable_vector_test.cpp
+++ b/test/stable_vector_test.cpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-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)
 //
diff --git a/test/string_test.cpp b/test/string_test.cpp
index 3799d4a..c51e80b 100644
--- a/test/string_test.cpp
+++ b/test/string_test.cpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-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)
 //
diff --git a/test/tree_test.cpp b/test/tree_test.cpp
index 0717cce..dca5a31 100644
--- a/test/tree_test.cpp
+++ b/test/tree_test.cpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-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)
 //
@@ -201,8 +201,10 @@ void test_move()
 {
    //Now test move semantics
    C original;
+   original.emplace();
    C move_ctor(boost::move(original));
    C move_assign;
+   move_assign.emplace();
    move_assign = boost::move(move_ctor);
    move_assign.swap(original);
 }
diff --git a/test/util.hpp b/test/util.hpp
index eea3b00..9bfe1af 100644
--- a/test/util.hpp
+++ b/test/util.hpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-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)
 //
diff --git a/test/vector_test.cpp b/test/vector_test.cpp
index 3be90ae..6e393be 100644
--- a/test/vector_test.cpp
+++ b/test/vector_test.cpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-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)
 //
@@ -95,6 +95,26 @@ enum Test
 
 int main()
 {
+   const std::size_t positions_length = 10;
+   std::size_t positions[positions_length];
+   vector vector_int;
+   vector vector_int2(positions_length);
+   for(std::size_t i = 0; i != positions_length; ++i){
+      positions[i] = 0u;
+   }
+   for(std::size_t i = 0, max = vector_int2.size(); i != max; ++i){
+      vector_int2[i] = i;
+   }
+
+   vector_int.insert(vector_int.begin(), 999);
+
+   vector_int.insert_at_ordered_positions(positions, positions_length, vector_int2.end());
+
+   for(std::size_t i = 0, max = vector_int.size(); i != max; ++i){
+      std::cout << vector_int[i] << std::endl;
+   }
+   return 0;
+/*
    recursive_vector_test();
    {
       //Now test move semantics
@@ -134,7 +154,8 @@ int main()
 
    if(!boost::container::test::test_propagate_allocator())
       return 1;
-  
+
    return 0;
+  */
 }
 #include 
diff --git a/test/vector_test.hpp b/test/vector_test.hpp
index 4b6d7b7..847e9e8 100644
--- a/test/vector_test.hpp
+++ b/test/vector_test.hpp
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-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)
 //

From 64e3627f5c19541fd4971bd24ac83a11de973e65 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Fri, 23 Mar 2012 17:51:20 +0000
Subject: [PATCH 13/93] Fixed documentation comments

[SVN r77504]
---
 include/boost/container/scoped_allocator.hpp | 23 +++++++++++---------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/include/boost/container/scoped_allocator.hpp b/include/boost/container/scoped_allocator.hpp
index 88bbeb0..cbadff7 100644
--- a/include/boost/container/scoped_allocator.hpp
+++ b/include/boost/container/scoped_allocator.hpp
@@ -71,17 +71,9 @@ class scoped_allocator_adaptor;
 //! by an argument of a type that satisfies the Allocator requirements
 struct allocator_arg_t{};
 
-static const allocator_arg_t allocator_arg = allocator_arg_t();
-
-//! Remark: Automatically detects if T has a nested allocator_type that is convertible from 
-//! Alloc. Meets the BinaryTypeTrait requirements ([meta.rqmts] 20.4.1). A program may 
-//! specialize this type to derive from true_type for a T of user-defined type if T does not
-//! have a nested allocator_type but is nonetheless constructible using the specified Alloc. 
+//! A instance of type allocator_arg_t
 //!
-//! Result: derived from true_type if Convertible and 
-//! derived from false_type otherwise. 
-template 
-struct uses_allocator; 
+static const allocator_arg_t allocator_arg = allocator_arg_t();
 
 //! Remark: if a specialization is derived from true_type, indicates that T may be constructed 
 //! with an allocator as its last constructor argument.  Ideally, all constructors of T (including the 
@@ -207,11 +199,22 @@ struct uses_allocator_imp
 
 }  //namespace container_detail {
 
+///@endcond
+
+//! Remark: Automatically detects if T has a nested allocator_type that is convertible from 
+//! Alloc. Meets the BinaryTypeTrait requirements ([meta.rqmts] 20.4.1). A program may 
+//! specialize this type to derive from true_type for a T of user-defined type if T does not
+//! have a nested allocator_type but is nonetheless constructible using the specified Alloc. 
+//!
+//! Result: derived from true_type if Convertible and 
+//! derived from false_type otherwise.
 template 
 struct uses_allocator
    : boost::integral_constant::value>
 {};
 
+///@cond
+
 namespace container_detail {
 
 template 

From 90740ea8ea4fa1bb31844d9c89303b9ecc9223cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Fri, 23 Mar 2012 17:51:44 +0000
Subject: [PATCH 14/93] Fixed documentation comments

[SVN r77505]
---
 test/vector_test.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/vector_test.cpp b/test/vector_test.cpp
index 6e393be..cbc9721 100644
--- a/test/vector_test.cpp
+++ b/test/vector_test.cpp
@@ -108,13 +108,13 @@ int main()
 
    vector_int.insert(vector_int.begin(), 999);
 
-   vector_int.insert_at_ordered_positions(positions, positions_length, vector_int2.end());
+   //vector_int.insert_at_ordered_positions(positions, positions_length, vector_int2.end());
 
    for(std::size_t i = 0, max = vector_int.size(); i != max; ++i){
       std::cout << vector_int[i] << std::endl;
    }
    return 0;
-/*
+
    recursive_vector_test();
    {
       //Now test move semantics
@@ -156,6 +156,6 @@ int main()
       return 1;
 
    return 0;
-  */
+
 }
 #include 

From 7f1456c30fa5ed58af912d67352f55bc961be55e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Sat, 31 Mar 2012 20:52:06 +0000
Subject: [PATCH 15/93] Added missing typename in template alias

[SVN r77678]
---
 include/boost/container/allocator_traits.hpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/boost/container/allocator_traits.hpp b/include/boost/container/allocator_traits.hpp
index b4b3b01..b253cde 100644
--- a/include/boost/container/allocator_traits.hpp
+++ b/include/boost/container/allocator_traits.hpp
@@ -167,7 +167,7 @@ struct allocator_traits
 
       #if !defined(BOOST_NO_TEMPLATE_ALIASES)
          //C++11
-         template  using rebind_alloc  = boost::intrusive::detail::type_rebinder::type;
+         template  using rebind_alloc  = typename boost::intrusive::detail::type_rebinder::type;
          template  using rebind_traits = allocator_traits< rebind_alloc >;
       #else    // #if !defined(BOOST_NO_TEMPLATE_ALIASES)
          //Some workaround for C++03 or C++11 compilers with no template aliases

From 0098adea15500fde74cb1bec2a0a6f4dddce4397 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Sat, 31 Mar 2012 20:57:45 +0000
Subject: [PATCH 16/93] Added documentation on scoped allocators

[SVN r77679]
---
 doc/container.qbk    | 52 ++++++++++++++++++++++++++++++++++++++++----
 test/vector_test.cpp | 36 +++++++++++++++---------------
 2 files changed, 66 insertions(+), 22 deletions(-)

diff --git a/doc/container.qbk b/doc/container.qbk
index 464bd04..c446e60 100644
--- a/doc/container.qbk
+++ b/doc/container.qbk
@@ -422,10 +422,9 @@ to suppose two allocators of the same type always compare equal (that means that
 by one allocator object could be deallocated by another instance of the same type) and
 allocators were not swapped when the container was swapped.
 
-C++11 further improves stateful allocator support through the
-[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2554.pdf
-Scoped Allocators model]. [@http://en.cppreference.com/w/cpp/memory/allocator_traits
-`std::allocator_traits`] is the protocol between a container and an allocator, and
+C++11 further improves stateful allocator support through 
+[@http://en.cppreference.com/w/cpp/memory/allocator_traits `std::allocator_traits`].
+`std::allocator_traits` is the protocol between a container and an allocator, and
 an allocator writer can customize its behaviour (should the container propagate it in
 move constructor, swap, etc.?) following `allocator_traits` requirements. [*Boost.Container]
 not only supports this model with C++11 but also [*backports it to C++03]. 
@@ -437,6 +436,36 @@ not constructed on the fly when auxiliary memory is needed).
 
 [endsect]
 
+[section:scoped_allocator Scoped allocators]
+
+C++11 improves stateful allocators with the introduction of
+[@http://http://en.cppreference.com/w/cpp/memory/scoped_allocator_adaptor `std::scoped_allocator_adaptor`]
+class template. `scoped_allocator_adaptor` is instantiated with one outer allocator and zero or more inner
+allocators.
+
+A scoped allocator is a mechanism to automatically propagate the state of the allocator to the subobjects
+of a container in a controlled way. If instantiated with only one allocator type, the inner allocator
+becomes the `scoped_allocator_adaptor` itself, thus using the same allocator
+resource for the container and every element within the container and, if the elements themselves are
+containers, each of their elements recursively. If instantiated with more than one allocator, the first allocator
+is the outer allocator for use by the container, the second allocator is passed to the constructors of the
+container's elements, and, if the elements themselves are containers, the third allocator is passed to the
+elements' elements, and so on.
+
+[*Boost.Container] implements its own `scoped_allocator_adaptor` class and [*backports this feature also
+to C++03 compilers]. Due to C++03 limitations, in those compilers 
+the allocator propagation implemented by `scoped_allocator_adaptor::construct` functions
+will be based on traits([classref boost::container::constructible_with_allocator_suffix constructible_with_allocator_suffix]
+and [classref boost::container::constructible_with_allocator_prefix constructible_with_allocator_prefix])
+proposed in [@http://www.open-std.org/jtc1/sc22/WG21/docs/papers/2008/n2554.pdf 
+N2554: The Scoped Allocator Model (Rev 2) proposal]. In conforming C++11 compilers or compilers supporting SFINAE
+expressions (when `BOOST_NO_SFINAE_EXPR` is NOT defined), traits are ignored and C++11 rules 
+(`is_constructible::value` and 
+`is_constructible::value`)
+will be used to detect if the allocator must be propagated with suffix or prefix allocator arguments.
+
+[endsect]
+
 [section:initializer_lists Initializer lists]
 
 [*Boost.Container] does not support initializer lists when constructing or assigning containers
@@ -585,6 +614,21 @@ use [*Boost.Container]? There are several reasons for that:
 
 [section:release_notes Release Notes]
 
+[section:release_notes_boost_1_50_00 Boost 1.50 Release]
+
+*  Added Scoped Allocator Model support.
+
+*  Fixed bugs
+  [@https://svn.boost.org/trac/boost/ticket/6566 #6566],
+  [@https://svn.boost.org/trac/boost/ticket/6575 #6575],
+  [@https://svn.boost.org/trac/boost/ticket/6606 #6606],
+  [@https://svn.boost.org/trac/boost/ticket/6615 #6615],
+  [@https://svn.boost.org/trac/boost/ticket/6533 #6533],
+  [@https://svn.boost.org/trac/boost/ticket/6536 #6536],
+
+[endsect]
+
+
 [section:release_notes_boost_1_49_00 Boost 1.49 Release]
 
 *  Fixed bugs
diff --git a/test/vector_test.cpp b/test/vector_test.cpp
index cbc9721..bf99fea 100644
--- a/test/vector_test.cpp
+++ b/test/vector_test.cpp
@@ -94,27 +94,27 @@ enum Test
 };
 
 int main()
-{
-   const std::size_t positions_length = 10;
-   std::size_t positions[positions_length];
-   vector vector_int;
-   vector vector_int2(positions_length);
-   for(std::size_t i = 0; i != positions_length; ++i){
-      positions[i] = 0u;
-   }
-   for(std::size_t i = 0, max = vector_int2.size(); i != max; ++i){
-      vector_int2[i] = i;
-   }
+{/*
+   {
+      const std::size_t positions_length = 10;
+      std::size_t positions[positions_length];
+      vector vector_int;
+      vector vector_int2(positions_length);
+      for(std::size_t i = 0; i != positions_length; ++i){
+         positions[i] = 0u;
+      }
+      for(std::size_t i = 0, max = vector_int2.size(); i != max; ++i){
+         vector_int2[i] = i;
+      }
 
-   vector_int.insert(vector_int.begin(), 999);
+      vector_int.insert(vector_int.begin(), 999);
 
-   //vector_int.insert_at_ordered_positions(positions, positions_length, vector_int2.end());
-
-   for(std::size_t i = 0, max = vector_int.size(); i != max; ++i){
-      std::cout << vector_int[i] << std::endl;
-   }
-   return 0;
+      vector_int.insert_ordered_at(positions_length, positions + positions_length, vector_int2.end());
 
+      for(std::size_t i = 0, max = vector_int.size(); i != max; ++i){
+         std::cout << vector_int[i] << std::endl;
+      }
+   }*/
    recursive_vector_test();
    {
       //Now test move semantics

From d8fda23564317ec702ac9051824bf7362ac7be20 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Tue, 10 Apr 2012 20:04:35 +0000
Subject: [PATCH 17/93] Make ordered insertion tags more iterator_tag-like.

[SVN r77894]
---
 include/boost/container/container_fwd.hpp | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/include/boost/container/container_fwd.hpp b/include/boost/container/container_fwd.hpp
index affea83..cf8d6e6 100644
--- a/include/boost/container/container_fwd.hpp
+++ b/include/boost/container/container_fwd.hpp
@@ -132,26 +132,22 @@ class basic_string;
 
 //! Type used to tag that the input range is
 //! guaranteed to be ordered
-struct ordered_range_impl_t {};
+struct ordered_range_t
+{};
 
 //! Type used to tag that the input range is
 //! guaranteed to be ordered and unique
-struct ordered_unique_range_impl_t{};
-
-/// @cond
-
-typedef ordered_range_impl_t * ordered_range_t;
-typedef ordered_unique_range_impl_t *ordered_unique_range_t;
-
-/// @endcond
+struct ordered_unique_range_t
+   : public ordered_range_t
+{};
 
 //! Value used to tag that the input range is
 //! guaranteed to be ordered
-static const ordered_range_t ordered_range = 0;
+static const ordered_range_t ordered_range = ordered_range_t();
 
 //! Value used to tag that the input range is
 //! guaranteed to be ordered and unique
-static const ordered_unique_range_t ordered_unique_range = 0;
+static const ordered_unique_range_t ordered_unique_range = ordered_unique_range_t();
 
 /// @cond
 

From a3772374011b9566ede798379da2c456bc9ede57 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Tue, 10 Apr 2012 20:14:31 +0000
Subject: [PATCH 18/93] Changed ordered insertion function and added comments

[SVN r77895]
---
 include/boost/container/detail/flat_tree.hpp | 52 +++++++++++++++++---
 1 file changed, 44 insertions(+), 8 deletions(-)

diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp
index 1cbe8da..960a491 100644
--- a/include/boost/container/detail/flat_tree.hpp
+++ b/include/boost/container/detail/flat_tree.hpp
@@ -301,7 +301,6 @@ class flat_tree
       return ret;
    }
 
-
    iterator insert_equal(const value_type& val)
    {
       iterator i = this->upper_bound(KeyOfValue()(val));
@@ -339,14 +338,14 @@ class flat_tree
    iterator insert_equal(const_iterator pos, const value_type& val)
    {
       insert_commit_data data;
-      priv_insert_equal_prepare(pos, val, data);
+      this->priv_insert_equal_prepare(pos, val, data);
       return priv_insert_commit(data, val);
    }
 
    iterator insert_equal(const_iterator pos, BOOST_RV_REF(value_type) mval)
    {
       insert_commit_data data;
-      priv_insert_equal_prepare(pos, mval, data);
+      this->priv_insert_equal_prepare(pos, mval, data);
       return priv_insert_commit(data, boost::move(mval));
    }
 
@@ -362,7 +361,15 @@ class flat_tree
    {
       typedef typename 
          std::iterator_traits::iterator_category ItCat;
-      priv_insert_equal(first, last, ItCat());
+      this->priv_insert_equal(first, last, ItCat());
+   }
+
+   template 
+   void insert_equal(ordered_range_t, InIt first, InIt last)
+   {
+      typedef typename 
+         std::iterator_traits::iterator_category ItCat;
+      this->priv_insert_equal(ordered_range_t(), first, last, ItCat());
    }
 
    #ifdef BOOST_CONTAINER_PERFECT_FORWARDING
@@ -406,7 +413,7 @@ class flat_tree
    {
       value_type &&val = value_type(boost::forward(args)...);
       insert_commit_data data;
-      priv_insert_equal_prepare(hint, val, data);
+      this->priv_insert_equal_prepare(hint, val, data);
       return priv_insert_commit(data, boost::move(val));
    }
 
@@ -466,7 +473,7 @@ class flat_tree
             BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) BOOST_PP_RPAREN_IF(n);  \
       value_type &val = vval;                                                             \
       insert_commit_data data;                                                            \
-      priv_insert_equal_prepare(hint, val, data);                                         \
+      this->priv_insert_equal_prepare(hint, val, data);                                   \
       return priv_insert_commit(data, boost::move(val));                                  \
    }                                                                                      \
    //!
@@ -746,10 +753,39 @@ class flat_tree
       return std::pair(first, first);
    }
 
-   template 
-   void priv_insert_equal(FwdIt first, FwdIt last, std::forward_iterator_tag)
+   template 
+   void priv_insert_equal(ordered_range_t, BidirIt first, BidirIt last, std::bidirectional_iterator_tag)
    {
       size_type len = static_cast(std::distance(first, last));
+      const size_type BurstSize = 16;
+      size_type positions[BurstSize];
+
+      while(len){
+         const size_type burst = len < BurstSize ? len : BurstSize;
+         len -= burst;
+         const iterator beg(this->cbegin());
+         iterator pos;
+         for(size_type i = 0; i != burst; ++i){
+            pos = this->upper_bound(KeyOfValue()(*first));
+            positions[i] = static_cast(pos - beg);
+            ++first;
+         }
+         this->m_data.m_vect.insert_ordered_at(burst, positions + burst, first);
+      }
+   }
+
+   template 
+   void priv_insert_equal_forward(ordered_range_t, FwdIt first, FwdIt last, std::forward_iterator_tag)
+   {  this->priv_insert_equal(first, last, std::forward_iterator_tag());   }
+
+   template 
+   void priv_insert_equal(ordered_range_t, InIt first, InIt last, std::input_iterator_tag)
+   {  this->priv_insert_equal(first, last, std::input_iterator_tag());  }
+
+   template 
+   void priv_insert_equal_forward(FwdIt first, FwdIt last, std::forward_iterator_tag)
+   {
+      const size_type len = static_cast(std::distance(first, last));
       this->reserve(this->size()+len);
       this->priv_insert_equal(first, last, std::input_iterator_tag());
    }

From e6fd299292f724243676324aa6cfbe3fba7ff5b8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Tue, 10 Apr 2012 20:16:14 +0000
Subject: [PATCH 19/93] Added SFINAE to constructors

[SVN r77896]
---
 include/boost/container/detail/pair.hpp | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/include/boost/container/detail/pair.hpp b/include/boost/container/detail/pair.hpp
index 3c3ae38..af32d6a 100644
--- a/include/boost/container/detail/pair.hpp
+++ b/include/boost/container/detail/pair.hpp
@@ -20,6 +20,8 @@
 #include "config_begin.hpp"
 #include 
 
+#include 
+#include 
 #include 
 #include 
 
@@ -211,7 +213,11 @@ struct pair
    }
 
    template 
-   pair& operator=(const pair&p)
+   typename ::boost::container::container_detail::enable_if_c
+      < !(::boost::container::container_detail::is_same::value &&
+          ::boost::container::container_detail::is_same::value)
+      , pair &>::type
+      operator=(const pair&p)
    {
       first  = p.first;
       second = p.second;
@@ -219,7 +225,11 @@ struct pair
    }
 
    template 
-   pair& operator=(BOOST_RV_REF_BEG pair BOOST_RV_REF_END p)
+   typename ::boost::container::container_detail::enable_if_c
+      < !(::boost::container::container_detail::is_same::value &&
+          ::boost::container::container_detail::is_same::value)
+      , pair &>::type
+      operator=(BOOST_RV_REF_BEG pair BOOST_RV_REF_END p)
    {
       first  = ::boost::move(p.first);
       second = ::boost::move(p.second);

From 199b9dca8cbfc746d7a0323c3a486e0249e39065 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Tue, 10 Apr 2012 20:18:37 +0000
Subject: [PATCH 20/93] Fix for Visual 11

[SVN r77898]
---
 .../boost/container/detail/preprocessor.hpp   | 21 +++++++++----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/include/boost/container/detail/preprocessor.hpp b/include/boost/container/detail/preprocessor.hpp
index edea7a0..051c17a 100644
--- a/include/boost/container/detail/preprocessor.hpp
+++ b/include/boost/container/detail/preprocessor.hpp
@@ -78,17 +78,16 @@ const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \
 
 #ifndef BOOST_NO_RVALUE_REFERENCES
 
-   #ifdef BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
+   #if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
 
-      #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \
-      BOOST_PP_CAT(m_p, n) (boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) ))           \
-      //!
+   #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \
+   BOOST_PP_CAT(m_p, n) (static_cast( BOOST_PP_CAT(p, n) ))           \
 
-   #else    //BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
+   #else //#if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
 
-      #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \
-      BOOST_PP_CAT(m_p, n) (static_cast( BOOST_PP_CAT(p, n) ))           \
-      //!
+   #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \
+   BOOST_PP_CAT(m_p, n) (::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) ))           \
+   //!
 
    #endif   //BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
 
@@ -131,7 +130,7 @@ const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \
 #else //!defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
 
    #define BOOST_CONTAINER_PP_MEMBER_FORWARD(z, n, data) \
-   boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(this->m_p, n) ) \
+   ::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(this->m_p, n) ) \
    //!
 
 #endif   //!defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
@@ -144,11 +143,11 @@ const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \
 
 
 #define BOOST_CONTAINER_PP_PARAM_FORWARD(z, n, data) \
-boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) ) \
+::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) ) \
 //!
 
 #define BOOST_CONTAINER_PP_DECLVAL(z, n, data) \
-boost::move_detail::declval< BOOST_PP_CAT(P, n) >() \
+::boost::move_detail::declval< BOOST_PP_CAT(P, n) >() \
 //!
 
 #define BOOST_CONTAINER_PP_MEMBER_IT_FORWARD(z, n, data) \

From ed523da2bcfcaf75a3e4202ea3235908f61c8fda Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Wed, 11 Apr 2012 06:24:09 +0000
Subject: [PATCH 21/93] Added equal_range and range insertion test prototypes.

[SVN r77908]
---
 test/map_test.hpp    | 15 +++++++++++----
 test/vector_test.cpp |  4 ++--
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/test/map_test.hpp b/test/map_test.hpp
index 5eee229..45efc31 100644
--- a/test/map_test.hpp
+++ b/test/map_test.hpp
@@ -387,10 +387,17 @@ int map_test ()
                return 1;
             if(!CheckEqualPairContainers(boostmultimap, stdmultimap))
                return 1;
-            {
-               IntType i1(i);
-               IntType i2(i);
-               new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
+            {  //Check equal_range
+               std::pair bret =
+                  boostmultimap->equal_range(boostmultimap->begin()->first);
+
+               std::pair   sret =
+                  stdmultimap->equal_range(stdmultimap->begin()->first);
+         
+               if( std::distance(bret.first, bret.second) !=
+                   std::distance(sret.first, sret.second) ){
+                  return 1;
+               }
             }
             {
                IntType i1(i);
diff --git a/test/vector_test.cpp b/test/vector_test.cpp
index bf99fea..d7fc47c 100644
--- a/test/vector_test.cpp
+++ b/test/vector_test.cpp
@@ -94,7 +94,7 @@ enum Test
 };
 
 int main()
-{/*
+{
    {
       const std::size_t positions_length = 10;
       std::size_t positions[positions_length];
@@ -114,7 +114,7 @@ int main()
       for(std::size_t i = 0, max = vector_int.size(); i != max; ++i){
          std::cout << vector_int[i] << std::endl;
       }
-   }*/
+   }
    recursive_vector_test();
    {
       //Now test move semantics

From ffde790ae098db36aea86972e8f074af0bba53eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Wed, 11 Apr 2012 06:26:20 +0000
Subject: [PATCH 22/93] Updated scoped allocator support

[SVN r77911]
---
 include/boost/container/detail/tree.hpp      |  52 ++-------
 include/boost/container/flat_map.hpp         |  26 +++--
 include/boost/container/list.hpp             |   6 --
 include/boost/container/scoped_allocator.hpp | 105 ++++++++++---------
 include/boost/container/slist.hpp            |   6 --
 include/boost/container/stable_vector.hpp    |   6 --
 include/boost/container/vector.hpp           |  89 +++++++++++++---
 7 files changed, 154 insertions(+), 136 deletions(-)

diff --git a/include/boost/container/detail/tree.hpp b/include/boost/container/detail/tree.hpp
index e9a4bdd..178c29d 100644
--- a/include/boost/container/detail/tree.hpp
+++ b/include/boost/container/detail/tree.hpp
@@ -110,8 +110,9 @@ template 
 struct rbtree_node
    :  public rbtree_hook::type
 {
-   //private:
+   private:
    //BOOST_COPYABLE_AND_MOVABLE(rbtree_node)
+   rbtree_node();
 
    public:
    typedef typename rbtree_hook::type hook_type;
@@ -121,46 +122,6 @@ struct rbtree_node
 
    typedef rbtree_node node_type;
 
-   private:
-   rbtree_node();
-   rbtree_node (const rbtree_node &);
-   rbtree_node & operator=(const rbtree_node &);
-
-/*
-   rbtree_node(const rbtree_node &other)
-      : m_data(other.m_data)
-   {}
-
-   rbtree_node(BOOST_RV_REF(rbtree_node) other)
-      : m_data(::boost::move(other.m_data))
-   {}
-
-   #ifndef BOOST_CONTAINER_PERFECT_FORWARDING
-
-   #define BOOST_PP_LOCAL_MACRO(n)                                           \
-   template                                \
-   rbtree_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()
-
-   #else //#ifndef BOOST_CONTAINER_PERFECT_FORWARDING
-
-   template
-   rbtree_node(Args &&...args)
-      : m_data(boost::forward(args)...)
-   {}
-   #endif//#ifndef BOOST_CONTAINER_PERFECT_FORWARDING
-
-   rbtree_node &operator=(const rbtree_node &other)
-   {  do_assign(other.m_data);   return *this;  }
-
-   rbtree_node &operator=(BOOST_RV_REF(rbtree_node) other)
-   {  do_move_assign(other.m_data);   return *this;  }
-*/
-   public:
    T &get_data()
    {
       T* ptr = reinterpret_cast(&this->m_data);
@@ -173,7 +134,6 @@ struct rbtree_node
       return *ptr;
    }
 
-//   private:
    internal_type m_data;
 
    template
@@ -900,9 +860,9 @@ class rbtree
       if(this->empty()){
          //Insert with end hint, to achieve linear
          //complexity if [first, last) is ordered
-         const_iterator end(this->end());
+         const_iterator hint(this->cend());
          for( ; first != last; ++first)
-            this->insert_unique(end, *first);
+            hint = this->insert_unique(hint, *first);
       }
       else{
          for( ; first != last; ++first)
@@ -941,9 +901,9 @@ class rbtree
    {
       //Insert with end hint, to achieve linear
       //complexity if [first, last) is ordered
-      const_iterator end(this->cend());
+      const_iterator hint(this->cend());
       for( ; first != last; ++first)
-         this->insert_equal(end, *first);
+         hint = this->insert_equal(hint, *first);
    }
 
    iterator erase(const_iterator position)
diff --git a/include/boost/container/flat_map.hpp b/include/boost/container/flat_map.hpp
index 93429f3..f2b8e34 100644
--- a/include/boost/container/flat_map.hpp
+++ b/include/boost/container/flat_map.hpp
@@ -165,8 +165,13 @@ class flat_map
       get_flat_tree_iterators
          ::const_reverse_iterator                  const_reverse_iterator;
    typedef A                                                allocator_type;
+   
+   //!Standard extension
    typedef A                                                stored_allocator_type;
 
+   //!Standard extension for C++03 compilers with non-movable std::pair
+   typedef impl_value_type                                  movable_value_type;
+
    public:
    //! Effects: Default constructs an empty flat_map.
    //! 
@@ -499,7 +504,7 @@ class flat_map
    //!   to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   std::pair insert(BOOST_RV_REF(impl_value_type) x) 
+   std::pair insert(BOOST_RV_REF(movable_value_type) x) 
    {
       return container_detail::force >
       (m_flat_tree.insert_unique(boost::move(x)));
@@ -530,8 +535,11 @@ class flat_map
    //!
    //! Note: If an element is inserted it might invalidate elements.
    iterator insert(const_iterator position, BOOST_RV_REF(value_type) x)
-      { return container_detail::force_copy
-         (m_flat_tree.insert_unique(container_detail::force(position), boost::move(container_detail::force(x)))); }
+   {
+      return container_detail::force_copy
+         (m_flat_tree.insert_unique( container_detail::force(position)
+                                   , boost::move(container_detail::force(x))));
+   }
 
    //! Effects: Inserts an element move constructed from x in the container.
    //!   p is a hint pointing to where the insert should start to search.
@@ -542,7 +550,7 @@ class flat_map
    //!   right before p) plus insertion linear to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(const_iterator position, BOOST_RV_REF(impl_value_type) x)
+   iterator insert(const_iterator position, BOOST_RV_REF(movable_value_type) x)
    {
       return container_detail::force_copy(
          m_flat_tree.insert_unique(container_detail::force(position), boost::move(x)));
@@ -719,13 +727,13 @@ class flat_map
    //!
    //! Complexity: Logarithmic
    std::pair equal_range(const key_type& x) 
-      {  return container_detail::force >(m_flat_tree.equal_range(x)); }
+      {  return container_detail::force_copy >(m_flat_tree.equal_range(x)); }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
    std::pair equal_range(const key_type& x) const 
-      {  return container_detail::force >(m_flat_tree.equal_range(x)); }
+      {  return container_detail::force_copy >(m_flat_tree.equal_range(x)); }
 
    //! Effects: Number of elements for which memory has been allocated.
    //!   capacity() is always greater than or equal to size().
@@ -931,6 +939,8 @@ class flat_multimap
    typedef A                                                allocator_type;
    //Non-standard extension
    typedef A                                                stored_allocator_type;
+   //!Standard extension for C++03 compilers with non-movable std::pair
+   typedef impl_value_type                                  movable_value_type;
 
    //! Effects: Default constructs an empty flat_map.
    //! 
@@ -1389,14 +1399,14 @@ class flat_multimap
    //!
    //! Complexity: Logarithmic
    std::pair equal_range(const key_type& x) 
-      {  return container_detail::force_copy >(m_flat_tree.equal_range(x));   }
+      {  return container_detail::force >(m_flat_tree.equal_range(x));   }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
    std::pair 
       equal_range(const key_type& x) const 
-      {  return container_detail::force_copy >(m_flat_tree.equal_range(x));   }
+      {  return container_detail::force >(m_flat_tree.equal_range(x));   }
 
    //! Effects: Number of elements for which memory has been allocated.
    //!   capacity() is always greater than or equal to size().
diff --git a/include/boost/container/list.hpp b/include/boost/container/list.hpp
index 512835a..744ddff 100644
--- a/include/boost/container/list.hpp
+++ b/include/boost/container/list.hpp
@@ -65,12 +65,6 @@ template 
 struct list_node
    :  public list_hook::type
 {
-   private:
-   list_node();
-   list_node(const list_node &);
-   list_node & operator=(const list_node &);
-
-   public:
    typedef typename list_hook::type hook_type;
    T m_data;
 };
diff --git a/include/boost/container/scoped_allocator.hpp b/include/boost/container/scoped_allocator.hpp
index cbadff7..d9023f8 100644
--- a/include/boost/container/scoped_allocator.hpp
+++ b/include/boost/container/scoped_allocator.hpp
@@ -294,8 +294,6 @@ namespace container_detail {
 // Check if we can detect is_convertible using advanced SFINAE expressions
 #if !defined(BOOST_NO_SFINAE_EXPR)
 
-   #define BOOST_CONTAINER_IS_CONSTRUCTIBLE_AVAILABLE
-
    //! Code inspired by Mathias Gaunard's is_convertible.cpp found in the Boost mailing list
    //! http://boost.2283326.n4.nabble.com/type-traits-is-constructible-when-decltype-is-supported-td3575452.html
    //! Thanks Mathias!
@@ -973,14 +971,18 @@ class scoped_allocator_adaptor_base
    //! and, if the elements themselves are containers, the third allocator is passed to 
    //! the elements' elements, and so on. If containers are nested to a depth greater 
    //! than the number of allocators, the last allocator is used repeatedly, as in the 
-   //! single-allocator case, for any remaining recursions. [Note: The
+   //! single-allocator case, for any remaining recursions. 
+   //!
+   //! [Note: The
    //! scoped_allocator_adaptor is derived from the outer allocator type so it can be 
    //! substituted for the outer allocator type in most expressions. -end note]
    //!
    //! In the construct member functions, `OUTERMOST(x)` is x if x does not have 
    //! an `outer_allocator()` member function and
    //! `OUTERMOST(x.outer_allocator())` otherwise; `OUTERMOST_ALLOC_TRAITS(x)` is
-   //! `allocator_traits`. [Note: `OUTERMOST(x)` and
+   //! `allocator_traits`.
+   //!
+   //! [Note: `OUTERMOST(x)` and
    //! `OUTERMOST_ALLOC_TRAITS(x)` are recursive operations. It is incumbent upon 
    //! the definition of `outer_allocator()` to ensure that the recursion terminates. 
    //! It will terminate for all instantiations of scoped_allocator_adaptor. -end note]
@@ -1067,7 +1069,7 @@ class scoped_allocator_adaptor
          > other;
    };
 
-   //! Effects: value-initializes the OuterAlloc base class
+   //! Effects: value-initializes the OuterAlloc base class
    //! and the inner allocator object.
    scoped_allocator_adaptor()
       {}
@@ -1075,13 +1077,13 @@ class scoped_allocator_adaptor
    ~scoped_allocator_adaptor()
       {}
 
-   //! Effects: initializes each allocator within the adaptor with
+   //! Effects: initializes each allocator within the adaptor with
    //! the corresponding allocator from other.
    scoped_allocator_adaptor(const scoped_allocator_adaptor& other)
       : base_type(other.base())
       {}
 
-   //! Effects: move constructs each allocator within the adaptor with 
+   //! Effects: move constructs each allocator within the adaptor with 
    //! the corresponding allocator from other.
    scoped_allocator_adaptor(BOOST_RV_REF(scoped_allocator_adaptor) other)
       : base_type(::boost::move(other.base()))
@@ -1089,8 +1091,9 @@ class scoped_allocator_adaptor
 
    #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
-   //! Requires: OuterAlloc shall be constructible from OuterA2.
-   //! Effects: initializes the OuterAlloc base class with boost::forward(outerAlloc) and inner
+   //! Requires: OuterAlloc shall be constructible from OuterA2.
+   //!
+   //! Effects: initializes the OuterAlloc base class with boost::forward(outerAlloc) and inner
    //! with innerAllocs...(hence recursively initializing each allocator within the adaptor with the 
    //! corresponding allocator from the argument list).
    template 
@@ -1113,8 +1116,9 @@ class scoped_allocator_adaptor
 
    #endif   // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
-   //! Requires: OuterAlloc shall be constructible from OuterA2.
-   //! Effects: initializes each allocator within the adaptor with the corresponding allocator from other.
+   //! Requires: OuterAlloc shall be constructible from OuterA2.
+   //!
+   //! Effects: initializes each allocator within the adaptor with the corresponding allocator from other.
    template 
    scoped_allocator_adaptor(const scoped_allocator_adaptorRequires: OuterAlloc shall be constructible from OuterA2.
+   //!
+   //! Effects: initializes each allocator within the adaptor with the corresponding allocator 
    //! rvalue from other.
    template 
    scoped_allocator_adaptor(BOOST_RV_REF_BEG scoped_allocator_adaptor(*this).
+   //! Returns:
+   //!   `static_cast(*this)`.
    outer_allocator_type      & outer_allocator()
       {  return *this; }
 
-   //! Returns:
-   //!   static_cast(*this).
+   //! Returns:
+   //!   `static_cast(*this)`.
    const outer_allocator_type &outer_allocator() const
       {  return *this; }
 
-   //! Returns:
-   //!   *this if sizeof...(InnerAllocs) is zero; otherwise, inner.
+   //! Returns:
+   //!   *this if `sizeof...(InnerAllocs)` is zero; otherwise, inner.
    inner_allocator_type&       inner_allocator()
       {  return base_type::inner_allocator(); }
 
-   //! Returns:
-   //!   *this if sizeof...(InnerAllocs) is zero; otherwise, inner.
+   //! Returns:
+   //!   *this if `sizeof...(InnerAllocs)` is zero; otherwise, inner.
    inner_allocator_type const& inner_allocator() const
       {  return base_type::inner_allocator(); }
 
-   //! Returns:
-   //!   allocator_traits::max_size(outer_allocator()).
+   //! Returns:
+   //!   `allocator_traits::max_size(outer_allocator())`.
    size_type max_size() const
    {
       return outer_traits_type::max_size(this->outer_allocator());
    }
 
-   //! Effects: 
-   //!   calls OUTERMOST_ALLOC_TRAITS(*this)::destroy(OUTERMOST(*this), p).
+   //! Effects: 
+   //!   calls `OUTERMOST_ALLOC_TRAITS(*this)::destroy(OUTERMOST(*this), p)`.
    template 
    void destroy(T* p)
    {
@@ -1188,30 +1193,30 @@ class scoped_allocator_adaptor
          ::destroy(get_outermost_allocator(this->outer_allocator()), p);
    }
 
-   //! Returns: 
-   //! allocator_traits::allocate(outer_allocator(), n).
+   //! Returns: 
+   //! `allocator_traits::allocate(outer_allocator(), n)`.
    pointer allocate(size_type n)
    {
       return outer_traits_type::allocate(this->outer_allocator(), n);
    }
 
-   //! Returns: 
-   //! allocator_traits::allocate(outer_allocator(), n, hint).
+   //! Returns: 
+   //! `allocator_traits::allocate(outer_allocator(), n, hint)`.
    pointer allocate(size_type n, const_void_pointer hint)
    {
       return outer_traits_type::allocate(this->outer_allocator(), n, hint);
    }
 
-   //! Effects:
-   //! allocator_traits::deallocate(outer_allocator(), p, n);
+   //! Effects:
+   //! `allocator_traits::deallocate(outer_allocator(), p, n)`.
    void deallocate(pointer p, size_type n)
    {
       outer_traits_type::deallocate(this->outer_allocator(), p, n);
    }
 
-   //! Returns: A new scoped_allocator_adaptor object where each allocator
+   //! Returns: A new scoped_allocator_adaptor object where each allocator
    //! A in the adaptor is initialized from the result of calling 
-   //! allocator_traits::select_on_container_copy_construction() on
+   //! `allocator_traits::select_on_container_copy_construction()` on
    //! the corresponding allocator in *this.
    scoped_allocator_adaptor select_on_container_copy_construction() const
    {
@@ -1228,30 +1233,32 @@ class scoped_allocator_adaptor
 
    #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
-   //! Effects:
-   //! 1) If uses_allocator::value is false calls
-   //!    OUTERMOST_ALLOC_TRAITS(*this)::construct
-   //!       (OUTERMOST(*this), p, std::forward(args)...).
+   //! Effects:
+   //! 1) If `uses_allocator::value` is false calls
+   //!    `OUTERMOST_ALLOC_TRAITS(*this)::construct
+   //!       (OUTERMOST(*this), p, std::forward(args)...)`.
    //! 
-   //! 2) Otherwise, if uses_allocator::value is true and 
-   //!    is_constructible::value is true, calls
-   //!    OUTERMOST_ALLOC_TRAITS(*this)::construct(OUTERMOST(*this), p, allocator_arg,
-   //! inner_allocator(), std::forward(args)...).
+   //! 2) Otherwise, if `uses_allocator::value` is true and 
+   //!    `is_constructible::value` is true, calls
+   //!    `OUTERMOST_ALLOC_TRAITS(*this)::construct(OUTERMOST(*this), p, allocator_arg,
+   //!    inner_allocator(), std::forward(args)...)`.
    //! 
-   //! [Note: In compilers without advanced decltype SFINAE support, is_constructible can't be,
-   //! implemented so that condition will be replaced by
+   //! [Note: In compilers without advanced decltype SFINAE support, `is_constructible` can't
+   //! be implemented so that condition will be replaced by
    //! constructible_with_allocator_prefix::value. -end note]
    //!
    //! 3) Otherwise, if uses_allocator::value is true and 
-   //!    is_constructible::value is true, calls 
-   //!    OUTERMOST_ALLOC_TRAITS(*this)::construct(OUTERMOST(*this), p, 
-   //!    std::forward(args)..., inner_allocator()).
+   //!    `is_constructible::value` is true, calls 
+   //!    `OUTERMOST_ALLOC_TRAITS(*this)::construct(OUTERMOST(*this), p, 
+   //!    std::forward(args)..., inner_allocator())`.
    //! 
-   //! [Note: In compilers without advanced decltype SFINAE support, is_constructible can't be,
+   //! [Note: In compilers without advanced decltype SFINAE support, `is_constructible` can't be
    //! implemented so that condition will be replaced by
-   //! constructible_with_allocator_suffix::value. -end note]
+   //! `constructible_with_allocator_suffix::value`. -end note]
    //!
-   //! 4) Otherwise, the program is ill-formed. [Note: An error will result if uses_allocator evaluates
+   //! 4) Otherwise, the program is ill-formed.
+   //!
+   //! [Note: An error will result if `uses_allocator` evaluates
    //! to true but the specific constructor does not take an allocator. This definition prevents a silent
    //! failure to pass an inner allocator to a contained element. -end note]
    template < typename T, class ...Args>
diff --git a/include/boost/container/slist.hpp b/include/boost/container/slist.hpp
index 3146c0f..70a2cbb 100644
--- a/include/boost/container/slist.hpp
+++ b/include/boost/container/slist.hpp
@@ -65,12 +65,6 @@ template 
 struct slist_node
    :  public slist_hook::type
 {
-   private:
-   slist_node();
-   slist_node(const slist_node &);
-   slist_node & operator=(const slist_node &);
-
-   public:
    typedef typename slist_hook::type hook_type;
    T m_data;
 };
diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp
index 2d15f46..3f29a86 100644
--- a/include/boost/container/stable_vector.hpp
+++ b/include/boost/container/stable_vector.hpp
@@ -119,12 +119,6 @@ template
 struct node_type
    : public node_type_base
 {
-   private:
-   node_type();
-   node_type(const node_type &);
-   node_type & operator=(const node_type &);
-
-   public:
    T value;
 };
 
diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp
index 66e86ee..6b590fb 100644
--- a/include/boost/container/vector.hpp
+++ b/include/boost/container/vector.hpp
@@ -1463,9 +1463,10 @@ class vector : private container_detail::vector_alloc_holder
       }
    }
 
-   private:
-   template
-   void insert_at_ordered_positions(const size_type *positions, size_type element_count, BiDirIt end)
+   public:
+   //Absolutely experimental. This function might change, disappear or simply crash!
+   template
+   void insert_ordered_at(size_type element_count, BiDirPosIt last_position_it, BiDirValueIt last_value_it)
    {
       const size_type old_size_pos = this->size();
       this->reserve(old_size_pos + element_count);
@@ -1481,16 +1482,16 @@ class vector : private container_detail::vector_alloc_holder
       //Loop for each insertion backwards, first moving the elements after the insertion point,
       //then inserting the element.
       while(insertions_left){
-         const size_type pos = positions[insertions_left - 1];
+         const size_type pos = static_cast(*(--last_position_it));
          BOOST_ASSERT(pos <= old_size_pos);
          //Shift the range after the insertion point, function will take care if the shift
          //crosses the size() boundary, using copy/move or uninitialized copy/move if necessary.
-         size_type new_hole_size = shift_range(pos, next_pos, this->size(), insertions_left);
+         size_type new_hole_size = insert_ordered_at_shift_range(pos, next_pos, this->size(), insertions_left);
          if(new_hole_size > 0){
-            //The hole was reduced by shift_range so expand exception rollback range backwards
+            //The hole was reduced by insert_ordered_at_shift_range so expand exception rollback range backwards
             past_hole_values_destroyer.increment_size_backwards(next_pos - pos);
             //Insert the new value in the hole
-            allocator_traits_type::construct(this->alloc(), begin_ptr + pos + insertions_left - 1, *(--end));
+            allocator_traits_type::construct(this->alloc(), begin_ptr + pos + insertions_left - 1, *(--last_value_it));
             --new_hole_size;
             if(new_hole_size == 0){
                //Hole was just filled, disable exception rollback and change vector size
@@ -1504,12 +1505,12 @@ class vector : private container_detail::vector_alloc_holder
          }
          else{
             if(hole_size){
-               //Hole was just filled by shift_range, disable exception rollback and change vector size
+               //Hole was just filled by insert_ordered_at_shift_range, disable exception rollback and change vector size
                past_hole_values_destroyer.release();
                this->members_.m_size += element_count;
             }
             //Insert the new value in the already constructed range
-            begin_ptr[pos + insertions_left - 1] = *(--end);
+            begin_ptr[pos + insertions_left - 1] = *(--last_value_it);
          }
          --insertions_left;
          hole_size = new_hole_size;
@@ -1517,7 +1518,58 @@ class vector : private container_detail::vector_alloc_holder
       }
    }
 
-   size_type shift_range(size_type first_pos, size_type last_pos, size_type limit_pos, size_type shift_count)
+   //Takes the range pointed by [first_pos, last_pos) and shifts it to the right
+   //by 'shift_count'. 'limit_pos' marks the end of constructed elements.
+   //
+   //Precondition: first_pos <= last_pos <= limit_pos
+   //
+   //The shift operation might cross limit_pos so elements to moved beyond limit_pos
+   //are uninitialized_moved with an allocator. Other elements are moved.
+   //
+   //The shift operation might left uninitialized elements after limit_pos
+   //and the number of uninitialized elements is returned by the function.
+   //
+   //Old situation:
+   //       first_pos   last_pos         old_limit
+   //             |       |                  |  
+   // ____________V_______V__________________V_____________
+   //|   prefix   | range |     suffix       |raw_mem      ~
+   //|____________|_______|__________________|_____________~
+   //
+   //New situation in Case A (hole_size == 0):
+   // range is moved through move assignments
+   //
+   //       first_pos   last_pos         old_limit
+   //             |       |                  |  
+   // ____________V_______V__________________V_____________
+   //|   prefix'  |       |  | range |suffix'|raw_mem      ~
+   //|________________+______|___^___|_______|_____________~
+   //                 |          |
+   //                 |_>_>_>_>_>^                     
+   //
+   //
+   //New situation in Case B (hole_size >= 0):
+   // range is moved through uninitialized moves
+   //
+   //       first_pos   last_pos         old_limit
+   //             |       |                  |  
+   // ____________V_______V__________________V________________ 
+   //|    prefix' |       |                  | [hole] | range |
+   //|_______________________________________|________|___^___|
+   //                 |                                   |
+   //                 |_>_>_>_>_>_>_>_>_>_>_>_>_>_>_>_>_>_^
+   //
+   //New situation in Case C (hole_size == 0):
+   // range is moved through move assignments and uninitialized moves
+   //
+   //       first_pos   last_pos         old_limit
+   //             |       |                  |  
+   // ____________V_______V__________________V___ 
+   //|   prefix'  |       |              | range |
+   //|___________________________________|___^___|
+   //                 |                      |
+   //                 |_>_>_>_>_>_>_>_>_>_>_>^
+   size_type insert_ordered_at_shift_range(size_type first_pos, size_type last_pos, size_type limit_pos, size_type shift_count)
    {
       BOOST_ASSERT(first_pos <= last_pos);
       BOOST_ASSERT(last_pos <= limit_pos);
@@ -1525,20 +1577,27 @@ class vector : private container_detail::vector_alloc_holder
       T* const begin_ptr = container_detail::to_raw_pointer(this->members_.m_start);
 
       size_type hole_size = 0;
-      if((last_pos + shift_count) < limit_pos){
-         //All inside
+      //Case A:
+      if((last_pos + shift_count) <= limit_pos){
+         //All move assigned
          boost::move_backward(begin_ptr + first_pos, begin_ptr + last_pos, begin_ptr + last_pos + shift_count);
       }
+      //Case B:
       else if((first_pos + shift_count) >= limit_pos){
-         //All outside
+         //All uninitialized_moved
          ::boost::container::uninitialized_move_alloc
             (this->alloc(), begin_ptr + first_pos, begin_ptr + last_pos, begin_ptr + first_pos + shift_count);
          hole_size = last_pos + shift_count - limit_pos;
       }
+      //Case C:
       else{
+         //Some uninitialized_moved
+         T* const limit_ptr    = begin_ptr + limit_pos;
+         T* const boundary_ptr = limit_ptr - shift_count;
          ::boost::container::uninitialized_move_alloc
-            (this->alloc(), begin_ptr + limit_pos - shift_count, begin_ptr + last_pos, begin_ptr + limit_pos);
-         boost::move_backward(begin_ptr + first_pos, begin_ptr + limit_pos - shift_count, begin_ptr + limit_pos + shift_count);
+            (this->alloc(), boundary_ptr, begin_ptr + last_pos, limit_ptr);
+         //The rest is move assigned
+         boost::move_backward(begin_ptr + first_pos, boundary_ptr, limit_ptr + shift_count);
       }
       return hole_size;
    }

From 75a29768b0bfbf0c5ecea04a910261c767f2acba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Wed, 11 Apr 2012 16:01:46 +0000
Subject: [PATCH 23/93] Fully qualifified boost move calls

[SVN r77914]
---
 include/boost/container/detail/advanced_insert_int.hpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/boost/container/detail/advanced_insert_int.hpp b/include/boost/container/detail/advanced_insert_int.hpp
index 978a819..0d198b0 100644
--- a/include/boost/container/detail/advanced_insert_int.hpp
+++ b/include/boost/container/detail/advanced_insert_int.hpp
@@ -267,7 +267,7 @@ struct advanced_insert_aux_emplace
    typedef typename base_t::index_tuple_t    index_tuple_t;
 
    explicit advanced_insert_aux_emplace(A &a, Args&&... args)
-      : base_t(a, boost::forward(args)...)
+      : base_t(a, ::boost::forward(args)...)
    {}
 
    ~advanced_insert_aux_emplace()
@@ -290,7 +290,7 @@ struct advanced_insert_aux_emplace
          alloc_traits::construct(this->a_, vp,
             ::boost::container::container_detail::stored_ref::forward(get(this->args_))...);
          scoped_destructor d(this->a_, vp);
-         *p = boost::move(*vp);
+         *p = ::boost::move(*vp);
          d.release();
          this->used_ = true;
       }
@@ -307,7 +307,7 @@ struct advanced_insert_aux_emplace
             alloc_traits::construct(this->a_, vp,
                ::boost::container::container_detail::stored_ref::forward(get(this->args_))...);
             try {
-               *p = boost::move(*vp);
+               *p = ::boost::move(*vp);
             } catch (...) {
                alloc_traits::destroy(this->a_, vp);
                throw;
@@ -413,7 +413,7 @@ struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)
          alloc_traits::construct(this->a_, vp                                       \
             BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _));       \
          scoped_destructor d(this->a_, vp);                                      \
-         *p = boost::move(*vp);                                                     \
+         *p = ::boost::move(*vp);                                                     \
          d.release();                                                               \
          this->used_ = true;                                                        \
       }                                                                             \
@@ -430,7 +430,7 @@ struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)
             alloc_traits::construct(this->a_, vp                                    \
                BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _));    \
             scoped_destructor d(this->a_, vp);                                   \
-            *p = boost::move(*vp);                                                  \
+            *p = ::boost::move(*vp);                                                  \
             d.release();                                                            \
             this->used_ = true;                                                     \
          }                                                                          \

From b31cf6c8f4af0a19b7346290c934552c21587bb0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Wed, 11 Apr 2012 16:02:19 +0000
Subject: [PATCH 24/93] Added test for containers using scoped allocator

[SVN r77915]
---
 proj/vc7ide/container.sln                     |   8 +
 .../vc7ide/scoped_allocator_usage_test.vcproj | 139 ++++++++++++++++++
 test/scoped_allocator_usage_test.cpp          |  95 ++++++++++++
 3 files changed, 242 insertions(+)
 create mode 100644 proj/vc7ide/scoped_allocator_usage_test.vcproj
 create mode 100644 test/scoped_allocator_usage_test.cpp

diff --git a/proj/vc7ide/container.sln b/proj/vc7ide/container.sln
index 7bc2ee8..591f0fc 100644
--- a/proj/vc7ide/container.sln
+++ b/proj/vc7ide/container.sln
@@ -47,6 +47,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scoped_allocator_adaptor_te
 	ProjectSection(ProjectDependencies) = postProject
 	EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scoped_allocator_usage_test", "scoped_allocator_usage_test.vcproj", "{B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}"
+	ProjectSection(ProjectDependencies) = postProject
+	EndProjectSection
+EndProject
 Global
 	GlobalSection(SolutionConfiguration) = preSolution
 		Debug = Debug
@@ -103,6 +107,10 @@ Global
 		{B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Debug.Build.0 = Debug|Win32
 		{B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Release.ActiveCfg = Release|Win32
 		{B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Release.Build.0 = Release|Win32
+		{B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Debug.ActiveCfg = Debug|Win32
+		{B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Debug.Build.0 = Debug|Win32
+		{B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Release.ActiveCfg = Release|Win32
+		{B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Release.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 	EndGlobalSection
diff --git a/proj/vc7ide/scoped_allocator_usage_test.vcproj b/proj/vc7ide/scoped_allocator_usage_test.vcproj
new file mode 100644
index 0000000..a19b214
--- /dev/null
+++ b/proj/vc7ide/scoped_allocator_usage_test.vcproj
@@ -0,0 +1,139 @@
+
+
+	
+		
+	
+	
+		
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+		
+		
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+		
+	
+	
+	
+	
+		
+			
+			
+		
+		
+		
+	
+	
+	
+
diff --git a/test/scoped_allocator_usage_test.cpp b/test/scoped_allocator_usage_test.cpp
new file mode 100644
index 0000000..e7af116
--- /dev/null
+++ b/test/scoped_allocator_usage_test.cpp
@@ -0,0 +1,95 @@
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+template 
+class SimpleAllocator
+{
+public:
+	typedef Ty value_type;
+	typedef typename std::allocator::pointer pointer;
+	typedef typename std::allocator::size_type size_type;
+
+	SimpleAllocator(int value)
+		: _value(value)
+	{}
+
+	template 
+	SimpleAllocator(const SimpleAllocator &other)
+		: _value(other._value)
+	{}
+
+	pointer allocate(size_type n)
+	{
+		return _allocator.allocate(n);
+	}
+	void deallocate(pointer p, size_type n)
+	{
+		_allocator.deallocate(p, n);
+	}
+private:
+	int _value;
+	std::allocator _allocator;
+
+	template  friend class SimpleAllocator;
+};
+
+template 
+class ScopedAllocator : public boost::container::scoped_allocator_adaptor >
+{
+private:
+	typedef boost::container::scoped_allocator_adaptor > Base;
+
+public:
+	ScopedAllocator(int value)
+		: Base(SimpleAllocator(value))
+	{}
+};
+
+class Resource
+{
+private: // Not copyable
+	Resource(const Resource &);
+	Resource &operator=(const Resource &);
+public:
+	typedef SimpleAllocator allocator_type;
+
+	Resource(BOOST_RV_REF(Resource)other)
+		: _value(other._value), _allocator(boost::move(other._allocator))
+	{
+		other._value = -1;
+	}
+
+	Resource(BOOST_RV_REF(Resource)other, const allocator_type &allocator)
+		: _value(other._value), _allocator(allocator)
+	{
+		other._value = -1;
+	}
+
+	Resource(int value, const allocator_type &allocator)
+		: _value(value), _allocator(allocator)
+	{}
+private:
+	int _value;
+	allocator_type _allocator;
+};
+
+typedef std::pair MapNode;
+
+typedef boost::container::scoped_allocator_adaptor > MapAllocator;
+
+typedef boost::container::map, MapAllocator> Map;
+
+int main()
+{
+	Map map1(std::less(), SimpleAllocator(5));
+
+	map1.emplace("foo", 42);
+	map1.emplace("bar", 11);
+
+	//Map map2 = map1;
+	return 0;
+}

From 1c7b25854146fb0e4b3124d8d54892827f775300 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Sun, 22 Apr 2012 21:21:45 +0000
Subject: [PATCH 25/93] Corrections for scoped_allocator

[SVN r78147]
---
 include/boost/container/detail/flat_tree.hpp |  85 ++--
 include/boost/container/flat_map.hpp         |  84 ++--
 include/boost/container/list.hpp             |   4 +
 include/boost/container/map.hpp              |  68 ++++
 include/boost/container/scoped_allocator.hpp |  71 +++-
 include/boost/container/slist.hpp            |   4 +
 include/boost/container/stable_vector.hpp    |   4 +
 test/scoped_allocator_usage_test.cpp         | 386 ++++++++++++++++---
 8 files changed, 602 insertions(+), 104 deletions(-)

diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp
index 960a491..81c1802 100644
--- a/include/boost/container/detail/flat_tree.hpp
+++ b/include/boost/container/detail/flat_tree.hpp
@@ -32,6 +32,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 namespace boost {
 
@@ -173,6 +175,10 @@ class flat_tree
    //!Standard extension
    typedef allocator_type                             stored_allocator_type;
 
+   private:
+   typedef allocator_traits stored_allocator_traits;
+
+   public:
    flat_tree()
       : m_data()
    { }
@@ -377,44 +383,65 @@ class flat_tree
    template 
    std::pair emplace_unique(Args&&... args)
    {
-      value_type && val = value_type(boost::forward(args)...);
+      aligned_storage::value> v;
+      value_type &val = *static_cast(static_cast(&v));
+      stored_allocator_type &a = this->get_stored_allocator();
+      stored_allocator_traits::construct(a, &val, ::boost::forward(args)... );
+      scoped_destructor d(a, &val);
       insert_commit_data data;
       std::pair ret =
          priv_insert_unique_prepare(val, data);
       if(ret.second){
          ret.first = priv_insert_commit(data, boost::move(val));
       }
+      d.release();
       return ret;
    }
 
    template 
    iterator emplace_hint_unique(const_iterator hint, Args&&... args)
    {
-      value_type && val = value_type(boost::forward(args)...);
+      aligned_storage::value> v;
+      value_type &val = *static_cast(static_cast(&v));
+      stored_allocator_type &a = this->get_stored_allocator();
+      stored_allocator_traits::construct(a, &val, ::boost::forward(args)... );
+      scoped_destructor d(a, &val);
       insert_commit_data data;
       std::pair ret = priv_insert_unique_prepare(hint, val, data);
       if(ret.second){
          ret.first = priv_insert_commit(data, boost::move(val));
       }
+      d.release();
       return ret.first;
    }
 
    template 
    iterator emplace_equal(Args&&... args)
    {
-      value_type &&val = value_type(boost::forward(args)...);
+      aligned_storage::value> v;
+      value_type &val = *static_cast(static_cast(&v));
+      stored_allocator_type &a = this->get_stored_allocator();
+      stored_allocator_traits::construct(a, &val, ::boost::forward(args)... );
+      scoped_destructor d(a, &val);
       iterator i = this->upper_bound(KeyOfValue()(val));
       i = this->m_data.m_vect.insert(i, boost::move(val));
+      d.release();
       return i;
    }
 
    template 
    iterator emplace_hint_equal(const_iterator hint, Args&&... args)
    {
-      value_type &&val = value_type(boost::forward(args)...);
+      aligned_storage::value> v;
+      value_type &val = *static_cast(static_cast(&v));
+      stored_allocator_type &a = this->get_stored_allocator();
+      stored_allocator_traits::construct(a, &val, ::boost::forward(args)... );
+      scoped_destructor d(a, &val);
       insert_commit_data data;
       this->priv_insert_equal_prepare(hint, val, data);
-      return priv_insert_commit(data, boost::move(val));
+      iterator i = priv_insert_commit(data, boost::move(val));
+      d.release();
+      return i;
    }
 
    #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
@@ -424,15 +451,18 @@ class flat_tree
    std::pair                                                              \
       emplace_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                  \
    {                                                                                      \
-      BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), container_detail::value_init<) value_type         \
-         BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), >) vval BOOST_PP_LPAREN_IF(n)                  \
-            BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) BOOST_PP_RPAREN_IF(n);  \
-      value_type &val = vval;                                                             \
+      aligned_storage::value> v;             \
+      value_type &val = *static_cast(static_cast(&v));              \
+      stored_allocator_type &a = this->get_stored_allocator();                            \
+      stored_allocator_traits::construct(a, &val                                          \
+         BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) );                \
+      scoped_destructor d(a, &val);                                \
       insert_commit_data data;                                                            \
       std::pair ret = priv_insert_unique_prepare(val, data);               \
       if(ret.second){                                                                     \
          ret.first = priv_insert_commit(data, boost::move(val));                          \
       }                                                                                   \
+      d.release();                                                                        \
       return ret;                                                                         \
    }                                                                                      \
                                                                                           \
@@ -440,27 +470,33 @@ class flat_tree
    iterator emplace_hint_unique(const_iterator hint                                       \
                         BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _))      \
    {                                                                                      \
-      BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), container_detail::value_init<) value_type         \
-         BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), >) vval BOOST_PP_LPAREN_IF(n)                  \
-            BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) BOOST_PP_RPAREN_IF(n);  \
-      value_type &val = vval;                                                             \
+      aligned_storage::value> v;             \
+      value_type &val = *static_cast(static_cast(&v));              \
+      stored_allocator_type &a = this->get_stored_allocator();                            \
+      stored_allocator_traits::construct(a, &val                                          \
+         BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) );                \
+      scoped_destructor d(a, &val);                                \
       insert_commit_data data;                                                            \
       std::pair ret = priv_insert_unique_prepare(hint, val, data);         \
       if(ret.second){                                                                     \
          ret.first = priv_insert_commit(data, boost::move(val));                          \
       }                                                                                   \
+      d.release();                                                                        \
       return ret.first;                                                                   \
    }                                                                                      \
                                                                                           \
    BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
    iterator emplace_equal(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))             \
    {                                                                                      \
-      BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), container_detail::value_init<) value_type         \
-         BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), >) vval BOOST_PP_LPAREN_IF(n)                  \
-            BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) BOOST_PP_RPAREN_IF(n);  \
-      value_type &val = vval;                                                             \
+      aligned_storage::value> v;             \
+      value_type &val = *static_cast(static_cast(&v));              \
+      stored_allocator_type &a = this->get_stored_allocator();                            \
+      stored_allocator_traits::construct(a, &val                                          \
+         BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) );                \
+      scoped_destructor d(a, &val);                                \
       iterator i = this->upper_bound(KeyOfValue()(val));                                  \
       i = this->m_data.m_vect.insert(i, boost::move(val));                                \
+      d.release();                                                                        \
       return i;                                                                           \
    }                                                                                      \
                                                                                           \
@@ -468,14 +504,19 @@ class flat_tree
    iterator emplace_hint_equal(const_iterator hint                                        \
                       BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _))        \
    {                                                                                      \
-      BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), container_detail::value_init<) value_type         \
-         BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), >) vval BOOST_PP_LPAREN_IF(n)                  \
-            BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) BOOST_PP_RPAREN_IF(n);  \
-      value_type &val = vval;                                                             \
+      aligned_storage::value> v;             \
+      value_type &val = *static_cast(static_cast(&v));              \
+      stored_allocator_type &a = this->get_stored_allocator();                            \
+      stored_allocator_traits::construct(a, &val                                          \
+         BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) );                \
+      scoped_destructor d(a, &val);                                \
       insert_commit_data data;                                                            \
       this->priv_insert_equal_prepare(hint, val, data);                                   \
-      return priv_insert_commit(data, boost::move(val));                                  \
+      iterator i = priv_insert_commit(data, boost::move(val));                            \
+      d.release();                                                                        \
+      return i;                                                                           \
    }                                                                                      \
+
    //!
    #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
    #include BOOST_PP_LOCAL_ITERATE()
diff --git a/include/boost/container/flat_map.hpp b/include/boost/container/flat_map.hpp
index f2b8e34..28ef1d6 100644
--- a/include/boost/container/flat_map.hpp
+++ b/include/boost/container/flat_map.hpp
@@ -300,14 +300,6 @@ class flat_map
    const_iterator begin() const 
       { return container_detail::force(m_flat_tree.begin()); }
 
-   //! Effects: Returns a const_iterator to the first element contained in the container.
-   //! 
-   //! Throws: Nothing.
-   //! 
-   //! Complexity: Constant.
-   const_iterator cbegin() const 
-      { return container_detail::force(m_flat_tree.cbegin()); }
-
    //! Effects: Returns an iterator to the end of the container.
    //! 
    //! Throws: Nothing.
@@ -324,14 +316,6 @@ class flat_map
    const_iterator end() const 
       { return container_detail::force(m_flat_tree.end()); }
 
-   //! Effects: Returns a const_iterator to the end of the container.
-   //! 
-   //! Throws: Nothing.
-   //! 
-   //! Complexity: Constant.
-   const_iterator cend() const 
-      { return container_detail::force(m_flat_tree.cend()); }
-
    //! Effects: Returns a reverse_iterator pointing to the beginning 
    //! of the reversed container. 
    //! 
@@ -350,15 +334,6 @@ class flat_map
    const_reverse_iterator rbegin() const 
       { return container_detail::force(m_flat_tree.rbegin()); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
-   //! Throws: Nothing.
-   //! 
-   //! Complexity: Constant.
-   const_reverse_iterator crbegin() const 
-      { return container_detail::force(m_flat_tree.crbegin()); }
-
    //! Effects: Returns a reverse_iterator pointing to the end
    //! of the reversed container. 
    //! 
@@ -377,6 +352,31 @@ class flat_map
    const_reverse_iterator rend() const 
       { return container_detail::force(m_flat_tree.rend()); }
 
+   //! Effects: Returns a const_iterator to the first element contained in the container.
+   //! 
+   //! Throws: Nothing.
+   //! 
+   //! Complexity: Constant.
+   const_iterator cbegin() const 
+      { return container_detail::force(m_flat_tree.cbegin()); }
+
+   //! Effects: Returns a const_iterator to the end of the container.
+   //! 
+   //! Throws: Nothing.
+   //! 
+   //! Complexity: Constant.
+   const_iterator cend() const 
+      { return container_detail::force(m_flat_tree.cend()); }
+
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
+   //! of the reversed container. 
+   //! 
+   //! Throws: Nothing.
+   //! 
+   //! Complexity: Constant.
+   const_reverse_iterator crbegin() const 
+      { return container_detail::force(m_flat_tree.crbegin()); }
+
    //! Effects: Returns a const_reverse_iterator pointing to the end
    //! of the reversed container. 
    //! 
@@ -1119,6 +1119,40 @@ class flat_multimap
    const_reverse_iterator rend() const 
       { return container_detail::force(m_flat_tree.rend()); }
 
+   //! Effects: Returns a const_iterator to the first element contained in the container.
+   //! 
+   //! Throws: Nothing.
+   //! 
+   //! Complexity: Constant.
+   const_iterator cbegin() const 
+      { return container_detail::force(m_flat_tree.cbegin()); }
+
+   //! Effects: Returns a const_iterator to the end of the container.
+   //! 
+   //! Throws: Nothing.
+   //! 
+   //! Complexity: Constant.
+   const_iterator cend() const 
+      { return container_detail::force(m_flat_tree.cend()); }
+
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
+   //! of the reversed container. 
+   //! 
+   //! Throws: Nothing.
+   //! 
+   //! Complexity: Constant.
+   const_reverse_iterator crbegin() const 
+      { return container_detail::force(m_flat_tree.crbegin()); }
+
+   //! Effects: Returns a const_reverse_iterator pointing to the end
+   //! of the reversed container. 
+   //! 
+   //! Throws: Nothing.
+   //! 
+   //! Complexity: Constant.
+   const_reverse_iterator crend() const 
+      { return container_detail::force(m_flat_tree.crend()); }
+
    //! Effects: Returns true if the container contains no elements.
    //! 
    //! Throws: Nothing.
diff --git a/include/boost/container/list.hpp b/include/boost/container/list.hpp
index 744ddff..e6682d8 100644
--- a/include/boost/container/list.hpp
+++ b/include/boost/container/list.hpp
@@ -65,6 +65,10 @@ template 
 struct list_node
    :  public list_hook::type
 {
+   private:
+   list_node();
+
+   public:
    typedef typename list_hook::type hook_type;
    T m_data;
 };
diff --git a/include/boost/container/map.hpp b/include/boost/container/map.hpp
index 25403e0..b22e794 100644
--- a/include/boost/container/map.hpp
+++ b/include/boost/container/map.hpp
@@ -276,6 +276,14 @@ class map
    //! 
    //! Complexity: Constant.
    const_iterator begin() const 
+   { return this->cbegin(); }
+
+   //! Effects: Returns a const_iterator to the first element contained in the container.
+   //! 
+   //! Throws: Nothing.
+   //! 
+   //! Complexity: Constant.
+   const_iterator cbegin() const 
    { return m_tree.begin(); }
 
    //! Effects: Returns an iterator to the end of the container.
@@ -292,6 +300,14 @@ class map
    //! 
    //! Complexity: Constant.
    const_iterator end() const 
+   { return this->cend(); }
+
+   //! Effects: Returns a const_iterator to the end of the container.
+   //! 
+   //! Throws: Nothing.
+   //! 
+   //! Complexity: Constant.
+   const_iterator cend() const 
    { return m_tree.end(); }
 
    //! Effects: Returns a reverse_iterator pointing to the beginning 
@@ -310,6 +326,15 @@ class map
    //! 
    //! Complexity: Constant.
    const_reverse_iterator rbegin() const 
+   { return this->crbegin(); }
+
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
+   //! of the reversed container. 
+   //! 
+   //! Throws: Nothing.
+   //! 
+   //! Complexity: Constant.
+   const_reverse_iterator crbegin() const 
    { return m_tree.rbegin(); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
@@ -328,6 +353,15 @@ class map
    //! 
    //! Complexity: Constant.
    const_reverse_iterator rend() const 
+   { return this->crend(); }
+
+   //! Effects: Returns a const_reverse_iterator pointing to the end
+   //! of the reversed container. 
+   //! 
+   //! Throws: Nothing.
+   //! 
+   //! Complexity: Constant.
+   const_reverse_iterator crend() const 
    { return m_tree.rend(); }
 
    //! Effects: Returns true if the container contains no elements.
@@ -984,6 +1018,14 @@ class multimap
    //! 
    //! Complexity: Constant.
    const_iterator begin() const 
+   { return this->cbegin(); }
+
+   //! Effects: Returns a const_iterator to the first element contained in the container.
+   //! 
+   //! Throws: Nothing.
+   //! 
+   //! Complexity: Constant.
+   const_iterator cbegin() const 
    { return m_tree.begin(); }
 
    //! Effects: Returns an iterator to the end of the container.
@@ -1000,6 +1042,14 @@ class multimap
    //! 
    //! Complexity: Constant.
    const_iterator end() const 
+   { return this->cend(); }
+
+   //! Effects: Returns a const_iterator to the end of the container.
+   //! 
+   //! Throws: Nothing.
+   //! 
+   //! Complexity: Constant.
+   const_iterator cend() const 
    { return m_tree.end(); }
 
    //! Effects: Returns a reverse_iterator pointing to the beginning 
@@ -1018,6 +1068,15 @@ class multimap
    //! 
    //! Complexity: Constant.
    const_reverse_iterator rbegin() const 
+   { return this->crbegin(); }
+
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
+   //! of the reversed container. 
+   //! 
+   //! Throws: Nothing.
+   //! 
+   //! Complexity: Constant.
+   const_reverse_iterator crbegin() const 
    { return m_tree.rbegin(); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
@@ -1036,6 +1095,15 @@ class multimap
    //! 
    //! Complexity: Constant.
    const_reverse_iterator rend() const 
+   { return this->crend(); }
+
+   //! Effects: Returns a const_reverse_iterator pointing to the end
+   //! of the reversed container. 
+   //! 
+   //! Throws: Nothing.
+   //! 
+   //! Complexity: Constant.
+   const_reverse_iterator crend() const 
    { return m_tree.rend(); }
 
    //! Effects: Returns true if the container contains no elements.
diff --git a/include/boost/container/scoped_allocator.hpp b/include/boost/container/scoped_allocator.hpp
index d9023f8..770158a 100644
--- a/include/boost/container/scoped_allocator.hpp
+++ b/include/boost/container/scoped_allocator.hpp
@@ -674,6 +674,20 @@ class scoped_allocator_adaptor_base
       , inner(other.inner_allocator())
       {}
 
+   protected:
+   struct internal_type_t{};
+
+   template 
+   scoped_allocator_adaptor_base
+      ( internal_type_t
+      , BOOST_FWD_REF(OuterA2) outerAlloc
+      , const inner_allocator_type &inner)
+      : outer_allocator_type(::boost::forward(outerAlloc))
+      , m_inner(inner)
+   {}
+
+   public:
+
    scoped_allocator_adaptor_base &operator=
       (BOOST_COPY_ASSIGN_REF(scoped_allocator_adaptor_base) other)
    {
@@ -772,17 +786,17 @@ class scoped_allocator_adaptor_base(outerAlloc))                             \
-      , inner(BOOST_PP_ENUM_PARAMS(n, q))                                                       \
+      , m_inner(BOOST_PP_ENUM_PARAMS(n, q))                                                     \
       {}                                                                                        \
                                                                                                 \
    scoped_allocator_adaptor_base(const scoped_allocator_adaptor_base& other)                    \
       : outer_allocator_type(other.outer_allocator())                                           \
-      , inner(other.inner_allocator())                                                          \
+      , m_inner(other.inner_allocator())                                                        \
       {}                                                                                        \
                                                                                                 \
    scoped_allocator_adaptor_base(BOOST_RV_REF(scoped_allocator_adaptor_base) other)             \
       : outer_allocator_type(::boost::move(other.outer_allocator()))                            \
-      , inner(::boost::move(other.inner_allocator()))                                           \
+      , m_inner(::boost::move(other.inner_allocator()))                                         \
       {}                                                                                        \
                                                                                                 \
    template                                                                      \
@@ -793,7 +807,7 @@ class scoped_allocator_adaptor_base& other)                                                                              \
       : outer_allocator_type(other.outer_allocator())                                           \
-      , inner(other.inner_allocator())                                                          \
+      , m_inner(other.inner_allocator())                                                        \
       {}                                                                                        \
                                                                                                 \
    template                                                                      \
@@ -805,29 +819,42 @@ class scoped_allocator_adaptor_base BOOST_RV_REF_END other)                                                              \
       : outer_allocator_type(other.outer_allocator())                                           \
-      , inner(other.inner_allocator())                                                          \
+      , m_inner(other.inner_allocator())                                                        \
       {}                                                                                        \
                                                                                                 \
+   protected:                                                                                   \
+   struct internal_type_t{};                                                                    \
+                                                                                                \
+   template                                                                      \
+   scoped_allocator_adaptor_base                                                                \
+      ( internal_type_t                                                                         \
+      , BOOST_FWD_REF(OuterA2) outerAlloc                                                       \
+      , const inner_allocator_type &inner)                                                      \
+      : outer_allocator_type(::boost::forward(outerAlloc))                             \
+      , m_inner(inner)                                                                          \
+   {}                                                                                           \
+                                                                                                \
+   public:                                                                                      \
    scoped_allocator_adaptor_base &operator=                                                     \
       (BOOST_COPY_ASSIGN_REF(scoped_allocator_adaptor_base) other)                              \
    {                                                                                            \
       outer_allocator_type::operator=(other.outer_allocator());                                 \
-      inner = other.inner_allocator();                                                          \
+      m_inner = other.inner_allocator();                                                        \
       return *this;                                                                             \
    }                                                                                            \
                                                                                                 \
    scoped_allocator_adaptor_base &operator=(BOOST_RV_REF(scoped_allocator_adaptor_base) other)  \
    {                                                                                            \
       outer_allocator_type::operator=(boost::move(other.outer_allocator()));                    \
-      inner = ::boost::move(other.inner_allocator());                                           \
+      m_inner = ::boost::move(other.inner_allocator());                                         \
       return *this;                                                                             \
    }                                                                                            \
                                                                                                 \
    inner_allocator_type&       inner_allocator()                                                \
-      { return inner; }                                                                         \
+      { return m_inner; }                                                                       \
                                                                                                 \
    inner_allocator_type const& inner_allocator() const                                          \
-      { return inner; }                                                                         \
+      { return m_inner; }                                                                       \
                                                                                                 \
    outer_allocator_type      & outer_allocator()                                                \
       { return static_cast(*this); }                                     \
@@ -836,7 +863,7 @@ class scoped_allocator_adaptor_base(*this); }                               \
                                                                                                 \
    private:                                                                                     \
-   inner_allocator_type inner;                                                                  \
+   inner_allocator_type m_inner;                                                                \
 };                                                                                              \
 //!
 #define BOOST_PP_LOCAL_LIMITS (1, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
@@ -920,6 +947,15 @@ class scoped_allocator_adaptor_base
       : outer_allocator_type(other.outer_allocator())
       {}
 
+   protected:
+   struct internal_type_t{};
+
+   template 
+   scoped_allocator_adaptor_base(internal_type_t, BOOST_FWD_REF(OuterA2) outerAlloc, const inner_allocator_type &)
+      : outer_allocator_type(::boost::forward(outerAlloc))
+      {}
+  
+   public:
    scoped_allocator_adaptor_base &operator=(BOOST_COPY_ASSIGN_REF(scoped_allocator_adaptor_base) other)
    {
       outer_allocator_type::operator=(other.outer_allocator());
@@ -1221,8 +1257,9 @@ class scoped_allocator_adaptor
    scoped_allocator_adaptor select_on_container_copy_construction() const
    {
       return scoped_allocator_adaptor
-         (outer_traits_type::select_on_container_copy_construction(this->outer_allocator()),
-          outer_traits_type::select_on_container_copy_construction(this->inner_allocator())
+         (internal_type_t()
+         ,outer_traits_type::select_on_container_copy_construction(this->outer_allocator())
+         ,outer_traits_type::select_on_container_copy_construction(this->inner_allocator())
          );
    }
    /// @cond
@@ -1309,11 +1346,11 @@ class scoped_allocator_adaptor
 
    template 
    void construct(std::pair* p, BOOST_FWD_REF(U) x, BOOST_FWD_REF(V) y)
-   {  this->construct_pair(p, ::boost::forward(x), ::boost::forward(y));   }
+   {  this->construct_pair(p, ::boost::forward(x), ::boost::forward(y));   }
 
    template 
    void construct(container_detail::pair* p, BOOST_FWD_REF(U) x, BOOST_FWD_REF(V) y)
-   {  this->construct_pair(p, ::boost::forward(x), ::boost::forward(y));   }
+   {  this->construct_pair(p, ::boost::forward(x), ::boost::forward(y));   }
    
    template 
    void construct(std::pair* p, const std::pair& x)
@@ -1391,6 +1428,12 @@ class scoped_allocator_adaptor
    //template 
    //void construct(pair* p, piecewise_construct_t, tuple x, tuple y);
 
+   private:
+   template 
+   scoped_allocator_adaptor(internal_type_t, BOOST_FWD_REF(OuterA2) outer, const inner_allocator_type& inner)
+      : base_type(internal_type_t(), ::boost::forward(outer), inner)
+   {}
+
    /// @endcond
 };
 
diff --git a/include/boost/container/slist.hpp b/include/boost/container/slist.hpp
index 70a2cbb..5797d6c 100644
--- a/include/boost/container/slist.hpp
+++ b/include/boost/container/slist.hpp
@@ -65,6 +65,10 @@ template 
 struct slist_node
    :  public slist_hook::type
 {
+   private:
+   slist_node();
+
+   public:
    typedef typename slist_hook::type hook_type;
    T m_data;
 };
diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp
index 3f29a86..c6ca778 100644
--- a/include/boost/container/stable_vector.hpp
+++ b/include/boost/container/stable_vector.hpp
@@ -119,6 +119,10 @@ template
 struct node_type
    : public node_type_base
 {
+   private:
+   node_type();
+
+   public:
    T value;
 };
 
diff --git a/test/scoped_allocator_usage_test.cpp b/test/scoped_allocator_usage_test.cpp
index e7af116..1fbd2ce 100644
--- a/test/scoped_allocator_usage_test.cpp
+++ b/test/scoped_allocator_usage_test.cpp
@@ -1,8 +1,18 @@
+#include 
 #include 
-#include 
 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
+#include 
+#include 
+
 #include 
 
 template 
@@ -14,82 +24,372 @@ public:
 	typedef typename std::allocator::size_type size_type;
 
 	SimpleAllocator(int value)
-		: _value(value)
+		: m_state(value)
 	{}
 
 	template 
 	SimpleAllocator(const SimpleAllocator &other)
-		: _value(other._value)
+		: m_state(other.m_state)
 	{}
 
 	pointer allocate(size_type n)
 	{
-		return _allocator.allocate(n);
+		return m_allocator.allocate(n);
 	}
+
 	void deallocate(pointer p, size_type n)
 	{
-		_allocator.deallocate(p, n);
+		m_allocator.deallocate(p, n);
 	}
-private:
-	int _value;
-	std::allocator _allocator;
+
+   int get_value() const
+   {  return m_state;   }
+
+   private:
+	int m_state;
+	std::allocator m_allocator;
 
 	template  friend class SimpleAllocator;
 };
 
-template 
-class ScopedAllocator : public boost::container::scoped_allocator_adaptor >
+class alloc_int
 {
-private:
-	typedef boost::container::scoped_allocator_adaptor > Base;
+   private: // Not copyable
 
-public:
-	ScopedAllocator(int value)
-		: Base(SimpleAllocator(value))
-	{}
-};
+   BOOST_MOVABLE_BUT_NOT_COPYABLE(alloc_int)
 
-class Resource
-{
-private: // Not copyable
-	Resource(const Resource &);
-	Resource &operator=(const Resource &);
-public:
+   public:
 	typedef SimpleAllocator allocator_type;
 
-	Resource(BOOST_RV_REF(Resource)other)
-		: _value(other._value), _allocator(boost::move(other._allocator))
+	alloc_int(BOOST_RV_REF(alloc_int)other)
+		: m_value(other.m_value), m_allocator(boost::move(other.m_allocator))
 	{
-		other._value = -1;
+		other.m_value = -1;
 	}
 
-	Resource(BOOST_RV_REF(Resource)other, const allocator_type &allocator)
-		: _value(other._value), _allocator(allocator)
+	alloc_int(BOOST_RV_REF(alloc_int)other, const allocator_type &allocator)
+		: m_value(other.m_value), m_allocator(allocator)
 	{
-		other._value = -1;
+		other.m_value = -1;
 	}
 
-	Resource(int value, const allocator_type &allocator)
-		: _value(value), _allocator(allocator)
+	alloc_int(int value, const allocator_type &allocator)
+		: m_value(value), m_allocator(allocator)
 	{}
-private:
-	int _value;
-	allocator_type _allocator;
+
+	alloc_int & operator=(BOOST_RV_REF(alloc_int)other)
+	{
+		other.m_value = other.m_value;
+      return *this;
+	}
+
+   int get_allocator_state() const
+   {  return m_allocator.get_value();  }
+
+   int get_value() const
+   {  return m_value;   }
+
+   friend bool operator < (const alloc_int &l, const alloc_int &r)
+   {  return l.m_value < r.m_value;  }
+
+   friend bool operator == (const alloc_int &l, const alloc_int &r)
+   {  return l.m_value == r.m_value;  }
+
+   private:
+	int m_value;
+	allocator_type m_allocator;
 };
 
-typedef std::pair MapNode;
+using namespace ::boost::container;
 
-typedef boost::container::scoped_allocator_adaptor > MapAllocator;
+//general allocator
+typedef scoped_allocator_adaptor > AllocIntAllocator;
 
-typedef boost::container::map, MapAllocator> Map;
+//[multi]map/set
+typedef std::pair MapNode;
+typedef scoped_allocator_adaptor > MapAllocator;
+typedef map, MapAllocator> Map;
+typedef set, AllocIntAllocator> Set;
+typedef multimap, MapAllocator> MultiMap;
+typedef multiset, AllocIntAllocator> MultiSet;
+
+//[multi]flat_map/set
+typedef std::pair FlatMapNode;
+typedef scoped_allocator_adaptor > FlatMapAllocator;
+typedef flat_map, MapAllocator> FlatMap;
+typedef flat_set, AllocIntAllocator> FlatSet;
+typedef flat_multimap, MapAllocator> FlatMultiMap;
+typedef flat_multiset, AllocIntAllocator> FlatMultiSet;
+
+//vector, deque, list, slist, stable_vector.
+typedef vector          Vector;
+typedef deque           Deque;
+typedef list            List;
+typedef slist           Slist;
+typedef stable_vector   StableVector;
+
+/////////
+//is_unique_assoc
+/////////
+
+template
+struct is_unique_assoc
+{
+   static const bool value = false;
+};
+
+template
+struct is_unique_assoc< map >
+{
+   static const bool value = true;
+};
+
+template
+struct is_unique_assoc< flat_map >
+{
+   static const bool value = true;
+};
+
+template
+struct is_unique_assoc< set >
+{
+   static const bool value = true;
+};
+
+template
+struct is_unique_assoc< flat_set >
+{
+   static const bool value = true;
+};
+
+
+/////////
+//is_map
+/////////
+
+template
+struct is_map
+{
+   static const bool value = false;
+};
+
+template
+struct is_map< map >
+{
+   static const bool value = true;
+};
+
+template
+struct is_map< flat_map >
+{
+   static const bool value = true;
+};
+
+template
+struct is_map< multimap >
+{
+   static const bool value = true;
+};
+
+template
+struct is_map< flat_multimap >
+{
+   static const bool value = true;
+};
+
+template
+struct is_set
+{
+   static const bool value = false;
+};
+
+template
+struct is_set< set >
+{
+   static const bool value = true;
+};
+
+template
+struct is_set< flat_set >
+{
+   static const bool value = true;
+};
+
+template
+struct is_set< multiset >
+{
+   static const bool value = true;
+};
+
+template
+struct is_set< flat_multiset >
+{
+   static const bool value = true;
+};
+
+/////////
+//container_wrapper
+/////////
+
+template< class Container
+        , bool Assoc = is_set::value || is_map::value
+        , bool UniqueAssoc = is_unique_assoc::value
+        , bool Map  = is_map::value
+        >
+struct container_wrapper
+   : public Container
+{
+   typedef typename Container::allocator_type   allocator_type;
+   
+   container_wrapper(const allocator_type &a)
+      : Container(a)
+   {}
+};
+
+template  //map
+struct container_wrapper
+   : public Container
+{
+   typedef typename Container::allocator_type   allocator_type;
+   typedef typename Container::key_compare      key_compare;
+   typedef typename Container::value_type       value_type;
+   typedef typename Container::const_iterator   const_iterator;
+   typedef typename Container::iterator         iterator;
+
+   container_wrapper(const allocator_type &a)
+      : Container(key_compare(), a)
+   {}
+
+   template
+   iterator emplace(const_iterator, const Arg &arg)
+   {
+      return this->Container::emplace(arg, arg).first;
+   }
+};
+
+template  //set
+struct container_wrapper
+   : public Container
+{
+   typedef typename Container::allocator_type   allocator_type;
+   typedef typename Container::key_compare      key_compare;
+   typedef typename Container::value_type       value_type;
+   typedef typename Container::const_iterator   const_iterator;
+   typedef typename Container::iterator         iterator;
+
+   container_wrapper(const allocator_type &a)
+      : Container(key_compare(), a)
+   {}
+
+   template
+   iterator emplace(const_iterator, const Arg &arg)
+   {
+      return this->Container::emplace(arg).first;
+   }
+};
+
+template  //multimap
+struct container_wrapper
+   : public Container
+{
+   typedef typename Container::value_type       value_type;
+   typedef typename Container::key_compare      key_compare;
+   typedef typename Container::allocator_type   allocator_type;
+   typedef typename Container::const_iterator   const_iterator;
+   typedef typename Container::iterator         iterator;
+
+   container_wrapper(const allocator_type &a)
+      : Container(key_compare(), a)
+   {}
+
+   template
+   iterator emplace(const_iterator, const Arg &arg)
+   {
+      return this->Container::emplace(arg, arg);
+   }
+};
+
+//multiset
+template  //multimap
+struct container_wrapper
+   : public Container
+{
+   typedef typename Container::value_type       value_type;
+   typedef typename Container::key_compare      key_compare;
+   typedef typename Container::allocator_type   allocator_type;
+   typedef typename Container::const_iterator   const_iterator;
+   typedef typename Container::iterator         iterator;
+
+   container_wrapper(const allocator_type &a)
+      : Container(key_compare(), a)
+   {}
+
+   template
+   iterator emplace(const_iterator, const Arg &arg)
+   {
+      return this->Container::emplace(arg);
+   }
+};
+
+bool test_value_and_state_equals(const alloc_int &r, int value, int state)
+{  return r.get_value() == value && r.get_allocator_state() == state;  }
+
+template
+bool test_value_and_state_equals(const container_detail::pair &p, int value, int state)
+{  return test_value_and_state_equals(p.first, value, state) && test_alloc_state_equals(p.second, value, state);  }
+
+template
+bool test_value_and_state_equals(const std::pair &p, int value, int state)
+{  return test_value_and_state_equals(p.first, value, state) && test_value_and_state_equals(p.second, value, state);  }
+
+template
+bool one_level_allocator_propagation_test()
+{
+   typedef container_wrapper ContainerWrapper;
+   typedef typename ContainerWrapper::iterator iterator;
+	ContainerWrapper c(SimpleAllocator(5));
+
+   c.clear();
+	iterator it = c.emplace(c.cbegin(), 42);
+
+   if(!test_value_and_state_equals(*it, 42, 5))
+      return false;
+
+   return true;
+}
 
 int main()
 {
-	Map map1(std::less(), SimpleAllocator(5));
-
-	map1.emplace("foo", 42);
-	map1.emplace("bar", 11);
-
-	//Map map2 = map1;
+   //unique assoc
+   if(!one_level_allocator_propagation_test())
+      return 1;
+   if(!one_level_allocator_propagation_test())
+      return 1;
+   if(!one_level_allocator_propagation_test())
+      return 1;
+   if(!one_level_allocator_propagation_test())
+      return 1;
+   //multi assoc
+   if(!one_level_allocator_propagation_test())
+      return 1;
+   if(!one_level_allocator_propagation_test())
+      return 1;
+   if(!one_level_allocator_propagation_test())
+      return 1;
+   if(!one_level_allocator_propagation_test())
+      return 1;
+   //sequence containers
+   if(!one_level_allocator_propagation_test())
+      return 1;
+   if(!one_level_allocator_propagation_test())
+      return 1;
+   if(!one_level_allocator_propagation_test())
+      return 1;
+   if(!one_level_allocator_propagation_test())
+      return 1;
+   if(!one_level_allocator_propagation_test())
+      return 1;
 	return 0;
 }
+
+#include 

From 636cc66599a9a4dc6e7dc6b1b28ffae11e605a45 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Sun, 22 Apr 2012 22:54:18 +0000
Subject: [PATCH 26/93] Fixed clang warnings and errors

[SVN r78149]
---
 include/boost/container/detail/flat_tree.hpp |  8 ++++----
 include/boost/container/scoped_allocator.hpp | 21 ++++++++++----------
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp
index 81c1802..f5710c5 100644
--- a/include/boost/container/detail/flat_tree.hpp
+++ b/include/boost/container/detail/flat_tree.hpp
@@ -386,7 +386,7 @@ class flat_tree
       aligned_storage::value> v;
       value_type &val = *static_cast(static_cast(&v));
       stored_allocator_type &a = this->get_stored_allocator();
-      stored_allocator_traits::construct(a, &val, ::boost::forward(args)... );
+      stored_allocator_traits::construct(a, &val, ::boost::forward(args)... );
       scoped_destructor d(a, &val);
       insert_commit_data data;
       std::pair ret =
@@ -404,7 +404,7 @@ class flat_tree
       aligned_storage::value> v;
       value_type &val = *static_cast(static_cast(&v));
       stored_allocator_type &a = this->get_stored_allocator();
-      stored_allocator_traits::construct(a, &val, ::boost::forward(args)... );
+      stored_allocator_traits::construct(a, &val, ::boost::forward(args)... );
       scoped_destructor d(a, &val);
       insert_commit_data data;
       std::pair ret = priv_insert_unique_prepare(hint, val, data);
@@ -421,7 +421,7 @@ class flat_tree
       aligned_storage::value> v;
       value_type &val = *static_cast(static_cast(&v));
       stored_allocator_type &a = this->get_stored_allocator();
-      stored_allocator_traits::construct(a, &val, ::boost::forward(args)... );
+      stored_allocator_traits::construct(a, &val, ::boost::forward(args)... );
       scoped_destructor d(a, &val);
       iterator i = this->upper_bound(KeyOfValue()(val));
       i = this->m_data.m_vect.insert(i, boost::move(val));
@@ -435,7 +435,7 @@ class flat_tree
       aligned_storage::value> v;
       value_type &val = *static_cast(static_cast(&v));
       stored_allocator_type &a = this->get_stored_allocator();
-      stored_allocator_traits::construct(a, &val, ::boost::forward(args)... );
+      stored_allocator_traits::construct(a, &val, ::boost::forward(args)... );
       scoped_destructor d(a, &val);
       insert_commit_data data;
       this->priv_insert_equal_prepare(hint, val, data);
diff --git a/include/boost/container/scoped_allocator.hpp b/include/boost/container/scoped_allocator.hpp
index 770158a..e2f72c6 100644
--- a/include/boost/container/scoped_allocator.hpp
+++ b/include/boost/container/scoped_allocator.hpp
@@ -646,24 +646,24 @@ class scoped_allocator_adaptor_base
    template 
    scoped_allocator_adaptor_base(BOOST_FWD_REF(OuterA2) outerAlloc, const InnerAllocs &...args)
       : outer_allocator_type(::boost::forward(outerAlloc))
-      , inner(args...)
+      , m_inner(args...)
       {}
 
    scoped_allocator_adaptor_base(const scoped_allocator_adaptor_base& other)
       : outer_allocator_type(other.outer_allocator())
-      , inner(other.inner_allocator())
+      , m_inner(other.inner_allocator())
       {}
 
    scoped_allocator_adaptor_base(BOOST_RV_REF(scoped_allocator_adaptor_base) other)
       : outer_allocator_type(::boost::move(other.outer_allocator()))
-      , inner(::boost::move(other.inner_allocator()))
+      , m_inner(::boost::move(other.inner_allocator()))
       {}
 
    template 
    scoped_allocator_adaptor_base
       (const scoped_allocator_adaptor_base& other)
       : outer_allocator_type(other.outer_allocator())
-      , inner(other.inner_allocator())
+      , m_inner(other.inner_allocator())
       {}
 
    template 
@@ -671,7 +671,7 @@ class scoped_allocator_adaptor_base
       (BOOST_RV_REF_BEG scoped_allocator_adaptor_base
           BOOST_RV_REF_END other)
       : outer_allocator_type(other.outer_allocator())
-      , inner(other.inner_allocator())
+      , m_inner(other.inner_allocator())
       {}
 
    protected:
@@ -692,22 +692,22 @@ class scoped_allocator_adaptor_base
       (BOOST_COPY_ASSIGN_REF(scoped_allocator_adaptor_base) other)
    {
       outer_allocator_type::operator=(other.outer_allocator());
-      inner = other.inner_allocator();
+      m_inner = other.inner_allocator();
       return *this;
    }
 
    scoped_allocator_adaptor_base &operator=(BOOST_RV_REF(scoped_allocator_adaptor_base) other)
    {
       outer_allocator_type::operator=(boost::move(other.outer_allocator()));
-      inner = ::boost::move(other.inner_allocator());
+      m_inner = ::boost::move(other.inner_allocator());
       return *this;
    }
 
    inner_allocator_type&       inner_allocator()
-      { return inner; }
+      { return m_inner; }
 
    inner_allocator_type const& inner_allocator() const
-      { return inner; }
+      { return m_inner; }
 
    outer_allocator_type      & outer_allocator()
       { return static_cast(*this); }
@@ -716,7 +716,7 @@ class scoped_allocator_adaptor_base
       { return static_cast(*this); }
 
    private:
-   inner_allocator_type inner;
+   inner_allocator_type m_inner;
 };
 
 #else //#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
@@ -1060,6 +1060,7 @@ class scoped_allocator_adaptor
       , true BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, Q)
       #endif
       >                       base_type;
+   typedef typename base_type::internal_type_t internal_type_t;
    /// @endcond
    typedef OuterAlloc                                       outer_allocator_type;
    //! Type: For exposition only

From 9460e0322455f37201a59145c5d7590d8845bef8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Sun, 20 May 2012 10:02:49 +0000
Subject: [PATCH 27/93] Trailing whitespaces

[SVN r78518]
---
 include/boost/container/allocator_traits.hpp  |  34 +-
 include/boost/container/container_fwd.hpp     |  12 +-
 include/boost/container/deque.hpp             | 348 +++++-----
 .../detail/adaptive_node_pool_impl.hpp        |  18 +-
 .../container/detail/advanced_insert_int.hpp  |   8 +-
 include/boost/container/detail/algorithms.hpp |   2 +-
 .../container/detail/allocation_type.hpp      |   2 +-
 include/boost/container/detail/destroyers.hpp |   8 +-
 include/boost/container/detail/flat_tree.hpp  | 214 +++---
 .../container/detail/function_detector.hpp    |   4 +-
 include/boost/container/detail/iterators.hpp  |  40 +-
 .../boost/container/detail/math_functions.hpp |   4 +-
 include/boost/container/detail/mpl.hpp        |  20 +-
 .../container/detail/node_alloc_holder.hpp    |   8 +-
 .../boost/container/detail/node_pool_impl.hpp |  20 +-
 include/boost/container/detail/pair.hpp       |   6 +-
 .../boost/container/detail/preprocessor.hpp   |   2 +-
 .../container/detail/transform_iterator.hpp   |   6 +-
 include/boost/container/detail/tree.hpp       | 132 ++--
 .../boost/container/detail/type_traits.hpp    |   4 +-
 include/boost/container/detail/utilities.hpp  |   4 +-
 include/boost/container/detail/value_init.hpp |   6 +-
 .../detail/variadic_templates_tools.hpp       |   4 +-
 .../boost/container/detail/version_type.hpp   |   2 +-
 include/boost/container/flat_map.hpp          | 633 +++++++++---------
 include/boost/container/flat_set.hpp          | 575 ++++++++--------
 include/boost/container/list.hpp              | 346 +++++-----
 include/boost/container/map.hpp               | 566 ++++++++--------
 include/boost/container/scoped_allocator.hpp  | 210 +++---
 include/boost/container/set.hpp               | 536 +++++++--------
 include/boost/container/slist.hpp             | 480 ++++++-------
 include/boost/container/stable_vector.hpp     | 194 +++---
 include/boost/container/string.hpp            | 580 ++++++++--------
 include/boost/container/vector.hpp            | 347 +++++-----
 34 files changed, 2766 insertions(+), 2609 deletions(-)

diff --git a/include/boost/container/allocator_traits.hpp b/include/boost/container/allocator_traits.hpp
index b253cde..f1ce2fc 100644
--- a/include/boost/container/allocator_traits.hpp
+++ b/include/boost/container/allocator_traits.hpp
@@ -66,10 +66,10 @@ struct allocator_traits
 
    #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
       //! Alloc::pointer if such a type exists; otherwise, value_type*
-      //! 
+      //!
       typedef unspecified pointer;
       //! Alloc::const_pointer if such a type exists ; otherwise, pointer_traits::rebind::rebind.
-      //! 
+      //!
       typedef unspecified void_pointer;
       //! Alloc::const_void_pointer if such a type exists ; otherwis e, pointer_traits::rebind::difference_type.
-      //! 
+      //!
       typedef unspecified difference_type;
       //! Alloc::size_type if such a type exists ; otherwise, make_unsigned::type
-      //! 
+      //!
       typedef unspecified size_type;
       //! Alloc::propagate_on_container_copy_assignment if such a type exists, otherwise an integral_constant
       //! type with internal constant static member `value` == false.
@@ -99,9 +99,9 @@ struct allocator_traits
       //! type with internal constant static member `value` == false.
       typedef unspecified propagate_on_container_swap;
       //! Defines an allocator: Alloc::rebind::other if such a type exists; otherwise, Alloc
-      //! if Alloc is a class template instantiation of the form Alloc, where Args is zero or 
+      //! if Alloc is a class template instantiation of the form Alloc, where Args is zero or
       //! more type arguments ; otherwise, the instantiation of rebind_alloc is ill-formed.
-      //! 
+      //!
       //! In C++03 compilers `rebind_alloc` is a struct derived from an allocator
       //! deduced by previously detailed rules.
       template  using rebind_alloc = unspecified;
@@ -122,7 +122,7 @@ struct allocator_traits
          pointer, value_type*)
             pointer;
       //const_pointer
-      typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc, 
+      typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc,
          const_pointer, typename boost::intrusive::pointer_traits::template
             rebind_pointer)
                const_pointer;
@@ -131,11 +131,11 @@ struct allocator_traits
          reference, typename container_detail::unvoid::type&)
             reference;
       //const_reference
-      typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, 
+      typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc,
          const_reference, const typename container_detail::unvoid::type&)
                const_reference;
       //void_pointer
-      typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc, 
+      typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc,
          void_pointer, typename boost::intrusive::pointer_traits::template
             rebind_pointer)
                void_pointer;
@@ -203,12 +203,12 @@ struct allocator_traits
    #endif   //BOOST_CONTAINER_DOXYGEN_INVOKED
 
    //! Returns: `a.allocate(n)`
-   //! 
+   //!
    static pointer allocate(Alloc &a, size_type n)
    {  return a.allocate(n);  }
 
    //! Returns: `a.deallocate(p, n)`
-   //! 
+   //!
    //! Throws: Nothing
    static void deallocate(Alloc &a, pointer p, size_type n)
    {  return a.deallocate(p, n);  }
@@ -260,7 +260,7 @@ struct allocator_traits
    }
 
    #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-      //! Effects: calls `a.construct(p, std::forward(args)...)` if that call is well-formed; 
+      //! Effects: calls `a.construct(p, std::forward(args)...)` if that call is well-formed;
       //! otherwise, invokes `::new (static_cast(p)) T(std::forward(args)...)`
       template 
       static void construct(Alloc & a, T* p, BOOST_FWD_REF(Args)... args)
@@ -300,8 +300,8 @@ struct allocator_traits
 
       #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
          template
-         static void priv_construct(boost::false_type, Alloc &a, T *p, BOOST_FWD_REF(Args) ...args)                    
-         {                                                                                                  
+         static void priv_construct(boost::false_type, Alloc &a, T *p, BOOST_FWD_REF(Args) ...args)                   
+         {                                                                                                 
             const bool value = boost::container::container_detail::
                   has_member_function_callable_with_construct
                      < Alloc, T*, Args... >::value;
@@ -336,7 +336,7 @@ struct allocator_traits
          //
          #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
          #include BOOST_PP_LOCAL_ITERATE()
-      
+     
          private:
          #define BOOST_PP_LOCAL_MACRO(n)                                                                    \
          template                                      \
diff --git a/include/boost/container/container_fwd.hpp b/include/boost/container/container_fwd.hpp
index cf8d6e6..c52b04a 100644
--- a/include/boost/container/container_fwd.hpp
+++ b/include/boost/container/container_fwd.hpp
@@ -21,8 +21,8 @@
 
 /// @cond
 
-namespace boost{ 
-namespace intrusive{ 
+namespace boost{
+namespace intrusive{
    //Create namespace to avoid compilation errors
 }}
 
@@ -32,9 +32,9 @@ namespace bi = boost::intrusive;
 
 }}}
 
-#include  
-#include  
-#include  
+#include 
+#include 
+#include 
 #include 
 #include 
 
@@ -127,7 +127,7 @@ class flat_multimap;
 //basic_string class
 template 
-         ,class A  = std::allocator > 
+         ,class A  = std::allocator >
 class basic_string;
 
 //! Type used to tag that the input range is
diff --git a/include/boost/container/deque.hpp b/include/boost/container/deque.hpp
index 92bf0d4..6a85ae9 100644
--- a/include/boost/container/deque.hpp
+++ b/include/boost/container/deque.hpp
@@ -90,7 +90,7 @@ struct deque_value_traits
 
 // Note: this function is simply a kludge to work around several compilers'
 //  bugs in handling constant expressions.
-inline std::size_t deque_buf_size(std::size_t size) 
+inline std::size_t deque_buf_size(std::size_t size)
    {  return size < 512 ? std::size_t(512 / size) : std::size_t(1);  }
 
 // Deque base class.  It has two purposes.  First, its constructor
@@ -128,16 +128,16 @@ class deque_base
 
    static size_type s_buffer_size() { return deque_buf_size(sizeof(T)); }
 
-   val_alloc_ptr priv_allocate_node() 
+   val_alloc_ptr priv_allocate_node()
       {  return this->alloc().allocate(s_buffer_size());  }
 
-   void priv_deallocate_node(val_alloc_ptr p) 
+   void priv_deallocate_node(val_alloc_ptr p)
       {  this->alloc().deallocate(p, s_buffer_size());  }
 
-   ptr_alloc_ptr priv_allocate_map(size_type n) 
+   ptr_alloc_ptr priv_allocate_map(size_type n)
       { return this->ptr_alloc().allocate(n); }
 
-   void priv_deallocate_map(ptr_alloc_ptr p, size_type n) 
+   void priv_deallocate_map(ptr_alloc_ptr p, size_type n)
       { this->ptr_alloc().deallocate(p, n); }
 
  public:
@@ -145,7 +145,7 @@ class deque_base
    //  For any nonsingular iterator i:
    //    i.node is the address of an element in the map array.  The
    //      contents of i.node is a pointer to the beginning of a node.
-   //    i.first == //(i.node) 
+   //    i.first == //(i.node)
    //    i.last  == i.first + node_size
    //    i.cur is a pointer in the range [i.first, i.last).  NOTE:
    //      the implication of this is that i.cur is always a dereferenceable
@@ -160,14 +160,14 @@ class deque_base
    //    [start.cur, start.last) and [finish.first, finish.cur) are initialized
    //    objects, and [start.first, start.cur) and [finish.cur, finish.last)
    //    are uninitialized storage.
-   //  [map, map + map_size) is a valid, non-empty range.  
-   //  [start.node, finish.node] is a valid range contained within 
-   //    [map, map + map_size).  
+   //  [map, map + map_size) is a valid, non-empty range. 
+   //  [start.node, finish.node] is a valid range contained within
+   //    [map, map + map_size). 
    //  A pointer in the range [map, map + map_size) points to an allocated node
    //    if and only if the pointer is in the range [start.node, finish.node].
-   class const_iterator 
-      : public std::iterator
    {
       public:
@@ -185,30 +185,30 @@ class deque_base
       friend class deque;
       friend class deque_base;
 
-      protected: 
+      protected:
       val_alloc_ptr  m_cur;
       val_alloc_ptr  m_first;
       val_alloc_ptr  m_last;
       index_pointer  m_node;
 
-      public: 
-      const_iterator(val_alloc_ptr x, index_pointer y) 
+      public:
+      const_iterator(val_alloc_ptr x, index_pointer y)
          : m_cur(x), m_first(*y),
            m_last(*y + s_buffer_size()), m_node(y) {}
 
       const_iterator() : m_cur(0), m_first(0), m_last(0), m_node(0) {}
 
       const_iterator(const const_iterator& x)
-         : m_cur(x.m_cur),   m_first(x.m_first), 
+         : m_cur(x.m_cur),   m_first(x.m_first),
            m_last(x.m_last), m_node(x.m_node) {}
 
-      reference operator*() const 
+      reference operator*() const
          { return *this->m_cur; }
 
-      pointer operator->() const 
+      pointer operator->() const
          { return this->m_cur; }
 
-      difference_type operator-(const self_t& x) const 
+      difference_type operator-(const self_t& x) const
       {
          if(!this->m_cur && !x.m_cur){
             return 0;
@@ -217,24 +217,24 @@ class deque_base
             (this->m_cur - this->m_first) + (x.m_last - x.m_cur);
       }
 
-      self_t& operator++() 
+      self_t& operator++()
       {
          ++this->m_cur;
          if (this->m_cur == this->m_last) {
             this->priv_set_node(this->m_node + 1);
             this->m_cur = this->m_first;
          }
-         return *this; 
+         return *this;
       }
 
-      self_t operator++(int)  
+      self_t operator++(int) 
       {
          self_t tmp = *this;
          ++*this;
          return tmp;
       }
 
-      self_t& operator--() 
+      self_t& operator--()
       {
          if (this->m_cur == this->m_first) {
             this->priv_set_node(this->m_node - 1);
@@ -244,7 +244,7 @@ class deque_base
          return *this;
       }
 
-      self_t operator--(int) 
+      self_t operator--(int)
       {
          self_t tmp = *this;
          --*this;
@@ -261,7 +261,7 @@ class deque_base
             offset > 0 ? offset / difference_type(this->s_buffer_size())
                         : -difference_type((-offset - 1) / this->s_buffer_size()) - 1;
             this->priv_set_node(this->m_node + node_offset);
-            this->m_cur = this->m_first + 
+            this->m_cur = this->m_first +
             (offset - node_offset * difference_type(this->s_buffer_size()));
          }
          return *this;
@@ -270,37 +270,37 @@ class deque_base
       self_t operator+(difference_type n) const
          {  self_t tmp = *this; return tmp += n;  }
 
-      self_t& operator-=(difference_type n) 
+      self_t& operator-=(difference_type n)
          { return *this += -n; }
-       
-      self_t operator-(difference_type n) const 
+      
+      self_t operator-(difference_type n) const
          {  self_t tmp = *this; return tmp -= n;  }
 
-      reference operator[](difference_type n) const 
+      reference operator[](difference_type n) const
          { return *(*this + n); }
 
-      bool operator==(const self_t& x) const 
+      bool operator==(const self_t& x) const
          { return this->m_cur == x.m_cur; }
 
-      bool operator!=(const self_t& x) const 
+      bool operator!=(const self_t& x) const
          { return !(*this == x); }
 
-      bool operator<(const self_t& x) const 
+      bool operator<(const self_t& x) const
       {
-         return (this->m_node == x.m_node) ? 
+         return (this->m_node == x.m_node) ?
             (this->m_cur < x.m_cur) : (this->m_node < x.m_node);
       }
 
-      bool operator>(const self_t& x) const  
+      bool operator>(const self_t& x) const 
          { return x < *this; }
 
-      bool operator<=(const self_t& x) const 
+      bool operator<=(const self_t& x) const
          { return !(x < *this); }
 
-      bool operator>=(const self_t& x) const 
+      bool operator>=(const self_t& x) const
          { return !(*this < x); }
 
-      void priv_set_node(index_pointer new_node) 
+      void priv_set_node(index_pointer new_node)
       {
          this->m_node = new_node;
          this->m_first = *new_node;
@@ -343,12 +343,12 @@ class deque_base
       reference operator[](difference_type n) const { return *(*this + n); }
 
       //Increment / Decrement
-      iterator& operator++()  
+      iterator& operator++() 
          { this->const_iterator::operator++(); return *this;  }
 
       iterator operator++(int)
          { iterator tmp = *this; ++*this; return tmp; }
-      
+     
       iterator& operator--()
          {  this->const_iterator::operator--(); return *this;  }
 
@@ -379,7 +379,7 @@ class deque_base
       :  members_(a)
    { this->priv_initialize_map(num_elements); }
 
-   explicit deque_base(const allocator_type& a) 
+   explicit deque_base(const allocator_type& a)
       :  members_(a)
    {}
 
@@ -402,7 +402,7 @@ class deque_base
 
    private:
    deque_base(const deque_base&);
-  
+ 
    protected:
 
    void swap_members(deque_base &x)
@@ -423,7 +423,7 @@ class deque_base
 
          ptr_alloc_ptr nstart = this->members_.m_map + (this->members_.m_map_size - num_nodes) / 2;
          ptr_alloc_ptr nfinish = nstart + num_nodes;
-             
+            
          BOOST_TRY {
             this->priv_create_nodes(nstart, nfinish);
          }
@@ -508,16 +508,16 @@ class deque_base
       iterator        m_finish;
    } members_;
 
-   ptr_alloc_t &ptr_alloc() 
+   ptr_alloc_t &ptr_alloc()
    {  return members_;  }
-   
-   const ptr_alloc_t &ptr_alloc() const 
+  
+   const ptr_alloc_t &ptr_alloc() const
    {  return members_;  }
 
-   allocator_type &alloc() 
+   allocator_type &alloc()
    {  return members_;  }
-   
-   const allocator_type &alloc() const 
+  
+   const allocator_type &alloc() const
    {  return members_;  }
 };
 /// @endcond
@@ -574,7 +574,7 @@ class deque : protected deque_base
    private:                      // Internal typedefs
    BOOST_COPYABLE_AND_MOVABLE(deque)
    typedef ptr_alloc_ptr index_pointer;
-   static size_type s_buffer_size() 
+   static size_type s_buffer_size()
       { return Base::s_buffer_size(); }
    typedef container_detail::advanced_insert_aux_int advanced_insert_aux_int_t;
    typedef repeat_iterator  r_iterator;
@@ -586,175 +586,175 @@ class deque : protected deque_base
    public:
 
    //! Effects: Returns a copy of the internal allocator.
-   //! 
+   //!
    //! Throws: If allocator's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
    allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
    { return Base::alloc(); }
 
    //! Effects: Returns a reference to the internal allocator.
-   //! 
+   //!
    //! Throws: Nothing
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Note: Non-standard extension.
    const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
    {  return Base::alloc(); }
 
    //! Effects: Returns a reference to the internal allocator.
-   //! 
+   //!
    //! Throws: Nothing
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Note: Non-standard extension.
    stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
    {  return Base::alloc(); }
 
    //! Effects: Returns an iterator to the first element contained in the deque.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    iterator begin() BOOST_CONTAINER_NOEXCEPT
       { return this->members_.m_start; }
 
    //! Effects: Returns an iterator to the end of the deque.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    iterator end() BOOST_CONTAINER_NOEXCEPT
       { return this->members_.m_finish; }
 
    //! Effects: Returns a const_iterator to the first element contained in the deque.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
       { return this->members_.m_start; }
 
    //! Effects: Returns a const_iterator to the end of the deque.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator end() const BOOST_CONTAINER_NOEXCEPT
       { return this->members_.m_finish; }
 
-   //! Effects: Returns a reverse_iterator pointing to the beginning 
-   //! of the reversed deque. 
-   //! 
+   //! Effects: Returns a reverse_iterator pointing to the beginning
+   //! of the reversed deque.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT
       { return reverse_iterator(this->members_.m_finish); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
-   //! of the reversed deque. 
-   //! 
+   //! of the reversed deque.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT
       { return reverse_iterator(this->members_.m_start); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed deque. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed deque.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
       { return const_reverse_iterator(this->members_.m_finish); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed deque. 
-   //! 
+   //! of the reversed deque.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT
       { return const_reverse_iterator(this->members_.m_start); }
 
    //! Effects: Returns a const_iterator to the first element contained in the deque.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
       { return this->members_.m_start; }
 
    //! Effects: Returns a const_iterator to the end of the deque.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
       { return this->members_.m_finish; }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed deque. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed deque.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT
       { return const_reverse_iterator(this->members_.m_finish); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed deque. 
-   //! 
+   //! of the reversed deque.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
       { return const_reverse_iterator(this->members_.m_start); }
 
    //! Requires: size() > n.
    //!
-   //! Effects: Returns a reference to the nth element 
+   //! Effects: Returns a reference to the nth element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT
       { return this->members_.m_start[difference_type(n)]; }
 
    //! Requires: size() > n.
    //!
-   //! Effects: Returns a const reference to the nth element 
+   //! Effects: Returns a const reference to the nth element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT
       { return this->members_.m_start[difference_type(n)]; }
 
    //! Requires: size() > n.
    //!
-   //! Effects: Returns a reference to the nth element 
+   //! Effects: Returns a reference to the nth element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: std::range_error if n >= size()
-   //! 
+   //!
    //! Complexity: Constant.
    reference at(size_type n)
       { this->priv_range_check(n); return (*this)[n]; }
 
    //! Requires: size() > n.
    //!
-   //! Effects: Returns a const reference to the nth element 
+   //! Effects: Returns a const reference to the nth element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: std::range_error if n >= size()
-   //! 
+   //!
    //! Complexity: Constant.
    const_reference at(size_type n) const
       { this->priv_range_check(n); return (*this)[n]; }
@@ -763,20 +763,20 @@ class deque : protected deque_base
    //!
    //! Effects: Returns a reference to the first
    //!   element of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reference front() BOOST_CONTAINER_NOEXCEPT
       { return *this->members_.m_start; }
 
    //! Requires: !empty()
    //!
-   //! Effects: Returns a const reference to the first element 
+   //! Effects: Returns a const reference to the first element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reference front() const BOOST_CONTAINER_NOEXCEPT
       { return *this->members_.m_start; }
@@ -785,9 +785,9 @@ class deque : protected deque_base
    //!
    //! Effects: Returns a reference to the last
    //!   element of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reference back() BOOST_CONTAINER_NOEXCEPT
       {  return *(end()-1); }
@@ -796,52 +796,52 @@ class deque : protected deque_base
    //!
    //! Effects: Returns a const reference to the last
    //!   element of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reference back() const BOOST_CONTAINER_NOEXCEPT
       {  return *(cend()-1);  }
 
    //! Effects: Returns the number of the elements contained in the deque.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    size_type size() const BOOST_CONTAINER_NOEXCEPT
       { return this->members_.m_finish - this->members_.m_start; }
 
    //! Effects: Returns the largest possible size of the deque.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    size_type max_size() const BOOST_CONTAINER_NOEXCEPT
       { return allocator_traits_type::max_size(this->alloc()); }
 
    //! Effects: Returns true if the deque contains no elements.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    bool empty() const BOOST_CONTAINER_NOEXCEPT
    { return this->members_.m_finish == this->members_.m_start; }
 
    //! Effects: Default constructors a deque.
-   //! 
+   //!
    //! Throws: If allocator_type's default constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
-   deque() 
+   deque()
       : Base()
    {}
 
    //! Effects: Constructs a deque taking the allocator as parameter.
-   //! 
+   //!
    //! Throws: If allocator_type's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
-   explicit deque(const allocator_type& a) 
+   explicit deque(const allocator_type& a)
       : Base(a)
    {}
 
@@ -850,7 +850,7 @@ class deque : protected deque_base
    //!
    //! Throws: If allocator_type's default constructor or copy constructor
    //!   throws or T's default or copy constructor throws.
-   //! 
+   //!
    //! Complexity: Linear to n.
    explicit deque(size_type n)
       : Base(n, allocator_type())
@@ -865,7 +865,7 @@ class deque : protected deque_base
    //!
    //! Throws: If allocator_type's default constructor or copy constructor
    //!   throws or T's default or copy constructor throws.
-   //! 
+   //!
    //! Complexity: Linear to n.
    deque(size_type n, const value_type& value,
          const allocator_type& a = allocator_type())
@@ -875,7 +875,7 @@ class deque : protected deque_base
    //! Effects: Copy constructs a deque.
    //!
    //! Postcondition: x == *this.
-   //! 
+   //!
    //! Complexity: Linear to the elements x contains.
    deque(const deque& x)
       :  Base(allocator_traits_type::select_on_container_copy_construction(x.alloc()))
@@ -890,19 +890,19 @@ class deque : protected deque_base
    //! Effects: Move constructor. Moves mx's resources to *this.
    //!
    //! Throws: If allocator_type's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
-   deque(BOOST_RV_REF(deque) x) 
+   deque(BOOST_RV_REF(deque) x)
       :  Base(boost::move(static_cast(x)))
    {  this->swap_members(x);   }
 
    //! Effects: Copy constructs a vector using the specified allocator.
    //!
    //! Postcondition: x == *this.
-   //! 
+   //!
    //! Throws: If allocation
    //!   throws or T's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Linear to the elements x contains.
    deque(const deque& x, const allocator_type &a)
       :  Base(a)
@@ -919,9 +919,9 @@ class deque : protected deque_base
    //!                 Otherwise copies values from x to *this.
    //!
    //! Throws: If allocation or T's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant if a == mx.get_allocator(), linear otherwise.
-   deque(BOOST_RV_REF(deque) mx, const allocator_type &a) 
+   deque(BOOST_RV_REF(deque) mx, const allocator_type &a)
       :  Base(a)
    {
       if(mx.alloc() == a){
@@ -945,7 +945,7 @@ class deque : protected deque_base
    //! Complexity: Linear to the range [first, last).
    template 
    deque(InpIt first, InpIt last, const allocator_type& a = allocator_type())
-      : Base(a) 
+      : Base(a)
    {
       //Dispatch depending on integer/iterator
       const bool aux_boolean = container_detail::is_convertible::value;
@@ -966,13 +966,13 @@ class deque : protected deque_base
 
    //! Effects: Makes *this contain the same elements as x.
    //!
-   //! Postcondition: this->size() == x.size(). *this contains a copy 
-   //! of each of x's elements. 
+   //! Postcondition: this->size() == x.size(). *this contains a copy
+   //! of each of x's elements.
    //!
    //! Throws: If memory allocation throws or T's copy constructor throws.
    //!
    //! Complexity: Linear to the number of elements in x.
-   deque& operator= (BOOST_COPY_ASSIGN_REF(deque) x) 
+   deque& operator= (BOOST_COPY_ASSIGN_REF(deque) x)
    {
       if (&x != this){
          allocator_type &this_alloc     = this->alloc();
@@ -1132,7 +1132,7 @@ class deque : protected deque_base
             );
          ++this->members_.m_start.m_cur;
       }
-      else 
+      else
          this->priv_pop_front_aux();
    }
 
@@ -1180,7 +1180,7 @@ class deque : protected deque_base
    //!
    //! Complexity: Linear to std::distance [first, last).
    template 
-   void insert(const_iterator pos, InpIt first, InpIt last) 
+   void insert(const_iterator pos, InpIt first, InpIt last)
    {
       //Dispatch depending on integer/iterator
       const bool aux_boolean = container_detail::is_convertible::value;
@@ -1340,10 +1340,10 @@ class deque : protected deque_base
    //! Throws: If memory allocation throws, or T's copy constructor throws.
    //!
    //! Complexity: Linear to the difference between size() and new_size.
-   void resize(size_type new_size, const value_type& x) 
+   void resize(size_type new_size, const value_type& x)
    {
       const size_type len = size();
-      if (new_size < len) 
+      if (new_size < len)
          this->erase(this->members_.m_start + new_size, this->members_.m_finish);
       else
          this->insert(this->members_.m_finish, new_size - len, x);
@@ -1355,10 +1355,10 @@ class deque : protected deque_base
    //! Throws: If memory allocation throws, or T's copy constructor throws.
    //!
    //! Complexity: Linear to the difference between size() and new_size.
-   void resize(size_type new_size) 
+   void resize(size_type new_size)
    {
       const size_type len = size();
-      if (new_size < len) 
+      if (new_size < len)
          this->priv_erase_last_n(len - new_size);
       else{
          size_type n = new_size - this->size();
@@ -1371,7 +1371,7 @@ class deque : protected deque_base
    //!
    //! Throws: Nothing.
    //!
-   //! Complexity: Linear to the elements between pos and the 
+   //! Complexity: Linear to the elements between pos and the
    //!   last element (if pos is near the end) or the first element
    //!   if(pos is near the beginning).
    //!   Constant if pos is the first or the last element.
@@ -1396,7 +1396,7 @@ class deque : protected deque_base
    //! Throws: Nothing.
    //!
    //! Complexity: Linear to the distance between first and
-   //!   last plus the elements between pos and the 
+   //!   last plus the elements between pos and the
    //!   last element (if pos is near the end) or the first element
    //!   if(pos is near the beginning).
    iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
@@ -1486,10 +1486,10 @@ class deque : protected deque_base
 
    /// @cond
    private:
-   void priv_range_check(size_type n) const 
+   void priv_range_check(size_type n) const
       {  if (n >= this->size())  BOOST_RETHROW std::out_of_range("deque");   }
 
-   iterator priv_insert(const_iterator position, const value_type &x) 
+   iterator priv_insert(const_iterator position, const value_type &x)
    {
       if (position == cbegin()){
          this->push_front(x);
@@ -1506,7 +1506,7 @@ class deque : protected deque_base
       }
    }
 
-   iterator priv_insert(const_iterator position, BOOST_RV_REF(value_type) mx) 
+   iterator priv_insert(const_iterator position, BOOST_RV_REF(value_type) mx)
    {
       if (position == cbegin()) {
          this->push_front(boost::move(mx));
@@ -1609,7 +1609,7 @@ class deque : protected deque_base
    }
 
    template 
-   void priv_insert_aux(const_iterator pos, FwdIt first, FwdIt last, std::forward_iterator_tag) 
+   void priv_insert_aux(const_iterator pos, FwdIt first, FwdIt last, std::forward_iterator_tag)
    {  this->priv_insert_aux(pos, first, last);  }
 
   // assign(), a generalized assignment member function.  Two
@@ -1629,14 +1629,14 @@ class deque : protected deque_base
    }
 
    template 
-   void priv_initialize_dispatch(Integer n, Integer x, container_detail::true_) 
+   void priv_initialize_dispatch(Integer n, Integer x, container_detail::true_)
    {
       this->priv_initialize_map(n);
       this->priv_fill_initialize(x);
    }
 
    template 
-   void priv_initialize_dispatch(InpIt first, InpIt last, container_detail::false_) 
+   void priv_initialize_dispatch(InpIt first, InpIt last, container_detail::false_)
    {
       typedef typename std::iterator_traits::iterator_category ItCat;
       this->priv_range_initialize(first, last, ItCat());
@@ -1667,7 +1667,7 @@ class deque : protected deque_base
       { this->priv_fill_assign((size_type) n, (value_type)val); }
 
    template 
-   void priv_assign_dispatch(InpIt first, InpIt last, container_detail::false_) 
+   void priv_assign_dispatch(InpIt first, InpIt last, container_detail::false_)
    {
       typedef typename std::iterator_traits::iterator_category ItCat;
       this->priv_assign_aux(first, last, ItCat());
@@ -1700,11 +1700,11 @@ class deque : protected deque_base
    }
 
    template 
-   void priv_insert_dispatch(const_iterator pos, Integer n, Integer x, container_detail::true_) 
+   void priv_insert_dispatch(const_iterator pos, Integer n, Integer x, container_detail::true_)
    {  this->priv_fill_insert(pos, (size_type) n, (value_type)x); }
 
    template 
-   void priv_insert_dispatch(const_iterator pos,InpIt first, InpIt last, container_detail::false_) 
+   void priv_insert_dispatch(const_iterator pos,InpIt first, InpIt last, container_detail::false_)
    {
       typedef typename std::iterator_traits::iterator_category ItCat;
       this->priv_insert_aux(pos, first, last, ItCat());
@@ -1739,7 +1739,7 @@ class deque : protected deque_base
          iterator old_start = this->members_.m_start;
          pos = this->members_.m_start + elemsbefore;
          if (elemsbefore >= difference_type(n)) {
-            iterator start_n = this->members_.m_start + difference_type(n); 
+            iterator start_n = this->members_.m_start + difference_type(n);
             ::boost::container::uninitialized_move_alloc
                (this->alloc(), this->members_.m_start, start_n, new_start);
             this->members_.m_start = new_start;
@@ -1760,7 +1760,7 @@ class deque : protected deque_base
       else {
          iterator new_finish = this->priv_reserve_elements_at_back(n);
          iterator old_finish = this->members_.m_finish;
-         const difference_type elemsafter = 
+         const difference_type elemsafter =
             difference_type(length) - elemsbefore;
          pos = this->members_.m_finish - elemsafter;
          if (elemsafter >= difference_type(n)) {
@@ -1814,7 +1814,7 @@ class deque : protected deque_base
 
    // Precondition: this->members_.m_start and this->members_.m_finish have already been initialized,
    // but none of the deque's elements have yet been constructed.
-   void priv_fill_initialize(const value_type& value) 
+   void priv_fill_initialize(const value_type& value)
    {
       index_pointer cur;
       BOOST_TRY {
@@ -1856,8 +1856,8 @@ class deque : protected deque_base
 
       index_pointer cur_node;
       BOOST_TRY {
-         for (cur_node = this->members_.m_start.m_node; 
-               cur_node < this->members_.m_finish.m_node; 
+         for (cur_node = this->members_.m_start.m_node;
+               cur_node < this->members_.m_finish.m_node;
                ++cur_node) {
             FwdIt mid = first;
             std::advance(mid, this->s_buffer_size());
@@ -1887,9 +1887,9 @@ class deque : protected deque_base
          );
    }
 
-   // Called only if this->members_.m_start.m_cur == this->members_.m_start.m_last - 1.  Note that 
-   // if the deque has at least one element (a precondition for this member 
-   // function), and if this->members_.m_start.m_cur == this->members_.m_start.m_last, then the deque 
+   // Called only if this->members_.m_start.m_cur == this->members_.m_start.m_last - 1.  Note that
+   // if the deque has at least one element (a precondition for this member
+   // function), and if this->members_.m_start.m_cur == this->members_.m_start.m_last, then the deque
    // must have at least two nodes.
    void priv_pop_front_aux()
    {
@@ -1900,14 +1900,14 @@ class deque : protected deque_base
       this->priv_deallocate_node(this->members_.m_start.m_first);
       this->members_.m_start.priv_set_node(this->members_.m_start.m_node + 1);
       this->members_.m_start.m_cur = this->members_.m_start.m_first;
-   }      
+   }     
 
-   iterator priv_reserve_elements_at_front(size_type n) 
+   iterator priv_reserve_elements_at_front(size_type n)
    {
       size_type vacancies = this->members_.m_start.m_cur - this->members_.m_start.m_first;
       if (n > vacancies){
          size_type new_elems = n-vacancies;
-         size_type new_nodes = (new_elems + this->s_buffer_size() - 1) / 
+         size_type new_nodes = (new_elems + this->s_buffer_size() - 1) /
             this->s_buffer_size();
          size_type s = (size_type)(this->members_.m_start.m_node - this->members_.m_map);
          if (new_nodes > s){
@@ -1920,7 +1920,7 @@ class deque : protected deque_base
          }
          BOOST_CATCH(...) {
             for (size_type j = 1; j < i; ++j)
-               this->priv_deallocate_node(*(this->members_.m_start.m_node - j));      
+               this->priv_deallocate_node(*(this->members_.m_start.m_node - j));     
             BOOST_RETHROW
          }
          BOOST_CATCH_END
@@ -1928,7 +1928,7 @@ class deque : protected deque_base
       return this->members_.m_start - difference_type(n);
    }
 
-   iterator priv_reserve_elements_at_back(size_type n) 
+   iterator priv_reserve_elements_at_back(size_type n)
    {
       size_type vacancies = (this->members_.m_finish.m_last - this->members_.m_finish.m_cur) - 1;
       if (n > vacancies){
@@ -1945,7 +1945,7 @@ class deque : protected deque_base
          }
          BOOST_CATCH(...) {
             for (size_type j = 1; j < i; ++j)
-               this->priv_deallocate_node(*(this->members_.m_finish.m_node + j));      
+               this->priv_deallocate_node(*(this->members_.m_finish.m_node + j));     
             BOOST_RETHROW
          }
          BOOST_CATCH_END
@@ -1960,7 +1960,7 @@ class deque : protected deque_base
 
       index_pointer new_nstart;
       if (this->members_.m_map_size > 2 * new_num_nodes) {
-         new_nstart = this->members_.m_map + (this->members_.m_map_size - new_num_nodes) / 2 
+         new_nstart = this->members_.m_map + (this->members_.m_map_size - new_num_nodes) / 2
                            + (add_at_front ? nodes_to_add : 0);
          if (new_nstart < this->members_.m_start.m_node)
             boost::move(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart);
@@ -1969,7 +1969,7 @@ class deque : protected deque_base
                (this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart + old_num_nodes);
       }
       else {
-         size_type new_map_size = 
+         size_type new_map_size =
             this->members_.m_map_size + container_detail::max_value(this->members_.m_map_size, nodes_to_add) + 2;
 
          index_pointer new_map = this->priv_allocate_map(new_map_size);
@@ -1998,29 +1998,29 @@ inline bool operator==(const deque& x,
 
 template 
 inline bool operator<(const deque& x,
-                      const deque& y) 
+                      const deque& y)
 {
    return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
 }
 
 template 
 inline bool operator!=(const deque& x,
-                       const deque& y) 
+                       const deque& y)
    {  return !(x == y);   }
 
 template 
 inline bool operator>(const deque& x,
-                      const deque& y) 
+                      const deque& y)
    {  return y < x; }
 
 template 
 inline bool operator<=(const deque& x,
-                       const deque& y) 
+                       const deque& y)
    {  return !(y < x); }
 
 template 
 inline bool operator>=(const deque& x,
-                       const deque& y) 
+                       const deque& y)
    {  return !(x < y); }
 
 
diff --git a/include/boost/container/detail/adaptive_node_pool_impl.hpp b/include/boost/container/detail/adaptive_node_pool_impl.hpp
index 92b6133..afba6b5 100644
--- a/include/boost/container/detail/adaptive_node_pool_impl.hpp
+++ b/include/boost/container/detail/adaptive_node_pool_impl.hpp
@@ -51,11 +51,11 @@ struct adaptive_pool_types
       , bi::optimize_size
       , bi::constant_time_size
       , bi::link_mode >::type multiset_hook_t;
-   
+  
    typedef hdr_offset_holder_t hdr_offset_holder;
 
    struct block_info_t
-      :  
+      : 
          public hdr_offset_holder,
          public multiset_hook_t
    {
@@ -89,7 +89,7 @@ inline size_type calculate_alignment
    const size_type divisor  = overhead_percent*real_node_size;
    const size_type dividend = hdr_offset_size*100;
    size_type elements_per_subblock = (dividend - 1)/divisor + 1;
-   size_type candidate_power_of_2 = 
+   size_type candidate_power_of_2 =
       upper_power_of_2(elements_per_subblock*real_node_size + hdr_offset_size);
    bool overhead_satisfied = false;
    //Now calculate the wors-case overhead for a subblock
@@ -228,7 +228,7 @@ class private_adaptive_node_pool_impl
    {
       priv_invariants();
       //If there are no free nodes we allocate a new block
-      if (m_block_multiset.empty()){ 
+      if (m_block_multiset.empty()){
          priv_alloc_block(1);
       }
       //We take the first free node the multiset can't be empty
@@ -248,7 +248,7 @@ class private_adaptive_node_pool_impl
       priv_invariants();
    }
 
-   //!Allocates n nodes. 
+   //!Allocates n nodes.
    //!Can throw
    multiallocation_chain allocate_nodes(const size_type n)
    {
@@ -448,7 +448,7 @@ class private_adaptive_node_pool_impl
    #undef BOOST_CONTAINER_ADAPTIVE_NODE_POOL_CHECK_INVARIANTS
    {
       //We iterate through the block tree to free the memory
-      block_iterator it(m_block_multiset.begin()), 
+      block_iterator it(m_block_multiset.begin()),
                      itend(m_block_multiset.end()), to_deallocate;
       if(it != itend){
          for(++it; it != itend; ++it){
@@ -559,9 +559,9 @@ class private_adaptive_node_pool_impl
          ++m_totally_free_blocks;
          block_info_t *c_info = new(mem_address)block_info_t();
          m_block_multiset.insert(m_block_multiset.end(), *c_info);
-         
+        
          mem_address += HdrSize;
-         //We initialize all Nodes in Node Block to insert 
+         //We initialize all Nodes in Node Block to insert
          //them in the free Node list
          typename free_nodes_t::iterator prev_insert_pos = c_info->free_nodes.before_begin();
          for(size_type i = 0; i < m_real_num_node; ++i){
@@ -605,7 +605,7 @@ class private_adaptive_node_pool_impl
          }
          {
             char *pNode = hdr_addr + HdrSize;
-            //We initialize all Nodes in Node Block to insert 
+            //We initialize all Nodes in Node Block to insert
             //them in the free Node list
             for(size_type i = 0; i < hdr_subblock_elements; ++i){
                prev_insert_pos = c_info->free_nodes.insert_after(prev_insert_pos, *new (pNode) node_t);
diff --git a/include/boost/container/detail/advanced_insert_int.hpp b/include/boost/container/detail/advanced_insert_int.hpp
index 0d198b0..a97af28 100644
--- a/include/boost/container/detail/advanced_insert_int.hpp
+++ b/include/boost/container/detail/advanced_insert_int.hpp
@@ -183,7 +183,7 @@ namespace container {
 namespace container_detail {
 
 
-//This class template will adapt emplace construction insertions of movable types 
+//This class template will adapt emplace construction insertions of movable types
 //to advanced_insert_aux_int
 template
 struct advanced_insert_aux_non_movable_emplace
@@ -254,7 +254,7 @@ struct advanced_insert_aux_non_movable_emplace
    bool used_;
 };
 
-//This class template will adapt emplace construction insertions of movable types 
+//This class template will adapt emplace construction insertions of movable types
 //to advanced_insert_aux_int
 template
 struct advanced_insert_aux_emplace
@@ -323,11 +323,11 @@ struct advanced_insert_aux_emplace
 
 #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
-#include  
+#include 
 #include 
 
 namespace boost {
-namespace container { 
+namespace container {
 namespace container_detail {
 
 #define BOOST_PP_LOCAL_MACRO(n)                                                     \
diff --git a/include/boost/container/detail/algorithms.hpp b/include/boost/container/detail/algorithms.hpp
index 5735f4d..dc09575 100644
--- a/include/boost/container/detail/algorithms.hpp
+++ b/include/boost/container/detail/algorithms.hpp
@@ -51,7 +51,7 @@ inline void construct_in_place(A &a, T *dest, emplace_iterator ei)
    ei.construct_in_place(a, dest);
 }
 
-}  //namespace container { 
+}  //namespace container {
 }  //namespace boost {
 
 #include 
diff --git a/include/boost/container/detail/allocation_type.hpp b/include/boost/container/detail/allocation_type.hpp
index 3988fda..1ebf20e 100644
--- a/include/boost/container/detail/allocation_type.hpp
+++ b/include/boost/container/detail/allocation_type.hpp
@@ -23,7 +23,7 @@ namespace container {
 
 /// @cond
 enum allocation_type_v
-{   
+{  
    // constants for allocation commands
    allocate_new_v   = 0x01,
    expand_fwd_v     = 0x02,
diff --git a/include/boost/container/detail/destroyers.hpp b/include/boost/container/detail/destroyers.hpp
index 55b811d..3a42be3 100644
--- a/include/boost/container/detail/destroyers.hpp
+++ b/include/boost/container/detail/destroyers.hpp
@@ -24,7 +24,7 @@
 #include 
 
 namespace boost {
-namespace container { 
+namespace container {
 namespace container_detail {
 
 //!A deleter for scoped_ptr that deallocates the memory
@@ -88,7 +88,7 @@ struct scoped_destructor_n
 
    void increment_size_backwards(size_type inc)
    {  m_n += inc;   m_p -= inc;  }
-   
+  
    ~scoped_destructor_n()
    {
       if(!m_p) return;
@@ -185,8 +185,8 @@ class allocator_destroyer
 };
 
 
-}  //namespace container_detail { 
-}  //namespace container { 
+}  //namespace container_detail {
+}  //namespace container {
 }  //namespace boost {
 
 #include 
diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp
index f5710c5..739c844 100644
--- a/include/boost/container/detail/flat_tree.hpp
+++ b/include/boost/container/detail/flat_tree.hpp
@@ -48,24 +48,24 @@ class flat_tree_value_compare
    typedef Value              first_argument_type;
    typedef Value              second_argument_type;
    typedef bool               return_type;
-   public:     
+   public:    
    flat_tree_value_compare()
       : Compare()
    {}
 
-   flat_tree_value_compare(const Compare &pred) 
+   flat_tree_value_compare(const Compare &pred)
       : Compare(pred)
    {}
 
    bool operator()(const Value& lhs, const Value& rhs) const
-   { 
+   {
       KeyOfValue key_extract;
-      return Compare::operator()(key_extract(lhs), key_extract(rhs)); 
+      return Compare::operator()(key_extract(lhs), key_extract(rhs));
    }
 
    const Compare &get_comp() const
       {  return *this;  }
-   
+  
    Compare &get_comp()
       {  return *this;  }
 };
@@ -81,7 +81,7 @@ struct get_flat_tree_iterators
    typedef std::reverse_iterator      const_reverse_iterator;
 };
 
-template 
 class flat_tree
 {
@@ -92,7 +92,7 @@ class flat_tree
    typedef flat_tree_value_compare value_compare;
 
  private:
-   struct Data 
+   struct Data
       //Inherit from value_compare to do EBO
       : public value_compare
    {
@@ -119,12 +119,12 @@ class flat_tree
          : value_compare(boost::move(static_cast(d))), m_vect(boost::move(d.m_vect), a)
       {}
 
-      Data(const Compare &comp) 
+      Data(const Compare &comp)
          : value_compare(comp), m_vect()
       {}
 
       Data(const Compare &comp,
-           const allocator_t &alloc) 
+           const allocator_t &alloc)
          : value_compare(comp), m_vect(alloc)
       {}
 
@@ -191,7 +191,7 @@ class flat_tree
       : m_data(comp, a)
    { }
 
-   flat_tree(const flat_tree& x) 
+   flat_tree(const flat_tree& x)
       :  m_data(x.m_data)
    { }
 
@@ -199,7 +199,7 @@ class flat_tree
       :  m_data(boost::move(x.m_data))
    { }
 
-   flat_tree(const flat_tree& x, const allocator_type &a) 
+   flat_tree(const flat_tree& x, const allocator_type &a)
       :  m_data(x.m_data, a)
    { }
 
@@ -223,66 +223,66 @@ class flat_tree
    flat_tree&  operator=(BOOST_RV_REF(flat_tree) mx)
    {  m_data = boost::move(mx.m_data); return *this;  }
 
-   public:    
+   public:   
    // accessors:
-   Compare key_comp() const 
+   Compare key_comp() const
    { return this->m_data.get_comp(); }
 
-   allocator_type get_allocator() const 
+   allocator_type get_allocator() const
    { return this->m_data.m_vect.get_allocator(); }
 
-   const stored_allocator_type &get_stored_allocator() const 
+   const stored_allocator_type &get_stored_allocator() const
    {  return this->m_data.m_vect.get_stored_allocator(); }
 
    stored_allocator_type &get_stored_allocator()
    {  return this->m_data.m_vect.get_stored_allocator(); }
 
-   iterator begin() 
+   iterator begin()
    { return this->m_data.m_vect.begin(); }
 
-   const_iterator begin() const 
+   const_iterator begin() const
    { return this->cbegin(); }
 
-   const_iterator cbegin() const 
+   const_iterator cbegin() const
    { return this->m_data.m_vect.begin(); }
 
-   iterator end() 
+   iterator end()
    { return this->m_data.m_vect.end(); }
 
-   const_iterator end() const 
+   const_iterator end() const
    { return this->cend(); }
 
-   const_iterator cend() const 
+   const_iterator cend() const
    { return this->m_data.m_vect.end(); }
 
-   reverse_iterator rbegin() 
+   reverse_iterator rbegin()
    { return reverse_iterator(this->end()); }
 
-   const_reverse_iterator rbegin() const 
+   const_reverse_iterator rbegin() const
    {  return this->crbegin();  }
 
-   const_reverse_iterator crbegin() const 
+   const_reverse_iterator crbegin() const
    {  return const_reverse_iterator(this->cend());  }
 
-   reverse_iterator rend() 
+   reverse_iterator rend()
    { return reverse_iterator(this->begin()); }
 
-   const_reverse_iterator rend() const 
-   { return this->crend(); } 
+   const_reverse_iterator rend() const
+   { return this->crend(); }
 
-   const_reverse_iterator crend() const 
-   { return const_reverse_iterator(this->cbegin()); } 
+   const_reverse_iterator crend() const
+   { return const_reverse_iterator(this->cbegin()); }
 
-   bool empty() const 
+   bool empty() const
    { return this->m_data.m_vect.empty(); }
 
-   size_type size() const 
+   size_type size() const
    { return this->m_data.m_vect.size(); }
 
-   size_type max_size() const 
+   size_type max_size() const
    { return this->m_data.m_vect.max_size(); }
 
-   void swap(flat_tree& other) 
+   void swap(flat_tree& other)
    {  this->m_data.swap(other.m_data);  }
 
    public:
@@ -365,7 +365,7 @@ class flat_tree
    template 
    void insert_equal(InIt first, InIt last)
    {
-      typedef typename 
+      typedef typename
          std::iterator_traits::iterator_category ItCat;
       this->priv_insert_equal(first, last, ItCat());
    }
@@ -373,11 +373,19 @@ class flat_tree
    template 
    void insert_equal(ordered_range_t, InIt first, InIt last)
    {
-      typedef typename 
+      typedef typename
          std::iterator_traits::iterator_category ItCat;
       this->priv_insert_equal(ordered_range_t(), first, last, ItCat());
    }
 
+   template 
+   void insert_unique(ordered_unique_range_t, InIt first, InIt last)
+   {
+      typedef typename
+         std::iterator_traits::iterator_category ItCat;
+      this->priv_insert_unique(ordered_unique_range_t(), first, last, ItCat());
+   }
+
    #ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
    template 
@@ -557,8 +565,8 @@ class flat_tree
       const Compare &key_comp = this->m_data.get_comp();
       iterator i = this->lower_bound(k);
 
-      if (i != this->end() && key_comp(k, KeyOfValue()(*i))){  
-         i = this->end();  
+      if (i != this->end() && key_comp(k, KeyOfValue()(*i))){ 
+         i = this->end(); 
       }
       return i;
    }
@@ -568,8 +576,8 @@ class flat_tree
       const Compare &key_comp = this->m_data.get_comp();
       const_iterator i = this->lower_bound(k);
 
-      if (i != this->end() && key_comp(k, KeyOfValue()(*i))){  
-         i = this->end();  
+      if (i != this->end() && key_comp(k, KeyOfValue()(*i))){ 
+         i = this->end(); 
       }
       return i;
    }
@@ -599,10 +607,10 @@ class flat_tree
    std::pair equal_range(const key_type& k) const
    {  return this->priv_equal_range(this->begin(), this->end(), k);  }
 
-   size_type capacity() const           
+   size_type capacity() const          
    { return this->m_data.m_vect.capacity(); }
 
-   void reserve(size_type count)       
+   void reserve(size_type count)      
    { this->m_data.m_vect.reserve(count);   }
 
    private:
@@ -631,12 +639,12 @@ class flat_tree
             data.position = pos;
          }
          else{
-            data.position = 
+            data.position =
                this->priv_upper_bound(this->cbegin(), pos, KeyOfValue()(val));
          }
       }
       else{
-         data.position = 
+         data.position =
             this->priv_lower_bound(pos, this->cend(), KeyOfValue()(val));
       }
    }
@@ -756,7 +764,7 @@ class flat_tree
          }
          else{
             first = ++middle;
-            len = len - half - 1;  
+            len = len - half - 1; 
          }
       }
       return first;
@@ -801,28 +809,82 @@ class flat_tree
       const size_type BurstSize = 16;
       size_type positions[BurstSize];
 
+      //Prereserve all memory so that iterators are not invalidated
+      this->reserve(this->size()+len);
+      const const_iterator beg(this->cbegin());
+      const_iterator pos(beg);
+      //Loop in burst sizes
       while(len){
          const size_type burst = len < BurstSize ? len : BurstSize;
+         const const_iterator cend(this->cend());
          len -= burst;
-         const iterator beg(this->cbegin());
-         iterator pos;
          for(size_type i = 0; i != burst; ++i){
-            pos = this->upper_bound(KeyOfValue()(*first));
+            //Get the insertion position for each key
+            pos = const_cast(*this).priv_upper_bound(pos, cend, KeyOfValue()(*first));
             positions[i] = static_cast(pos - beg);
             ++first;
          }
+         //Insert all in a single step in the precalculated positions
          this->m_data.m_vect.insert_ordered_at(burst, positions + burst, first);
+         //Next search position updated
+         pos += burst;
       }
    }
 
+   template 
+   void priv_insert_unique(ordered_unique_range_t, BidirIt first, BidirIt last, std::bidirectional_iterator_tag)
+   {
+      size_type len = static_cast(std::distance(first, last));
+      const size_type BurstSize = 16;
+      size_type positions[BurstSize];
+      size_type skips[BurstSize];
+
+      //Prereserve all memory so that iterators are not invalidated
+      this->reserve(this->size()+len);
+      const const_iterator beg(this->cbegin());
+      const_iterator pos(beg);
+      const value_compare &value_comp = this->m_data;
+      //Loop in burst sizes
+      while(len){
+         skips[0u] = 0u;
+         const size_type burst = len < BurstSize ? len : BurstSize;
+         size_type unique_burst = 0u;
+         const const_iterator cend(this->cend());
+         while(unique_burst < burst && len > 0){
+            //Get the insertion position for each key
+            const value_type & val = *first++;
+            --len;
+            pos = const_cast(*this).priv_lower_bound(pos, cend, KeyOfValue()(val));
+            //Check if already present
+            if(pos != cend && !value_comp(*pos, val)){
+               ++skips[unique_burst];
+               continue;
+            }
+
+            //If not present, calculate position
+            positions[unique_burst] = static_cast(pos - beg);
+            if(++unique_burst < burst)
+               skips[unique_burst] = 0u;
+         }
+         //Insert all in a single step in the precalculated positions
+         this->m_data.m_vect.insert_ordered_at(unique_burst, positions + unique_burst, skips + unique_burst, first);
+         //Next search position updated
+         pos += unique_burst;
+      }
+   }
+/*
    template 
    void priv_insert_equal_forward(ordered_range_t, FwdIt first, FwdIt last, std::forward_iterator_tag)
    {  this->priv_insert_equal(first, last, std::forward_iterator_tag());   }
-
+*/
    template 
    void priv_insert_equal(ordered_range_t, InIt first, InIt last, std::input_iterator_tag)
    {  this->priv_insert_equal(first, last, std::input_iterator_tag());  }
 
+   template 
+   void priv_insert_unique(ordered_unique_range_t, InIt first, InIt last, std::input_iterator_tag)
+   {  this->priv_insert_unique(first, last, std::input_iterator_tag());  }
+/*
    template 
    void priv_insert_equal_forward(FwdIt first, FwdIt last, std::forward_iterator_tag)
    {
@@ -830,7 +892,7 @@ class flat_tree
       this->reserve(this->size()+len);
       this->priv_insert_equal(first, last, std::input_iterator_tag());
    }
-
+*/
    template 
    void priv_insert_equal(InIt first, InIt last, std::input_iterator_tag)
    {
@@ -839,59 +901,59 @@ class flat_tree
    }
 };
 
-template 
-inline bool 
-operator==(const flat_tree& x, 
+inline bool
+operator==(const flat_tree& x,
            const flat_tree& y)
 {
   return x.size() == y.size() &&
          std::equal(x.begin(), x.end(), y.begin());
 }
 
-template 
-inline bool 
-operator<(const flat_tree& x, 
+inline bool
+operator<(const flat_tree& x,
           const flat_tree& y)
 {
-  return std::lexicographical_compare(x.begin(), x.end(), 
+  return std::lexicographical_compare(x.begin(), x.end(),
                                       y.begin(), y.end());
 }
 
-template 
-inline bool 
-operator!=(const flat_tree& x, 
-           const flat_tree& y) 
+inline bool
+operator!=(const flat_tree& x,
+           const flat_tree& y)
    {  return !(x == y); }
 
-template 
-inline bool 
-operator>(const flat_tree& x, 
-          const flat_tree& y) 
+inline bool
+operator>(const flat_tree& x,
+          const flat_tree& y)
    {  return y < x;  }
 
-template 
-inline bool 
-operator<=(const flat_tree& x, 
-           const flat_tree& y) 
+inline bool
+operator<=(const flat_tree& x,
+           const flat_tree& y)
    {  return !(y < x);  }
 
-template 
-inline bool 
-operator>=(const flat_tree& x, 
-           const flat_tree& y) 
+inline bool
+operator>=(const flat_tree& x,
+           const flat_tree& y)
    {  return !(x < y);  }
 
 
-template 
-inline void 
-swap(flat_tree& x, 
+inline void
+swap(flat_tree& x,
      flat_tree& y)
    {  x.swap(y);  }
 
@@ -901,7 +963,7 @@ swap(flat_tree& x,
 /*
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
-template 
 struct has_trivial_destructor_after_move >
 {
diff --git a/include/boost/container/detail/function_detector.hpp b/include/boost/container/detail/function_detector.hpp
index c30ed81..5a5f6fd 100644
--- a/include/boost/container/detail/function_detector.hpp
+++ b/include/boost/container/detail/function_detector.hpp
@@ -15,7 +15,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Copyright 2007 Alexandre Courpron
 //
-// Permission to use, copy, modify, redistribute and sell this software, 
+// Permission to use, copy, modify, redistribute and sell this software,
 // provided that this copyright notice appears on all copies of the software.
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -74,7 +74,7 @@ namespace function_detector {
    public : \
       static const int check = NotFound + (sizeof(Test(0, 0)) - sizeof(NotFoundType));\
    };\
-}}} //namespace boost::container::function_detector { 
+}}} //namespace boost::container::function_detector {
 
 #define BOOST_CONTAINER_DETECT_FUNCTION(Class, InstantiationKey, ReturnType, Identifier, Params) \
     ::boost::container::function_detector::DetectMember_##InstantiationKey_##Identifier< Class,\
diff --git a/include/boost/container/detail/iterators.hpp b/include/boost/container/detail/iterators.hpp
index 53a3ef5..374b55c 100644
--- a/include/boost/container/detail/iterators.hpp
+++ b/include/boost/container/detail/iterators.hpp
@@ -33,7 +33,7 @@
 #include 
 
 namespace boost {
-namespace container { 
+namespace container {
 
 template 
 class constant_iterator
@@ -50,9 +50,9 @@ class constant_iterator
    constant_iterator()
       :  m_ptr(0), m_num(0){}
 
-   constant_iterator& operator++() 
+   constant_iterator& operator++()
    { increment();   return *this;   }
-   
+  
    constant_iterator operator++(int)
    {
       constant_iterator result (*this);
@@ -60,9 +60,9 @@ class constant_iterator
       return result;
    }
 
-   constant_iterator& operator--() 
+   constant_iterator& operator--()
    { decrement();   return *this;   }
-   
+  
    constant_iterator operator--(int)
    {
       constant_iterator result (*this);
@@ -161,9 +161,9 @@ class default_construct_iterator
    default_construct_iterator()
       :  m_num(0){}
 
-   default_construct_iterator& operator++() 
+   default_construct_iterator& operator++()
    { increment();   return *this;   }
-   
+  
    default_construct_iterator operator++(int)
    {
       default_construct_iterator result (*this);
@@ -171,9 +171,9 @@ class default_construct_iterator
       return result;
    }
 
-   default_construct_iterator& operator--() 
+   default_construct_iterator& operator--()
    { decrement();   return *this;   }
-   
+  
    default_construct_iterator operator--(int)
    {
       default_construct_iterator result (*this);
@@ -247,7 +247,7 @@ class default_construct_iterator
    {  return other.m_num < m_num;   }
 
    const T & dereference() const
-   { 
+   {
       static T dummy;
       return dummy;
    }
@@ -273,9 +273,9 @@ class repeat_iterator
    repeat_iterator()
       :  m_ptr(0), m_num(0){}
 
-   this_type& operator++() 
+   this_type& operator++()
    { increment();   return *this;   }
-   
+  
    this_type operator++(int)
    {
       this_type result (*this);
@@ -283,9 +283,9 @@ class repeat_iterator
       return result;
    }
 
-   this_type& operator--() 
+   this_type& operator--()
    { increment();   return *this;   }
-   
+  
    this_type operator--(int)
    {
       this_type result (*this);
@@ -384,9 +384,9 @@ class emplace_iterator
    emplace_iterator()
       :  m_num(0), m_pe(0){}
 
-   this_type& operator++() 
+   this_type& operator++()
    { increment();   return *this;   }
-   
+  
    this_type operator++(int)
    {
       this_type result (*this);
@@ -394,9 +394,9 @@ class emplace_iterator
       return result;
    }
 
-   this_type& operator--() 
+   this_type& operator--()
    { decrement();   return *this;   }
-   
+  
    this_type operator--(int)
    {
       this_type result (*this);
@@ -475,7 +475,7 @@ class emplace_iterator
    {  return other.m_num < m_num;   }
 
    const T & dereference() const
-   { 
+   {
       static T dummy;
       return dummy;
    }
@@ -539,7 +539,7 @@ struct emplace_functor
 
 #endif
 
-}  //namespace container { 
+}  //namespace container {
 }  //namespace boost {
 
 #include 
diff --git a/include/boost/container/detail/math_functions.hpp b/include/boost/container/detail/math_functions.hpp
index 609e1d4..fe8386b 100644
--- a/include/boost/container/detail/math_functions.hpp
+++ b/include/boost/container/detail/math_functions.hpp
@@ -4,7 +4,7 @@
 // (C) Copyright Ion Gaztanaga 2007-2012.
 //
 // Distributed under the Boost Software License, Version 1.0.
-//    (See accompanying file LICENSE_1_0.txt or copy at 
+//    (See accompanying file LICENSE_1_0.txt or copy at
 //    http://www.boost.org/LICENSE_1_0.txt)
 //
 // See http://www.boost.org/libs/container for documentation.
@@ -94,7 +94,7 @@ inline std::size_t floor_log2 (std::size_t x)
 
    std::size_t n = x;
    std::size_t log2 = 0;
-   
+  
    for(std::size_t shift = Bits >> 1; shift; shift >>= 1){
       std::size_t tmp = n >> shift;
       if (tmp)
diff --git a/include/boost/container/detail/mpl.hpp b/include/boost/container/detail/mpl.hpp
index 032110a..74a1ce0 100644
--- a/include/boost/container/detail/mpl.hpp
+++ b/include/boost/container/detail/mpl.hpp
@@ -20,7 +20,7 @@
 #include 
 
 namespace boost {
-namespace container { 
+namespace container {
 namespace container_detail {
 
 template 
@@ -109,24 +109,24 @@ struct if_
 
 
 template 
-struct select1st 
-//   : public std::unary_function 
+struct select1st
+//   : public std::unary_function
 {
    template
-   const typename Pair::first_type& operator()(const OtherPair& x) const 
+   const typename Pair::first_type& operator()(const OtherPair& x) const
    {  return x.first;   }
 
-   const typename Pair::first_type& operator()(const typename Pair::first_type& x) const 
+   const typename Pair::first_type& operator()(const typename Pair::first_type& x) const
    {  return x;   }
 };
 
 // identity is an extension: it is not part of the standard.
 template 
-struct identity 
-//   : public std::unary_function 
+struct identity
+//   : public std::unary_function
 {
    typedef T type;
-   const T& operator()(const T& x) const 
+   const T& operator()(const T& x) const
    { return x; }
 };
 
@@ -152,8 +152,8 @@ template  struct unvoid { typedef T type; };
 template <> struct unvoid { struct type { }; };
 template <> struct unvoid { struct type { }; };
 
-}  //namespace container_detail { 
-}  //namespace container { 
+}  //namespace container_detail {
+}  //namespace container {
 }  //namespace boost {
 
 #endif   //#ifndef BOOST_CONTAINER_CONTAINER_DETAIL_MPL_HPP
diff --git a/include/boost/container/detail/node_alloc_holder.hpp b/include/boost/container/detail/node_alloc_holder.hpp
index 022a54f..9797f1f 100644
--- a/include/boost/container/detail/node_alloc_holder.hpp
+++ b/include/boost/container/detail/node_alloc_holder.hpp
@@ -189,11 +189,11 @@ struct node_alloc_holder
    public:
 
    //Constructors for sequence containers
-   node_alloc_holder() 
+   node_alloc_holder()
       : members_()
    {}
 
-   explicit node_alloc_holder(const ValAlloc &a) 
+   explicit node_alloc_holder(const ValAlloc &a)
       : members_(a)
    {}
 
@@ -206,7 +206,7 @@ struct node_alloc_holder
    {  this->icont().swap(x.icont());  }
 
    //Constructors for associative containers
-   explicit node_alloc_holder(const ValAlloc &a, const Pred &c) 
+   explicit node_alloc_holder(const ValAlloc &a, const Pred &c)
       : members_(a, c)
    {}
 
@@ -224,7 +224,7 @@ struct node_alloc_holder
    {  this->icont().swap(x.icont());  }
 
    void copy_assign_alloc(const node_alloc_holder &x)
-   {  
+   { 
       container_detail::bool_ flag;
       container_detail::assign_alloc( static_cast(this->members_)
                                     , static_cast(x.members_), flag);
diff --git a/include/boost/container/detail/node_pool_impl.hpp b/include/boost/container/detail/node_pool_impl.hpp
index b7fb511..63c1278 100644
--- a/include/boost/container/detail/node_pool_impl.hpp
+++ b/include/boost/container/detail/node_pool_impl.hpp
@@ -86,12 +86,12 @@ class private_node_pool_impl
 
    void *allocate_node()
    {  return priv_alloc_node();  }
-   
+  
    //!Deallocates an array pointed by ptr. Never throws
    void deallocate_node(void *ptr)
    {  priv_dealloc_node(ptr); }
 
-   //!Allocates a singly linked list of n nodes ending in null pointer. 
+   //!Allocates a singly linked list of n nodes ending in null pointer.
    multiallocation_chain allocate_nodes(const size_type n)
    {
       //Preallocate all needed blocks to fulfill the request
@@ -238,7 +238,7 @@ class private_node_pool_impl
       push_in_list(free_nodes_t &l, typename free_nodes_t::iterator &it)
          :  slist_(l), last_it_(it)
       {}
-      
+     
       void operator()(typename free_nodes_t::pointer p) const
       {
          slist_.push_front(*p);
@@ -258,10 +258,10 @@ class private_node_pool_impl
       is_between(const void *addr, std::size_t size)
          :  beg_(static_cast(addr)), end_(beg_+size)
       {}
-      
+     
       bool operator()(typename free_nodes_t::const_reference v) const
       {
-         return (beg_ <= reinterpret_cast(&v) && 
+         return (beg_ <= reinterpret_cast(&v) &&
                  end_ >  reinterpret_cast(&v));
       }
       private:
@@ -299,7 +299,7 @@ class private_node_pool_impl
    {
       if(!num_blocks)
          return;
-      size_type blocksize = 
+      size_type blocksize =
          get_rounded_size(m_real_node_size*m_nodes_per_block, (size_type)alignment_of::value);
 
       try{
@@ -311,7 +311,7 @@ class private_node_pool_impl
             char *pBlock = pNode;
             m_blocklist.push_front(get_block_hook(pBlock, blocksize));
 
-            //We initialize all Nodes in Node Block to insert 
+            //We initialize all Nodes in Node Block to insert
             //them in the free Node list
             for(size_type i = 0; i < m_nodes_per_block; ++i, pNode += m_real_node_size){
                m_freelist.push_front(*new (pNode) node_t);
@@ -335,13 +335,13 @@ class private_node_pool_impl
    private:
    //!Returns a reference to the block hook placed in the end of the block
    static node_t & get_block_hook (void *block, size_type blocksize)
-   {  
-      return *reinterpret_cast(reinterpret_cast(block) + blocksize);  
+   { 
+      return *reinterpret_cast(reinterpret_cast(block) + blocksize); 
    }
 
    //!Returns the starting address of the block reference to the block hook placed in the end of the block
    void *get_block_from_hook (node_t *hook, size_type blocksize)
-   {  
+   { 
       return (reinterpret_cast(hook) - blocksize);
    }
 
diff --git a/include/boost/container/detail/pair.hpp b/include/boost/container/detail/pair.hpp
index af32d6a..2a20ed1 100644
--- a/include/boost/container/detail/pair.hpp
+++ b/include/boost/container/detail/pair.hpp
@@ -35,7 +35,7 @@
 #endif
 
 namespace boost {
-namespace container { 
+namespace container {
 namespace container_detail {
 
 template 
@@ -313,8 +313,8 @@ inline void swap(pair& x, pair& y)
    swap(x.second, y.second);
 }
 
-}  //namespace container_detail { 
-}  //namespace container { 
+}  //namespace container_detail {
+}  //namespace container {
 
 
 //Without this specialization recursive flat_(multi)map instantiation fails
diff --git a/include/boost/container/detail/preprocessor.hpp b/include/boost/container/detail/preprocessor.hpp
index 051c17a..1818094 100644
--- a/include/boost/container/detail/preprocessor.hpp
+++ b/include/boost/container/detail/preprocessor.hpp
@@ -27,7 +27,7 @@
 //#error "This file is not needed when perfect forwarding is available"
 #endif   //BOOST_CONTAINER_PERFECT_FORWARDING
 
-#include  
+#include 
 #include 
 #include 
 #include 
diff --git a/include/boost/container/detail/transform_iterator.hpp b/include/boost/container/detail/transform_iterator.hpp
index bc558ba..98f5c04 100644
--- a/include/boost/container/detail/transform_iterator.hpp
+++ b/include/boost/container/detail/transform_iterator.hpp
@@ -24,7 +24,7 @@
 #include 
 
 namespace boost {
-namespace container { 
+namespace container {
 
 template 
 struct operator_arrow_proxy
@@ -74,7 +74,7 @@ class transform_iterator
    {}
 
    //Constructors
-   transform_iterator& operator++() 
+   transform_iterator& operator++()
    { increment();   return *this;   }
 
    transform_iterator operator++(int)
@@ -168,7 +168,7 @@ make_transform_iterator(Iterator it, UnaryFunc fun)
    return transform_iterator(it, fun);
 }
 
-}  //namespace container { 
+}  //namespace container {
 }  //namespace boost {
 
 #include 
diff --git a/include/boost/container/detail/tree.hpp b/include/boost/container/detail/tree.hpp
index 178c29d..50212ce 100644
--- a/include/boost/container/detail/tree.hpp
+++ b/include/boost/container/detail/tree.hpp
@@ -45,7 +45,7 @@ struct value_compare_impl
    :  public KeyCompare
 {
    typedef Value        value_type;
-   typedef KeyCompare   key_compare; 
+   typedef KeyCompare   key_compare;
    typedef KeyOfValue   key_of_value;
    typedef Key          key_type;
 
@@ -203,13 +203,13 @@ struct intrusive_rbtree_type
 
 namespace container_detail {
 
-template 
 class rbtree
    : protected container_detail::node_alloc_holder
       < A
       , typename container_detail::intrusive_rbtree_type
-           
+          
          >::type
       , KeyCompare
       >
@@ -218,7 +218,7 @@ class rbtree
          < A, value_compare_impl
             
          >::type                                            Icont;
-   typedef container_detail::node_alloc_holder  
+   typedef container_detail::node_alloc_holder 
                                       AllocHolder;
    typedef typename AllocHolder::NodePtr                    NodePtr;
    typedef rbtree < Key, Value, KeyOfValue
@@ -398,17 +398,17 @@ class rbtree
       {}
 
       //Pointer like operators
-      const_reference operator*()  const 
+      const_reference operator*()  const
       { return  m_it->get_data();  }
 
-      const_pointer   operator->() const 
+      const_pointer   operator->() const
       { return  const_pointer(&m_it->get_data()); }
 
       //Increment / Decrement
-      const_iterator& operator++()       
+      const_iterator& operator++()      
       { prot_incr();  return *this; }
 
-      const_iterator operator++(int)      
+      const_iterator operator++(int)     
       { iiterator tmp = m_it; ++*this; return const_iterator(tmp);  }
 
       const_iterator& operator--()
@@ -432,7 +432,7 @@ class rbtree
       explicit iterator(iiterator it)
          :  const_iterator(it)
       {}
-   
+  
       iiterator get()
       {  return this->m_it;   }
 
@@ -451,12 +451,12 @@ class rbtree
          {  return boost::intrusive::pointer_traits::pointer_to(this->m_it->get_data());  }
 
       //Increment / Decrement
-      iterator& operator++()  
+      iterator& operator++() 
          { this->prot_incr(); return *this;  }
 
       iterator operator++(int)
          { iiterator tmp = this->m_it; ++*this; return iterator(tmp); }
-      
+     
       iterator& operator--()
          {  this->prot_decr(); return *this;  }
 
@@ -493,18 +493,18 @@ class rbtree
       priv_create_and_insert_ordered_nodes(first, last, alloc_version(), ItCat());
    }
 
-   rbtree(const rbtree& x) 
+   rbtree(const rbtree& x)
       :  AllocHolder(x, x.key_comp())
    {
       this->icont().clone_from
          (x.icont(), typename AllocHolder::cloner(*this), Destroyer(this->node_alloc()));
    }
 
-   rbtree(BOOST_RV_REF(rbtree) x) 
+   rbtree(BOOST_RV_REF(rbtree) x)
       :  AllocHolder(::boost::move(static_cast(x)), x.key_comp())
    {}
 
-   rbtree(const rbtree& x, const allocator_type &a) 
+   rbtree(const rbtree& x, const allocator_type &a)
       :  AllocHolder(a, x.key_comp())
    {
       this->icont().clone_from
@@ -593,18 +593,18 @@ class rbtree
       return *this;
    }
 
-   public:    
+   public:   
    // accessors:
-   value_compare value_comp() const 
+   value_compare value_comp() const
    {  return this->icont().value_comp().value_comp(); }
 
-   key_compare key_comp() const 
+   key_compare key_comp() const
    {  return this->icont().value_comp().value_comp().key_comp(); }
 
-   allocator_type get_allocator() const 
+   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()
@@ -635,46 +635,46 @@ class rbtree
    {  return this->crend();   }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cbegin() const 
+   const_iterator cbegin() const
    { return const_iterator(this->non_const_icont().begin()); }
 
    //! Effects: Returns a const_iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cend() const 
+   const_iterator cend() const
    { return const_iterator(this->non_const_icont().end()); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin() const 
-   { return const_reverse_iterator(cend()); } 
+   const_reverse_iterator crbegin() const
+   { return const_reverse_iterator(cend()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crend() const 
+   const_reverse_iterator crend() const
    { return const_reverse_iterator(cbegin()); }
 
-   bool empty() const 
+   bool empty() const
    {  return !this->size();  }
 
-   size_type size() const 
+   size_type size() const
    {  return this->icont().size();   }
 
-   size_type max_size() const 
+   size_type max_size() const
    {  return AllocHolder::max_size();  }
 
    void swap(ThisType& x)
@@ -688,7 +688,7 @@ class rbtree
    std::pair insert_unique_check
       (const key_type& key, insert_commit_data &data)
    {
-      std::pair ret = 
+      std::pair ret =
          this->icont().insert_unique_check(key, KeyNodeCompare(value_comp()), data);
       return std::pair(iterator(ret.first), ret.second);
    }
@@ -696,7 +696,7 @@ class rbtree
    std::pair insert_unique_check
       (const_iterator hint, const key_type& key, insert_commit_data &data)
    {
-      std::pair ret = 
+      std::pair ret =
          this->icont().insert_unique_check(hint.get(), key, KeyNodeCompare(value_comp()), data);
       return std::pair(iterator(ret.first), ret.second);
    }
@@ -915,7 +915,7 @@ class rbtree
    iterator erase(const_iterator first, const_iterator last)
    {  return iterator(AllocHolder::erase_range(first.get(), last.get(), alloc_version())); }
 
-   void clear() 
+   void clear()
    {  AllocHolder::clear(alloc_version());  }
 
    // set operations:
@@ -941,14 +941,14 @@ class rbtree
    {  return const_iterator(this->non_const_icont().upper_bound(k, KeyNodeCompare(value_comp())));  }
 
    std::pair equal_range(const key_type& k)
-   {  
+   { 
       std::pair ret =
          this->icont().equal_range(k, KeyNodeCompare(value_comp()));
       return std::pair(iterator(ret.first), iterator(ret.second));
    }
 
    std::pair equal_range(const key_type& k) const
-   {  
+   { 
       std::pair ret =
          this->non_const_icont().equal_range(k, KeyNodeCompare(value_comp()));
       return std::pair
@@ -1060,63 +1060,63 @@ class rbtree
    }
 };
 
-template 
-inline bool 
-operator==(const rbtree& x, 
+inline bool
+operator==(const rbtree& x,
            const rbtree& y)
 {
   return x.size() == y.size() &&
          std::equal(x.begin(), x.end(), y.begin());
 }
 
-template 
-inline bool 
-operator<(const rbtree& x, 
+inline bool
+operator<(const rbtree& x,
           const rbtree& y)
 {
-  return std::lexicographical_compare(x.begin(), x.end(), 
+  return std::lexicographical_compare(x.begin(), x.end(),
                                       y.begin(), y.end());
 }
 
-template 
-inline bool 
-operator!=(const rbtree& x, 
+inline bool
+operator!=(const rbtree& x,
            const rbtree& y) {
   return !(x == y);
 }
 
-template 
-inline bool 
-operator>(const rbtree& x, 
+inline bool
+operator>(const rbtree& x,
           const rbtree& y) {
   return y < x;
 }
 
-template 
-inline bool 
-operator<=(const rbtree& x, 
+inline bool
+operator<=(const rbtree& x,
            const rbtree& y) {
   return !(y < x);
 }
 
-template 
-inline bool 
-operator>=(const rbtree& x, 
+inline bool
+operator>=(const rbtree& x,
            const rbtree& y) {
   return !(x < y);
 }
 
 
-template 
-inline void 
-swap(rbtree& x, 
+inline void
+swap(rbtree& x,
      rbtree& y)
 {
   x.swap(y);
@@ -1127,7 +1127,7 @@ swap(rbtree& x,
 /*
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
-template 
 struct has_trivial_destructor_after_move
     >
diff --git a/include/boost/container/detail/type_traits.hpp b/include/boost/container/detail/type_traits.hpp
index 2940f72..0e096e5 100644
--- a/include/boost/container/detail/type_traits.hpp
+++ b/include/boost/container/detail/type_traits.hpp
@@ -24,7 +24,7 @@
 #include 
 
 namespace boost {
-namespace container { 
+namespace container {
 namespace container_detail {
 
 struct nat{};
@@ -202,7 +202,7 @@ struct remove_ref_const
 };
 
 } // namespace container_detail
-}  //namespace container { 
+}  //namespace container {
 }  //namespace boost {
 
 #include 
diff --git a/include/boost/container/detail/utilities.hpp b/include/boost/container/detail/utilities.hpp
index 57ce356..152b5e1 100644
--- a/include/boost/container/detail/utilities.hpp
+++ b/include/boost/container/detail/utilities.hpp
@@ -150,7 +150,7 @@ enum {
    && !::boost::is_fundamental<_TypeT>::value
 };
 
-}; 
+};
 */
 
 template
@@ -233,7 +233,7 @@ F uninitialized_copy_alloc(A &a, I f, I l, F r)
 template
     
+    typename T>
 void uninitialized_fill_alloc(A &a, F f, F l, const T &t)
 {
    while (f != l) {
diff --git a/include/boost/container/detail/value_init.hpp b/include/boost/container/detail/value_init.hpp
index f164d21..ec1a99c 100644
--- a/include/boost/container/detail/value_init.hpp
+++ b/include/boost/container/detail/value_init.hpp
@@ -21,7 +21,7 @@
 #include 
 
 namespace boost {
-namespace container { 
+namespace container {
 namespace container_detail {
 
 template
@@ -36,8 +36,8 @@ struct value_init
    T m_t;
 };
 
-}  //namespace container_detail { 
-}  //namespace container { 
+}  //namespace container_detail {
+}  //namespace container {
 }  //namespace boost {
 
 #include 
diff --git a/include/boost/container/detail/variadic_templates_tools.hpp b/include/boost/container/detail/variadic_templates_tools.hpp
index e24a2e0..d903dfa 100644
--- a/include/boost/container/detail/variadic_templates_tools.hpp
+++ b/include/boost/container/detail/variadic_templates_tools.hpp
@@ -21,7 +21,7 @@
 #include    //std::size_t
 
 namespace boost {
-namespace container { 
+namespace container {
 namespace container_detail {
 
 template
@@ -136,7 +136,7 @@ struct index_tuple{};
 template >
 struct build_number_seq;
 
-template 
+template
 struct build_number_seq >
    : build_number_seq >
 {};
diff --git a/include/boost/container/detail/version_type.hpp b/include/boost/container/detail/version_type.hpp
index aac704f..e47ba26 100644
--- a/include/boost/container/detail/version_type.hpp
+++ b/include/boost/container/detail/version_type.hpp
@@ -38,7 +38,7 @@ struct version_type
 
 namespace impl{
 
-template , typename T::version>::value>
 struct extract_version
 {
diff --git a/include/boost/container/flat_map.hpp b/include/boost/container/flat_map.hpp
index 28ef1d6..18a3c5e 100644
--- a/include/boost/container/flat_map.hpp
+++ b/include/boost/container/flat_map.hpp
@@ -47,11 +47,11 @@ template 
 class flat_map;
 
 template 
-inline bool operator==(const flat_map& x, 
+inline bool operator==(const flat_map& x,
                        const flat_map& y);
 
 template 
-inline bool operator<(const flat_map& x, 
+inline bool operator<(const flat_map& x,
                       const flat_map& y);
 
 namespace container_detail{
@@ -73,12 +73,12 @@ static D force_copy(S s)
 /// @endcond
 
 //! A flat_map is a kind of associative container that supports unique keys (contains at
-//! most one of each key value) and provides for fast retrieval of values of another 
+//! most one of each key value) and provides for fast retrieval of values of another
 //! type T based on the keys. The flat_map class supports random-access iterators.
-//! 
-//! A flat_map satisfies all of the requirements of a container and of a reversible 
-//! container and of an associative container. A flat_map also provides 
-//! most operations described for unique keys. For a 
+//!
+//! A flat_map satisfies all of the requirements of a container and of a reversible
+//! container and of an associative container. A flat_map also provides
+//! most operations described for unique keys. For a
 //! flat_map the key_type is Key and the value_type is std::pair
 //! (unlike std::map which value_type is std::pair<const Key, T>).
 //!
@@ -86,35 +86,35 @@ static D force_copy(S s)
 //!
 //! A is the allocator to allocate the value_types
 //! (e.g. allocator< std::pair >).
-//! 
+//!
 //! flat_map is similar to std::map but it's implemented like an ordered vector.
 //! This means that inserting a new element into a flat_map invalidates
 //! previous iterators and references
 //!
-//! Erasing an element of a flat_map invalidates iterators and references 
+//! Erasing an element of a flat_map invalidates iterators and references
 //! pointing to elements that come after (their keys are bigger) the erased element.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
 template  >, class A = std::allocator >
 #else
 template 
 #endif
-class flat_map 
+class flat_map
 {
    /// @cond
    private:
    BOOST_COPYABLE_AND_MOVABLE(flat_map)
    //This is the tree that we should store if pair was movable
-   typedef container_detail::flat_tree, 
-                           container_detail::select1st< std::pair >, 
-                           Pred, 
+   typedef container_detail::flat_tree,
+                           container_detail::select1st< std::pair >,
+                           Pred,
                            A> tree_t;
 
    //This is the real tree stored here. It's based on a movable pair
-   typedef container_detail::flat_tree, 
-                           container_detail::select1st >, 
-                           Pred, 
+   typedef container_detail::flat_tree,
+                           container_detail::select1st >,
+                           Pred,
                            typename allocator_traits::template portable_rebind_alloc
                                >::type> impl_tree_t;
    impl_tree_t m_flat_tree;  // flat tree representing flat_map
@@ -165,7 +165,7 @@ class flat_map
       get_flat_tree_iterators
          ::const_reverse_iterator                  const_reverse_iterator;
    typedef A                                                allocator_type;
-   
+  
    //!Standard extension
    typedef A                                                stored_allocator_type;
 
@@ -174,61 +174,63 @@ class flat_map
 
    public:
    //! Effects: Default constructs an empty flat_map.
-   //! 
+   //!
    //! Complexity: Constant.
-   flat_map() 
+   flat_map()
       : m_flat_tree() {}
 
    //! Effects: Constructs an empty flat_map using the specified
    //! comparison object and allocator.
-   //! 
+   //!
    //! Complexity: Constant.
-   explicit flat_map(const Pred& comp, const allocator_type& a = allocator_type()) 
+   explicit flat_map(const Pred& comp, const allocator_type& a = allocator_type())
       : m_flat_tree(comp, container_detail::force(a)) {}
 
-   //! Effects: Constructs an empty flat_map using the specified comparison object and 
+   //! Effects: Constructs an empty flat_map using the specified comparison object and
    //! allocator, and inserts elements from the range [first ,last ).
-   //! 
-   //! Complexity: Linear in N if the range [first ,last ) is already sorted using 
+   //!
+   //! Complexity: Linear in N if the range [first ,last ) is already sorted using
    //! comp and otherwise N logN, where N is last - first.
    template 
    flat_map(InputIterator first, InputIterator last, const Pred& comp = Pred(),
          const allocator_type& a = allocator_type())
-      : m_flat_tree(comp, container_detail::force(a)) 
+      : m_flat_tree(comp, container_detail::force(a))
       { m_flat_tree.insert_unique(first, last); }
 
-   //! Effects: Constructs an empty flat_map using the specified comparison object and 
+   //! Effects: Constructs an empty flat_map using the specified comparison object and
    //! allocator, and inserts elements from the ordered unique range [first ,last). This function
    //! is more efficient than the normal range creation for ordered ranges.
    //!
    //! Requires: [first ,last) must be ordered according to the predicate and must be
    //! unique values.
-   //! 
+   //!
    //! Complexity: Linear in N.
+   //!
+   //! Note: Non-standard extension.
    template 
    flat_map( ordered_unique_range_t, InputIterator first, InputIterator last
            , const Pred& comp = Pred(), const allocator_type& a = allocator_type())
-      : m_flat_tree(ordered_range, first, last, comp, a) 
+      : m_flat_tree(ordered_range, first, last, comp, a)
    {}
 
    //! Effects: Copy constructs a flat_map.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
-   flat_map(const flat_map& x) 
+   flat_map(const flat_map& x)
       : m_flat_tree(x.m_flat_tree) {}
 
    //! Effects: Move constructs a flat_map.
    //!   Constructs *this using x's resources.
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Postcondition: x is emptied.
-   flat_map(BOOST_RV_REF(flat_map) x) 
+   flat_map(BOOST_RV_REF(flat_map) x)
       : m_flat_tree(boost::move(x.m_flat_tree))
    {}
 
    //! Effects: Copy constructs a flat_map using the specified allocator.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
    flat_map(const flat_map& x, const allocator_type &a)
       : m_flat_tree(x.m_flat_tree, a)
@@ -236,194 +238,194 @@ class flat_map
 
    //! Effects: Move constructs a flat_map using the specified allocator.
    //!   Constructs *this using x's resources.
-   //! 
+   //!
    //! Complexity: Constant if x.get_allocator() == a, linear otherwise.
-   flat_map(BOOST_RV_REF(flat_map) x, const allocator_type &a) 
+   flat_map(BOOST_RV_REF(flat_map) x, const allocator_type &a)
       : m_flat_tree(boost::move(x.m_flat_tree), a)
    {}
 
    //! Effects: Makes *this a copy of x.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
    flat_map& operator=(BOOST_COPY_ASSIGN_REF(flat_map) x)
    {  m_flat_tree = x.m_flat_tree;   return *this;  }
 
    //! Effects: Move constructs a flat_map.
    //!   Constructs *this using x's resources.
-   //! 
+   //!
    //! Complexity: Construct.
-   //! 
+   //!
    //! Postcondition: x is emptied.
    flat_map& operator=(BOOST_RV_REF(flat_map) mx)
    {  m_flat_tree = boost::move(mx.m_flat_tree);   return *this;  }
 
    //! Effects: Returns the comparison object out
    //!   of which a was constructed.
-   //! 
+   //!
    //! Complexity: Constant.
-   key_compare key_comp() const 
+   key_compare key_comp() const
       { return container_detail::force(m_flat_tree.key_comp()); }
 
    //! Effects: Returns an object of value_compare constructed out
    //!   of the comparison object.
-   //! 
+   //!
    //! Complexity: Constant.
-   value_compare value_comp() const 
+   value_compare value_comp() const
       { return value_compare(container_detail::force(m_flat_tree.key_comp())); }
 
    //! Effects: Returns a copy of the Allocator that
    //!   was passed to the object's constructor.
-   //! 
+   //!
    //! Complexity: Constant.
-   allocator_type get_allocator() const 
+   allocator_type get_allocator() const
       { return container_detail::force(m_flat_tree.get_allocator()); }
 
-   const stored_allocator_type &get_stored_allocator() const 
+   const stored_allocator_type &get_stored_allocator() const
       { return container_detail::force(m_flat_tree.get_stored_allocator()); }
 
    stored_allocator_type &get_stored_allocator()
       { return container_detail::force(m_flat_tree.get_stored_allocator()); }
 
    //! Effects: Returns an iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   iterator begin() 
+   iterator begin()
       { return container_detail::force_copy(m_flat_tree.begin()); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator begin() const 
+   const_iterator begin() const
       { return container_detail::force(m_flat_tree.begin()); }
 
    //! Effects: Returns an iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   iterator end() 
+   iterator end()
       { return container_detail::force_copy(m_flat_tree.end()); }
 
    //! Effects: Returns a const_iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator end() const 
+   const_iterator end() const
       { return container_detail::force(m_flat_tree.end()); }
 
-   //! Effects: Returns a reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reverse_iterator rbegin() 
+   reverse_iterator rbegin()
       { return container_detail::force(m_flat_tree.rbegin()); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator rbegin() const 
+   const_reverse_iterator rbegin() const
       { return container_detail::force(m_flat_tree.rbegin()); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reverse_iterator rend() 
+   reverse_iterator rend()
       { return container_detail::force(m_flat_tree.rend()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator rend() const 
+   const_reverse_iterator rend() const
       { return container_detail::force(m_flat_tree.rend()); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cbegin() const 
+   const_iterator cbegin() const
       { return container_detail::force(m_flat_tree.cbegin()); }
 
    //! Effects: Returns a const_iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cend() const 
+   const_iterator cend() const
       { return container_detail::force(m_flat_tree.cend()); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin() const 
+   const_reverse_iterator crbegin() const
       { return container_detail::force(m_flat_tree.crbegin()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crend() const 
+   const_reverse_iterator crend() const
       { return container_detail::force(m_flat_tree.crend()); }
 
    //! Effects: Returns true if the container contains no elements.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   bool empty() const 
+   bool empty() const
       { return m_flat_tree.empty(); }
 
    //! Effects: Returns the number of the elements contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type size() const 
+   size_type size() const
       { return m_flat_tree.size(); }
 
    //! Effects: Returns the largest possible size of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type max_size() const 
+   size_type max_size() const
       { return m_flat_tree.max_size(); }
 
    #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   //! Effects: If there is no key equivalent to x in the flat_map, inserts 
+   //! Effects: If there is no key equivalent to x in the flat_map, inserts
    //!   value_type(x, T()) into the flat_map.
-   //! 
+   //!
    //! Returns: A reference to the mapped_type corresponding to x in *this.
-   //! 
+   //!
    //! Complexity: Logarithmic.
    mapped_type &operator[](const key_type& k);
 
-   //! Effects: If there is no key equivalent to x in the flat_map, inserts 
+   //! Effects: If there is no key equivalent to x in the flat_map, inserts
    //! value_type(move(x), T()) into the flat_map (the key is move-constructed)
-   //! 
+   //!
    //! Returns: A reference to the mapped_type corresponding to x in *this.
-   //! 
+   //!
    //! Complexity: Logarithmic.
    mapped_type &operator[](key_type &&k) ;
 
@@ -463,10 +465,10 @@ class flat_map
    void swap(flat_map& x)
    { m_flat_tree.swap(x.m_flat_tree); }
 
-   //! Effects: Inserts x if and only if there is no element in the container 
+   //! Effects: Inserts x if and only if there is no element in the container
    //!   with key equivalent to the key of x.
    //!
-   //! Returns: The bool component of the returned pair is true if and only 
+   //! Returns: The bool component of the returned pair is true if and only
    //!   if the insertion takes place, and the iterator component of the pair
    //!   points to the element with key equivalent to the key of x.
    //!
@@ -474,14 +476,14 @@ class flat_map
    //!   to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   std::pair insert(const value_type& x) 
+   std::pair insert(const value_type& x)
       { return container_detail::force >(
          m_flat_tree.insert_unique(container_detail::force(x))); }
 
    //! Effects: Inserts a new value_type move constructed from the pair if and
    //! only if there is no element in the container with key equivalent to the key of x.
    //!
-   //! Returns: The bool component of the returned pair is true if and only 
+   //! Returns: The bool component of the returned pair is true if and only
    //!   if the insertion takes place, and the iterator component of the pair
    //!   points to the element with key equivalent to the key of x.
    //!
@@ -489,14 +491,14 @@ class flat_map
    //!   to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   std::pair insert(BOOST_RV_REF(value_type) x) 
+   std::pair insert(BOOST_RV_REF(value_type) x)
    {  return container_detail::force >(
       m_flat_tree.insert_unique(boost::move(container_detail::force(x)))); }
 
    //! Effects: Inserts a new value_type move constructed from the pair if and
    //! only if there is no element in the container with key equivalent to the key of x.
    //!
-   //! Returns: The bool component of the returned pair is true if and only 
+   //! Returns: The bool component of the returned pair is true if and only
    //!   if the insertion takes place, and the iterator component of the pair
    //!   points to the element with key equivalent to the key of x.
    //!
@@ -504,13 +506,13 @@ class flat_map
    //!   to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   std::pair insert(BOOST_RV_REF(movable_value_type) x) 
+   std::pair insert(BOOST_RV_REF(movable_value_type) x)
    {
       return container_detail::force >
       (m_flat_tree.insert_unique(boost::move(x)));
    }
 
-   //! Effects: Inserts a copy of x in the container if and only if there is 
+   //! Effects: Inserts a copy of x in the container if and only if there is
    //!   no element in the container with key equivalent to the key of x.
    //!   p is a hint pointing to where the insert should start to search.
    //!
@@ -558,7 +560,7 @@ class flat_map
 
    //! Requires: first, last are not iterators into *this.
    //!
-   //! Effects: inserts each element from the range [first,last) if and only 
+   //! Effects: inserts each element from the range [first,last) if and only
    //!   if there is no element with key equivalent to the key of that element.
    //!
    //! Complexity: At most N log(size()+N) (N is the distance from first to last)
@@ -566,16 +568,33 @@ class flat_map
    //!
    //! Note: If an element is inserted it might invalidate elements.
    template 
-   void insert(InputIterator first, InputIterator last) 
+   void insert(InputIterator first, InputIterator last)
    {  m_flat_tree.insert_unique(first, last);  }
 
+   //! Requires: first, last are not iterators into *this.
+   //!
+   //! Requires: [first ,last) must be ordered according to the predicate and must be
+   //! unique values.
+   //!
+   //! Effects: inserts each element from the range [first,last) if and only
+   //!   if there is no element with key equivalent to the key of that element. This
+   //!   function is more efficient than the normal range creation for ordered ranges.
+   //!
+   //! Complexity: At most N log(size()+N) (N is the distance from first to last)
+   //!   search time plus N*size() insertion time.
+   //!
+   //! Note: If an element is inserted it might invalidate elements.
+   template 
+   void insert(ordered_unique_range_t, InputIterator first, InputIterator last)
+      {  m_flat_tree.insert_unique(ordered_unique_range, first, last); }
+
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
    //! Effects: Inserts an object x of type T constructed with
-   //!   std::forward(args)... if and only if there is no element in the container 
+   //!   std::forward(args)... if and only if there is no element in the container
    //!   with key equivalent to the key of x.
    //!
-   //! Returns: The bool component of the returned pair is true if and only 
+   //! Returns: The bool component of the returned pair is true if and only
    //!   if the insertion takes place, and the iterator component of the pair
    //!   points to the element with key equivalent to the key of x.
    //!
@@ -588,7 +607,7 @@ class flat_map
    {  return container_detail::force_copy< std::pair >(m_flat_tree.emplace_unique(boost::forward(args)...)); }
 
    //! Effects: Inserts an object of type T constructed with
-   //!   std::forward(args)... in the container if and only if there is 
+   //!   std::forward(args)... in the container if and only if there is
    //!   no element in the container with key equivalent to the key of x.
    //!   p is a hint pointing to where the insert should start to search.
    //!
@@ -627,14 +646,14 @@ class flat_map
    //! Effects: Erases the element pointed to by position.
    //!
    //! Returns: Returns an iterator pointing to the element immediately
-   //!   following q prior to the element being erased. If no such element exists, 
+   //!   following q prior to the element being erased. If no such element exists,
    //!   returns end().
    //!
    //! Complexity: Linear to the elements with keys bigger than position
    //!
    //! Note: Invalidates elements with keys
    //!   not less than the erased element.
-   iterator erase(const_iterator position) 
+   iterator erase(const_iterator position)
       { return container_detail::force_copy(m_flat_tree.erase(container_detail::force(position))); }
 
    //! Effects: Erases all elements in the container with key equivalent to x.
@@ -643,7 +662,7 @@ class flat_map
    //!
    //! Complexity: Logarithmic search time plus erasure time
    //!   linear to the elements with bigger keys.
-   size_type erase(const key_type& x) 
+   size_type erase(const key_type& x)
       { return m_flat_tree.erase(x); }
 
    //! Effects: Erases all the elements in the range [first, last).
@@ -663,7 +682,7 @@ class flat_map
    //! Postcondition: size() == 0.
    //!
    //! Complexity: linear in size().
-   void clear() 
+   void clear()
       { m_flat_tree.clear(); }
 
    //! Effects: Tries to deallocate the excess of memory created
@@ -679,81 +698,81 @@ class flat_map
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.
-   iterator find(const key_type& x) 
+   iterator find(const key_type& x)
       { return container_detail::force_copy(m_flat_tree.find(x)); }
 
    //! Returns: A const_iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.s
-   const_iterator find(const key_type& x) const 
+   const_iterator find(const key_type& x) const
       { return container_detail::force(m_flat_tree.find(x)); }
 
    //! Returns: The number of elements with key equivalent to x.
    //!
    //! Complexity: log(size())+count(k)
-   size_type count(const key_type& x) const 
+   size_type count(const key_type& x) const
       {  return m_flat_tree.find(x) == m_flat_tree.end() ? 0 : 1;  }
 
    //! Returns: An iterator pointing to the first element with key not less
    //!   than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   iterator lower_bound(const key_type& x) 
+   iterator lower_bound(const key_type& x)
       {  return container_detail::force_copy(m_flat_tree.lower_bound(x)); }
 
    //! Returns: A const iterator pointing to the first element with key not
    //!   less than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   const_iterator lower_bound(const key_type& x) const 
+   const_iterator lower_bound(const key_type& x) const
       {  return container_detail::force(m_flat_tree.lower_bound(x)); }
 
    //! Returns: An iterator pointing to the first element with key not less
    //!   than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   iterator upper_bound(const key_type& x) 
+   iterator upper_bound(const key_type& x)
       {  return container_detail::force_copy(m_flat_tree.upper_bound(x)); }
 
    //! Returns: A const iterator pointing to the first element with key not
    //!   less than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   const_iterator upper_bound(const key_type& x) const 
+   const_iterator upper_bound(const key_type& x) const
       {  return container_detail::force(m_flat_tree.upper_bound(x)); }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair equal_range(const key_type& x) 
+   std::pair equal_range(const key_type& x)
       {  return container_detail::force_copy >(m_flat_tree.equal_range(x)); }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair equal_range(const key_type& x) const 
+   std::pair equal_range(const key_type& x) const
       {  return container_detail::force_copy >(m_flat_tree.equal_range(x)); }
 
    //! Effects: Number of elements for which memory has been allocated.
    //!   capacity() is always greater than or equal to size().
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type capacity() const           
+   size_type capacity() const          
       { return m_flat_tree.capacity(); }
 
    //! Effects: If n is less than or equal to capacity(), this call has no
    //!   effect. Otherwise, it is a request for allocation of additional memory.
    //!   If the request is successful, then capacity() is greater than or equal to
    //!   n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
-   //! 
+   //!
    //! Throws: If memory allocation allocation throws or T's copy constructor throws.
    //!
    //! Note: If capacity() is less than "count", iterators and references to
    //!   to values might be invalidated.
-   void reserve(size_type count)       
+   void reserve(size_type count)      
       { m_flat_tree.reserve(count);   }
 
    /// @cond
@@ -775,7 +794,7 @@ class flat_map
       }
       return (*i).second;
    }
-   mapped_type &priv_subscript(BOOST_RV_REF(key_type) mk) 
+   mapped_type &priv_subscript(BOOST_RV_REF(key_type) mk)
    {
       key_type &k = mk;
       iterator i = lower_bound(k);
@@ -790,38 +809,38 @@ class flat_map
 };
 
 template 
-inline bool operator==(const flat_map& x, 
-                       const flat_map& y) 
+inline bool operator==(const flat_map& x,
+                       const flat_map& y)
    {  return x.m_flat_tree == y.m_flat_tree;  }
 
 template 
-inline bool operator<(const flat_map& x, 
-                      const flat_map& y) 
+inline bool operator<(const flat_map& x,
+                      const flat_map& y)
    {  return x.m_flat_tree < y.m_flat_tree;   }
 
 template 
-inline bool operator!=(const flat_map& x, 
-                       const flat_map& y) 
+inline bool operator!=(const flat_map& x,
+                       const flat_map& y)
    {  return !(x == y); }
 
 template 
-inline bool operator>(const flat_map& x, 
-                      const flat_map& y) 
+inline bool operator>(const flat_map& x,
+                      const flat_map& y)
    {  return y < x;  }
 
 template 
-inline bool operator<=(const flat_map& x, 
-                       const flat_map& y) 
+inline bool operator<=(const flat_map& x,
+                       const flat_map& y)
    {  return !(y < x);  }
 
 template 
-inline bool operator>=(const flat_map& x, 
-                       const flat_map& y) 
+inline bool operator>=(const flat_map& x,
+                       const flat_map& y)
    {  return !(x < y);  }
 
 template 
-inline void swap(flat_map& x, 
-                 flat_map& y) 
+inline void swap(flat_map& x,
+                 flat_map& y)
    {  x.swap(y);  }
 
 /// @cond
@@ -847,21 +866,21 @@ template 
 class flat_multimap;
 
 template 
-inline bool operator==(const flat_multimap& x, 
+inline bool operator==(const flat_multimap& x,
                        const flat_multimap& y);
 
 template 
-inline bool operator<(const flat_multimap& x, 
+inline bool operator<(const flat_multimap& x,
                       const flat_multimap& y);
 /// @endcond
 
-//! A flat_multimap is a kind of associative container that supports equivalent keys 
-//! (possibly containing multiple copies of the same key value) and provides for 
-//! fast retrieval of values of another type T based on the keys. The flat_multimap 
+//! A flat_multimap is a kind of associative container that supports equivalent keys
+//! (possibly containing multiple copies of the same key value) and provides for
+//! fast retrieval of values of another type T based on the keys. The flat_multimap
 //! class supports random-access iterators.
-//! 
-//! A flat_multimap satisfies all of the requirements of a container and of a reversible 
-//! container and of an associative container. For a 
+//!
+//! A flat_multimap satisfies all of the requirements of a container and of a reversible
+//! container and of an associative container. For a
 //! flat_multimap the key_type is Key and the value_type is std::pair
 //! (unlike std::multimap which value_type is std::pair<const Key, T>).
 //!
@@ -874,21 +893,21 @@ template  >, clas
 #else
 template 
 #endif
-class flat_multimap 
+class flat_multimap
 {
    /// @cond
    private:
    BOOST_COPYABLE_AND_MOVABLE(flat_multimap)
-   typedef container_detail::flat_tree, 
-                           container_detail::select1st< std::pair >, 
-                           Pred, 
+   typedef container_detail::flat_tree,
+                           container_detail::select1st< std::pair >,
+                           Pred,
                            A> tree_t;
    //This is the real tree stored here. It's based on a movable pair
-   typedef container_detail::flat_tree, 
-                           container_detail::select1st >, 
-                           Pred, 
+   typedef container_detail::flat_tree,
+                           container_detail::select1st >,
+                           Pred,
                            typename allocator_traits::template portable_rebind_alloc
                                >::type> impl_tree_t;
    impl_tree_t m_flat_tree;  // flat tree representing flat_map
@@ -943,14 +962,14 @@ class flat_multimap
    typedef impl_value_type                                  movable_value_type;
 
    //! Effects: Default constructs an empty flat_map.
-   //! 
+   //!
    //! Complexity: Constant.
-   flat_multimap() 
+   flat_multimap()
       : m_flat_tree() {}
 
    //! Effects: Constructs an empty flat_multimap using the specified comparison
    //!   object and allocator.
-   //! 
+   //!
    //! Complexity: Constant.
    explicit flat_multimap(const Pred& comp,
                           const allocator_type& a = allocator_type())
@@ -958,49 +977,51 @@ class flat_multimap
 
    //! Effects: Constructs an empty flat_multimap using the specified comparison object
    //!   and allocator, and inserts elements from the range [first ,last ).
-   //! 
-   //! Complexity: Linear in N if the range [first ,last ) is already sorted using 
+   //!
+   //! Complexity: Linear in N if the range [first ,last ) is already sorted using
    //! comp and otherwise N logN, where N is last - first.
    template 
    flat_multimap(InputIterator first, InputIterator last,
             const Pred& comp        = Pred(),
             const allocator_type& a = allocator_type())
-      : m_flat_tree(comp, container_detail::force(a)) 
+      : m_flat_tree(comp, container_detail::force(a))
       { m_flat_tree.insert_equal(first, last); }
 
-   //! Effects: Constructs an empty flat_multimap using the specified comparison object and 
+   //! Effects: Constructs an empty flat_multimap using the specified comparison object and
    //! allocator, and inserts elements from the ordered range [first ,last). This function
    //! is more efficient than the normal range creation for ordered ranges.
    //!
    //! Requires: [first ,last) must be ordered according to the predicate.
-   //! 
+   //!
    //! Complexity: Linear in N.
+   //!
+   //! Note: Non-standard extension.
    template 
    flat_multimap(ordered_range_t, InputIterator first, InputIterator last,
             const Pred& comp        = Pred(),
             const allocator_type& a = allocator_type())
-      : m_flat_tree(ordered_range, first, last, comp, a) 
+      : m_flat_tree(ordered_range, first, last, comp, a)
    {}
 
    //! Effects: Copy constructs a flat_multimap.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
-   flat_multimap(const flat_multimap& x) 
+   flat_multimap(const flat_multimap& x)
       : m_flat_tree(x.m_flat_tree) { }
 
    //! Effects: Move constructs a flat_multimap. Constructs *this using x's resources.
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Postcondition: x is emptied.
-   flat_multimap(BOOST_RV_REF(flat_multimap) x) 
+   flat_multimap(BOOST_RV_REF(flat_multimap) x)
       : m_flat_tree(boost::move(x.m_flat_tree))
    { }
 
    //! Effects: Copy constructs a flat_multimap using the specified allocator.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
-   flat_multimap(const flat_multimap& x, const allocator_type &a) 
+   flat_multimap(const flat_multimap& x, const allocator_type &a)
       : m_flat_tree(x.m_flat_tree, a)
    {}
 
@@ -1008,173 +1029,173 @@ class flat_multimap
    //!                 Constructs *this using x's resources.
    //!
    //! Complexity: Constant if a == x.get_allocator(), linear otherwise.
-   flat_multimap(BOOST_RV_REF(flat_multimap) x, const allocator_type &a) 
+   flat_multimap(BOOST_RV_REF(flat_multimap) x, const allocator_type &a)
       : m_flat_tree(boost::move(x.m_flat_tree), a)
    { }
 
    //! Effects: Makes *this a copy of x.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
-   flat_multimap& operator=(BOOST_COPY_ASSIGN_REF(flat_multimap) x) 
+   flat_multimap& operator=(BOOST_COPY_ASSIGN_REF(flat_multimap) x)
       {  m_flat_tree = x.m_flat_tree;   return *this;  }
 
    //! Effects: this->swap(x.get()).
-   //! 
+   //!
    //! Complexity: Constant.
-   flat_multimap& operator=(BOOST_RV_REF(flat_multimap) mx) 
+   flat_multimap& operator=(BOOST_RV_REF(flat_multimap) mx)
       {  m_flat_tree = boost::move(mx.m_flat_tree);   return *this;  }
 
    //! Effects: Returns the comparison object out
    //!   of which a was constructed.
-   //! 
+   //!
    //! Complexity: Constant.
-   key_compare key_comp() const 
+   key_compare key_comp() const
       { return container_detail::force(m_flat_tree.key_comp()); }
 
    //! Effects: Returns an object of value_compare constructed out
    //!   of the comparison object.
-   //! 
+   //!
    //! Complexity: Constant.
-   value_compare value_comp() const 
+   value_compare value_comp() const
       { return value_compare(container_detail::force(m_flat_tree.key_comp())); }
 
    //! Effects: Returns a copy of the Allocator that
    //!   was passed to the object's constructor.
-   //! 
+   //!
    //! Complexity: Constant.
-   allocator_type get_allocator() const 
+   allocator_type get_allocator() const
       { return container_detail::force(m_flat_tree.get_allocator()); }
 
-   const stored_allocator_type &get_stored_allocator() const 
+   const stored_allocator_type &get_stored_allocator() const
       { return container_detail::force(m_flat_tree.get_stored_allocator()); }
 
    stored_allocator_type &get_stored_allocator()
       { return container_detail::force(m_flat_tree.get_stored_allocator()); }
 
    //! Effects: Returns an iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   iterator begin() 
+   iterator begin()
       { return container_detail::force_copy(m_flat_tree.begin()); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator begin() const 
+   const_iterator begin() const
       { return container_detail::force(m_flat_tree.begin()); }
 
    //! Effects: Returns an iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   iterator end() 
+   iterator end()
       { return container_detail::force_copy(m_flat_tree.end()); }
 
    //! Effects: Returns a const_iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator end() const 
+   const_iterator end() const
       { return container_detail::force(m_flat_tree.end()); }
 
-   //! Effects: Returns a reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reverse_iterator rbegin() 
+   reverse_iterator rbegin()
       { return container_detail::force(m_flat_tree.rbegin()); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator rbegin() const 
+   const_reverse_iterator rbegin() const
       { return container_detail::force(m_flat_tree.rbegin()); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reverse_iterator rend() 
+   reverse_iterator rend()
       { return container_detail::force(m_flat_tree.rend()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator rend() const 
+   const_reverse_iterator rend() const
       { return container_detail::force(m_flat_tree.rend()); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cbegin() const 
+   const_iterator cbegin() const
       { return container_detail::force(m_flat_tree.cbegin()); }
 
    //! Effects: Returns a const_iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cend() const 
+   const_iterator cend() const
       { return container_detail::force(m_flat_tree.cend()); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin() const 
+   const_reverse_iterator crbegin() const
       { return container_detail::force(m_flat_tree.crbegin()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crend() const 
+   const_reverse_iterator crend() const
       { return container_detail::force(m_flat_tree.crend()); }
 
    //! Effects: Returns true if the container contains no elements.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   bool empty() const 
+   bool empty() const
       { return m_flat_tree.empty(); }
 
    //! Effects: Returns the number of the elements contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type size() const 
+   size_type size() const
       { return m_flat_tree.size(); }
 
    //! Effects: Returns the largest possible size of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type max_size() const 
+   size_type max_size() const
       { return m_flat_tree.max_size(); }
 
    //! Effects: Swaps the contents of *this and x.
@@ -1186,33 +1207,33 @@ class flat_multimap
    { m_flat_tree.swap(x.m_flat_tree); }
 
    //! Effects: Inserts x and returns the iterator pointing to the
-   //!   newly inserted element. 
+   //!   newly inserted element.
    //!
    //! Complexity: Logarithmic search time plus linear insertion
    //!   to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(const value_type& x) 
+   iterator insert(const value_type& x)
       { return container_detail::force_copy(m_flat_tree.insert_equal(container_detail::force(x))); }
 
-   //! Effects: Inserts a new value move-constructed from x and returns 
-   //!   the iterator pointing to the newly inserted element. 
+   //! Effects: Inserts a new value move-constructed from x and returns
+   //!   the iterator pointing to the newly inserted element.
    //!
    //! Complexity: Logarithmic search time plus linear insertion
    //!   to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(BOOST_RV_REF(value_type) x) 
+   iterator insert(BOOST_RV_REF(value_type) x)
    { return container_detail::force_copy(m_flat_tree.insert_equal(boost::move(x))); }
 
-   //! Effects: Inserts a new value move-constructed from x and returns 
-   //!   the iterator pointing to the newly inserted element. 
+   //! Effects: Inserts a new value move-constructed from x and returns
+   //!   the iterator pointing to the newly inserted element.
    //!
    //! Complexity: Logarithmic search time plus linear insertion
    //!   to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(BOOST_RV_REF(impl_value_type) x) 
+   iterator insert(BOOST_RV_REF(impl_value_type) x)
       { return container_detail::force_copy(m_flat_tree.insert_equal(boost::move(x))); }
 
    //! Effects: Inserts a copy of x in the container.
@@ -1226,7 +1247,7 @@ class flat_multimap
    //!   to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(const_iterator position, const value_type& x) 
+   iterator insert(const_iterator position, const value_type& x)
       { return container_detail::force_copy
          (m_flat_tree.insert_equal(container_detail::force(position), container_detail::force(x))); }
 
@@ -1241,7 +1262,7 @@ class flat_multimap
    //!   to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(const_iterator position, BOOST_RV_REF(value_type) x) 
+   iterator insert(const_iterator position, BOOST_RV_REF(value_type) x)
    {
       return container_detail::force_copy
          (m_flat_tree.insert_equal(container_detail::force(position)
@@ -1259,7 +1280,7 @@ class flat_multimap
    //!   to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(const_iterator position, BOOST_RV_REF(impl_value_type) x) 
+   iterator insert(const_iterator position, BOOST_RV_REF(impl_value_type) x)
    {
       return container_detail::force_copy(
          m_flat_tree.insert_equal(container_detail::force(position), boost::move(x)));
@@ -1274,14 +1295,30 @@ class flat_multimap
    //!
    //! Note: If an element is inserted it might invalidate elements.
    template 
-   void insert(InputIterator first, InputIterator last) 
+   void insert(InputIterator first, InputIterator last)
       {  m_flat_tree.insert_equal(first, last); }
 
+   //! Requires: first, last are not iterators into *this.
+   //!
+   //! Requires: [first ,last) must be ordered according to the predicate.
+   //!
+   //! Effects: inserts each element from the range [first,last) if and only
+   //!   if there is no element with key equivalent to the key of that element. This
+   //!   function is more efficient than the normal range creation for ordered ranges.
+   //!
+   //! Complexity: At most N log(size()+N) (N is the distance from first to last)
+   //!   search time plus N*size() insertion time.
+   //!
+   //! Note: If an element is inserted it might invalidate elements.
+   template 
+   void insert(ordered_range_t, InputIterator first, InputIterator last)
+      {  m_flat_tree.insert_equal(ordered_range, first, last); }
+
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
    //! Effects: Inserts an object of type T constructed with
    //!   std::forward(args)... and returns the iterator pointing to the
-   //!   newly inserted element. 
+   //!   newly inserted element.
    //!
    //! Complexity: Logarithmic search time plus linear insertion
    //!   to the elements with bigger keys than x.
@@ -1333,14 +1370,14 @@ class flat_multimap
    //! Effects: Erases the element pointed to by position.
    //!
    //! Returns: Returns an iterator pointing to the element immediately
-   //!   following q prior to the element being erased. If no such element exists, 
+   //!   following q prior to the element being erased. If no such element exists,
    //!   returns end().
    //!
    //! Complexity: Linear to the elements with keys bigger than position
    //!
    //! Note: Invalidates elements with keys
    //!   not less than the erased element.
-   iterator erase(const_iterator position) 
+   iterator erase(const_iterator position)
       { return container_detail::force_copy(m_flat_tree.erase(container_detail::force(position))); }
 
    //! Effects: Erases all elements in the container with key equivalent to x.
@@ -1349,7 +1386,7 @@ class flat_multimap
    //!
    //! Complexity: Logarithmic search time plus erasure time
    //!   linear to the elements with bigger keys.
-   size_type erase(const key_type& x) 
+   size_type erase(const key_type& x)
       { return m_flat_tree.erase(x); }
 
    //! Effects: Erases all the elements in the range [first, last).
@@ -1369,7 +1406,7 @@ class flat_multimap
    //! Postcondition: size() == 0.
    //!
    //! Complexity: linear in size().
-   void clear() 
+   void clear()
       { m_flat_tree.clear(); }
 
    //! Effects: Tries to deallocate the excess of memory created
@@ -1392,75 +1429,75 @@ class flat_multimap
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.
-   const_iterator find(const key_type& x) const 
+   const_iterator find(const key_type& x) const
       { return container_detail::force(m_flat_tree.find(x)); }
 
    //! Returns: The number of elements with key equivalent to x.
    //!
    //! Complexity: log(size())+count(k)
-   size_type count(const key_type& x) const 
+   size_type count(const key_type& x) const
       { return m_flat_tree.count(x); }
 
    //! Returns: An iterator pointing to the first element with key not less
    //!   than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   iterator lower_bound(const key_type& x) 
+   iterator lower_bound(const key_type& x)
       {return container_detail::force_copy(m_flat_tree.lower_bound(x)); }
 
    //! Returns: A const iterator pointing to the first element with key
    //!   not less than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   const_iterator lower_bound(const key_type& x) const 
+   const_iterator lower_bound(const key_type& x) const
       {  return container_detail::force(m_flat_tree.lower_bound(x));  }
 
    //! Returns: An iterator pointing to the first element with key not less
    //!   than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   iterator upper_bound(const key_type& x) 
+   iterator upper_bound(const key_type& x)
       {return container_detail::force_copy(m_flat_tree.upper_bound(x)); }
 
    //! Returns: A const iterator pointing to the first element with key
    //!   not less than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   const_iterator upper_bound(const key_type& x) const 
+   const_iterator upper_bound(const key_type& x) const
       {  return container_detail::force(m_flat_tree.upper_bound(x)); }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair equal_range(const key_type& x) 
+   std::pair equal_range(const key_type& x)
       {  return container_detail::force >(m_flat_tree.equal_range(x));   }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair 
-      equal_range(const key_type& x) const 
+   std::pair
+      equal_range(const key_type& x) const
       {  return container_detail::force >(m_flat_tree.equal_range(x));   }
 
    //! Effects: Number of elements for which memory has been allocated.
    //!   capacity() is always greater than or equal to size().
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type capacity() const           
+   size_type capacity() const          
       { return m_flat_tree.capacity(); }
 
    //! Effects: If n is less than or equal to capacity(), this call has no
    //!   effect. Otherwise, it is a request for allocation of additional memory.
    //!   If the request is successful, then capacity() is greater than or equal to
    //!   n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
-   //! 
+   //!
    //! Throws: If memory allocation allocation throws or T's copy constructor throws.
    //!
    //! Note: If capacity() is less than "count", iterators and references to
    //!   to values might be invalidated.
-   void reserve(size_type count)       
+   void reserve(size_type count)      
       { m_flat_tree.reserve(count);   }
 
    /// @cond
@@ -1475,37 +1512,37 @@ class flat_multimap
 };
 
 template 
-inline bool operator==(const flat_multimap& x, 
-                       const flat_multimap& y) 
+inline bool operator==(const flat_multimap& x,
+                       const flat_multimap& y)
    {  return x.m_flat_tree == y.m_flat_tree;  }
 
 template 
-inline bool operator<(const flat_multimap& x, 
-                      const flat_multimap& y) 
+inline bool operator<(const flat_multimap& x,
+                      const flat_multimap& y)
    {  return x.m_flat_tree < y.m_flat_tree;   }
 
 template 
-inline bool operator!=(const flat_multimap& x, 
-                       const flat_multimap& y) 
+inline bool operator!=(const flat_multimap& x,
+                       const flat_multimap& y)
    {  return !(x == y);  }
 
 template 
-inline bool operator>(const flat_multimap& x, 
-                      const flat_multimap& y) 
+inline bool operator>(const flat_multimap& x,
+                      const flat_multimap& y)
    {  return y < x;  }
 
 template 
-inline bool operator<=(const flat_multimap& x, 
-                       const flat_multimap& y) 
+inline bool operator<=(const flat_multimap& x,
+                       const flat_multimap& y)
    {  return !(y < x);  }
 
 template 
-inline bool operator>=(const flat_multimap& x, 
-                       const flat_multimap& y) 
+inline bool operator>=(const flat_multimap& x,
+                       const flat_multimap& y)
    {  return !(x < y);  }
 
 template 
-inline void swap(flat_multimap& x, flat_multimap& y) 
+inline void swap(flat_multimap& x, flat_multimap& y)
    {  x.swap(y);  }
 
 }}
@@ -1522,7 +1559,7 @@ struct has_trivial_destructor_after_move< boost::container::flat_multimap::value && has_trivial_destructor::value;
 };
 */
-}  //namespace boost { 
+}  //namespace boost {
 
 /// @endcond
 
diff --git a/include/boost/container/flat_set.hpp b/include/boost/container/flat_set.hpp
index e10e7be..09c95eb 100644
--- a/include/boost/container/flat_set.hpp
+++ b/include/boost/container/flat_set.hpp
@@ -45,31 +45,31 @@ template 
 class flat_set;
 
 template 
-inline bool operator==(const flat_set& x, 
+inline bool operator==(const flat_set& x,
                        const flat_set& y);
 
 template 
-inline bool operator<(const flat_set& x, 
+inline bool operator<(const flat_set& x,
                       const flat_set& y);
 /// @endcond
 
-//! flat_set is a Sorted Associative Container that stores objects of type Key. 
-//! flat_set is a Simple Associative Container, meaning that its value type, 
-//! as well as its key type, is Key. It is also a Unique Associative Container, 
-//! meaning that no two elements are the same. 
-//! 
+//! flat_set is a Sorted Associative Container that stores objects of type Key.
+//! flat_set is a Simple Associative Container, meaning that its value type,
+//! as well as its key type, is Key. It is also a Unique Associative Container,
+//! meaning that no two elements are the same.
+//!
 //! flat_set is similar to std::set but it's implemented like an ordered vector.
 //! This means that inserting a new element into a flat_set invalidates
 //! previous iterators and references
 //!
-//! Erasing an element of a flat_set invalidates iterators and references 
+//! Erasing an element of a flat_set invalidates iterators and references
 //! pointing to elements that come after (their keys are bigger) the erased element.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
 template , class A = std::allocator >
 #else
 template 
 #endif
-class flat_set 
+class flat_set
 {
    /// @cond
    private:
@@ -101,7 +101,7 @@ class flat_set
    typedef typename tree_t::stored_allocator_type  stored_allocator_type;
 
    //! Effects: Default constructs an empty flat_set.
-   //! 
+   //!
    //! Complexity: Constant.
    explicit flat_set()
       : m_flat_tree()
@@ -109,58 +109,60 @@ class flat_set
 
    //! Effects: Constructs an empty flat_set using the specified
    //! comparison object and allocator.
-   //! 
+   //!
    //! Complexity: Constant.
    explicit flat_set(const Pred& comp,
                      const allocator_type& a = allocator_type())
       : m_flat_tree(comp, a)
    {}
 
-   //! Effects: Constructs an empty set using the specified comparison object and 
+   //! Effects: Constructs an empty set using the specified comparison object and
    //! allocator, and inserts elements from the range [first ,last ).
-   //! 
-   //! Complexity: Linear in N if the range [first ,last ) is already sorted using 
+   //!
+   //! Complexity: Linear in N if the range [first ,last ) is already sorted using
    //! comp and otherwise N logN, where N is last - first.
    template 
-   flat_set(InputIterator first, InputIterator last, 
+   flat_set(InputIterator first, InputIterator last,
             const Pred& comp = Pred(),
             const allocator_type& a = allocator_type())
-      : m_flat_tree(comp, a) 
+      : m_flat_tree(comp, a)
       { m_flat_tree.insert_unique(first, last); }
 
-   //! Effects: Constructs an empty flat_set using the specified comparison object and 
+   //! Effects: Constructs an empty flat_set using the specified comparison object and
    //! allocator, and inserts elements from the ordered unique range [first ,last). This function
    //! is more efficient than the normal range creation for ordered ranges.
    //!
    //! Requires: [first ,last) must be ordered according to the predicate and must be
    //! unique values.
-   //! 
+   //!
    //! Complexity: Linear in N.
+   //!
+   //! Note: Non-standard extension.
    template 
-   flat_set(ordered_unique_range_t, InputIterator first, InputIterator last, 
+   flat_set(ordered_unique_range_t, InputIterator first, InputIterator last,
             const Pred& comp = Pred(),
             const allocator_type& a = allocator_type())
-      : m_flat_tree(ordered_range, first, last, comp, a) 
+      : m_flat_tree(ordered_range, first, last, comp, a)
    {}
 
    //! Effects: Copy constructs a set.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
-   flat_set(const flat_set& x) 
+   flat_set(const flat_set& x)
       : m_flat_tree(x.m_flat_tree)
    {}
 
    //! Effects: Move constructs a set. Constructs *this using x's resources.
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Postcondition: x is emptied.
-   flat_set(BOOST_RV_REF(flat_set) mx) 
+   flat_set(BOOST_RV_REF(flat_set) mx)
       : m_flat_tree(boost::move(mx.m_flat_tree))
    {}
 
    //! Effects: Copy constructs a set using the specified allocator.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
    flat_set(const flat_set& x, const allocator_type &a)
       : m_flat_tree(x.m_flat_tree, a)
@@ -168,175 +170,175 @@ class flat_set
 
    //! Effects: Move constructs a set using the specified allocator.
    //!                 Constructs *this using x's resources.
-   //! 
+   //!
    //! Complexity: Constant if a == mx.get_allocator(), linear otherwise
-   flat_set(BOOST_RV_REF(flat_set) mx, const allocator_type &a) 
+   flat_set(BOOST_RV_REF(flat_set) mx, const allocator_type &a)
       : m_flat_tree(boost::move(mx.m_flat_tree), a)
    {}
 
    //! Effects: Makes *this a copy of x.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
    flat_set& operator=(BOOST_COPY_ASSIGN_REF(flat_set) x)
       {  m_flat_tree = x.m_flat_tree;   return *this;  }
 
    //! Effects: Makes *this a copy of the previous value of xx.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
    flat_set& operator=(BOOST_RV_REF(flat_set) mx)
    {  m_flat_tree = boost::move(mx.m_flat_tree);   return *this;  }
 
    //! Effects: Returns the comparison object out
    //!   of which a was constructed.
-   //! 
+   //!
    //! Complexity: Constant.
-   key_compare key_comp() const 
+   key_compare key_comp() const
       { return m_flat_tree.key_comp(); }
 
    //! Effects: Returns an object of value_compare constructed out
    //!   of the comparison object.
-   //! 
+   //!
    //! Complexity: Constant.
-   value_compare value_comp() const 
+   value_compare value_comp() const
       { return m_flat_tree.key_comp(); }
 
    //! Effects: Returns a copy of the Allocator that
    //!   was passed to the object's constructor.
-   //! 
+   //!
    //! Complexity: Constant.
-   allocator_type get_allocator() const 
+   allocator_type get_allocator() const
       { return m_flat_tree.get_allocator(); }
 
-   const stored_allocator_type &get_stored_allocator() const 
+   const stored_allocator_type &get_stored_allocator() const
    {  return m_flat_tree.get_stored_allocator(); }
 
    stored_allocator_type &get_stored_allocator()
    {  return m_flat_tree.get_stored_allocator(); }
 
    //! Effects: Returns an iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   iterator begin() 
+   iterator begin()
       { return m_flat_tree.begin(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator begin() const 
+   const_iterator begin() const
       { return m_flat_tree.begin(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cbegin() const 
+   const_iterator cbegin() const
       { return m_flat_tree.cbegin(); }
 
    //! Effects: Returns an iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   iterator end() 
+   iterator end()
       { return m_flat_tree.end(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator end() const 
+   const_iterator end() const
       { return m_flat_tree.end(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cend() const 
+   const_iterator cend() const
       { return m_flat_tree.cend(); }
 
-   //! Effects: Returns a reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reverse_iterator rbegin() 
-      { return m_flat_tree.rbegin(); } 
+   reverse_iterator rbegin()
+      { return m_flat_tree.rbegin(); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator rbegin() const 
-      { return m_flat_tree.rbegin(); } 
+   const_reverse_iterator rbegin() const
+      { return m_flat_tree.rbegin(); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin() const 
-      { return m_flat_tree.crbegin(); } 
+   const_reverse_iterator crbegin() const
+      { return m_flat_tree.crbegin(); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reverse_iterator rend()
       { return m_flat_tree.rend(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator rend() const 
+   const_reverse_iterator rend() const
       { return m_flat_tree.rend(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crend() const 
+   const_reverse_iterator crend() const
       { return m_flat_tree.crend(); }
 
    //! Effects: Returns true if the container contains no elements.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   bool empty() const 
+   bool empty() const
       { return m_flat_tree.empty(); }
 
    //! Effects: Returns the number of the elements contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type size() const 
+   size_type size() const
       { return m_flat_tree.size(); }
 
    //! Effects: Returns the largest possible size of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type max_size() const 
+   size_type max_size() const
       { return m_flat_tree.max_size(); }
 
    //! Effects: Swaps the contents of *this and x.
@@ -347,10 +349,10 @@ class flat_set
    void swap(flat_set& x)
    { m_flat_tree.swap(x.m_flat_tree); }
 
-   //! Effects: Inserts x if and only if there is no element in the container 
+   //! Effects: Inserts x if and only if there is no element in the container
    //!   with key equivalent to the key of x.
    //!
-   //! Returns: The bool component of the returned pair is true if and only 
+   //! Returns: The bool component of the returned pair is true if and only
    //!   if the insertion takes place, and the iterator component of the pair
    //!   points to the element with key equivalent to the key of x.
    //!
@@ -358,7 +360,7 @@ class flat_set
    //!   to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   std::pair insert(insert_const_ref_type x) 
+   std::pair insert(insert_const_ref_type x)
    {  return priv_insert(x); }
 
    #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -373,7 +375,7 @@ class flat_set
    //! Effects: Inserts a new value_type move constructed from the pair if and
    //! only if there is no element in the container with key equivalent to the key of x.
    //!
-   //! Returns: The bool component of the returned pair is true if and only 
+   //! Returns: The bool component of the returned pair is true if and only
    //!   if the insertion takes place, and the iterator component of the pair
    //!   points to the element with key equivalent to the key of x.
    //!
@@ -381,10 +383,10 @@ class flat_set
    //!   to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   std::pair insert(BOOST_RV_REF(value_type) x) 
+   std::pair insert(BOOST_RV_REF(value_type) x)
    {  return m_flat_tree.insert_unique(boost::move(x));  }
 
-   //! Effects: Inserts a copy of x in the container if and only if there is 
+   //! Effects: Inserts a copy of x in the container if and only if there is
    //!   no element in the container with key equivalent to the key of x.
    //!   p is a hint pointing to where the insert should start to search.
    //!
@@ -395,7 +397,7 @@ class flat_set
    //!   right before p) plus insertion linear to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(const_iterator p, insert_const_ref_type x) 
+   iterator insert(const_iterator p, insert_const_ref_type x)
    {  return priv_insert(p, x); }
 
    #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -416,12 +418,12 @@ class flat_set
    //!   right before p) plus insertion linear to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(const_iterator position, BOOST_RV_REF(value_type) x) 
+   iterator insert(const_iterator position, BOOST_RV_REF(value_type) x)
    {  return m_flat_tree.insert_unique(position, boost::move(x)); }
 
    //! Requires: first, last are not iterators into *this.
    //!
-   //! Effects: inserts each element from the range [first,last) if and only 
+   //! Effects: inserts each element from the range [first,last) if and only
    //!   if there is no element with key equivalent to the key of that element.
    //!
    //! Complexity: At most N log(size()+N) (N is the distance from first to last)
@@ -429,16 +431,31 @@ class flat_set
    //!
    //! Note: If an element is inserted it might invalidate elements.
    template 
-   void insert(InputIterator first, InputIterator last) 
+   void insert(InputIterator first, InputIterator last)
       {  m_flat_tree.insert_unique(first, last);  }
 
+   //! Requires: first, last are not iterators into *this and
+   //! must be ordered according to the predicate and must be
+   //! unique values.
+   //!
+   //! Effects: inserts each element from the range [first,last) .This function
+   //! is more efficient than the normal range creation for ordered ranges.
+   //!
+   //! Complexity: At most N log(size()+N) (N is the distance from first to last)
+   //!   search time plus N*size() insertion time.
+   //!
+   //! Note: Non-standard extension. If an element is inserted it might invalidate elements.
+   template 
+   void insert(ordered_unique_range_t, InputIterator first, InputIterator last)
+      {  m_flat_tree.insert_unique(ordered_unique_range, first, last);  }
+
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
    //! Effects: Inserts an object x of type T constructed with
-   //!   std::forward(args)... if and only if there is no element in the container 
+   //!   std::forward(args)... if and only if there is no element in the container
    //!   with key equivalent to the key of x.
    //!
-   //! Returns: The bool component of the returned pair is true if and only 
+   //! Returns: The bool component of the returned pair is true if and only
    //!   if the insertion takes place, and the iterator component of the pair
    //!   points to the element with key equivalent to the key of x.
    //!
@@ -451,7 +468,7 @@ class flat_set
    {  return m_flat_tree.emplace_unique(boost::forward(args)...); }
 
    //! Effects: Inserts an object of type T constructed with
-   //!   std::forward(args)... in the container if and only if there is 
+   //!   std::forward(args)... in the container if and only if there is
    //!   no element in the container with key equivalent to the key of x.
    //!   p is a hint pointing to where the insert should start to search.
    //!
@@ -487,14 +504,14 @@ class flat_set
    //! Effects: Erases the element pointed to by position.
    //!
    //! Returns: Returns an iterator pointing to the element immediately
-   //!   following q prior to the element being erased. If no such element exists, 
+   //!   following q prior to the element being erased. If no such element exists,
    //!   returns end().
    //!
    //! Complexity: Linear to the elements with keys bigger than position
    //!
    //! Note: Invalidates elements with keys
    //!   not less than the erased element.
-   iterator erase(const_iterator position) 
+   iterator erase(const_iterator position)
       {  return m_flat_tree.erase(position); }
 
    //! Effects: Erases all elements in the container with key equivalent to x.
@@ -503,7 +520,7 @@ class flat_set
    //!
    //! Complexity: Logarithmic search time plus erasure time
    //!   linear to the elements with bigger keys.
-   size_type erase(const key_type& x) 
+   size_type erase(const key_type& x)
       {  return m_flat_tree.erase(x); }
 
    //! Effects: Erases all the elements in the range [first, last).
@@ -514,7 +531,7 @@ class flat_set
    //!
    //! Complexity: Logarithmic search time plus erasure time
    //!   linear to the elements with bigger keys.
-   iterator erase(const_iterator first, const_iterator last) 
+   iterator erase(const_iterator first, const_iterator last)
       {  return m_flat_tree.erase(first, last);  }
 
    //! Effects: erase(a.begin(),a.end()).
@@ -522,7 +539,7 @@ class flat_set
    //! Postcondition: size() == 0.
    //!
    //! Complexity: linear in size().
-   void clear() 
+   void clear()
       { m_flat_tree.clear(); }
 
    //! Effects: Tries to deallocate the excess of memory created
@@ -538,34 +555,34 @@ class flat_set
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.
-   iterator find(const key_type& x) 
+   iterator find(const key_type& x)
       { return m_flat_tree.find(x); }
 
    //! Returns: A const_iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.s
-   const_iterator find(const key_type& x) const 
+   const_iterator find(const key_type& x) const
       { return m_flat_tree.find(x); }
 
    //! Returns: The number of elements with key equivalent to x.
    //!
    //! Complexity: log(size())+count(k)
-   size_type count(const key_type& x) const 
+   size_type count(const key_type& x) const
       {  return m_flat_tree.find(x) == m_flat_tree.end() ? 0 : 1;  }
 
    //! Returns: An iterator pointing to the first element with key not less
    //!   than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   iterator lower_bound(const key_type& x) 
+   iterator lower_bound(const key_type& x)
       {  return m_flat_tree.lower_bound(x); }
 
    //! Returns: A const iterator pointing to the first element with key not
    //!   less than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   const_iterator lower_bound(const key_type& x) const 
+   const_iterator lower_bound(const key_type& x) const
       {  return m_flat_tree.lower_bound(x); }
 
    //! Returns: An iterator pointing to the first element with key not less
@@ -579,42 +596,42 @@ class flat_set
    //!   less than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   const_iterator upper_bound(const key_type& x) const 
+   const_iterator upper_bound(const key_type& x) const
       {  return m_flat_tree.upper_bound(x);    }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair 
-      equal_range(const key_type& x) const 
+   std::pair
+      equal_range(const key_type& x) const
       {  return m_flat_tree.equal_range(x); }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair 
-      equal_range(const key_type& x) 
+   std::pair
+      equal_range(const key_type& x)
       {  return m_flat_tree.equal_range(x); }
 
    //! Effects: Number of elements for which memory has been allocated.
    //!   capacity() is always greater than or equal to size().
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type capacity() const           
+   size_type capacity() const          
       { return m_flat_tree.capacity(); }
 
    //! Effects: If n is less than or equal to capacity(), this call has no
    //!   effect. Otherwise, it is a request for allocation of additional memory.
    //!   If the request is successful, then capacity() is greater than or equal to
    //!   n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
-   //! 
+   //!
    //! Throws: If memory allocation allocation throws or T's copy constructor throws.
    //!
    //! Note: If capacity() is less than "count", iterators and references to
    //!   to values might be invalidated.
-   void reserve(size_type count)       
+   void reserve(size_type count)      
       { m_flat_tree.reserve(count);   }
 
    /// @cond
@@ -625,46 +642,46 @@ class flat_set
    friend bool operator< (const flat_set&, const flat_set&);
 
    private:
-   std::pair priv_insert(const T &x) 
+   std::pair priv_insert(const T &x)
    {  return m_flat_tree.insert_unique(x);  }
 
-   iterator priv_insert(const_iterator p, const T &x) 
+   iterator priv_insert(const_iterator p, const T &x)
    {  return m_flat_tree.insert_unique(p, x); }
    /// @endcond
 };
 
 template 
-inline bool operator==(const flat_set& x, 
-                       const flat_set& y) 
+inline bool operator==(const flat_set& x,
+                       const flat_set& y)
    {  return x.m_flat_tree == y.m_flat_tree;  }
 
 template 
-inline bool operator<(const flat_set& x, 
-                      const flat_set& y) 
+inline bool operator<(const flat_set& x,
+                      const flat_set& y)
    {  return x.m_flat_tree < y.m_flat_tree;   }
 
 template 
-inline bool operator!=(const flat_set& x, 
-                       const flat_set& y) 
+inline bool operator!=(const flat_set& x,
+                       const flat_set& y)
    {  return !(x == y);   }
 
 template 
-inline bool operator>(const flat_set& x, 
-                      const flat_set& y) 
+inline bool operator>(const flat_set& x,
+                      const flat_set& y)
    {  return y < x; }
 
 template 
-inline bool operator<=(const flat_set& x, 
-                       const flat_set& y) 
+inline bool operator<=(const flat_set& x,
+                       const flat_set& y)
    {  return !(y < x); }
 
 template 
-inline bool operator>=(const flat_set& x, 
-                       const flat_set& y) 
+inline bool operator>=(const flat_set& x,
+                       const flat_set& y)
    {  return !(x < y);  }
 
 template 
-inline void swap(flat_set& x, flat_set& y) 
+inline void swap(flat_set& x, flat_set& y)
    {  x.swap(y);  }
 
 /// @cond
@@ -691,31 +708,31 @@ template 
 class flat_multiset;
 
 template 
-inline bool operator==(const flat_multiset& x, 
+inline bool operator==(const flat_multiset& x,
                        const flat_multiset& y);
 
 template 
-inline bool operator<(const flat_multiset& x, 
+inline bool operator<(const flat_multiset& x,
                       const flat_multiset& y);
 /// @endcond
 
-//! flat_multiset is a Sorted Associative Container that stores objects of type Key. 
-//! flat_multiset is a Simple Associative Container, meaning that its value type, 
+//! flat_multiset is a Sorted Associative Container that stores objects of type Key.
+//! flat_multiset is a Simple Associative Container, meaning that its value type,
 //! as well as its key type, is Key.
 //! flat_Multiset can store multiple copies of the same key value.
-//! 
+//!
 //! flat_multiset is similar to std::multiset but it's implemented like an ordered vector.
 //! This means that inserting a new element into a flat_multiset invalidates
 //! previous iterators and references
 //!
-//! Erasing an element of a flat_multiset invalidates iterators and references 
+//! Erasing an element of a flat_multiset invalidates iterators and references
 //! pointing to elements that come after (their keys are equal or bigger) the erased element.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
 template , class A = std::allocator >
 #else
 template 
 #endif
-class flat_multiset 
+class flat_multiset
 {
    /// @cond
    private:
@@ -746,7 +763,7 @@ class flat_multiset
    typedef typename tree_t::stored_allocator_type  stored_allocator_type;
 
    //! Effects: Default constructs an empty flat_multiset.
-   //! 
+   //!
    //! Complexity: Constant.
    explicit flat_multiset()
       : m_flat_tree()
@@ -760,41 +777,43 @@ class flat_multiset
    flat_multiset(InputIterator first, InputIterator last,
                  const Pred& comp        = Pred(),
                  const allocator_type& a = allocator_type())
-      : m_flat_tree(comp, a) 
+      : m_flat_tree(comp, a)
       { m_flat_tree.insert_equal(first, last); }
 
-   //! Effects: Constructs an empty flat_multiset using the specified comparison object and 
+   //! Effects: Constructs an empty flat_multiset using the specified comparison object and
    //! allocator, and inserts elements from the ordered range [first ,last ). This function
    //! is more efficient than the normal range creation for ordered ranges.
    //!
    //! Requires: [first ,last) must be ordered according to the predicate.
-   //! 
+   //!
    //! Complexity: Linear in N.
+   //!
+   //! Note: Non-standard extension.
    template 
    flat_multiset(ordered_range_t, InputIterator first, InputIterator last,
                  const Pred& comp        = Pred(),
                  const allocator_type& a = allocator_type())
-      : m_flat_tree(ordered_range, first, last, comp, a) 
+      : m_flat_tree(ordered_range, first, last, comp, a)
    {}
 
    //! Effects: Copy constructs a flat_multiset.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
-   flat_multiset(const flat_multiset& x) 
+   flat_multiset(const flat_multiset& x)
       : m_flat_tree(x.m_flat_tree)
    {}
 
    //! Effects: Move constructs a flat_multiset. Constructs *this using x's resources.
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Postcondition: x is emptied.
-   flat_multiset(BOOST_RV_REF(flat_multiset) mx) 
+   flat_multiset(BOOST_RV_REF(flat_multiset) mx)
       : m_flat_tree(boost::move(mx.m_flat_tree))
    {}
 
    //! Effects: Copy constructs a flat_multiset using the specified allocator.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
    flat_multiset(const flat_multiset& x, const allocator_type &a)
       : m_flat_tree(x.m_flat_tree, a)
@@ -802,175 +821,175 @@ class flat_multiset
 
    //! Effects: Move constructs a flat_multiset using the specified allocator.
    //!                 Constructs *this using x's resources.
-   //! 
+   //!
    //! Complexity: Constant if a == mx.get_allocator(), linear otherwise
-   flat_multiset(BOOST_RV_REF(flat_multiset) mx, const allocator_type &a) 
+   flat_multiset(BOOST_RV_REF(flat_multiset) mx, const allocator_type &a)
       : m_flat_tree(boost::move(mx.m_flat_tree), a)
    {}
 
    //! Effects: Makes *this a copy of x.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
-   flat_multiset& operator=(BOOST_COPY_ASSIGN_REF(flat_multiset) x) 
+   flat_multiset& operator=(BOOST_COPY_ASSIGN_REF(flat_multiset) x)
       {  m_flat_tree = x.m_flat_tree;   return *this;  }
 
    //! Effects: Makes *this a copy of x.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
-   flat_multiset& operator=(BOOST_RV_REF(flat_multiset) mx) 
+   flat_multiset& operator=(BOOST_RV_REF(flat_multiset) mx)
    {  m_flat_tree = boost::move(mx.m_flat_tree);   return *this;  }
 
    //! Effects: Returns the comparison object out
    //!   of which a was constructed.
-   //! 
+   //!
    //! Complexity: Constant.
-   key_compare key_comp() const 
+   key_compare key_comp() const
       { return m_flat_tree.key_comp(); }
 
    //! Effects: Returns an object of value_compare constructed out
    //!   of the comparison object.
-   //! 
+   //!
    //! Complexity: Constant.
-   value_compare value_comp() const 
+   value_compare value_comp() const
       { return m_flat_tree.key_comp(); }
 
    //! Effects: Returns a copy of the Allocator that
    //!   was passed to the object's constructor.
-   //! 
+   //!
    //! Complexity: Constant.
-   allocator_type get_allocator() const 
+   allocator_type get_allocator() const
    { return m_flat_tree.get_allocator(); }
 
-   const stored_allocator_type &get_stored_allocator() const 
+   const stored_allocator_type &get_stored_allocator() const
    { return m_flat_tree.get_stored_allocator(); }
 
    stored_allocator_type &get_stored_allocator()
    { return m_flat_tree.get_stored_allocator(); }
 
    //! Effects: Returns an iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   iterator begin() 
+   iterator begin()
       { return m_flat_tree.begin(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator begin() const 
+   const_iterator begin() const
       { return m_flat_tree.begin(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cbegin() const 
+   const_iterator cbegin() const
       { return m_flat_tree.cbegin(); }
 
    //! Effects: Returns an iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   iterator end() 
+   iterator end()
       { return m_flat_tree.end(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator end() const 
+   const_iterator end() const
       { return m_flat_tree.end(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cend() const 
+   const_iterator cend() const
       { return m_flat_tree.cend(); }
 
-   //! Effects: Returns a reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reverse_iterator rbegin() 
-      { return m_flat_tree.rbegin(); } 
+   reverse_iterator rbegin()
+      { return m_flat_tree.rbegin(); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator rbegin() const 
-      { return m_flat_tree.rbegin(); } 
+   const_reverse_iterator rbegin() const
+      { return m_flat_tree.rbegin(); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin() const 
-      { return m_flat_tree.crbegin(); } 
+   const_reverse_iterator crbegin() const
+      { return m_flat_tree.crbegin(); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reverse_iterator rend()
       { return m_flat_tree.rend(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator rend() const 
+   const_reverse_iterator rend() const
       { return m_flat_tree.rend(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crend() const 
+   const_reverse_iterator crend() const
       { return m_flat_tree.crend(); }
 
    //! Effects: Returns true if the container contains no elements.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   bool empty() const 
+   bool empty() const
       { return m_flat_tree.empty(); }
 
    //! Effects: Returns the number of the elements contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type size() const 
+   size_type size() const
       { return m_flat_tree.size(); }
 
    //! Effects: Returns the largest possible size of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type max_size() const 
+   size_type max_size() const
       { return m_flat_tree.max_size(); }
 
    //! Effects: Swaps the contents of *this and x.
@@ -982,13 +1001,13 @@ class flat_multiset
    { m_flat_tree.swap(x.m_flat_tree); }
 
    //! Effects: Inserts x and returns the iterator pointing to the
-   //!   newly inserted element. 
+   //!   newly inserted element.
    //!
    //! Complexity: Logarithmic search time plus linear insertion
    //!   to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(insert_const_ref_type x) 
+   iterator insert(insert_const_ref_type x)
    {  return priv_insert(x); }
 
    #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1001,13 +1020,13 @@ class flat_multiset
    #endif
 
    //! Effects: Inserts a new value_type move constructed from x
-   //!   and returns the iterator pointing to the newly inserted element. 
+   //!   and returns the iterator pointing to the newly inserted element.
    //!
    //! Complexity: Logarithmic search time plus linear insertion
    //!   to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(BOOST_RV_REF(value_type) x) 
+   iterator insert(BOOST_RV_REF(value_type) x)
    {  return m_flat_tree.insert_equal(boost::move(x));   }
 
    //! Effects: Inserts a copy of x in the container.
@@ -1020,7 +1039,7 @@ class flat_multiset
    //!   right before p) plus insertion linear to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(const_iterator p, insert_const_ref_type x) 
+   iterator insert(const_iterator p, insert_const_ref_type x)
    {  return priv_insert(p, x); }
 
    #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1043,7 +1062,7 @@ class flat_multiset
    //!   right before p) plus insertion linear to the elements with bigger keys than x.
    //!
    //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(const_iterator position, BOOST_RV_REF(value_type) x) 
+   iterator insert(const_iterator position, BOOST_RV_REF(value_type) x)
    {  return m_flat_tree.insert_equal(position, boost::move(x));  }
 
    //! Requires: first, last are not iterators into *this.
@@ -1055,14 +1074,28 @@ class flat_multiset
    //!
    //! Note: If an element is inserted it might invalidate elements.
    template 
-   void insert(InputIterator first, InputIterator last) 
+   void insert(InputIterator first, InputIterator last)
       {  m_flat_tree.insert_equal(first, last);  }
 
+   //! Requires: first, last are not iterators into *this and
+   //! must be ordered according to the predicate.
+   //!
+   //! Effects: inserts each element from the range [first,last) .This function
+   //! is more efficient than the normal range creation for ordered ranges.
+   //!
+   //! Complexity: At most N log(size()+N) (N is the distance from first to last)
+   //!   search time plus N*size() insertion time.
+   //!
+   //! Note: Non-standard extension. If an element is inserted it might invalidate elements.
+   template 
+   void insert(ordered_range_t, InputIterator first, InputIterator last)
+      {  m_flat_tree.insert_equal(ordered_range, first, last);  }
+
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
    //! Effects: Inserts an object of type T constructed with
    //!   std::forward(args)... and returns the iterator pointing to the
-   //!   newly inserted element. 
+   //!   newly inserted element.
    //!
    //! Complexity: Logarithmic search time plus linear insertion
    //!   to the elements with bigger keys than x.
@@ -1108,14 +1141,14 @@ class flat_multiset
    //! Effects: Erases the element pointed to by position.
    //!
    //! Returns: Returns an iterator pointing to the element immediately
-   //!   following q prior to the element being erased. If no such element exists, 
+   //!   following q prior to the element being erased. If no such element exists,
    //!   returns end().
    //!
    //! Complexity: Linear to the elements with keys bigger than position
    //!
    //! Note: Invalidates elements with keys
    //!   not less than the erased element.
-   iterator erase(const_iterator position) 
+   iterator erase(const_iterator position)
       {  return m_flat_tree.erase(position); }
 
    //! Effects: Erases all elements in the container with key equivalent to x.
@@ -1124,7 +1157,7 @@ class flat_multiset
    //!
    //! Complexity: Logarithmic search time plus erasure time
    //!   linear to the elements with bigger keys.
-   size_type erase(const key_type& x) 
+   size_type erase(const key_type& x)
       {  return m_flat_tree.erase(x); }
 
    //! Effects: Erases all the elements in the range [first, last).
@@ -1135,7 +1168,7 @@ class flat_multiset
    //!
    //! Complexity: Logarithmic search time plus erasure time
    //!   linear to the elements with bigger keys.
-   iterator erase(const_iterator first, const_iterator last) 
+   iterator erase(const_iterator first, const_iterator last)
       {  return m_flat_tree.erase(first, last);  }
 
    //! Effects: erase(a.begin(),a.end()).
@@ -1143,7 +1176,7 @@ class flat_multiset
    //! Postcondition: size() == 0.
    //!
    //! Complexity: linear in size().
-   void clear() 
+   void clear()
       { m_flat_tree.clear(); }
 
    //! Effects: Tries to deallocate the excess of memory created
@@ -1159,34 +1192,34 @@ class flat_multiset
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.
-   iterator find(const key_type& x) 
+   iterator find(const key_type& x)
       { return m_flat_tree.find(x); }
 
    //! Returns: A const_iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.s
-   const_iterator find(const key_type& x) const 
+   const_iterator find(const key_type& x) const
       { return m_flat_tree.find(x); }
 
    //! Returns: The number of elements with key equivalent to x.
    //!
    //! Complexity: log(size())+count(k)
-   size_type count(const key_type& x) const 
+   size_type count(const key_type& x) const
       { return m_flat_tree.count(x); }
 
    //! Returns: An iterator pointing to the first element with key not less
    //!   than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   iterator lower_bound(const key_type& x) 
+   iterator lower_bound(const key_type& x)
       {  return m_flat_tree.lower_bound(x); }
 
    //! Returns: A const iterator pointing to the first element with key not
    //!   less than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   const_iterator lower_bound(const key_type& x) const 
+   const_iterator lower_bound(const key_type& x) const
       {  return m_flat_tree.lower_bound(x); }
 
    //! Returns: An iterator pointing to the first element with key not less
@@ -1200,42 +1233,42 @@ class flat_multiset
    //!   less than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   const_iterator upper_bound(const key_type& x) const 
+   const_iterator upper_bound(const key_type& x) const
       {  return m_flat_tree.upper_bound(x);    }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair 
-      equal_range(const key_type& x) const 
+   std::pair
+      equal_range(const key_type& x) const
       {  return m_flat_tree.equal_range(x); }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair 
-      equal_range(const key_type& x) 
+   std::pair
+      equal_range(const key_type& x)
       {  return m_flat_tree.equal_range(x); }
 
    //! Effects: Number of elements for which memory has been allocated.
    //!   capacity() is always greater than or equal to size().
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type capacity() const           
+   size_type capacity() const          
       { return m_flat_tree.capacity(); }
 
    //! Effects: If n is less than or equal to capacity(), this call has no
    //!   effect. Otherwise, it is a request for allocation of additional memory.
    //!   If the request is successful, then capacity() is greater than or equal to
    //!   n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
-   //! 
+   //!
    //! Throws: If memory allocation allocation throws or T's copy constructor throws.
    //!
    //! Note: If capacity() is less than "count", iterators and references to
    //!   to values might be invalidated.
-   void reserve(size_type count)       
+   void reserve(size_type count)      
       { m_flat_tree.reserve(count);   }
 
    /// @cond
@@ -1246,46 +1279,46 @@ class flat_multiset
    friend bool operator< (const flat_multiset&,
                           const flat_multiset&);
    private:
-   iterator priv_insert(const T &x) 
+   iterator priv_insert(const T &x)
    {  return m_flat_tree.insert_equal(x);  }
 
-   iterator priv_insert(const_iterator p, const T &x) 
+   iterator priv_insert(const_iterator p, const T &x)
    {  return m_flat_tree.insert_equal(p, x); }
    /// @endcond
 };
 
 template 
-inline bool operator==(const flat_multiset& x, 
-                       const flat_multiset& y) 
+inline bool operator==(const flat_multiset& x,
+                       const flat_multiset& y)
    {  return x.m_flat_tree == y.m_flat_tree;  }
 
 template 
-inline bool operator<(const flat_multiset& x, 
-                      const flat_multiset& y) 
+inline bool operator<(const flat_multiset& x,
+                      const flat_multiset& y)
    {  return x.m_flat_tree < y.m_flat_tree;   }
 
 template 
-inline bool operator!=(const flat_multiset& x, 
-                       const flat_multiset& y) 
+inline bool operator!=(const flat_multiset& x,
+                       const flat_multiset& y)
    {  return !(x == y);  }
 
 template 
-inline bool operator>(const flat_multiset& x, 
-                      const flat_multiset& y) 
+inline bool operator>(const flat_multiset& x,
+                      const flat_multiset& y)
    {  return y < x;  }
 
 template 
-inline bool operator<=(const flat_multiset& x, 
-                       const flat_multiset& y) 
+inline bool operator<=(const flat_multiset& x,
+                       const flat_multiset& y)
    {  return !(y < x);  }
 
 template 
-inline bool operator>=(const flat_multiset& x, 
-                       const flat_multiset& y) 
+inline bool operator>=(const flat_multiset& x,
+                       const flat_multiset& y)
 {  return !(x < y);  }
 
 template 
-inline void swap(flat_multiset& x, flat_multiset& y) 
+inline void swap(flat_multiset& x, flat_multiset& y)
    {  x.swap(y);  }
 
 /// @cond
diff --git a/include/boost/container/list.hpp b/include/boost/container/list.hpp
index e6682d8..c3e3562 100644
--- a/include/boost/container/list.hpp
+++ b/include/boost/container/list.hpp
@@ -32,7 +32,7 @@
 #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 #else
 //Preprocessor library to emulate perfect forwarding
-#include  
+#include 
 #endif
 
 #include 
@@ -98,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::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::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  >
 #else
 template 
 #endif
-class list 
+class list
    : protected container_detail::node_alloc_holder
       ::type>
 {
    /// @cond
-   typedef typename 
+   typedef typename
       container_detail::intrusive_list_type::type Icont;
    typedef list                                 ThisType;
    typedef container_detail::node_alloc_holder        AllocHolder;
@@ -192,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
    {
 
@@ -220,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--()
@@ -259,7 +259,7 @@ class list
       explicit iterator(typename Icont::iterator it)
          :  const_iterator(it)
       {}
-   
+  
       typename Icont::iterator get()
       {  return this->m_it;   }
 
@@ -276,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;  }
 
@@ -290,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        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_reverse_iterator;
 
    //! Effects: Default constructs a list.
-   //! 
+   //!
    //! Throws: If allocator_type's default constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
-   list() 
+   list()
       : AllocHolder()
    {}
 
    //! Effects: Constructs a list taking the allocator as parameter.
-   //! 
+   //!
    //! Throws: If allocator_type's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
    explicit list(const allocator_type &a)
       : AllocHolder(a)
@@ -318,7 +318,7 @@ class list
    //!
    //! Throws: If allocator_type's default constructor or copy constructor
    //!   throws or T's default or copy constructor throws.
-   //! 
+   //!
    //! Complexity: Linear to n.
    explicit list(size_type n)
       : AllocHolder(A())
@@ -329,7 +329,7 @@ class list
    //!
    //! Throws: If allocator_type's default constructor or copy constructor
    //!   throws or T's default or copy constructor throws.
-   //! 
+   //!
    //! Complexity: Linear to n.
    list(size_type n, const T& value, const A& a = A())
       : AllocHolder(a)
@@ -338,18 +338,18 @@ class list
    //! Effects: Copy constructs a list.
    //!
    //! Postcondition: x == *this.
-   //! 
+   //!
    //! Throws: If allocator_type's default constructor or copy constructor throws.
-   //! 
+   //!
    //! Complexity: Linear to the elements x contains.
-   list(const list& x) 
+   list(const list& x)
       : AllocHolder(x)
    {  this->insert(this->cbegin(), x.begin(), x.end());   }
 
    //! Effects: Move constructor. Moves mx's resources to *this.
    //!
    //! Throws: If allocator_type's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
    list(BOOST_RV_REF(list) x)
       : AllocHolder(boost::move(static_cast(x)))
@@ -358,11 +358,11 @@ class list
    //! Effects: Copy constructs a list using the specified allocator.
    //!
    //! Postcondition: x == *this.
-   //! 
+   //!
    //! Throws: If allocator_type's default constructor or copy constructor throws.
-   //! 
+   //!
    //! Complexity: Linear to the elements x contains.
-   list(const list& x, const allocator_type &a) 
+   list(const list& x, const allocator_type &a)
       : AllocHolder(a)
    {  this->insert(this->cbegin(), x.begin(), x.end());   }
 
@@ -370,7 +370,7 @@ class list
    //!                 Moves mx's resources to *this.
    //!
    //! Throws: If allocation or value_type's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant if a == x.get_allocator(), linear otherwise.
    list(BOOST_RV_REF(list) x, const allocator_type &a)
       : AllocHolder(a)
@@ -405,14 +405,14 @@ class list
    {} //AllocHolder clears the list
 
    //! Effects: Returns a copy of the internal allocator.
-   //! 
+   //!
    //! Throws: If allocator's copy constructor throws.
-   //! 
+   //!
    //! Complexity: 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()
@@ -427,129 +427,129 @@ class list
    {  AllocHolder::clear(alloc_version());  }
 
    //! Effects: Returns an iterator to the first element contained in the list.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    iterator begin()
    { return iterator(this->icont().begin()); }
 
    //! Effects: Returns a const_iterator to the first element contained in the list.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator begin() const
    {  return this->cbegin();   }
 
    //! Effects: Returns an iterator to the end of the list.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    iterator end()
    {  return iterator(this->icont().end());  }
 
    //! Effects: Returns a const_iterator to the end of the list.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator end() const
    {  return this->cend();  }
 
-   //! Effects: Returns a reverse_iterator pointing to the beginning 
-   //! of the reversed list. 
-   //! 
+   //! Effects: Returns a reverse_iterator pointing to the beginning
+   //! of the reversed list.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reverse_iterator rbegin()
    {  return reverse_iterator(end());  }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed list. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed list.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reverse_iterator rbegin() const
    {  return this->crbegin();  }
 
    //! Effects: Returns a reverse_iterator pointing to the end
-   //! of the reversed list. 
-   //! 
+   //! of the reversed list.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reverse_iterator rend()
    {  return reverse_iterator(begin());   }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed list. 
-   //! 
+   //! of the reversed list.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reverse_iterator rend() const
    {  return this->crend();   }
 
    //! Effects: Returns a const_iterator to the first element contained in the list.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator cbegin() const
    {  return const_iterator(this->non_const_icont().begin());   }
 
    //! Effects: Returns a const_iterator to the end of the list.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator cend() const
    {  return const_iterator(this->non_const_icont().end());  }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed list. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed list.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reverse_iterator crbegin() const
    {  return const_reverse_iterator(this->cend());  }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed list. 
-   //! 
+   //! of the reversed list.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reverse_iterator crend() const
    {  return const_reverse_iterator(this->cbegin());   }
 
    //! Effects: Returns true if the list contains no elements.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   bool empty() const 
+   bool empty() const
    {  return !this->size();  }
 
    //! Effects: Returns the number of the elements contained in the list.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type size() const 
+   size_type size() const
    {   return this->icont().size();   }
 
    //! Effects: Returns the largest possible size of the list.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type max_size() const 
+   size_type max_size() const
    {  return AllocHolder::max_size();  }
 
    #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -597,7 +597,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Amortized constant time.
-   void pop_front()              
+   void pop_front()             
    {  this->erase(this->cbegin());      }
 
    //! Effects: Removes the last element from the list.
@@ -605,51 +605,51 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Amortized constant time.
-   void pop_back()               
+   void pop_back()              
    {  const_iterator tmp = this->cend(); this->erase(--tmp);  }
 
    //! Requires: !empty()
    //!
-   //! Effects: Returns a reference to the first element 
+   //! Effects: Returns a reference to the first element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reference front()             
+   reference front()            
    { return *this->begin(); }
 
    //! Requires: !empty()
    //!
-   //! Effects: Returns a const reference to the first element 
+   //! Effects: Returns a const reference to the first element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reference front() const 
+   const_reference front() const
    { return *this->begin(); }
 
    //! Requires: !empty()
    //!
-   //! Effects: Returns a reference to the first element 
+   //! Effects: Returns a reference to the first element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reference back()              
+   reference back()             
    { return *(--this->end()); }
 
    //! Requires: !empty()
    //!
-   //! Effects: Returns a const reference to the first element 
+   //! Effects: Returns a const reference to the first element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reference back()  const 
+   const_reference back()  const
    { return *(--this->end()); }
 
    //! Effects: Inserts or erases elements at the end such that
@@ -662,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--){
@@ -685,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;
@@ -719,8 +719,8 @@ class list
 
    //! Effects: Makes *this contain the same elements as x.
    //!
-   //! Postcondition: this->size() == x.size(). *this contains a copy 
-   //! of each of x's elements. 
+   //! Postcondition: this->size() == x.size(). *this contains a copy
+   //! of each of x's elements.
    //!
    //! Throws: If memory allocation throws or T's copy constructor throws.
    //!
@@ -791,7 +791,7 @@ class list
    //!
    //! Complexity: Linear to std::distance [first, last).
    template 
-   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::value;
       typedef container_detail::bool_ Result;
@@ -900,7 +900,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: 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()))); }
 
    //! Requires: first and last must be valid iterator to elements in *this.
@@ -918,7 +918,7 @@ class list
    //! Throws: If memory allocation throws or T's copy constructor throws.
    //!
    //! Complexity: 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);  }
 
    //! Effects: Assigns the the range [first, last) to *this.
@@ -928,7 +928,7 @@ class list
    //!
    //! Complexity: Linear to n.
    template 
-   void assign(InpIt first, InpIt last) 
+   void assign(InpIt first, InpIt last)
    {
       const bool aux_boolean = container_detail::is_convertible::value;
       typedef container_detail::bool_ Result;
@@ -945,7 +945,7 @@ class list
    //!   are not equal.
    //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Note: 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
@@ -956,16 +956,16 @@ class list
 
    //! Requires: p must point to an element contained
    //!   by this list. i must point to an element contained in list x.
-   //! 
-   //! Effects: Transfers the value pointed by i, from list x to this list, 
+   //!
+   //! Effects: 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.
+   //!
    //! Throws: std::runtime_error if this' allocator and x's allocator
    //!   are not equal.
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Note: 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
@@ -976,15 +976,15 @@ class list
 
    //! Requires: p must point to an element contained
    //!   by this list. first and last must point to elements contained in list x.
-   //! 
-   //! Effects: Transfers the range pointed by first and last from list x to this list, 
+   //!
+   //! Effects: 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.
-   //! 
+   //!
    //! Throws: std::runtime_error if this' allocator and x's allocator
    //!   are not equal.
-   //! 
+   //!
    //! Complexity: Linear to the number of elements transferred.
-   //! 
+   //!
    //! Note: 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
@@ -996,15 +996,15 @@ class list
    //! Requires: 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)
-   //! 
-   //! Effects: Transfers the range pointed by first and last from list x to this list, 
+   //!
+   //! Effects: 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.
-   //! 
+   //!
    //! Throws: std::runtime_error if this' allocator and x's allocator
    //!   are not equal.
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Note: 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
@@ -1013,22 +1013,22 @@ class list
       this->icont().splice(p.get(), x.icont(), first.get(), last.get(), n);
    }
 
-   //! Effects: Reverses the order of elements in the list. 
-   //! 
+   //! Effects: Reverses the order of elements in the list.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: This function is linear time.
-   //! 
+   //!
    //! Note: Iterators and references are not invalidated
    void reverse()
-   {  this->icont().reverse(); }    
+   {  this->icont().reverse(); }   
 
    //! Effects: Removes all the elements that compare equal to value.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Linear time. It performs exactly size() comparisons for equality.
-   //! 
+   //!
    //! Note: 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)
@@ -1036,11 +1036,11 @@ class list
 
    //! Effects: Removes all the elements for which a specified
    //!   predicate is satisfied.
-   //! 
+   //!
    //! Throws: If pred throws.
-   //! 
+   //!
    //! Complexity: Linear time. It performs exactly size() calls to the predicate.
-   //! 
+   //!
    //! Note: The relative order of elements that are not removed is unchanged,
    //!   and iterators to elements that are not removed remain valid.
    template 
@@ -1050,25 +1050,25 @@ class list
       this->icont().remove_and_dispose_if(Predicate(pred), Destroyer(this->node_alloc()));
    }
 
-   //! Effects: Removes adjacent duplicate elements or adjacent 
+   //! Effects: Removes adjacent duplicate elements or adjacent
    //!   elements that are equal from the list.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Linear time (size()-1 comparisons calls to pred()).
-   //! 
+   //!
    //! Note: 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());  }
 
-   //! Effects: Removes adjacent duplicate elements or adjacent 
+   //! Effects: Removes adjacent duplicate elements or adjacent
    //!   elements that satisfy some binary predicate from the list.
-   //! 
+   //!
    //! Throws: If pred throws.
-   //! 
+   //!
    //! Complexity: Linear time (size()-1 comparisons equality comparisons).
-   //! 
+   //!
    //! Note: The relative order of elements that are not removed is unchanged,
    //!   and iterators to elements that are not removed remain valid.
    template 
@@ -1078,15 +1078,15 @@ class list
       this->icont().unique_and_dispose(Predicate(binary_pred), Destroyer(this->node_alloc()));
    }
 
-   //! Requires: The lists x and *this must be distinct. 
+   //! Requires: The lists x and *this must be distinct.
    //!
    //! Effects: This function removes all of x's elements and inserts them
-   //!   in order into *this according to std::less. 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. 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.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: This function is linear time: it performs at most
    //!   size() + x.size() - 1 comparisons.
    void merge(list& x)
@@ -1094,17 +1094,17 @@ class list
 
    //! Requires: 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.
+   //!
    //! Effects: 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.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: This function is linear time: it performs at most
    //!   size() + x.size() - 1 comparisons.
-   //! 
+   //!
    //! Note: Iterators and references to *this are not invalidated.
    template 
    void merge(list &x, StrictWeakOrdering comp)
@@ -1118,25 +1118,25 @@ class list
       }
    }
 
-   //! Effects: This function sorts the list *this according to std::less. 
+   //! Effects: This function sorts the list *this according to std::less.
    //!   The sort is stable, that is, the relative order of equivalent elements is preserved.
    //!
    //! Throws: Nothing.
    //!
    //! Notes: Iterators and references are not invalidated.
-   //!   
+   //!  
    //! Complexity: The number of comparisons is approximately N log N, where N
    //!   is the list's size.
    void sort()
    {  this->sort(value_less());  }
 
-   //! Effects: This function sorts the list *this according to std::less. 
+   //! Effects: This function sorts the list *this according to std::less.
    //!   The sort is stable, that is, the relative order of equivalent elements is preserved.
-   //! 
+   //!
    //! Throws: Nothing.
    //!
    //! Notes: Iterators and references are not invalidated.
-   //! 
+   //!
    //! Complexity: The number of comparisons is approximately N log N, where N
    //!   is the list's size.
    template 
@@ -1151,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)
@@ -1251,10 +1251,10 @@ class list
    {  this->priv_create_and_insert_nodes(p, first, last);   }
 
    template
-   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();
 
@@ -1328,25 +1328,25 @@ inline bool operator<(const list& x,
 }
 
 template 
-inline bool operator!=(const list& x, const list& y) 
+inline bool operator!=(const list& x, const list& y)
 {
   return !(x == y);
 }
 
 template 
-inline bool operator>(const list& x, const list& y) 
+inline bool operator>(const list& x, const list& y)
 {
   return y < x;
 }
 
 template 
-inline bool operator<=(const list& x, const list& y) 
+inline bool operator<=(const list& x, const list& y)
 {
   return !(y < x);
 }
 
 template 
-inline bool operator>=(const list& x, const list& y) 
+inline bool operator>=(const list& x, const list& y)
 {
   return !(x < y);
 }
diff --git a/include/boost/container/map.hpp b/include/boost/container/map.hpp
index b22e794..91cbd35 100644
--- a/include/boost/container/map.hpp
+++ b/include/boost/container/map.hpp
@@ -47,20 +47,20 @@ namespace container {
 /// @cond
 // Forward declarations of operators == and <, needed for friend declarations.
 template 
-inline bool operator==(const map& x, 
+inline bool operator==(const map& x,
                        const map& y);
 
 template 
-inline bool operator<(const map& x, 
+inline bool operator<(const map& x,
                       const map& y);
 /// @endcond
 
-//! A map is a kind of associative container that supports unique keys (contains at 
-//! most one of each key value) and provides for fast retrieval of values of another 
+//! A map is a kind of associative container that supports unique keys (contains at
+//! most one of each key value) and provides for fast retrieval of values of another
 //! type T based on the keys. The map class supports bidirectional iterators.
-//! 
-//! A map satisfies all of the requirements of a container and of a reversible 
-//! container and of an associative container. For a 
+//!
+//! A map satisfies all of the requirements of a container and of a reversible
+//! container and of an associative container. For a
 //! map the key_type is Key and the value_type is std::pair.
 //!
 //! Pred is the ordering function for Keys (e.g. std::less).
@@ -72,15 +72,15 @@ template  >
 #else
 template 
 #endif
-class map 
+class map
 {
    /// @cond
    private:
    BOOST_COPYABLE_AND_MOVABLE(map)
-   typedef container_detail::rbtree, 
-                           container_detail::select1st< std::pair >, 
-                           Pred, 
+   typedef container_detail::rbtree,
+                           container_detail::select1st< std::pair >,
+                           Pred,
                            A> tree_t;
    tree_t m_tree;  // red-black tree representing map
 
@@ -112,7 +112,7 @@ class map
    /// @cond
    class value_compare_impl
       :  public Pred,
-         public std::binary_function 
+         public std::binary_function
    {
       friend class map;
     protected :
@@ -126,7 +126,7 @@ class map
    typedef value_compare_impl             value_compare;
 
    //! Effects: Default constructs an empty map.
-   //! 
+   //!
    //! Complexity: Constant.
    map()
       : m_tree()
@@ -135,9 +135,9 @@ class map
       BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
    }
 
-   //! Effects: Constructs an empty map using the specified comparison object 
+   //! Effects: Constructs an empty map using the specified comparison object
    //! and allocator.
-   //! 
+   //!
    //! Complexity: Constant.
    explicit map(const Pred& comp,
                 const allocator_type& a = allocator_type())
@@ -147,41 +147,41 @@ class map
       BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
    }
 
-   //! Effects: Constructs an empty map using the specified comparison object and 
+   //! Effects: Constructs an empty map using the specified comparison object and
    //! allocator, and inserts elements from the range [first ,last ).
-   //! 
-   //! Complexity: Linear in N if the range [first ,last ) is already sorted using 
+   //!
+   //! Complexity: Linear in N if the range [first ,last ) is already sorted using
    //! comp and otherwise N logN, where N is last - first.
    template 
    map(InputIterator first, InputIterator last, const Pred& comp = Pred(),
          const allocator_type& a = allocator_type())
-      : m_tree(first, last, comp, a, true) 
+      : m_tree(first, last, comp, a, true)
    {
       //Allocator type must be std::pair
       BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
    }
 
-   //! Effects: Constructs an empty map using the specified comparison object and 
+   //! Effects: Constructs an empty map using the specified comparison object and
    //! allocator, and inserts elements from the ordered unique range [first ,last). This function
    //! is more efficient than the normal range creation for ordered ranges.
    //!
    //! Requires: [first ,last) must be ordered according to the predicate and must be
    //! unique values.
-   //! 
+   //!
    //! Complexity: Linear in N.
    template 
    map( ordered_unique_range_t, InputIterator first, InputIterator last
       , const Pred& comp = Pred(), const allocator_type& a = allocator_type())
-      : m_tree(ordered_range, first, last, comp, a) 
+      : m_tree(ordered_range, first, last, comp, a)
    {
       //Allocator type must be std::pair
       BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
    }
 
    //! Effects: Copy constructs a map.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
-   map(const map& x) 
+   map(const map& x)
       : m_tree(x.m_tree)
    {
       //Allocator type must be std::pair
@@ -189,11 +189,11 @@ class map
    }
 
    //! Effects: Move constructs a map. Constructs *this using x's resources.
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Postcondition: x is emptied.
-   map(BOOST_RV_REF(map) x) 
+   map(BOOST_RV_REF(map) x)
       : m_tree(boost::move(x.m_tree))
    {
       //Allocator type must be std::pair
@@ -201,9 +201,9 @@ class map
    }
 
    //! Effects: Copy constructs a map using the specified allocator.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
-   map(const map& x, const allocator_type &a) 
+   map(const map& x, const allocator_type &a)
       : m_tree(x.m_tree, a)
    {
       //Allocator type must be std::pair
@@ -214,9 +214,9 @@ class map
    //!                 Constructs *this using x's resources.
    //!
    //! Complexity: Constant if x == x.get_allocator(), linear otherwise.
-   //! 
+   //!
    //! Postcondition: x is emptied.
-   map(BOOST_RV_REF(map) x, const allocator_type &a) 
+   map(BOOST_RV_REF(map) x, const allocator_type &a)
       : m_tree(boost::move(x.m_tree), a)
    {
       //Allocator type must be std::pair
@@ -224,184 +224,184 @@ class map
    }
 
    //! Effects: Makes *this a copy of x.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
    map& operator=(BOOST_COPY_ASSIGN_REF(map) x)
    {  m_tree = x.m_tree;   return *this;  }
 
    //! Effects: this->swap(x.get()).
-   //! 
+   //!
    //! Complexity: Constant.
    map& operator=(BOOST_RV_REF(map) x)
    {  m_tree = boost::move(x.m_tree);   return *this;  }
 
    //! Effects: Returns the comparison object out
    //!   of which a was constructed.
-   //! 
+   //!
    //! Complexity: Constant.
-   key_compare key_comp() const 
+   key_compare key_comp() const
    { return m_tree.key_comp(); }
 
    //! Effects: Returns an object of value_compare constructed out
    //!   of the comparison object.
-   //! 
+   //!
    //! Complexity: Constant.
-   value_compare value_comp() const 
+   value_compare value_comp() const
    { return value_compare(m_tree.key_comp()); }
 
    //! Effects: Returns a copy of the Allocator that
    //!   was passed to the object's constructor.
-   //! 
+   //!
    //! Complexity: Constant.
-   allocator_type get_allocator() const 
+   allocator_type get_allocator() const
    { return m_tree.get_allocator(); }
 
-   const stored_allocator_type &get_stored_allocator() const 
+   const stored_allocator_type &get_stored_allocator() const
    { return m_tree.get_stored_allocator(); }
 
    stored_allocator_type &get_stored_allocator()
    { return m_tree.get_stored_allocator(); }
 
    //! Effects: Returns an iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   iterator begin() 
+   iterator begin()
    { return m_tree.begin(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator begin() const 
+   const_iterator begin() const
    { return this->cbegin(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cbegin() const 
+   const_iterator cbegin() const
    { return m_tree.begin(); }
 
    //! Effects: Returns an iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   iterator end() 
+   iterator end()
    { return m_tree.end(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator end() const 
+   const_iterator end() const
    { return this->cend(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cend() const 
+   const_iterator cend() const
    { return m_tree.end(); }
 
-   //! Effects: Returns a reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reverse_iterator rbegin() 
+   reverse_iterator rbegin()
    { return m_tree.rbegin(); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator rbegin() const 
+   const_reverse_iterator rbegin() const
    { return this->crbegin(); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin() const 
+   const_reverse_iterator crbegin() const
    { return m_tree.rbegin(); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reverse_iterator rend() 
+   reverse_iterator rend()
    { return m_tree.rend(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator rend() const 
+   const_reverse_iterator rend() const
    { return this->crend(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crend() const 
+   const_reverse_iterator crend() const
    { return m_tree.rend(); }
 
    //! Effects: Returns true if the container contains no elements.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   bool empty() const 
+   bool empty() const
    { return m_tree.empty(); }
 
    //! Effects: Returns the number of the elements contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type size() const 
+   size_type size() const
    { return m_tree.size(); }
 
    //! Effects: Returns the largest possible size of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type max_size() const 
+   size_type max_size() const
    { return m_tree.max_size(); }
 
    #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   //! Effects: If there is no key equivalent to x in the map, inserts 
+   //! Effects: If there is no key equivalent to x in the map, inserts
    //! value_type(x, T()) into the map.
-   //! 
+   //!
    //! Returns: A reference to the mapped_type corresponding to x in *this.
-   //! 
+   //!
    //! Complexity: Logarithmic.
    mapped_type& operator[](const key_type &k);
 
-   //! Effects: If there is no key equivalent to x in the map, inserts 
+   //! Effects: If there is no key equivalent to x in the map, inserts
    //! value_type(boost::move(x), T()) into the map (the key is move-constructed)
-   //! 
+   //!
    //! Returns: A reference to the mapped_type corresponding to x in *this.
-   //! 
+   //!
    //! Complexity: Logarithmic.
    mapped_type& operator[](key_type &&k);
    #else
@@ -440,62 +440,62 @@ class map
    void swap(map& x)
    { m_tree.swap(x.m_tree); }
 
-   //! Effects: Inserts x if and only if there is no element in the container 
+   //! Effects: Inserts x if and only if there is no element in the container
    //!   with key equivalent to the key of x.
    //!
-   //! Returns: The bool component of the returned pair is true if and only 
+   //! Returns: The bool component of the returned pair is true if and only
    //!   if the insertion takes place, and the iterator component of the pair
    //!   points to the element with key equivalent to the key of x.
    //!
    //! Complexity: Logarithmic.
-   std::pair insert(const value_type& x) 
+   std::pair insert(const value_type& x)
    { return m_tree.insert_unique(x); }
 
-   //! Effects: Inserts a new value_type created from the pair if and only if 
+   //! Effects: Inserts a new value_type created from the pair if and only if
    //! there is no element in the container  with key equivalent to the key of x.
    //!
-   //! Returns: The bool component of the returned pair is true if and only 
+   //! Returns: The bool component of the returned pair is true if and only
    //!   if the insertion takes place, and the iterator component of the pair
    //!   points to the element with key equivalent to the key of x.
    //!
    //! Complexity: Logarithmic.
-   std::pair insert(const nonconst_value_type& x) 
+   std::pair insert(const nonconst_value_type& x)
    { return m_tree.insert_unique(x); }
 
    //! Effects: Inserts a new value_type move constructed from the pair if and
    //! only if there is no element in the container with key equivalent to the key of x.
    //!
-   //! Returns: The bool component of the returned pair is true if and only 
+   //! Returns: The bool component of the returned pair is true if and only
    //!   if the insertion takes place, and the iterator component of the pair
    //!   points to the element with key equivalent to the key of x.
    //!
    //! Complexity: Logarithmic.
-   std::pair insert(BOOST_RV_REF(nonconst_value_type) x) 
+   std::pair insert(BOOST_RV_REF(nonconst_value_type) x)
    { return m_tree.insert_unique(boost::move(x)); }
 
    //! Effects: Inserts a new value_type move constructed from the pair if and
    //! only if there is no element in the container with key equivalent to the key of x.
    //!
-   //! Returns: The bool component of the returned pair is true if and only 
+   //! Returns: The bool component of the returned pair is true if and only
    //!   if the insertion takes place, and the iterator component of the pair
    //!   points to the element with key equivalent to the key of x.
    //!
    //! Complexity: Logarithmic.
-   std::pair insert(BOOST_RV_REF(nonconst_impl_value_type) x) 
+   std::pair insert(BOOST_RV_REF(nonconst_impl_value_type) x)
    { return m_tree.insert_unique(boost::move(x)); }
 
-   //! Effects: Move constructs a new value from x if and only if there is 
+   //! Effects: Move constructs a new value from x if and only if there is
    //!   no element in the container with key equivalent to the key of x.
    //!
-   //! Returns: The bool component of the returned pair is true if and only 
+   //! Returns: The bool component of the returned pair is true if and only
    //!   if the insertion takes place, and the iterator component of the pair
    //!   points to the element with key equivalent to the key of x.
    //!
    //! Complexity: Logarithmic.
-   std::pair insert(BOOST_RV_REF(value_type) x) 
+   std::pair insert(BOOST_RV_REF(value_type) x)
    { return m_tree.insert_unique(boost::move(x)); }
 
-   //! Effects: Inserts a copy of x in the container if and only if there is 
+   //! Effects: Inserts a copy of x in the container if and only if there is
    //!   no element in the container with key equivalent to the key of x.
    //!   p is a hint pointing to where the insert should start to search.
    //!
@@ -507,7 +507,7 @@ class map
    iterator insert(iterator position, const value_type& x)
    { return m_tree.insert_unique(position, x); }
 
-   //! Effects: Move constructs a new value from x if and only if there is 
+   //! Effects: Move constructs a new value from x if and only if there is
    //!   no element in the container with key equivalent to the key of x.
    //!   p is a hint pointing to where the insert should start to search.
    //!
@@ -519,7 +519,7 @@ class map
    iterator insert(iterator position, BOOST_RV_REF(nonconst_value_type) x)
    { return m_tree.insert_unique(position, boost::move(x)); }
 
-   //! Effects: Move constructs a new value from x if and only if there is 
+   //! Effects: Move constructs a new value from x if and only if there is
    //!   no element in the container with key equivalent to the key of x.
    //!   p is a hint pointing to where the insert should start to search.
    //!
@@ -551,22 +551,22 @@ class map
 
    //! Requires: first, last are not iterators into *this.
    //!
-   //! Effects: inserts each element from the range [first,last) if and only 
+   //! Effects: inserts each element from the range [first,last) if and only
    //!   if there is no element with key equivalent to the key of that element.
    //!
    //! Complexity: At most N log(size()+N) (N is the distance from first to last)
    template 
-   void insert(InputIterator first, InputIterator last) 
+   void insert(InputIterator first, InputIterator last)
    {  m_tree.insert_unique(first, last);  }
 
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
    //! Effects: Inserts an object x of type T constructed with
-   //!   std::forward(args)... in the container if and only if there is 
+   //!   std::forward(args)... in the container if and only if there is
    //!   no element in the container with an equivalent key.
    //!   p is a hint pointing to where the insert should start to search.
    //!
-   //! Returns: The bool component of the returned pair is true if and only 
+   //! Returns: The bool component of the returned pair is true if and only
    //!   if the insertion takes place, and the iterator component of the pair
    //!   points to the element with key equivalent to the key of x.
    //!
@@ -577,7 +577,7 @@ class map
    {  return m_tree.emplace_unique(boost::forward(args)...); }
 
    //! Effects: Inserts an object of type T constructed with
-   //!   std::forward(args)... in the container if and only if there is 
+   //!   std::forward(args)... in the container if and only if there is
    //!   no element in the container with an equivalent key.
    //!   p is a hint pointing to where the insert should start to search.
    //!
@@ -611,11 +611,11 @@ class map
    //! Effects: Erases the element pointed to by position.
    //!
    //! Returns: Returns an iterator pointing to the element immediately
-   //!   following q prior to the element being erased. If no such element exists, 
+   //!   following q prior to the element being erased. If no such element exists,
    //!   returns end().
    //!
    //! Complexity: Amortized constant time
-   iterator erase(const_iterator position) 
+   iterator erase(const_iterator position)
    { return m_tree.erase(position); }
 
    //! Effects: Erases all elements in the container with key equivalent to x.
@@ -623,7 +623,7 @@ class map
    //! Returns: Returns the number of erased elements.
    //!
    //! Complexity: log(size()) + count(k)
-   size_type erase(const key_type& x) 
+   size_type erase(const key_type& x)
    { return m_tree.erase(x); }
 
    //! Effects: Erases all the elements in the range [first, last).
@@ -639,67 +639,67 @@ class map
    //! Postcondition: size() == 0.
    //!
    //! Complexity: linear in size().
-   void clear() 
+   void clear()
    { m_tree.clear(); }
 
    //! Returns: An iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.
-   iterator find(const key_type& x) 
+   iterator find(const key_type& x)
    { return m_tree.find(x); }
 
    //! Returns: A const_iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.
-   const_iterator find(const key_type& x) const 
+   const_iterator find(const key_type& x) const
    { return m_tree.find(x); }
 
    //! Returns: The number of elements with key equivalent to x.
    //!
    //! Complexity: log(size())+count(k)
-   size_type count(const key_type& x) const 
+   size_type count(const key_type& x) const
    {  return m_tree.find(x) == m_tree.end() ? 0 : 1;  }
 
    //! Returns: An iterator pointing to the first element with key not less
    //!   than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   iterator lower_bound(const key_type& x) 
+   iterator lower_bound(const key_type& x)
    {  return m_tree.lower_bound(x); }
 
    //! Returns: A const iterator pointing to the first element with key not
    //!   less than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   const_iterator lower_bound(const key_type& x) const 
+   const_iterator lower_bound(const key_type& x) const
    {  return m_tree.lower_bound(x); }
 
    //! Returns: An iterator pointing to the first element with key not less
    //!   than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   iterator upper_bound(const key_type& x) 
+   iterator upper_bound(const key_type& x)
    {  return m_tree.upper_bound(x); }
 
    //! Returns: A const iterator pointing to the first element with key not
    //!   less than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   const_iterator upper_bound(const key_type& x) const 
+   const_iterator upper_bound(const key_type& x) const
    {  return m_tree.upper_bound(x); }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair equal_range(const key_type& x) 
+   std::pair equal_range(const key_type& x)
    {  return m_tree.equal_range(x); }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair equal_range(const key_type& x) const 
+   std::pair equal_range(const key_type& x) const
    {  return m_tree.equal_range(x); }
 
    /// @cond
@@ -723,7 +723,7 @@ class map
       return (*i).second;
    }
 
-   mapped_type& priv_subscript(BOOST_RV_REF(key_type) mk) 
+   mapped_type& priv_subscript(BOOST_RV_REF(key_type) mk)
    {
       key_type &k = mk;
       //we can optimize this
@@ -741,37 +741,37 @@ class map
 };
 
 template 
-inline bool operator==(const map& x, 
-                       const map& y) 
+inline bool operator==(const map& x,
+                       const map& y)
    {  return x.m_tree == y.m_tree;  }
 
 template 
-inline bool operator<(const map& x, 
-                      const map& y) 
+inline bool operator<(const map& x,
+                      const map& y)
    {  return x.m_tree < y.m_tree;   }
 
 template 
-inline bool operator!=(const map& x, 
-                       const map& y) 
+inline bool operator!=(const map& x,
+                       const map& y)
    {  return !(x == y); }
 
 template 
-inline bool operator>(const map& x, 
-                      const map& y) 
+inline bool operator>(const map& x,
+                      const map& y)
    {  return y < x;  }
 
 template 
-inline bool operator<=(const map& x, 
-                       const map& y) 
+inline bool operator<=(const map& x,
+                       const map& y)
    {  return !(y < x);  }
 
 template 
-inline bool operator>=(const map& x, 
-                       const map& y) 
+inline bool operator>=(const map& x,
+                       const map& y)
    {  return !(x < y);  }
 
 template 
-inline void swap(map& x, map& y) 
+inline void swap(map& x, map& y)
    {  x.swap(y);  }
 
 /// @cond
@@ -779,11 +779,11 @@ inline void swap(map& x, map& y)
 // Forward declaration of operators < and ==, needed for friend declaration.
 
 template 
-inline bool operator==(const multimap& x, 
+inline bool operator==(const multimap& x,
                        const multimap& y);
 
 template 
-inline bool operator<(const multimap& x, 
+inline bool operator<(const multimap& x,
                       const multimap& y);
 
 }  //namespace container {
@@ -800,14 +800,14 @@ namespace container {
 
 /// @endcond
 
-//! A multimap is a kind of associative container that supports equivalent keys 
-//! (possibly containing multiple copies of the same key value) and provides for 
+//! A multimap is a kind of associative container that supports equivalent keys
+//! (possibly containing multiple copies of the same key value) and provides for
 //! fast retrieval of values of another type T based on the keys. The multimap class
 //! supports bidirectional iterators.
-//! 
-//! A multimap satisfies all of the requirements of a container and of a reversible 
-//! container and of an associative container. For a 
-//! map the key_type is Key and the value_type is std::pair. 
+//!
+//! A multimap satisfies all of the requirements of a container and of a reversible
+//! container and of an associative container. For a
+//! map the key_type is Key and the value_type is std::pair.
 //!
 //! Pred is the ordering function for Keys (e.g. std::less).
 //!
@@ -818,15 +818,15 @@ template  >
 #else
 template 
 #endif
-class multimap 
+class multimap
 {
    /// @cond
    private:
    BOOST_COPYABLE_AND_MOVABLE(multimap)
-   typedef container_detail::rbtree, 
-                           container_detail::select1st< std::pair >, 
-                           Pred, 
+   typedef container_detail::rbtree,
+                           container_detail::select1st< std::pair >,
+                           Pred,
                            A> tree_t;
    tree_t m_tree;  // red-black tree representing map
    typedef typename container_detail::
@@ -859,7 +859,7 @@ class multimap
    /// @cond
    class value_compare_impl
       :  public Pred,
-         public std::binary_function 
+         public std::binary_function
    {
       friend class multimap;
     protected :
@@ -873,7 +873,7 @@ class multimap
    typedef value_compare_impl                      value_compare;
 
    //! Effects: Default constructs an empty multimap.
-   //! 
+   //!
    //! Complexity: Constant.
    multimap()
       : m_tree()
@@ -884,7 +884,7 @@ class multimap
 
    //! Effects: Constructs an empty multimap using the specified comparison
    //!   object and allocator.
-   //! 
+   //!
    //! Complexity: Constant.
    explicit multimap(const Pred& comp, const allocator_type& a = allocator_type())
       : m_tree(comp, a)
@@ -895,36 +895,36 @@ class multimap
 
    //! Effects: Constructs an empty multimap using the specified comparison object
    //!   and allocator, and inserts elements from the range [first ,last ).
-   //! 
-   //! Complexity: Linear in N if the range [first ,last ) is already sorted using 
+   //!
+   //! Complexity: Linear in N if the range [first ,last ) is already sorted using
    //! comp and otherwise N logN, where N is last - first.
    template 
    multimap(InputIterator first, InputIterator last,
             const Pred& comp = Pred(),
             const allocator_type& a = allocator_type())
-      : m_tree(first, last, comp, a, false) 
+      : m_tree(first, last, comp, a, false)
    {
       //Allocator type must be std::pair
       BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
    }
 
-   //! Effects: Constructs an empty multimap using the specified comparison object and 
+   //! Effects: Constructs an empty multimap using the specified comparison object and
    //! allocator, and inserts elements from the ordered range [first ,last). This function
    //! is more efficient than the normal range creation for ordered ranges.
    //!
    //! Requires: [first ,last) must be ordered according to the predicate.
-   //! 
+   //!
    //! Complexity: Linear in N.
    template 
    multimap(ordered_range_t ordered_range, InputIterator first, InputIterator last, const Pred& comp = Pred(),
          const allocator_type& a = allocator_type())
-      : m_tree(ordered_range, first, last, comp, a) 
+      : m_tree(ordered_range, first, last, comp, a)
    {}
 
    //! Effects: Copy constructs a multimap.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
-   multimap(const multimap& x) 
+   multimap(const multimap& x)
       : m_tree(x.m_tree)
    {
       //Allocator type must be std::pair
@@ -932,11 +932,11 @@ class multimap
    }
 
    //! Effects: Move constructs a multimap. Constructs *this using x's resources.
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Postcondition: x is emptied.
-   multimap(BOOST_RV_REF(multimap) x) 
+   multimap(BOOST_RV_REF(multimap) x)
       : m_tree(boost::move(x.m_tree))
    {
       //Allocator type must be std::pair
@@ -944,9 +944,9 @@ class multimap
    }
 
    //! Effects: Copy constructs a multimap.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
-   multimap(const multimap& x, const allocator_type &a) 
+   multimap(const multimap& x, const allocator_type &a)
       : m_tree(x.m_tree, a)
    {
       //Allocator type must be std::pair
@@ -956,7 +956,7 @@ class multimap
    //! Effects: Move constructs a multimap using the specified allocator.
    //!                 Constructs *this using x's resources.
    //! Complexity: Constant if a == x.get_allocator(), linear otherwise.
-   //! 
+   //!
    //! Postcondition: x is emptied.
    multimap(BOOST_RV_REF(multimap) x, const allocator_type &a)
       : m_tree(boost::move(x.m_tree), a)
@@ -966,168 +966,168 @@ class multimap
    }
 
    //! Effects: Makes *this a copy of x.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
-   multimap& operator=(BOOST_COPY_ASSIGN_REF(multimap) x) 
+   multimap& operator=(BOOST_COPY_ASSIGN_REF(multimap) x)
    {  m_tree = x.m_tree;   return *this;  }
 
    //! Effects: this->swap(x.get()).
-   //! 
+   //!
    //! Complexity: Constant.
-   multimap& operator=(BOOST_RV_REF(multimap) x) 
+   multimap& operator=(BOOST_RV_REF(multimap) x)
    {  m_tree = boost::move(x.m_tree);   return *this;  }
 
    //! Effects: Returns the comparison object out
    //!   of which a was constructed.
-   //! 
+   //!
    //! Complexity: Constant.
-   key_compare key_comp() const 
+   key_compare key_comp() const
    { return m_tree.key_comp(); }
 
    //! Effects: Returns an object of value_compare constructed out
    //!   of the comparison object.
-   //! 
+   //!
    //! Complexity: Constant.
-   value_compare value_comp() const 
+   value_compare value_comp() const
    { return value_compare(m_tree.key_comp()); }
 
    //! Effects: Returns a copy of the Allocator that
    //!   was passed to the object's constructor.
-   //! 
+   //!
    //! Complexity: Constant.
-   allocator_type get_allocator() const 
+   allocator_type get_allocator() const
    { return m_tree.get_allocator(); }
 
-   const stored_allocator_type &get_stored_allocator() const 
+   const stored_allocator_type &get_stored_allocator() const
    { return m_tree.get_stored_allocator(); }
 
    stored_allocator_type &get_stored_allocator()
    { return m_tree.get_stored_allocator(); }
 
    //! Effects: Returns an iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   iterator begin() 
+   iterator begin()
    { return m_tree.begin(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator begin() const 
+   const_iterator begin() const
    { return this->cbegin(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cbegin() const 
+   const_iterator cbegin() const
    { return m_tree.begin(); }
 
    //! Effects: Returns an iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   iterator end() 
+   iterator end()
    { return m_tree.end(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator end() const 
+   const_iterator end() const
    { return this->cend(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cend() const 
+   const_iterator cend() const
    { return m_tree.end(); }
 
-   //! Effects: Returns a reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reverse_iterator rbegin() 
+   reverse_iterator rbegin()
    { return m_tree.rbegin(); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator rbegin() const 
+   const_reverse_iterator rbegin() const
    { return this->crbegin(); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin() const 
+   const_reverse_iterator crbegin() const
    { return m_tree.rbegin(); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reverse_iterator rend() 
+   reverse_iterator rend()
    { return m_tree.rend(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator rend() const 
+   const_reverse_iterator rend() const
    { return this->crend(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crend() const 
+   const_reverse_iterator crend() const
    { return m_tree.rend(); }
 
    //! Effects: Returns true if the container contains no elements.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   bool empty() const 
+   bool empty() const
    { return m_tree.empty(); }
 
    //! Effects: Returns the number of the elements contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type size() const 
+   size_type size() const
    { return m_tree.size(); }
 
    //! Effects: Returns the largest possible size of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type max_size() const 
+   size_type max_size() const
    { return m_tree.max_size(); }
 
    //! Effects: Swaps the contents of *this and x.
@@ -1139,31 +1139,31 @@ class multimap
    { m_tree.swap(x.m_tree); }
 
    //! Effects: Inserts x and returns the iterator pointing to the
-   //!   newly inserted element. 
+   //!   newly inserted element.
    //!
    //! Complexity: Logarithmic.
-   iterator insert(const value_type& x) 
+   iterator insert(const value_type& x)
    { return m_tree.insert_equal(x); }
 
-   //! Effects: Inserts a new value constructed from x and returns 
-   //!   the iterator pointing to the newly inserted element. 
+   //! Effects: Inserts a new value constructed from x and returns
+   //!   the iterator pointing to the newly inserted element.
    //!
    //! Complexity: Logarithmic.
-   iterator insert(const nonconst_value_type& x) 
+   iterator insert(const nonconst_value_type& x)
    { return m_tree.insert_equal(x); }
 
-   //! Effects: Inserts a new value move-constructed from x and returns 
-   //!   the iterator pointing to the newly inserted element. 
+   //! Effects: Inserts a new value move-constructed from x and returns
+   //!   the iterator pointing to the newly inserted element.
    //!
    //! Complexity: Logarithmic.
-   iterator insert(BOOST_RV_REF(nonconst_value_type) x) 
+   iterator insert(BOOST_RV_REF(nonconst_value_type) x)
    { return m_tree.insert_equal(boost::move(x)); }
 
-   //! Effects: Inserts a new value move-constructed from x and returns 
-   //!   the iterator pointing to the newly inserted element. 
+   //! Effects: Inserts a new value move-constructed from x and returns
+   //!   the iterator pointing to the newly inserted element.
    //!
    //! Complexity: Logarithmic.
-   iterator insert(BOOST_RV_REF(nonconst_impl_value_type) x) 
+   iterator insert(BOOST_RV_REF(nonconst_impl_value_type) x)
    { return m_tree.insert_equal(boost::move(x)); }
 
    //! Effects: Inserts a copy of x in the container.
@@ -1216,7 +1216,7 @@ class multimap
    //!
    //! Complexity: At most N log(size()+N) (N is the distance from first to last)
    template 
-   void insert(InputIterator first, InputIterator last) 
+   void insert(InputIterator first, InputIterator last)
    {  m_tree.insert_equal(first, last); }
 
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1268,11 +1268,11 @@ class multimap
    //! Effects: Erases the element pointed to by position.
    //!
    //! Returns: Returns an iterator pointing to the element immediately
-   //!   following q prior to the element being erased. If no such element exists, 
+   //!   following q prior to the element being erased. If no such element exists,
    //!   returns end().
    //!
    //! Complexity: Amortized constant time
-   iterator erase(const_iterator position) 
+   iterator erase(const_iterator position)
    { return m_tree.erase(position); }
 
    //! Effects: Erases all elements in the container with key equivalent to x.
@@ -1280,7 +1280,7 @@ class multimap
    //! Returns: Returns the number of erased elements.
    //!
    //! Complexity: log(size()) + count(k)
-   size_type erase(const key_type& x) 
+   size_type erase(const key_type& x)
    { return m_tree.erase(x); }
 
    //! Effects: Erases all the elements in the range [first, last).
@@ -1296,68 +1296,68 @@ class multimap
    //! Postcondition: size() == 0.
    //!
    //! Complexity: linear in size().
-   void clear() 
+   void clear()
    { m_tree.clear(); }
 
    //! Returns: An iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.
-   iterator find(const key_type& x) 
+   iterator find(const key_type& x)
    { return m_tree.find(x); }
 
    //! Returns: A const iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.
-   const_iterator find(const key_type& x) const 
+   const_iterator find(const key_type& x) const
    { return m_tree.find(x); }
 
    //! Returns: The number of elements with key equivalent to x.
    //!
    //! Complexity: log(size())+count(k)
-   size_type count(const key_type& x) const 
+   size_type count(const key_type& x) const
    { return m_tree.count(x); }
 
    //! Returns: An iterator pointing to the first element with key not less
    //!   than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   iterator lower_bound(const key_type& x) 
+   iterator lower_bound(const key_type& x)
    {return m_tree.lower_bound(x); }
 
    //! Returns: A const iterator pointing to the first element with key not
    //!   less than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   const_iterator lower_bound(const key_type& x) const 
+   const_iterator lower_bound(const key_type& x) const
    {  return m_tree.lower_bound(x);  }
 
    //! Returns: An iterator pointing to the first element with key not less
    //!   than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   iterator upper_bound(const key_type& x) 
+   iterator upper_bound(const key_type& x)
    {  return m_tree.upper_bound(x); }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair equal_range(const key_type& x) 
+   std::pair equal_range(const key_type& x)
    {  return m_tree.equal_range(x);   }
 
    //! Returns: A const iterator pointing to the first element with key not
    //!   less than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   const_iterator upper_bound(const key_type& x) const 
+   const_iterator upper_bound(const key_type& x) const
    {  return m_tree.upper_bound(x); }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair 
-      equal_range(const key_type& x) const 
+   std::pair
+      equal_range(const key_type& x) const
    {  return m_tree.equal_range(x);   }
 
    /// @cond
@@ -1372,37 +1372,37 @@ class multimap
 };
 
 template 
-inline bool operator==(const multimap& x, 
-                       const multimap& y) 
+inline bool operator==(const multimap& x,
+                       const multimap& y)
 {  return x.m_tree == y.m_tree;  }
 
 template 
-inline bool operator<(const multimap& x, 
-                      const multimap& y) 
+inline bool operator<(const multimap& x,
+                      const multimap& y)
 {  return x.m_tree < y.m_tree;   }
 
 template 
-inline bool operator!=(const multimap& x, 
-                       const multimap& y) 
+inline bool operator!=(const multimap& x,
+                       const multimap& y)
 {  return !(x == y);  }
 
 template 
-inline bool operator>(const multimap& x, 
-                      const multimap& y) 
+inline bool operator>(const multimap& x,
+                      const multimap& y)
 {  return y < x;  }
 
 template 
-inline bool operator<=(const multimap& x, 
-                       const multimap& y) 
+inline bool operator<=(const multimap& x,
+                       const multimap& y)
 {  return !(y < x);  }
 
 template 
-inline bool operator>=(const multimap& x, 
-                       const multimap& y) 
+inline bool operator>=(const multimap& x,
+                       const multimap& y)
 {  return !(x < y);  }
 
 template 
-inline void swap(multimap& x, multimap& y) 
+inline void swap(multimap& x, multimap& y)
 {  x.swap(y);  }
 
 /// @cond
diff --git a/include/boost/container/scoped_allocator.hpp b/include/boost/container/scoped_allocator.hpp
index e2f72c6..d7115d8 100644
--- a/include/boost/container/scoped_allocator.hpp
+++ b/include/boost/container/scoped_allocator.hpp
@@ -75,36 +75,36 @@ struct allocator_arg_t{};
 //!
 static const allocator_arg_t allocator_arg = allocator_arg_t();
 
-//! Remark: if a specialization is derived from true_type, indicates that T may be constructed 
-//! with an allocator as its last constructor argument.  Ideally, all constructors of T (including the 
-//! copy and move constructors) should have a variant that accepts a final argument of 
-//! allocator_type. 
+//! Remark: if a specialization is derived from true_type, indicates that T may be constructed
+//! with an allocator as its last constructor argument.  Ideally, all constructors of T (including the
+//! copy and move constructors) should have a variant that accepts a final argument of
+//! allocator_type.
 //!
-//! Requires: if a specialization is derived from true_type, T must have a nested type, 
-//! allocator_type and at least one constructor for which allocator_type is the last 
-//! parameter.  If not all constructors of T can be called with a final allocator_type argument, 
-//! and if T is used in a context where a container must call such a constructor, then the program is 
-//! ill-formed. 
+//! Requires: if a specialization is derived from true_type, T must have a nested type,
+//! allocator_type and at least one constructor for which allocator_type is the last
+//! parameter.  If not all constructors of T can be called with a final allocator_type argument,
+//! and if T is used in a context where a container must call such a constructor, then the program is
+//! ill-formed.
 //!
-//! [Example: 
-//!  template  >   
-//!  class Z { 
-//!    public: 
-//!      typedef A allocator_type; 
+//! [Example:
+//!  template  >  
+//!  class Z {
+//!    public:
+//!      typedef A allocator_type;
 //!
-//!    // Default constructor with optional allocator suffix 
-//!    Z(const allocator_type& a = allocator_type()); 
+//!    // Default constructor with optional allocator suffix
+//!    Z(const allocator_type& a = allocator_type());
 //!
-//!    // Copy constructor and allocator-extended copy constructor 
-//!    Z(const Z& zz); 
-//!    Z(const Z& zz, const allocator_type& a); 
-//! }; 
+//!    // Copy constructor and allocator-extended copy constructor
+//!    Z(const Z& zz);
+//!    Z(const Z& zz, const allocator_type& a);
+//! };
 //!
-//! // Specialize trait for class template Z 
-//! template  > 
-//! struct constructible_with_allocator_suffix >  
+//! // Specialize trait for class template Z
+//! template  >
+//! struct constructible_with_allocator_suffix > 
 //!      : ::boost::true_type { };
-//! -- end example] 
+//! -- end example]
 //!
 //! Note: This trait is a workaround inspired by "N2554: The Scoped Allocator Model (Rev 2)"
 //! (Pablo Halpern, 2008-02-29) to backport the scoped allocator model to C++03, as
@@ -117,44 +117,44 @@ static const allocator_arg_t allocator_arg = allocator_arg_t();
 template 
 struct constructible_with_allocator_suffix
    : ::boost::false_type
-{}; 
+{};
 
-//! Remark: if a specialization is derived from true_type, indicates that T may be constructed 
-//! with allocator_arg and T::allocator_type as its first two constructor arguments.  
-//! Ideally, all constructors of T (including the copy and move constructors) should have a variant 
+//! Remark: if a specialization is derived from true_type, indicates that T may be constructed
+//! with allocator_arg and T::allocator_type as its first two constructor arguments. 
+//! Ideally, all constructors of T (including the copy and move constructors) should have a variant
 //! that accepts these two initial arguments.
 //!
-//! Requires: if a specialization is derived from true_type, T must have a nested type, 
-//! allocator_type and at least one constructor for which allocator_arg_t is the first 
-//! parameter and allocator_type is the second parameter.  If not all constructors of T can be 
-//! called with these initial arguments, and if T is used in a context where a container must call such 
+//! Requires: if a specialization is derived from true_type, T must have a nested type,
+//! allocator_type and at least one constructor for which allocator_arg_t is the first
+//! parameter and allocator_type is the second parameter.  If not all constructors of T can be
+//! called with these initial arguments, and if T is used in a context where a container must call such
 //! a constructor, then the program is ill-formed.
 //!
-//! [Example: 
-//! template  > 
-//! class Y { 
-//!    public: 
-//!       typedef A allocator_type; 
-//!  
-//!       // Default constructor with and allocator-extended default constructor 
-//!       Y(); 
-//!       Y(allocator_arg_t, const allocator_type& a); 
-//!  
-//!       // Copy constructor and allocator-extended copy constructor 
-//!       Y(const Y& yy); 
-//!       Y(allocator_arg_t, const allocator_type& a, const Y& yy); 
-//!  
-//!       // Variadic constructor and allocator-extended variadic constructor 
-//!       template Y(Args&& args...); 
-//!       template  
-//!       Y(allocator_arg_t, const allocator_type& a, Args&&... args); 
-//! }; 
-//!  
-//! // Specialize trait for class template Y 
-//! template  > 
-//! struct constructible_with_allocator_prefix >  
-//!       : ::boost::true_type { }; 
-//!  
+//! [Example:
+//! template  >
+//! class Y {
+//!    public:
+//!       typedef A allocator_type;
+//! 
+//!       // Default constructor with and allocator-extended default constructor
+//!       Y();
+//!       Y(allocator_arg_t, const allocator_type& a);
+//! 
+//!       // Copy constructor and allocator-extended copy constructor
+//!       Y(const Y& yy);
+//!       Y(allocator_arg_t, const allocator_type& a, const Y& yy);
+//! 
+//!       // Variadic constructor and allocator-extended variadic constructor
+//!       template Y(Args&& args...);
+//!       template 
+//!       Y(allocator_arg_t, const allocator_type& a, Args&&... args);
+//! };
+//! 
+//! // Specialize trait for class template Y
+//! template  >
+//! struct constructible_with_allocator_prefix > 
+//!       : ::boost::true_type { };
+//! 
 //! -- end example]
 //!
 //! Note: This trait is a workaround inspired by "N2554: The Scoped Allocator Model (Rev 2)"
@@ -166,7 +166,7 @@ struct constructible_with_allocator_suffix
 //! (when BOOST_NO_SFINAE_EXPR is NOT defined), this trait is ignored and C++11 rules will be used
 //! to detect if a type should be constructed with suffix or prefix allocator arguments.
 template 
-struct constructible_with_allocator_prefix 
+struct constructible_with_allocator_prefix
     : ::boost::false_type
 {};
 
@@ -201,12 +201,12 @@ struct uses_allocator_imp
 
 ///@endcond
 
-//! Remark: Automatically detects if T has a nested allocator_type that is convertible from 
-//! Alloc. Meets the BinaryTypeTrait requirements ([meta.rqmts] 20.4.1). A program may 
+//! Remark: Automatically detects if T has a nested allocator_type that is convertible from
+//! Alloc. Meets the BinaryTypeTrait requirements ([meta.rqmts] 20.4.1). A program may
 //! specialize this type to derive from true_type for a T of user-defined type if T does not
-//! have a nested allocator_type but is nonetheless constructible using the specified Alloc. 
+//! have a nested allocator_type but is nonetheless constructible using the specified Alloc.
 //!
-//! Result: derived from true_type if Convertible and 
+//! Result: derived from true_type if Convertible and
 //! derived from false_type otherwise.
 template 
 struct uses_allocator
@@ -340,7 +340,7 @@ namespace container_detail {
    //!
 
    //Generate N+1 template parameters so that we can specialize N
-   template::value
          >
    {};
 
    //Finally just inherit from the implementation to define he trait
-   template 
    {};
 /*
-   template 
    {};
 /*
-   template < class T 
+   template < class T
             , class InnerAlloc
             BOOST_PP_ENUM_TRAILING( BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
                                   , BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT
@@ -954,7 +954,7 @@ class scoped_allocator_adaptor_base
    scoped_allocator_adaptor_base(internal_type_t, BOOST_FWD_REF(OuterA2) outerAlloc, const inner_allocator_type &)
       : outer_allocator_type(::boost::forward(outerAlloc))
       {}
-  
+ 
    public:
    scoped_allocator_adaptor_base &operator=(BOOST_COPY_ASSIGN_REF(scoped_allocator_adaptor_base) other)
    {
@@ -991,36 +991,36 @@ class scoped_allocator_adaptor_base
    #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
 
    //! This class is a C++03-compatible implementation of std::scoped_allocator_adaptor.
-   //! The class template scoped_allocator_adaptor is an allocator template that specifies 
-   //! the memory resource (the outer allocator) to be used by a container (as any other 
-   //! allocator does) and also specifies an inner allocator resource to be passed to 
+   //! The class template scoped_allocator_adaptor is an allocator template that specifies
+   //! the memory resource (the outer allocator) to be used by a container (as any other
+   //! allocator does) and also specifies an inner allocator resource to be passed to
    //! the constructor of every element within the container.
    //!
-   //! This adaptor is 
-   //! instantiated with one outer and zero or more inner allocator types. If 
-   //! instantiated with only one allocator type, the inner allocator becomes the 
-   //! scoped_allocator_adaptor itself, thus using the same allocator resource for the 
-   //! container and every element within the container and, if the elements themselves 
-   //! are containers, each of their elements recursively. If instantiated with more than 
+   //! This adaptor is
+   //! instantiated with one outer and zero or more inner allocator types. If
+   //! instantiated with only one allocator type, the inner allocator becomes the
+   //! scoped_allocator_adaptor itself, thus using the same allocator resource for the
+   //! container and every element within the container and, if the elements themselves
+   //! are containers, each of their elements recursively. If instantiated with more than
    //! one allocator, the first allocator is the outer allocator for use by the container,
-   //! the second allocator is passed to the constructors of the container's elements, 
-   //! and, if the elements themselves are containers, the third allocator is passed to 
-   //! the elements' elements, and so on. If containers are nested to a depth greater 
-   //! than the number of allocators, the last allocator is used repeatedly, as in the 
-   //! single-allocator case, for any remaining recursions. 
+   //! the second allocator is passed to the constructors of the container's elements,
+   //! and, if the elements themselves are containers, the third allocator is passed to
+   //! the elements' elements, and so on. If containers are nested to a depth greater
+   //! than the number of allocators, the last allocator is used repeatedly, as in the
+   //! single-allocator case, for any remaining recursions.
    //!
    //! [Note: The
-   //! scoped_allocator_adaptor is derived from the outer allocator type so it can be 
+   //! scoped_allocator_adaptor is derived from the outer allocator type so it can be
    //! substituted for the outer allocator type in most expressions. -end note]
    //!
-   //! In the construct member functions, `OUTERMOST(x)` is x if x does not have 
+   //! In the construct member functions, `OUTERMOST(x)` is x if x does not have
    //! an `outer_allocator()` member function and
    //! `OUTERMOST(x.outer_allocator())` otherwise; `OUTERMOST_ALLOC_TRAITS(x)` is
    //! `allocator_traits`.
    //!
    //! [Note: `OUTERMOST(x)` and
-   //! `OUTERMOST_ALLOC_TRAITS(x)` are recursive operations. It is incumbent upon 
-   //! the definition of `outer_allocator()` to ensure that the recursion terminates. 
+   //! `OUTERMOST_ALLOC_TRAITS(x)` are recursive operations. It is incumbent upon
+   //! the definition of `outer_allocator()` to ensure that the recursion terminates.
    //! It will terminate for all instantiations of scoped_allocator_adaptor. -end note]
    template 
    class scoped_allocator_adaptor
@@ -1120,7 +1120,7 @@ class scoped_allocator_adaptor
       : base_type(other.base())
       {}
 
-   //! Effects: move constructs each allocator within the adaptor with 
+   //! Effects: move constructs each allocator within the adaptor with
    //! the corresponding allocator from other.
    scoped_allocator_adaptor(BOOST_RV_REF(scoped_allocator_adaptor) other)
       : base_type(::boost::move(other.base()))
@@ -1131,7 +1131,7 @@ class scoped_allocator_adaptor
    //! Requires: OuterAlloc shall be constructible from OuterA2.
    //!
    //! Effects: initializes the OuterAlloc base class with boost::forward(outerAlloc) and inner
-   //! with innerAllocs...(hence recursively initializing each allocator within the adaptor with the 
+   //! with innerAllocs...(hence recursively initializing each allocator within the adaptor with the
    //! corresponding allocator from the argument list).
    template 
    scoped_allocator_adaptor(BOOST_FWD_REF(OuterA2) outerAlloc, const InnerAllocs & ...innerAllocs)
@@ -1169,7 +1169,7 @@ class scoped_allocator_adaptor
 
    //! Requires: OuterAlloc shall be constructible from OuterA2.
    //!
-   //! Effects: initializes each allocator within the adaptor with the corresponding allocator 
+   //! Effects: initializes each allocator within the adaptor with the corresponding allocator
    //! rvalue from other.
    template 
    scoped_allocator_adaptor(BOOST_RV_REF_BEG scoped_allocator_adaptorouter_allocator());
    }
 
-   //! Effects: 
+   //! Effects:
    //!   calls `OUTERMOST_ALLOC_TRAITS(*this)::destroy(OUTERMOST(*this), p)`.
    template 
    void destroy(T* p)
@@ -1230,14 +1230,14 @@ class scoped_allocator_adaptor
          ::destroy(get_outermost_allocator(this->outer_allocator()), p);
    }
 
-   //! Returns: 
+   //! Returns:
    //! `allocator_traits::allocate(outer_allocator(), n)`.
    pointer allocate(size_type n)
    {
       return outer_traits_type::allocate(this->outer_allocator(), n);
    }
 
-   //! Returns: 
+   //! Returns:
    //! `allocator_traits::allocate(outer_allocator(), n, hint)`.
    pointer allocate(size_type n, const_void_pointer hint)
    {
@@ -1252,7 +1252,7 @@ class scoped_allocator_adaptor
    }
 
    //! Returns: A new scoped_allocator_adaptor object where each allocator
-   //! A in the adaptor is initialized from the result of calling 
+   //! A in the adaptor is initialized from the result of calling
    //! `allocator_traits::select_on_container_copy_construction()` on
    //! the corresponding allocator in *this.
    scoped_allocator_adaptor select_on_container_copy_construction() const
@@ -1275,21 +1275,21 @@ class scoped_allocator_adaptor
    //! 1) If `uses_allocator::value` is false calls
    //!    `OUTERMOST_ALLOC_TRAITS(*this)::construct
    //!       (OUTERMOST(*this), p, std::forward(args)...)`.
-   //! 
-   //! 2) Otherwise, if `uses_allocator::value` is true and 
+   //!
+   //! 2) Otherwise, if `uses_allocator::value` is true and
    //!    `is_constructible::value` is true, calls
    //!    `OUTERMOST_ALLOC_TRAITS(*this)::construct(OUTERMOST(*this), p, allocator_arg,
    //!    inner_allocator(), std::forward(args)...)`.
-   //! 
+   //!
    //! [Note: In compilers without advanced decltype SFINAE support, `is_constructible` can't
    //! be implemented so that condition will be replaced by
    //! constructible_with_allocator_prefix::value. -end note]
    //!
-   //! 3) Otherwise, if uses_allocator::value is true and 
-   //!    `is_constructible::value` is true, calls 
-   //!    `OUTERMOST_ALLOC_TRAITS(*this)::construct(OUTERMOST(*this), p, 
+   //! 3) Otherwise, if uses_allocator::value is true and
+   //!    `is_constructible::value` is true, calls
+   //!    `OUTERMOST_ALLOC_TRAITS(*this)::construct(OUTERMOST(*this), p,
    //!    std::forward(args)..., inner_allocator())`.
-   //! 
+   //!
    //! [Note: In compilers without advanced decltype SFINAE support, `is_constructible` can't be
    //! implemented so that condition will be replaced by
    //! `constructible_with_allocator_suffix::value`. -end note]
@@ -1352,7 +1352,7 @@ class scoped_allocator_adaptor
    template 
    void construct(container_detail::pair* p, BOOST_FWD_REF(U) x, BOOST_FWD_REF(V) y)
    {  this->construct_pair(p, ::boost::forward(x), ::boost::forward(y));   }
-   
+  
    template 
    void construct(std::pair* p, const std::pair& x)
    {  this->construct_pair(p, x);   }
@@ -1361,7 +1361,7 @@ class scoped_allocator_adaptor
    void construct( container_detail::pair* p
                  , const container_detail::pair& x)
    {  this->construct_pair(p, x);   }
-   
+  
    template 
    void construct( std::pair* p
                  , BOOST_RV_REF_BEG std::pair BOOST_RV_REF_END x)
@@ -1461,7 +1461,7 @@ inline bool operator==(
       #endif
    >& b)
 {
-   #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)   
+   #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)  
    const bool has_zero_inner = sizeof...(InnerAllocs) == 0u;
    #else
    const bool has_zero_inner =
diff --git a/include/boost/container/set.hpp b/include/boost/container/set.hpp
index ef3d989..09ada20 100644
--- a/include/boost/container/set.hpp
+++ b/include/boost/container/set.hpp
@@ -42,32 +42,32 @@ namespace container {
 /// @cond
 // Forward declarations of operators < and ==, needed for friend declaration.
 template 
-inline bool operator==(const set& x, 
+inline bool operator==(const set& x,
                        const set& y);
 
 template 
-inline bool operator<(const set& x, 
+inline bool operator<(const set& x,
                       const set& y);
 /// @endcond
 
-//! A set is a kind of associative container that supports unique keys (contains at 
-//! most one of each key value) and provides for fast retrieval of the keys themselves. 
-//! Class set supports bidirectional iterators. 
-//! 
-//! A set satisfies all of the requirements of a container and of a reversible container 
-//! , and of an associative container. A set also provides most operations described in 
+//! A set is a kind of associative container that supports unique keys (contains at
+//! most one of each key value) and provides for fast retrieval of the keys themselves.
+//! Class set supports bidirectional iterators.
+//!
+//! A set satisfies all of the requirements of a container and of a reversible container
+//! , and of an associative container. A set also provides most operations described in
 //! for unique keys.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
 template , class A = std::allocator >
 #else
 template 
 #endif
-class set 
+class set
 {
    /// @cond
    private:
    BOOST_COPYABLE_AND_MOVABLE(set)
-   typedef container_detail::rbtree, Pred, A> tree_t;
    tree_t m_tree;  // red-black tree representing set
    typedef typename container_detail::
@@ -95,66 +95,66 @@ class set
    typedef typename tree_t::stored_allocator_type  stored_allocator_type;
 
    //! Effects: Default constructs an empty set.
-   //! 
+   //!
    //! Complexity: Constant.
    set()
       : m_tree()
    {}
 
-   //! Effects: Constructs an empty set using the specified comparison object 
+   //! Effects: Constructs an empty set using the specified comparison object
    //! and allocator.
-   //! 
+   //!
    //! Complexity: Constant.
    explicit set(const Pred& comp,
                 const allocator_type& a = allocator_type())
       : m_tree(comp, a)
    {}
 
-   //! Effects: Constructs an empty set using the specified comparison object and 
+   //! Effects: Constructs an empty set using the specified comparison object and
    //! allocator, and inserts elements from the range [first ,last ).
-   //! 
-   //! Complexity: Linear in N if the range [first ,last ) is already sorted using 
+   //!
+   //! Complexity: Linear in N if the range [first ,last ) is already sorted using
    //! comp and otherwise N logN, where N is last - first.
    template 
    set(InputIterator first, InputIterator last, const Pred& comp = Pred(),
          const allocator_type& a = allocator_type())
-      : m_tree(first, last, comp, a, true) 
+      : m_tree(first, last, comp, a, true)
    {}
 
-   //! Effects: Constructs an empty set using the specified comparison object and 
+   //! Effects: Constructs an empty set using the specified comparison object and
    //! allocator, and inserts elements from the ordered unique range [first ,last). This function
    //! is more efficient than the normal range creation for ordered ranges.
    //!
    //! Requires: [first ,last) must be ordered according to the predicate and must be
    //! unique values.
-   //! 
+   //!
    //! Complexity: Linear in N.
    template 
    set( ordered_unique_range_t, InputIterator first, InputIterator last
       , const Pred& comp = Pred(), const allocator_type& a = allocator_type())
-      : m_tree(ordered_range, first, last, comp, a) 
+      : m_tree(ordered_range, first, last, comp, a)
    {}
 
    //! Effects: Copy constructs a set.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
-   set(const set& x) 
+   set(const set& x)
       : m_tree(x.m_tree)
    {}
 
    //! Effects: Move constructs a set. Constructs *this using x's resources.
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Postcondition: x is emptied.
-   set(BOOST_RV_REF(set) x) 
+   set(BOOST_RV_REF(set) x)
       : m_tree(boost::move(x.m_tree))
    {}
 
    //! Effects: Copy constructs a set using the specified allocator.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
-   set(const set& x, const allocator_type &a) 
+   set(const set& x, const allocator_type &a)
       : m_tree(x.m_tree, a)
    {}
 
@@ -162,7 +162,7 @@ class set
    //!                 Constructs *this using x's resources.
    //!
    //! Complexity: Constant if a == x.get_allocator(), linear otherwise.
-   set(BOOST_RV_REF(set) x, const allocator_type &a) 
+   set(BOOST_RV_REF(set) x, const allocator_type &a)
       : m_tree(boost::move(x.m_tree), a)
    {}
 
@@ -173,162 +173,162 @@ class set
    {  m_tree = x.m_tree;   return *this;  }
 
    //! Effects: this->swap(x.get()).
-   //! 
+   //!
    //! Complexity: Constant.
    set& operator=(BOOST_RV_REF(set) x)
    {  m_tree = boost::move(x.m_tree);   return *this;  }
 
    //! Effects: Returns the comparison object out
    //!   of which a was constructed.
-   //! 
+   //!
    //! Complexity: Constant.
-   key_compare key_comp() const 
+   key_compare key_comp() const
    { return m_tree.key_comp(); }
 
    //! Effects: Returns an object of value_compare constructed out
    //!   of the comparison object.
-   //! 
+   //!
    //! Complexity: Constant.
-   value_compare value_comp() const 
+   value_compare value_comp() const
    { return m_tree.key_comp(); }
 
    //! Effects: Returns a copy of the Allocator that
    //!   was passed to the object's constructor.
-   //! 
+   //!
    //! Complexity: Constant.
-   allocator_type get_allocator() const 
+   allocator_type get_allocator() const
    { return m_tree.get_allocator(); }
 
-   const stored_allocator_type &get_stored_allocator() const 
+   const stored_allocator_type &get_stored_allocator() const
    { return m_tree.get_stored_allocator(); }
 
    stored_allocator_type &get_stored_allocator()
    { return m_tree.get_stored_allocator(); }
 
    //! Effects: Returns an iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant
-   iterator begin() 
+   iterator begin()
    { return m_tree.begin(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator begin() const 
+   const_iterator begin() const
    { return m_tree.begin(); }
 
    //! Effects: Returns an iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   iterator end() 
+   iterator end()
    { return m_tree.end(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator end() const 
+   const_iterator end() const
    { return m_tree.end(); }
 
-   //! Effects: Returns a reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reverse_iterator rbegin() 
-   { return m_tree.rbegin(); } 
+   reverse_iterator rbegin()
+   { return m_tree.rbegin(); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator rbegin() const 
-   { return m_tree.rbegin(); } 
+   const_reverse_iterator rbegin() const
+   { return m_tree.rbegin(); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reverse_iterator rend() 
+   reverse_iterator rend()
    { return m_tree.rend(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator rend() const 
+   const_reverse_iterator rend() const
    { return m_tree.rend(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cbegin() const 
+   const_iterator cbegin() const
    { return m_tree.cbegin(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cend() const 
+   const_iterator cend() const
    { return m_tree.cend(); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin() const 
-   { return m_tree.crbegin(); } 
+   const_reverse_iterator crbegin() const
+   { return m_tree.crbegin(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crend() const 
+   const_reverse_iterator crend() const
    { return m_tree.crend(); }
 
    //! Effects: Returns true if the container contains no elements.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   bool empty() const 
+   bool empty() const
    { return m_tree.empty(); }
 
    //! Effects: Returns the number of the elements contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type size() const 
+   size_type size() const
    { return m_tree.size(); }
 
    //! Effects: Returns the largest possible size of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type max_size() const 
+   size_type max_size() const
    { return m_tree.max_size(); }
 
    //! Effects: Swaps the contents of *this and x.
@@ -339,15 +339,15 @@ class set
    void swap(set& x)
    { m_tree.swap(x.m_tree); }
 
-   //! Effects: Inserts x if and only if there is no element in the container 
+   //! Effects: Inserts x if and only if there is no element in the container
    //!   with key equivalent to the key of x.
    //!
-   //! Returns: The bool component of the returned pair is true if and only 
+   //! Returns: The bool component of the returned pair is true if and only
    //!   if the insertion takes place, and the iterator component of the pair
    //!   points to the element with key equivalent to the key of x.
    //!
    //! Complexity: Logarithmic.
-   std::pair insert(insert_const_ref_type x) 
+   std::pair insert(insert_const_ref_type x)
    {  return priv_insert(x); }
 
    #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -360,18 +360,18 @@ class set
    {  return priv_insert(u); }
    #endif
 
-   //! Effects: Move constructs a new value from x if and only if there is 
+   //! Effects: Move constructs a new value from x if and only if there is
    //!   no element in the container with key equivalent to the key of x.
    //!
-   //! Returns: The bool component of the returned pair is true if and only 
+   //! Returns: The bool component of the returned pair is true if and only
    //!   if the insertion takes place, and the iterator component of the pair
    //!   points to the element with key equivalent to the key of x.
    //!
    //! Complexity: Logarithmic.
-   std::pair insert(BOOST_RV_REF(value_type) x) 
+   std::pair insert(BOOST_RV_REF(value_type) x)
    {  return m_tree.insert_unique(boost::move(x));  }
 
-   //! Effects: Inserts a copy of x in the container if and only if there is 
+   //! Effects: Inserts a copy of x in the container if and only if there is
    //!   no element in the container with key equivalent to the key of x.
    //!   p is a hint pointing to where the insert should start to search.
    //!
@@ -380,7 +380,7 @@ class set
    //!
    //! Complexity: Logarithmic in general, but amortized constant if t
    //!   is inserted right before p.
-   iterator insert(const_iterator p, insert_const_ref_type x) 
+   iterator insert(const_iterator p, insert_const_ref_type x)
    {  return priv_insert(p, x); }
 
    #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -399,28 +399,28 @@ class set
    //! Returns: An iterator pointing to the element with key equivalent to the key of x.
    //!
    //! Complexity: Logarithmic.
-   iterator insert(const_iterator p, BOOST_RV_REF(value_type) x) 
+   iterator insert(const_iterator p, BOOST_RV_REF(value_type) x)
    {  return m_tree.insert_unique(p, boost::move(x)); }
 
    //! Requires: first, last are not iterators into *this.
    //!
-   //! Effects: inserts each element from the range [first,last) if and only 
+   //! Effects: inserts each element from the range [first,last) if and only
    //!   if there is no element with key equivalent to the key of that element.
    //!
    //! Complexity: At most N log(size()+N) (N is the distance from first to last)
    template 
-   void insert(InputIterator first, InputIterator last) 
+   void insert(InputIterator first, InputIterator last)
    {  m_tree.insert_unique(first, last);  }
 
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
    //! Effects:  Inserts an object x of type T constructed with
-   //!   std::forward(args)... if and only if there is 
+   //!   std::forward(args)... if and only if there is
    //!   no element in the container with equivalent value.
    //!   and returns the iterator pointing to the
    //!   newly inserted element.
    //!
-   //! Returns: The bool component of the returned pair is true if and only 
+   //! Returns: The bool component of the returned pair is true if and only
    //!   if the insertion takes place, and the iterator component of the pair
    //!   points to the element with key equivalent to the key of x.
    //!
@@ -433,7 +433,7 @@ class set
    {  return m_tree.emplace_unique(boost::forward(args)...); }
 
    //! Effects:  Inserts an object of type T constructed with
-   //!   std::forward(args)... if and only if there is 
+   //!   std::forward(args)... if and only if there is
    //!   no element in the container with equivalent value.
    //!   p is a hint pointing to where the insert
    //!   should start to search.
@@ -466,11 +466,11 @@ class set
    //! Effects: Erases the element pointed to by p.
    //!
    //! Returns: Returns an iterator pointing to the element immediately
-   //!   following q prior to the element being erased. If no such element exists, 
+   //!   following q prior to the element being erased. If no such element exists,
    //!   returns end().
    //!
    //! Complexity: Amortized constant time
-   iterator erase(const_iterator p) 
+   iterator erase(const_iterator p)
    {  return m_tree.erase(p); }
 
    //! Effects: Erases all elements in the container with key equivalent to x.
@@ -478,7 +478,7 @@ class set
    //! Returns: Returns the number of erased elements.
    //!
    //! Complexity: log(size()) + count(k)
-   size_type erase(const key_type& x) 
+   size_type erase(const key_type& x)
    {  return m_tree.erase(x); }
 
    //! Effects: Erases all the elements in the range [first, last).
@@ -486,7 +486,7 @@ class set
    //! Returns: Returns last.
    //!
    //! Complexity: log(size())+N where N is the distance from first to last.
-   iterator erase(const_iterator first, const_iterator last) 
+   iterator erase(const_iterator first, const_iterator last)
    {  return m_tree.erase(first, last);  }
 
    //! Effects: erase(a.begin(),a.end()).
@@ -494,41 +494,41 @@ class set
    //! Postcondition: size() == 0.
    //!
    //! Complexity: linear in size().
-   void clear() 
+   void clear()
    { m_tree.clear(); }
 
    //! Returns: An iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.
-   iterator find(const key_type& x) 
+   iterator find(const key_type& x)
    { return m_tree.find(x); }
 
    //! Returns: A const_iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.
-   const_iterator find(const key_type& x) const 
+   const_iterator find(const key_type& x) const
    { return m_tree.find(x); }
 
    //! Returns: The number of elements with key equivalent to x.
    //!
    //! Complexity: log(size())+count(k)
-   size_type count(const key_type& x) const 
+   size_type count(const key_type& x) const
    {  return m_tree.find(x) == m_tree.end() ? 0 : 1;  }
 
    //! Returns: An iterator pointing to the first element with key not less
    //!   than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   iterator lower_bound(const key_type& x) 
+   iterator lower_bound(const key_type& x)
    {  return m_tree.lower_bound(x); }
 
    //! Returns: A const iterator pointing to the first element with key not
    //!   less than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   const_iterator lower_bound(const key_type& x) const 
+   const_iterator lower_bound(const key_type& x) const
    {  return m_tree.lower_bound(x); }
 
    //! Returns: An iterator pointing to the first element with key not less
@@ -542,21 +542,21 @@ class set
    //!   less than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   const_iterator upper_bound(const key_type& x) const 
+   const_iterator upper_bound(const key_type& x) const
    {  return m_tree.upper_bound(x);    }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair 
-      equal_range(const key_type& x) 
+   std::pair
+      equal_range(const key_type& x)
    {  return m_tree.equal_range(x); }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair 
-      equal_range(const key_type& x) const 
+   std::pair
+      equal_range(const key_type& x) const
    {  return m_tree.equal_range(x); }
 
    /// @cond
@@ -567,47 +567,47 @@ class set
    friend bool operator< (const set&, const set&);
 
    private:
-   std::pair priv_insert(const T &x) 
+   std::pair priv_insert(const T &x)
    {  return m_tree.insert_unique(x);  }
 
-   iterator priv_insert(const_iterator p, const T &x) 
+   iterator priv_insert(const_iterator p, const T &x)
    {  return m_tree.insert_unique(p, x); }
 
    /// @endcond
 };
 
 template 
-inline bool operator==(const set& x, 
-                       const set& y) 
+inline bool operator==(const set& x,
+                       const set& y)
 {  return x.m_tree == y.m_tree;  }
 
 template 
-inline bool operator<(const set& x, 
-                      const set& y) 
+inline bool operator<(const set& x,
+                      const set& y)
 {  return x.m_tree < y.m_tree;   }
 
 template 
-inline bool operator!=(const set& x, 
-                       const set& y) 
+inline bool operator!=(const set& x,
+                       const set& y)
 {  return !(x == y);   }
 
 template 
-inline bool operator>(const set& x, 
-                      const set& y) 
+inline bool operator>(const set& x,
+                      const set& y)
 {  return y < x; }
 
 template 
-inline bool operator<=(const set& x, 
-                       const set& y) 
+inline bool operator<=(const set& x,
+                       const set& y)
 {  return !(y < x); }
 
 template 
-inline bool operator>=(const set& x, 
-                       const set& y) 
+inline bool operator>=(const set& x,
+                       const set& y)
 {  return !(x < y);  }
 
 template 
-inline void swap(set& x, set& y) 
+inline void swap(set& x, set& y)
 {  x.swap(y);  }
 
 /// @cond
@@ -627,32 +627,32 @@ namespace container {
 // Forward declaration of operators < and ==, needed for friend declaration.
 
 template 
-inline bool operator==(const multiset& x, 
+inline bool operator==(const multiset& x,
                        const multiset& y);
 
 template 
-inline bool operator<(const multiset& x, 
+inline bool operator<(const multiset& x,
                       const multiset& y);
 /// @endcond
 
-//! A multiset is a kind of associative container that supports equivalent keys 
-//! (possibly contains multiple copies of the same key value) and provides for 
+//! A multiset is a kind of associative container that supports equivalent keys
+//! (possibly contains multiple copies of the same key value) and provides for
 //! fast retrieval of the keys themselves. Class multiset supports bidirectional iterators.
-//! 
-//! A multiset satisfies all of the requirements of a container and of a reversible 
-//! container, and of an associative container). multiset also provides most operations 
+//!
+//! A multiset satisfies all of the requirements of a container and of a reversible
+//! container, and of an associative container). multiset also provides most operations
 //! described for duplicate keys.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
 template , class A = std::allocator >
 #else
 template 
 #endif
-class multiset 
+class multiset
 {
    /// @cond
    private:
    BOOST_COPYABLE_AND_MOVABLE(multiset)
-   typedef container_detail::rbtree, Pred, A> tree_t;
    tree_t m_tree;  // red-black tree representing multiset
    typedef typename container_detail::
@@ -681,7 +681,7 @@ class multiset
 
    //! Effects: Constructs an empty multiset using the specified comparison
    //!   object and allocator.
-   //! 
+   //!
    //! Complexity: Constant.
    multiset()
       : m_tree()
@@ -689,7 +689,7 @@ class multiset
 
    //! Effects: Constructs an empty multiset using the specified comparison
    //!   object and allocator.
-   //! 
+   //!
    //! Complexity: Constant.
    explicit multiset(const Pred& comp,
                      const allocator_type& a = allocator_type())
@@ -698,226 +698,226 @@ class multiset
 
    //! Effects: Constructs an empty multiset using the specified comparison object
    //!   and allocator, and inserts elements from the range [first ,last ).
-   //! 
-   //! Complexity: Linear in N if the range [first ,last ) is already sorted using 
+   //!
+   //! Complexity: Linear in N if the range [first ,last ) is already sorted using
    //! comp and otherwise N logN, where N is last - first.
    template 
    multiset(InputIterator first, InputIterator last,
             const Pred& comp = Pred(),
             const allocator_type& a = allocator_type())
-      : m_tree(first, last, comp, a, false) 
+      : m_tree(first, last, comp, a, false)
    {}
 
-   //! Effects: Constructs an empty multiset using the specified comparison object and 
+   //! Effects: Constructs an empty multiset using the specified comparison object and
    //! allocator, and inserts elements from the ordered range [first ,last ). This function
    //! is more efficient than the normal range creation for ordered ranges.
    //!
    //! Requires: [first ,last) must be ordered according to the predicate.
-   //! 
+   //!
    //! Complexity: Linear in N.
    template 
    multiset( ordered_range_t ordered_range, InputIterator first, InputIterator last
            , const Pred& comp = Pred()
            , const allocator_type& a = allocator_type())
-      : m_tree(ordered_range, first, last, comp, a) 
+      : m_tree(ordered_range, first, last, comp, a)
    {}
 
    //! Effects: Copy constructs a multiset.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
-   multiset(const multiset& x) 
+   multiset(const multiset& x)
       : m_tree(x.m_tree)
    {}
 
    //! Effects: Move constructs a multiset. Constructs *this using x's resources.
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Postcondition: x is emptied.
-   multiset(BOOST_RV_REF(multiset) x) 
+   multiset(BOOST_RV_REF(multiset) x)
       : m_tree(boost::move(x.m_tree))
    {}
 
    //! Effects: Copy constructs a multiset using the specified allocator.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
-   multiset(const multiset& x, const allocator_type &a) 
+   multiset(const multiset& x, const allocator_type &a)
       : m_tree(x.m_tree, a)
    {}
 
    //! Effects: Move constructs a multiset using the specified allocator.
    //!                 Constructs *this using x's resources.
-   //! 
+   //!
    //! Complexity: Constant if a == x.get_allocator(), linear otherwise.
-   //! 
+   //!
    //! Postcondition: x is emptied.
-   multiset(BOOST_RV_REF(multiset) x, const allocator_type &a) 
+   multiset(BOOST_RV_REF(multiset) x, const allocator_type &a)
       : m_tree(boost::move(x.m_tree), a)
    {}
 
    //! Effects: Makes *this a copy of x.
-   //! 
+   //!
    //! Complexity: Linear in x.size().
-   multiset& operator=(BOOST_COPY_ASSIGN_REF(multiset) x) 
+   multiset& operator=(BOOST_COPY_ASSIGN_REF(multiset) x)
    {  m_tree = x.m_tree;   return *this;  }
 
    //! Effects: this->swap(x.get()).
-   //! 
+   //!
    //! Complexity: Constant.
-   multiset& operator=(BOOST_RV_REF(multiset) x) 
+   multiset& operator=(BOOST_RV_REF(multiset) x)
    {  m_tree = boost::move(x.m_tree);   return *this;  }
 
    //! Effects: Returns the comparison object out
    //!   of which a was constructed.
-   //! 
+   //!
    //! Complexity: Constant.
-   key_compare key_comp() const 
+   key_compare key_comp() const
    { return m_tree.key_comp(); }
 
    //! Effects: Returns an object of value_compare constructed out
    //!   of the comparison object.
-   //! 
+   //!
    //! Complexity: Constant.
-   value_compare value_comp() const 
+   value_compare value_comp() const
    { return m_tree.key_comp(); }
 
    //! Effects: Returns a copy of the Allocator that
    //!   was passed to the object's constructor.
-   //! 
+   //!
    //! Complexity: Constant.
-   allocator_type get_allocator() const 
+   allocator_type get_allocator() const
    { return m_tree.get_allocator(); }
 
-   const stored_allocator_type &get_stored_allocator() const 
+   const stored_allocator_type &get_stored_allocator() const
    { return m_tree.get_stored_allocator(); }
 
    stored_allocator_type &get_stored_allocator()
    { return m_tree.get_stored_allocator(); }
 
    //! Effects: Returns an iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   iterator begin() 
+   iterator begin()
    { return m_tree.begin(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator begin() const 
+   const_iterator begin() const
    { return m_tree.begin(); }
 
    //! Effects: Returns an iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   iterator end() 
+   iterator end()
    { return m_tree.end(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator end() const 
+   const_iterator end() const
    { return m_tree.end(); }
 
-   //! Effects: Returns a reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reverse_iterator rbegin() 
-   { return m_tree.rbegin(); } 
+   reverse_iterator rbegin()
+   { return m_tree.rbegin(); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator rbegin() const 
-   { return m_tree.rbegin(); } 
+   const_reverse_iterator rbegin() const
+   { return m_tree.rbegin(); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reverse_iterator rend() 
+   reverse_iterator rend()
    { return m_tree.rend(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator rend() const 
+   const_reverse_iterator rend() const
    { return m_tree.rend(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cbegin() const 
+   const_iterator cbegin() const
    { return m_tree.cbegin(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cend() const 
+   const_iterator cend() const
    { return m_tree.cend(); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed container. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin() const 
-   { return m_tree.crbegin(); } 
+   const_reverse_iterator crbegin() const
+   { return m_tree.crbegin(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed container. 
-   //! 
+   //! of the reversed container.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crend() const 
+   const_reverse_iterator crend() const
    { return m_tree.crend(); }
 
    //! Effects: Returns true if the container contains no elements.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   bool empty() const 
+   bool empty() const
    { return m_tree.empty(); }
 
    //! Effects: Returns the number of the elements contained in the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type size() const 
+   size_type size() const
    { return m_tree.size(); }
 
    //! Effects: Returns the largest possible size of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type max_size() const 
+   size_type max_size() const
    { return m_tree.max_size(); }
 
    //! Effects: Swaps the contents of *this and x.
@@ -929,10 +929,10 @@ class multiset
    { m_tree.swap(x.m_tree); }
 
    //! Effects: Inserts x and returns the iterator pointing to the
-   //!   newly inserted element. 
+   //!   newly inserted element.
    //!
    //! Complexity: Logarithmic.
-   iterator insert(insert_const_ref_type x) 
+   iterator insert(insert_const_ref_type x)
    {  return priv_insert(x); }
 
    #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -952,7 +952,7 @@ class multiset
    //!
    //! Complexity: Logarithmic in general, but amortized constant if t
    //!   is inserted right before p.
-   iterator insert(BOOST_RV_REF(value_type) x) 
+   iterator insert(BOOST_RV_REF(value_type) x)
    {  return m_tree.insert_equal(boost::move(x));  }
 
    //! Effects: Inserts a copy of x in the container.
@@ -963,7 +963,7 @@ class multiset
    //!
    //! Complexity: Logarithmic in general, but amortized constant if t
    //!   is inserted right before p.
-   iterator insert(const_iterator p, insert_const_ref_type x) 
+   iterator insert(const_iterator p, insert_const_ref_type x)
    {  return priv_insert(p, x); }
 
    #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -984,7 +984,7 @@ class multiset
    //!
    //! Complexity: Logarithmic in general, but amortized constant if t
    //!   is inserted right before p.
-   iterator insert(const_iterator p, BOOST_RV_REF(value_type) x) 
+   iterator insert(const_iterator p, BOOST_RV_REF(value_type) x)
    {  return m_tree.insert_equal(p, boost::move(x));  }
 
    //! Requires: first, last are not iterators into *this.
@@ -993,14 +993,14 @@ class multiset
    //!
    //! Complexity: At most N log(size()+N) (N is the distance from first to last)
    template 
-   void insert(InputIterator first, InputIterator last) 
+   void insert(InputIterator first, InputIterator last)
    {  m_tree.insert_equal(first, last);  }
 
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
    //! Effects: Inserts an object of type T constructed with
    //!   std::forward(args)... and returns the iterator pointing to the
-   //!   newly inserted element. 
+   //!   newly inserted element.
    //!
    //! Complexity: Logarithmic.
    template 
@@ -1040,11 +1040,11 @@ class multiset
    //! Effects: Erases the element pointed to by p.
    //!
    //! Returns: Returns an iterator pointing to the element immediately
-   //!   following q prior to the element being erased. If no such element exists, 
+   //!   following q prior to the element being erased. If no such element exists,
    //!   returns end().
    //!
    //! Complexity: Amortized constant time
-   iterator erase(const_iterator p) 
+   iterator erase(const_iterator p)
    {  return m_tree.erase(p); }
 
    //! Effects: Erases all elements in the container with key equivalent to x.
@@ -1052,7 +1052,7 @@ class multiset
    //! Returns: Returns the number of erased elements.
    //!
    //! Complexity: log(size()) + count(k)
-   size_type erase(const key_type& x) 
+   size_type erase(const key_type& x)
    {  return m_tree.erase(x); }
 
    //! Effects: Erases all the elements in the range [first, last).
@@ -1068,41 +1068,41 @@ class multiset
    //! Postcondition: size() == 0.
    //!
    //! Complexity: linear in size().
-   void clear() 
+   void clear()
    { m_tree.clear(); }
 
    //! Returns: An iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.
-   iterator find(const key_type& x) 
+   iterator find(const key_type& x)
    { return m_tree.find(x); }
 
    //! Returns: A const iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.
-   const_iterator find(const key_type& x) const 
+   const_iterator find(const key_type& x) const
    { return m_tree.find(x); }
 
    //! Returns: The number of elements with key equivalent to x.
    //!
    //! Complexity: log(size())+count(k)
-   size_type count(const key_type& x) const 
+   size_type count(const key_type& x) const
    {  return m_tree.count(x);  }
 
    //! Returns: An iterator pointing to the first element with key not less
    //!   than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   iterator lower_bound(const key_type& x) 
+   iterator lower_bound(const key_type& x)
    {  return m_tree.lower_bound(x); }
 
    //! Returns: A const iterator pointing to the first element with key not
    //!   less than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   const_iterator lower_bound(const key_type& x) const 
+   const_iterator lower_bound(const key_type& x) const
    {  return m_tree.lower_bound(x); }
 
    //! Returns: An iterator pointing to the first element with key not less
@@ -1116,21 +1116,21 @@ class multiset
    //!   less than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
-   const_iterator upper_bound(const key_type& x) const 
+   const_iterator upper_bound(const key_type& x) const
    {  return m_tree.upper_bound(x);    }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair 
-      equal_range(const key_type& x) 
+   std::pair
+      equal_range(const key_type& x)
    {  return m_tree.equal_range(x); }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair 
-      equal_range(const key_type& x) const 
+   std::pair
+      equal_range(const key_type& x) const
    {  return m_tree.equal_range(x); }
 
    /// @cond
@@ -1141,47 +1141,47 @@ class multiset
    friend bool operator< (const multiset&,
                           const multiset&);
    private:
-   iterator priv_insert(const T &x) 
+   iterator priv_insert(const T &x)
    {  return m_tree.insert_equal(x);  }
 
-   iterator priv_insert(const_iterator p, const T &x) 
+   iterator priv_insert(const_iterator p, const T &x)
    {  return m_tree.insert_equal(p, x); }
 
    /// @endcond
 };
 
 template 
-inline bool operator==(const multiset& x, 
-                       const multiset& y) 
+inline bool operator==(const multiset& x,
+                       const multiset& y)
 {  return x.m_tree == y.m_tree;  }
 
 template 
-inline bool operator<(const multiset& x, 
-                      const multiset& y) 
+inline bool operator<(const multiset& x,
+                      const multiset& y)
 {  return x.m_tree < y.m_tree;   }
 
 template 
-inline bool operator!=(const multiset& x, 
-                       const multiset& y) 
+inline bool operator!=(const multiset& x,
+                       const multiset& y)
 {  return !(x == y);  }
 
 template 
-inline bool operator>(const multiset& x, 
-                      const multiset& y) 
+inline bool operator>(const multiset& x,
+                      const multiset& y)
 {  return y < x;  }
 
 template 
-inline bool operator<=(const multiset& x, 
-                       const multiset& y) 
+inline bool operator<=(const multiset& x,
+                       const multiset& y)
 {  return !(y < x);  }
 
 template 
-inline bool operator>=(const multiset& x, 
-                       const multiset& y) 
+inline bool operator>=(const multiset& x,
+                       const multiset& y)
 {  return !(x < y);  }
 
 template 
-inline void swap(multiset& x, multiset& y) 
+inline void swap(multiset& x, multiset& y)
 {  x.swap(y);  }
 
 /// @cond
diff --git a/include/boost/container/slist.hpp b/include/boost/container/slist.hpp
index 5797d6c..5771935 100644
--- a/include/boost/container/slist.hpp
+++ b/include/boost/container/slist.hpp
@@ -32,7 +32,7 @@
 #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 //Preprocessor library to emulate perfect forwarding
 #else
-#include  
+#include 
 #endif
 
 #include 
@@ -99,51 +99,51 @@ struct intrusive_slist_type
 
 /// @endcond
 
-//! An slist is a singly linked list: a list where each element is linked to the next 
-//! element, but not to the previous element. That is, it is a Sequence that 
-//! supports forward but not backward traversal, and (amortized) constant time 
-//! insertion and removal of elements. Slists, like 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, 
-//! slist::iterator might have a different predecessor or successor after a list 
-//! operation than it did before), but the iterators themselves will not be invalidated 
+//! An slist is a singly linked list: a list where each element is linked to the next
+//! element, but not to the previous element. That is, it is a Sequence that
+//! supports forward but not backward traversal, and (amortized) constant time
+//! insertion and removal of elements. Slists, like 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,
+//! slist::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.
 //!
-//! The main difference between slist and list is that list's iterators are bidirectional 
-//! iterators, while slist's iterators are forward iterators. This means that slist is 
-//! less versatile than list; frequently, however, bidirectional iterators are 
-//! unnecessary. You should usually use slist unless you actually need the extra 
-//! functionality of list, because singly linked lists are smaller and faster than double 
-//! linked lists. 
-//! 
-//! Important performance note: like every other Sequence, slist defines the member 
-//! functions insert and erase. Using these member functions carelessly, however, can 
-//! result in disastrously slow programs. The problem is that insert's first argument is 
-//! an iterator p, and that it inserts the new element(s) before p. This means that 
-//! insert must find the iterator just before p; this is a constant-time operation 
-//! for list, since list has bidirectional iterators, but for slist it must find that 
-//! iterator by traversing the list from the beginning up to p. In other words: 
+//! The main difference between slist and list is that list's iterators are bidirectional
+//! iterators, while slist's iterators are forward iterators. This means that slist is
+//! less versatile than list; frequently, however, bidirectional iterators are
+//! unnecessary. You should usually use slist unless you actually need the extra
+//! functionality of list, because singly linked lists are smaller and faster than double
+//! linked lists.
+//!
+//! Important performance note: like every other Sequence, slist defines the member
+//! functions insert and erase. Using these member functions carelessly, however, can
+//! result in disastrously slow programs. The problem is that insert's first argument is
+//! an iterator p, and that it inserts the new element(s) before p. This means that
+//! insert must find the iterator just before p; this is a constant-time operation
+//! for list, since list has bidirectional iterators, but for slist it must find that
+//! iterator by traversing the list from the beginning up to p. In other words:
 //! insert and erase are slow operations anywhere but near the beginning of the slist.
-//! 
-//! Slist provides the member functions insert_after and erase_after, which are constant 
-//! time operations: you should always use insert_after and erase_after whenever 
-//! possible. If you find that insert_after and erase_after aren't adequate for your 
-//! needs, and that you often need to use insert and erase in the middle of the list, 
+//!
+//! Slist provides the member functions insert_after and erase_after, which are constant
+//! time operations: you should always use insert_after and erase_after whenever
+//! possible. If you find that insert_after and erase_after aren't adequate for your
+//! needs, and that you often need to use insert and erase in the middle of the list,
 //! then you should probably use list instead of slist.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
 template  >
 #else
 template 
 #endif
-class slist 
+class slist
    : protected container_detail::node_alloc_holder
       ::type>
 {
    /// @cond
    typedef typename container_detail::
       move_const_ref_type::type                    insert_const_ref_type;
-   typedef typename 
+   typedef typename
       container_detail::intrusive_slist_type::type           Icont;
    typedef container_detail::node_alloc_holder        AllocHolder;
    typedef typename AllocHolder::NodePtr              NodePtr;
@@ -218,11 +218,11 @@ class slist
 
    public:
 
-   //! Const iterator used to iterate through a list. 
+   //! Const iterator used to iterate through a list.
    class const_iterator
       /// @cond
-      : public std::iterator
    {
 
@@ -245,17 +245,17 @@ class slist
       {}
 
       //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);  }
 
       //Comparison operators
@@ -278,7 +278,7 @@ class slist
       explicit iterator(typename Icont::iterator it)
          :  const_iterator(it)
       {}
-   
+  
       typename Icont::iterator get()
       {  return this->m_it;   }
 
@@ -295,7 +295,7 @@ class slist
       pointer   operator->() const {  return  pointer(&this->m_it->m_data);  }
 
       //Increment / Decrement
-      iterator& operator++()  
+      iterator& operator++() 
          { this->prot_incr(); return *this;  }
 
       iterator operator++(int)
@@ -306,18 +306,18 @@ class slist
 
    public:
    //! Effects: Constructs a list taking the allocator as parameter.
-   //! 
+   //!
    //! Throws: If allocator_type's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
    slist()
       :  AllocHolder()
    {}
 
    //! Effects: Constructs a list taking the allocator as parameter.
-   //! 
+   //!
    //! Throws: If allocator_type's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
    explicit slist(const allocator_type& a)
       :  AllocHolder(a)
@@ -332,7 +332,7 @@ class slist
    //!
    //! Throws: If allocator_type's default constructor or copy constructor
    //!   throws or T's default or copy constructor throws.
-   //! 
+   //!
    //! Complexity: Linear to n.
    explicit slist(size_type n, const value_type& x, const allocator_type& a = allocator_type())
       :  AllocHolder(a)
@@ -347,25 +347,25 @@ class slist
    //! Complexity: Linear to the range [first, last).
    template 
    slist(InpIt first, InpIt last,
-         const allocator_type& a =  allocator_type()) 
+         const allocator_type& a =  allocator_type())
       : AllocHolder(a)
    { this->insert_after(this->before_begin(), first, last); }
 
    //! Effects: Copy constructs a list.
    //!
    //! Postcondition: x == *this.
-   //! 
+   //!
    //! Throws: If allocator_type's default constructor or copy constructor throws.
-   //! 
+   //!
    //! Complexity: Linear to the elements x contains.
-   slist(const slist& x) 
+   slist(const slist& x)
       : AllocHolder(x)
    { this->insert_after(this->before_begin(), x.begin(), x.end()); }
 
    //! Effects: Move constructor. Moves mx's resources to *this.
    //!
    //! Throws: If allocator_type's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
    slist(BOOST_RV_REF(slist) x)
       : AllocHolder(boost::move(static_cast(x)))
@@ -374,11 +374,11 @@ class slist
    //! Effects: Copy constructs a list using the specified allocator.
    //!
    //! Postcondition: x == *this.
-   //! 
+   //!
    //! Throws: If allocator_type's default constructor or copy constructor throws.
-   //! 
+   //!
    //! Complexity: Linear to the elements x contains.
-   slist(const slist& x, const allocator_type &a) 
+   slist(const slist& x, const allocator_type &a)
       : AllocHolder(a)
    { this->insert_after(this->before_begin(), x.begin(), x.end()); }
 
@@ -386,7 +386,7 @@ class slist
    //!                 Moves x's resources to *this.
    //!
    //! Throws: If allocation or value_type's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant if a == x.get_allocator(), linear otherwise.
    slist(BOOST_RV_REF(slist) x, const allocator_type &a)
       : AllocHolder(a)
@@ -401,8 +401,8 @@ class slist
 
    //! Effects: Makes *this contain the same elements as x.
    //!
-   //! Postcondition: this->size() == x.size(). *this contains a copy 
-   //! of each of x's elements. 
+   //! Postcondition: this->size() == x.size(). *this contains a copy
+   //! of each of x's elements.
    //!
    //! Throws: If memory allocation throws or T's copy constructor throws.
    //!
@@ -425,8 +425,8 @@ class slist
 
    //! Effects: Makes *this contain the same elements as x.
    //!
-   //! Postcondition: this->size() == x.size(). *this contains a copy 
-   //! of each of x's elements. 
+   //! Postcondition: this->size() == x.size(). *this contains a copy
+   //! of each of x's elements.
    //!
    //! Throws: If memory allocation throws or T's copy constructor throws.
    //!
@@ -460,18 +460,18 @@ class slist
    //! Throws: Nothing.
    //!
    //! Complexity: Linear to the number of elements.
-   ~slist() 
+   ~slist()
    {} //AllocHolder clears the slist
 
    //! Effects: Returns a copy of the internal allocator.
-   //! 
+   //!
    //! Throws: If allocator's copy constructor throws.
-   //! 
+   //!
    //! Complexity: 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()
@@ -494,7 +494,7 @@ class slist
    //!
    //! Complexity: Linear to n.
    template 
-   void assign(InpIt first, InpIt last) 
+   void assign(InpIt first, InpIt last)
    {
       const bool aux_boolean = container_detail::is_convertible::value;
       typedef container_detail::bool_ Result;
@@ -502,33 +502,33 @@ class slist
    }
 
    //! Effects: Returns an iterator to the first element contained in the list.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   iterator begin() 
+   iterator begin()
    { return iterator(this->icont().begin()); }
 
    //! Effects: Returns a const_iterator to the first element contained in the list.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator begin() const 
+   const_iterator begin() const
    {  return this->cbegin();   }
 
    //! Effects: Returns an iterator to the end of the list.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    iterator end()
    { return iterator(this->icont().end()); }
 
    //! Effects: Returns a const_iterator to the end of the list.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator end() const
    {  return this->cend();   }
@@ -536,71 +536,71 @@ class slist
    //! Effects: Returns a non-dereferenceable iterator that,
    //! when incremented, yields begin().  This iterator may be used
    //! as the argument toinsert_after, erase_after, etc.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   iterator before_begin() 
+   iterator before_begin()
    {  return iterator(end());  }
 
-   //! Effects: Returns a non-dereferenceable const_iterator 
+   //! Effects: Returns a non-dereferenceable const_iterator
    //! that, when incremented, yields begin().  This iterator may be used
    //! as the argument toinsert_after, erase_after, etc.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator before_begin() const
    {  return this->cbefore_begin();  }
 
    //! Effects: Returns a const_iterator to the first element contained in the list.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cbegin() const 
+   const_iterator cbegin() const
    {  return const_iterator(this->non_const_icont().begin());   }
 
    //! Effects: Returns a const_iterator to the end of the list.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator cend() const
    {  return const_iterator(this->non_const_icont().end());   }
 
-   //! Effects: Returns a non-dereferenceable const_iterator 
+   //! Effects: Returns a non-dereferenceable const_iterator
    //! that, when incremented, yields begin().  This iterator may be used
    //! as the argument toinsert_after, erase_after, etc.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator cbefore_begin() const
    {  return const_iterator(end());  }
 
    //! Effects: Returns the number of the elements contained in the list.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type size() const 
+   size_type size() const
    {  return this->icont().size(); }
 
    //! Effects: Returns the largest possible size of the list.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type max_size() const 
+   size_type max_size() const
    {  return AllocHolder::max_size();  }
 
    //! Effects: Returns true if the list contains no elements.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   bool empty() const 
+   bool empty() const
    {  return !this->size();   }
 
    //! Effects: Swaps the contents of *this and x.
@@ -613,24 +613,24 @@ class slist
 
    //! Requires: !empty()
    //!
-   //! Effects: Returns a reference to the first element 
+   //! Effects: Returns a reference to the first element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reference front() 
+   reference front()
    {  return *this->begin();  }
 
    //! Requires: !empty()
    //!
-   //! Effects: Returns a const reference to the first element 
+   //! Effects: Returns a const reference to the first element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reference front() const 
+   const_reference front() const
    {  return *this->begin();  }
 
    //! Effects: Inserts a copy of t in the beginning of the list.
@@ -668,24 +668,24 @@ class slist
    void pop_front()
    {  this->icont().pop_front_and_dispose(Destroyer(this->node_alloc()));      }
 
-   //! Returns: The iterator to the element before i in the sequence. 
-   //!   Returns the end-iterator, if either i is the begin-iterator or the 
-   //!   sequence is empty. 
-   //! 
+   //! Returns: The iterator to the element before i in the sequence.
+   //!   Returns the end-iterator, if either i is the begin-iterator or the
+   //!   sequence is empty.
+   //!
    //! Throws: Nothing.
-   //! 
-   //! Complexity: Linear to the number of elements before i. 
-   iterator previous(iterator p) 
+   //!
+   //! Complexity: Linear to the number of elements before i.
+   iterator previous(iterator p)
    {  return iterator(this->icont().previous(p.get())); }
 
-   //! Returns: The const_iterator to the element before i in the sequence. 
-   //!   Returns the end-const_iterator, if either i is the begin-const_iterator or 
-   //!   the sequence is empty. 
-   //! 
+   //! Returns: The const_iterator to the element before i in the sequence.
+   //!   Returns the end-const_iterator, if either i is the begin-const_iterator or
+   //!   the sequence is empty.
+   //!
    //! Throws: Nothing.
-   //! 
-   //! Complexity: Linear to the number of elements before i. 
-   const_iterator previous(const_iterator p) 
+   //!
+   //! Complexity: Linear to the number of elements before i.
+   const_iterator previous(const_iterator p)
    {  return const_iterator(this->icont().previous(p.get())); }
 
    //! Requires: p must be a valid iterator of *this.
@@ -694,14 +694,14 @@ class slist
    //!    by prev_p.
    //!
    //! Returns: An iterator to the inserted element.
-   //! 
+   //!
    //! Throws: If memory allocation throws or T's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Amortized constant time.
    //!
    //! Note: Does not affect the validity of iterators and references of
    //!   previous values.
-   iterator insert_after(const_iterator prev_pos, insert_const_ref_type x) 
+   iterator insert_after(const_iterator prev_pos, insert_const_ref_type x)
    {  return this->priv_insert_after(prev_pos, x); }
 
    #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -720,14 +720,14 @@ class slist
    //!    p pointed by prev_pos.
    //!
    //! Returns: An iterator to the inserted element.
-   //! 
+   //!
    //! Throws: If memory allocation throws.
-   //! 
+   //!
    //! Complexity: Amortized constant time.
    //!
    //! Note: Does not affect the validity of iterators and references of
    //!   previous values.
-   iterator insert_after(const_iterator prev_pos, BOOST_RV_REF(value_type) x) 
+   iterator insert_after(const_iterator prev_pos, BOOST_RV_REF(value_type) x)
    {  return iterator(this->icont().insert_after(prev_pos.get(), *this->create_node(boost::move(x)))); }
 
    //! Requires: prev_pos must be a valid iterator of *this.
@@ -744,19 +744,19 @@ class slist
    {  this->priv_create_and_insert_nodes(prev_pos, n, x); }
 
    //! Requires: prev_pos must be a valid iterator of *this.
-   //! 
-   //! Effects: Inserts the range pointed by [first, last) 
+   //!
+   //! Effects: Inserts the range pointed by [first, last)
    //!   after the p prev_pos.
-   //! 
+   //!
    //! Throws: If memory allocation throws, T's constructor from a
    //!   dereferenced InpIt throws.
-   //! 
+   //!
    //! Complexity: Linear to the number of elements inserted.
-   //! 
+   //!
    //! Note: Does not affect the validity of iterators and references of
    //!   previous values.
    template 
-   void insert_after(const_iterator prev_pos, InIter first, InIter last) 
+   void insert_after(const_iterator prev_pos, InIter first, InIter last)
    {
       const bool aux_boolean = container_detail::is_convertible::value;
       typedef container_detail::bool_ Result;
@@ -770,7 +770,7 @@ class slist
    //! Throws: If memory allocation throws or x's copy constructor throws.
    //!
    //! Complexity: Linear to the elements before p.
-   iterator insert(const_iterator position, insert_const_ref_type x) 
+   iterator insert(const_iterator position, insert_const_ref_type x)
    {  return this->priv_insert(position, x); }
 
    #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -790,7 +790,7 @@ class slist
    //! Throws: If memory allocation throws.
    //!
    //! Complexity: Linear to the elements before p.
-   iterator insert(const_iterator p, BOOST_RV_REF(value_type) x) 
+   iterator insert(const_iterator p, BOOST_RV_REF(value_type) x)
    {  return this->insert_after(previous(p), boost::move(x)); }
 
    //! Requires: p must be a valid iterator of *this.
@@ -800,9 +800,9 @@ class slist
    //! Throws: If memory allocation throws or T's copy constructor throws.
    //!
    //! Complexity: Linear to n plus linear to the elements before p.
-   void insert(const_iterator p, size_type n, const value_type& x) 
+   void insert(const_iterator p, size_type n, const value_type& x)
    {  return this->insert_after(previous(p), n, x); }
-      
+     
    //! Requires: p must be a valid iterator of *this.
    //!
    //! Effects: Insert a copy of the [first, last) range before p.
@@ -813,7 +813,7 @@ class slist
    //! Complexity: Linear to std::distance [first, last) plus
    //!    linear to the elements before p.
    template 
-   void insert(const_iterator p, InIter first, InIter last) 
+   void insert(const_iterator p, InIter first, InIter last)
    {  return this->insert_after(previous(p), first, last); }
 
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -892,11 +892,11 @@ class slist
    //!
    //! Returns: the first element remaining beyond the removed elements,
    //!   or end() if no such element exists.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Note: Does not invalidate iterators or references to non erased elements.
    iterator erase_after(const_iterator prev_pos)
    {
@@ -904,17 +904,17 @@ class slist
    }
 
    //! Effects: Erases the range (before_first, last) from
-   //!   the list. 
+   //!   the list.
    //!
    //! Returns: the first element remaining beyond the removed elements,
    //!   or end() if no such element exists.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Linear to the number of erased elements.
-   //! 
+   //!
    //! Note: Does not invalidate iterators or references to non erased elements.
-   iterator erase_after(const_iterator before_first, const_iterator last) 
+   iterator erase_after(const_iterator before_first, const_iterator last)
    {
       return iterator(this->icont().erase_after_and_dispose(before_first.get(), last.get(), Destroyer(this->node_alloc())));
    }
@@ -926,7 +926,7 @@ class slist
    //! Throws: Nothing.
    //!
    //! Complexity: Linear to the number of elements before p.
-   iterator erase(const_iterator p) 
+   iterator erase(const_iterator p)
    {  return iterator(this->erase_after(previous(p))); }
 
    //! Requires: first and last must be valid iterator to elements in *this.
@@ -953,7 +953,7 @@ class slist
          --new_size;
          cur = cur_next;
       }
-      if (cur_next != end_n) 
+      if (cur_next != end_n)
          this->erase_after(const_iterator(cur), const_iterator(end_n));
       else
          this->insert_after(const_iterator(cur), new_size, x);
@@ -970,7 +970,7 @@ class slist
       typename Icont::iterator end_n(this->icont().end()), cur(this->icont().before_begin()), cur_next;
       size_type len = this->size();
       size_type left = new_size;
-      
+     
       while (++(cur_next = cur) != end_n && left > 0){
          --left;
          cur = cur_next;
@@ -988,7 +988,7 @@ class slist
    //! Throws: Nothing.
    //!
    //! Complexity: Linear to the number of elements in the list.
-   void clear() 
+   void clear()
    {  this->icont().clear_and_dispose(Destroyer(this->node_alloc()));  }
 
    //! Requires: p must point to an element contained
@@ -1001,7 +1001,7 @@ class slist
    //!   are not equal.
    //!
    //! Complexity: Linear to the elements in x.
-   //! 
+   //!
    //! Note: 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_pos, slist& x)
@@ -1016,16 +1016,16 @@ class slist
 
    //! Requires: prev_pos must be a valid iterator of this.
    //!   i must point to an element contained in list x.
-   //! 
-   //! Effects: Transfers the value pointed by i, from list x to this list, 
+   //!
+   //! Effects: Transfers the value pointed by i, from list x to this list,
    //!   after the element pointed by prev_pos.
-   //!   If prev_pos == prev or prev_pos == ++prev, this function is a null operation. 
-   //! 
+   //!   If prev_pos == prev or prev_pos == ++prev, this function is a null operation.
+   //!
    //! Throws: std::runtime_error if this' allocator and x's allocator
    //!   are not equal.
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Note: 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_pos, slist& x, const_iterator prev)
@@ -1041,18 +1041,18 @@ class slist
    //! Requires: prev_pos must be a valid iterator of this.
    //!   before_first and before_last must be valid iterators of x.
    //!   prev_pos must not be contained in [before_first, before_last) range.
-   //! 
+   //!
    //! Effects: Transfers the range [before_first + 1, before_last + 1)
    //!   from list x to this list, after the element pointed by prev_pos.
-   //! 
+   //!
    //! Throws: std::runtime_error if this' allocator and x's allocator
    //!   are not equal.
-   //! 
+   //!
    //! Complexity: Linear to the number of transferred elements.
-   //! 
+   //!
    //! Note: 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_pos,      slist& x, 
+   void splice_after(const_iterator prev_pos,      slist& x,
       const_iterator before_first,  const_iterator before_last)
    {
       if((NodeAlloc&)*this == (NodeAlloc&)x){
@@ -1068,18 +1068,18 @@ class slist
    //!   before_first and before_last must be valid iterators of x.
    //!   prev_pos must not be contained in [before_first, before_last) range.
    //!   n == std::distance(before_first, before_last)
-   //! 
+   //!
    //! Effects: Transfers the range [before_first + 1, before_last + 1)
    //!   from list x to this list, after the element pointed by prev_pos.
-   //! 
+   //!
    //! Throws: std::runtime_error if this' allocator and x's allocator
    //!   are not equal.
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Note: 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_pos,      slist& x, 
+   void splice_after(const_iterator prev_pos,      slist& x,
                      const_iterator before_first,  const_iterator before_last,
                      size_type n)
    {
@@ -1102,24 +1102,24 @@ class slist
    //!   are not equal.
    //!
    //! Complexity: Linear in distance(begin(), p), and linear in x.size().
-   //! 
+   //!
    //! Note: 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) 
+   void splice(const_iterator p, ThisType& x)
    {  this->splice_after(this->previous(p), x);  }
 
    //! Requires: p must point to an element contained
    //!   by this list. i must point to an element contained in list x.
-   //! 
-   //! Effects: Transfers the value pointed by i, from list x to this list, 
+   //!
+   //! Effects: 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.
+   //!
    //! Throws: std::runtime_error if this' allocator and x's allocator
    //!   are not equal.
-   //! 
+   //!
    //! Complexity: Linear in distance(begin(), p), and in distance(x.begin(), i).
-   //! 
+   //!
    //! Note: 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)
@@ -1127,37 +1127,37 @@ class slist
 
    //! Requires: p must point to an element contained
    //!   by this list. first and last must point to elements contained in list x.
-   //! 
-   //! Effects: Transfers the range pointed by first and last from list x to this list, 
+   //!
+   //! Effects: 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.
-   //! 
+   //!
    //! Throws: std::runtime_error if this' allocator and x's allocator
    //!   are not equal.
-   //! 
+   //!
    //! Complexity: Linear in distance(begin(), p), in distance(x.begin(), first),
    //!   and in distance(first, last).
-   //! 
+   //!
    //! Note: 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)
    {  this->splice_after(previous(p), x, previous(first), previous(last));  }
 
-   //! Effects: Reverses the order of elements in the list. 
-   //! 
+   //! Effects: Reverses the order of elements in the list.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: This function is linear time.
-   //! 
+   //!
    //! Note: Iterators and references are not invalidated
-   void reverse() 
+   void reverse()
    {  this->icont().reverse();  }
 
    //! Effects: Removes all the elements that compare equal to value.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Linear time. It performs exactly size() comparisons for equality.
-   //! 
+   //!
    //! Note: 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)
@@ -1165,57 +1165,57 @@ class slist
 
    //! Effects: Removes all the elements for which a specified
    //!   predicate is satisfied.
-   //! 
+   //!
    //! Throws: If pred throws.
-   //! 
+   //!
    //! Complexity: Linear time. It performs exactly size() calls to the predicate.
-   //! 
+   //!
    //! Note: The relative order of elements that are not removed is unchanged,
    //!   and iterators to elements that are not removed remain valid.
-   template  
+   template 
    void remove_if(Pred pred)
    {
       typedef ValueCompareToNodeCompare Predicate;
       this->icont().remove_and_dispose_if(Predicate(pred), Destroyer(this->node_alloc()));
    }
 
-   //! Effects: Removes adjacent duplicate elements or adjacent 
+   //! Effects: Removes adjacent duplicate elements or adjacent
    //!   elements that are equal from the list.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Linear time (size()-1 comparisons calls to pred()).
-   //! 
+   //!
    //! Note: 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());  }
 
-   //! Effects: Removes adjacent duplicate elements or adjacent 
+   //! Effects: Removes adjacent duplicate elements or adjacent
    //!   elements that satisfy some binary predicate from the list.
-   //! 
+   //!
    //! Throws: If pred throws.
-   //! 
+   //!
    //! Complexity: Linear time (size()-1 comparisons equality comparisons).
-   //! 
+   //!
    //! Note: The relative order of elements that are not removed is unchanged,
    //!   and iterators to elements that are not removed remain valid.
-   template  
+   template 
    void unique(Pred pred)
    {
       typedef ValueCompareToNodeCompare Predicate;
       this->icont().unique_and_dispose(Predicate(pred), Destroyer(this->node_alloc()));
    }
 
-   //! Requires: The lists x and *this must be distinct. 
+   //! Requires: The lists x and *this must be distinct.
    //!
    //! Effects: This function removes all of x's elements and inserts them
-   //!   in order into *this according to std::less. 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. 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.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: This function is linear time: it performs at most
    //!   size() + x.size() - 1 comparisons.
    void merge(slist & x)
@@ -1223,17 +1223,17 @@ class slist
 
    //! Requires: 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.
+   //!
    //! Effects: 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.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: This function is linear time: it performs at most
    //!   size() + x.size() - 1 comparisons.
-   //! 
+   //!
    //! Note: Iterators and references to *this are not invalidated.
    template 
    void merge(slist& x, StrictWeakOrdering comp)
@@ -1247,28 +1247,28 @@ class slist
       }
    }
 
-   //! Effects: This function sorts the list *this according to std::less. 
+   //! Effects: This function sorts the list *this according to std::less.
    //!   The sort is stable, that is, the relative order of equivalent elements is preserved.
-   //! 
+   //!
    //! Throws: Nothing.
    //!
    //! Notes: Iterators and references are not invalidated.
-   //! 
+   //!
    //! Complexity: The number of comparisons is approximately N log N, where N
    //!   is the list's size.
    void sort()
    {  this->sort(value_less());  }
 
-   //! Effects: This function sorts the list *this according to std::less. 
+   //! Effects: This function sorts the list *this according to std::less.
    //!   The sort is stable, that is, the relative order of equivalent elements is preserved.
-   //! 
+   //!
    //! Throws: Nothing.
    //!
    //! Notes: Iterators and references are not invalidated.
-   //! 
+   //!
    //! Complexity: The number of comparisons is approximately N log N, where N
    //!   is the list's size.
-   template  
+   template 
    void sort(StrictWeakOrdering comp)
    {
       // nothing if the slist has length 0 or 1.
@@ -1279,10 +1279,10 @@ class slist
 
    /// @cond
    private:
-   iterator priv_insert(const_iterator p, const value_type& x) 
+   iterator priv_insert(const_iterator p, const value_type& x)
    {  return this->insert_after(previous(p), x); }
 
-   iterator priv_insert_after(const_iterator prev_pos, const value_type& x) 
+   iterator priv_insert_after(const_iterator prev_pos, const value_type& x)
    {  return iterator(this->icont().insert_after(prev_pos.get(), *this->create_node(x))); }
 
    void priv_push_front(const value_type &x)
@@ -1362,10 +1362,10 @@ class slist
    {  this->priv_create_and_insert_nodes(prev, first, last);   }
 
    template
-   void priv_insert_dispatch(const_iterator prev, Integer n, Integer x, container_detail::true_) 
+   void priv_insert_dispatch(const_iterator prev, Integer n, Integer x, container_detail::true_)
    {  this->priv_create_and_insert_nodes(prev, (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 end_n(this->end());
       iterator prev(this->before_begin());
@@ -1404,11 +1404,11 @@ class slist
    }
 
    template 
-   void priv_insert_after_range_dispatch(const_iterator prev_pos, Int n, Int x, container_detail::true_) 
+   void priv_insert_after_range_dispatch(const_iterator prev_pos, Int n, Int x, container_detail::true_)
    {  this->priv_create_and_insert_nodes(prev_pos, (size_type)n, x);  }
 
    template 
-   void priv_insert_after_range_dispatch(const_iterator prev_pos, InIter first, InIter last, container_detail::false_) 
+   void priv_insert_after_range_dispatch(const_iterator prev_pos, InIter first, InIter last, container_detail::false_)
    {  this->priv_create_and_insert_nodes(prev_pos, first, last); }
 
    //Functors for member algorithm defaults
@@ -1438,7 +1438,7 @@ class slist
 };
 
 template 
-inline bool 
+inline bool
 operator==(const slist& x, const slist& y)
 {
    if(x.size() != y.size()){
@@ -1465,27 +1465,27 @@ operator<(const slist& sL1, const slist& sL2)
 }
 
 template 
-inline bool 
-operator!=(const slist& sL1, const slist& sL2) 
+inline bool
+operator!=(const slist& sL1, const slist& sL2)
    {  return !(sL1 == sL2);   }
 
 template 
-inline bool 
-operator>(const slist& sL1, const slist& sL2) 
+inline bool
+operator>(const slist& sL1, const slist& sL2)
    {  return sL2 < sL1; }
 
 template 
-inline bool 
+inline bool
 operator<=(const slist& sL1, const slist& sL2)
    {  return !(sL2 < sL1); }
 
 template 
-inline bool 
+inline bool
 operator>=(const slist& sL1, const slist& sL2)
    {  return !(sL1 < sL2); }
 
 template 
-inline void swap(slist& x, slist& y) 
+inline void swap(slist& x, slist& y)
    {  x.swap(y);  }
 
 }}
@@ -1513,12 +1513,12 @@ namespace container {
 
 ///@cond
 
-//Ummm, I don't like to define things in namespace std, but 
+//Ummm, I don't like to define things in namespace std, but
 //there is no other way
 namespace std {
 
 template 
-class insert_iterator > 
+class insert_iterator >
 {
  protected:
    typedef boost::container::slist Container;
@@ -1532,14 +1532,14 @@ class insert_iterator >
    typedef void                pointer;
    typedef void                reference;
 
-   insert_iterator(Container& x, 
-                   typename Container::iterator i, 
-                   bool is_previous = false) 
+   insert_iterator(Container& x,
+                   typename Container::iterator i,
+                   bool is_previous = false)
       : container(&x), iter(is_previous ? i : x.previous(i)){ }
 
-   insert_iterator& 
-      operator=(const typename Container::value_type& value) 
-   { 
+   insert_iterator&
+      operator=(const typename Container::value_type& value)
+   {
       iter = container->insert_after(iter, value);
       return *this;
    }
diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp
index c6ca778..d91eccd 100644
--- a/include/boost/container/stable_vector.hpp
+++ b/include/boost/container/stable_vector.hpp
@@ -93,7 +93,7 @@ class clear_on_destroy
    {
       if(do_clear_){
          c_.clear();
-         c_.clear_pool();  
+         c_.clear_pool(); 
       }
    }
 
@@ -172,7 +172,7 @@ class iterator
    iterator(const iterator::template rebind_pointer::type>& x)
       : pn(x.pn)
    {}
-   
+  
    private:
    static node_type_ptr_t node_ptr_cast(const void_ptr &p)
    {
@@ -208,7 +208,7 @@ class iterator
    pointer   operator->() const {  return  pointer(&this->dereference());  }
 
    //Increment / Decrement
-   iterator& operator++()  
+   iterator& operator++() 
    {  this->increment(); return *this;  }
 
    iterator operator++(int)
@@ -328,11 +328,11 @@ BOOST_JOIN(check_invariant_,__LINE__).touch();
 //! stability.
 //!
 //! More details taken the author's blog:
-//! ( 
+//! (
 //! Introducing stable_vector)
 //!
 //! We present stable_vector, a fully STL-compliant stable container that provides
-//! most of the features of std::vector except element contiguity. 
+//! most of the features of std::vector except element contiguity.
 //!
 //! General properties: stable_vector satisfies all the requirements of a container,
 //! a reversible container and a sequence and provides all the optional operations
@@ -398,7 +398,7 @@ class stable_vector
       integral_constant                  allocator_v1;
    typedef ::boost::container::container_detail::
       integral_constant                  allocator_v2;
-   typedef ::boost::container::container_detail::integral_constant 
+   typedef ::boost::container::container_detail::integral_constant
       ::value>                              alloc_version;
    typedef typename allocator_traits_type::
@@ -481,9 +481,9 @@ class stable_vector
    public:
 
    //! Effects: Default constructs a stable_vector.
-   //! 
+   //!
    //! Throws: If allocator_type's default constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
    stable_vector()
       : internal_data(), impl()
@@ -492,9 +492,9 @@ class stable_vector
    }
 
    //! Effects: Constructs a stable_vector taking the allocator as parameter.
-   //! 
+   //!
    //! Throws: If allocator_type's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
    explicit stable_vector(const allocator_type& al)
       : internal_data(al),impl(al)
@@ -507,7 +507,7 @@ class stable_vector
    //!
    //! Throws: If allocator_type's default constructor or copy constructor
    //!   throws or T's default or copy constructor throws.
-   //! 
+   //!
    //! Complexity: Linear to n.
    explicit stable_vector(size_type n)
       : internal_data(),impl()
@@ -523,7 +523,7 @@ class stable_vector
    //!
    //! Throws: If allocator_type's default constructor or copy constructor
    //!   throws or T's default or copy constructor throws.
-   //! 
+   //!
    //! Complexity: Linear to n.
    stable_vector(size_type n, const T& t, const allocator_type& al = allocator_type())
       : internal_data(al),impl(al)
@@ -554,7 +554,7 @@ class stable_vector
    //! Effects: Copy constructs a stable_vector.
    //!
    //! Postcondition: x == *this.
-   //! 
+   //!
    //! Complexity: Linear to the elements x contains.
    stable_vector(const stable_vector& x)
       : internal_data(allocator_traits::
@@ -571,7 +571,7 @@ class stable_vector
    //! Effects: Move constructor. Moves mx's resources to *this.
    //!
    //! Throws: If allocator_type's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
    stable_vector(BOOST_RV_REF(stable_vector) x)
       : internal_data(boost::move(x.node_alloc())), impl(boost::move(x.impl))
@@ -582,7 +582,7 @@ class stable_vector
    //! Effects: Copy constructs a stable_vector using the specified allocator.
    //!
    //! Postcondition: x == *this.
-   //! 
+   //!
    //! Complexity: Linear to the elements x contains.
    stable_vector(const stable_vector& x, const allocator_type &a)
       : internal_data(a), impl(a)
@@ -597,7 +597,7 @@ class stable_vector
    //!                 Moves mx's resources to *this.
    //!
    //! Throws: If allocator_type's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant if a == x.get_allocator(), linear otherwise
    stable_vector(BOOST_RV_REF(stable_vector) x, const allocator_type &a)
       : internal_data(a), impl(a)
@@ -622,13 +622,13 @@ class stable_vector
    ~stable_vector()
    {
       this->clear();
-      clear_pool();  
+      clear_pool(); 
    }
 
    //! Effects: Makes *this contain the same elements as x.
    //!
-   //! Postcondition: this->size() == x.size(). *this contains a copy 
-   //! of each of x's elements. 
+   //! Postcondition: this->size() == x.size(). *this contains a copy
+   //! of each of x's elements.
    //!
    //! Throws: If memory allocation throws or T's copy constructor throws.
    //!
@@ -711,146 +711,146 @@ class stable_vector
    }
 
    //! Effects: Returns a copy of the internal allocator.
-   //! 
+   //!
    //! Throws: If allocator's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
    allocator_type get_allocator()const  {return this->node_alloc();}
 
    //! Effects: Returns a reference to the internal allocator.
-   //! 
+   //!
    //! Throws: Nothing
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Note: Non-standard extension.
    const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
    {  return node_alloc(); }
 
    //! Effects: Returns a reference to the internal allocator.
-   //! 
+   //!
    //! Throws: Nothing
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Note: Non-standard extension.
    stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
    {  return node_alloc(); }
 
 
    //! Effects: Returns an iterator to the first element contained in the stable_vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    iterator  begin()
    {   return (impl.empty()) ? end(): iterator(node_ptr_cast(impl.front())) ;   }
 
    //! Effects: Returns a const_iterator to the first element contained in the stable_vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator  begin()const
    {   return (impl.empty()) ? cend() : const_iterator(node_ptr_cast(impl.front())) ;   }
 
    //! Effects: Returns an iterator to the end of the stable_vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    iterator        end()                {return iterator(get_end_node());}
 
    //! Effects: Returns a const_iterator to the end of the stable_vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator  end()const           {return const_iterator(get_end_node());}
 
-   //! Effects: Returns a reverse_iterator pointing to the beginning 
-   //! of the reversed stable_vector. 
-   //! 
+   //! Effects: Returns a reverse_iterator pointing to the beginning
+   //! of the reversed stable_vector.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reverse_iterator       rbegin()      {return reverse_iterator(this->end());}
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed stable_vector. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed stable_vector.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reverse_iterator rbegin()const {return const_reverse_iterator(this->end());}
 
    //! Effects: Returns a reverse_iterator pointing to the end
-   //! of the reversed stable_vector. 
-   //! 
+   //! of the reversed stable_vector.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reverse_iterator       rend()        {return reverse_iterator(this->begin());}
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed stable_vector. 
-   //! 
+   //! of the reversed stable_vector.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reverse_iterator rend()const   {return const_reverse_iterator(this->begin());}
 
    //! Effects: Returns a const_iterator to the first element contained in the stable_vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator         cbegin()const {return this->begin();}
 
    //! Effects: Returns a const_iterator to the end of the stable_vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator         cend()const   {return this->end();}
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed stable_vector. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed stable_vector.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reverse_iterator crbegin()const{return this->rbegin();}
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed stable_vector. 
-   //! 
+   //! of the reversed stable_vector.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reverse_iterator crend()const  {return this->rend();}
 
    //! Effects: Returns the number of the elements contained in the stable_vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    size_type size() const
    {  return impl.empty() ? 0 : (impl.size() - ExtraPointers);   }
 
    //! Effects: Returns the largest possible size of the stable_vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    size_type max_size() const
    {  return impl.max_size() - ExtraPointers;  }
 
    //! Effects: Number of elements for which memory has been allocated.
    //!   capacity() is always greater than or equal to size().
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    size_type capacity() const
    {
@@ -865,9 +865,9 @@ class stable_vector
    }
 
    //! Effects: Returns true if the stable_vector contains no elements.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    bool empty() const
    {  return impl.empty() || impl.size() == ExtraPointers;  }
@@ -907,7 +907,7 @@ class stable_vector
    //!   effect. Otherwise, it is a request for allocation of additional memory.
    //!   If the request is successful, then capacity() is greater than or equal to
    //!   n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
-   //! 
+   //!
    //! Throws: If memory allocation allocation throws.
    void reserve(size_type n)
    {
@@ -915,7 +915,7 @@ class stable_vector
       if(n > this->max_size())
          throw std::bad_alloc();
 
-      size_type size = this->size();   
+      size_type size = this->size();  
       size_type old_capacity = this->capacity();
       if(n > old_capacity){
          this->initialize_end_node(n);
@@ -935,31 +935,31 @@ class stable_vector
 
    //! Requires: size() > n.
    //!
-   //! Effects: Returns a reference to the nth element 
+   //! Effects: Returns a reference to the nth element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reference operator[](size_type n){return value(impl[n]);}
 
    //! Requires: size() > n.
    //!
-   //! Effects: Returns a const reference to the nth element 
+   //! Effects: Returns a const reference to the nth element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reference operator[](size_type n)const{return value(impl[n]);}
 
    //! Requires: size() > n.
    //!
-   //! Effects: Returns a reference to the nth element 
+   //! Effects: Returns a reference to the nth element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: std::range_error if n >= size()
-   //! 
+   //!
    //! Complexity: Constant.
    reference at(size_type n)
    {
@@ -970,11 +970,11 @@ class stable_vector
 
    //! Requires: size() > n.
    //!
-   //! Effects: Returns a const reference to the nth element 
+   //! Effects: Returns a const reference to the nth element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: std::range_error if n >= size()
-   //! 
+   //!
    //! Complexity: Constant.
    const_reference at(size_type n)const
    {
@@ -987,9 +987,9 @@ class stable_vector
    //!
    //! Effects: Returns a reference to the first
    //!   element of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reference front()
    {  return value(impl.front());   }
@@ -998,9 +998,9 @@ class stable_vector
    //!
    //! Effects: Returns a const reference to the first
    //!   element of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reference front()const
    {  return value(impl.front());   }
@@ -1009,9 +1009,9 @@ class stable_vector
    //!
    //! Effects: Returns a reference to the last
    //!   element of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reference back()
    {  return value(*(&impl.back() - ExtraPointers)); }
@@ -1020,9 +1020,9 @@ class stable_vector
    //!
    //! Effects: Returns a const reference to the last
    //!   element of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reference back()const
    {  return value(*(&impl.back() - ExtraPointers)); }
@@ -1033,7 +1033,7 @@ class stable_vector
    //!   T's copy constructor throws.
    //!
    //! Complexity: Amortized constant time.
-   void push_back(insert_const_ref_type x) 
+   void push_back(insert_const_ref_type x)
    {  return priv_push_back(x);  }
 
    #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1051,7 +1051,7 @@ class stable_vector
    //! Throws: If memory allocation throws.
    //!
    //! Complexity: Amortized constant time.
-   void push_back(BOOST_RV_REF(T) t) 
+   void push_back(BOOST_RV_REF(T) t)
    {  this->insert(end(), boost::move(t));  }
 
    //! Effects: Removes the last element from the stable_vector.
@@ -1070,7 +1070,7 @@ class stable_vector
    //!
    //! Complexity: If position is end(), amortized constant time
    //!   Linear time otherwise.
-   iterator insert(const_iterator position, insert_const_ref_type x) 
+   iterator insert(const_iterator position, insert_const_ref_type x)
    {  return this->priv_insert(position, x); }
 
    #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1090,7 +1090,7 @@ class stable_vector
    //!
    //! Complexity: If position is end(), amortized constant time
    //!   Linear time otherwise.
-   iterator insert(const_iterator position, BOOST_RV_REF(T) x) 
+   iterator insert(const_iterator position, BOOST_RV_REF(T) x)
    {
       typedef repeat_iterator           repeat_it;
       typedef boost::move_iterator repeat_move_it;
@@ -1210,7 +1210,7 @@ class stable_vector
    //!
    //! Throws: Nothing.
    //!
-   //! Complexity: Linear to the elements between pos and the 
+   //! Complexity: Linear to the elements between pos and the
    //!   last element. Constant if pos is the last element.
    iterator erase(const_iterator position)
    {
@@ -1581,7 +1581,7 @@ class stable_vector
    {
       for(; first!=last; ++first){
          this->insert(position, *first);
-      }    
+      }   
    }
 
    template 
@@ -1692,7 +1692,7 @@ class stable_vector
          return false;
       }
       for(const_impl_iterator it = impl.begin(), it_end = get_last_align(); it != it_end; ++it){
-         if(const_void_ptr(node_ptr_cast(*it)->up) != 
+         if(const_void_ptr(node_ptr_cast(*it)->up) !=
                const_void_ptr(const_void_ptr_ptr(&*it)))
             return false;
       }
diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp
index 5821f02..dc2fdd9 100644
--- a/include/boost/container/string.hpp
+++ b/include/boost/container/string.hpp
@@ -50,8 +50,8 @@
 
 #include 
 #include 
-#include       
-#include   
+#include      
+#include  
 #include 
 #include 
 #include 
@@ -78,14 +78,14 @@ namespace container {
 /// @cond
 namespace container_detail {
 // ------------------------------------------------------------
-// Class basic_string_base.  
+// Class basic_string_base. 
 
 // basic_string_base is a helper class that makes it it easier to write
 // an exception-safe version of basic_string.  The constructor allocates,
 // but does not initialize, a block of memory.  The destructor
 // deallocates, but does not destroy elements within, a block of
-// memory.  The destructor assumes that the memory either is the internal buffer, 
-// or else points to a block of memory that was allocated using _String_base's 
+// memory.  The destructor assumes that the memory either is the internal buffer,
+// or else points to a block of memory that was allocated using _String_base's
 // allocator and whose size is this->m_storage.
 template 
 class basic_string_base
@@ -111,22 +111,22 @@ class basic_string_base
 
    basic_string_base(const allocator_type& a, size_type n)
       : members_(a)
-   {  
-      this->init(); 
+   { 
+      this->init();
       this->allocate_initial_block(n);
    }
 
    basic_string_base(BOOST_RV_REF(basic_string_base) b)
       :  members_(boost::move(b.alloc()))
-   {  
+   { 
       this->init();
-      this->swap_data(b); 
+      this->swap_data(b);
    }
 
-   ~basic_string_base() 
-   {  
+   ~basic_string_base()
+   { 
       if(!this->is_short()){
-         this->deallocate_block(); 
+         this->deallocate_block();
          allocator_traits_type::destroy
             ( this->alloc()
             , static_cast(static_cast(&this->members_.m_repr.r))
@@ -136,7 +136,7 @@ class basic_string_base
 
    private:
 
-   //This is the structure controlling a long string 
+   //This is the structure controlling a long string
    struct long_t
    {
       size_type      is_short  : 1;
@@ -175,8 +175,8 @@ class basic_string_base
 
    //This type has the same alignment and size as long_t but it's POD
    //so, unlike long_t, it can be placed in a union
-   
-   typedef typename boost::aligned_storage< sizeof(long_t), 
+  
+   typedef typename boost::aligned_storage< sizeof(long_t),
        container_detail::alignment_of::value>::type   long_raw_t;
 
    protected:
@@ -187,13 +187,13 @@ class basic_string_base
       container_detail::ct_rounded_size::value;
    static const size_type  ZeroCostInternalBufferChars =
       (sizeof(long_t) - ShortDataOffset)/sizeof(value_type);
-   static const size_type  UnalignedFinalInternalBufferChars = 
+   static const size_type  UnalignedFinalInternalBufferChars =
       (ZeroCostInternalBufferChars > MinInternalBufferChars) ?
                 ZeroCostInternalBufferChars : MinInternalBufferChars;
 
    struct short_t
    {
-      short_header   h; 
+      short_header   h;
       value_type     data[UnalignedFinalInternalBufferChars];
    };
 
@@ -241,7 +241,7 @@ class basic_string_base
    {  return static_cast(this->members_.m_repr.s.h.is_short != 0);  }
 
    void is_short(bool yes)
-   {  
+   { 
       if(yes && !this->is_short()){
          allocator_traits_type::destroy
             ( this->alloc()
@@ -273,7 +273,7 @@ class basic_string_base
 
    std::pair
       allocation_command(allocation_type command,
-                         size_type limit_size, 
+                         size_type limit_size,
                          size_type preferred_size,
                          size_type &received_size, pointer reuse = 0)
    {
@@ -287,7 +287,7 @@ class basic_string_base
 
    std::pair
       allocation_command(allocation_type command,
-                         size_type limit_size, 
+                         size_type limit_size,
                          size_type preferred_size,
                          size_type &received_size,
                          const pointer &reuse,
@@ -303,21 +303,21 @@ class basic_string_base
 
    std::pair
       allocation_command(allocation_type command,
-                         size_type limit_size, 
+                         size_type limit_size,
                          size_type preferred_size,
                          size_type &received_size,
                          pointer reuse,
                          allocator_v2)
    {
-      return this->alloc().allocation_command(command, limit_size, preferred_size, 
+      return this->alloc().allocation_command(command, limit_size, preferred_size,
                                               received_size, reuse);
    }
 
    size_type next_capacity(size_type additional_objects) const
    {  return get_next_capacity(allocator_traits_type::max_size(this->alloc()), this->priv_storage(), additional_objects);  }
 
-   void deallocate(pointer p, size_type n) 
-   {  
+   void deallocate(pointer p, size_type n)
+   { 
       if (p && (n > InternalBufferChars))
          this->alloc().deallocate(p, n);
    }
@@ -365,9 +365,9 @@ class basic_string_base
          throw_length_error();
    }
 
-   void deallocate_block() 
+   void deallocate_block()
    {  this->deallocate(this->priv_addr(), this->priv_storage());  }
-      
+     
    size_type max_size() const
    {  return allocator_traits_type::max_size(this->alloc()) - 1; }
 
@@ -404,13 +404,13 @@ class basic_string_base
    {  return this->members_.m_repr.long_repr().storage;  }
 
    void priv_storage(size_type storage)
-   {  
+   { 
       if(!this->is_short())
          this->priv_long_storage(storage);
    }
 
    void priv_long_storage(size_type storage)
-   {  
+   { 
       this->members_.m_repr.long_repr().storage = storage;
    }
 
@@ -424,7 +424,7 @@ class basic_string_base
    {  return this->members_.m_repr.long_repr().length;  }
 
    void priv_size(size_type sz)
-   {  
+   { 
       if(this->is_short())
          this->priv_short_size(sz);
       else
@@ -432,12 +432,12 @@ class basic_string_base
    }
 
    void priv_short_size(size_type sz)
-   {  
+   { 
       this->members_.m_repr.s.h.length = (unsigned char)sz;
    }
 
    void priv_long_size(size_type sz)
-   {  
+   { 
       this->members_.m_repr.long_repr().length = static_cast(sz);
    }
 
@@ -470,41 +470,41 @@ class basic_string_base
 
 /// @endcond
 
-//! The basic_string class represents a Sequence of characters. It contains all the 
-//! usual operations of a Sequence, and, additionally, it contains standard string 
+//! The basic_string class represents a Sequence of characters. It contains all the
+//! usual operations of a Sequence, and, additionally, it contains standard string
 //! operations such as search and concatenation.
 //!
-//! The basic_string class is parameterized by character type, and by that type's 
+//! The basic_string class is parameterized by character type, and by that type's
 //! Character Traits.
-//! 
-//! This class has performance characteristics very much like vector<>, meaning, 
+//!
+//! This class has performance characteristics very much like vector<>, meaning,
 //! for example, that it does not perform reference-count or copy-on-write, and that
-//! concatenation of two strings is an O(N) operation. 
-//! 
-//! Some of basic_string's member functions use an unusual method of specifying positions 
-//! and ranges. In addition to the conventional method using iterators, many of 
-//! basic_string's member functions use a single value pos of type size_type to represent a 
-//! position (in which case the position is begin() + pos, and many of basic_string's 
-//! member functions use two values, pos and n, to represent a range. In that case pos is 
-//! the beginning of the range and n is its size. That is, the range is 
-//! [begin() + pos, begin() + pos + n). 
-//! 
-//! Note that the C++ standard does not specify the complexity of basic_string operations. 
-//! In this implementation, basic_string has performance characteristics very similar to 
-//! those of vector: access to a single character is O(1), while copy and concatenation 
+//! concatenation of two strings is an O(N) operation.
+//!
+//! Some of basic_string's member functions use an unusual method of specifying positions
+//! and ranges. In addition to the conventional method using iterators, many of
+//! basic_string's member functions use a single value pos of type size_type to represent a
+//! position (in which case the position is begin() + pos, and many of basic_string's
+//! member functions use two values, pos and n, to represent a range. In that case pos is
+//! the beginning of the range and n is its size. That is, the range is
+//! [begin() + pos, begin() + pos + n).
+//!
+//! Note that the C++ standard does not specify the complexity of basic_string operations.
+//! In this implementation, basic_string has performance characteristics very similar to
+//! those of vector: access to a single character is O(1), while copy and concatenation
 //! are O(N).
-//! 
-//! In this implementation, begin(), 
+//!
+//! In this implementation, begin(),
 //! end(), rbegin(), rend(), operator[], c_str(), and data() do not invalidate iterators.
 //! In this implementation, iterators are only invalidated by member functions that
-//! explicitly change the string's contents. 
+//! explicitly change the string's contents.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
 template , class A = std::allocator >
 #else
 template 
 #endif
 class basic_string
-   :  private container_detail::basic_string_base 
+   :  private container_detail::basic_string_base
 {
    /// @cond
    private:
@@ -535,12 +535,12 @@ class basic_string
       const Pointer m_first;
       const Pointer m_last;
 
-      Not_within_traits(Pointer f, Pointer l) 
+      Not_within_traits(Pointer f, Pointer l)
          : m_first(f), m_last(l) {}
 
-      bool operator()(const typename Tr::char_type& x) const 
+      bool operator()(const typename Tr::char_type& x) const
       {
-         return std::find_if(m_first, m_last, 
+         return std::find_if(m_first, m_last,
                         std::bind1st(Eq_traits(), x)) == m_last;
       }
    };
@@ -558,11 +558,11 @@ class basic_string
    typedef Traits                                  traits_type;
    //! Pointer to CharT
    typedef typename allocator_traits_type::pointer pointer;
-   //! Const pointer to CharT 
+   //! Const pointer to CharT
    typedef typename allocator_traits_type::const_pointer               const_pointer;
-   //! Reference to CharT 
+   //! Reference to CharT
    typedef typename allocator_traits_type::reference                   reference;
-   //! Const reference to CharT 
+   //! Const reference to CharT
    typedef typename allocator_traits_type::const_reference             const_reference;
    //! An unsigned integral type
    typedef typename allocator_traits_type::size_type                   size_type;
@@ -576,7 +576,7 @@ class basic_string
    typedef std::reverse_iterator       reverse_iterator;
    //! Const iterator used to iterate backwards through a string
    typedef std::reverse_iterator const_reverse_iterator;
-   //! The largest possible value of type size_type. That is, size_type(-1). 
+   //! The largest possible value of type size_type. That is, size_type(-1).
    static const size_type npos;
 
    /// @cond
@@ -602,7 +602,7 @@ class basic_string
    /// @endcond
 
    //! Effects: Default constructs a basic_string.
-   //! 
+   //!
    //! Throws: If allocator_type's default constructor throws.
    basic_string()
       : base_t()
@@ -610,7 +610,7 @@ class basic_string
 
 
    //! Effects: Constructs a basic_string taking the allocator as parameter.
-   //! 
+   //!
    //! Throws: If allocator_type's copy constructor throws.
    explicit basic_string(const allocator_type& a)
       : base_t(a)
@@ -619,27 +619,27 @@ class basic_string
    //! Effects: Copy constructs a basic_string.
    //!
    //! Postcondition: x == *this.
-   //! 
+   //!
    //! Throws: If allocator_type's default constructor throws.
-   basic_string(const basic_string& s) 
+   basic_string(const basic_string& s)
       :  base_t(allocator_traits_type::select_on_container_copy_construction(s.alloc()))
    { this->priv_range_initialize(s.begin(), s.end()); }
 
    //! Effects: Move constructor. Moves s's resources to *this.
    //!
    //! Throws: If allocator_type's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
-   basic_string(BOOST_RV_REF(basic_string) s) 
+   basic_string(BOOST_RV_REF(basic_string) s)
       : base_t(boost::move((base_t&)s))
    {}
 
    //! Effects: Copy constructs a basic_string using the specified allocator.
    //!
    //! Postcondition: x == *this.
-   //! 
+   //!
    //! Throws: If allocation throws.
-   basic_string(const basic_string& s, const allocator_type &a) 
+   basic_string(const basic_string& s, const allocator_type &a)
       :  base_t(a)
    { this->priv_range_initialize(s.begin(), s.end()); }
 
@@ -647,9 +647,9 @@ class basic_string
    //!                 Moves s's resources to *this.
    //!
    //! Throws: If allocation throws.
-   //! 
+   //!
    //! Complexity: Constant if a == s.get_allocator(), linear otherwise.
-   basic_string(BOOST_RV_REF(basic_string) s, const allocator_type &a) 
+   basic_string(BOOST_RV_REF(basic_string) s, const allocator_type &a)
       : base_t(a)
    {
       if(a == this->alloc()){
@@ -661,10 +661,10 @@ class basic_string
    }
 
    //! Effects: Constructs a basic_string taking the allocator as parameter,
-   //!   and is initialized by a specific number of characters of the s string. 
+   //!   and is initialized by a specific number of characters of the s string.
    basic_string(const basic_string& s, size_type pos, size_type n = npos,
-               const allocator_type& a = allocator_type()) 
-      : base_t(a) 
+               const allocator_type& a = allocator_type())
+      : base_t(a)
    {
       if (pos > s.size())
          this->throw_out_of_range();
@@ -676,15 +676,15 @@ class basic_string
    //! Effects: Constructs a basic_string taking the allocator as parameter,
    //!   and is initialized by a specific number of characters of the s c-string.
    basic_string(const CharT* s, size_type n,
-               const allocator_type& a = allocator_type()) 
-      : base_t(a) 
+               const allocator_type& a = allocator_type())
+      : base_t(a)
    { this->priv_range_initialize(s, s + n); }
 
    //! Effects: Constructs a basic_string taking the allocator as parameter,
    //!   and is initialized by the null-terminated s c-string.
    basic_string(const CharT* s,
                 const allocator_type& a = allocator_type())
-      : base_t(a) 
+      : base_t(a)
    { this->priv_range_initialize(s, s + Traits::length(s)); }
 
    //! Effects: Constructs a basic_string taking the allocator as parameter,
@@ -692,7 +692,7 @@ class basic_string
    basic_string(size_type n, CharT c,
                 const allocator_type& a = allocator_type())
       : base_t(a)
-   {  
+   { 
       this->priv_range_initialize(cvalue_iterator(c, n),
                                   cvalue_iterator());
    }
@@ -715,13 +715,13 @@ class basic_string
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   ~basic_string() 
+   ~basic_string()
    {}
-      
+     
    //! Effects: Copy constructs a string.
    //!
    //! Postcondition: x == *this.
-   //! 
+   //!
    //! Complexity: Linear to the elements x contains.
    basic_string& operator=(BOOST_COPY_ASSIGN_REF(basic_string) x)
    {
@@ -747,7 +747,7 @@ class basic_string
    //! Effects: Move constructor. Moves mx's resources to *this.
    //!
    //! Throws: If allocator_type's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
    basic_string& operator=(BOOST_RV_REF(basic_string) x)
    {
@@ -773,7 +773,7 @@ class basic_string
    }
 
    //! Effects: Assignment from a null-terminated c-string.
-   basic_string& operator=(const CharT* s) 
+   basic_string& operator=(const CharT* s)
    { return this->assign(s, s + Traits::length(s)); }
 
    //! Effects: Assignment from character.
@@ -781,155 +781,155 @@ class basic_string
    { return this->assign(static_cast(1), c); }
 
    //! Effects: Returns an iterator to the first element contained in the vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    iterator begin()
    { return this->priv_addr(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator begin() const
    { return this->priv_addr(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator cbegin() const
    { return this->priv_addr(); }
 
    //! Effects: Returns an iterator to the end of the vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    iterator end()
    { return this->priv_addr() + this->priv_size(); }
 
    //! Effects: Returns a const_iterator to the end of the vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator end() const 
-   { return this->priv_addr() + this->priv_size(); }  
+   const_iterator end() const
+   { return this->priv_addr() + this->priv_size(); } 
 
    //! Effects: Returns a const_iterator to the end of the vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_iterator cend() const 
-   { return this->priv_addr() + this->priv_size(); }  
+   const_iterator cend() const
+   { return this->priv_addr() + this->priv_size(); } 
 
-   //! Effects: Returns a reverse_iterator pointing to the beginning 
-   //! of the reversed vector. 
-   //! 
+   //! Effects: Returns a reverse_iterator pointing to the beginning
+   //! of the reversed vector.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reverse_iterator rbegin()             
+   reverse_iterator rbegin()            
    { return reverse_iterator(this->priv_addr() + this->priv_size()); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed vector. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed vector.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator rbegin() const 
+   const_reverse_iterator rbegin() const
    { return this->crbegin(); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed vector. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed vector.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin() const 
+   const_reverse_iterator crbegin() const
    { return const_reverse_iterator(this->priv_addr() + this->priv_size()); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
-   //! of the reversed vector. 
-   //! 
+   //! of the reversed vector.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reverse_iterator rend()               
+   reverse_iterator rend()              
    { return reverse_iterator(this->priv_addr()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed vector. 
-   //! 
+   //! of the reversed vector.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator rend()   const 
+   const_reverse_iterator rend()   const
    { return this->crend(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed vector. 
-   //! 
+   //! of the reversed vector.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   const_reverse_iterator crend()   const 
+   const_reverse_iterator crend()   const
    { return const_reverse_iterator(this->priv_addr()); }
 
    //! Effects: Returns a copy of the internal allocator.
-   //! 
+   //!
    //! Throws: If allocator's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
-   allocator_type get_allocator() const 
+   allocator_type get_allocator() const
    { return this->alloc(); }
 
    //! Effects: Returns a reference to the internal allocator.
-   //! 
+   //!
    //! Throws: Nothing
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Note: Non-standard extension.
    const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
    {  return this->alloc(); }
 
    //! Effects: Returns a reference to the internal allocator.
-   //! 
+   //!
    //! Throws: Nothing
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Note: Non-standard extension.
    stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
    {  return this->alloc(); }
 
    //! Effects: Returns the number of the elements contained in the vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   size_type size() const    
+   size_type size() const   
    { return this->priv_size(); }
 
    //! Effects: Returns the number of the elements contained in the vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    size_type length() const
    { return this->size(); }
 
    //! Effects: Returns the largest possible size of the vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    size_type max_size() const
    { return base_t::max_size(); }
@@ -961,7 +961,7 @@ class basic_string
    //!   effect. Otherwise, it is a request for allocation of additional memory.
    //!   If the request is successful, then capacity() is greater than or equal to
    //!   n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
-   //! 
+   //!
    //! Throws: If memory allocation allocation throws
    void reserve(size_type res_arg)
    {
@@ -988,9 +988,9 @@ class basic_string
 
    //! Effects: Number of elements for which memory has been allocated.
    //!   capacity() is always greater than or equal to size().
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    size_type capacity() const
    { return this->priv_capacity(); }
@@ -1040,42 +1040,42 @@ class basic_string
    }
 
    //! Effects: Returns true if the vector contains no elements.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    bool empty() const
    { return !this->priv_size(); }
 
    //! Requires: size() > n.
    //!
-   //! Effects: Returns a reference to the nth element 
+   //! Effects: Returns a reference to the nth element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reference operator[](size_type n)
       { return *(this->priv_addr() + n); }
 
    //! Requires: size() > n.
    //!
-   //! Effects: Returns a const reference to the nth element 
+   //! Effects: Returns a const reference to the nth element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reference operator[](size_type n) const
       { return *(this->priv_addr() + n); }
 
    //! Requires: size() > n.
    //!
-   //! Effects: Returns a reference to the nth element 
+   //! Effects: Returns a reference to the nth element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: std::range_error if n >= size()
-   //! 
+   //!
    //! Complexity: Constant.
    reference at(size_type n) {
       if (n >= size())
@@ -1085,11 +1085,11 @@ class basic_string
 
    //! Requires: size() > n.
    //!
-   //! Effects: Returns a const reference to the nth element 
+   //! Effects: Returns a const reference to the nth element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: std::range_error if n >= size()
-   //! 
+   //!
    //! Complexity: Constant.
    const_reference at(size_type n) const {
       if (n >= size())
@@ -1118,12 +1118,12 @@ class basic_string
    //! Effects: Calls append(str.data(), str.size()).
    //!
    //! Returns: *this
-   basic_string& append(const basic_string& s) 
+   basic_string& append(const basic_string& s)
    {  return this->append(s.begin(), s.end());  }
 
    //! Requires: pos <= str.size()
    //!
-   //! Effects: Determines the effective length rlen of the string to append 
+   //! Effects: Determines the effective length rlen of the string to append
    //! as the smaller of n and str.size() - pos and calls append(str.data() + pos, rlen).
    //!
    //! Throws: If memory allocation throws and out_of_range if pos > str.size()
@@ -1147,7 +1147,7 @@ class basic_string
    //! Throws: If memory allocation throws length_error if size() + n > max_size().
    //!
    //! Returns: *this
-   basic_string& append(const CharT* s, size_type n) 
+   basic_string& append(const CharT* s, size_type n)
    {  return this->append(s, s + n);  }
 
    //! Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.
@@ -1155,7 +1155,7 @@ class basic_string
    //! Effects: Calls append(s, traits::length(s)).
    //!
    //! Returns: *this
-   basic_string& append(const CharT* s) 
+   basic_string& append(const CharT* s)
    {  return this->append(s, s + Traits::length(s));  }
 
    //! Effects: Equivalent to append(basic_string(n, c)).
@@ -1190,17 +1190,17 @@ class basic_string
    //! Effects: Equivalent to assign(str, 0, npos).
    //!
    //! Returns: *this
-   basic_string& assign(const basic_string& s) 
+   basic_string& assign(const basic_string& s)
    {  return this->operator=(s); }
 
    //! Effects: The function replaces the string controlled by *this
-   //!    with a string of length str.size() whose elements are a copy of the string 
+   //!    with a string of length str.size() whose elements are a copy of the string
    //!   controlled by str. Leaves str in a valid but unspecified state.
    //!
    //! Throws: Nothing
    //!
    //! Returns: *this
-   basic_string& assign(BOOST_RV_REF(basic_string) ms) 
+   basic_string& assign(BOOST_RV_REF(basic_string) ms)
    {  return this->swap_data(ms), *this;  }
 
    //! Requires: pos <= str.size()
@@ -1211,11 +1211,11 @@ class basic_string
    //! Throws: If memory allocation throws or out_of_range if pos > str.size().
    //!
    //! Returns: *this
-   basic_string& assign(const basic_string& s, 
+   basic_string& assign(const basic_string& s,
                         size_type pos, size_type n) {
       if (pos > s.size())
       this->throw_out_of_range();
-      return this->assign(s.begin() + pos, 
+      return this->assign(s.begin() + pos,
                           s.begin() + pos + container_detail::min_value(n, s.size() - pos));
    }
 
@@ -1225,7 +1225,7 @@ class basic_string
    //! length n whose elements are a copy of those pointed to by s.
    //!
    //! Throws: If memory allocation throws or length_error if n > max_size().
-   //!    
+   //!   
    //! Returns: *this
    basic_string& assign(const CharT* s, size_type n)
    {  return this->assign(s, s + n);   }
@@ -1248,7 +1248,7 @@ class basic_string
    //!
    //! Returns: *this
    template 
-   basic_string& assign(InputIter first, InputIter last) 
+   basic_string& assign(InputIter first, InputIter last)
    {
       //Dispatch depending on integer/iterator
       const bool aux_boolean = container_detail::is_convertible::value;
@@ -1263,7 +1263,7 @@ class basic_string
    //! Throws: If memory allocation throws or out_of_range if pos > size().
    //!
    //! Returns: *this
-   basic_string& insert(size_type pos, const basic_string& s) 
+   basic_string& insert(size_type pos, const basic_string& s)
    {
       if (pos > size())
          this->throw_out_of_range();
@@ -1282,7 +1282,7 @@ class basic_string
    //!
    //! Returns: *this
    basic_string& insert(size_type pos1, const basic_string& s,
-                        size_type pos2, size_type n) 
+                        size_type pos2, size_type n)
    {
       if (pos1 > this->size() || pos2 > s.size())
          this->throw_out_of_range();
@@ -1306,7 +1306,7 @@ class basic_string
    //!   length_error if size() + n > max_size().
    //!
    //! Returns: *this
-   basic_string& insert(size_type pos, const CharT* s, size_type n) 
+   basic_string& insert(size_type pos, const CharT* s, size_type n)
    {
       if (pos > this->size())
          this->throw_out_of_range();
@@ -1324,7 +1324,7 @@ class basic_string
    //!   length_error if size() > max_size() - Traits::length(s)
    //!
    //! Returns: *this
-   basic_string& insert(size_type pos, const CharT* s) 
+   basic_string& insert(size_type pos, const CharT* s)
    {
       if (pos > size())
          this->throw_out_of_range();
@@ -1341,7 +1341,7 @@ class basic_string
    //!   length_error if size() > max_size() - n
    //!
    //! Returns: *this
-   basic_string& insert(size_type pos, size_type n, CharT c) 
+   basic_string& insert(size_type pos, size_type n, CharT c)
    {
       if (pos > this->size())
          this->throw_out_of_range();
@@ -1356,7 +1356,7 @@ class basic_string
    //! Effects: inserts a copy of c before the character referred to by p.
    //!
    //! Returns: An iterator which refers to the copy of the inserted character.
-   iterator insert(const_iterator p, CharT c) 
+   iterator insert(const_iterator p, CharT c)
    {
       size_type new_offset = p - this->priv_addr() + 1;
       this->insert(p, cvalue_iterator(c, 1), cvalue_iterator());
@@ -1382,7 +1382,7 @@ class basic_string
    //! Returns: An iterator which refers to the copy of the first
    //!   inserted character, or p if first == last.
    template 
-   void insert(const_iterator p, InputIter first, InputIter last) 
+   void insert(const_iterator p, InputIter first, InputIter last)
    {
       //Dispatch depending on integer/iterator
       const bool aux_boolean = container_detail::is_convertible::value;
@@ -1401,13 +1401,13 @@ class basic_string
    //! Throws: out_of_range if pos > size().
    //!
    //! Returns: *this
-   basic_string& erase(size_type pos = 0, size_type n = npos) 
+   basic_string& erase(size_type pos = 0, size_type n = npos)
    {
       if (pos > size())
          this->throw_out_of_range();
       erase(this->priv_addr() + pos, this->priv_addr() + pos + container_detail::min_value(n, size() - pos));
       return *this;
-   }  
+   } 
 
    //! Effects: Removes the character referred to by p.
    //!
@@ -1415,12 +1415,12 @@ class basic_string
    //!
    //! Returns: An iterator which points to the element immediately following p prior to the element being
    //!    erased. If no such element exists, end() is returned.
-   iterator erase(const_iterator p) 
+   iterator erase(const_iterator p)
    {
       // The move includes the terminating null.
       CharT *ptr = const_cast(container_detail::to_raw_pointer(p));
       Traits::move(ptr,
-                   container_detail::to_raw_pointer(p + 1), 
+                   container_detail::to_raw_pointer(p + 1),
                    this->priv_size() - (p - this->priv_addr()));
       this->priv_size(this->priv_size()-1);
       return iterator(ptr);
@@ -1440,7 +1440,7 @@ class basic_string
       if (first != last) { // The move includes the terminating null.
          size_type num_erased = last - first;
          Traits::move(f,
-                      container_detail::to_raw_pointer(last), 
+                      container_detail::to_raw_pointer(last),
                       (this->priv_size() + 1)-(last - this->priv_addr()));
          size_type new_length = this->priv_size() - num_erased;
          this->priv_size(new_length);
@@ -1466,14 +1466,14 @@ class basic_string
    //! Throws: if memory allocation throws or out_of_range if pos1 > size().
    //!
    //! Returns: *this
-   basic_string& replace(size_type pos1, size_type n1, const basic_string& str) 
+   basic_string& replace(size_type pos1, size_type n1, const basic_string& str)
    {
       if (pos1 > size())
          this->throw_out_of_range();
       const size_type len = container_detail::min_value(n1, size() - pos1);
       if (this->size() - len >= this->max_size() - str.size())
          this->throw_length_error();
-      return this->replace(this->priv_addr() + pos1, this->priv_addr() + pos1 + len, 
+      return this->replace(this->priv_addr() + pos1, this->priv_addr() + pos1 + len,
                            str.begin(), str.end());
    }
 
@@ -1487,7 +1487,7 @@ class basic_string
    //!
    //! Returns: *this
    basic_string& replace(size_type pos1, size_type n1,
-                         const basic_string& str, size_type pos2, size_type n2) 
+                         const basic_string& str, size_type pos2, size_type n2)
    {
       if (pos1 > size() || pos2 > str.size())
          this->throw_out_of_range();
@@ -1501,20 +1501,20 @@ class basic_string
 
    //! Requires: pos1 <= size() and s points to an array of at least n2 elements of CharT.
    //!
-   //! Effects: Determines the effective length xlen of the string to be removed as the 
-   //!   smaller of n1 and size() - pos1. If size() - xlen >= max_size() - n2 throws length_error. 
-   //!   Otherwise, the function replaces the string controlled by *this with a string of 
-   //!   length size() - xlen + n2 whose first pos1 elements are a copy of the initial elements 
-   //!   of the original string controlled by *this, whose next n2 elements are a copy of the 
-   //!   initial n2 elements of s, and whose remaining elements are a copy of the elements of 
+   //! Effects: Determines the effective length xlen of the string to be removed as the
+   //!   smaller of n1 and size() - pos1. If size() - xlen >= max_size() - n2 throws length_error.
+   //!   Otherwise, the function replaces the string controlled by *this with a string of
+   //!   length size() - xlen + n2 whose first pos1 elements are a copy of the initial elements
+   //!   of the original string controlled by *this, whose next n2 elements are a copy of the
+   //!   initial n2 elements of s, and whose remaining elements are a copy of the elements of
    //!   the original string controlled by *this beginning at position pos + xlen.
    //!
-   //! Throws: if memory allocation throws, out_of_range if pos1 > size() or length_error 
+   //! Throws: if memory allocation throws, out_of_range if pos1 > size() or length_error
    //!   if the length of the  resulting string would exceed max_size()
    //!
    //! Returns: *this
    basic_string& replace(size_type pos1, size_type n1,
-                        const CharT* s, size_type n2) 
+                        const CharT* s, size_type n2)
    {
       if (pos1 > size())
          this->throw_out_of_range();
@@ -1535,11 +1535,11 @@ class basic_string
    //! remaining elements are a copy of the elements of the original string controlled by *this
    //! beginning at position pos + xlen.
    //!
-   //! Throws: if memory allocation throws, out_of_range if pos1 > size() or length_error 
+   //! Throws: if memory allocation throws, out_of_range if pos1 > size() or length_error
    //!   if the length of the resulting string would exceed max_size()
    //!
    //! Returns: *this
-   basic_string& replace(size_type pos, size_type n1, const CharT* s) 
+   basic_string& replace(size_type pos, size_type n1, const CharT* s)
    {
       if (pos > size())
          this->throw_out_of_range();
@@ -1555,11 +1555,11 @@ class basic_string
    //!
    //! Effects: Equivalent to replace(pos1, n1, basic_string(n2, c)).
    //!
-   //! Throws: if memory allocation throws, out_of_range if pos1 > size() or length_error 
+   //! Throws: if memory allocation throws, out_of_range if pos1 > size() or length_error
    //!   if the length of the  resulting string would exceed max_size()
    //!
    //! Returns: *this
-   basic_string& replace(size_type pos1, size_type n1, size_type n2, CharT c) 
+   basic_string& replace(size_type pos1, size_type n1, size_type n2, CharT c)
    {
       if (pos1 > size())
          this->throw_out_of_range();
@@ -1576,10 +1576,10 @@ class basic_string
    //! Throws: if memory allocation throws
    //!
    //! Returns: *this
-   basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str) 
+   basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str)
    { return this->replace(i1, i2, str.begin(), str.end()); }
 
-   //! Requires: [begin(),i1) and [i1,i2) are valid ranges and 
+   //! Requires: [begin(),i1) and [i1,i2) are valid ranges and
    //!   s points to an array of at least n elements
    //!
    //! Effects: Calls replace(i1 - begin(), i2 - i1, s, n).
@@ -1587,7 +1587,7 @@ class basic_string
    //! Throws: if memory allocation throws
    //!
    //! Returns: *this
-   basic_string& replace(const_iterator i1, const_iterator i2, const CharT* s, size_type n) 
+   basic_string& replace(const_iterator i1, const_iterator i2, const CharT* s, size_type n)
    { return this->replace(i1, i2, s, s + n); }
 
    //! Requires: [begin(),i1) and [i1,i2) are valid ranges and s points to an
@@ -1598,7 +1598,7 @@ class basic_string
    //! Throws: if memory allocation throws
    //!
    //! Returns: *this
-   basic_string& replace(const_iterator i1, const_iterator i2, const CharT* s) 
+   basic_string& replace(const_iterator i1, const_iterator i2, const CharT* s)
    {  return this->replace(i1, i2, s, s + Traits::length(s));   }
 
    //! Requires: [begin(),i1) and [i1,i2) are valid ranges.
@@ -1630,7 +1630,7 @@ class basic_string
    //!
    //! Returns: *this
    template 
-   basic_string& replace(const_iterator i1, const_iterator i2, InputIter j1, InputIter j2) 
+   basic_string& replace(const_iterator i1, const_iterator i2, InputIter j1, InputIter j2)
    {
       //Dispatch depending on integer/iterator
       const bool aux_boolean = container_detail::is_convertible::value;
@@ -1642,14 +1642,14 @@ class basic_string
    //!
    //! Effects: Determines the effective length rlen of the string to copy as the
    //!   smaller of n and size() - pos. s shall designate an array of at least rlen elements.
-   //!   The function then replaces the string designated by s with a string of length rlen 
+   //!   The function then replaces the string designated by s with a string of length rlen
    //!   whose elements are a copy of the string controlled by *this beginning at position pos.
    //!   The function does not append a null object to the string designated by s.
    //!
    //! Throws: if memory allocation throws, out_of_range if pos > size().
    //!
    //! Returns: rlen
-   size_type copy(CharT* s, size_type n, size_type pos = 0) const 
+   size_type copy(CharT* s, size_type n, size_type pos = 0) const
    {
       if (pos > size())
          this->throw_out_of_range();
@@ -1658,7 +1658,7 @@ class basic_string
       return len;
    }
 
-   //! Effects: *this contains the same sequence of characters that was in s, 
+   //! Effects: *this contains the same sequence of characters that was in s,
    //!   s contains the same sequence of characters that was in *this.
    //!
    //! Throws: Nothing
@@ -1674,7 +1674,7 @@ class basic_string
    //! Returns: A pointer p such that p + i == &operator[](i) for each i in [0,size()].
    //!
    //! Complexity: constant time.
-   const CharT* c_str() const 
+   const CharT* c_str() const
    {  return container_detail::to_raw_pointer(this->priv_addr()); }
 
    //! Requires: The program shall not alter any of the values stored in the character array.
@@ -1682,17 +1682,17 @@ class basic_string
    //! Returns: A pointer p such that p + i == &operator[](i) for each i in [0,size()].
    //!
    //! Complexity: constant time.
-   const CharT* data()  const 
+   const CharT* data()  const
    {  return container_detail::to_raw_pointer(this->priv_addr()); }
 
-   //! Effects: Determines the lowest position xpos, if possible, such that both 
+   //! Effects: Determines the lowest position xpos, if possible, such that both
    //!   of the following conditions obtain: 19 pos <= xpos and xpos + str.size() <= size();
    //!   2) traits::eq(at(xpos+I), str.at(I)) for all elements I of the string controlled by str.
    //!
    //! Throws: Nothing
    //!
    //! Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
-   size_type find(const basic_string& s, size_type pos = 0) const 
+   size_type find(const basic_string& s, size_type pos = 0) const
    { return find(s.c_str(), pos, s.size()); }
 
    //! Requires: s points to an array of at least n elements of CharT.
@@ -1707,7 +1707,7 @@ class basic_string
       else {
          pointer finish = this->priv_addr() + this->priv_size();
          const const_iterator result =
-            std::search(container_detail::to_raw_pointer(this->priv_addr() + pos), 
+            std::search(container_detail::to_raw_pointer(this->priv_addr() + pos),
                    container_detail::to_raw_pointer(finish),
                    s, s + n, Eq_traits());
          return result != finish ? result - begin() : npos;
@@ -1719,7 +1719,7 @@ class basic_string
    //! Throws: Nothing
    //!
    //! Returns: find(basic_string(s), pos).
-   size_type find(const CharT* s, size_type pos = 0) const 
+   size_type find(const CharT* s, size_type pos = 0) const
    { return find(s, pos, Traits::length(s)); }
 
    //! Throws: Nothing
@@ -1738,7 +1738,7 @@ class basic_string
       }
    }
 
-   //! Effects: Determines the highest position xpos, if possible, such 
+   //! Effects: Determines the highest position xpos, if possible, such
    //!   that both of the following conditions obtain:
    //!   a) xpos <= pos and xpos + str.size() <= size();
    //!   b) traits::eq(at(xpos+I), str.at(I)) for all elements I of the string controlled by str.
@@ -1746,7 +1746,7 @@ class basic_string
    //! Throws: Nothing
    //!
    //! Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
-   size_type rfind(const basic_string& str, size_type pos = npos) const 
+   size_type rfind(const basic_string& str, size_type pos = npos) const
       { return rfind(str.c_str(), pos, str.size()); }
 
    //! Requires: s points to an array of at least n elements of CharT.
@@ -1771,13 +1771,13 @@ class basic_string
       }
    }
 
-   //! Requires: pos <= size() and s points to an array of at least 
+   //! Requires: pos <= size() and s points to an array of at least
    //!   traits::length(s) + 1 elements of CharT.
    //!
    //! Throws: Nothing
    //!
    //! Returns: rfind(basic_string(s), pos).
-   size_type rfind(const CharT* s, size_type pos = npos) const 
+   size_type rfind(const CharT* s, size_type pos = npos) const
       { return rfind(s, pos, Traits::length(s)); }
 
    //! Throws: Nothing
@@ -1805,7 +1805,7 @@ class basic_string
    //! Throws: Nothing
    //!
    //! Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
-   size_type find_first_of(const basic_string& s, size_type pos = 0) const 
+   size_type find_first_of(const basic_string& s, size_type pos = 0) const
       { return find_first_of(s.c_str(), pos, s.size()); }
 
    //! Requires: s points to an array of at least n elements of CharT.
@@ -1831,7 +1831,7 @@ class basic_string
    //! Throws: Nothing
    //!
    //! Returns: find_first_of(basic_string(s), pos).
-   size_type find_first_of(const CharT* s, size_type pos = 0) const 
+   size_type find_first_of(const CharT* s, size_type pos = 0) const
       { return find_first_of(s, pos, Traits::length(s)); }
 
    //! Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.
@@ -1839,10 +1839,10 @@ class basic_string
    //! Throws: Nothing
    //!
    //! Returns: find_first_of(basic_string(1,c), pos).
-   size_type find_first_of(CharT c, size_type pos = 0) const 
+   size_type find_first_of(CharT c, size_type pos = 0) const
     { return find(c, pos); }
 
-   //! Effects: Determines the highest position xpos, if possible, such that both of 
+   //! Effects: Determines the highest position xpos, if possible, such that both of
    //!   the following conditions obtain: a) xpos <= pos and xpos < size(); b)
    //!   traits::eq(at(xpos), str.at(I)) for some element I of the string controlled by str.
    //!
@@ -1878,16 +1878,16 @@ class basic_string
    //! Throws: Nothing
    //!
    //! Returns: find_last_of(basic_string(1,c),pos).
-   size_type find_last_of(const CharT* s, size_type pos = npos) const 
+   size_type find_last_of(const CharT* s, size_type pos = npos) const
       { return find_last_of(s, pos, Traits::length(s)); }
 
    //! Throws: Nothing
    //!
    //! Returns: find_last_of(basic_string(s), pos).
-   size_type find_last_of(CharT c, size_type pos = npos) const 
+   size_type find_last_of(CharT c, size_type pos = npos) const
       {  return rfind(c, pos);   }
 
-   //! Effects: Determines the lowest position xpos, if possible, such that 
+   //! Effects: Determines the lowest position xpos, if possible, such that
    //!   both of the following conditions obtain:
    //!   a) pos <= xpos and xpos < size(); b) traits::eq(at(xpos), str.at(I)) for no
    //!   element I of the string controlled by str.
@@ -1895,7 +1895,7 @@ class basic_string
    //! Throws: Nothing
    //!
    //! Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
-   size_type find_first_not_of(const basic_string& str, size_type pos = 0) const 
+   size_type find_first_not_of(const basic_string& str, size_type pos = 0) const
       { return find_first_not_of(str.c_str(), pos, str.size()); }
 
    //! Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.
@@ -1920,7 +1920,7 @@ class basic_string
    //! Throws: Nothing
    //!
    //! Returns: find_first_not_of(basic_string(s), pos).
-   size_type find_first_not_of(const CharT* s, size_type pos = 0) const 
+   size_type find_first_not_of(const CharT* s, size_type pos = 0) const
       { return find_first_not_of(s, pos, Traits::length(s)); }
 
    //! Throws: Nothing
@@ -1940,7 +1940,7 @@ class basic_string
    }
 
    //! Effects: Determines the highest position xpos, if possible, such that
-   //!   both of the following conditions obtain: a) xpos <= pos and xpos < size(); 
+   //!   both of the following conditions obtain: a) xpos <= pos and xpos < size();
    //!   b) traits::eq(at(xpos), str.at(I)) for no element I of the string controlled by str.
    //!
    //! Throws: Nothing
@@ -2003,11 +2003,11 @@ class basic_string
    //! Throws: If memory allocation throws or out_of_range if pos > size().
    //!
    //! Returns: basic_string(data()+pos,rlen).
-   basic_string substr(size_type pos = 0, size_type n = npos) const 
+   basic_string substr(size_type pos = 0, size_type n = npos) const
    {
       if (pos > size())
          this->throw_out_of_range();
-      return basic_string(this->priv_addr() + pos, 
+      return basic_string(this->priv_addr() + pos,
                           this->priv_addr() + pos + container_detail::min_value(n, size() - pos), this->alloc());
    }
 
@@ -2020,7 +2020,7 @@ class basic_string
    //! Returns: The nonzero result if the result of the comparison is nonzero.
    //!   Otherwise, returns a value < 0 if size() < str.size(), a 0 value if size() == str.size(),
    //!   and value > 0 if size() > str.size()
-   int compare(const basic_string& str) const 
+   int compare(const basic_string& str) const
    { return s_compare(this->priv_addr(), this->priv_addr() + this->priv_size(), str.priv_addr(), str.priv_addr() + str.priv_size()); }
 
    //! Requires: pos1 <= size()
@@ -2031,16 +2031,16 @@ class basic_string
    //! Throws: out_of_range if pos1 > size()
    //!
    //! Returns:basic_string(*this,pos1,n1).compare(str).
-   int compare(size_type pos1, size_type n1, const basic_string& str) const 
+   int compare(size_type pos1, size_type n1, const basic_string& str) const
    {
       if (pos1 > size())
          this->throw_out_of_range();
-      return s_compare(this->priv_addr() + pos1, 
+      return s_compare(this->priv_addr() + pos1,
                         this->priv_addr() + pos1 + container_detail::min_value(n1, size() - pos1),
                         str.priv_addr(), str.priv_addr() + str.priv_size());
    }
 
-   //! Requires: pos1 <= size() and pos2 <= str.size() 
+   //! Requires: pos1 <= size() and pos2 <= str.size()
    //!
    //! Effects: Determines the effective length rlen of the string to copy as
    //!   the smaller of
@@ -2048,20 +2048,20 @@ class basic_string
    //! Throws: out_of_range if pos1 > size() or pos2 > str.size()
    //!
    //! Returns: basic_string(*this, pos1, n1).compare(basic_string(str, pos2, n2)).
-   int compare(size_type pos1, size_type n1, 
+   int compare(size_type pos1, size_type n1,
                const basic_string& str, size_type pos2, size_type n2) const {
       if (pos1 > size() || pos2 > str.size())
          this->throw_out_of_range();
-      return s_compare(this->priv_addr() + pos1, 
+      return s_compare(this->priv_addr() + pos1,
                         this->priv_addr() + pos1 + container_detail::min_value(n1, size() - pos1),
-                        str.priv_addr() + pos2, 
+                        str.priv_addr() + pos2,
                         str.priv_addr() + pos2 + container_detail::min_value(n2, size() - pos2));
    }
 
    //! Throws: Nothing
    //!
    //! Returns: compare(basic_string(s)).
-   int compare(const CharT* s) const 
+   int compare(const CharT* s) const
    {  return s_compare(this->priv_addr(), this->priv_addr() + this->priv_size(), s, s + Traits::length(s));   }
 
 
@@ -2071,11 +2071,11 @@ class basic_string
    //!
    //! Returns: basic_string(*this, pos, n1).compare(basic_string(s, n2)).
    int compare(size_type pos1, size_type n1,
-               const CharT* s, size_type n2) const 
+               const CharT* s, size_type n2) const
    {
       if (pos1 > size())
          this->throw_out_of_range();
-      return s_compare(this->priv_addr() + pos1, 
+      return s_compare(this->priv_addr() + pos1,
                         this->priv_addr() + pos1 + container_detail::min_value(n1, size() - pos1),
                         s, s + n2);
    }
@@ -2085,18 +2085,18 @@ class basic_string
    //! Throws: out_of_range if pos1 > size()
    //!
    //! Returns: basic_string(*this, pos, n1).compare(basic_string(s, n2)).
-   int compare(size_type pos1, size_type n1, const CharT* s) const 
+   int compare(size_type pos1, size_type n1, const CharT* s) const
    {  return this->compare(pos1, n1, s, Traits::length(s)); }
 
    /// @cond
    private:
    static int s_compare(const_pointer f1, const_pointer l1,
-                        const_pointer f2, const_pointer l2) 
+                        const_pointer f2, const_pointer l2)
    {
       const difference_type n1 = l1 - f1;
       const difference_type n2 = l2 - f2;
-      const int cmp = Traits::compare(container_detail::to_raw_pointer(f1), 
-                                      container_detail::to_raw_pointer(f2), 
+      const int cmp = Traits::compare(container_detail::to_raw_pointer(f1),
+                                      container_detail::to_raw_pointer(f2),
                                       container_detail::min_value(n1, n2));
       return cmp != 0 ? cmp : (n1 < n2 ? -1 : (n1 > n2 ? 1 : 0));
    }
@@ -2131,7 +2131,7 @@ class basic_string
 
    template
    void priv_shrink_to_fit_dynamic_buffer
-      ( AllocVersion 
+      ( AllocVersion
       , typename container_detail::enable_if >::type* = 0)
    {
       size_type received_size;
@@ -2151,7 +2151,7 @@ class basic_string
 
    // Helper functions used by constructors.  It is a severe error for
    // any of them to be called anywhere except from within constructors.
-   void priv_terminate_string() 
+   void priv_terminate_string()
    {  this->priv_construct_null(this->priv_addr() + this->priv_size());  }
 
    template 
@@ -2164,7 +2164,7 @@ class basic_string
    }
 
    template 
-   void priv_range_initialize(ForwardIter f, ForwardIter l, 
+   void priv_range_initialize(ForwardIter f, ForwardIter l,
                               std::forward_iterator_tag)
    {
       difference_type n = std::distance(f, l);
@@ -2193,7 +2193,7 @@ class basic_string
    template 
    void priv_initialize_dispatch(InputIter f, InputIter l, container_detail::false_)
    {  this->priv_range_initialize(f, l);  }
- 
+
    template inline
    void priv_uninitialized_fill_n(FwdIt first, Count count, const CharT val)
    {
@@ -2241,7 +2241,7 @@ class basic_string
    }
 
    template 
-   basic_string& priv_assign_dispatch(Integer n, Integer x, container_detail::true_) 
+   basic_string& priv_assign_dispatch(Integer n, Integer x, container_detail::true_)
    {  return this->assign((size_type) n, (CharT) x);   }
 
    template 
@@ -2272,7 +2272,7 @@ class basic_string
    }
 
    template 
-   void priv_insert(const_iterator position, ForwardIter first, 
+   void priv_insert(const_iterator position, ForwardIter first,
                     ForwardIter last,  std::forward_iterator_tag)
    {
       if (first != last) {
@@ -2286,13 +2286,13 @@ class basic_string
 
          //Check if we have enough capacity
          if (remaining >= n){
-            enough_capacity = true;            
+            enough_capacity = true;           
          }
          else {
             //Otherwise expand current buffer or allocate new storage
             new_cap  = this->next_capacity(n);
             allocation_ret = this->allocation_command
-                  (allocate_new | expand_fwd | expand_bwd, old_size + n + 1, 
+                  (allocate_new | expand_fwd | expand_bwd, old_size + n + 1,
                      new_cap, new_cap, old_start);
 
             //Check forward expansion
@@ -2353,7 +2353,7 @@ class basic_string
                this->priv_long_storage(new_cap);
             }
             else{
-               //value_type is POD, so backwards expansion is much easier 
+               //value_type is POD, so backwards expansion is much easier
                //than with vector
                value_type *oldbuf = container_detail::to_raw_pointer(old_start);
                value_type *newbuf = container_detail::to_raw_pointer(new_start);
@@ -2377,12 +2377,12 @@ class basic_string
 
    template 
    void priv_insert_dispatch(const_iterator p, Integer n, Integer x,
-                           container_detail::true_) 
+                           container_detail::true_)
    {  insert(p, (size_type) n, (CharT) x);   }
 
    template 
    void priv_insert_dispatch(const_iterator p, InputIter first, InputIter last,
-                           container_detail::false_) 
+                           container_detail::false_)
    {
       typedef typename std::iterator_traits::iterator_category Category;
       priv_insert(p, first, last, Category());
@@ -2395,19 +2395,19 @@ class basic_string
          Traits::assign(*result, *first);
    }
 
-   void priv_copy(const CharT* first, const CharT* last, CharT* result) 
+   void priv_copy(const CharT* first, const CharT* last, CharT* result)
    {  Traits::copy(result, first, last - first);  }
 
    template 
    basic_string& priv_replace_dispatch(const_iterator first, const_iterator last,
                                        Integer n, Integer x,
-                                       container_detail::true_) 
+                                       container_detail::true_)
    {  return this->replace(first, last, (size_type) n, (CharT) x);   }
 
    template 
    basic_string& priv_replace_dispatch(const_iterator first, const_iterator last,
                                        InputIter f, InputIter l,
-                                       container_detail::false_) 
+                                       container_detail::false_)
    {
       typedef typename std::iterator_traits::iterator_category Category;
       return this->priv_replace(first, last, f, l, Category());
@@ -2430,7 +2430,7 @@ class basic_string
 
    template 
    basic_string& priv_replace(const_iterator first, const_iterator last,
-                              ForwardIter f, ForwardIter l, 
+                              ForwardIter f, ForwardIter l,
                               std::forward_iterator_tag)
    {
       difference_type n = std::distance(f, l);
@@ -2468,9 +2468,9 @@ wstring;
 
 /// @cond
 
-template  
-const typename basic_string::size_type 
-basic_string::npos 
+template 
+const typename basic_string::size_type
+basic_string::npos
   = (typename basic_string::size_type) -1;
 
 /// @endcond
@@ -2526,7 +2526,7 @@ BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A)
 
 template 
 inline basic_string
-operator+(const CharT* s, const basic_string& y) 
+operator+(const CharT* s, const basic_string& y)
 {
    typedef basic_string str_t;
    typedef typename str_t::reserve_t reserve_t;
@@ -2549,7 +2549,7 @@ operator+(const CharT* s,
 
 template 
 inline basic_string
-operator+(CharT c, const basic_string& y) 
+operator+(CharT c, const basic_string& y)
 {
    typedef basic_string str_t;
    typedef typename str_t::reserve_t reserve_t;
@@ -2571,7 +2571,7 @@ operator+(CharT c,
 
 template 
 inline basic_string
-operator+(const basic_string& x, const CharT* s) 
+operator+(const basic_string& x, const CharT* s)
 {
    typedef basic_string str_t;
    typedef typename str_t::reserve_t reserve_t;
@@ -2594,7 +2594,7 @@ operator+(BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) mx
 
 template 
 inline basic_string
-operator+(const basic_string& x, const CharT c) 
+operator+(const basic_string& x, const CharT c)
 {
    typedef basic_string str_t;
    typedef typename str_t::reserve_t reserve_t;
@@ -2619,7 +2619,7 @@ operator+( BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) mx
 template 
 inline bool
 operator==(const basic_string& x,
-           const basic_string& y) 
+           const basic_string& y)
 {
    return x.size() == y.size() &&
           Traits::compare(x.data(), y.data(), x.size()) == 0;
@@ -2627,7 +2627,7 @@ operator==(const basic_string& x,
 
 template 
 inline bool
-operator==(const CharT* s, const basic_string& y) 
+operator==(const CharT* s, const basic_string& y)
 {
    typename basic_string::size_type n = Traits::length(s);
    return n == y.size() && Traits::compare(s, y.data(), n) == 0;
@@ -2635,7 +2635,7 @@ operator==(const CharT* s, const basic_string& y)
 
 template 
 inline bool
-operator==(const basic_string& x, const CharT* s) 
+operator==(const basic_string& x, const CharT* s)
 {
    typename basic_string::size_type n = Traits::length(s);
    return x.size() == n && Traits::compare(x.data(), s, n) == 0;
@@ -2644,17 +2644,17 @@ operator==(const basic_string& x, const CharT* s)
 template 
 inline bool
 operator!=(const basic_string& x,
-           const basic_string& y) 
+           const basic_string& y)
    {  return !(x == y);  }
 
 template 
 inline bool
-operator!=(const CharT* s, const basic_string& y) 
+operator!=(const CharT* s, const basic_string& y)
    {  return !(s == y); }
 
 template 
 inline bool
-operator!=(const basic_string& x, const CharT* s) 
+operator!=(const basic_string& x, const CharT* s)
    {  return !(x == s);   }
 
 
@@ -2662,7 +2662,7 @@ operator!=(const basic_string& x, const CharT* s)
 
 template 
 inline bool
-operator<(const basic_string& x, const basic_string& y) 
+operator<(const basic_string& x, const basic_string& y)
 {
    return x.compare(y) < 0;
 //   return basic_string
@@ -2671,7 +2671,7 @@ operator<(const basic_string& x, const basic_string
 inline bool
-operator<(const CharT* s, const basic_string& y) 
+operator<(const CharT* s, const basic_string& y)
 {
    return y.compare(s) > 0;
 //   basic_string::size_type n = Traits::length(s);
@@ -2682,7 +2682,7 @@ operator<(const CharT* s, const basic_string& y)
 template 
 inline bool
 operator<(const basic_string& x,
-          const CharT* s) 
+          const CharT* s)
 {
    return x.compare(s) < 0;
 //   basic_string::size_type n = Traits::length(s);
@@ -2705,7 +2705,7 @@ operator>(const CharT* s, const basic_string& y) {
 
 template 
 inline bool
-operator>(const basic_string& x, const CharT* s) 
+operator>(const basic_string& x, const CharT* s)
 {
    return s < x;
 }
@@ -2713,44 +2713,44 @@ operator>(const basic_string& x, const CharT* s)
 template 
 inline bool
 operator<=(const basic_string& x,
-           const basic_string& y) 
+           const basic_string& y)
 {
   return !(y < x);
 }
 
 template 
 inline bool
-operator<=(const CharT* s, const basic_string& y) 
+operator<=(const CharT* s, const basic_string& y)
    {  return !(y < s);  }
 
 template 
 inline bool
-operator<=(const basic_string& x, const CharT* s) 
+operator<=(const basic_string& x, const CharT* s)
    {  return !(s < x);  }
 
 template 
 inline bool
 operator>=(const basic_string& x,
-           const basic_string& y) 
+           const basic_string& y)
    {  return !(x < y);  }
 
 template 
 inline bool
-operator>=(const CharT* s, const basic_string& y) 
+operator>=(const CharT* s, const basic_string& y)
    {  return !(s < y);  }
 
 template 
 inline bool
-operator>=(const basic_string& x, const CharT* s) 
+operator>=(const basic_string& x, const CharT* s)
    {  return !(x < s);  }
 
 // Swap.
 template 
-inline void swap(basic_string& x, basic_string& y) 
+inline void swap(basic_string& x, basic_string& y)
 {  x.swap(y);  }
 
 /// @cond
-// I/O.  
+// I/O. 
 namespace container_detail {
 
 template 
@@ -2788,11 +2788,11 @@ operator<<(std::basic_ostream& os, const basic_stringsputn(s.data(), std::streamsize(n)) == std::streamsize(n);
 
       if (left)
@@ -2807,7 +2807,7 @@ operator<<(std::basic_ostream& os, const basic_string
-std::basic_istream& 
+std::basic_istream&
 operator>>(std::basic_istream& is, basic_string& s)
 {
    typename std::basic_istream::sentry sentry(is);
@@ -2842,7 +2842,7 @@ operator>>(std::basic_istream& is, basic_string&
                s.push_back(c);
          }
       }
-      
+     
       // If we have read no characters, then set failbit.
       if (s.size() == 0)
          is.setstate(std::ios_base::failbit);
@@ -2853,8 +2853,8 @@ operator>>(std::basic_istream& is, basic_string&
    return is;
 }
 
-template     
-std::basic_istream& 
+template    
+std::basic_istream&
 getline(std::istream& is, basic_string& s,CharT delim)
 {
    typename basic_string::size_type nread = 0;
@@ -2872,7 +2872,7 @@ getline(std::istream& is, basic_string& s,CharT delim)
          else {
             ++nread;
             CharT c = Traits::to_char_type(c1);
-            if (!Traits::eq(c, delim)) 
+            if (!Traits::eq(c, delim))
                s.push_back(c);
             else
                break;              // Character is extracted but not appended.
@@ -2885,8 +2885,8 @@ getline(std::istream& is, basic_string& s,CharT delim)
    return is;
 }
 
-template     
-inline std::basic_istream& 
+template    
+inline std::basic_istream&
 getline(std::basic_istream& is, basic_string& s)
 {
    return getline(is, s, '\n');
diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp
index 6b590fb..c6e5b51 100644
--- a/include/boost/container/vector.hpp
+++ b/include/boost/container/vector.hpp
@@ -55,7 +55,7 @@ namespace container {
 
 namespace container_detail {
 
-//! Const vector_iterator used to iterate through a vector. 
+//! Const vector_iterator used to iterate through a vector.
 template 
 class vector_const_iterator
 {
@@ -82,20 +82,20 @@ class vector_const_iterator
    vector_const_iterator() : m_ptr(0){}
 
    //Pointer like operators
-   reference operator*()   const  
+   reference operator*()   const 
    {  return *m_ptr;  }
 
-   const value_type * operator->()  const  
+   const value_type * operator->()  const 
    {  return  container_detail::to_raw_pointer(m_ptr);  }
 
    reference operator[](difference_type off) const
    {  return m_ptr[off];   }
 
    //Increment / Decrement
-   vector_const_iterator& operator++()       
+   vector_const_iterator& operator++()      
    { ++m_ptr;  return *this; }
 
-   vector_const_iterator operator++(int)      
+   vector_const_iterator operator++(int)     
    {  Pointer tmp = m_ptr; ++*this; return vector_const_iterator(tmp);  }
 
    vector_const_iterator& operator--()
@@ -165,22 +165,22 @@ class vector_iterator
    {}
 
    //Pointer like operators
-   reference operator*()  const  
+   reference operator*()  const 
    {  return *this->m_ptr;  }
 
-   value_type* operator->() const  
+   value_type* operator->() const 
    {  return  container_detail::to_raw_pointer(this->m_ptr);  }
 
-   reference operator[](difference_type off) const 
+   reference operator[](difference_type off) const
    {  return this->m_ptr[off];   }
 
    //Increment / Decrement
-   vector_iterator& operator++()  
+   vector_iterator& operator++() 
    {  ++this->m_ptr; return *this;  }
 
    vector_iterator operator++(int)
    {  pointer tmp = this->m_ptr; ++*this; return vector_iterator(tmp);  }
-   
+  
    vector_iterator& operator--()
    {  --this->m_ptr; return *this;  }
 
@@ -249,7 +249,7 @@ struct vector_value_traits
 
 //!This struct deallocates and allocated memory
 template 
-struct vector_alloc_holder 
+struct vector_alloc_holder
 {
    typedef boost::container::allocator_traits         allocator_traits_type;
    typedef typename allocator_traits_type::pointer       pointer;
@@ -282,7 +282,7 @@ struct vector_alloc_holder
       boost::container::container_detail::version::value> alloc_version;
    std::pair
       allocation_command(allocation_type command,
-                         size_type limit_size, 
+                         size_type limit_size,
                          size_type preferred_size,
                          size_type &received_size, const pointer &reuse = 0)
    {
@@ -292,7 +292,7 @@ struct vector_alloc_holder
 
    std::pair
       allocation_command(allocation_type command,
-                         size_type limit_size, 
+                         size_type limit_size,
                          size_type preferred_size,
                          size_type &received_size,
                          const pointer &reuse,
@@ -308,7 +308,7 @@ struct vector_alloc_holder
 
    std::pair
       allocation_command(allocation_type command,
-                         size_type limit_size, 
+                         size_type limit_size,
                          size_type preferred_size,
                          size_type &received_size,
                          const pointer &reuse,
@@ -394,9 +394,9 @@ struct vector_alloc_holder
 /// @endcond
 
 //! \class vector
-//! A vector is a sequence that supports random access to elements, constant 
-//! time insertion and removal of elements at the end, and linear time insertion 
-//! and removal of elements at the beginning or in the middle. The number of 
+//! A vector is a sequence that supports random access to elements, constant
+//! time insertion and removal of elements at the end, and linear time insertion
+//! and removal of elements at the beginning or in the middle. The number of
 //! elements in a vector may vary dynamically; memory management is automatic.
 //! boost::container::vector is similar to std::vector but it's compatible
 //! with shared memory and memory mapped files.
@@ -434,11 +434,11 @@ class vector : private container_detail::vector_alloc_holder
    //! The random access const_iterator
    typedef container_detail::vector_const_iterator  const_iterator;
 
-   //! Iterator used to iterate backwards through a vector. 
-   typedef std::reverse_iterator   
+   //! Iterator used to iterate backwards through a vector.
+   typedef std::reverse_iterator  
       reverse_iterator;
-   //! Const iterator used to iterate backwards through a vector. 
-   typedef std::reverse_iterator                 
+   //! Const iterator used to iterate backwards through a vector.
+   typedef std::reverse_iterator                
       const_reverse_iterator;
    //! The stored allocator type
    typedef allocator_type                          stored_allocator_type;
@@ -461,9 +461,9 @@ class vector : private container_detail::vector_alloc_holder
    public:
 
    //! Effects: Constructs a vector taking the allocator as parameter.
-   //! 
+   //!
    //! Throws: If allocator_type's default constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
    vector()
       BOOST_CONTAINER_NOEXCEPT_IF(::boost::has_nothrow_default_constructor::value)
@@ -471,9 +471,9 @@ class vector : private container_detail::vector_alloc_holder
    {}
 
    //! Effects: Constructs a vector taking the allocator as parameter.
-   //! 
+   //!
    //! Throws: Nothing
-   //! 
+   //!
    //! Complexity: Constant.
    explicit vector(const A& a) BOOST_CONTAINER_NOEXCEPT
       : base_t(a)
@@ -484,7 +484,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Throws: If allocator_type's default constructor or allocation
    //!   throws or T's default constructor throws.
-   //! 
+   //!
    //! Complexity: Linear to n.
    explicit vector(size_type n)
       :  base_t()
@@ -511,21 +511,21 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Throws: If allocator_type's default constructor or allocation
    //!   throws or T's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Linear to n.
-   vector(size_type n, const T& value, const allocator_type& a = allocator_type()) 
+   vector(size_type n, const T& value, const allocator_type& a = allocator_type())
       :  base_t(a)
    {  this->insert(this->cend(), n, value); }
 
    //! Effects: Copy constructs a vector.
    //!
    //! Postcondition: x == *this.
-   //! 
+   //!
    //! Throws: If allocator_type's default constructor or allocation
    //!   throws or T's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Linear to the elements x contains.
-   vector(const vector &x) 
+   vector(const vector &x)
       :  base_t(allocator_traits_type::select_on_container_copy_construction(x.alloc()))
    {
       this->assign( container_detail::to_raw_pointer(x.members_.m_start)
@@ -535,7 +535,7 @@ class vector : private container_detail::vector_alloc_holder
    //! Effects: Move constructor. Moves mx's resources to *this.
    //!
    //! Throws: Nothing
-   //! 
+   //!
    //! Complexity: Constant.
    vector(BOOST_RV_REF(vector) mx) BOOST_CONTAINER_NOEXCEPT
       :  base_t(boost::move(mx.alloc()))
@@ -544,12 +544,12 @@ class vector : private container_detail::vector_alloc_holder
    //! Effects: Copy constructs a vector using the specified allocator.
    //!
    //! Postcondition: x == *this.
-   //! 
+   //!
    //! Throws: If allocation
    //!   throws or T's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Linear to the elements x contains.
-   vector(const vector &x, const allocator_type &a) 
+   vector(const vector &x, const allocator_type &a)
       :  base_t(a)
    {
       this->assign( container_detail::to_raw_pointer(x.members_.m_start)
@@ -561,7 +561,7 @@ class vector : private container_detail::vector_alloc_holder
    //!                 Otherwise copies values from x to *this.
    //!
    //! Throws: If allocation or T's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant if a == mx.get_allocator(), linear otherwise.
    vector(BOOST_RV_REF(vector) mx, const allocator_type &a)
       :  base_t(a)
@@ -597,103 +597,103 @@ class vector : private container_detail::vector_alloc_holder
    {} //vector_alloc_holder clears the data
 
    //! Effects: Returns an iterator to the first element contained in the vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    iterator begin() BOOST_CONTAINER_NOEXCEPT
    { return iterator(this->members_.m_start); }
 
    //! Effects: Returns a const_iterator to the first element contained in the vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
    { return const_iterator(this->members_.m_start); }
 
    //! Effects: Returns an iterator to the end of the vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    iterator end() BOOST_CONTAINER_NOEXCEPT
    { return iterator(this->members_.m_start + this->members_.m_size); }
 
    //! Effects: Returns a const_iterator to the end of the vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator end() const BOOST_CONTAINER_NOEXCEPT
    { return this->cend(); }
 
-   //! Effects: Returns a reverse_iterator pointing to the beginning 
-   //! of the reversed vector. 
-   //! 
+   //! Effects: Returns a reverse_iterator pointing to the beginning
+   //! of the reversed vector.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT
    { return reverse_iterator(this->end());      }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed vector. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed vector.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
    { return this->crbegin(); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
-   //! of the reversed vector. 
-   //! 
+   //! of the reversed vector.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT
    { return reverse_iterator(this->begin());       }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed vector. 
-   //! 
+   //! of the reversed vector.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT
    { return this->crend(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
    { return const_iterator(this->members_.m_start); }
 
    //! Effects: Returns a const_iterator to the end of the vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
    { return const_iterator(this->members_.m_start + this->members_.m_size); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning 
-   //! of the reversed vector. 
-   //! 
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed vector.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT
    { return const_reverse_iterator(this->end());}
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed vector. 
-   //! 
+   //! of the reversed vector.
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
    { return const_reverse_iterator(this->begin()); }
@@ -702,9 +702,9 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Effects: Returns a reference to the first
    //!   element of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reference         front() BOOST_CONTAINER_NOEXCEPT
    { return *this->members_.m_start; }
@@ -713,9 +713,9 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Effects: Returns a const reference to the first
    //!   element of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reference   front() const BOOST_CONTAINER_NOEXCEPT
    { return *this->members_.m_start; }
@@ -724,9 +724,9 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Effects: Returns a reference to the last
    //!   element of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    reference         back() BOOST_CONTAINER_NOEXCEPT
    { return this->members_.m_start[this->members_.m_size - 1]; }
@@ -735,132 +735,132 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Effects: Returns a const reference to the last
    //!   element of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reference   back()  const BOOST_CONTAINER_NOEXCEPT
    { return this->members_.m_start[this->members_.m_size - 1]; }
 
    //! Returns: A pointer such that [data(),data() + size()) is a valid range.
    //!   For a non-empty vector, data() == &front().
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    pointer data() BOOST_CONTAINER_NOEXCEPT
    { return this->members_.m_start; }
 
    //! Returns: A pointer such that [data(),data() + size()) is a valid range.
    //!   For a non-empty vector, data() == &front().
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_pointer data()  const BOOST_CONTAINER_NOEXCEPT
    { return this->members_.m_start; }
 
    //! Effects: Returns the number of the elements contained in the vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    size_type size() const BOOST_CONTAINER_NOEXCEPT
    { return this->members_.m_size; }
 
    //! Effects: Returns the largest possible size of the vector.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    size_type max_size() const BOOST_CONTAINER_NOEXCEPT
    { return allocator_traits_type::max_size(this->alloc()); }
 
    //! Effects: Number of elements for which memory has been allocated.
    //!   capacity() is always greater than or equal to size().
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    size_type capacity() const BOOST_CONTAINER_NOEXCEPT
    { return this->members_.m_capacity; }
 
    //! Effects: Returns true if the vector contains no elements.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    bool empty() const BOOST_CONTAINER_NOEXCEPT
    { return !this->members_.m_size; }
 
    //! Requires: size() > n.
    //!
-   //! Effects: Returns a reference to the nth element 
+   //! Effects: Returns a reference to the nth element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
-   reference operator[](size_type n)         
+   reference operator[](size_type n)        
    { return this->members_.m_start[n]; }
 
    //! Requires: size() > n.
    //!
-   //! Effects: Returns a const reference to the nth element 
+   //! Effects: Returns a const reference to the nth element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: Nothing.
-   //! 
+   //!
    //! Complexity: Constant.
    const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT
    { return this->members_.m_start[n]; }
 
    //! Requires: size() > n.
    //!
-   //! Effects: Returns a reference to the nth element 
+   //! Effects: Returns a reference to the nth element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: std::range_error if n >= size()
-   //! 
+   //!
    //! Complexity: Constant.
-   reference at(size_type n) 
+   reference at(size_type n)
    { this->priv_check_range(n); return this->members_.m_start[n]; }
 
    //! Requires: size() > n.
    //!
-   //! Effects: Returns a const reference to the nth element 
+   //! Effects: Returns a const reference to the nth element
    //!   from the beginning of the container.
-   //! 
+   //!
    //! Throws: std::range_error if n >= size()
-   //! 
+   //!
    //! Complexity: Constant.
    const_reference at(size_type n) const
    { this->priv_check_range(n); return this->members_.m_start[n]; }
 
    //! Effects: Returns a copy of the internal allocator.
-   //! 
+   //!
    //! Throws: If allocator's copy constructor throws.
-   //! 
+   //!
    //! Complexity: Constant.
    allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
    { return this->alloc();  }
 
    //! Effects: Returns a reference to the internal allocator.
-   //! 
+   //!
    //! Throws: Nothing
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Note: Non-standard extension.
    const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
    {  return this->alloc(); }
 
    //! Effects: Returns a reference to the internal allocator.
-   //! 
+   //!
    //! Throws: Nothing
-   //! 
+   //!
    //! Complexity: Constant.
-   //! 
+   //!
    //! Note: Non-standard extension.
    stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
    {  return this->alloc(); }
@@ -869,7 +869,7 @@ class vector : private container_detail::vector_alloc_holder
    //!   effect. Otherwise, it is a request for allocation of additional memory.
    //!   If the request is successful, then capacity() is greater than or equal to
    //!   n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
-   //! 
+   //!
    //! Throws: If memory allocation allocation throws or T's copy/move constructor throws.
    void reserve(size_type new_cap)
    {
@@ -928,8 +928,8 @@ class vector : private container_detail::vector_alloc_holder
 
    //! Effects: Makes *this contain the same elements as x.
    //!
-   //! Postcondition: this->size() == x.size(). *this contains a copy 
-   //! of each of x's elements. 
+   //! Postcondition: this->size() == x.size(). *this contains a copy
+   //! of each of x's elements.
    //!
    //! Throws: If memory allocation throws or T's copy/move constructor/assignment throws.
    //!
@@ -1002,7 +1002,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Linear to n.
    template 
-   void assign(InIt first, InIt last) 
+   void assign(InIt first, InIt last)
    {
       //Dispatch depending on integer/iterator
       const bool aux_boolean = container_detail::is_convertible::value;
@@ -1113,7 +1113,7 @@ class vector : private container_detail::vector_alloc_holder
    #include BOOST_PP_LOCAL_ITERATE()
 
    #endif   //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-  
+ 
    //! Effects: Swaps the contents of *this and x.
    //!
    //! Throws: Nothing.
@@ -1184,7 +1184,7 @@ class vector : private container_detail::vector_alloc_holder
    //! Throws: Nothing.
    //!
    //! Complexity: Constant time.
-   void pop_back() 
+   void pop_back()
    {
       //Destroy last element
       --this->members_.m_size;
@@ -1195,9 +1195,9 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Throws: Nothing.
    //!
-   //! Complexity: Linear to the elements between pos and the 
+   //! Complexity: Linear to the elements between pos and the
    //!   last element. Constant if pos is the last element.
-   iterator erase(const_iterator position) 
+   iterator erase(const_iterator position)
    {
       T *pos = container_detail::to_raw_pointer(position.get_ptr());
       T *beg = container_detail::to_raw_pointer(this->members_.m_start);
@@ -1214,7 +1214,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Linear to the distance between first and last
    //!   plus linear to the elements between pos and the last element.
-   iterator erase(const_iterator first, const_iterator last) 
+   iterator erase(const_iterator first, const_iterator last)
    {
       if (first != last){   // worth doing, copy down over hole
          T* end_pos = container_detail::to_raw_pointer(this->members_.m_start) + this->members_.m_size;
@@ -1236,7 +1236,7 @@ class vector : private container_detail::vector_alloc_holder
    //! Throws: If memory allocation throws, or T's copy constructor throws.
    //!
    //! Complexity: Linear to the difference between size() and new_size.
-   void resize(size_type new_size, const T& x) 
+   void resize(size_type new_size, const T& x)
    {
       pointer finish = this->members_.m_start + this->members_.m_size;
       if (new_size < size()){
@@ -1255,7 +1255,7 @@ class vector : private container_detail::vector_alloc_holder
    //! Throws: If memory allocation throws, or T's copy constructor throws.
    //!
    //! Complexity: Linear to the difference between size() and new_size.
-   void resize(size_type new_size) 
+   void resize(size_type new_size)
    {
       if (new_size < this->size()){
          //Destroy last elements
@@ -1288,8 +1288,23 @@ class vector : private container_detail::vector_alloc_holder
 
    /// @cond
 
+   //Absolutely experimental. This function might change, disappear or simply crash!
+   template
+   void insert_ordered_at(size_type element_count, BiDirPosConstIt last_position_it, BiDirValueIt last_value_it)
+   {
+      const size_type *dummy = 0;
+      this->priv_insert_ordered_at(element_count, last_position_it, false, &dummy[0], last_value_it);
+   }
+
+   //Absolutely experimental. This function might change, disappear or simply crash!
+   template
+   void insert_ordered_at(size_type element_count, BiDirPosConstIt last_position_it, BiDirSkipConstIt last_skip_it, BiDirValueIt last_value_it)
+   {
+      this->priv_insert_ordered_at(element_count, last_position_it, true, last_skip_it, last_value_it);
+   }
+
    private:
-   iterator priv_insert(const_iterator position, const T &x) 
+   iterator priv_insert(const_iterator position, const T &x)
    {
       //Just call more general insert(pos, size, value) and return iterator
       size_type pos_n = position - cbegin();
@@ -1297,7 +1312,7 @@ class vector : private container_detail::vector_alloc_holder
       return iterator(this->members_.m_start + pos_n);
    }
 
-   iterator priv_insert(const_iterator position, BOOST_RV_REF(T) x) 
+   iterator priv_insert(const_iterator position, BOOST_RV_REF(T) x)
    {
       //Just call more general insert(pos, size, value) and return iterator
       size_type pos_n = position - cbegin();
@@ -1387,7 +1402,7 @@ class vector : private container_detail::vector_alloc_holder
    template 
    void priv_range_insert(const_iterator pos, FwdIt first, FwdIt last, std::forward_iterator_tag)
    {
-      if(first != last){        
+      if(first != last){       
          const size_type n = std::distance(first, last);
          container_detail::advanced_insert_aux_proxy proxy(this->alloc(), first, last);
          priv_range_insert(pos.get_ptr(), n, proxy);
@@ -1428,7 +1443,7 @@ class vector : private container_detail::vector_alloc_holder
             this->members_.m_capacity  = real_cap;
          }
       }
-      
+     
       //If we had room or we have expanded forward
       if (same_buffer_start){
          #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
@@ -1463,10 +1478,10 @@ class vector : private container_detail::vector_alloc_holder
       }
    }
 
-   public:
    //Absolutely experimental. This function might change, disappear or simply crash!
-   template
-   void insert_ordered_at(size_type element_count, BiDirPosIt last_position_it, BiDirValueIt last_value_it)
+   template
+   void priv_insert_ordered_at( size_type element_count, BiDirPosConstIt last_position_it
+                              , bool do_skip, BiDirSkipConstIt last_skip_it, BiDirValueIt last_value_it)
    {
       const size_type old_size_pos = this->size();
       this->reserve(old_size_pos + element_count);
@@ -1484,11 +1499,15 @@ class vector : private container_detail::vector_alloc_holder
       while(insertions_left){
          const size_type pos = static_cast(*(--last_position_it));
          BOOST_ASSERT(pos <= old_size_pos);
-         //Shift the range after the insertion point, function will take care if the shift
-         //crosses the size() boundary, using copy/move or uninitialized copy/move if necessary.
-         size_type new_hole_size = insert_ordered_at_shift_range(pos, next_pos, this->size(), insertions_left);
+         //If needed shift the range after the insertion point and the previous insertion point.
+         //Function will take care if the shift crosses the size() boundary, using copy/move
+         //or uninitialized copy/move if necessary.
+         size_type new_hole_size = (pos != next_pos)
+            ? priv_insert_ordered_at_shift_range(pos, next_pos, this->size(), insertions_left)
+            : hole_size
+            ;
          if(new_hole_size > 0){
-            //The hole was reduced by insert_ordered_at_shift_range so expand exception rollback range backwards
+            //The hole was reduced by priv_insert_ordered_at_shift_range so expand exception rollback range backwards
             past_hole_values_destroyer.increment_size_backwards(next_pos - pos);
             //Insert the new value in the hole
             allocator_traits_type::construct(this->alloc(), begin_ptr + pos + insertions_left - 1, *(--last_value_it));
@@ -1505,13 +1524,19 @@ class vector : private container_detail::vector_alloc_holder
          }
          else{
             if(hole_size){
-               //Hole was just filled by insert_ordered_at_shift_range, disable exception rollback and change vector size
+               //Hole was just filled by priv_insert_ordered_at_shift_range, disable exception rollback and change vector size
                past_hole_values_destroyer.release();
                this->members_.m_size += element_count;
             }
             //Insert the new value in the already constructed range
             begin_ptr[pos + insertions_left - 1] = *(--last_value_it);
          }
+         if(do_skip){
+            size_type n = *(--last_skip_it);
+            while(n--){
+               --last_value_it;
+            }
+         }
          --insertions_left;
          hole_size = new_hole_size;
          next_pos = pos;
@@ -1531,7 +1556,7 @@ class vector : private container_detail::vector_alloc_holder
    //
    //Old situation:
    //       first_pos   last_pos         old_limit
-   //             |       |                  |  
+   //             |       |                  | 
    // ____________V_______V__________________V_____________
    //|   prefix   | range |     suffix       |raw_mem      ~
    //|____________|_______|__________________|_____________~
@@ -1540,20 +1565,20 @@ class vector : private container_detail::vector_alloc_holder
    // range is moved through move assignments
    //
    //       first_pos   last_pos         old_limit
-   //             |       |                  |  
+   //             |       |                  | 
    // ____________V_______V__________________V_____________
    //|   prefix'  |       |  | range |suffix'|raw_mem      ~
    //|________________+______|___^___|_______|_____________~
    //                 |          |
-   //                 |_>_>_>_>_>^                     
+   //                 |_>_>_>_>_>^                    
    //
    //
    //New situation in Case B (hole_size >= 0):
    // range is moved through uninitialized moves
    //
    //       first_pos   last_pos         old_limit
-   //             |       |                  |  
-   // ____________V_______V__________________V________________ 
+   //             |       |                  | 
+   // ____________V_______V__________________V________________
    //|    prefix' |       |                  | [hole] | range |
    //|_______________________________________|________|___^___|
    //                 |                                   |
@@ -1563,13 +1588,13 @@ class vector : private container_detail::vector_alloc_holder
    // range is moved through move assignments and uninitialized moves
    //
    //       first_pos   last_pos         old_limit
-   //             |       |                  |  
-   // ____________V_______V__________________V___ 
+   //             |       |                  | 
+   // ____________V_______V__________________V___
    //|   prefix'  |       |              | range |
    //|___________________________________|___^___|
    //                 |                      |
    //                 |_>_>_>_>_>_>_>_>_>_>_>^
-   size_type insert_ordered_at_shift_range(size_type first_pos, size_type last_pos, size_type limit_pos, size_type shift_count)
+   size_type priv_insert_ordered_at_shift_range(size_type first_pos, size_type last_pos, size_type limit_pos, size_type shift_count)
    {
       BOOST_ASSERT(first_pos <= last_pos);
       BOOST_ASSERT(last_pos <= limit_pos);
@@ -1597,7 +1622,7 @@ class vector : private container_detail::vector_alloc_holder
          ::boost::container::uninitialized_move_alloc
             (this->alloc(), boundary_ptr, begin_ptr + last_pos, limit_ptr);
          //The rest is move assigned
-         boost::move_backward(begin_ptr + first_pos, boundary_ptr, limit_ptr + shift_count);
+         boost::move_backward(begin_ptr + first_pos, boundary_ptr, limit_ptr);
       }
       return hole_size;
    }
@@ -1646,7 +1671,7 @@ class vector : private container_detail::vector_alloc_holder
       typename value_traits::ArrayDeallocator scoped_alloc(new_start, this->alloc(), new_cap);
       typename value_traits::ArrayDestructor constructed_values_destroyer(new_start, this->alloc(), 0u);
 
-      //Initialize with [begin(), pos) old buffer 
+      //Initialize with [begin(), pos) old buffer
       //the start of the new buffer
       T *old_buffer = container_detail::to_raw_pointer(this->members_.m_start);
       if(old_buffer){
@@ -1658,7 +1683,7 @@ class vector : private container_detail::vector_alloc_holder
       interf.uninitialized_copy_remaining_to(old_finish = new_finish);
       new_finish += n;
       constructed_values_destroyer.increment_size(new_finish - old_finish);
-      //Initialize from the rest of the old buffer, 
+      //Initialize from the rest of the old buffer,
       //starting from previous point
       if(old_buffer){
          new_finish = ::boost::container::uninitialized_move_alloc
@@ -1666,7 +1691,7 @@ class vector : private container_detail::vector_alloc_holder
          //Destroy and deallocate old elements
          //If there is allocated memory, destroy and deallocate
          if(!value_traits::trivial_dctr_after_move)
-            this->destroy_n(old_buffer, this->members_.m_size); 
+            this->destroy_n(old_buffer, this->members_.m_size);
          this->alloc().deallocate(this->members_.m_start, this->members_.m_capacity);
       }
       this->members_.m_start     = new_start;
@@ -1812,7 +1837,7 @@ class vector : private container_detail::vector_alloc_holder
             //|___________|_____|_________|_____________________|
             //
             //Copy the first part of old_begin to raw_mem
-            T *start_n = old_start + difference_type(s_before); 
+            T *start_n = old_start + difference_type(s_before);
             ::boost::container::uninitialized_move_alloc
                (this->alloc(), old_start, start_n, new_start);
             //The buffer is all constructed until old_end,
@@ -2021,7 +2046,7 @@ class vector : private container_detail::vector_alloc_holder
             this->members_.m_capacity  = real_cap;
          }
       }
-      
+     
       if(same_buffer_start){
          T *start = container_detail::to_raw_pointer(this->members_.m_start);
          if (this->size() >= n){
@@ -2050,7 +2075,7 @@ class vector : private container_detail::vector_alloc_holder
          scoped_alloc.release();
          //Destroy and deallocate old buffer
          if(this->members_.m_start != 0){
-            this->destroy_n(container_detail::to_raw_pointer(this->members_.m_start), this->members_.m_size); 
+            this->destroy_n(container_detail::to_raw_pointer(this->members_.m_start), this->members_.m_size);
             this->alloc().deallocate(this->members_.m_start, this->members_.m_capacity);
          }
          this->members_.m_start     = ret.first;
@@ -2068,7 +2093,7 @@ class vector : private container_detail::vector_alloc_holder
          this->members_.m_size  = 0;
          this->members_.m_start = ret.first;
          this->members_.m_capacity = real_cap;
-         
+        
          //Backup old buffer data
          size_type old_offset    = old_start - container_detail::to_raw_pointer(ret.first);
          size_type first_count   = container_detail::min_value(n, old_offset);
@@ -2079,7 +2104,7 @@ class vector : private container_detail::vector_alloc_holder
             (this->alloc(), first, mid, container_detail::to_raw_pointer(ret.first));
 
          if(old_offset > n){
-            //All old elements will be destroyed by "old_values_destroyer" 
+            //All old elements will be destroyed by "old_values_destroyer"
             this->members_.m_size = n;
          }
          else{
@@ -2094,7 +2119,7 @@ class vector : private container_detail::vector_alloc_holder
             std::advance(mid2, second_count);
             // iG std::copy(mid, mid2, old_start);
             std::copy(mid, mid2, old_start);
-            
+           
             //Check if we still have to append elements in the
             //uninitialized end
             if(second_count == old_size){
@@ -2107,7 +2132,7 @@ class vector : private container_detail::vector_alloc_holder
                   (old_start + second_count, old_size - second_count);
                this->members_.m_size = n;
             }
-            this->members_.m_size = n;                        
+            this->members_.m_size = n;                       
          }
       }
    }
@@ -2118,18 +2143,18 @@ class vector : private container_detail::vector_alloc_holder
 
    template 
    void priv_assign_dispatch(InIt first, InIt last, container_detail::false_)
-   { 
+   {
       //Dispatch depending on integer/iterator
       typedef typename std::iterator_traits::iterator_category ItCat;
-      this->priv_assign_aux(first, last, ItCat()); 
+      this->priv_assign_aux(first, last, ItCat());
    }
 
    template 
-   void priv_insert_dispatch(const_iterator pos, Integer n, Integer val, container_detail::true_) 
+   void priv_insert_dispatch(const_iterator pos, Integer n, Integer val, container_detail::true_)
    {  this->insert(pos, (size_type)n, (T)val);  }
 
    template 
-   void priv_insert_dispatch(const_iterator pos, InIt first, 
+   void priv_insert_dispatch(const_iterator pos, InIt first,
                              InIt last,      container_detail::false_)
    {
       //Dispatch depending on integer/iterator
@@ -2137,7 +2162,7 @@ class vector : private container_detail::vector_alloc_holder
       this->priv_range_insert(pos, first, last, ItCat());
    }
 
-   void priv_check_range(size_type n) const 
+   void priv_check_range(size_type n) const
    {
       //If n is out of range, throw an out_of_range exception
       if (n >= size())
@@ -2157,7 +2182,7 @@ class vector : private container_detail::vector_alloc_holder
 };
 
 template 
-inline bool 
+inline bool
 operator==(const vector& x, const vector& y)
 {
    //Check first size and each element if needed
@@ -2165,7 +2190,7 @@ operator==(const vector& x, const vector& y)
 }
 
 template 
-inline bool 
+inline bool
 operator!=(const vector& x, const vector& y)
 {
    //Check first size and each element if needed
@@ -2173,7 +2198,7 @@ operator!=(const vector& x, const vector& y)
 }
 
 template 
-inline bool 
+inline bool
 operator<(const vector& x, const vector& y)
 {
    return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());

From 082c47b72196310aa64df7260ef40eee69a4b2ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Sun, 20 May 2012 10:03:06 +0000
Subject: [PATCH 28/93] Trailing whitespaces

[SVN r78519]
---
 doc/Jamfile.v2                         |  18 +-
 doc/container.qbk                      |  44 ++---
 doc/index.idx                          |   2 +-
 example/Jamfile.v2                     |  10 +-
 example/doc_recursive_containers.cpp   |   2 +-
 example/doc_type_erasure.cpp           |   4 +-
 test/Jamfile.v2                        |  10 +-
 test/check_equal_containers.hpp        |  14 +-
 test/deque_test.cpp                    |   6 +-
 test/dummy_test_allocator.hpp          |  16 +-
 test/expand_bwd_test_allocator.hpp     |  18 +-
 test/expand_bwd_test_template.hpp      |  14 +-
 test/flat_tree_test.cpp                | 238 ++++++++++++++++++++++++-
 test/heap_allocator_v1.hpp             |  22 +--
 test/list_test.cpp                     |   6 +-
 test/list_test.hpp                     |   2 +-
 test/map_test.hpp                      |   8 +-
 test/movable_int.hpp                   |  16 +-
 test/print_container.hpp               |   4 +-
 test/scoped_allocator_adaptor_test.cpp |   8 +-
 test/scoped_allocator_usage_test.cpp   |   2 +-
 test/set_test.hpp                      |   4 +-
 test/slist_test.cpp                    |   6 +-
 test/stable_vector_test.cpp            |   6 +-
 test/string_test.cpp                   |  30 ++--
 test/vector_test.cpp                   |   6 +-
 test/vector_test.hpp                   |   6 +-
 27 files changed, 371 insertions(+), 151 deletions(-)

diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2
index 8e4eb2b..05bf622 100644
--- a/doc/Jamfile.v2
+++ b/doc/Jamfile.v2
@@ -36,8 +36,8 @@ doxygen autodoc
         "boost.doxygen.reftitle=Boost.Container Header Reference"
    ;
 
-xml container : container.qbk 
-              : 
+xml container : container.qbk
+              :
                  ../../../tools/auto_index/include
               ;
 
@@ -54,26 +54,26 @@ boostbook standalone
         pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html
 
         # Build requirements go here:
-        
+       
         # on (or off) one turns on (or off) indexing:
         on
-        
+       
         # Turns on (or off) auto-index-verbose for diagnostic info.
         # This is highly recommended until you have got all the many details correct!
-        on 
-        
+        on
+       
         # Choose the indexing method (separately for html and PDF) - see manual.
         # Choose indexing method for PDFs:
         pdf:off
-        
+       
         # Choose indexing method for html:
         html:on
-        
+       
         # Set the name of the script file to use (index.idx is popular):
         index.idx
         # Commands in the script file should all use RELATIVE PATHS
         # otherwise the script will not be portable to other machines.
-        # Relative paths are normally taken as relative to the location 
+        # Relative paths are normally taken as relative to the location
         # of the script file, but we can add a prefix to all
         # those relative paths using the  feature.
         # The path specified by  may be either relative or
diff --git a/doc/container.qbk b/doc/container.qbk
index c446e60..ee4cf42 100644
--- a/doc/container.qbk
+++ b/doc/container.qbk
@@ -225,7 +225,7 @@ want to advance it by n positions, we simply do:
 
    it.p = *(it.p->up+n);
 
-That is, we go "up" to the pointer array, add n there and then go "down" to the resulting node. 
+That is, we go "up" to the pointer array, add n there and then go "down" to the resulting node.
 
 [*General properties]. `stable_vector` satisfies all the requirements of a container, a reversible container and a sequence
 and provides all the optional operations present in vector. Like vector, iterators are random access. `stable_vector`
@@ -291,8 +291,8 @@ C++ world. Matt Austern's  classic article
 
 ["['Red-black trees aren't the only way to organize data that permits lookup in logarithmic time.  One of the basic
 algorithms of computer science is binary search, which works by successively dividing a range in half. Binary
-search is log N and it doesn't require any fancy data structures, just a sorted collection of elements. 
-(...) You can use whatever data structure is convenient, so long as it provides STL iterator; 
+search is log N and it doesn't require any fancy data structures, just a sorted collection of elements.
+(...) You can use whatever data structure is convenient, so long as it provides STL iterator;
 usually it's easiest to use a C array, or a vector.]]
 
 ["['Both std::lower_bound and set::find take time proportional to log N, but the constants of proportionality
@@ -317,12 +317,12 @@ showed `AssocVector`, a `std::map` drop-in
 replacement designed in his [@http://loki-lib.sourceforge.net/ Loki] library:
 
 ["['It seems as if we're better off with a sorted vector. The disadvantages of a sorted
-vector are linear-time insertions and linear-time deletions (...). In exchange, a vector 
-offers about twice the lookup speed and a much smaller working set (...). 
-Loki saves the trouble of maintaining a sorted vector by hand by defining an AssocVector class 
-template. AssocVector is a drop-in replacement for std::map (it supports the same set of member 
-functions), implemented on top of std::vector. AssocVector differs from a map in the behavior of 
-its erase functions (AssocVector::erase invalidates all iterators into the object) and in the 
+vector are linear-time insertions and linear-time deletions (...). In exchange, a vector
+offers about twice the lookup speed and a much smaller working set (...).
+Loki saves the trouble of maintaining a sorted vector by hand by defining an AssocVector class
+template. AssocVector is a drop-in replacement for std::map (it supports the same set of member
+functions), implemented on top of std::vector. AssocVector differs from a map in the behavior of
+its erase functions (AssocVector::erase invalidates all iterators into the object) and in the
 complexity guarantees of insert and erase (linear as opposed to constant). ]]
 
 [*Boost.Container] `flat_[multi]map/set` containers are ordered-vector based associative containers
@@ -380,7 +380,7 @@ should probably use list instead of slist.]]
 [*Boost.Container] updates the classic `slist` container with C++11 features like move semantics and placement
 insertion and implements it a bit differently than the standard C++ `forward_list`. `forward_list` has no `size()`
 method, so it's been designed to allow (or in practice, encourage) implementations without tracking list size
-with every insertion/erasure, allowing constant-time 
+with every insertion/erasure, allowing constant-time
 `splice_after(iterator, forward_list &, iterator, iterator)`-based list merging. On the other hand `slist` offers
 constant-time `size()` for those that don't care about linear-time `splice_after(iterator, slist &, iterator, iterator)`
 `size()` and offers an additional `splice_after(iterator, slist &, iterator, iterator, size_type)` method that
@@ -422,16 +422,16 @@ to suppose two allocators of the same type always compare equal (that means that
 by one allocator object could be deallocated by another instance of the same type) and
 allocators were not swapped when the container was swapped.
 
-C++11 further improves stateful allocator support through 
+C++11 further improves stateful allocator support through
 [@http://en.cppreference.com/w/cpp/memory/allocator_traits `std::allocator_traits`].
 `std::allocator_traits` is the protocol between a container and an allocator, and
 an allocator writer can customize its behaviour (should the container propagate it in
 move constructor, swap, etc.?) following `allocator_traits` requirements. [*Boost.Container]
-not only supports this model with C++11 but also [*backports it to C++03]. 
+not only supports this model with C++11 but also [*backports it to C++03].
 
-If possible, a single allocator is hold to construct `value_type`. If the container needs an auxiliary 
-allocator (e.g. a array allocator used by `deque` or `stable_vector`), that allocator is also 
-constructed from the user-supplied allocator when the container is constructed (i.e. it's 
+If possible, a single allocator is hold to construct `value_type`. If the container needs an auxiliary
+allocator (e.g. a array allocator used by `deque` or `stable_vector`), that allocator is also
+constructed from the user-supplied allocator when the container is constructed (i.e. it's
 not constructed on the fly when auxiliary memory is needed).
 
 [endsect]
@@ -453,14 +453,14 @@ container's elements, and, if the elements themselves are containers, the third
 elements' elements, and so on.
 
 [*Boost.Container] implements its own `scoped_allocator_adaptor` class and [*backports this feature also
-to C++03 compilers]. Due to C++03 limitations, in those compilers 
+to C++03 compilers]. Due to C++03 limitations, in those compilers
 the allocator propagation implemented by `scoped_allocator_adaptor::construct` functions
 will be based on traits([classref boost::container::constructible_with_allocator_suffix constructible_with_allocator_suffix]
 and [classref boost::container::constructible_with_allocator_prefix constructible_with_allocator_prefix])
-proposed in [@http://www.open-std.org/jtc1/sc22/WG21/docs/papers/2008/n2554.pdf 
+proposed in [@http://www.open-std.org/jtc1/sc22/WG21/docs/papers/2008/n2554.pdf
 N2554: The Scoped Allocator Model (Rev 2) proposal]. In conforming C++11 compilers or compilers supporting SFINAE
-expressions (when `BOOST_NO_SFINAE_EXPR` is NOT defined), traits are ignored and C++11 rules 
-(`is_constructible::value` and 
+expressions (when `BOOST_NO_SFINAE_EXPR` is NOT defined), traits are ignored and C++11 rules
+(`is_constructible::value` and
 `is_constructible::value`)
 will be used to detect if the allocator must be propagated with suffix or prefix allocator arguments.
 
@@ -487,7 +487,7 @@ versions.
 unsuccessful tries to deprecate or remove it from the standard. [*Boost.Container] does not implement it
 as there is a superior [@http://www.boost.org/libs/dynamic_bitset/ Boost.DynamicBitset]
 solution. For issues with `vector` see papers
-[@http://www.gotw.ca/publications/N1211.pdf vector: N1211: More Problems, Better Solutions], 
+[@http://www.gotw.ca/publications/N1211.pdf vector: N1211: More Problems, Better Solutions],
 [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2160.html N2160: Library Issue 96: Fixing vector],
 [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2204.html N2204 A Specification to deprecate vector].
 
@@ -539,7 +539,7 @@ code tweaked to support non-raw `allocator::pointer` types and stateful allocato
 Shmem was accepted as [@http://www.boost.org/libs/interprocess/ Boost.Interprocess] and this library
 continued to refine and improve those containers.
 
-In 2007, container code from node containers (`map`, `list`, `slist`) was rewritten, refactored 
+In 2007, container code from node containers (`map`, `list`, `slist`) was rewritten, refactored
 and expanded to build the intrusive container library [@http://www.boost.org/libs/intrusive/ Boost.Intrusive].
 [*Boost.Interprocess] containers were refactored to take advantage of [*Boost.Intrusive] containers and
 code duplication was minimized. Both libraries continued to gain support and bug fixes for years.
@@ -603,7 +603,7 @@ use [*Boost.Container]? There are several reasons for that:
    [@http://bannalia.blogspot.com/2008/09/introducing-stablevector.html Joaqu\u00EDn M. L\u00F3pez Mu\u00F1oz],
    then adapted for [*Boost.Interprocess]. Thanks for such a great container.
 
-*  Howard Hinnant's help and advices were essential when implementing move semantics, 
+*  Howard Hinnant's help and advices were essential when implementing move semantics,
    improving allocator support or implementing small string optimization. Thanks Howard
    for your wonderful standard library implementations.
 
diff --git a/doc/index.idx b/doc/index.idx
index 9d0d126..b055432 100644
--- a/doc/index.idx
+++ b/doc/index.idx
@@ -1 +1 @@
-!scan-path "boost/container" ".*.hpp" false 
+!scan-path "boost/container" ".*.hpp" false
diff --git a/example/Jamfile.v2 b/example/Jamfile.v2
index 1b4eb2d..2371b80 100644
--- a/example/Jamfile.v2
+++ b/example/Jamfile.v2
@@ -1,14 +1,14 @@
 # Boost Container Library Example Jamfile
 
 #  (C) Copyright Ion Gaztanaga 2009
-# Use, modification and distribution are subject to the 
-# Boost Software License, Version 1.0. (See accompanying file 
+# Use, modification and distribution are subject to 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)
 
 # Adapted from John Maddock's TR1 Jamfile.v2
 # Copyright John Maddock 2005.
-# Use, modification and distribution are subject to the 
-# Boost Software License, Version 1.0. (See accompanying file 
+# Use, modification and distribution are subject to 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)
 
 # this rule enumerates through all the sources and invokes
@@ -31,4 +31,4 @@ rule test_all
    return $(all_rules) ;
 }
 
-test-suite container_example : [ test_all r ] : multi ; 
\ No newline at end of file
+test-suite container_example : [ test_all r ] : multi ;
diff --git a/example/doc_recursive_containers.cpp b/example/doc_recursive_containers.cpp
index e9e67d5..e486209 100644
--- a/example/doc_recursive_containers.cpp
+++ b/example/doc_recursive_containers.cpp
@@ -49,7 +49,7 @@ int main()
    stable_vector sv;
    sv.resize(100);
 
-   //Let's build a tree based in 
+   //Let's build a tree based in
    //a recursive data type
    tree_node root;
    root.name  = "root";
diff --git a/example/doc_type_erasure.cpp b/example/doc_type_erasure.cpp
index 73c81f1..1c56f7f 100644
--- a/example/doc_type_erasure.cpp
+++ b/example/doc_type_erasure.cpp
@@ -15,7 +15,7 @@
 //MyClassHolder.h
 
 //We don't need to include "MyClass.h"
-//to store vector 
+//to store vector
 class MyClass;
 
 class MyClassHolder
@@ -44,7 +44,7 @@ class MyClass
    MyClass(int val = 0) : value_(val){}
 
    friend bool operator==(const MyClass &l, const MyClass &r)
-   {  return l.value_ == r.value_;  } 
+   {  return l.value_ == r.value_;  }
    //...
 };
 
diff --git a/test/Jamfile.v2 b/test/Jamfile.v2
index 6120122..af84010 100644
--- a/test/Jamfile.v2
+++ b/test/Jamfile.v2
@@ -1,14 +1,14 @@
 # Boost Container Library Test Jamfile
 
 #  (C) Copyright Ion Gaztanaga 2009.
-# Use, modification and distribution are subject to the 
-# Boost Software License, Version 1.0. (See accompanying file 
+# Use, modification and distribution are subject to 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)
 
 # Adapted from John Maddock's TR1 Jamfile.v2
 # Copyright John Maddock 2005.
-# Use, modification and distribution are subject to the 
-# Boost Software License, Version 1.0. (See accompanying file 
+# Use, modification and distribution are subject to 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)
 
 # this rule enumerates through all the sources and invokes
@@ -31,4 +31,4 @@ rule test_all
    return $(all_rules) ;
 }
 
-test-suite container_test : [ test_all r ] ; 
+test-suite container_test : [ test_all r ] ;
diff --git a/test/check_equal_containers.hpp b/test/check_equal_containers.hpp
index ad89e6b..69d642c 100644
--- a/test/check_equal_containers.hpp
+++ b/test/check_equal_containers.hpp
@@ -23,17 +23,17 @@ namespace test{
 //Function to check if both containers are equal
 template
-bool CheckEqualContainers(MyBoostCont *boostcont, MyStdCont *stdcont)
+bool CheckEqualContainers(const MyBoostCont *boostcont, const MyStdCont *stdcont)
 {
    if(boostcont->size() != stdcont->size())
       return false;
 
    typedef typename MyBoostCont::value_type value_type;
 
-   typename MyBoostCont::iterator itboost(boostcont->begin()), itboostend(boostcont->end());
-   typename MyStdCont::iterator itstd(stdcont->begin());
+   typename MyBoostCont::const_iterator itboost(boostcont->begin()), itboostend(boostcont->end());
+   typename MyStdCont::const_iterator itstd(stdcont->begin());
    typename MyStdCont::size_type dist = (typename MyStdCont::size_type)std::distance(itboost, itboostend);
-   if(dist != boostcont->size()){ 
+   if(dist != boostcont->size()){
       return false;
    }
    std::size_t i = 0;
@@ -48,7 +48,7 @@ bool CheckEqualContainers(MyBoostCont *boostcont, MyStdCont *stdcont)
 
 template
-bool CheckEqualPairContainers(MyBoostCont *boostcont, MyStdCont *stdcont)
+bool CheckEqualPairContainers(const MyBoostCont *boostcont, const MyStdCont *stdcont)
 {
    if(boostcont->size() != stdcont->size())
       return false;
@@ -56,8 +56,8 @@ bool CheckEqualPairContainers(MyBoostCont *boostcont, MyStdCont *stdcont)
    typedef typename MyBoostCont::key_type      key_type;
    typedef typename MyBoostCont::mapped_type   mapped_type;
 
-   typename MyBoostCont::iterator itboost(boostcont->begin()), itboostend(boostcont->end());
-   typename MyStdCont::iterator itstd(stdcont->begin());
+   typename MyBoostCont::const_iterator itboost(boostcont->begin()), itboostend(boostcont->end());
+   typename MyStdCont::const_iterator itstd(stdcont->begin());
    for(; itboost != itboostend; ++itboost, ++itstd){
       if(itboost->first != key_type(itstd->first))
          return false;
diff --git a/test/deque_test.cpp b/test/deque_test.cpp
index 7190e0a..53f17a3 100644
--- a/test/deque_test.cpp
+++ b/test/deque_test.cpp
@@ -259,11 +259,11 @@ bool do_test()
 
       cntdeque->resize(100);
       stddeque->resize(100);
-      if(!test::CheckEqualContainers(cntdeque, stddeque)) return 1;         
+      if(!test::CheckEqualContainers(cntdeque, stddeque)) return 1;        
 
       cntdeque->resize(200);
       stddeque->resize(200);
-      if(!test::CheckEqualContainers(cntdeque, stddeque)) return 1;         
+      if(!test::CheckEqualContainers(cntdeque, stddeque)) return 1;        
 
       delete cntdeque;
       delete stddeque;
@@ -272,7 +272,7 @@ bool do_test()
       std::cout << ex.what() << std::endl;
       return false;
    }
-   
+  
    std::cout << std::endl << "Test OK!" << std::endl;
    return true;
 }
diff --git a/test/dummy_test_allocator.hpp b/test/dummy_test_allocator.hpp
index 394b5a9..332892e 100644
--- a/test/dummy_test_allocator.hpp
+++ b/test/dummy_test_allocator.hpp
@@ -69,7 +69,7 @@ class simple_allocator
 
 //Version 2 allocator with rebind
 template
-class dummy_test_allocator 
+class dummy_test_allocator
 {
  private:
    typedef dummy_test_allocator  self_t;
@@ -100,7 +100,7 @@ class dummy_test_allocator
 
    //!Default constructor. Never throws
    dummy_test_allocator()
-   {} 
+   {}
 
    //!Constructor from other dummy_test_allocator. Never throws
    dummy_test_allocator(const dummy_test_allocator &)
@@ -111,7 +111,7 @@ class dummy_test_allocator
    dummy_test_allocator(const dummy_test_allocator &)
    {}
 
-   pointer address(reference value) 
+   pointer address(reference value)
    {  return pointer(container_detail::addressof(value));  }
 
    const_pointer address(const_reference value) const
@@ -140,7 +140,7 @@ class dummy_test_allocator
 
    std::pair
       allocation_command(boost::container::allocation_type,
-                         size_type, 
+                         size_type,
                          size_type,
                          size_type &, const pointer & = 0)
    {  return std::pair(pointer(), true); }
@@ -192,19 +192,19 @@ class dummy_test_allocator
 
 //!Equality test for same type of dummy_test_allocator
 template inline
-bool operator==(const dummy_test_allocator  &, 
+bool operator==(const dummy_test_allocator  &,
                 const dummy_test_allocator  &)
 {  return true; }
 
 //!Inequality test for same type of dummy_test_allocator
 template inline
-bool operator!=(const dummy_test_allocator  &, 
+bool operator!=(const dummy_test_allocator  &,
                 const dummy_test_allocator  &)
 {  return false; }
 
 
 template< class T
-        , bool PropagateOnContCopyAssign 
+        , bool PropagateOnContCopyAssign
         , bool PropagateOnContMoveAssign
         , bool PropagateOnContSwap
         , bool CopyOnPropagateOnContSwap
@@ -335,7 +335,7 @@ class propagation_test_allocator
 };
 
 template< class T
-        , bool PropagateOnContCopyAssign 
+        , bool PropagateOnContCopyAssign
         , bool PropagateOnContMoveAssign
         , bool PropagateOnContSwap
         , bool CopyOnPropagateOnContSwap
diff --git a/test/expand_bwd_test_allocator.hpp b/test/expand_bwd_test_allocator.hpp
index 3f499d2..fbab8c7 100644
--- a/test/expand_bwd_test_allocator.hpp
+++ b/test/expand_bwd_test_allocator.hpp
@@ -36,11 +36,11 @@ namespace boost {
 namespace container {
 namespace test {
 
-//This allocator just allows two allocations. The first one will return 
+//This allocator just allows two allocations. The first one will return
 //mp_buffer + m_offset configured in the constructor. The second one
 //will return mp_buffer.
 template
-class expand_bwd_test_allocator 
+class expand_bwd_test_allocator
 {
  private:
    typedef expand_bwd_test_allocator self_t;
@@ -70,12 +70,12 @@ class expand_bwd_test_allocator
    {  typedef expand_bwd_test_allocator   other;   };
 
    //!Constructor from the segment manager. Never throws
-   expand_bwd_test_allocator(T *buffer, size_type size, difference_type offset) 
+   expand_bwd_test_allocator(T *buffer, size_type size, difference_type offset)
       : mp_buffer(buffer), m_size(size)
       , m_offset(offset),  m_allocations(0){ }
 
    //!Constructor from other expand_bwd_test_allocator. Never throws
-   expand_bwd_test_allocator(const expand_bwd_test_allocator &other) 
+   expand_bwd_test_allocator(const expand_bwd_test_allocator &other)
       : mp_buffer(other.mp_buffer), m_size(other.m_size)
       , m_offset(other.m_offset),  m_allocations(0){ }
 
@@ -108,7 +108,7 @@ class expand_bwd_test_allocator
    {  return m_size;   }
 
    friend void swap(self_t &alloc1, self_t &alloc2)
-   {  
+   { 
       container_detail::do_swap(alloc1.mp_buffer, alloc2.mp_buffer);
       container_detail::do_swap(alloc1.m_size,    alloc2.m_size);
       container_detail::do_swap(alloc1.m_offset,  alloc2.m_offset);
@@ -118,14 +118,14 @@ class expand_bwd_test_allocator
 
    std::pair
       allocation_command(boost::container::allocation_type command,
-                         size_type limit_size, 
+                         size_type limit_size,
                          size_type preferred_size,
                          size_type &received_size, const pointer &reuse = 0)
    {
       (void)preferred_size;   (void)reuse;   (void)command;
       //This allocator only expands backwards!
       assert(m_allocations == 0 || (command & boost::container::expand_bwd));
-      
+     
       received_size = limit_size;
 
       if(m_allocations == 0){
@@ -173,13 +173,13 @@ class expand_bwd_test_allocator
 
 //!Equality test for same type of expand_bwd_test_allocator
 template inline
-bool operator==(const expand_bwd_test_allocator  &alloc1, 
+bool operator==(const expand_bwd_test_allocator  &alloc1,
                 const expand_bwd_test_allocator  &alloc2)
 {  return false; }
 
 //!Inequality test for same type of expand_bwd_test_allocator
 template inline
-bool operator!=(const expand_bwd_test_allocator  &alloc1, 
+bool operator!=(const expand_bwd_test_allocator  &alloc1,
                 const expand_bwd_test_allocator  &alloc2)
 {  return true; }
 
diff --git a/test/expand_bwd_test_template.hpp b/test/expand_bwd_test_template.hpp
index 7dadcf9..0f06e23 100644
--- a/test/expand_bwd_test_template.hpp
+++ b/test/expand_bwd_test_template.hpp
@@ -114,19 +114,19 @@ bool test_insert_with_expand_bwd()
    const int MemorySize = 1000;
 
    //Distance old and new buffer
-   const int Offset[]      = 
+   const int Offset[]      =
       {  350,  250,  150,  150,
          150,  50,   50,   50    };
    //Insert position
-   const int Position[]    = 
+   const int Position[]    =
       {  100,  100,  100,  100,
          100,  100,  100,  100   };
    //Initial vector size
-   const int InitialSize[] = 
+   const int InitialSize[] =
       {  200,  200,  200,  200,
          200,  200,  200,  200   };
    //Size of the data to insert
-   const int InsertSize[]  = 
+   const int InsertSize[]  =
       {  100,  100,  100,  200,
          300,  25,   100,  200   };
    //Number of tests
@@ -159,7 +159,7 @@ bool test_insert_with_expand_bwd()
                            , data_to_insert.begin(), data_to_insert.end());
          //Now check that values are equal
          if(!CheckEqualVector(vector, initial_data)){
-            std::cout << "test_assign_with_expand_bwd::CheckEqualVector failed." << std::endl 
+            std::cout << "test_assign_with_expand_bwd::CheckEqualVector failed." << std::endl
                      << "   Class: " << typeid(VectorWithExpandBwdAllocator).name() << std::endl
                      << "   Iteration: " << iteration << std::endl;
             return false;
@@ -215,13 +215,13 @@ bool test_assign_with_expand_bwd()
          vector.insert( vector.begin()
                      , initial_data.begin(), initial_data.end());
 
-         //Assign data 
+         //Assign data
          vector.assign(data_to_assign.begin(), data_to_assign.end());
          initial_data.assign(data_to_assign.begin(), data_to_assign.end());
 
          //Now check that values are equal
          if(!CheckEqualVector(vector, initial_data)){
-            std::cout << "test_assign_with_expand_bwd::CheckEqualVector failed." << std::endl 
+            std::cout << "test_assign_with_expand_bwd::CheckEqualVector failed." << std::endl
                      << "   Class: " << typeid(VectorWithExpandBwdAllocator).name() << std::endl
                      << "   Iteration: " << iteration << std::endl;
             return false;
diff --git a/test/flat_tree_test.cpp b/test/flat_tree_test.cpp
index 645a124..ba3d450 100644
--- a/test/flat_tree_test.cpp
+++ b/test/flat_tree_test.cpp
@@ -19,12 +19,14 @@
 #include "map_test.hpp"
 #include "propagate_allocator_test.hpp"
 #include "emplace_test.hpp"
+#include 
+#include 
 
 using namespace boost::container;
 
 namespace boost {
 namespace container {
-
+/*
 //Explicit instantiation to detect compilation errors
 
 //flat_map
@@ -113,25 +115,25 @@ template class flat_multiset
    , std::less
    , std::allocator
    >;
-
+*/
 }} //boost::container
 
 
 //Alias allocator type
 typedef std::allocator allocator_t;
-typedef std::allocator 
+typedef std::allocator
    movable_allocator_t;
-typedef std::allocator > 
+typedef std::allocator >
    pair_allocator_t;
-typedef std::allocator > 
+typedef std::allocator >
    movable_pair_allocator_t;
-typedef std::allocator 
+typedef std::allocator
    move_copy_allocator_t;
-typedef std::allocator > 
+typedef std::allocator >
    move_copy_pair_allocator_t;
-typedef std::allocator 
+typedef std::allocator
    copy_allocator_t;
-typedef std::allocator > 
+typedef std::allocator >
    copy_pair_allocator_t;
 
 
@@ -302,6 +304,169 @@ class flat_tree_propagate_test_wrapper
    {  this->Base::swap(x);  }
 };
 
+namespace boost{
+namespace container {
+namespace test{
+
+bool flat_tree_ordered_insertion_test()
+{
+   using namespace boost::container;
+   const std::size_t NumElements = 100;
+
+   //Ordered insertion multiset
+   {
+      std::multiset int_mset;
+      for(std::size_t i = 0; i != NumElements; ++i){
+         int_mset.insert(static_cast(i));
+      }
+      //Construction insertion
+      flat_multiset fmset(ordered_range, int_mset.begin(), int_mset.end());
+      if(!CheckEqualContainers(&int_mset, &fmset))
+         return false;
+      //Insertion when empty
+      fmset.clear();
+      fmset.insert(ordered_range, int_mset.begin(), int_mset.end());
+      if(!CheckEqualContainers(&int_mset, &fmset))
+         return false;
+      //Re-insertion
+      fmset.insert(ordered_range, int_mset.begin(), int_mset.end());
+      std::multiset int_mset2(int_mset);
+      int_mset2.insert(int_mset.begin(), int_mset.end());
+      if(!CheckEqualContainers(&int_mset2, &fmset))
+         return false;
+      //Re-re-insertion
+      fmset.insert(ordered_range, int_mset2.begin(), int_mset2.end());
+      std::multiset int_mset4(int_mset2);
+      int_mset4.insert(int_mset2.begin(), int_mset2.end());
+      if(!CheckEqualContainers(&int_mset4, &fmset))
+         return false;
+      //Re-re-insertion of even
+      std::multiset int_even_mset;
+      for(std::size_t i = 0; i < NumElements; i+=2){
+         int_mset.insert(static_cast(i));
+      }
+      fmset.insert(ordered_range, int_even_mset.begin(), int_even_mset.end());
+      int_mset4.insert(int_even_mset.begin(), int_even_mset.end());
+      if(!CheckEqualContainers(&int_mset4, &fmset))
+         return false;
+   }
+   //Ordered insertion multimap
+   {
+      std::multimap int_mmap;
+      for(std::size_t i = 0; i != NumElements; ++i){
+         int_mmap.insert(std::multimap::value_type(static_cast(i), static_cast(i)));
+      }
+      //Construction insertion
+      flat_multimap fmmap(ordered_range, int_mmap.begin(), int_mmap.end());
+      if(!CheckEqualContainers(&int_mmap, &fmmap))
+         return false;
+      //Insertion when empty
+      fmmap.clear();
+      fmmap.insert(ordered_range, int_mmap.begin(), int_mmap.end());
+      if(!CheckEqualContainers(&int_mmap, &fmmap))
+         return false;
+      //Re-insertion
+      fmmap.insert(ordered_range, int_mmap.begin(), int_mmap.end());
+      std::multimap int_mmap2(int_mmap);
+      int_mmap2.insert(int_mmap.begin(), int_mmap.end());
+      if(!CheckEqualContainers(&int_mmap2, &fmmap))
+         return false;
+      //Re-re-insertion
+      fmmap.insert(ordered_range, int_mmap2.begin(), int_mmap2.end());
+      std::multimap int_mmap4(int_mmap2);
+      int_mmap4.insert(int_mmap2.begin(), int_mmap2.end());
+      if(!CheckEqualContainers(&int_mmap4, &fmmap))
+         return false;
+      //Re-re-insertion of even
+      std::multimap int_even_mmap;
+      for(std::size_t i = 0; i < NumElements; i+=2){
+         int_mmap.insert(std::multimap::value_type(static_cast(i), static_cast(i)));
+      }
+      fmmap.insert(ordered_range, int_even_mmap.begin(), int_even_mmap.end());
+      int_mmap4.insert(int_even_mmap.begin(), int_even_mmap.end());
+      if(!CheckEqualContainers(&int_mmap4, &fmmap))
+         return false;
+   }
+
+   //Ordered insertion set
+   {
+      std::set int_set;
+      for(std::size_t i = 0; i != NumElements; ++i){
+         int_set.insert(static_cast(i));
+      }
+      //Construction insertion
+      flat_set fset(ordered_unique_range, int_set.begin(), int_set.end());
+      if(!CheckEqualContainers(&int_set, &fset))
+         return false;
+      //Insertion when empty
+      fset.clear();
+      fset.insert(ordered_unique_range, int_set.begin(), int_set.end());
+      if(!CheckEqualContainers(&int_set, &fset))
+         return false;
+      //Re-insertion
+      fset.insert(ordered_unique_range, int_set.begin(), int_set.end());
+      std::set int_set2(int_set);
+      int_set2.insert(int_set.begin(), int_set.end());
+      if(!CheckEqualContainers(&int_set2, &fset))
+         return false;
+      //Re-re-insertion
+      fset.insert(ordered_unique_range, int_set2.begin(), int_set2.end());
+      std::set int_set4(int_set2);
+      int_set4.insert(int_set2.begin(), int_set2.end());
+      if(!CheckEqualContainers(&int_set4, &fset))
+         return false;
+      //Re-re-insertion of even
+      std::set int_even_set;
+      for(std::size_t i = 0; i < NumElements; i+=2){
+         int_set.insert(static_cast(i));
+      }
+      fset.insert(ordered_unique_range, int_even_set.begin(), int_even_set.end());
+      int_set4.insert(int_even_set.begin(), int_even_set.end());
+      if(!CheckEqualContainers(&int_set4, &fset))
+         return false;
+   }
+   //Ordered insertion map
+   {
+      std::map int_map;
+      for(std::size_t i = 0; i != NumElements; ++i){
+         int_map.insert(std::map::value_type(static_cast(i), static_cast(i)));
+      }
+      //Construction insertion
+      flat_map fmap(ordered_unique_range, int_map.begin(), int_map.end());
+      if(!CheckEqualContainers(&int_map, &fmap))
+         return false;
+      //Insertion when empty
+      fmap.clear();
+      fmap.insert(ordered_unique_range, int_map.begin(), int_map.end());
+      if(!CheckEqualContainers(&int_map, &fmap))
+         return false;
+      //Re-insertion
+      fmap.insert(ordered_unique_range, int_map.begin(), int_map.end());
+      std::map int_map2(int_map);
+      int_map2.insert(int_map.begin(), int_map.end());
+      if(!CheckEqualContainers(&int_map2, &fmap))
+         return false;
+      //Re-re-insertion
+      fmap.insert(ordered_unique_range, int_map2.begin(), int_map2.end());
+      std::map int_map4(int_map2);
+      int_map4.insert(int_map2.begin(), int_map2.end());
+      if(!CheckEqualContainers(&int_map4, &fmap))
+         return false;
+      //Re-re-insertion of even
+      std::map int_even_map;
+      for(std::size_t i = 0; i < NumElements; i+=2){
+         int_map.insert(std::map::value_type(static_cast(i), static_cast(i)));
+      }
+      fmap.insert(ordered_unique_range, int_even_map.begin(), int_even_map.end());
+      int_map4.insert(int_even_map.begin(), int_even_map.end());
+      if(!CheckEqualContainers(&int_map4, &fmap))
+         return false;
+   }
+
+   return true;
+}
+
+}}}
 
 int main()
 {
@@ -315,6 +480,9 @@ int main()
       test_move >();
    }
 
+   if(!flat_tree_ordered_insertion_test()){
+      return 1;
+   }
 
    if (0 != set_test<
                   MyBoostSet
@@ -459,3 +627,55 @@ int main()
 }
 
 #include 
+
+/*
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct Request
+{
+    Request() {};
+  
+    //Move semantics...
+    Request(BOOST_RV_REF(Request) r) : rvals()  //Move constructor
+    {
+        rvals.swap(r.rvals);
+    };
+
+    Request& operator=(BOOST_RV_REF(Request) r) //Move assignment
+    {
+        if (this != &r){
+            rvals.swap(r.rvals);
+        }
+        return *this;
+    };
+
+    // Values I want to be moved, not copied.
+    boost::container::vector rvals;
+
+   private:
+    // Mark this class movable but not copyable
+    BOOST_MOVABLE_BUT_NOT_COPYABLE(Request)
+};
+
+typedef boost::container::flat_map Requests;
+//typedef boost::container::map Requests2;
+
+int
+main() {
+    Requests req;
+   
+    Requests::value_type v;
+    std::pair ret = req.insert( boost::move(v));
+    //std::cout << "Insert success for req: " << ret.second << std::endl;
+  
+    //Requests2 req2;
+    //std::pair ret2 = req2.insert( Requests2::value_type( 7, Request() ) );
+    //std::cout << "Insert success for req2: " << ret2.second << std::endl;
+
+    return 0;
+}
+*/
diff --git a/test/heap_allocator_v1.hpp b/test/heap_allocator_v1.hpp
index 10437b5..56fc1a2 100644
--- a/test/heap_allocator_v1.hpp
+++ b/test/heap_allocator_v1.hpp
@@ -38,19 +38,19 @@ namespace boost {
 namespace container {
 namespace test {
 
-//!An STL compatible heap_allocator_v1 that uses a segment manager as 
+//!An STL compatible heap_allocator_v1 that uses a segment manager as
 //!memory source. The internal pointer type will of the same type (raw, smart) as
 //!"typename SegmentManager::void_pointer" type. This allows
 //!placing the heap_allocator_v1 in shared memory, memory mapped-files, etc...*/
 template
-class heap_allocator_v1 
+class heap_allocator_v1
 {
  private:
    typedef heap_allocator_v1         self_t;
    typedef SegmentManager                          segment_manager;
    typedef typename segment_manager::void_pointer  aux_pointer_t;
 
-   typedef typename 
+   typedef typename
       boost::pointer_to_other
          ::type   cvoid_ptr;
 
@@ -80,7 +80,7 @@ class heap_allocator_v1
    //!Obtains an heap_allocator_v1 of other type
    template
    struct rebind
-   {   
+   {  
       typedef heap_allocator_v1     other;
    };
 
@@ -97,19 +97,19 @@ class heap_allocator_v1
    {  return const_pointer(addressof(value));  }
 */
    //!Constructor from the segment manager. Never throws
-   heap_allocator_v1(segment_manager *segment_mngr) 
+   heap_allocator_v1(segment_manager *segment_mngr)
       : mp_mngr(segment_mngr) { }
 
    //!Constructor from other heap_allocator_v1. Never throws
-   heap_allocator_v1(const heap_allocator_v1 &other) 
+   heap_allocator_v1(const heap_allocator_v1 &other)
       : mp_mngr(other.get_segment_manager()){ }
 
    //!Constructor from related heap_allocator_v1. Never throws
    template
-   heap_allocator_v1(const heap_allocator_v1 &other) 
+   heap_allocator_v1(const heap_allocator_v1 &other)
       : mp_mngr(other.get_segment_manager()){}
 
-   //!Allocates memory for an array of count elements. 
+   //!Allocates memory for an array of count elements.
    //!Throws boost::container::bad_alloc if there is no enough memory
    pointer allocate(size_type count, cvoid_ptr hint = 0)
    {  (void)hint; return ::new value_type[count];  }
@@ -118,7 +118,7 @@ class heap_allocator_v1
    void deallocate(const pointer &ptr, size_type)
    {  return ::delete[] detail::get_pointer(ptr) ;  }
 
-   //!Construct object, calling constructor. 
+   //!Construct object, calling constructor.
    //!Throws if T(const T&) throws
    void construct(const pointer &ptr, const_reference value)
    {  new((void*)detail::get_pointer(ptr)) value_type(value);  }
@@ -139,13 +139,13 @@ class heap_allocator_v1
 
 //!Equality test for same type of heap_allocator_v1
 template inline
-bool operator==(const heap_allocator_v1  &alloc1, 
+bool operator==(const heap_allocator_v1  &alloc1,
                 const heap_allocator_v1  &alloc2)
    {  return alloc1.get_segment_manager() == alloc2.get_segment_manager(); }
 
 //!Inequality test for same type of heap_allocator_v1
 template inline
-bool operator!=(const heap_allocator_v1  &alloc1, 
+bool operator!=(const heap_allocator_v1  &alloc1,
                 const heap_allocator_v1  &alloc2)
    {  return alloc1.get_segment_manager() != alloc2.get_segment_manager(); }
 
diff --git a/test/list_test.cpp b/test/list_test.cpp
index b3fe6b2..2abcdec 100644
--- a/test/list_test.cpp
+++ b/test/list_test.cpp
@@ -23,13 +23,13 @@ namespace boost {
 namespace container {
 
 //Explicit instantiation to detect compilation errors
-template class boost::container::list >;
 
-template class boost::container::list >;
 
-template class boost::container::list >;
 
 }}
diff --git a/test/list_test.hpp b/test/list_test.hpp
index c248231..6862ffe 100644
--- a/test/list_test.hpp
+++ b/test/list_test.hpp
@@ -258,7 +258,7 @@ int list_test (bool copied_allocators_equal = true)
             boostlist->splice(boostlist->begin(), otherboostlist);
             stdlist->splice(stdlist->begin(), otherstdlist);
             if(!CheckEqualContainers(boostlist, stdlist))
-               return 1;   
+               return 1;  
          }
 
          listsize = (int)boostlist->size();
diff --git a/test/map_test.hpp b/test/map_test.hpp
index 45efc31..66dc800 100644
--- a/test/map_test.hpp
+++ b/test/map_test.hpp
@@ -48,7 +48,7 @@ int map_test ()
       MyBoostMultiMap *boostmultimap = new MyBoostMultiMap;
       MyStdMultiMap *stdmultimap = new MyStdMultiMap;
 
-      //Test construction from a range   
+      //Test construction from a range  
       {
          //This is really nasty, but we have no other simple choice
          IntPairType aux_vect[50];
@@ -105,7 +105,7 @@ int map_test ()
          if(!CheckEqualContainers(boostmultimap2, stdmultimap2)) return 1;
 
 /*
-         MyBoostMap *boostmap3 = new MyBoostMap 
+         MyBoostMap *boostmap3 = new MyBoostMap
                ( ordered_unique_range
                , boost::make_move_iterator(&aux_vect[0])
                , boost::make_move_iterator(aux_vect + 50));
@@ -393,7 +393,7 @@ int map_test ()
 
                std::pair   sret =
                   stdmultimap->equal_range(stdmultimap->begin()->first);
-         
+        
                if( std::distance(bret.first, bret.second) !=
                    std::distance(sret.first, sret.second) ){
                   return 1;
@@ -523,7 +523,7 @@ int map_test_copyable ()
          stdmapcopy  = *stdmap;
          boostmmapcopy = *boostmultimap;
          stdmmapcopy = *stdmultimap;
-         
+        
          if(!CheckEqualContainers(&boostmapcopy, &stdmapcopy))
             return 1;
          if(!CheckEqualContainers(&boostmmapcopy, &stdmmapcopy))
diff --git a/test/movable_int.hpp b/test/movable_int.hpp
index 599dbbb..9402b16 100644
--- a/test/movable_int.hpp
+++ b/test/movable_int.hpp
@@ -77,8 +77,8 @@ class movable_int
    int m_int;
 };
 
-template 
-std::basic_ostream & operator<< 
+template
+std::basic_ostream & operator<<
    (std::basic_ostream & os, movable_int const & p)
 
 {
@@ -109,7 +109,7 @@ class movable_and_copyable_int
    movable_and_copyable_int(const movable_and_copyable_int& mmi)
       :  m_int(mmi.m_int)
    {}
-   
+  
    movable_and_copyable_int(BOOST_RV_REF(movable_and_copyable_int) mmi)
       :  m_int(mmi.m_int)
    {  mmi.m_int = 0; }
@@ -148,8 +148,8 @@ class movable_and_copyable_int
    int m_int;
 };
 
-template 
-std::basic_ostream & operator<< 
+template
+std::basic_ostream & operator<<
    (std::basic_ostream & os, movable_and_copyable_int const & p)
 
 {
@@ -177,7 +177,7 @@ class copyable_int
    copyable_int(const copyable_int& mmi)
       :  m_int(mmi.m_int)
    {}
-   
+  
    copyable_int & operator= (int i)
    {  this->m_int = i;  return *this;  }
 
@@ -206,8 +206,8 @@ class copyable_int
    int m_int;
 };
 
-template 
-std::basic_ostream & operator<< 
+template
+std::basic_ostream & operator<<
    (std::basic_ostream & os, copyable_int const & p)
 
 {
diff --git a/test/print_container.hpp b/test/print_container.hpp
index f34a9f3..a3de94e 100644
--- a/test/print_container.hpp
+++ b/test/print_container.hpp
@@ -48,8 +48,8 @@ void PrintContainers(MyBoostCont *boostcont, MyStdCont *stdcont)
    for(; itboost != itboostend; ++itboost){
       std::cout << *itboost << std::endl;
    }
-   std::cout << "MyStdCont" << std::endl; 
-  
+   std::cout << "MyStdCont" << std::endl;
+ 
    for(; itstd != itstdend; ++itstd){
       std::cout << *itstd << std::endl;
    }
diff --git a/test/scoped_allocator_adaptor_test.cpp b/test/scoped_allocator_adaptor_test.cpp
index cecfade..6afca6e 100644
--- a/test/scoped_allocator_adaptor_test.cpp
+++ b/test/scoped_allocator_adaptor_test.cpp
@@ -644,7 +644,7 @@ int main()
    }
 
    {
-      vector > > dummy;  
+      vector > > dummy; 
       dummy.push_back(0);
    }
 
@@ -682,15 +682,15 @@ int main()
 
       BOOST_STATIC_ASSERT(( !boost::container::uses_allocator
                               < ::mark_on_scoped_allocation
-                              , test_allocator 
+                              , test_allocator
                               >::value ));
       BOOST_STATIC_ASSERT((  boost::container::uses_allocator
                               < ::mark_on_scoped_allocation
-                              , test_allocator 
+                              , test_allocator
                               >::value ));
       BOOST_STATIC_ASSERT((  boost::container::uses_allocator
                               < ::mark_on_scoped_allocation
-                              , test_allocator 
+                              , test_allocator
                               >::value ));
       BOOST_STATIC_ASSERT(( boost::container::constructible_with_allocator_prefix
                           < ::mark_on_scoped_allocation >::value ));
diff --git a/test/scoped_allocator_usage_test.cpp b/test/scoped_allocator_usage_test.cpp
index 1fbd2ce..bb841a2 100644
--- a/test/scoped_allocator_usage_test.cpp
+++ b/test/scoped_allocator_usage_test.cpp
@@ -240,7 +240,7 @@ struct container_wrapper
    : public Container
 {
    typedef typename Container::allocator_type   allocator_type;
-   
+  
    container_wrapper(const allocator_type &a)
       : Container(a)
    {}
diff --git a/test/set_test.hpp b/test/set_test.hpp
index 95dfee0..2afe4ce 100644
--- a/test/set_test.hpp
+++ b/test/set_test.hpp
@@ -40,7 +40,7 @@ int set_test ()
    MyBoostMultiSet *boostmultiset = new MyBoostMultiSet;
    MyStdMultiSet *stdmultiset = new MyStdMultiSet;
 
-   //Test construction from a range   
+   //Test construction from a range  
    {
       IntType aux_vect[50];
       for(int i = 0; i < 50; ++i){
@@ -483,7 +483,7 @@ int set_test_copyable ()
 
          boostmsetcopy = *boostmultiset;
          stdmsetcopy = *stdmultiset;
-         
+        
          if(!CheckEqualContainers(&boostmsetcopy, &stdmsetcopy))
             return 1;
       }
diff --git a/test/slist_test.cpp b/test/slist_test.cpp
index d1c80e3..46d6851 100644
--- a/test/slist_test.cpp
+++ b/test/slist_test.cpp
@@ -22,13 +22,13 @@ namespace boost {
 namespace container {
 
 //Explicit instantiation to detect compilation errors
-template class boost::container::slist >;
 
-template class boost::container::slist >;
 
-template class boost::container::slist >;
 }}
 
diff --git a/test/stable_vector_test.cpp b/test/stable_vector_test.cpp
index fe7d9e1..c69efe4 100644
--- a/test/stable_vector_test.cpp
+++ b/test/stable_vector_test.cpp
@@ -30,13 +30,13 @@ namespace boost {
 namespace container {
 
 //Explicit instantiation to detect compilation errors
-template class stable_vector >;
 
-template class stable_vector >;
 
-template class stable_vector >;
 
 }}
diff --git a/test/string_test.cpp b/test/string_test.cpp
index c51e80b..ce0e9c6 100644
--- a/test/string_test.cpp
+++ b/test/string_test.cpp
@@ -26,10 +26,10 @@
 
 using namespace boost::container;
 
-typedef test::dummy_test_allocator           DummyCharAllocator; 
+typedef test::dummy_test_allocator           DummyCharAllocator;
 typedef basic_string, DummyCharAllocator> DummyString;
 typedef test::dummy_test_allocator    DummyStringAllocator;
-typedef test::dummy_test_allocator              DummyWCharAllocator; 
+typedef test::dummy_test_allocator              DummyWCharAllocator;
 typedef basic_string, DummyWCharAllocator> DummyWString;
 typedef test::dummy_test_allocator         DummyWStringAllocator;
 
@@ -67,7 +67,7 @@ template
 bool CheckEqualStringVector(StrVector1 *strvect1, StrVector2 *strvect2)
 {
    StringEqual comp;
-   return std::equal(strvect1->begin(), strvect1->end(), 
+   return std::equal(strvect1->begin(), strvect1->end(),
                      strvect2->begin(), comp);
 }
 
@@ -159,7 +159,7 @@ int string_test()
          return 1;
       }
 
-      //Now push back moving 
+      //Now push back moving
       for(int i = 0; i < MaxSize; ++i){
          auxBoostString = string_literals::String();
          auxStdString = string_literals::String();
@@ -189,7 +189,7 @@ int string_test()
          return 1;
       }
 
-      //Now push front moving 
+      //Now push front moving
       for(int i = 0; i < MaxSize; ++i){
          auxBoostString = string_literals::String();
          auxStdString = string_literals::String();
@@ -214,15 +214,15 @@ int string_test()
       boost_swapper.swap(auxBoostString);
       std_swapper.swap(auxStdString);
       if(!StringEqual()(auxBoostString, auxStdString))
-         return 1;   
+         return 1;  
       if(!StringEqual()(boost_swapper, std_swapper))
-         return 1;   
+         return 1;  
       boost_swapper.swap(auxBoostString);
       std_swapper.swap(auxStdString);
       if(!StringEqual()(auxBoostString, auxStdString))
-         return 1;   
+         return 1;  
       if(!StringEqual()(boost_swapper, std_swapper))
-         return 1;   
+         return 1;  
 
       //Shrink_to_fit
       auxBoostString.shrink_to_fit();
@@ -249,7 +249,7 @@ int string_test()
       boost_swapper.swap(auxBoostString);
       std_swapper.swap(auxStdString);
       if(!StringEqual()(auxBoostString, auxStdString))
-         return 1;   
+         return 1;  
       if(!StringEqual()(boost_swapper, std_swapper))
          return 1;
       boost_swapper.swap(auxBoostString);
@@ -280,9 +280,9 @@ int string_test()
       for(int i = 0; i < MaxSize; ++i){
          (*boostStringVect)[i].append(sufix);
          (*stdStringVect)[i].append(sufix);
-         (*boostStringVect)[i].insert((*boostStringVect)[i].begin(), 
+         (*boostStringVect)[i].insert((*boostStringVect)[i].begin(),
                                     prefix, prefix + prefix_size);
-         (*stdStringVect)[i].insert((*stdStringVect)[i].begin(), 
+         (*stdStringVect)[i].insert((*stdStringVect)[i].begin(),
                                     prefix, prefix + prefix_size);
       }
 
@@ -310,10 +310,10 @@ int string_test()
       if(!CheckEqualStringVector(boostStringVect, stdStringVect)) return 1;
 
       for(int i = 0; i < MaxSize; ++i){
-         (*boostStringVect)[i].replace((*boostStringVect)[i].begin(), 
+         (*boostStringVect)[i].replace((*boostStringVect)[i].begin(),
                                     (*boostStringVect)[i].end(),
                                     string_literals::String());
-         (*stdStringVect)[i].replace((*stdStringVect)[i].begin(), 
+         (*stdStringVect)[i].replace((*stdStringVect)[i].begin(),
                                     (*stdStringVect)[i].end(),
                                     string_literals::String());
       }
@@ -330,7 +330,7 @@ int string_test()
       {
          typedef std::basic_string StdString;
          typedef basic_string BoostString;
-         
+        
          BoostString bs2 = string_literals::String();
          StdString   ss2 = string_literals::String();
          BoostString bs3 = string_literals::Suffix();
diff --git a/test/vector_test.cpp b/test/vector_test.cpp
index d7fc47c..afc03b8 100644
--- a/test/vector_test.cpp
+++ b/test/vector_test.cpp
@@ -30,13 +30,13 @@ namespace boost {
 namespace container {
 
 //Explicit instantiation to detect compilation errors
-template class boost::container::vector >;
 
-template class boost::container::vector >;
 
-template class boost::container::vector >;
 
 }}
diff --git a/test/vector_test.hpp b/test/vector_test.hpp
index 847e9e8..a46d42b 100644
--- a/test/vector_test.hpp
+++ b/test/vector_test.hpp
@@ -90,15 +90,15 @@ int vector_test()
          MyStdVector *stdvector = new MyStdVector;
          boostvector->resize(100);
          stdvector->resize(100);
-         if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;         
+         if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;        
 
          boostvector->resize(200);
          stdvector->resize(200);
-         if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;         
+         if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;        
 
          boostvector->resize(0);
          stdvector->resize(0);
-         if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;         
+         if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;        
 
          for(int i = 0; i < max; ++i){
             IntType new_int(i);

From 4f013bfcce9b2659c910a5212d9bd509fb403320 Mon Sep 17 00:00:00 2001
From: John Maddock 
Date: Thu, 7 Jun 2012 12:32:56 +0000
Subject: [PATCH 29/93] Changes required to build PDF versions of docs.

[SVN r78845]
---
 doc/Jamfile.v2 | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2
index 05bf622..9b11f38 100644
--- a/doc/Jamfile.v2
+++ b/doc/Jamfile.v2
@@ -13,6 +13,7 @@ import quickbook ;
 using auto-index ;
 
 path-constant images_location : html ;
+path-constant here : . ;
 
 doxygen autodoc
    :
@@ -70,7 +71,7 @@ boostbook standalone
         html:on
        
         # Set the name of the script file to use (index.idx is popular):
-        index.idx
+        $(here)/index.idx
         # Commands in the script file should all use RELATIVE PATHS
         # otherwise the script will not be portable to other machines.
         # Relative paths are normally taken as relative to the location
@@ -79,6 +80,14 @@ boostbook standalone
         # The path specified by  may be either relative or
         # absolute, for example the following will get us up to the boost root
         # directory for most Boost libraries:
-        "../../.."
+        "$(here)/../../.."
 
+        pdf:admon.graphics.extension=".svg"
    ;
+
+install pdf-install : standalone : PDF . container.pdf ;
+
+
+
+
+

From 2c5c074091990d69259c32ac1f1e2af76d1c0ff6 Mon Sep 17 00:00:00 2001
From: Daniel James 
Date: Mon, 11 Jun 2012 01:33:10 +0000
Subject: [PATCH 30/93] Make the new pdf install rules explicit, and fix
 intrusive's.

[SVN r78877]
---
 doc/Jamfile.v2 | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2
index 9b11f38..4647f89 100644
--- a/doc/Jamfile.v2
+++ b/doc/Jamfile.v2
@@ -86,8 +86,4 @@ boostbook standalone
    ;
 
 install pdf-install : standalone : PDF . container.pdf ;
-
-
-
-
-
+explicit pdf-install ;

From 390dce6172ea3c84c4b7becf9283a83d1bdb6439 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=BCrgen=20Hunold?= 
Date: Sat, 16 Jun 2012 12:05:44 +0000
Subject: [PATCH 31/93] Fix regressions introduced in r78802.

Reference #6940. Rename TIME_UTC to TIME_UTC_

[SVN r78972]
---
 test/util.hpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/util.hpp b/test/util.hpp
index 9bfe1af..639c17b 100644
--- a/test/util.hpp
+++ b/test/util.hpp
@@ -71,7 +71,7 @@ inline bool in_range(const boost::posix_time::ptime& xt, int secs=1)
 boost::xtime xsecs(int secs)
 {
    boost::xtime ret;
-   boost::xtime_get(&ret, boost::TIME_UTC);
+   boost::xtime_get(&ret, boost::TIME_UTC_);
    ret.sec += secs;
    return ret;
 }

From a9eb3dad276cb3cced1c6eeb0c8b11a257682eb0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Wed, 11 Jul 2012 17:34:44 +0000
Subject: [PATCH 32/93] Ticket #7114:Destructor not called when using emplace()

[SVN r79422]
---
 include/boost/container/detail/destroyers.hpp | 59 +++++++++++++++++++
 include/boost/container/detail/flat_tree.hpp  | 24 +++-----
 include/boost/container/detail/tree.hpp       |  4 +-
 3 files changed, 70 insertions(+), 17 deletions(-)

diff --git a/include/boost/container/detail/destroyers.hpp b/include/boost/container/detail/destroyers.hpp
index 3a42be3..d1b118c 100644
--- a/include/boost/container/detail/destroyers.hpp
+++ b/include/boost/container/detail/destroyers.hpp
@@ -65,6 +65,44 @@ struct null_scoped_array_deallocator
    {}
 };
 
+template 
+struct scoped_destroy_deallocator
+{
+   typedef boost::container::allocator_traits AllocTraits;
+   typedef typename AllocTraits::pointer    pointer;
+   typedef typename AllocTraits::size_type  size_type;
+   typedef container_detail::integral_constant::value>                          alloc_version;
+   typedef container_detail::integral_constant  allocator_v1;
+   typedef container_detail::integral_constant  allocator_v2;
+
+   scoped_destroy_deallocator(pointer p, Allocator& a)
+      : m_ptr(p), m_alloc(a) {}
+
+   ~scoped_destroy_deallocator()
+   {
+      if(m_ptr){
+         AllocTraits::destroy(m_alloc, container_detail::to_raw_pointer(m_ptr));
+         priv_deallocate(m_ptr, alloc_version());
+      }
+   }
+
+   void release()
+   {  m_ptr = 0; }
+
+   private:
+
+   void priv_deallocate(const pointer &p, allocator_v1)
+   {  AllocTraits::deallocate(m_alloc, p, 1); }
+
+   void priv_deallocate(const pointer &p, allocator_v2)
+   {  m_alloc.deallocate_one(p); }
+
+   pointer     m_ptr;
+   Allocator&  m_alloc;
+};
+
 
 //!A deleter for scoped_ptr that destroys
 //!an object using a STL allocator.
@@ -150,6 +188,27 @@ class scoped_destructor
    A &a_;
 };
 
+
+template
+class value_destructor
+{
+   typedef boost::container::allocator_traits AllocTraits;
+   public:
+   typedef typename A::value_type value_type;
+   value_destructor(A &a, value_type &rv)
+      : rv_(rv), a_(a)
+   {}
+
+   ~value_destructor()
+   {
+      AllocTraits::destroy(a_, &rv_);
+   }
+
+   private:
+   value_type &rv_;
+   A &a_;
+};
+
 template 
 class allocator_destroyer
 {
diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp
index 739c844..23be0bf 100644
--- a/include/boost/container/detail/flat_tree.hpp
+++ b/include/boost/container/detail/flat_tree.hpp
@@ -395,14 +395,13 @@ class flat_tree
       value_type &val = *static_cast(static_cast(&v));
       stored_allocator_type &a = this->get_stored_allocator();
       stored_allocator_traits::construct(a, &val, ::boost::forward(args)... );
-      scoped_destructor d(a, &val);
+      value_destructor d(a, val);
       insert_commit_data data;
       std::pair ret =
          priv_insert_unique_prepare(val, data);
       if(ret.second){
          ret.first = priv_insert_commit(data, boost::move(val));
       }
-      d.release();
       return ret;
    }
 
@@ -413,13 +412,12 @@ class flat_tree
       value_type &val = *static_cast(static_cast(&v));
       stored_allocator_type &a = this->get_stored_allocator();
       stored_allocator_traits::construct(a, &val, ::boost::forward(args)... );
-      scoped_destructor d(a, &val);
+      value_destructor d(a, val);
       insert_commit_data data;
       std::pair ret = priv_insert_unique_prepare(hint, val, data);
       if(ret.second){
          ret.first = priv_insert_commit(data, boost::move(val));
       }
-      d.release();
       return ret.first;
    }
 
@@ -430,10 +428,9 @@ class flat_tree
       value_type &val = *static_cast(static_cast(&v));
       stored_allocator_type &a = this->get_stored_allocator();
       stored_allocator_traits::construct(a, &val, ::boost::forward(args)... );
-      scoped_destructor d(a, &val);
+      value_destructor d(a, val);
       iterator i = this->upper_bound(KeyOfValue()(val));
       i = this->m_data.m_vect.insert(i, boost::move(val));
-      d.release();
       return i;
    }
 
@@ -444,11 +441,10 @@ class flat_tree
       value_type &val = *static_cast(static_cast(&v));
       stored_allocator_type &a = this->get_stored_allocator();
       stored_allocator_traits::construct(a, &val, ::boost::forward(args)... );
-      scoped_destructor d(a, &val);
+      value_destructor d(a, val);
       insert_commit_data data;
       this->priv_insert_equal_prepare(hint, val, data);
       iterator i = priv_insert_commit(data, boost::move(val));
-      d.release();
       return i;
    }
 
@@ -464,13 +460,12 @@ class flat_tree
       stored_allocator_type &a = this->get_stored_allocator();                            \
       stored_allocator_traits::construct(a, &val                                          \
          BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) );                \
-      scoped_destructor d(a, &val);                                \
+      value_destructor d(a, val);                                  \
       insert_commit_data data;                                                            \
       std::pair ret = priv_insert_unique_prepare(val, data);               \
       if(ret.second){                                                                     \
          ret.first = priv_insert_commit(data, boost::move(val));                          \
       }                                                                                   \
-      d.release();                                                                        \
       return ret;                                                                         \
    }                                                                                      \
                                                                                           \
@@ -483,13 +478,12 @@ class flat_tree
       stored_allocator_type &a = this->get_stored_allocator();                            \
       stored_allocator_traits::construct(a, &val                                          \
          BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) );                \
-      scoped_destructor d(a, &val);                                \
+      value_destructor d(a,  val);                                 \
       insert_commit_data data;                                                            \
       std::pair ret = priv_insert_unique_prepare(hint, val, data);         \
       if(ret.second){                                                                     \
          ret.first = priv_insert_commit(data, boost::move(val));                          \
       }                                                                                   \
-      d.release();                                                                        \
       return ret.first;                                                                   \
    }                                                                                      \
                                                                                           \
@@ -501,10 +495,9 @@ class flat_tree
       stored_allocator_type &a = this->get_stored_allocator();                            \
       stored_allocator_traits::construct(a, &val                                          \
          BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) );                \
-      scoped_destructor d(a, &val);                                \
+      value_destructor d(a,  val);                                 \
       iterator i = this->upper_bound(KeyOfValue()(val));                                  \
       i = this->m_data.m_vect.insert(i, boost::move(val));                                \
-      d.release();                                                                        \
       return i;                                                                           \
    }                                                                                      \
                                                                                           \
@@ -517,11 +510,10 @@ class flat_tree
       stored_allocator_type &a = this->get_stored_allocator();                            \
       stored_allocator_traits::construct(a, &val                                          \
          BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) );                \
-      scoped_destructor d(a, &val);                                \
+      value_destructor d(a,  val);                                 \
       insert_commit_data data;                                                            \
       this->priv_insert_equal_prepare(hint, val, data);                                   \
       iterator i = priv_insert_commit(data, boost::move(val));                            \
-      d.release();                                                                        \
       return i;                                                                           \
    }                                                                                      \
 
diff --git a/include/boost/container/detail/tree.hpp b/include/boost/container/detail/tree.hpp
index 50212ce..3ab1536 100644
--- a/include/boost/container/detail/tree.hpp
+++ b/include/boost/container/detail/tree.hpp
@@ -745,12 +745,14 @@ class rbtree
    {
       value_type &v = p->get_data();
       insert_commit_data data;
+      scoped_destroy_deallocator destroy_deallocator(p, this->node_alloc());
       std::pair ret =
          this->insert_unique_check(KeyOfValue()(v), data);
       if(!ret.second){
-         Destroyer(this->node_alloc())(p);
          return ret;
       }
+      //No throw insertion part, release rollback
+      destroy_deallocator.release();
       return std::pair
          ( iterator(iiterator(this->icont().insert_unique_commit(*p, data)))
          , true );

From d3fb53368d667920c102e15ac324882ffa470301 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Wed, 11 Jul 2012 17:51:50 +0000
Subject: [PATCH 33/93] Ticket #7103: boost/container/string.hpp missing
 #include 

[SVN r79423]
---
 include/boost/container/string.hpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp
index dc2fdd9..2a64cec 100644
--- a/include/boost/container/string.hpp
+++ b/include/boost/container/string.hpp
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 

From 00d07000887432921e5e44ff3f43d67a89eb6307 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Wed, 11 Jul 2012 22:09:37 +0000
Subject: [PATCH 34/93] Updated changeset

[SVN r79430]
---
 doc/container.qbk       |  8 ++++++
 proj/to-do.txt          |  6 ++++-
 test/flat_tree_test.cpp | 56 ++---------------------------------------
 3 files changed, 15 insertions(+), 55 deletions(-)

diff --git a/doc/container.qbk b/doc/container.qbk
index ee4cf42..dd1bc7d 100644
--- a/doc/container.qbk
+++ b/doc/container.qbk
@@ -614,6 +614,14 @@ use [*Boost.Container]? There are several reasons for that:
 
 [section:release_notes Release Notes]
 
+[section:release_notes_boost_1_51_00 Boost 1.51 Release]
+
+*  Fixed bugs
+  [@https://svn.boost.org/trac/boost/ticket/7114 #7114],
+  [@https://svn.boost.org/trac/boost/ticket/7103 #7103].
+
+[endsect]
+
 [section:release_notes_boost_1_50_00 Boost 1.50 Release]
 
 *  Added Scoped Allocator Model support.
diff --git a/proj/to-do.txt b/proj/to-do.txt
index 1152393..072519c 100644
--- a/proj/to-do.txt
+++ b/proj/to-do.txt
@@ -36,4 +36,8 @@ check move if noexcept conditions in vector, deque and stable_vector
 
 Detect always equal or unequal allocators at compiler time. operator== returns true_type or false_type
 
-change virtual functions with pointers to avoid template instantiation for every type
\ No newline at end of file
+change virtual functions with pointers to avoid template instantiation for every type
+
+Add hash for containers
+
+Add std:: hashing support
\ No newline at end of file
diff --git a/test/flat_tree_test.cpp b/test/flat_tree_test.cpp
index ba3d450..c6738e2 100644
--- a/test/flat_tree_test.cpp
+++ b/test/flat_tree_test.cpp
@@ -26,7 +26,7 @@ using namespace boost::container;
 
 namespace boost {
 namespace container {
-/*
+
 //Explicit instantiation to detect compilation errors
 
 //flat_map
@@ -115,7 +115,7 @@ template class flat_multiset
    , std::less
    , std::allocator
    >;
-*/
+
 }} //boost::container
 
 
@@ -627,55 +627,3 @@ int main()
 }
 
 #include 
-
-/*
-#include 
-#include 
-#include 
-#include 
-#include 
-
-struct Request
-{
-    Request() {};
-  
-    //Move semantics...
-    Request(BOOST_RV_REF(Request) r) : rvals()  //Move constructor
-    {
-        rvals.swap(r.rvals);
-    };
-
-    Request& operator=(BOOST_RV_REF(Request) r) //Move assignment
-    {
-        if (this != &r){
-            rvals.swap(r.rvals);
-        }
-        return *this;
-    };
-
-    // Values I want to be moved, not copied.
-    boost::container::vector rvals;
-
-   private:
-    // Mark this class movable but not copyable
-    BOOST_MOVABLE_BUT_NOT_COPYABLE(Request)
-};
-
-typedef boost::container::flat_map Requests;
-//typedef boost::container::map Requests2;
-
-int
-main() {
-    Requests req;
-   
-    Requests::value_type v;
-    std::pair ret = req.insert( boost::move(v));
-    //std::cout << "Insert success for req: " << ret.second << std::endl;
-  
-    //Requests2 req2;
-    //std::pair ret2 = req2.insert( Requests2::value_type( 7, Request() ) );
-    //std::cout << "Insert success for req2: " << ret2.second << std::endl;
-
-    return 0;
-}
-*/

From 586c35bf1d43dbf526ec0972df80992eee8d58f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Thu, 12 Jul 2012 12:33:54 +0000
Subject: [PATCH 35/93] Used force<> to cast references, force_copy<> to cast
 values.

[SVN r79446]
---
 include/boost/container/flat_map.hpp | 138 ++++++++++++++++-----------
 1 file changed, 81 insertions(+), 57 deletions(-)

diff --git a/include/boost/container/flat_map.hpp b/include/boost/container/flat_map.hpp
index 18a3c5e..0142500 100644
--- a/include/boost/container/flat_map.hpp
+++ b/include/boost/container/flat_map.hpp
@@ -264,21 +264,21 @@ class flat_map
    //!
    //! Complexity: Constant.
    key_compare key_comp() const
-      { return container_detail::force(m_flat_tree.key_comp()); }
+      { return container_detail::force_copy(m_flat_tree.key_comp()); }
 
    //! Effects: Returns an object of value_compare constructed out
    //!   of the comparison object.
    //!
    //! Complexity: Constant.
    value_compare value_comp() const
-      { return value_compare(container_detail::force(m_flat_tree.key_comp())); }
+      { return value_compare(container_detail::force_copy(m_flat_tree.key_comp())); }
 
    //! Effects: Returns a copy of the Allocator that
    //!   was passed to the object's constructor.
    //!
    //! Complexity: Constant.
    allocator_type get_allocator() const
-      { return container_detail::force(m_flat_tree.get_allocator()); }
+      { return container_detail::force_copy(m_flat_tree.get_allocator()); }
 
    const stored_allocator_type &get_stored_allocator() const
       { return container_detail::force(m_flat_tree.get_stored_allocator()); }
@@ -300,7 +300,7 @@ class flat_map
    //!
    //! Complexity: Constant.
    const_iterator begin() const
-      { return container_detail::force(m_flat_tree.begin()); }
+      { return container_detail::force_copy(m_flat_tree.begin()); }
 
    //! Effects: Returns an iterator to the end of the container.
    //!
@@ -316,7 +316,7 @@ class flat_map
    //!
    //! Complexity: Constant.
    const_iterator end() const
-      { return container_detail::force(m_flat_tree.end()); }
+      { return container_detail::force_copy(m_flat_tree.end()); }
 
    //! Effects: Returns a reverse_iterator pointing to the beginning
    //! of the reversed container.
@@ -325,7 +325,7 @@ class flat_map
    //!
    //! Complexity: Constant.
    reverse_iterator rbegin()
-      { return container_detail::force(m_flat_tree.rbegin()); }
+      { return container_detail::force_copy(m_flat_tree.rbegin()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
    //! of the reversed container.
@@ -334,7 +334,7 @@ class flat_map
    //!
    //! Complexity: Constant.
    const_reverse_iterator rbegin() const
-      { return container_detail::force(m_flat_tree.rbegin()); }
+      { return container_detail::force_copy(m_flat_tree.rbegin()); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
    //! of the reversed container.
@@ -343,7 +343,7 @@ class flat_map
    //!
    //! Complexity: Constant.
    reverse_iterator rend()
-      { return container_detail::force(m_flat_tree.rend()); }
+      { return container_detail::force_copy(m_flat_tree.rend()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
    //! of the reversed container.
@@ -352,7 +352,7 @@ class flat_map
    //!
    //! Complexity: Constant.
    const_reverse_iterator rend() const
-      { return container_detail::force(m_flat_tree.rend()); }
+      { return container_detail::force_copy(m_flat_tree.rend()); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
    //!
@@ -360,7 +360,7 @@ class flat_map
    //!
    //! Complexity: Constant.
    const_iterator cbegin() const
-      { return container_detail::force(m_flat_tree.cbegin()); }
+      { return container_detail::force_copy(m_flat_tree.cbegin()); }
 
    //! Effects: Returns a const_iterator to the end of the container.
    //!
@@ -368,7 +368,7 @@ class flat_map
    //!
    //! Complexity: Constant.
    const_iterator cend() const
-      { return container_detail::force(m_flat_tree.cend()); }
+      { return container_detail::force_copy(m_flat_tree.cend()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
    //! of the reversed container.
@@ -377,7 +377,7 @@ class flat_map
    //!
    //! Complexity: Constant.
    const_reverse_iterator crbegin() const
-      { return container_detail::force(m_flat_tree.crbegin()); }
+      { return container_detail::force_copy(m_flat_tree.crbegin()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
    //! of the reversed container.
@@ -386,7 +386,7 @@ class flat_map
    //!
    //! Complexity: Constant.
    const_reverse_iterator crend() const
-      { return container_detail::force(m_flat_tree.crend()); }
+      { return container_detail::force_copy(m_flat_tree.crend()); }
 
    //! Effects: Returns true if the container contains no elements.
    //!
@@ -477,7 +477,7 @@ class flat_map
    //!
    //! Note: If an element is inserted it might invalidate elements.
    std::pair insert(const value_type& x)
-      { return container_detail::force >(
+      { return container_detail::force_copy >(
          m_flat_tree.insert_unique(container_detail::force(x))); }
 
    //! Effects: Inserts a new value_type move constructed from the pair if and
@@ -492,7 +492,7 @@ class flat_map
    //!
    //! Note: If an element is inserted it might invalidate elements.
    std::pair insert(BOOST_RV_REF(value_type) x)
-   {  return container_detail::force >(
+   {  return container_detail::force_copy >(
       m_flat_tree.insert_unique(boost::move(container_detail::force(x)))); }
 
    //! Effects: Inserts a new value_type move constructed from the pair if and
@@ -508,7 +508,7 @@ class flat_map
    //! Note: If an element is inserted it might invalidate elements.
    std::pair insert(BOOST_RV_REF(movable_value_type) x)
    {
-      return container_detail::force >
+      return container_detail::force_copy >
       (m_flat_tree.insert_unique(boost::move(x)));
    }
 
@@ -524,8 +524,11 @@ class flat_map
    //!
    //! Note: If an element is inserted it might invalidate elements.
    iterator insert(const_iterator position, const value_type& x)
-      { return container_detail::force_copy(
-         m_flat_tree.insert_unique(container_detail::force(position), container_detail::force(x))); }
+   {
+      return container_detail::force_copy(
+         m_flat_tree.insert_unique( container_detail::force_copy(position)
+                                  , container_detail::force(x)));
+   }
 
    //! Effects: Inserts an element move constructed from x in the container.
    //!   p is a hint pointing to where the insert should start to search.
@@ -539,7 +542,7 @@ class flat_map
    iterator insert(const_iterator position, BOOST_RV_REF(value_type) x)
    {
       return container_detail::force_copy
-         (m_flat_tree.insert_unique( container_detail::force(position)
+         (m_flat_tree.insert_unique( container_detail::force_copy(position)
                                    , boost::move(container_detail::force(x))));
    }
 
@@ -555,7 +558,7 @@ class flat_map
    iterator insert(const_iterator position, BOOST_RV_REF(movable_value_type) x)
    {
       return container_detail::force_copy(
-         m_flat_tree.insert_unique(container_detail::force(position), boost::move(x)));
+         m_flat_tree.insert_unique(container_detail::force_copy(position), boost::move(x)));
    }
 
    //! Requires: first, last are not iterators into *this.
@@ -620,8 +623,11 @@ class flat_map
    //! Note: If an element is inserted it might invalidate elements.
    template 
    iterator emplace_hint(const_iterator hint, Args&&... args)
-   {  return container_detail::force_copy
-      (m_flat_tree.emplace_hint_unique(container_detail::force(hint), boost::forward(args)...)); }
+   {
+      return container_detail::force_copy
+         (m_flat_tree.emplace_hint_unique( container_detail::force_copy(hint)
+                                         , boost::forward(args)...));
+   }
 
    #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
@@ -635,7 +641,7 @@ class flat_map
    iterator emplace_hint(const_iterator hint                                                       \
                          BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _))              \
    {  return container_detail::force_copy(m_flat_tree.emplace_hint_unique                \
-            (container_detail::force(hint)                                    \
+            (container_detail::force_copy(hint)                               \
                BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); }                 \
    //!
    #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
@@ -654,7 +660,10 @@ class flat_map
    //! Note: Invalidates elements with keys
    //!   not less than the erased element.
    iterator erase(const_iterator position)
-      { return container_detail::force_copy(m_flat_tree.erase(container_detail::force(position))); }
+   {
+      return container_detail::force_copy
+         (m_flat_tree.erase(container_detail::force_copy(position)));
+   }
 
    //! Effects: Erases all elements in the container with key equivalent to x.
    //!
@@ -674,8 +683,11 @@ class flat_map
    //! Complexity: Logarithmic search time plus erasure time
    //!   linear to the elements with bigger keys.
    iterator erase(const_iterator first, const_iterator last)
-      { return container_detail::force_copy
-         (m_flat_tree.erase(container_detail::force(first), container_detail::force(last))); }
+   {
+      return container_detail::force_copy(
+         m_flat_tree.erase( container_detail::force_copy(first)
+                          , container_detail::force_copy(last)));
+   }
 
    //! Effects: erase(a.begin(),a.end()).
    //!
@@ -706,7 +718,7 @@ class flat_map
    //!
    //! Complexity: Logarithmic.s
    const_iterator find(const key_type& x) const
-      { return container_detail::force(m_flat_tree.find(x)); }
+      { return container_detail::force_copy(m_flat_tree.find(x)); }
 
    //! Returns: The number of elements with key equivalent to x.
    //!
@@ -726,7 +738,7 @@ class flat_map
    //!
    //! Complexity: Logarithmic
    const_iterator lower_bound(const key_type& x) const
-      {  return container_detail::force(m_flat_tree.lower_bound(x)); }
+      {  return container_detail::force_copy(m_flat_tree.lower_bound(x)); }
 
    //! Returns: An iterator pointing to the first element with key not less
    //!   than x, or end() if such an element is not found.
@@ -740,7 +752,7 @@ class flat_map
    //!
    //! Complexity: Logarithmic
    const_iterator upper_bound(const key_type& x) const
-      {  return container_detail::force(m_flat_tree.upper_bound(x)); }
+      {  return container_detail::force_copy(m_flat_tree.upper_bound(x)); }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
@@ -1050,21 +1062,21 @@ class flat_multimap
    //!
    //! Complexity: Constant.
    key_compare key_comp() const
-      { return container_detail::force(m_flat_tree.key_comp()); }
+      { return container_detail::force_copy(m_flat_tree.key_comp()); }
 
    //! Effects: Returns an object of value_compare constructed out
    //!   of the comparison object.
    //!
    //! Complexity: Constant.
    value_compare value_comp() const
-      { return value_compare(container_detail::force(m_flat_tree.key_comp())); }
+      { return value_compare(container_detail::force_copy(m_flat_tree.key_comp())); }
 
    //! Effects: Returns a copy of the Allocator that
    //!   was passed to the object's constructor.
    //!
    //! Complexity: Constant.
    allocator_type get_allocator() const
-      { return container_detail::force(m_flat_tree.get_allocator()); }
+      { return container_detail::force_copy(m_flat_tree.get_allocator()); }
 
    const stored_allocator_type &get_stored_allocator() const
       { return container_detail::force(m_flat_tree.get_stored_allocator()); }
@@ -1086,7 +1098,7 @@ class flat_multimap
    //!
    //! Complexity: Constant.
    const_iterator begin() const
-      { return container_detail::force(m_flat_tree.begin()); }
+      { return container_detail::force_copy(m_flat_tree.begin()); }
 
    //! Effects: Returns an iterator to the end of the container.
    //!
@@ -1102,7 +1114,7 @@ class flat_multimap
    //!
    //! Complexity: Constant.
    const_iterator end() const
-      { return container_detail::force(m_flat_tree.end()); }
+      { return container_detail::force_copy(m_flat_tree.end()); }
 
    //! Effects: Returns a reverse_iterator pointing to the beginning
    //! of the reversed container.
@@ -1111,7 +1123,7 @@ class flat_multimap
    //!
    //! Complexity: Constant.
    reverse_iterator rbegin()
-      { return container_detail::force(m_flat_tree.rbegin()); }
+      { return container_detail::force_copy(m_flat_tree.rbegin()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
    //! of the reversed container.
@@ -1120,7 +1132,7 @@ class flat_multimap
    //!
    //! Complexity: Constant.
    const_reverse_iterator rbegin() const
-      { return container_detail::force(m_flat_tree.rbegin()); }
+      { return container_detail::force_copy(m_flat_tree.rbegin()); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
    //! of the reversed container.
@@ -1129,7 +1141,7 @@ class flat_multimap
    //!
    //! Complexity: Constant.
    reverse_iterator rend()
-      { return container_detail::force(m_flat_tree.rend()); }
+      { return container_detail::force_copy(m_flat_tree.rend()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
    //! of the reversed container.
@@ -1138,7 +1150,7 @@ class flat_multimap
    //!
    //! Complexity: Constant.
    const_reverse_iterator rend() const
-      { return container_detail::force(m_flat_tree.rend()); }
+      { return container_detail::force_copy(m_flat_tree.rend()); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
    //!
@@ -1146,7 +1158,7 @@ class flat_multimap
    //!
    //! Complexity: Constant.
    const_iterator cbegin() const
-      { return container_detail::force(m_flat_tree.cbegin()); }
+      { return container_detail::force_copy(m_flat_tree.cbegin()); }
 
    //! Effects: Returns a const_iterator to the end of the container.
    //!
@@ -1154,7 +1166,7 @@ class flat_multimap
    //!
    //! Complexity: Constant.
    const_iterator cend() const
-      { return container_detail::force(m_flat_tree.cend()); }
+      { return container_detail::force_copy(m_flat_tree.cend()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
    //! of the reversed container.
@@ -1163,7 +1175,7 @@ class flat_multimap
    //!
    //! Complexity: Constant.
    const_reverse_iterator crbegin() const
-      { return container_detail::force(m_flat_tree.crbegin()); }
+      { return container_detail::force_copy(m_flat_tree.crbegin()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
    //! of the reversed container.
@@ -1172,7 +1184,7 @@ class flat_multimap
    //!
    //! Complexity: Constant.
    const_reverse_iterator crend() const
-      { return container_detail::force(m_flat_tree.crend()); }
+      { return container_detail::force_copy(m_flat_tree.crend()); }
 
    //! Effects: Returns true if the container contains no elements.
    //!
@@ -1214,7 +1226,10 @@ class flat_multimap
    //!
    //! Note: If an element is inserted it might invalidate elements.
    iterator insert(const value_type& x)
-      { return container_detail::force_copy(m_flat_tree.insert_equal(container_detail::force(x))); }
+   {
+      return container_detail::force_copy(
+         m_flat_tree.insert_equal(container_detail::force(x)));
+   }
 
    //! Effects: Inserts a new value move-constructed from x and returns
    //!   the iterator pointing to the newly inserted element.
@@ -1248,8 +1263,11 @@ class flat_multimap
    //!
    //! Note: If an element is inserted it might invalidate elements.
    iterator insert(const_iterator position, const value_type& x)
-      { return container_detail::force_copy
-         (m_flat_tree.insert_equal(container_detail::force(position), container_detail::force(x))); }
+   {
+      return container_detail::force_copy
+         (m_flat_tree.insert_equal( container_detail::force_copy(position)
+                                  , container_detail::force(x)));
+   }
 
    //! Effects: Inserts a value move constructed from x in the container.
    //!   p is a hint pointing to where the insert should start to search.
@@ -1265,7 +1283,7 @@ class flat_multimap
    iterator insert(const_iterator position, BOOST_RV_REF(value_type) x)
    {
       return container_detail::force_copy
-         (m_flat_tree.insert_equal(container_detail::force(position)
+         (m_flat_tree.insert_equal(container_detail::force_copy(position)
                                   , boost::move(x)));
    }
 
@@ -1283,7 +1301,7 @@ class flat_multimap
    iterator insert(const_iterator position, BOOST_RV_REF(impl_value_type) x)
    {
       return container_detail::force_copy(
-         m_flat_tree.insert_equal(container_detail::force(position), boost::move(x)));
+         m_flat_tree.insert_equal(container_detail::force_copy(position), boost::move(x)));
    }
 
    //! Requires: first, last are not iterators into *this.
@@ -1344,7 +1362,7 @@ class flat_multimap
    iterator emplace_hint(const_iterator hint, Args&&... args)
    {
       return container_detail::force_copy(m_flat_tree.emplace_hint_equal
-         (container_detail::force(hint), boost::forward(args)...));
+         (container_detail::force_copy(hint), boost::forward(args)...));
    }
 
    #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
@@ -1359,7 +1377,7 @@ class flat_multimap
    iterator emplace_hint(const_iterator hint                                                       \
                          BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _))              \
    {  return container_detail::force_copy(m_flat_tree.emplace_hint_equal                 \
-            (container_detail::force(hint)                                    \
+            (container_detail::force_copy(hint)                               \
                BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); }                 \
    //!
    #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
@@ -1378,7 +1396,10 @@ class flat_multimap
    //! Note: Invalidates elements with keys
    //!   not less than the erased element.
    iterator erase(const_iterator position)
-      { return container_detail::force_copy(m_flat_tree.erase(container_detail::force(position))); }
+   {
+      return container_detail::force_copy(
+         m_flat_tree.erase(container_detail::force_copy(position)));
+   }
 
    //! Effects: Erases all elements in the container with key equivalent to x.
    //!
@@ -1398,8 +1419,11 @@ class flat_multimap
    //! Complexity: Logarithmic search time plus erasure time
    //!   linear to the elements with bigger keys.
    iterator erase(const_iterator first, const_iterator last)
-      { return container_detail::force_copy
-         (m_flat_tree.erase(container_detail::force(first), container_detail::force(last))); }
+   {
+      return container_detail::force_copy
+         (m_flat_tree.erase( container_detail::force_copy(first)
+                           , container_detail::force_copy(last)));
+   }
 
    //! Effects: erase(a.begin(),a.end()).
    //!
@@ -1430,7 +1454,7 @@ class flat_multimap
    //!
    //! Complexity: Logarithmic.
    const_iterator find(const key_type& x) const
-      { return container_detail::force(m_flat_tree.find(x)); }
+      { return container_detail::force_copy(m_flat_tree.find(x)); }
 
    //! Returns: The number of elements with key equivalent to x.
    //!
@@ -1450,7 +1474,7 @@ class flat_multimap
    //!
    //! Complexity: Logarithmic
    const_iterator lower_bound(const key_type& x) const
-      {  return container_detail::force(m_flat_tree.lower_bound(x));  }
+      {  return container_detail::force_copy(m_flat_tree.lower_bound(x));  }
 
    //! Returns: An iterator pointing to the first element with key not less
    //!   than x, or end() if such an element is not found.
@@ -1464,20 +1488,20 @@ class flat_multimap
    //!
    //! Complexity: Logarithmic
    const_iterator upper_bound(const key_type& x) const
-      {  return container_detail::force(m_flat_tree.upper_bound(x)); }
+      {  return container_detail::force_copy(m_flat_tree.upper_bound(x)); }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
    std::pair equal_range(const key_type& x)
-      {  return container_detail::force >(m_flat_tree.equal_range(x));   }
+      {  return container_detail::force_copy >(m_flat_tree.equal_range(x));   }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
    std::pair
       equal_range(const key_type& x) const
-      {  return container_detail::force >(m_flat_tree.equal_range(x));   }
+      {  return container_detail::force_copy >(m_flat_tree.equal_range(x));   }
 
    //! Effects: Number of elements for which memory has been allocated.
    //!   capacity() is always greater than or equal to size().

From 00285548d9e756b11cbc655f145f99a708c687cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Thu, 12 Jul 2012 12:35:14 +0000
Subject: [PATCH 36/93] Ticket #7122: Typos in container docs.

[SVN r79447]
---
 include/boost/container/allocator_traits.hpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/boost/container/allocator_traits.hpp b/include/boost/container/allocator_traits.hpp
index f1ce2fc..8e537cc 100644
--- a/include/boost/container/allocator_traits.hpp
+++ b/include/boost/container/allocator_traits.hpp
@@ -213,8 +213,8 @@ struct allocator_traits
    static void deallocate(Alloc &a, pointer p, size_type n)
    {  return a.deallocate(p, n);  }
 
-   //! Effects: calls `a.construct(p, std::forward(args)...)` if that call is well-formed;
-   //! otherwise, invokes `::new (static_cast(p)) T(std::forward(args)...)`
+   //! Effects: calls `a.allocate(n, p)` if that call is well-formed;
+   //! otherwise, invokes `a.allocate(n)`
    static pointer allocate(Alloc &a, size_type n, const_void_pointer p)
    {
       const bool value = boost::container::container_detail::

From 24ec45bdff96c267ed5255dbc5e227c407a6c91d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Thu, 12 Jul 2012 23:25:08 +0000
Subject: [PATCH 37/93] Ticket #7123: Forward declaration for scoped allocator
 customization traits.

[SVN r79462]
---
 include/boost/container/scoped_allocator.hpp  | 42 +---------
 .../boost/container/scoped_allocator_fwd.hpp  | 83 +++++++++++++++++++
 2 files changed, 84 insertions(+), 41 deletions(-)
 create mode 100644 include/boost/container/scoped_allocator_fwd.hpp

diff --git a/include/boost/container/scoped_allocator.hpp b/include/boost/container/scoped_allocator.hpp
index d7115d8..7da71bd 100644
--- a/include/boost/container/scoped_allocator.hpp
+++ b/include/boost/container/scoped_allocator.hpp
@@ -23,6 +23,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -31,50 +32,9 @@
 #include 
 #include 
 
-#if defined(BOOST_NO_VARIADIC_TEMPLATES)
-#include 
-#endif
 
 namespace boost { namespace container {
 
-#if defined(BOOST_CONTAINER_PERFECT_FORWARDING)
-
-#if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
-
-template 
-class scoped_allocator_adaptor;
-
-#else // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
-
-template 
-class scoped_allocator_adaptor;
-
-template 
-class scoped_allocator_adaptor;
-
-#endif   // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
-
-
-#else    // #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-template 
-class scoped_allocator_adaptor;
-
-#endif
-
-//! The allocator_arg_t struct is an empty structure type used as a unique type to
-//! disambiguate constructor and function overloading. Specifically, several types
-//! have constructors with allocator_arg_t as the first argument, immediately followed
-//! by an argument of a type that satisfies the Allocator requirements
-struct allocator_arg_t{};
-
-//! A instance of type allocator_arg_t
-//!
-static const allocator_arg_t allocator_arg = allocator_arg_t();
-
 //! Remark: if a specialization is derived from true_type, indicates that T may be constructed
 //! with an allocator as its last constructor argument.  Ideally, all constructors of T (including the
 //! copy and move constructors) should have a variant that accepts a final argument of
diff --git a/include/boost/container/scoped_allocator_fwd.hpp b/include/boost/container/scoped_allocator_fwd.hpp
new file mode 100644
index 0000000..0814a50
--- /dev/null
+++ b/include/boost/container/scoped_allocator_fwd.hpp
@@ -0,0 +1,83 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2011-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)
+//
+// See http://www.boost.org/libs/container for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_FWD_HPP
+#define BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_FWD_HPP
+
+#if (defined MSC_VER) && (_MSC_VER >= 1200)
+#  pragma once
+#endif
+
+#include 
+#include 
+
+#if defined(BOOST_NO_VARIADIC_TEMPLATES)
+#include 
+#include 
+#endif
+
+namespace boost { namespace container {
+
+///@cond
+
+#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+
+   #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
+
+   template 
+   class scoped_allocator_adaptor;
+
+   #else // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
+
+   template 
+   class scoped_allocator_adaptor;
+
+   template 
+   class scoped_allocator_adaptor;
+
+   #endif   // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
+
+
+#else    // #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+
+template 
+class scoped_allocator_adaptor;
+
+#endif
+
+///@endcond
+
+//! The allocator_arg_t struct is an empty structure type used as a unique type to
+//! disambiguate constructor and function overloading. Specifically, several types
+//! have constructors with allocator_arg_t as the first argument, immediately followed
+//! by an argument of a type that satisfies the Allocator requirements
+struct allocator_arg_t{};
+
+//! A instance of type allocator_arg_t
+//!
+static const allocator_arg_t allocator_arg = allocator_arg_t();
+
+template 
+struct constructible_with_allocator_suffix;
+
+template 
+struct constructible_with_allocator_prefix;
+
+template 
+struct uses_allocator;
+
+}} // namespace boost { namespace container {
+
+#include 
+
+#endif //  BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_FWD_HPP

From b0e36c06e965a919c3d640ceeddf5930120e8e97 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Thu, 12 Jul 2012 23:26:43 +0000
Subject: [PATCH 38/93] Ticket #7123: Forward declaration for scoped allocator
 customization traits.

[SVN r79463]
---
 doc/container.qbk                      | 12 ++++++++----
 proj/vc7ide/container.vcproj           |  3 +++
 test/scoped_allocator_adaptor_test.cpp | 15 ++++++++-------
 test/util.hpp                          |  2 +-
 4 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/doc/container.qbk b/doc/container.qbk
index dd1bc7d..65d4e90 100644
--- a/doc/container.qbk
+++ b/doc/container.qbk
@@ -439,7 +439,7 @@ not constructed on the fly when auxiliary memory is needed).
 [section:scoped_allocator Scoped allocators]
 
 C++11 improves stateful allocators with the introduction of
-[@http://http://en.cppreference.com/w/cpp/memory/scoped_allocator_adaptor `std::scoped_allocator_adaptor`]
+[@http://en.cppreference.com/w/cpp/memory/scoped_allocator_adaptor `std::scoped_allocator_adaptor`]
 class template. `scoped_allocator_adaptor` is instantiated with one outer allocator and zero or more inner
 allocators.
 
@@ -617,8 +617,12 @@ use [*Boost.Container]? There are several reasons for that:
 [section:release_notes_boost_1_51_00 Boost 1.51 Release]
 
 *  Fixed bugs
+  [@https://svn.boost.org/trac/boost/ticket/6763 #6763],
+  [@https://svn.boost.org/trac/boost/ticket/6803 #6803],
   [@https://svn.boost.org/trac/boost/ticket/7114 #7114],
   [@https://svn.boost.org/trac/boost/ticket/7103 #7103].
+  [@https://svn.boost.org/trac/boost/ticket/7123 #7123],
+
 
 [endsect]
 
@@ -627,13 +631,13 @@ use [*Boost.Container]? There are several reasons for that:
 *  Added Scoped Allocator Model support.
 
 *  Fixed bugs
+  [@https://svn.boost.org/trac/boost/ticket/6533 #6533],
+  [@https://svn.boost.org/trac/boost/ticket/6536 #6536],
   [@https://svn.boost.org/trac/boost/ticket/6566 #6566],
   [@https://svn.boost.org/trac/boost/ticket/6575 #6575],
   [@https://svn.boost.org/trac/boost/ticket/6606 #6606],
   [@https://svn.boost.org/trac/boost/ticket/6615 #6615],
-  [@https://svn.boost.org/trac/boost/ticket/6533 #6533],
-  [@https://svn.boost.org/trac/boost/ticket/6536 #6536],
-
+  
 [endsect]
 
 
diff --git a/proj/vc7ide/container.vcproj b/proj/vc7ide/container.vcproj
index 50610a6..fcd9e8a 100644
--- a/proj/vc7ide/container.vcproj
+++ b/proj/vc7ide/container.vcproj
@@ -203,6 +203,9 @@
 			
 			
+			
+			
 			
 			
diff --git a/test/scoped_allocator_adaptor_test.cpp b/test/scoped_allocator_adaptor_test.cpp
index 6afca6e..66d86b0 100644
--- a/test/scoped_allocator_adaptor_test.cpp
+++ b/test/scoped_allocator_adaptor_test.cpp
@@ -8,20 +8,15 @@
 //
 //////////////////////////////////////////////////////////////////////////////
 #include 
-#include 
+#include 
 #include 
-#include 
-#include 
-#include 
 #include 
 #include 
+#include 
 #include 
-#include 
-#include 
 
 using namespace boost::container;
 
-
 template
 class test_allocator
 {
@@ -242,6 +237,12 @@ struct constructible_with_allocator_suffix
 }  //namespace boost {
 
 
+#include 
+#include 
+#include 
+#include 
+#include 
+
 int main()
 {
    typedef test_allocator, 0>   OuterAlloc;
diff --git a/test/util.hpp b/test/util.hpp
index 639c17b..9bfe1af 100644
--- a/test/util.hpp
+++ b/test/util.hpp
@@ -71,7 +71,7 @@ inline bool in_range(const boost::posix_time::ptime& xt, int secs=1)
 boost::xtime xsecs(int secs)
 {
    boost::xtime ret;
-   boost::xtime_get(&ret, boost::TIME_UTC_);
+   boost::xtime_get(&ret, boost::TIME_UTC);
    ret.sec += secs;
    return ret;
 }

From 07c51f556699e6ae2aeeb5ff5585feb788a136dc Mon Sep 17 00:00:00 2001
From: John Maddock 
Date: Sat, 14 Jul 2012 11:21:03 +0000
Subject: [PATCH 39/93] Fix PDF install rule so that it's explicit and
 automatically invokes a PDF build when specified on the command line. So
 "bjam pdfinstall" will now build and install the PDF to the current
 directory. This works around some problems that the previous versions had if
 the user did not have an FO processor installed (basically Daniel James was
 unable to build the HTML docs for the distribution if the pdfinstall rule was
 implicit).

[SVN r79492]
---
 doc/Jamfile.v2 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2
index 4647f89..a9095bd 100644
--- a/doc/Jamfile.v2
+++ b/doc/Jamfile.v2
@@ -85,5 +85,5 @@ boostbook standalone
         pdf:admon.graphics.extension=".svg"
    ;
 
-install pdf-install : standalone : PDF . container.pdf ;
-explicit pdf-install ;
+install pdfinstall : standalone/pdf : PDF . container.pdf ;
+explicit pdfinstall ;

From 63a7e49036eb6f2834e0e94df6320d07f1bc3a92 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Wed, 15 Aug 2012 11:21:29 +0000
Subject: [PATCH 40/93] Ticket #7232

[SVN r80047]
---
 include/boost/container/string.hpp | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp
index 2a64cec..7b5e040 100644
--- a/include/boost/container/string.hpp
+++ b/include/boost/container/string.hpp
@@ -1368,9 +1368,6 @@ class basic_string
    //! Requires: p is a valid iterator on *this.
    //!
    //! Effects: Inserts n copies of c before the character referred to by p.
-   //!
-   //! Returns: An iterator which refers to the copy of the first
-   //!   inserted character, or p if n == 0.
    void insert(const_iterator p, size_type n, CharT c)
    {
       this->insert(p, cvalue_iterator(c, n), cvalue_iterator());
@@ -1379,9 +1376,6 @@ class basic_string
    //! Requires: p is a valid iterator on *this. [first,last) is a valid range.
    //!
    //! Effects: Equivalent to insert(p - begin(), basic_string(first, last)).
-   //!
-   //! Returns: An iterator which refers to the copy of the first
-   //!   inserted character, or p if first == last.
    template 
    void insert(const_iterator p, InputIter first, InputIter last)
    {

From 09d57bf2a227af44c01cb209d3398714200f0133 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Wed, 15 Aug 2012 11:33:40 +0000
Subject: [PATCH 41/93] Changelog for ticket #7232

[SVN r80048]
---
 doc/container.qbk | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/doc/container.qbk b/doc/container.qbk
index 65d4e90..b53c15d 100644
--- a/doc/container.qbk
+++ b/doc/container.qbk
@@ -614,6 +614,13 @@ use [*Boost.Container]? There are several reasons for that:
 
 [section:release_notes Release Notes]
 
+[section:release_notes_boost_1_52_00 Boost 1.52 Release]
+
+*  Fixed bug
+  [@https://svn.boost.org/trac/boost/ticket/7232 #7232].
+
+[endsect]
+
 [section:release_notes_boost_1_51_00 Boost 1.51 Release]
 
 *  Fixed bugs
@@ -623,7 +630,6 @@ use [*Boost.Container]? There are several reasons for that:
   [@https://svn.boost.org/trac/boost/ticket/7103 #7103].
   [@https://svn.boost.org/trac/boost/ticket/7123 #7123],
 
-
 [endsect]
 
 [section:release_notes_boost_1_50_00 Boost 1.50 Release]

From 32bf689e63e13c6512e1e18fbcc375373b434d08 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Fri, 24 Aug 2012 20:36:23 +0000
Subject: [PATCH 42/93] Ticket #7269

[SVN r80172]
---
 include/boost/container/vector.hpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp
index c6e5b51..e4235ef 100644
--- a/include/boost/container/vector.hpp
+++ b/include/boost/container/vector.hpp
@@ -1413,7 +1413,8 @@ class vector : private container_detail::vector_alloc_holder
    void priv_range_insert(const_iterator pos, InIt first, InIt last, std::input_iterator_tag)
    {
       for(;first != last; ++first){
-         this->emplace(pos, *first);
+         pos = this->emplace(pos, *first);
+         ++pos;
       }
    }
 

From 394643b5608b20a4ca96f769234bd588f76720c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Fri, 24 Aug 2012 20:48:01 +0000
Subject: [PATCH 43/93] Ticket #7139

[SVN r80173]
---
 include/boost/container/flat_map.hpp | 12 ++----------
 include/boost/container/map.hpp      |  4 ++--
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/include/boost/container/flat_map.hpp b/include/boost/container/flat_map.hpp
index 0142500..147c1fe 100644
--- a/include/boost/container/flat_map.hpp
+++ b/include/boost/container/flat_map.hpp
@@ -39,11 +39,7 @@ namespace container {
 
 /// @cond
 // Forward declarations of operators == and <, needed for friend declarations.
-#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template  >, class A = std::allocator >
-#else
 template 
-#endif
 class flat_map;
 
 template 
@@ -94,7 +90,7 @@ static D force_copy(S s)
 //! Erasing an element of a flat_map invalidates iterators and references
 //! pointing to elements that come after (their keys are bigger) the erased element.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template  >, class A = std::allocator >
+template , class A = std::allocator< std::pair< Key, T> > >
 #else
 template 
 #endif
@@ -870,11 +866,7 @@ struct has_trivial_destructor_after_move
 namespace container {
 
 // Forward declaration of operators < and ==, needed for friend declaration.
-#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template  >, class A = std::allocator >
-#else
 template 
-#endif
 class flat_multimap;
 
 template 
@@ -901,7 +893,7 @@ inline bool operator<(const flat_multimap& x,
 //! A is the allocator to allocate the value_types
 //! (e.g. allocator< std::pair >).
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template  >, class A = std::allocator >
+template , class A = std::allocator< std::pair< Key, T> > >
 #else
 template 
 #endif
diff --git a/include/boost/container/map.hpp b/include/boost/container/map.hpp
index 91cbd35..d4bd6e6 100644
--- a/include/boost/container/map.hpp
+++ b/include/boost/container/map.hpp
@@ -68,7 +68,7 @@ inline bool operator<(const map& x,
 //! A is the allocator to allocate the value_types
 //! (e.g. allocator< std::pair > ).
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template  >, class A = std::allocator >
+template , class A = std::allocator< std::pair< const Key, T> > >
 #else
 template 
 #endif
@@ -814,7 +814,7 @@ namespace container {
 //! A is the allocator to allocate the value_types
 //!(e.g. allocator< std::pair<const Key, T> >).
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template  >, class A = std::allocator >
+template , class A = std::allocator< std::pair< const Key, T> > >
 #else
 template 
 #endif

From 29f2f1f157690321c0eb2bbe1c9dc2246f97fade Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Fri, 24 Aug 2012 21:17:35 +0000
Subject: [PATCH 44/93] Ticket #7215 + added const for most local variables

[SVN r80174]
---
 include/boost/container/string.hpp | 86 ++++++++++++++++--------------
 1 file changed, 45 insertions(+), 41 deletions(-)

diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp
index 7b5e040..49f2974 100644
--- a/include/boost/container/string.hpp
+++ b/include/boost/container/string.hpp
@@ -1177,10 +1177,11 @@ class basic_string
    //! Effects: Equivalent to append(static_cast(1), c).
    void push_back(CharT c)
    {
-      if (this->priv_size() < this->capacity()){
-         this->priv_construct_null(this->priv_addr() + (this->priv_size() + 1));
-         Traits::assign(this->priv_addr()[this->priv_size()], c);
-         this->priv_size(this->priv_size()+1);
+      const size_type old_size = this->priv_size();
+      if (old_size < this->capacity()){
+         this->priv_construct_null(this->priv_addr() + old_size + 1);
+         Traits::assign(this->priv_addr()[old_size], c);
+         this->priv_size(old_size+1);
       }
       else{
          //No enough memory, insert a new object at the end
@@ -1359,7 +1360,7 @@ class basic_string
    //! Returns: An iterator which refers to the copy of the inserted character.
    iterator insert(const_iterator p, CharT c)
    {
-      size_type new_offset = p - this->priv_addr() + 1;
+      size_type new_offset = p - this->priv_addr();
       this->insert(p, cvalue_iterator(c, 1), cvalue_iterator());
       return this->priv_addr() + new_offset;
    }
@@ -1413,11 +1414,12 @@ class basic_string
    iterator erase(const_iterator p)
    {
       // The move includes the terminating null.
-      CharT *ptr = const_cast(container_detail::to_raw_pointer(p));
+      CharT * const ptr = const_cast(container_detail::to_raw_pointer(p));
+      const size_type old_size = this->priv_size();
       Traits::move(ptr,
                    container_detail::to_raw_pointer(p + 1),
-                   this->priv_size() - (p - this->priv_addr()));
-      this->priv_size(this->priv_size()-1);
+                   old_size - (p - this->priv_addr()));
+      this->priv_size(old_size-1);
       return iterator(ptr);
    }
 
@@ -1433,11 +1435,12 @@ class basic_string
    {
       CharT * f = const_cast(container_detail::to_raw_pointer(first));
       if (first != last) { // The move includes the terminating null.
-         size_type num_erased = last - first;
+         const size_type num_erased = last - first;
+         const size_type old_size = this->priv_size();
          Traits::move(f,
                       container_detail::to_raw_pointer(last),
-                      (this->priv_size() + 1)-(last - this->priv_addr()));
-         size_type new_length = this->priv_size() - num_erased;
+                      (old_size + 1)-(last - this->priv_addr()));
+         const size_type new_length = old_size - num_erased;
          this->priv_size(new_length);
       }
       return iterator(f);
@@ -1450,8 +1453,9 @@ class basic_string
    //! Effects: Equivalent to erase(size() - 1, 1).
    void pop_back()
    {
-      Traits::assign(this->priv_addr()[this->priv_size()-1], this->priv_null());
-      this->priv_size(this->priv_size()-1);;
+      const size_type old_size = this->priv_size();
+      Traits::assign(this->priv_addr()[old_size-1], this->priv_null());
+      this->priv_size(old_size-1);;
    }
 
    //! Requires: pos1 <= size().
@@ -1903,8 +1907,8 @@ class basic_string
       if (pos > size())
          return npos;
       else {
-         pointer finish = this->priv_addr() + this->priv_size();
-         const_iterator result = std::find_if(this->priv_addr() + pos, finish,
+         const pointer finish = this->priv_addr() + this->priv_size();
+         const const_iterator result = std::find_if(this->priv_addr() + pos, finish,
                                     Not_within_traits(s, s + n));
          return result != finish ? result - this->priv_addr() : npos;
       }
@@ -1926,8 +1930,8 @@ class basic_string
       if (pos > size())
          return npos;
       else {
-         pointer finish = this->priv_addr() + this->priv_size();
-         const_iterator result
+         const pointer finish = this->priv_addr() + this->priv_size();
+         const const_iterator result
             = std::find_if(this->priv_addr() + pos, finish,
                      std::not1(std::bind2nd(Eq_traits(), c)));
          return result != finish ? result - begin() : npos;
@@ -1983,7 +1987,7 @@ class basic_string
          return npos;
       else {
          const const_iterator last = begin() + container_detail::min_value(len - 1, pos) + 1;
-         const_reverse_iterator rresult =
+         const const_reverse_iterator rresult =
             std::find_if(const_reverse_iterator(last), rend(),
                   std::not1(std::bind2nd(Eq_traits(), c)));
          return rresult != rend() ? (rresult.base() - 1) - begin() : npos;
@@ -2103,12 +2107,12 @@ class basic_string
    {
       //Allocate a new buffer.
       size_type real_cap = 0;
-      pointer   long_addr    = this->priv_long_addr();
-      size_type long_size    = this->priv_long_size();
-      size_type long_storage = this->priv_long_storage();
+      const pointer   long_addr    = this->priv_long_addr();
+      const size_type long_size    = this->priv_long_size();
+      const size_type long_storage = this->priv_long_storage();
       //We can make this nothrow as chars are always NoThrowCopyables
       try{
-         std::pair ret = this->allocation_command
+         const std::pair ret = this->allocation_command
                (allocate_new, long_size+1, long_size+1, real_cap, long_addr);
          //Copy and update
          Traits::copy( container_detail::to_raw_pointer(ret.first)
@@ -2245,14 +2249,15 @@ class basic_string
    {
       size_type cur = 0;
       CharT *ptr = container_detail::to_raw_pointer(this->priv_addr());
-      while (f != l && cur != this->priv_size()) {
+      const size_type old_size = this->priv_size();
+      while (f != l && cur != old_size) {
          Traits::assign(*ptr, *f);
          ++f;
          ++cur;
          ++ptr;
       }
       if (f == l)
-         this->erase(this->priv_addr() + cur, this->priv_addr() + this->priv_size());
+         this->erase(this->priv_addr() + cur, this->priv_addr() + old_size);
       else
          this->append(f, l);
       return *this;
@@ -2271,10 +2276,10 @@ class basic_string
                     ForwardIter last,  std::forward_iterator_tag)
    {
       if (first != last) {
-         size_type n = std::distance(first, last);
-         size_type remaining = this->capacity() - this->priv_size();
-         const size_type old_size = this->size();
-         pointer old_start = this->priv_addr();
+         const size_type n = std::distance(first, last);
+         const size_type old_size = this->priv_size();
+         const size_type remaining = this->capacity() - old_size;
+         const pointer old_start = this->priv_addr();
          bool enough_capacity = false;
          std::pair allocation_ret;
          size_type new_cap = 0;
@@ -2299,15 +2304,14 @@ class basic_string
 
          //Reuse same buffer
          if(enough_capacity){
-            const size_type elems_after =
-               this->priv_size() - (position - this->priv_addr());
-            size_type old_length = this->priv_size();
+            const size_type elems_after = old_size - (position - this->priv_addr());
+            const size_type old_length = old_size;
             if (elems_after >= n) {
-               pointer pointer_past_last = this->priv_addr() + this->priv_size() + 1;
-               priv_uninitialized_copy(this->priv_addr() + (this->priv_size() - n + 1),
+               const pointer pointer_past_last = this->priv_addr() + old_size + 1;
+               priv_uninitialized_copy(this->priv_addr() + (old_size - n + 1),
                                        pointer_past_last, pointer_past_last);
 
-               this->priv_size(this->priv_size()+n);
+               this->priv_size(old_size+n);
                Traits::move(const_cast(container_detail::to_raw_pointer(position + n)),
                            container_detail::to_raw_pointer(position),
                            (elems_after - n) + 1);
@@ -2317,8 +2321,8 @@ class basic_string
                ForwardIter mid = first;
                std::advance(mid, elems_after + 1);
 
-               priv_uninitialized_copy(mid, last, this->priv_addr() + this->priv_size() + 1);
-               this->priv_size(this->priv_size() + (n - elems_after));
+               priv_uninitialized_copy(mid, last, this->priv_addr() + old_size + 1);
+               this->priv_size(old_size + (n - elems_after));
                priv_uninitialized_copy
                   (position, const_iterator(this->priv_addr() + old_length + 1),
                   this->priv_addr() + this->priv_size());
@@ -2337,7 +2341,7 @@ class basic_string
                new_length += priv_uninitialized_copy
                               (first, last, new_start + new_length);
                new_length += priv_uninitialized_copy
-                              (position, const_iterator(this->priv_addr() + this->priv_size()),
+                              (position, const_iterator(this->priv_addr() + old_size),
                               new_start + new_length);
                this->priv_construct_null(new_start + new_length);
 
@@ -2350,10 +2354,10 @@ class basic_string
             else{
                //value_type is POD, so backwards expansion is much easier
                //than with vector
-               value_type *oldbuf = container_detail::to_raw_pointer(old_start);
-               value_type *newbuf = container_detail::to_raw_pointer(new_start);
-               const value_type *pos    = container_detail::to_raw_pointer(position);
-               size_type  before  = pos - oldbuf;
+               value_type * const oldbuf     = container_detail::to_raw_pointer(old_start);
+               value_type * const newbuf     = container_detail::to_raw_pointer(new_start);
+               const value_type *const pos   = container_detail::to_raw_pointer(position);
+               const size_type before  = pos - oldbuf;
 
                //First move old data
                Traits::move(newbuf, oldbuf, before);

From 2947abfdefbd102982bbf4a7356cbdb06df408b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Fri, 24 Aug 2012 21:35:27 +0000
Subject: [PATCH 45/93] Ticket #6606

[SVN r80175]
---
 doc/container.qbk | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/doc/container.qbk b/doc/container.qbk
index b53c15d..3b99566 100644
--- a/doc/container.qbk
+++ b/doc/container.qbk
@@ -38,7 +38,7 @@ In short, what does [*Boost.Container] offer?
 * The library offers new useful containers:
   * [classref boost::container::flat_map flat_map],
     [classref boost::container::flat_set flat_set],
-    [classref boost::container::flat_multiset flat_multiset] and
+    [classref boost::container::flat_multimap flat_multimap] and
     [classref boost::container::flat_multiset flat_multiset]: drop-in
     replacements for standard associative containers but more memory friendly and with faster
     searches.
@@ -616,8 +616,12 @@ use [*Boost.Container]? There are several reasons for that:
 
 [section:release_notes_boost_1_52_00 Boost 1.52 Release]
 
-*  Fixed bug
-  [@https://svn.boost.org/trac/boost/ticket/7232 #7232].
+*  Fixed bugs
+  [@https://svn.boost.org/trac/boost/ticket/6606 #6606],
+  [@https://svn.boost.org/trac/boost/ticket/7139 #7139],
+  [@https://svn.boost.org/trac/boost/ticket/7215 #7215],
+  [@https://svn.boost.org/trac/boost/ticket/7232 #7232],
+  [@https://svn.boost.org/trac/boost/ticket/7269 #7269].
 
 [endsect]
 
@@ -641,7 +645,6 @@ use [*Boost.Container]? There are several reasons for that:
   [@https://svn.boost.org/trac/boost/ticket/6536 #6536],
   [@https://svn.boost.org/trac/boost/ticket/6566 #6566],
   [@https://svn.boost.org/trac/boost/ticket/6575 #6575],
-  [@https://svn.boost.org/trac/boost/ticket/6606 #6606],
   [@https://svn.boost.org/trac/boost/ticket/6615 #6615],
   
 [endsect]

From 011f1fb1818c7dd246b29adebcc906688286bb2b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Sat, 25 Aug 2012 08:54:03 +0000
Subject: [PATCH 46/93] Fixed error in  insertions with input iterator ranges

[SVN r80193]
---
 include/boost/container/deque.hpp  | 4 +++-
 include/boost/container/vector.hpp | 5 +++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/include/boost/container/deque.hpp b/include/boost/container/deque.hpp
index 6a85ae9..d3ca4ca 100644
--- a/include/boost/container/deque.hpp
+++ b/include/boost/container/deque.hpp
@@ -1603,8 +1603,10 @@ class deque : protected deque_base
    template 
    void priv_insert_aux(const_iterator pos, InpIt first, InpIt last, std::input_iterator_tag)
    {
+      iterator it(pos);
       for(;first != last; ++first){
-         this->insert(pos, boost::move(value_type(*first)));
+         it = this->emplace(it, *first);
+         ++it;
       }
    }
 
diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp
index e4235ef..f24699e 100644
--- a/include/boost/container/vector.hpp
+++ b/include/boost/container/vector.hpp
@@ -1412,9 +1412,10 @@ class vector : private container_detail::vector_alloc_holder
    template 
    void priv_range_insert(const_iterator pos, InIt first, InIt last, std::input_iterator_tag)
    {
+      iterator it(pos.get_ptr());
       for(;first != last; ++first){
-         pos = this->emplace(pos, *first);
-         ++pos;
+         it = this->emplace(it, *first);
+         ++it;
       }
    }
 

From 3c256c228284702bb2fa383092feecfdfb910188 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Sat, 1 Sep 2012 11:01:03 +0000
Subject: [PATCH 47/93] Implemented LWG Issue #149 (range insertion now returns
 an iterator) & cleaned up insertion code in most containers

[SVN r80348]
---
 doc/container.qbk                             |   4 +-
 include/boost/container/deque.hpp             | 280 +++++-----
 .../container/detail/advanced_insert_int.hpp  |  15 +-
 include/boost/container/detail/algorithms.hpp |  24 +
 include/boost/container/detail/flat_tree.hpp  | 340 +++++++-----
 include/boost/container/detail/iterators.hpp  |  86 +++-
 .../boost/container/detail/preprocessor.hpp   |  79 ++-
 include/boost/container/detail/stored_ref.hpp |  92 ----
 include/boost/container/detail/tree.hpp       | 165 +++---
 include/boost/container/flat_map.hpp          |   8 +-
 include/boost/container/flat_set.hpp          |   8 +-
 include/boost/container/list.hpp              | 266 +++++-----
 include/boost/container/map.hpp               |   4 +-
 include/boost/container/set.hpp               |   4 +-
 include/boost/container/slist.hpp             | 285 +++++------
 include/boost/container/stable_vector.hpp     | 313 ++++++------
 include/boost/container/string.hpp            | 482 +++++++++---------
 include/boost/container/vector.hpp            | 414 ++++++++-------
 proj/to-do.txt                                |  11 +
 proj/vc7ide/allocator_traits_test.vcproj      |   3 +
 proj/vc7ide/container.sln                     |   8 +
 proj/vc7ide/container.vcproj                  |   5 +-
 test/check_equal_containers.hpp               |  27 +-
 test/deque_test.cpp                           |   2 +-
 test/input_from_forward_iterator.hpp          |  80 +++
 test/list_test.hpp                            |  44 +-
 test/movable_int.hpp                          |  25 +
 test/set_test.hpp                             |  16 +-
 test/vector_test.hpp                          |  45 +-
 29 files changed, 1659 insertions(+), 1476 deletions(-)
 delete mode 100644 include/boost/container/detail/stored_ref.hpp
 create mode 100644 test/input_from_forward_iterator.hpp

diff --git a/doc/container.qbk b/doc/container.qbk
index 3b99566..0c760e0 100644
--- a/doc/container.qbk
+++ b/doc/container.qbk
@@ -617,7 +617,7 @@ use [*Boost.Container]? There are several reasons for that:
 [section:release_notes_boost_1_52_00 Boost 1.52 Release]
 
 *  Fixed bugs
-  [@https://svn.boost.org/trac/boost/ticket/6606 #6606],
+  [@https://svn.boost.org/trac/boost/ticket/6615 #6615],
   [@https://svn.boost.org/trac/boost/ticket/7139 #7139],
   [@https://svn.boost.org/trac/boost/ticket/7215 #7215],
   [@https://svn.boost.org/trac/boost/ticket/7232 #7232],
@@ -641,11 +641,11 @@ use [*Boost.Container]? There are several reasons for that:
 *  Added Scoped Allocator Model support.
 
 *  Fixed bugs
+  [@https://svn.boost.org/trac/boost/ticket/6606 #6606],
   [@https://svn.boost.org/trac/boost/ticket/6533 #6533],
   [@https://svn.boost.org/trac/boost/ticket/6536 #6536],
   [@https://svn.boost.org/trac/boost/ticket/6566 #6566],
   [@https://svn.boost.org/trac/boost/ticket/6575 #6575],
-  [@https://svn.boost.org/trac/boost/ticket/6615 #6615],
   
 [endsect]
 
diff --git a/include/boost/container/deque.hpp b/include/boost/container/deque.hpp
index d3ca4ca..c7f1aca 100644
--- a/include/boost/container/deque.hpp
+++ b/include/boost/container/deque.hpp
@@ -943,14 +943,18 @@ class deque : protected deque_base
    //!   throws or T's constructor taking an dereferenced InIt throws.
    //!
    //! Complexity: Linear to the range [first, last).
-   template 
-   deque(InpIt first, InpIt last, const allocator_type& a = allocator_type())
+   template 
+   deque(InIt first, InIt last, const allocator_type& a = allocator_type()
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+         >::type * = 0
+      #endif
+      )
       : Base(a)
    {
-      //Dispatch depending on integer/iterator
-      const bool aux_boolean = container_detail::is_convertible::value;
-      typedef container_detail::bool_ Result;
-      this->priv_initialize_dispatch(first, last, Result());
+      typedef typename std::iterator_traits::iterator_category ItCat;
+      this->priv_range_initialize(first, last, ItCat());
    }
 
    //! Effects: Destroys the deque. All stored values are destroyed
@@ -1043,23 +1047,61 @@ class deque : protected deque_base
    //!
    //! Complexity: Linear to n.
    void assign(size_type n, const T& val)
-   {  this->priv_fill_assign(n, val);  }
+   {
+      typedef constant_iterator c_it;
+      this->assign(c_it(val, n), c_it());
+   }
 
    //! Effects: Assigns the the range [first, last) to *this.
    //!
    //! Throws: If memory allocation throws or
-   //!   T's constructor from dereferencing InpIt throws.
+   //!   T's constructor from dereferencing InIt throws.
    //!
    //! Complexity: Linear to n.
-   template 
-   void assign(InpIt first, InpIt last)
+   template 
+   void assign(InIt first, InIt last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+            && container_detail::is_input_iterator::value
+         >::type * = 0
+      #endif
+      )
    {
-      //Dispatch depending on integer/iterator
-      const bool aux_boolean = container_detail::is_convertible::value;
-      typedef container_detail::bool_ Result;
-      this->priv_assign_dispatch(first, last, Result());
+      iterator cur = begin();
+      for ( ; first != last && cur != end(); ++cur, ++first){
+         *cur = *first;
+      }
+      if (first == last){
+         this->erase(cur, cend());
+      }
+      else{
+         this->insert(cend(), first, last);
+      }
    }
 
+   #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   template 
+   void assign(FwdIt first, FwdIt last
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+            && !container_detail::is_input_iterator::value
+         >::type * = 0
+      )
+   {
+      const size_type len = std::distance(first, last);
+      if (len > size()) {
+         FwdIt mid = first;
+         std::advance(mid, size());
+         boost::copy_or_move(first, mid, begin());
+         this->insert(cend(), mid, last);
+      }
+      else{
+         this->erase(boost::copy_or_move(first, last, begin()), cend());
+      }
+   }
+   #endif
+
    #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
    //! Effects: Inserts a copy of x at the end of the deque.
    //!
@@ -1142,6 +1184,8 @@ class deque : protected deque_base
    //!
    //! Effects: Insert a copy of x before position.
    //!
+   //! Returns: an iterator to the inserted element.
+   //!
    //! Throws: If memory allocation throws or x's copy constructor throws.
    //!
    //! Complexity: If position is end(), amortized constant time
@@ -1152,6 +1196,8 @@ class deque : protected deque_base
    //!
    //! Effects: Insert a new element before position with mx's resources.
    //!
+   //! Returns: an iterator to the inserted element.
+   //!
    //! Throws: If memory allocation throws.
    //!
    //! Complexity: If position is end(), amortized constant time
@@ -1165,29 +1211,63 @@ class deque : protected deque_base
    //!
    //! Effects: Insert n copies of x before pos.
    //!
+   //! Returns: an iterator to the first inserted element or pos if n is 0.
+   //!
    //! Throws: If memory allocation throws or T's copy constructor throws.
    //!
    //! Complexity: Linear to n.
-   void insert(const_iterator pos, size_type n, const value_type& x)
-   { this->priv_fill_insert(pos, n, x); }
+   iterator insert(const_iterator pos, size_type n, const value_type& x)
+   {
+      typedef constant_iterator c_it;
+      return this->insert(pos, c_it(x, n), c_it());
+   }
 
    //! Requires: pos must be a valid iterator of *this.
    //!
    //! Effects: Insert a copy of the [first, last) range before pos.
    //!
+   //! Returns: an iterator to the first inserted element or pos if first == last.
+   //!
    //! Throws: If memory allocation throws, T's constructor from a
-   //!   dereferenced InpIt throws or T's copy constructor throws.
+   //!   dereferenced InIt throws or T's copy constructor throws.
    //!
    //! Complexity: Linear to std::distance [first, last).
-   template 
-   void insert(const_iterator pos, InpIt first, InpIt last)
+   template 
+   iterator insert(const_iterator pos, InIt first, InIt last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+            && container_detail::is_input_iterator::value
+         >::type * = 0
+      #endif
+      )
    {
-      //Dispatch depending on integer/iterator
-      const bool aux_boolean = container_detail::is_convertible::value;
-      typedef container_detail::bool_ Result;
-      this->priv_insert_dispatch(pos, first, last, Result());
+      size_type n = 0;
+      iterator it(pos);
+      for(;first != last; ++first, ++n){
+         it = this->emplace(it, *first);
+         ++it;
+      }
+      it -= n;
+      return it;
    }
 
+   #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   template 
+   iterator insert(const_iterator p, FwdIt first, FwdIt last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+            && !container_detail::is_input_iterator::value
+         >::type * = 0
+      #endif
+      )
+   {
+      container_detail::advanced_insert_aux_proxy proxy(this->alloc(), first, last);
+      return priv_insert_aux_impl(p, (size_type)std::distance(first, last), proxy);
+   }
+   #endif
+
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
    //! Effects: Inserts an object of type T constructed with
@@ -1257,11 +1337,9 @@ class deque : protected deque_base
          return (this->end()-1);
       }
       else{
-         size_type n = p - this->cbegin();
          typedef container_detail::advanced_insert_aux_emplace type;
          type &&proxy = type(this->alloc(), boost::forward(args)...);
-         this->priv_insert_aux_impl(p, 1, proxy);
-         return iterator(this->begin() + n);
+         return this->priv_insert_aux_impl(p, 1, proxy);
       }
    }
 
@@ -1320,12 +1398,10 @@ class deque : protected deque_base
          return (this->end()-1);                                                             \
       }                                                                                      \
       else{                                                                                  \
-         size_type pos_num = p - this->cbegin();                                             \
          container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)   \
              proxy                          \
             (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));  \
-         this->priv_insert_aux_impl(p, 1, proxy);                                            \
-         return iterator(this->begin() + pos_num);                                           \
+         return this->priv_insert_aux_impl(p, 1, proxy);                                     \
       }                                                                                      \
    }                                                                                         \
    //!
@@ -1361,7 +1437,7 @@ class deque : protected deque_base
       if (new_size < len)
          this->priv_erase_last_n(len - new_size);
       else{
-         size_type n = new_size - this->size();
+         const size_type n = new_size - this->size();
          container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
          priv_insert_back_aux_impl(n, proxy);
       }
@@ -1500,9 +1576,7 @@ class deque : protected deque_base
          return (end()-1);
       }
       else {
-         size_type n = position - cbegin();
-         this->priv_insert_aux(position, size_type(1), x);
-         return iterator(this->begin() + n);
+         return this->insert(position, size_type(1), x);
       }
    }
 
@@ -1517,10 +1591,7 @@ class deque : protected deque_base
          return(end()-1);
       }
       else {
-         //Just call more general insert(pos, size, value) and return iterator
-         size_type n = position - begin();
-         this->priv_insert_aux(position, move_it(r_iterator(mx, 1)), move_it(r_iterator()));
-         return iterator(this->begin() + n);
+         return this->insert(position, move_it(r_iterator(mx, 1)), move_it(r_iterator()));
       }
    }
 
@@ -1532,7 +1603,7 @@ class deque : protected deque_base
          this->priv_push_front_simple_commit();
       }
       else{
-         this->priv_insert_aux(cbegin(), size_type(1), t);
+         this->insert(cbegin(), size_type(1), t);
       }
    }
 
@@ -1544,7 +1615,7 @@ class deque : protected deque_base
          this->priv_push_front_simple_commit();
       }
       else{
-         this->priv_insert_aux(cbegin(), move_it(r_iterator(t, 1)), move_it(r_iterator()));
+         this->insert(cbegin(), move_it(r_iterator(t, 1)), move_it(r_iterator()));
       }
    }
 
@@ -1556,7 +1627,7 @@ class deque : protected deque_base
          this->priv_push_back_simple_commit();
       }
       else{
-         this->priv_insert_aux(cend(), size_type(1), t);
+         this->insert(cend(), size_type(1), t);
       }
    }
 
@@ -1568,7 +1639,7 @@ class deque : protected deque_base
          this->priv_push_back_simple_commit();
       }
       else{
-         this->priv_insert_aux(cend(), move_it(r_iterator(t, 1)), move_it(r_iterator()));
+         this->insert(cend(), move_it(r_iterator(t, 1)), move_it(r_iterator()));
       }
    }
 
@@ -1600,50 +1671,6 @@ class deque : protected deque_base
    void priv_push_front_simple_commit()
    {  --this->members_.m_start.m_cur;   }
 
-   template 
-   void priv_insert_aux(const_iterator pos, InpIt first, InpIt last, std::input_iterator_tag)
-   {
-      iterator it(pos);
-      for(;first != last; ++first){
-         it = this->emplace(it, *first);
-         ++it;
-      }
-   }
-
-   template 
-   void priv_insert_aux(const_iterator pos, FwdIt first, FwdIt last, std::forward_iterator_tag)
-   {  this->priv_insert_aux(pos, first, last);  }
-
-  // assign(), a generalized assignment member function.  Two
-  // versions: one that takes a count, and one that takes a range.
-  // The range version is a member template, so we dispatch on whether
-  // or not the type is an integer.
-   void priv_fill_assign(size_type n, const T& val)
-   {
-      if (n > size()) {
-         std::fill(begin(), end(), val);
-         this->insert(cend(), n - size(), val);
-      }
-      else {
-         this->erase(cbegin() + n, cend());
-         std::fill(begin(), end(), val);
-      }
-   }
-
-   template 
-   void priv_initialize_dispatch(Integer n, Integer x, container_detail::true_)
-   {
-      this->priv_initialize_map(n);
-      this->priv_fill_initialize(x);
-   }
-
-   template 
-   void priv_initialize_dispatch(InpIt first, InpIt last, container_detail::false_)
-   {
-      typedef typename std::iterator_traits::iterator_category ItCat;
-      this->priv_range_initialize(first, last, ItCat());
-   }
-
    void priv_destroy_range(iterator p, iterator p2)
    {
       for(;p != p2; ++p){
@@ -1664,71 +1691,10 @@ class deque : protected deque_base
       }
    }
 
-   template 
-   void priv_assign_dispatch(Integer n, Integer val, container_detail::true_)
-      { this->priv_fill_assign((size_type) n, (value_type)val); }
-
-   template 
-   void priv_assign_dispatch(InpIt first, InpIt last, container_detail::false_)
-   {
-      typedef typename std::iterator_traits::iterator_category ItCat;
-      this->priv_assign_aux(first, last, ItCat());
-   }
-
-   template 
-   void priv_assign_aux(InpIt first, InpIt last, std::input_iterator_tag)
-   {
-      iterator cur = begin();
-      for ( ; first != last && cur != end(); ++cur, ++first)
-         *cur = *first;
-      if (first == last)
-         this->erase(cur, cend());
-      else
-         this->insert(cend(), first, last);
-   }
-
-   template 
-   void priv_assign_aux(FwdIt first, FwdIt last, std::forward_iterator_tag)
-   {
-      size_type len = std::distance(first, last);
-      if (len > size()) {
-         FwdIt mid = first;
-         std::advance(mid, size());
-         boost::copy_or_move(first, mid, begin());
-         this->insert(cend(), mid, last);
-      }
-      else
-         this->erase(boost::copy_or_move(first, last, begin()), cend());
-   }
-
-   template 
-   void priv_insert_dispatch(const_iterator pos, Integer n, Integer x, container_detail::true_)
-   {  this->priv_fill_insert(pos, (size_type) n, (value_type)x); }
-
-   template 
-   void priv_insert_dispatch(const_iterator pos,InpIt first, InpIt last, container_detail::false_)
-   {
-      typedef typename std::iterator_traits::iterator_category ItCat;
-      this->priv_insert_aux(pos, first, last, ItCat());
-   }
-
-   void priv_insert_aux(const_iterator pos, size_type n, const value_type& x)
-   {
-      typedef constant_iterator c_it;
-      this->priv_insert_aux(pos, c_it(x, n), c_it());
-   }
-
-   //Just forward all operations to priv_insert_aux_impl
-   template 
-   void priv_insert_aux(const_iterator p, FwdIt first, FwdIt last)
-   {
-      container_detail::advanced_insert_aux_proxy proxy(this->alloc(), first, last);
-      priv_insert_aux_impl(p, (size_type)std::distance(first, last), proxy);
-   }
-
-   void priv_insert_aux_impl(const_iterator p, size_type n, advanced_insert_aux_int_t &interf)
+   iterator priv_insert_aux_impl(const_iterator p, size_type n, advanced_insert_aux_int_t &interf)
    {
       iterator pos(p);
+      const size_type pos_n = p - this->cbegin();
       if(!this->members_.m_map){
          this->priv_initialize_map(0);
          pos = this->begin();
@@ -1782,9 +1748,10 @@ class deque : protected deque_base
             interf.copy_remaining_to(pos);
          }
       }
+      return this->begin() + pos_n;
    }
 
-   void priv_insert_back_aux_impl(size_type n, advanced_insert_aux_int_t &interf)
+   iterator priv_insert_back_aux_impl(size_type n, advanced_insert_aux_int_t &interf)
    {
       if(!this->members_.m_map){
          this->priv_initialize_map(0);
@@ -1794,9 +1761,10 @@ class deque : protected deque_base
       iterator old_finish = this->members_.m_finish;
       interf.uninitialized_copy_some_and_update(old_finish, n, true);
       this->members_.m_finish = new_finish;
+      return iterator(this->members_.m_finish - n);
    }
 
-   void priv_insert_front_aux_impl(size_type n, advanced_insert_aux_int_t &interf)
+   iterator priv_insert_front_aux_impl(size_type n, advanced_insert_aux_int_t &interf)
    {
       if(!this->members_.m_map){
          this->priv_initialize_map(0);
@@ -1805,13 +1773,13 @@ class deque : protected deque_base
       iterator new_start = this->priv_reserve_elements_at_front(n);
       interf.uninitialized_copy_some_and_update(new_start, difference_type(n), true);
       this->members_.m_start = new_start;
+      return new_start;
    }
 
-
-   void priv_fill_insert(const_iterator pos, size_type n, const value_type& x)
+   iterator priv_fill_insert(const_iterator pos, size_type n, const value_type& x)
    {
       typedef constant_iterator c_it;
-      this->insert(pos, c_it(x, n), c_it());
+      return this->insert(pos, c_it(x, n), c_it());
    }
 
    // Precondition: this->members_.m_start and this->members_.m_finish have already been initialized,
@@ -1834,13 +1802,13 @@ class deque : protected deque_base
       BOOST_CATCH_END
    }
 
-   template 
-   void priv_range_initialize(InpIt first, InpIt last, std::input_iterator_tag)
+   template 
+   void priv_range_initialize(InIt first, InIt last, std::input_iterator_tag)
    {
       this->priv_initialize_map(0);
       BOOST_TRY {
          for ( ; first != last; ++first)
-            this->push_back(*first);
+            this->emplace_back(*first);
       }
       BOOST_CATCH(...){
          this->clear();
diff --git a/include/boost/container/detail/advanced_insert_int.hpp b/include/boost/container/detail/advanced_insert_int.hpp
index a97af28..e7adcd2 100644
--- a/include/boost/container/detail/advanced_insert_int.hpp
+++ b/include/boost/container/detail/advanced_insert_int.hpp
@@ -173,7 +173,6 @@ struct default_construct_aux_proxy
 #ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
 #include 
-#include 
 #include 
 #include 
 //#include  //For debugging purposes
@@ -227,8 +226,7 @@ struct advanced_insert_aux_non_movable_emplace
          if(!this->used_){
             alloc_traits::construct( this->a_
                                    , container_detail::to_raw_pointer(&*p)
-                                   , ::boost::container::container_detail::
-                                       stored_ref::forward(get(this->args_))...
+                                   , ::boost::forward(get(this->args_))...
                                    );
             this->used_ = true;
          }
@@ -241,8 +239,7 @@ struct advanced_insert_aux_non_movable_emplace
       if(!this->used_){
          alloc_traits::construct( this->a_
                                 , container_detail::to_raw_pointer(&*p)
-                                , ::boost::container::container_detail::
-                                    stored_ref::forward(get(this->args_))...
+                                  , ::boost::forward(get(this->args_))...
                                 );
          this->used_ = true;
       }
@@ -288,7 +285,7 @@ struct advanced_insert_aux_emplace
          aligned_storage::value> v;
          value_type *vp = static_cast(static_cast(&v));
          alloc_traits::construct(this->a_, vp,
-            ::boost::container::container_detail::stored_ref::forward(get(this->args_))...);
+            ::boost::forward(get(this->args_))...);
          scoped_destructor d(this->a_, vp);
          *p = ::boost::move(*vp);
          d.release();
@@ -305,7 +302,7 @@ struct advanced_insert_aux_emplace
             aligned_storage::value> v;
             value_type *vp = static_cast(static_cast(&v));
             alloc_traits::construct(this->a_, vp,
-               ::boost::container::container_detail::stored_ref::forward(get(this->args_))...);
+               ::boost::forward(get(this->args_))...);
             try {
                *p = ::boost::move(*vp);
             } catch (...) {
@@ -413,7 +410,7 @@ struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)
          alloc_traits::construct(this->a_, vp                                       \
             BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _));       \
          scoped_destructor d(this->a_, vp);                                      \
-         *p = ::boost::move(*vp);                                                     \
+         *p = ::boost::move(*vp);                                                   \
          d.release();                                                               \
          this->used_ = true;                                                        \
       }                                                                             \
@@ -430,7 +427,7 @@ struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)
             alloc_traits::construct(this->a_, vp                                    \
                BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _));    \
             scoped_destructor d(this->a_, vp);                                   \
-            *p = ::boost::move(*vp);                                                  \
+            *p = ::boost::move(*vp);                                                \
             d.release();                                                            \
             this->used_ = true;                                                     \
          }                                                                          \
diff --git a/include/boost/container/detail/algorithms.hpp b/include/boost/container/detail/algorithms.hpp
index dc09575..824e44b 100644
--- a/include/boost/container/detail/algorithms.hpp
+++ b/include/boost/container/detail/algorithms.hpp
@@ -34,6 +34,30 @@
 namespace boost {
 namespace container {
 
+template
+struct is_default_construct_iterator
+{
+   static const bool value = false;
+};
+
+template
+struct is_default_construct_iterator >
+{
+   static const bool value = true;
+};
+
+template
+struct is_emplace_iterator
+{
+   static const bool value = false;
+};
+
+template
+struct is_emplace_iterator >
+{
+   static const bool value = true;
+};
+
 template
 inline void construct_in_place(A &a, T* dest, InpIt source)
 {     boost::container::allocator_traits::construct(a, dest, *source);  }
diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp
index 23be0bf..55fac62 100644
--- a/include/boost/container/detail/flat_tree.hpp
+++ b/include/boost/container/detail/flat_tree.hpp
@@ -214,6 +214,21 @@ class flat_tree
       : m_data(comp, a)
    { this->m_data.m_vect.insert(this->m_data.m_vect.end(), first, last); }
 
+   template 
+   flat_tree( bool unique_insertion
+            , InputIterator first, InputIterator last
+            , const Compare& comp     = Compare()
+            , const allocator_type& a = allocator_type())
+      : m_data(comp, a)
+   {
+      if(unique_insertion){
+         this->insert_unique(first, last);
+      }
+      else{
+         this->insert_equal(first, last);
+      }
+   }
+
    ~flat_tree()
    { }
 
@@ -290,9 +305,9 @@ class flat_tree
    std::pair insert_unique(const value_type& val)
    {
       insert_commit_data data;
-      std::pair ret = priv_insert_unique_prepare(val, data);
+      std::pair ret = this->priv_insert_unique_prepare(val, data);
       if(ret.second){
-         ret.first = priv_insert_commit(data, val);
+         ret.first = this->priv_insert_commit(data, val);
       }
       return ret;
    }
@@ -300,9 +315,9 @@ class flat_tree
    std::pair insert_unique(BOOST_RV_REF(value_type) val)
    {
       insert_commit_data data;
-      std::pair ret = priv_insert_unique_prepare(val, data);
+      std::pair ret = this->priv_insert_unique_prepare(val, data);
       if(ret.second){
-         ret.first = priv_insert_commit(data, boost::move(val));
+         ret.first = this->priv_insert_commit(data, boost::move(val));
       }
       return ret;
    }
@@ -324,9 +339,9 @@ class flat_tree
    iterator insert_unique(const_iterator pos, const value_type& val)
    {
       insert_commit_data data;
-      std::pair ret = priv_insert_unique_prepare(pos, val, data);
+      std::pair ret = this->priv_insert_unique_prepare(pos, val, data);
       if(ret.second){
-         ret.first = priv_insert_commit(data, val);
+         ret.first = this->priv_insert_commit(data, val);
       }
       return ret.first;
    }
@@ -334,9 +349,9 @@ class flat_tree
    iterator insert_unique(const_iterator pos, BOOST_RV_REF(value_type) mval)
    {
       insert_commit_data data;
-      std::pair ret = priv_insert_unique_prepare(pos, mval, data);
+      std::pair ret = this->priv_insert_unique_prepare(pos, mval, data);
       if(ret.second){
-         ret.first = priv_insert_commit(data, boost::move(mval));
+         ret.first = this->priv_insert_commit(data, boost::move(mval));
       }
       return ret.first;
    }
@@ -345,45 +360,164 @@ class flat_tree
    {
       insert_commit_data data;
       this->priv_insert_equal_prepare(pos, val, data);
-      return priv_insert_commit(data, val);
+      return this->priv_insert_commit(data, val);
    }
 
    iterator insert_equal(const_iterator pos, BOOST_RV_REF(value_type) mval)
    {
       insert_commit_data data;
       this->priv_insert_equal_prepare(pos, mval, data);
-      return priv_insert_commit(data, boost::move(mval));
+      return this->priv_insert_commit(data, boost::move(mval));
    }
 
    template 
    void insert_unique(InIt first, InIt last)
+   {  this->priv_insert_unique_loop(first, last); }
+
+   template 
+   void insert_equal(InIt first, InIt last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < container_detail::is_input_iterator::value
+         >::type * = 0
+      #endif
+      )
+   {  this->priv_insert_equal_loop(first, last);  }
+
+   template 
+   void insert_equal(InIt first, InIt last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_input_iterator::value
+         >::type * = 0
+      #endif
+      )
    {
-      for ( ; first != last; ++first)
-         this->insert_unique(*first);
+      const size_type len = static_cast(std::distance(first, last));
+      this->reserve(this->size()+len);
+      this->priv_insert_equal_loop(first, last);
+   }
+
+   //Ordered
+
+   template 
+   void insert_equal(ordered_range_t, InIt first, InIt last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < container_detail::is_input_iterator::value
+         >::type * = 0
+      #endif
+      )
+   {  this->priv_insert_equal_loop_ordered(first, last); }
+
+   template 
+   void insert_equal(ordered_range_t, FwdIt first, FwdIt last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < container_detail::is_forward_iterator::value
+         >::type * = 0
+      #endif
+      )
+   {
+      const size_type len = static_cast(std::distance(first, last));
+      this->reserve(this->size()+len);
+      this->priv_insert_equal_loop_ordered(first, last);
+   }
+
+   template 
+   void insert_equal(ordered_range_t, BidirIt first, BidirIt last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_input_iterator::value &&
+           !container_detail::is_forward_iterator::value
+         >::type * = 0
+      #endif
+      )
+   {
+      size_type len = static_cast(std::distance(first, last));
+      const size_type BurstSize = 16;
+      size_type positions[BurstSize];
+
+      //Prereserve all memory so that iterators are not invalidated
+      this->reserve(this->size()+len);
+      const const_iterator beg(this->cbegin());
+      const_iterator pos(beg);
+      //Loop in burst sizes
+      while(len){
+         const size_type burst = len < BurstSize ? len : BurstSize;
+         const const_iterator cend(this->cend());
+         len -= burst;
+         for(size_type i = 0; i != burst; ++i){
+            //Get the insertion position for each key
+            pos = const_cast(*this).priv_upper_bound(pos, cend, KeyOfValue()(*first));
+            positions[i] = static_cast(pos - beg);
+            ++first;
+         }
+         //Insert all in a single step in the precalculated positions
+         this->m_data.m_vect.insert_ordered_at(burst, positions + burst, first);
+         //Next search position updated
+         pos += burst;
+      }
    }
 
    template 
-   void insert_equal(InIt first, InIt last)
-   {
-      typedef typename
-         std::iterator_traits::iterator_category ItCat;
-      this->priv_insert_equal(first, last, ItCat());
-   }
+   void insert_unique(ordered_unique_range_t, InIt first, InIt last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < container_detail::is_input_iterator::value ||
+           container_detail::is_forward_iterator::value
+         >::type * = 0
+      #endif
+      )
+   {  this->priv_insert_unique_loop_hint(first, last);  }
 
-   template 
-   void insert_equal(ordered_range_t, InIt first, InIt last)
+   template 
+   void insert_unique(ordered_unique_range_t, BidirIt first, BidirIt last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !(container_detail::is_input_iterator::value ||
+             container_detail::is_forward_iterator::value)
+         >::type * = 0
+      #endif
+      )
    {
-      typedef typename
-         std::iterator_traits::iterator_category ItCat;
-      this->priv_insert_equal(ordered_range_t(), first, last, ItCat());
-   }
+      size_type len = static_cast(std::distance(first, last));
+      const size_type BurstSize = 16;
+      size_type positions[BurstSize];
+      size_type skips[BurstSize];
 
-   template 
-   void insert_unique(ordered_unique_range_t, InIt first, InIt last)
-   {
-      typedef typename
-         std::iterator_traits::iterator_category ItCat;
-      this->priv_insert_unique(ordered_unique_range_t(), first, last, ItCat());
+      //Prereserve all memory so that iterators are not invalidated
+      this->reserve(this->size()+len);
+      const const_iterator beg(this->cbegin());
+      const_iterator pos(beg);
+      const value_compare &value_comp = this->m_data;
+      //Loop in burst sizes
+      while(len){
+         skips[0u] = 0u;
+         const size_type burst = len < BurstSize ? len : BurstSize;
+         size_type unique_burst = 0u;
+         const const_iterator cend(this->cend());
+         while(unique_burst < burst && len > 0){
+            //Get the insertion position for each key
+            const value_type & val = *first++;
+            --len;
+            pos = const_cast(*this).priv_lower_bound(pos, cend, KeyOfValue()(val));
+            //Check if already present
+            if(pos != cend && !value_comp(*pos, val)){
+               ++skips[unique_burst];
+               continue;
+            }
+
+            //If not present, calculate position
+            positions[unique_burst] = static_cast(pos - beg);
+            if(++unique_burst < burst)
+               skips[unique_burst] = 0u;
+         }
+         //Insert all in a single step in the precalculated positions
+         this->m_data.m_vect.insert_ordered_at(unique_burst, positions + unique_burst, skips + unique_burst, first);
+         //Next search position updated
+         pos += unique_burst;
+      }
    }
 
    #ifdef BOOST_CONTAINER_PERFECT_FORWARDING
@@ -398,9 +532,9 @@ class flat_tree
       value_destructor d(a, val);
       insert_commit_data data;
       std::pair ret =
-         priv_insert_unique_prepare(val, data);
+         this->priv_insert_unique_prepare(val, data);
       if(ret.second){
-         ret.first = priv_insert_commit(data, boost::move(val));
+         ret.first = this->priv_insert_commit(data, boost::move(val));
       }
       return ret;
    }
@@ -414,9 +548,9 @@ class flat_tree
       stored_allocator_traits::construct(a, &val, ::boost::forward(args)... );
       value_destructor d(a, val);
       insert_commit_data data;
-      std::pair ret = priv_insert_unique_prepare(hint, val, data);
+      std::pair ret = this->priv_insert_unique_prepare(hint, val, data);
       if(ret.second){
-         ret.first = priv_insert_commit(data, boost::move(val));
+         ret.first = this->priv_insert_commit(data, boost::move(val));
       }
       return ret.first;
    }
@@ -444,7 +578,7 @@ class flat_tree
       value_destructor d(a, val);
       insert_commit_data data;
       this->priv_insert_equal_prepare(hint, val, data);
-      iterator i = priv_insert_commit(data, boost::move(val));
+      iterator i = this->priv_insert_commit(data, boost::move(val));
       return i;
    }
 
@@ -462,9 +596,9 @@ class flat_tree
          BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) );                \
       value_destructor d(a, val);                                  \
       insert_commit_data data;                                                            \
-      std::pair ret = priv_insert_unique_prepare(val, data);               \
+      std::pair ret = this->priv_insert_unique_prepare(val, data);         \
       if(ret.second){                                                                     \
-         ret.first = priv_insert_commit(data, boost::move(val));                          \
+         ret.first = this->priv_insert_commit(data, boost::move(val));                    \
       }                                                                                   \
       return ret;                                                                         \
    }                                                                                      \
@@ -480,9 +614,9 @@ class flat_tree
          BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) );                \
       value_destructor d(a,  val);                                 \
       insert_commit_data data;                                                            \
-      std::pair ret = priv_insert_unique_prepare(hint, val, data);         \
+      std::pair ret = this->priv_insert_unique_prepare(hint, val, data);   \
       if(ret.second){                                                                     \
-         ret.first = priv_insert_commit(data, boost::move(val));                          \
+         ret.first = this->priv_insert_commit(data, boost::move(val));                    \
       }                                                                                   \
       return ret.first;                                                                   \
    }                                                                                      \
@@ -513,7 +647,7 @@ class flat_tree
       value_destructor d(a,  val);                                 \
       insert_commit_data data;                                                            \
       this->priv_insert_equal_prepare(hint, val, data);                                   \
-      iterator i = priv_insert_commit(data, boost::move(val));                            \
+      iterator i = this->priv_insert_commit(data, boost::move(val));                      \
       return i;                                                                           \
    }                                                                                      \
 
@@ -653,7 +787,7 @@ class flat_tree
 
    std::pair priv_insert_unique_prepare
       (const value_type& val, insert_commit_data &commit_data)
-   {  return priv_insert_unique_prepare(this->begin(), this->end(), val, commit_data);   }
+   {  return this->priv_insert_unique_prepare(this->begin(), this->end(), val, commit_data);   }
 
    std::pair priv_insert_unique_prepare
       (const_iterator pos, const value_type& val, insert_commit_data &commit_data)
@@ -794,102 +928,38 @@ class flat_tree
       return std::pair(first, first);
    }
 
-   template 
-   void priv_insert_equal(ordered_range_t, BidirIt first, BidirIt last, std::bidirectional_iterator_tag)
+   template
+   void priv_insert_equal_loop(InIt first, InIt last)
    {
-      size_type len = static_cast(std::distance(first, last));
-      const size_type BurstSize = 16;
-      size_type positions[BurstSize];
-
-      //Prereserve all memory so that iterators are not invalidated
-      this->reserve(this->size()+len);
-      const const_iterator beg(this->cbegin());
-      const_iterator pos(beg);
-      //Loop in burst sizes
-      while(len){
-         const size_type burst = len < BurstSize ? len : BurstSize;
-         const const_iterator cend(this->cend());
-         len -= burst;
-         for(size_type i = 0; i != burst; ++i){
-            //Get the insertion position for each key
-            pos = const_cast(*this).priv_upper_bound(pos, cend, KeyOfValue()(*first));
-            positions[i] = static_cast(pos - beg);
-            ++first;
-         }
-         //Insert all in a single step in the precalculated positions
-         this->m_data.m_vect.insert_ordered_at(burst, positions + burst, first);
-         //Next search position updated
-         pos += burst;
-      }
-   }
-
-   template 
-   void priv_insert_unique(ordered_unique_range_t, BidirIt first, BidirIt last, std::bidirectional_iterator_tag)
-   {
-      size_type len = static_cast(std::distance(first, last));
-      const size_type BurstSize = 16;
-      size_type positions[BurstSize];
-      size_type skips[BurstSize];
-
-      //Prereserve all memory so that iterators are not invalidated
-      this->reserve(this->size()+len);
-      const const_iterator beg(this->cbegin());
-      const_iterator pos(beg);
-      const value_compare &value_comp = this->m_data;
-      //Loop in burst sizes
-      while(len){
-         skips[0u] = 0u;
-         const size_type burst = len < BurstSize ? len : BurstSize;
-         size_type unique_burst = 0u;
-         const const_iterator cend(this->cend());
-         while(unique_burst < burst && len > 0){
-            //Get the insertion position for each key
-            const value_type & val = *first++;
-            --len;
-            pos = const_cast(*this).priv_lower_bound(pos, cend, KeyOfValue()(val));
-            //Check if already present
-            if(pos != cend && !value_comp(*pos, val)){
-               ++skips[unique_burst];
-               continue;
-            }
-
-            //If not present, calculate position
-            positions[unique_burst] = static_cast(pos - beg);
-            if(++unique_burst < burst)
-               skips[unique_burst] = 0u;
-         }
-         //Insert all in a single step in the precalculated positions
-         this->m_data.m_vect.insert_ordered_at(unique_burst, positions + unique_burst, skips + unique_burst, first);
-         //Next search position updated
-         pos += unique_burst;
-      }
-   }
-/*
-   template 
-   void priv_insert_equal_forward(ordered_range_t, FwdIt first, FwdIt last, std::forward_iterator_tag)
-   {  this->priv_insert_equal(first, last, std::forward_iterator_tag());   }
-*/
-   template 
-   void priv_insert_equal(ordered_range_t, InIt first, InIt last, std::input_iterator_tag)
-   {  this->priv_insert_equal(first, last, std::input_iterator_tag());  }
-
-   template 
-   void priv_insert_unique(ordered_unique_range_t, InIt first, InIt last, std::input_iterator_tag)
-   {  this->priv_insert_unique(first, last, std::input_iterator_tag());  }
-/*
-   template 
-   void priv_insert_equal_forward(FwdIt first, FwdIt last, std::forward_iterator_tag)
-   {
-      const size_type len = static_cast(std::distance(first, last));
-      this->reserve(this->size()+len);
-      this->priv_insert_equal(first, last, std::input_iterator_tag());
-   }
-*/
-   template 
-   void priv_insert_equal(InIt first, InIt last, std::input_iterator_tag)
-   {
-      for ( ; first != last; ++first)
+      for ( ; first != last; ++first){
          this->insert_equal(*first);
+      }
+   }
+
+   template
+   void priv_insert_equal_loop_ordered(InIt first, InIt last)
+   {
+      const_iterator pos(this->cend());
+      for ( ; first != last; ++first){
+         pos = this->insert_equal(pos, *first);
+      }
+   }
+
+   template
+   void priv_insert_unique_loop(InIt first, InIt last)
+   {
+      for ( ; first != last; ++first){
+         this->insert_unique(*first);
+      }
+   }
+
+   template
+   void priv_insert_unique_loop_ordered(InIt first, InIt last)
+   {
+      const_iterator pos(this->cend());
+      for ( ; first != last; ++first){
+         pos = this->insert_unique(pos, *first);
+      }
    }
 };
 
diff --git a/include/boost/container/detail/iterators.hpp b/include/boost/container/detail/iterators.hpp
index 374b55c..78a0dda 100644
--- a/include/boost/container/detail/iterators.hpp
+++ b/include/boost/container/detail/iterators.hpp
@@ -22,10 +22,10 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 #include 
-#include 
 #else
 #include 
 #endif
@@ -222,14 +222,12 @@ class default_construct_iterator
    default_construct_iterator operator-(Difference off) const
    {  return *this + (-off);  }
 
-   const T& operator*() const
-   { return dereference(); }
-
-   const T* operator->() const
-   { return &(dereference()); }
-
-   const T& operator[] (Difference n) const
-   { return dereference(); }
+   //This pseudo-iterator's dereference operations have no sense since value is not
+   //constructed until ::boost::container::construct_in_place is called.
+   //So comment them to catch bad uses
+   //const T& operator*() const;
+   //const T& operator[](difference_type) const;
+   //const T* operator->() const;
 
    private:
    Difference  m_num;
@@ -445,14 +443,12 @@ class emplace_iterator
    this_type operator-(difference_type off) const
    {  return *this + (-off);  }
 
-   const T& operator*() const
-   { return dereference(); }
-
-   const T& operator[](difference_type) const
-   { return dereference(); }
-
-   const T* operator->() const
-   { return &(dereference()); }
+   //This pseudo-iterator's dereference operations have no sense since value is not
+   //constructed until ::boost::container::construct_in_place is called.
+   //So comment them to catch bad uses
+   //const T& operator*() const;
+   //const T& operator[](difference_type) const;
+   //const T* operator->() const;
 
    template
    void construct_in_place(A &a, T* ptr)
@@ -506,8 +502,7 @@ struct emplace_functor
    void inplace_impl(A &a, T* ptr, const container_detail::index_tuple&)
    {
       allocator_traits::construct
-         (a, ptr, container_detail::stored_ref::forward
-          (container_detail::get(args_))...);
+         (a, ptr, ::boost::forward(container_detail::get(args_))...);
    }
 
    container_detail::tuple args_;
@@ -539,6 +534,59 @@ struct emplace_functor
 
 #endif
 
+namespace container_detail {
+
+template
+struct has_iterator_category
+{
+   template 
+   static char test(int, typename X::iterator_category*);
+
+   template 
+   static int test(int, ...);
+
+   static const bool value = (1 == sizeof(test(0, 0)));
+};
+
+
+template::value >
+struct is_input_iterator
+{
+   static const bool value = is_same::value;
+};
+
+template
+struct is_input_iterator
+{
+   static const bool value = false;
+};
+
+template::value >
+struct is_forward_iterator
+{
+   static const bool value = is_same::value;
+};
+
+template
+struct is_forward_iterator
+{
+   static const bool value = false;
+};
+
+template::value >
+struct is_bidirectional_iterator
+{
+   static const bool value = is_same::value;
+};
+
+template
+struct is_bidirectional_iterator
+{
+   static const bool value = false;
+};
+
+}  //namespace container_detail {
+
 }  //namespace container {
 }  //namespace boost {
 
diff --git a/include/boost/container/detail/preprocessor.hpp b/include/boost/container/detail/preprocessor.hpp
index 1818094..5129ea1 100644
--- a/include/boost/container/detail/preprocessor.hpp
+++ b/include/boost/container/detail/preprocessor.hpp
@@ -16,11 +16,6 @@
 #endif
 
 #include 
-
-#ifndef BOOST_NO_RVALUE_REFERENCES
-#include 
-#endif   //#ifndef BOOST_NO_RVALUE_REFERENCES
-
 #include 
 
 #ifdef BOOST_CONTAINER_PERFECT_FORWARDING
@@ -78,19 +73,10 @@ const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \
 
 #ifndef BOOST_NO_RVALUE_REFERENCES
 
-   #if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
-
-   #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \
-   BOOST_PP_CAT(m_p, n) (static_cast( BOOST_PP_CAT(p, n) ))           \
-
-   #else //#if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
-
    #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \
    BOOST_PP_CAT(m_p, n) (::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) ))           \
    //!
 
-   #endif   //BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
-
 #else //BOOST_NO_RVALUE_REFERENCES
 
    #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \
@@ -102,8 +88,68 @@ const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \
 
    #if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
 
+      namespace boost {
+      namespace container {
+      namespace container_detail {
+         template
+         struct ref_holder;
+
+         template
+         struct ref_holder
+         {
+            ref_holder(T &t)
+               : t_(t)
+            {}
+            T &t_;
+            T & get() {  return t_;   }
+         };
+
+         template
+         struct ref_holder
+         {
+            ref_holder(const T &t)
+               : t_(t)
+            {}
+            const T &t_;
+            const T & get() {  return t_;   }
+         };
+
+         template
+         struct ref_holder
+         {
+            ref_holder(const T &t)
+               : t_(t)
+            {}
+            const T &t_;
+            const T & get() {  return t_;   }
+         };
+
+         template
+         struct ref_holder
+         {
+            ref_holder(T &&t)
+               : t_(t)
+            {}
+            T &t_;
+            T && get() {  return ::boost::move(t_);   }
+         };
+
+         template
+         struct ref_holder
+         {
+            ref_holder(T &&t)
+               : t(t)
+            {}
+            T &t;
+            T && get()  { return ::boost::move(t_); }
+         };
+
+      }  //namespace container_detail {
+      }  //namespace container {
+      }  //namespace boost {
+
       #define BOOST_CONTAINER_PP_PARAM_DEFINE(z, n, data)  \
-      BOOST_PP_CAT(P, n) & BOOST_PP_CAT(m_p, n);            \
+         ::boost::container::container_detail::ref_holder BOOST_PP_CAT(m_p, n);  \
       //!
 
    #else //BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG
@@ -123,8 +169,7 @@ const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \
 
 #if !defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
 
-   #define BOOST_CONTAINER_PP_MEMBER_FORWARD(z, n, data) \
-   ::boost::container::container_detail::stored_ref< BOOST_PP_CAT(P, n) >::forward( BOOST_PP_CAT(this->m_p, n) ) \
+   #define BOOST_CONTAINER_PP_MEMBER_FORWARD(z, n, data) BOOST_PP_CAT(this->m_p, n).get() \
    //!
 
 #else //!defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
diff --git a/include/boost/container/detail/stored_ref.hpp b/include/boost/container/detail/stored_ref.hpp
deleted file mode 100644
index 80fda89..0000000
--- a/include/boost/container/detail/stored_ref.hpp
+++ /dev/null
@@ -1,92 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Ion Gaztanaga 2008-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)
-//
-// See http://www.boost.org/libs/container for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef BOOST_CONTAINER_DETAIL_STORED_REF_HPP
-#define BOOST_CONTAINER_DETAIL_STORED_REF_HPP
-
-#include "config_begin.hpp"
-#include 
-
-#ifndef BOOST_NO_RVALUE_REFERENCES
-
-namespace boost{
-namespace container{
-namespace container_detail{
-
-template
-struct stored_ref
-{
-
-   static T && forward(T &t)
-   #ifdef BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
-   { return t; }
-   #else
-   { return boost::move(t); }
-   #endif
-};
-
-template
-struct stored_ref
-{
-   static const T && forward(const T &t)
-   #ifdef BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
-   { return t; }
-   #else
-   { return static_cast(t); }
-   #endif
-};
-
-template
-struct stored_ref
-{
-   static T && forward(T &t)
-   #ifdef BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
-   { return t; }
-   #else
-   { return boost::move(t); }
-   #endif
-};
-
-template
-struct stored_ref
-{
-   static const T && forward(const T &t)
-   #ifdef BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
-   { return t; }
-   #else
-   { return static_cast(t); }
-   #endif
-};
-
-template
-struct stored_ref
-{
-   static const T & forward(const T &t)
-   {  return t; }
-};
-
-template
-struct stored_ref
-{
-   static T & forward(T &t)
-   {  return t; }
-};
-
-}  //namespace container_detail{
-}  //namespace container{
-}  //namespace boost{
-
-#else
-#error "This header can be included only for compiler with rvalue references"
-#endif   //BOOST_NO_RVALUE_REFERENCES
-
-#include 
-
-#endif   //BOOST_CONTAINER_DETAIL_STORED_REF_HPP
diff --git a/include/boost/container/detail/tree.hpp b/include/boost/container/detail/tree.hpp
index 3ab1536..96db26f 100644
--- a/include/boost/container/detail/tree.hpp
+++ b/include/boost/container/detail/tree.hpp
@@ -476,21 +476,77 @@ class rbtree
    {}
 
    template 
-   rbtree(InputIterator first, InputIterator last, const key_compare& comp,
-          const allocator_type& a, bool unique_insertion)
+   rbtree(bool unique_insertion, InputIterator first, InputIterator last, const key_compare& comp,
+          const allocator_type& a
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < container_detail::is_input_iterator::value
+            || container_detail::is_same::value
+         >::type * = 0
+      #endif
+         )
       : AllocHolder(a, comp)
    {
-      typedef typename std::iterator_traits::iterator_category ItCat;
-      priv_create_and_insert_nodes(first, last, unique_insertion, alloc_version(), ItCat());
+      if(unique_insertion){
+         this->insert_unique(first, last);
+      }
+      else{
+         this->insert_equal(first, last);
+      }
+   }
+
+   template 
+   rbtree(bool unique_insertion, InputIterator first, InputIterator last, const key_compare& comp,
+          const allocator_type& a
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !(container_detail::is_input_iterator::value
+            || container_detail::is_same::value)
+         >::type * = 0
+      #endif
+         )
+      : AllocHolder(a, comp)
+   {
+      if(unique_insertion){
+         this->insert_unique(first, last);
+      }
+      else{
+         //Optimized allocation and construction
+         this->allocate_many_and_construct
+            (first, std::distance(first, last), insert_equal_end_hint_functor(this->icont()));
+      }
    }
 
    template 
    rbtree( ordered_range_t, InputIterator first, InputIterator last
-         , const key_compare& comp = key_compare(), const allocator_type& a = allocator_type())
+         , const key_compare& comp = key_compare(), const allocator_type& a = allocator_type()
+         #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+         , typename container_detail::enable_if_c
+            < container_detail::is_input_iterator::value
+               || container_detail::is_same::value
+            >::type * = 0
+         #endif
+         )
       : AllocHolder(a, comp)
    {
-      typedef typename std::iterator_traits::iterator_category ItCat;
-      priv_create_and_insert_ordered_nodes(first, last, alloc_version(), ItCat());
+      this->insert_equal(first, last);
+   }
+
+   template 
+   rbtree( ordered_range_t, InputIterator first, InputIterator last
+         , const key_compare& comp = key_compare(), const allocator_type& a = allocator_type()
+         #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+         , typename container_detail::enable_if_c
+            < !(container_detail::is_input_iterator::value
+               || container_detail::is_same::value)
+            >::type * = 0
+         #endif
+         )
+      : AllocHolder(a, comp)
+   {
+      //Optimized allocation and construction
+      this->allocate_many_and_construct
+         (first, std::distance(first, last), push_back_functor(this->icont()));
    }
 
    rbtree(const rbtree& x)
@@ -943,14 +999,14 @@ class rbtree
    {  return const_iterator(this->non_const_icont().upper_bound(k, KeyNodeCompare(value_comp())));  }
 
    std::pair equal_range(const key_type& k)
-   { 
+   {
       std::pair ret =
          this->icont().equal_range(k, KeyNodeCompare(value_comp()));
       return std::pair(iterator(ret.first), iterator(ret.second));
    }
 
    std::pair equal_range(const key_type& k) const
-   { 
+   {
       std::pair ret =
          this->non_const_icont().equal_range(k, KeyNodeCompare(value_comp()));
       return std::pair
@@ -958,108 +1014,39 @@ class rbtree
    }
 
    private:
-   //Iterator range version
-   template
-   void priv_create_and_insert_nodes
-      (InpIterator beg, InpIterator end, bool unique, allocator_v1, std::input_iterator_tag)
-   {
-      if(unique){
-         for (; beg != end; ++beg){
-            this->insert_unique(*beg);
-         }
-      }
-      else{
-         for (; beg != end; ++beg){
-            this->insert_equal(*beg);
-         }
-      }
-   }
 
-   template
-   void priv_create_and_insert_nodes
-      (InpIterator beg, InpIterator end, bool unique, allocator_v2, std::input_iterator_tag)
-   {  //Just forward to the default one
-      priv_create_and_insert_nodes(beg, end, unique, allocator_v1(), std::input_iterator_tag());
-   }
+   class insert_equal_end_hint_functor;
+   friend class insert_equal_end_hint_functor;
 
-   class insertion_functor;
-   friend class insertion_functor;
-
-   class insertion_functor
+   class insert_equal_end_hint_functor
    {
       Icont &icont_;
+      const iconst_iterator cend_;
 
       public:
-      insertion_functor(Icont &icont)
-         :  icont_(icont)
+      insert_equal_end_hint_functor(Icont &icont)
+         :  icont_(icont), cend_(this->icont_.cend())
       {}
 
       void operator()(Node &n)
-      {  this->icont_.insert_equal(this->icont_.cend(), n); }
+      {  this->icont_.insert_equal(cend_, n); }
    };
 
+   class push_back_functor;
+   friend class push_back_functor;
 
-   template
-   void priv_create_and_insert_nodes
-      (FwdIterator beg, FwdIterator end, bool unique, allocator_v2, std::forward_iterator_tag)
-   {
-      if(beg != end){
-         if(unique){
-            priv_create_and_insert_nodes(beg, end, unique, allocator_v2(), std::input_iterator_tag());
-         }
-         else{
-            //Optimized allocation and construction
-            this->allocate_many_and_construct
-               (beg, std::distance(beg, end), insertion_functor(this->icont()));
-         }
-      }
-   }
-
-   //Iterator range version
-   template
-   void priv_create_and_insert_ordered_nodes
-      (InpIterator beg, InpIterator end, allocator_v1, std::input_iterator_tag)
-   {
-      const_iterator cend_n(this->cend());
-      for (; beg != end; ++beg){
-         this->insert_before(cend_n, *beg);
-      }
-   }
-
-   template
-   void priv_create_and_insert_ordered_nodes
-      (InpIterator beg, InpIterator end, allocator_v2, std::input_iterator_tag)
-   {  //Just forward to the default one
-      priv_create_and_insert_ordered_nodes(beg, end, allocator_v1(), std::input_iterator_tag());
-   }
-
-   class back_insertion_functor;
-   friend class back_insertion_functor;
-
-   class back_insertion_functor
+   class push_back_functor
    {
       Icont &icont_;
 
       public:
-      back_insertion_functor(Icont &icont)
+      push_back_functor(Icont &icont)
          :  icont_(icont)
       {}
 
       void operator()(Node &n)
       {  this->icont_.push_back(n); }
    };
-
-
-   template
-   void priv_create_and_insert_ordered_nodes
-      (FwdIterator beg, FwdIterator end, allocator_v2, std::forward_iterator_tag)
-   {
-      if(beg != end){
-         //Optimized allocation and construction
-         this->allocate_many_and_construct
-            (beg, std::distance(beg, end), back_insertion_functor(this->icont()));
-      }
-   }
 };
 
 template 
    flat_map(InputIterator first, InputIterator last, const Pred& comp = Pred(),
          const allocator_type& a = allocator_type())
-      : m_flat_tree(comp, container_detail::force(a))
-      { m_flat_tree.insert_unique(first, last); }
+      : m_flat_tree(true, first, last, comp, container_detail::force(a))
+   {}
 
    //! Effects: Constructs an empty flat_map using the specified comparison object and
    //! allocator, and inserts elements from the ordered unique range [first ,last). This function
@@ -988,8 +988,8 @@ class flat_multimap
    flat_multimap(InputIterator first, InputIterator last,
             const Pred& comp        = Pred(),
             const allocator_type& a = allocator_type())
-      : m_flat_tree(comp, container_detail::force(a))
-      { m_flat_tree.insert_equal(first, last); }
+      : m_flat_tree(false, first, last, comp, container_detail::force(a))
+   {}
 
    //! Effects: Constructs an empty flat_multimap using the specified comparison object and
    //! allocator, and inserts elements from the ordered range [first ,last). This function
diff --git a/include/boost/container/flat_set.hpp b/include/boost/container/flat_set.hpp
index 09c95eb..513d487 100644
--- a/include/boost/container/flat_set.hpp
+++ b/include/boost/container/flat_set.hpp
@@ -125,8 +125,8 @@ class flat_set
    flat_set(InputIterator first, InputIterator last,
             const Pred& comp = Pred(),
             const allocator_type& a = allocator_type())
-      : m_flat_tree(comp, a)
-      { m_flat_tree.insert_unique(first, last); }
+      : m_flat_tree(true, first, last, comp, a)
+   {}
 
    //! Effects: Constructs an empty flat_set using the specified comparison object and
    //! allocator, and inserts elements from the ordered unique range [first ,last). This function
@@ -777,8 +777,8 @@ class flat_multiset
    flat_multiset(InputIterator first, InputIterator last,
                  const Pred& comp        = Pred(),
                  const allocator_type& a = allocator_type())
-      : m_flat_tree(comp, a)
-      { m_flat_tree.insert_equal(first, last); }
+      : m_flat_tree(false, first, last, comp, a)
+   {}
 
    //! Effects: Constructs an empty flat_multiset using the specified comparison object and
    //! allocator, and inserts elements from the ordered range [first ,last ). This function
diff --git a/include/boost/container/list.hpp b/include/boost/container/list.hpp
index c3e3562..a991860 100644
--- a/include/boost/container/list.hpp
+++ b/include/boost/container/list.hpp
@@ -660,18 +660,8 @@ class list
    //! Complexity: Linear to the difference between size() and new_size.
    void resize(size_type new_size, const T& x)
    {
-      const_iterator iend = this->cend();
-      size_type len = this->size();
-     
-      if(len > new_size){
-         size_type to_erase = len - new_size;
-         while(to_erase--){
-            --iend;
-         }
-         this->erase(iend, this->cend());
-      }
-      else{
-         this->priv_create_and_insert_nodes(iend, new_size - len, x);
+      if(!priv_try_shrink(new_size)){
+         this->insert(this->cend(), new_size - this->size(), x);
       }
    }
 
@@ -683,29 +673,9 @@ class list
    //! Complexity: Linear to the difference between size() and new_size.
    void resize(size_type new_size)
    {
-      const_iterator iend = this->end();
-      size_type len = this->size();
-     
-      if(len > new_size){
-         size_type to_erase = len - new_size;
-         const_iterator ifirst;
-         if(to_erase < len/2u){
-            ifirst = iend;
-            while(to_erase--){
-               --ifirst;
-            }
-         }
-         else{
-            ifirst = this->begin();
-            size_type to_skip = len - to_erase;
-            while(to_skip--){
-               ++ifirst;
-            }
-         }
-         this->erase(ifirst, iend);
-      }
-      else{
-         this->priv_create_and_insert_nodes(this->cend(), new_size - len);
+      if(!priv_try_shrink(new_size)){
+         typedef default_construct_iterator default_iterator;
+         this->insert(this->cend(), default_iterator(new_size - this->size()), default_iterator());
       }
    }
 
@@ -776,33 +746,76 @@ class list
    //!
    //! Effects: Inserts n copies of x before p.
    //!
+   //! Returns: an iterator to the first inserted element or p if n is 0.
+   //!
    //! Throws: If memory allocation throws or T's copy constructor throws.
    //!
    //! Complexity: Linear to n.
-   void insert(const_iterator p, size_type n, const T& x)
-   { this->priv_create_and_insert_nodes(p, n, x); }
+   iterator insert(const_iterator p, size_type n, const T& x)
+   {
+      typedef constant_iterator cvalue_iterator;
+      return this->insert(p, cvalue_iterator(x, n), cvalue_iterator());
+   }
 
    //! Requires: p must be a valid iterator of *this.
    //!
    //! Effects: Insert a copy of the [first, last) range before p.
    //!
+   //! Returns: an iterator to the first inserted element or p if first == last.
+   //!
    //! Throws: If memory allocation throws, T's constructor from a
    //!   dereferenced InpIt throws.
    //!
    //! Complexity: Linear to std::distance [first, last).
    template 
-   void insert(const_iterator p, InpIt first, InpIt last)
+   iterator insert(const_iterator p, InpIt first, InpIt last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+            && (container_detail::is_input_iterator::value
+                || container_detail::is_same::value
+               )
+         >::type * = 0
+      #endif
+      )
    {
-      const bool aux_boolean = container_detail::is_convertible::value;
-      typedef container_detail::bool_ Result;
-      this->priv_insert_dispatch(p, first, last, Result());
+      const typename Icont::iterator ipos(p.get());
+      iterator ret_it(ipos);
+      if(first != last){
+         ret_it = iterator(this->icont().insert(ipos, *this->create_node_from_it(first)));
+         ++first;
+      }
+      for (; first != last; ++first){
+         this->icont().insert(ipos, *this->create_node_from_it(first));
+      }
+      return ret_it;
    }
 
+   #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   template 
+   iterator insert(const_iterator p, FwdIt first, FwdIt last
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+            && !(container_detail::is_input_iterator::value
+                || container_detail::is_same::value
+               )
+         >::type * = 0
+      )
+   {
+      //Optimized allocation and construction
+      insertion_functor func(this->icont(), p.get());
+      this->allocate_many_and_construct(first, std::distance(first, last), func);
+      return iterator(func.inserted_first());
+   }
+   #endif
+
    #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
    //! Requires: position must be a valid iterator of *this.
    //!
    //! Effects: Insert a copy of x before position.
    //!
+   //! Returns: an iterator to the inserted element.
+   //!
    //! Throws: If memory allocation throws or x's copy constructor throws.
    //!
    //! Complexity: Amortized constant time.
@@ -812,6 +825,8 @@ class list
    //!
    //! Effects: Insert a new element before position with mx's resources.
    //!
+   //! Returns: an iterator to the inserted element.
+   //!
    //! Throws: If memory allocation throws.
    //!
    //! Complexity: Amortized constant time.
@@ -919,7 +934,10 @@ class list
    //!
    //! Complexity: Linear to n.
    void assign(size_type n, const T& val)
-   {  this->priv_fill_assign(n, val);  }
+   {
+      typedef constant_iterator cvalue_iterator;
+      return this->assign(cvalue_iterator(val, n), cvalue_iterator());
+   }
 
    //! Effects: Assigns the the range [first, last) to *this.
    //!
@@ -928,11 +946,23 @@ class list
    //!
    //! Complexity: Linear to n.
    template 
-   void assign(InpIt first, InpIt last)
+   void assign(InpIt first, InpIt last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+         >::type * = 0
+      #endif
+      )
    {
-      const bool aux_boolean = container_detail::is_convertible::value;
-      typedef container_detail::bool_ Result;
-      this->priv_assign_dispatch(first, last, Result());
+      iterator first1      = this->begin();
+      const iterator last1 = this->end();
+      for ( ; first1 != last1 && first != last; ++first1, ++first)
+         *first1 = *first;
+      if (first == last)
+         this->erase(first1, last1);
+      else{
+         this->insert(last1, first, last);
+      }
    }
 
    //! Requires: p must point to an element contained
@@ -1151,6 +1181,34 @@ class list
    /// @cond
    private:
 
+   bool priv_try_shrink(size_type new_size)
+   {
+      const size_type len = this->size();
+      if(len > new_size){
+         const const_iterator iend = this->cend();
+         size_type to_erase = len - new_size;
+         const_iterator ifirst;
+         if(to_erase < len/2u){
+            ifirst = iend;
+            while(to_erase--){
+               --ifirst;
+            }
+         }
+         else{
+            ifirst = this->cbegin();
+            size_type to_skip = len - to_erase;
+            while(to_skip--){
+               ++ifirst;
+            }
+         }
+         this->erase(ifirst, iend);
+         return true;
+      }
+      else{
+         return false;
+      }
+   }
+
    iterator priv_insert(const_iterator p, const T &x)
    {
       NodePtr tmp = AllocHolder::create_node(x);
@@ -1175,117 +1233,39 @@ class list
    void priv_push_front (BOOST_RV_REF(T) x)
    {  this->insert(this->cbegin(), boost::move(x));  }
 
-   //Iterator range version
-   template
-   void priv_create_and_insert_nodes
-      (const_iterator pos, InpIterator beg, InpIterator end)
-   {
-      typedef typename std::iterator_traits::iterator_category ItCat;
-      priv_create_and_insert_nodes(pos, beg, end, alloc_version(), ItCat());
-   }
-
-   template
-   void priv_create_and_insert_nodes
-      (const_iterator pos, InpIterator beg, InpIterator end, allocator_v1, std::input_iterator_tag)
-   {
-      for (; beg != end; ++beg){
-         this->icont().insert(pos.get(), *this->create_node_from_it(beg));
-      }
-   }
-
-   template
-   void priv_create_and_insert_nodes
-      (const_iterator pos, InpIterator beg, InpIterator end, allocator_v2, std::input_iterator_tag)
-   {  //Just forward to the default one
-      priv_create_and_insert_nodes(pos, beg, end, allocator_v1(), std::input_iterator_tag());
-   }
-
    class insertion_functor;
    friend class insertion_functor;
 
    class insertion_functor
    {
       Icont &icont_;
-      typename Icont::const_iterator pos_;
+      typedef typename Icont::iterator       iiterator;
+      typedef typename Icont::const_iterator iconst_iterator;
+
+      const iconst_iterator pos_;
+      iiterator ret_;
+      bool first_;
 
       public:
       insertion_functor(Icont &icont, typename Icont::const_iterator pos)
-         :  icont_(icont), pos_(pos)
+         :  icont_(icont), pos_(pos), ret_(pos.unconst()), first_(true)
       {}
 
       void operator()(Node &n)
-      {  this->icont_.insert(pos_, n); }
+      {
+         if(first_){
+            ret_ = this->icont_.insert(pos_, n);
+            first_ = false;
+         }
+         else{
+            this->icont_.insert(pos_, n);
+         }
+      }
+
+      iiterator inserted_first() const
+      {  return ret_;   }
    };
 
-
-   template
-   void priv_create_and_insert_nodes
-      (const_iterator pos, FwdIterator beg, FwdIterator end, allocator_v2, std::forward_iterator_tag)
-   {
-      if(beg != end){
-         //Optimized allocation and construction
-         this->allocate_many_and_construct
-            (beg, std::distance(beg, end), insertion_functor(this->icont(), pos.get()));
-      }
-   }
-
-   //Default constructed version
-   void priv_create_and_insert_nodes(const_iterator pos, size_type n)
-   {
-      typedef default_construct_iterator default_iterator;
-      this->priv_create_and_insert_nodes(pos, default_iterator(n), default_iterator());
-   }
-
-   //Copy constructed version
-   void priv_create_and_insert_nodes(const_iterator pos, size_type n, const T& x)
-   {
-      typedef constant_iterator cvalue_iterator;
-      this->priv_create_and_insert_nodes(pos, cvalue_iterator(x, n), cvalue_iterator());
-   }
-
-   //Dispatch to detect iterator range or integer overloads
-   template 
-   void priv_insert_dispatch(const_iterator p,
-                             InputIter first, InputIter last,
-                             container_detail::false_)
-   {  this->priv_create_and_insert_nodes(p, first, last);   }
-
-   template
-   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)
-   {
-      iterator i = this->begin(), iend = this->end();
-
-      for ( ; i != iend && n > 0; ++i, --n)
-         *i = val;
-      if (n > 0){
-         this->priv_create_and_insert_nodes(this->cend(), n, val);
-      }
-      else{
-         this->erase(i, cend());
-      }
-   }
-
-   template 
-   void priv_assign_dispatch(Integer n, Integer val, container_detail::true_)
-   {  this->priv_fill_assign((size_type) n, (T) val); }
-
-   template 
-   void priv_assign_dispatch(InputIter first2, InputIter last2, container_detail::false_)
-   {
-      iterator first1   = this->begin();
-      iterator last1    = this->end();
-      for ( ; first1 != last1 && first2 != last2; ++first1, ++first2)
-         *first1 = *first2;
-      if (first2 == last2)
-         this->erase(first1, last1);
-      else{
-         this->priv_create_and_insert_nodes(last1, first2, last2);
-      }
-   }
-
    //Functors for member algorithm defaults
    struct value_less
    {
diff --git a/include/boost/container/map.hpp b/include/boost/container/map.hpp
index d4bd6e6..d31122c 100644
--- a/include/boost/container/map.hpp
+++ b/include/boost/container/map.hpp
@@ -155,7 +155,7 @@ class map
    template 
    map(InputIterator first, InputIterator last, const Pred& comp = Pred(),
          const allocator_type& a = allocator_type())
-      : m_tree(first, last, comp, a, true)
+      : m_tree(true, first, last, comp, a)
    {
       //Allocator type must be std::pair
       BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
@@ -902,7 +902,7 @@ class multimap
    multimap(InputIterator first, InputIterator last,
             const Pred& comp = Pred(),
             const allocator_type& a = allocator_type())
-      : m_tree(first, last, comp, a, false)
+      : m_tree(false, first, last, comp, a)
    {
       //Allocator type must be std::pair
       BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
diff --git a/include/boost/container/set.hpp b/include/boost/container/set.hpp
index 09ada20..44a854c 100644
--- a/include/boost/container/set.hpp
+++ b/include/boost/container/set.hpp
@@ -118,7 +118,7 @@ class set
    template 
    set(InputIterator first, InputIterator last, const Pred& comp = Pred(),
          const allocator_type& a = allocator_type())
-      : m_tree(first, last, comp, a, true)
+      : m_tree(true, first, last, comp, a)
    {}
 
    //! Effects: Constructs an empty set using the specified comparison object and
@@ -705,7 +705,7 @@ class multiset
    multiset(InputIterator first, InputIterator last,
             const Pred& comp = Pred(),
             const allocator_type& a = allocator_type())
-      : m_tree(first, last, comp, a, false)
+      : m_tree(false, first, last, comp, a)
    {}
 
    //! Effects: Constructs an empty multiset using the specified comparison object and
diff --git a/include/boost/container/slist.hpp b/include/boost/container/slist.hpp
index 5771935..553fb54 100644
--- a/include/boost/container/slist.hpp
+++ b/include/boost/container/slist.hpp
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -336,7 +337,7 @@ class slist
    //! Complexity: Linear to n.
    explicit slist(size_type n, const value_type& x, const allocator_type& a = allocator_type())
       :  AllocHolder(a)
-   { this->priv_create_and_insert_nodes(this->before_begin(), n, x); }
+   { this->insert_after(this->cbefore_begin(), n, x); }
 
    //! Effects: Constructs a list that will use a copy of allocator a
    //!   and inserts a copy of the range [first, last) in the list.
@@ -349,7 +350,7 @@ class slist
    slist(InpIt first, InpIt last,
          const allocator_type& a =  allocator_type())
       : AllocHolder(a)
-   { this->insert_after(this->before_begin(), first, last); }
+   { this->insert_after(this->cbefore_begin(), first, last); }
 
    //! Effects: Copy constructs a list.
    //!
@@ -360,7 +361,7 @@ class slist
    //! Complexity: Linear to the elements x contains.
    slist(const slist& x)
       : AllocHolder(x)
-   { this->insert_after(this->before_begin(), x.begin(), x.end()); }
+   { this->insert_after(this->cbefore_begin(), x.begin(), x.end()); }
 
    //! Effects: Move constructor. Moves mx's resources to *this.
    //!
@@ -380,7 +381,7 @@ class slist
    //! Complexity: Linear to the elements x contains.
    slist(const slist& x, const allocator_type &a)
       : AllocHolder(a)
-   { this->insert_after(this->before_begin(), x.begin(), x.end()); }
+   { this->insert_after(this->cbefore_begin(), x.begin(), x.end()); }
 
    //! Effects: Move constructor using the specified allocator.
    //!                 Moves x's resources to *this.
@@ -485,7 +486,10 @@ class slist
    //!
    //! Complexity: Linear to n.
    void assign(size_type n, const T& val)
-   { this->priv_fill_assign(n, val); }
+   {
+      typedef constant_iterator cvalue_iterator;
+      return this->assign(cvalue_iterator(val, n), cvalue_iterator());
+   }
 
    //! Effects: Assigns the range [first, last) to *this.
    //!
@@ -494,11 +498,27 @@ class slist
    //!
    //! Complexity: Linear to n.
    template 
-   void assign(InpIt first, InpIt last)
+   void assign(InpIt first, InpIt last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+         >::type * = 0
+      #endif
+      )
    {
-      const bool aux_boolean = container_detail::is_convertible::value;
-      typedef container_detail::bool_ Result;
-      this->priv_assign_dispatch(first, last, Result());
+      iterator end_n(this->end());
+      iterator prev(this->before_begin());
+      iterator node(this->begin());
+      while (node != end_n && first != last){
+         *node = *first;
+         prev = node;
+         ++node;
+         ++first;
+      }
+      if (first != last)
+         this->insert_after(prev, first, last);
+      else
+         this->erase_after(prev, end_n);
    }
 
    //! Effects: Returns an iterator to the first element contained in the list.
@@ -535,7 +555,7 @@ class slist
 
    //! Effects: Returns a non-dereferenceable iterator that,
    //! when incremented, yields begin().  This iterator may be used
-   //! as the argument toinsert_after, erase_after, etc.
+   //! as the argument to insert_after, erase_after, etc.
    //!
    //! Throws: Nothing.
    //!
@@ -545,7 +565,7 @@ class slist
 
    //! Effects: Returns a non-dereferenceable const_iterator
    //! that, when incremented, yields begin().  This iterator may be used
-   //! as the argument toinsert_after, erase_after, etc.
+   //! as the argument to insert_after, erase_after, etc.
    //!
    //! Throws: Nothing.
    //!
@@ -571,7 +591,7 @@ class slist
 
    //! Effects: Returns a non-dereferenceable const_iterator
    //! that, when incremented, yields begin().  This iterator may be used
-   //! as the argument toinsert_after, erase_after, etc.
+   //! as the argument to insert_after, erase_after, etc.
    //!
    //! Throws: Nothing.
    //!
@@ -734,20 +754,28 @@ class slist
    //!
    //! Effects: Inserts n copies of x after prev_pos.
    //!
+   //! Returns: an iterator to the last inserted element or prev_pos if n is 0.
+   //!
    //! Throws: If memory allocation throws or T's copy constructor throws.
    //!
+   //!
    //! Complexity: Linear to n.
    //!
    //! Note: Does not affect the validity of iterators and references of
    //!   previous values.
-   void insert_after(const_iterator prev_pos, size_type n, const value_type& x)
-   {  this->priv_create_and_insert_nodes(prev_pos, n, x); }
+   iterator insert_after(const_iterator prev_pos, size_type n, const value_type& x)
+   {
+      typedef constant_iterator cvalue_iterator;
+      return this->insert_after(prev_pos, cvalue_iterator(x, n), cvalue_iterator());
+   }
 
    //! Requires: prev_pos must be a valid iterator of *this.
    //!
    //! Effects: Inserts the range pointed by [first, last)
    //!   after the p prev_pos.
    //!
+   //! Returns: an iterator to the last inserted element or prev_pos if first == last.
+   //!
    //! Throws: If memory allocation throws, T's constructor from a
    //!   dereferenced InpIt throws.
    //!
@@ -755,18 +783,49 @@ class slist
    //!
    //! Note: Does not affect the validity of iterators and references of
    //!   previous values.
-   template 
-   void insert_after(const_iterator prev_pos, InIter first, InIter last)
+   template 
+   iterator insert_after(const_iterator prev_pos, InpIt first, InpIt last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+          && (container_detail::is_input_iterator::value
+                || container_detail::is_same::value
+               )
+         >::type * = 0
+      #endif
+      )
    {
-      const bool aux_boolean = container_detail::is_convertible::value;
-      typedef container_detail::bool_ Result;
-      this->priv_insert_after_range_dispatch(prev_pos, first, last, Result());
+      iterator ret_it(prev_pos.get());
+      for (; first != last; ++first){
+         ret_it = iterator(this->icont().insert_after(ret_it.get(), *this->create_node_from_it(first)));
+      }
+      return ret_it;
    }
 
+   #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   template 
+   iterator insert_after(const_iterator prev, FwdIt first, FwdIt last
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+            && !(container_detail::is_input_iterator::value
+                || container_detail::is_same::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);
+      return iterator(func.inserted_first());
+   }
+   #endif
+
    //! Requires: p must be a valid iterator of *this.
    //!
    //! Effects: Insert a copy of x before p.
    //!
+   //! Returns: an iterator to the inserted element.
+   //!
    //! Throws: If memory allocation throws or x's copy constructor throws.
    //!
    //! Complexity: Linear to the elements before p.
@@ -787,6 +846,8 @@ class slist
    //!
    //! Effects: Insert a new element before p with mx's resources.
    //!
+   //! Returns: an iterator to the inserted element.
+   //!
    //! Throws: If memory allocation throws.
    //!
    //! Complexity: Linear to the elements before p.
@@ -797,24 +858,36 @@ class slist
    //!
    //! Effects: Inserts n copies of x before p.
    //!
+   //! Returns: an iterator to the first inserted element or p if n == 0.
+   //!
    //! Throws: If memory allocation throws or T's copy constructor throws.
    //!
    //! Complexity: Linear to n plus linear to the elements before p.
-   void insert(const_iterator p, size_type n, const value_type& x)
-   {  return this->insert_after(previous(p), n, x); }
+   iterator insert(const_iterator p, size_type n, const value_type& x)
+   {
+      const_iterator prev(this->previous(p));
+      this->insert_after(prev, n, x);
+      return ++iterator(prev.get());
+   }
      
    //! Requires: p must be a valid iterator of *this.
    //!
    //! Effects: Insert a copy of the [first, last) range before p.
    //!
+   //! Returns: an iterator to the first inserted element or p if first == last.
+   //!
    //! Throws: If memory allocation throws, T's constructor from a
    //!   dereferenced InpIt throws.
    //!
    //! Complexity: Linear to std::distance [first, last) plus
    //!    linear to the elements before p.
    template 
-   void insert(const_iterator p, InIter first, InIter last)
-   {  return this->insert_after(previous(p), first, last); }
+   iterator insert(const_iterator p, InIter first, InIter last)
+   {
+      const_iterator prev(this->previous(p));
+      this->insert_after(prev, first, last);
+      return ++iterator(prev.get());
+   }
 
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
@@ -948,15 +1021,10 @@ class slist
    //! Complexity: Linear to the difference between size() and new_size.
    void resize(size_type new_size, const T& x)
    {
-      typename Icont::iterator end_n(this->icont().end()), cur(this->icont().before_begin()), cur_next;
-      while (++(cur_next = cur) != end_n && new_size > 0){
-         --new_size;
-         cur = cur_next;
+      const_iterator last_pos;
+      if(!priv_try_shrink(new_size, last_pos)){
+         this->insert_after(last_pos, new_size, x);
       }
-      if (cur_next != end_n)
-         this->erase_after(const_iterator(cur), const_iterator(end_n));
-      else
-         this->insert_after(const_iterator(cur), new_size, x);
    }
 
    //! Effects: Inserts or erases elements at the end such that
@@ -967,19 +1035,10 @@ class slist
    //! Complexity: Linear to the difference between size() and new_size.
    void resize(size_type new_size)
    {
-      typename Icont::iterator end_n(this->icont().end()), cur(this->icont().before_begin()), cur_next;
-      size_type len = this->size();
-      size_type left = new_size;
-     
-      while (++(cur_next = cur) != end_n && left > 0){
-         --left;
-         cur = cur_next;
-      }
-      if (cur_next != end_n){
-         this->erase_after(const_iterator(cur), const_iterator(end_n));
-      }
-      else{
-         this->priv_create_and_insert_nodes(const_iterator(cur), new_size - len);
+      const_iterator last_pos;
+      if(!priv_try_shrink(new_size, last_pos)){
+         typedef default_construct_iterator default_iterator;
+         this->insert_after(last_pos, default_iterator(new_size - this->size()), default_iterator());
       }
    }
 
@@ -1279,6 +1338,24 @@ class slist
 
    /// @cond
    private:
+
+   bool priv_try_shrink(size_type new_size, const_iterator &last_pos)
+   {
+      typename Icont::iterator end_n(this->icont().end()), cur(this->icont().before_begin()), cur_next;
+      while (++(cur_next = cur) != end_n && new_size > 0){
+         --new_size;
+         cur = cur_next;
+      }
+      last_pos = const_iterator(cur);
+      if (cur_next != end_n){
+         this->erase_after(last_pos, const_iterator(end_n));
+         return true;
+      }
+      else{
+         return false;
+      }
+   }
+
    iterator priv_insert(const_iterator p, const value_type& x)
    {  return this->insert_after(previous(p), x); }
 
@@ -1288,129 +1365,31 @@ class slist
    void priv_push_front(const value_type &x)
    {  this->icont().push_front(*this->create_node(x));  }
 
-   //Iterator range version
-   template
-   void priv_create_and_insert_nodes
-      (const_iterator prev, InpIterator beg, InpIterator end)
-   {
-      typedef typename std::iterator_traits::iterator_category ItCat;
-      priv_create_and_insert_nodes(prev, beg, end, alloc_version(), ItCat());
-   }
-
-   template
-   void priv_create_and_insert_nodes
-      (const_iterator prev, InpIterator beg, InpIterator end, allocator_v1, std::input_iterator_tag)
-   {
-      for (; beg != end; ++beg){
-         this->icont().insert_after(prev.get(), *this->create_node_from_it(beg));
-         ++prev;
-      }
-   }
-
-   template
-   void priv_create_and_insert_nodes
-      (const_iterator prev, InpIterator beg, InpIterator end, allocator_v2, std::input_iterator_tag)
-   {  //Just forward to the default one
-      priv_create_and_insert_nodes(prev, beg, end, allocator_v1(), std::input_iterator_tag());
-   }
-
    class insertion_functor;
    friend class insertion_functor;
 
    class insertion_functor
    {
       Icont &icont_;
-      typename Icont::const_iterator prev_;
+      typedef typename Icont::iterator       iiterator;
+      typedef typename Icont::const_iterator iconst_iterator;
+      const iconst_iterator prev_;
+      iiterator   ret_;
 
       public:
       insertion_functor(Icont &icont, typename Icont::const_iterator prev)
-         :  icont_(icont), prev_(prev)
+         :  icont_(icont), prev_(prev), ret_(prev.unconst())
       {}
 
       void operator()(Node &n)
-      {  prev_ = this->icont_.insert_after(prev_, n); }
+      {
+         ret_ = this->icont_.insert_after(prev_, n);
+      }
+
+      iiterator inserted_first() const
+      {  return ret_;   }
    };
 
-   template
-   void priv_create_and_insert_nodes
-      (const_iterator prev, FwdIterator beg, FwdIterator end, allocator_v2, std::forward_iterator_tag)
-   {
-      //Optimized allocation and construction
-      this->allocate_many_and_construct
-         (beg, std::distance(beg, end), insertion_functor(this->icont(), prev.get()));
-   }
-
-   //Default constructed version
-   void priv_create_and_insert_nodes(const_iterator prev, size_type n)
-   {
-      typedef default_construct_iterator default_iterator;
-      this->priv_create_and_insert_nodes(prev, default_iterator(n), default_iterator());
-   }
-
-   //Copy constructed version
-   void priv_create_and_insert_nodes(const_iterator prev, size_type n, const T& x)
-   {
-      typedef constant_iterator cvalue_iterator;
-      this->priv_create_and_insert_nodes(prev, cvalue_iterator(x, n), cvalue_iterator());
-   }
-
-   //Dispatch to detect iterator range or integer overloads
-   template 
-   void priv_insert_dispatch(const_iterator prev,
-                             InputIter first, InputIter last,
-                             container_detail::false_)
-   {  this->priv_create_and_insert_nodes(prev, first, last);   }
-
-   template
-   void priv_insert_dispatch(const_iterator prev, Integer n, Integer x, container_detail::true_)
-   {  this->priv_create_and_insert_nodes(prev, (size_type)n, x);  }
-
-   void priv_fill_assign(size_type n, const T& val)
-   {
-      iterator end_n(this->end());
-      iterator prev(this->before_begin());
-      iterator node(this->begin());
-      for ( ; node != end_n && n > 0 ; --n){
-         *node = val;
-         prev = node;
-         ++node;
-      }
-      if (n > 0)
-         this->priv_create_and_insert_nodes(prev, n, val);
-      else
-         this->erase_after(prev, end_n);
-   }
-
-   template 
-   void priv_assign_dispatch(Int n, Int val, container_detail::true_)
-   {  this->priv_fill_assign((size_type) n, (T)val); }
-
-   template 
-   void priv_assign_dispatch(InpIt first, InpIt last, container_detail::false_)
-   {
-      iterator end_n(this->end());
-      iterator prev(this->before_begin());
-      iterator node(this->begin());
-      while (node != end_n && first != last){
-         *node = *first;
-         prev = node;
-         ++node;
-         ++first;
-      }
-      if (first != last)
-         this->priv_create_and_insert_nodes(prev, first, last);
-      else
-         this->erase_after(prev, end_n);
-   }
-
-   template 
-   void priv_insert_after_range_dispatch(const_iterator prev_pos, Int n, Int x, container_detail::true_)
-   {  this->priv_create_and_insert_nodes(prev_pos, (size_type)n, x);  }
-
-   template 
-   void priv_insert_after_range_dispatch(const_iterator prev_pos, InIter first, InIter last, container_detail::false_)
-   {  this->priv_create_and_insert_nodes(prev_pos, first, last); }
-
    //Functors for member algorithm defaults
    struct value_less
    {
diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp
index d91eccd..f43db03 100644
--- a/include/boost/container/stable_vector.hpp
+++ b/include/boost/container/stable_vector.hpp
@@ -93,7 +93,7 @@ class clear_on_destroy
    {
       if(do_clear_){
          c_.clear();
-         c_.clear_pool(); 
+         c_.priv_clear_pool(); 
       }
    }
 
@@ -172,6 +172,9 @@ class iterator
    iterator(const iterator::template rebind_pointer::type>& x)
       : pn(x.pn)
    {}
+
+   node_type_ptr_t node() const
+   {  return pn;  }
   
    private:
    static node_type_ptr_t node_ptr_cast(const void_ptr &p)
@@ -413,14 +416,14 @@ class stable_vector
       typename boost::container::container_detail::enable_if_c
          
             ::value>::type * = 0)
-   {  return node_alloc().allocate(1);   }
+   {  return this->priv_node_alloc().allocate(1);   }
 
    template
    node_type_ptr_t allocate_one(AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
          
             ::value>::type * = 0)
-   {  return node_alloc().allocate_one();   }
+   {  return this->priv_node_alloc().allocate_one();   }
 
    void deallocate_one(node_type_ptr_t p)
    {  return this->deallocate_one(p, alloc_version());   }
@@ -430,14 +433,14 @@ class stable_vector
       typename boost::container::container_detail::enable_if_c
          
             ::value>::type * = 0)
-   {  node_alloc().deallocate(p, 1);   }
+   {  this->priv_node_alloc().deallocate(p, 1);   }
 
    template
    void deallocate_one(node_type_ptr_t p, AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
          
             ::value>::type * = 0)
-   {  node_alloc().deallocate_one(p);   }
+   {  this->priv_node_alloc().deallocate_one(p);   }
 
    friend class stable_vector_detail::clear_on_destroy;
    ///@endcond
@@ -497,7 +500,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    explicit stable_vector(const allocator_type& al)
-      : internal_data(al),impl(al)
+      : internal_data(al), impl(al)
    {
       STABLE_VECTOR_CHECK_INVARIANT;
    }
@@ -510,7 +513,7 @@ class stable_vector
    //!
    //! Complexity: Linear to n.
    explicit stable_vector(size_type n)
-      : internal_data(),impl()
+      : internal_data(), impl()
    {
       stable_vector_detail::clear_on_destroy cod(*this);
       this->resize(n);
@@ -526,10 +529,10 @@ class stable_vector
    //!
    //! Complexity: Linear to n.
    stable_vector(size_type n, const T& t, const allocator_type& al = allocator_type())
-      : internal_data(al),impl(al)
+      : internal_data(al), impl(al)
    {
       stable_vector_detail::clear_on_destroy cod(*this);
-      this->insert(this->cbegin(), n, t);
+      this->insert(this->cend(), n, t);
       STABLE_VECTOR_CHECK_INVARIANT;
       cod.release();
    }
@@ -543,10 +546,10 @@ class stable_vector
    //! Complexity: Linear to the range [first, last).
    template 
    stable_vector(InputIterator first,InputIterator last, const allocator_type& al = allocator_type())
-      : internal_data(al),impl(al)
+      : internal_data(al), impl(al)
    {
       stable_vector_detail::clear_on_destroy cod(*this);
-      this->insert(this->cbegin(), first, last);
+      this->insert(this->cend(), first, last);
       STABLE_VECTOR_CHECK_INVARIANT;
       cod.release();
    }
@@ -558,12 +561,12 @@ class stable_vector
    //! Complexity: Linear to the elements x contains.
    stable_vector(const stable_vector& x)
       : internal_data(allocator_traits::
-         select_on_container_copy_construction(x.node_alloc()))
+         select_on_container_copy_construction(x.priv_node_alloc()))
       , impl(allocator_traits::
          select_on_container_copy_construction(x.impl.get_stored_allocator()))
    {
       stable_vector_detail::clear_on_destroy cod(*this);
-      this->insert(this->cbegin(), x.begin(), x.end());
+      this->insert(this->cend(), x.begin(), x.end());
       STABLE_VECTOR_CHECK_INVARIANT;
       cod.release();
    }
@@ -574,7 +577,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    stable_vector(BOOST_RV_REF(stable_vector) x)
-      : internal_data(boost::move(x.node_alloc())), impl(boost::move(x.impl))
+      : internal_data(boost::move(x.priv_node_alloc())), impl(boost::move(x.impl))
    {
       this->priv_swap_members(x);
    }
@@ -588,7 +591,7 @@ class stable_vector
       : internal_data(a), impl(a)
    {
       stable_vector_detail::clear_on_destroy cod(*this);
-      this->insert(this->cbegin(), x.begin(), x.end());
+      this->insert(this->cend(), x.begin(), x.end());
       STABLE_VECTOR_CHECK_INVARIANT;
       cod.release();
    }
@@ -602,12 +605,12 @@ class stable_vector
    stable_vector(BOOST_RV_REF(stable_vector) x, const allocator_type &a)
       : internal_data(a), impl(a)
    {
-      if(this->node_alloc() == x.node_alloc()){
+      if(this->priv_node_alloc() == x.priv_node_alloc()){
          this->priv_swap_members(x);
       }
       else{
          stable_vector_detail::clear_on_destroy cod(*this);
-         this->insert(this->cbegin(), x.begin(), x.end());
+         this->insert(this->cend(), x.begin(), x.end());
          STABLE_VECTOR_CHECK_INVARIANT;
          cod.release();
       }
@@ -622,7 +625,7 @@ class stable_vector
    ~stable_vector()
    {
       this->clear();
-      clear_pool(); 
+      priv_clear_pool(); 
    }
 
    //! Effects: Makes *this contain the same elements as x.
@@ -637,15 +640,15 @@ class stable_vector
    {
       STABLE_VECTOR_CHECK_INVARIANT;
       if (&x != this){
-         node_allocator_type &this_alloc     = this->node_alloc();
-         const node_allocator_type &x_alloc  = x.node_alloc();
+         node_allocator_type &this_alloc     = this->priv_node_alloc();
+         const node_allocator_type &x_alloc  = x.priv_node_alloc();
          container_detail::bool_ flag;
          if(flag && this_alloc != x_alloc){
             this->clear();
             this->shrink_to_fit();
          }
-         container_detail::assign_alloc(this->node_alloc(), x.node_alloc(), flag);
+         container_detail::assign_alloc(this->priv_node_alloc(), x.priv_node_alloc(), flag);
          container_detail::assign_alloc(this->impl.get_stored_allocator(), x.impl.get_stored_allocator(), flag);
          this->assign(x.begin(), x.end());
       }
@@ -663,8 +666,8 @@ class stable_vector
    stable_vector& operator=(BOOST_RV_REF(stable_vector) x)
    {
       if (&x != this){
-         node_allocator_type &this_alloc = this->node_alloc();
-         node_allocator_type &x_alloc    = x.node_alloc();
+         node_allocator_type &this_alloc = this->priv_node_alloc();
+         node_allocator_type &x_alloc    = x.priv_node_alloc();
          //If allocators are equal we can just swap pointers
          if(this_alloc == x_alloc){
             //Destroy objects but retain memory
@@ -674,7 +677,7 @@ class stable_vector
             //Move allocator if needed
             container_detail::bool_ flag;
-            container_detail::move_alloc(this->node_alloc(), x.node_alloc(), flag);
+            container_detail::move_alloc(this->priv_node_alloc(), x.priv_node_alloc(), flag);
          }
          //If unequal allocators, then do a one by one move
          else{
@@ -693,9 +696,25 @@ class stable_vector
    //!
    //! Complexity: Linear to n.
    template
-   void assign(InputIterator first,InputIterator last)
+   void assign(InputIterator first,InputIterator last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+         >::type * = 0
+      #endif
+      )
    {
-      assign_dispatch(first, last, boost::is_integral());
+      STABLE_VECTOR_CHECK_INVARIANT;
+      iterator first1   = this->begin();
+      iterator last1    = this->end();
+      for ( ; first1 != last1 && first != last; ++first1, ++first)
+         *first1 = *first;
+      if (first == last){
+         this->erase(first1, last1);
+      }
+      else{
+         this->insert(last1, first, last);
+      }
    }
 
 
@@ -707,7 +726,7 @@ class stable_vector
    void assign(size_type n,const T& t)
    {
       typedef constant_iterator cvalue_iterator;
-      return assign_dispatch(cvalue_iterator(t, n), cvalue_iterator(), boost::mpl::false_());
+      this->assign(cvalue_iterator(t, n), cvalue_iterator());
    }
 
    //! Effects: Returns a copy of the internal allocator.
@@ -715,7 +734,8 @@ class stable_vector
    //! Throws: If allocator's copy constructor throws.
    //!
    //! Complexity: Constant.
-   allocator_type get_allocator()const  {return this->node_alloc();}
+   allocator_type get_allocator()const
+   {  return this->priv_node_alloc();  }
 
    //! Effects: Returns a reference to the internal allocator.
    //!
@@ -725,7 +745,7 @@ class stable_vector
    //!
    //! Note: Non-standard extension.
    const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
-   {  return node_alloc(); }
+   {  return this->priv_node_alloc(); }
 
    //! Effects: Returns a reference to the internal allocator.
    //!
@@ -735,7 +755,7 @@ class stable_vector
    //!
    //! Note: Non-standard extension.
    stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
-   {  return node_alloc(); }
+   {  return this->priv_node_alloc(); }
 
 
    //! Effects: Returns an iterator to the first element contained in the stable_vector.
@@ -928,7 +948,7 @@ class stable_vector
          }
          //Now fill pool if data is not enough
          if((n - size) > this->internal_data.pool_size){
-            this->add_to_pool((n - size) - this->internal_data.pool_size);
+            this->priv_add_to_pool((n - size) - this->internal_data.pool_size);
          }
       }
    }
@@ -1066,6 +1086,8 @@ class stable_vector
    //!
    //! Effects: Insert a copy of x before position.
    //!
+   //! Returns: An iterator to the inserted element.
+   //!
    //! Throws: If memory allocation throws or x's copy constructor throws.
    //!
    //! Complexity: If position is end(), amortized constant time
@@ -1086,6 +1108,8 @@ class stable_vector
    //!
    //! Effects: Insert a new element before position with mx's resources.
    //!
+   //! Returns: an iterator to the inserted element.
+   //!
    //! Throws: If memory allocation throws.
    //!
    //! Complexity: If position is end(), amortized constant time
@@ -1104,33 +1128,70 @@ class stable_vector
 
    //! Requires: pos must be a valid iterator of *this.
    //!
-   //! Effects: Insert n copies of x before pos.
+   //! Effects: Insert n copies of x before position.
+   //!
+   //! Returns: an iterator to the first inserted element or position if n is 0.
    //!
    //! Throws: If memory allocation throws or T's copy constructor throws.
    //!
    //! Complexity: Linear to n.
-   void insert(const_iterator position, size_type n, const T& t)
+   iterator insert(const_iterator position, size_type n, const T& t)
    {
       STABLE_VECTOR_CHECK_INVARIANT;
-      this->insert_not_iter(position, n, t);
+      typedef constant_iterator cvalue_iterator;
+      return this->insert(position, cvalue_iterator(t, n), cvalue_iterator());
    }
 
    //! Requires: pos must be a valid iterator of *this.
    //!
    //! Effects: Insert a copy of the [first, last) range before pos.
    //!
+   //! Returns: an iterator to the first inserted element or position if first == last.
+   //!
    //! Throws: If memory allocation throws, T's constructor from a
    //!   dereferenced InpIt throws or T's copy constructor throws.
    //!
    //! Complexity: Linear to std::distance [first, last).
    template 
-   void insert(const_iterator position,InputIterator first, InputIterator last)
+   iterator insert(const_iterator position,InputIterator first, InputIterator last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+            && container_detail::is_input_iterator::value
+         >::type * = 0
+      #endif
+      )
    {
       STABLE_VECTOR_CHECK_INVARIANT;
-      this->insert_iter(position,first,last,
-                        boost::mpl::not_ >());
+      const size_type pos_n = position - this->cbegin();
+      for(; first != last; ++first){
+         this->emplace(position, *first);
+      }
+      return this->begin() + pos_n;
    }
 
+   #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   template 
+   iterator insert(const_iterator position, FwdIt first, FwdIt last
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+            && !container_detail::is_input_iterator::value
+         >::type * = 0
+      )
+   {
+      size_type       n = (size_type)std::distance(first,last);
+      difference_type d = position - this->cbegin();
+      if(n){
+         this->insert_iter_prolog(n, d);
+         const impl_iterator it(impl.begin() + d);
+         this->priv_insert_iter_fwd(it, first, last, n);
+         //Fix the pointers for the newly allocated buffer
+         this->align_nodes(it + n, get_last_align());
+      }
+      return this->begin() + d;
+   }
+   #endif
+
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
    //! Effects: Inserts an object of type T constructed with
@@ -1230,7 +1291,18 @@ class stable_vector
    //! Complexity: Linear to the distance between first and last
    //!   plus linear to the elements between pos and the last element.
    iterator erase(const_iterator first, const_iterator last)
-   {   return priv_erase(first, last, alloc_version());  }
+   {
+      STABLE_VECTOR_CHECK_INVARIANT;
+      difference_type d1 = first - this->cbegin(), d2 = last - this->cbegin();
+      if(d1 != d2){
+         impl_iterator it1(impl.begin() + d1), it2(impl.begin() + d2);
+         for(impl_iterator it = it1; it != it2; ++it)
+            this->delete_node(*it);
+         impl_iterator e = impl.erase(it1, it2);
+         this->align_nodes(e, get_last_align());
+      }
+      return iterator(this->begin() + d1);
+   }
 
    //! Effects: Swaps the contents of *this and x.
    //!
@@ -1241,7 +1313,7 @@ class stable_vector
    {
       STABLE_VECTOR_CHECK_INVARIANT;
       container_detail::bool_ flag;
-      container_detail::swap_alloc(this->node_alloc(), x.node_alloc(), flag);
+      container_detail::swap_alloc(this->priv_node_alloc(), x.priv_node_alloc(), flag);
       //vector's allocator is swapped here
       this->impl.swap(x.impl);
       this->priv_swap_members(x);
@@ -1265,7 +1337,7 @@ class stable_vector
    {
       if(this->capacity()){
          //First empty allocated node pool
-         this->clear_pool();
+         this->priv_clear_pool();
          //If empty completely destroy the index, let's recover default-constructed state
          if(this->empty()){
             this->impl.clear();
@@ -1291,14 +1363,14 @@ class stable_vector
    iterator priv_insert(const_iterator position, const value_type &t)
    {
       typedef constant_iterator cvalue_iterator;
-      return this->insert_iter(position, cvalue_iterator(t, 1), cvalue_iterator(), std::forward_iterator_tag());
+      return this->insert(position, cvalue_iterator(t, 1), cvalue_iterator());
    }
 
    void priv_push_back(const value_type &t)
    {  this->insert(end(), t);  }
 
    template
-   void clear_pool(AllocatorVersion,
+   void priv_clear_pool(AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
          
             ::value>::type * = 0)
@@ -1320,7 +1392,7 @@ class stable_vector
    }
 
    template
-   void clear_pool(AllocatorVersion,
+   void priv_clear_pool(AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
          
             ::value>::type * = 0)
@@ -1330,24 +1402,24 @@ class stable_vector
          void_ptr &pool_last_ref = impl.back();
          multiallocation_chain holder;
          holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
-         node_alloc().deallocate_individual(boost::move(holder));
+         this->priv_node_alloc().deallocate_individual(boost::move(holder));
          pool_first_ref = pool_last_ref = 0;
          this->internal_data.pool_size = 0;
       }
    }
 
-   void clear_pool()
+   void priv_clear_pool()
    {
-      this->clear_pool(alloc_version());
+      this->priv_clear_pool(alloc_version());
    }
 
-   void add_to_pool(size_type n)
+   void priv_add_to_pool(size_type n)
    {
-      this->add_to_pool(n, alloc_version());
+      this->priv_add_to_pool(n, alloc_version());
    }
 
    template
-   void add_to_pool(size_type n, AllocatorVersion,
+   void priv_add_to_pool(size_type n, AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
          
             ::value>::type * = 0)
@@ -1359,7 +1431,7 @@ class stable_vector
    }
 
    template
-   void add_to_pool(size_type n, AllocatorVersion,
+   void priv_add_to_pool(size_type n, AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
          
             ::value>::type * = 0)
@@ -1369,7 +1441,7 @@ class stable_vector
       multiallocation_chain holder;
       holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
       //BOOST_STATIC_ASSERT((::boost::has_move_emulation_enabled::value == true));
-      multiallocation_chain m (node_alloc().allocate_individual(n));
+      multiallocation_chain m (this->priv_node_alloc().allocate_individual(n));
       holder.splice_after(holder.before_begin(), m, m.before_begin(), m.last(), n);
       this->internal_data.pool_size += n;
       std::pair data(holder.extract_data());
@@ -1390,7 +1462,7 @@ class stable_vector
       pool_last_ref = ret.second;
    }
 
-   node_type_ptr_t get_from_pool()
+   node_type_ptr_t priv_get_from_pool()
    {
       if(!impl.back()){
          return node_type_ptr_t(0);
@@ -1429,43 +1501,6 @@ class stable_vector
       }
    }
 
-   template
-   void assign_dispatch(InputIterator first, InputIterator last, boost::mpl::false_)
-   {
-      STABLE_VECTOR_CHECK_INVARIANT;
-      iterator first1   = this->begin();
-      iterator last1    = this->end();
-      for ( ; first1 != last1 && first != last; ++first1, ++first)
-         *first1 = *first;
-      if (first == last){
-         this->erase(first1, last1);
-      }
-      else{
-         this->insert(last1, first, last);
-      }
-   }
-
-   template
-   void assign_dispatch(Integer n, Integer t, boost::mpl::true_)
-   {
-      typedef constant_iterator cvalue_iterator;
-      this->assign_dispatch(cvalue_iterator(t, n), cvalue_iterator(), boost::mpl::false_());
-   }
-
-   iterator priv_erase(const_iterator first, const_iterator last, allocator_v1)
-   {
-      STABLE_VECTOR_CHECK_INVARIANT;
-      difference_type d1 = first - this->cbegin(), d2 = last - this->cbegin();
-      if(d1 != d2){
-         impl_iterator it1(impl.begin() + d1), it2(impl.begin() + d2);
-         for(impl_iterator it = it1; it != it2; ++it)
-            this->delete_node(*it);
-         impl_iterator e = impl.erase(it1, it2);
-         this->align_nodes(e, get_last_align());
-      }
-      return iterator(this->begin() + d1);
-   }
-
    impl_iterator get_last_align()
    {
       return impl.end() - (ExtraPointers - 1);
@@ -1476,16 +1511,6 @@ class stable_vector
       return impl.cend() - (ExtraPointers - 1);
    }
 
-   template
-   iterator priv_erase(const_iterator first, const_iterator last, AllocatorVersion,
-      typename boost::container::container_detail::enable_if_c
-         
-            ::value>::type * = 0)
-   {
-      STABLE_VECTOR_CHECK_INVARIANT;
-      return priv_erase(first, last, allocator_v1());
-   }
-
    static node_type_ptr_t node_ptr_cast(const void_ptr &p)
    {
       return node_type_ptr_t(static_cast(container_detail::to_raw_pointer(p)));
@@ -1535,7 +1560,7 @@ class stable_vector
    {
       node_type_ptr_t p = this->allocate_one();
       try{
-         boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->value), it);
+         boost::container::construct_in_place(this->priv_node_alloc(), container_detail::addressof(p->value), it);
          //This does not throw
          ::new(static_cast(container_detail::to_raw_pointer(p))) node_type_base_t;
          p->set_pointer(up);
@@ -1551,7 +1576,7 @@ class stable_vector
    {
       node_type_ptr_t n(node_ptr_cast(p));
       allocator_traits::
-         destroy(this->node_alloc(), container_detail::to_raw_pointer(n));
+         destroy(this->priv_node_alloc(), container_detail::to_raw_pointer(n));
       this->put_in_pool(n);
    }
 
@@ -1563,44 +1588,8 @@ class stable_vector
       }
    }
 
-   void insert_not_iter(const_iterator position, size_type n, const T& t)
-   {
-      typedef constant_iterator cvalue_iterator;
-      this->insert_iter(position, cvalue_iterator(t, n), cvalue_iterator(), std::forward_iterator_tag());
-   }
-
-   template 
-   void insert_iter(const_iterator position,InputIterator first,InputIterator last, boost::mpl::true_)
-   {
-      typedef typename std::iterator_traits::iterator_category category;
-      this->insert_iter(position, first, last, category());
-   }
-
-   template 
-   void insert_iter(const_iterator position,InputIterator first,InputIterator last,std::input_iterator_tag)
-   {
-      for(; first!=last; ++first){
-         this->insert(position, *first);
-      }   
-   }
-
-   template 
-   iterator insert_iter(const_iterator position, InputIterator first, InputIterator last, std::forward_iterator_tag)
-   {
-      size_type       n = (size_type)std::distance(first,last);
-      difference_type d = position-this->cbegin();
-      if(n){
-         this->insert_iter_prolog(n, d);
-         const impl_iterator it(impl.begin() + d);
-         this->insert_iter_fwd(it, first, last, n);
-         //Fix the pointers for the newly allocated buffer
-         this->align_nodes(it + n, get_last_align());
-      }
-      return this->begin() + d;
-   }
-
    template 
-   void insert_iter_fwd_alloc(const impl_iterator it, FwdIterator first, FwdIterator last, difference_type n, allocator_v1)
+   void priv_insert_iter_fwd_alloc(const impl_iterator it, FwdIterator first, FwdIterator last, difference_type n, allocator_v1)
    {
       size_type i=0;
       try{
@@ -1618,9 +1607,9 @@ class stable_vector
    }
 
    template 
-   void insert_iter_fwd_alloc(const impl_iterator it, FwdIterator first, FwdIterator last, difference_type n, allocator_v2)
+   void priv_insert_iter_fwd_alloc(const impl_iterator it, FwdIterator first, FwdIterator last, difference_type n, allocator_v2)
    {
-      multiallocation_chain mem(node_alloc().allocate_individual(n));
+      multiallocation_chain mem(this->priv_node_alloc().allocate_individual(n));
 
       size_type i = 0;
       node_type_ptr_t p = 0;
@@ -1629,7 +1618,7 @@ class stable_vector
             p = mem.front();
             mem.pop_front();
             //This can throw
-            boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->value), first);
+            boost::container::construct_in_place(this->priv_node_alloc(), container_detail::addressof(p->value), first);
             //This does not throw
             ::new(static_cast(container_detail::to_raw_pointer(p))) node_type_base_t;
             p->set_pointer(void_ptr_ptr(&it[i]));
@@ -1639,8 +1628,8 @@ class stable_vector
          }
       }
       catch(...){
-         node_alloc().deallocate_one(p);
-         node_alloc().deallocate_many(boost::move(mem));
+         this->priv_node_alloc().deallocate_one(p);
+         this->priv_node_alloc().deallocate_many(boost::move(mem));
          impl_iterator e = impl.erase(it+i, it+n);
          this->align_nodes(e, get_last_align());
          throw;
@@ -1648,19 +1637,19 @@ class stable_vector
    }
 
    template 
-   void insert_iter_fwd(const impl_iterator it, FwdIterator first, FwdIterator last, difference_type n)
+   void priv_insert_iter_fwd(const impl_iterator it, FwdIterator first, FwdIterator last, difference_type n)
    {
       size_type i = 0;
       node_type_ptr_t p = 0;
       try{
          while(first != last){
-            p = this->get_from_pool();
+            p = this->priv_get_from_pool();
             if(!p){
-               insert_iter_fwd_alloc(it+i, first, last, n-i, alloc_version());
+               this->priv_insert_iter_fwd_alloc(it+i, first, last, n-i, alloc_version());
                break;
             }
             //This can throw
-            boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->value), first);
+            boost::container::construct_in_place(this->priv_node_alloc(), container_detail::addressof(p->value), first);
             //This does not throw
             ::new(static_cast(container_detail::to_raw_pointer(p))) node_type_base_t;
             p->set_pointer(void_ptr_ptr(&it[i]));
@@ -1677,14 +1666,15 @@ class stable_vector
       }
    }
 
-   template 
-   void insert_iter(const_iterator position, InputIterator first, InputIterator last, boost::mpl::false_)
+   void priv_swap_members(stable_vector &x)
    {
-      this->insert_not_iter(position, first, last);
+      container_detail::do_swap(this->internal_data.pool_size, x.internal_data.pool_size);
+      this->readjust_end_node();
+      x.readjust_end_node();
    }
 
    #if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING)
-   bool invariant()const
+   bool priv_invariant()const
    {
       if(impl.empty())
          return !capacity() && !size();
@@ -1715,7 +1705,7 @@ class stable_vector
 
       public:
       invariant_checker(const stable_vector& v):p(&v){}
-      ~invariant_checker(){BOOST_ASSERT(p->invariant());}
+      ~invariant_checker(){BOOST_ASSERT(p->priv_invariant());}
       void touch(){}
    };
    #endif
@@ -1725,14 +1715,8 @@ class stable_vector
    {
       private:
       BOOST_MOVABLE_BUT_NOT_COPYABLE(ebo_holder)
+
       public:
-/*
-      explicit ebo_holder(BOOST_RV_REF(ebo_holder) x)
-         : node_allocator_type(boost::move(static_cast(x)))
-         , pool_size(0)
-         , end_node()
-      {}
-*/
       template
       explicit ebo_holder(BOOST_FWD_REF(AllocatorRLValue) a)
          : node_allocator_type(boost::forward(a))
@@ -1759,15 +1743,8 @@ class stable_vector
       node_type_base_t end_node;
    } internal_data;
 
-   void priv_swap_members(stable_vector &x)
-   {
-      container_detail::do_swap(this->internal_data.pool_size, x.internal_data.pool_size);
-      this->readjust_end_node();
-      x.readjust_end_node();
-   }
-
-   node_allocator_type &node_alloc()              { return internal_data;  }
-   const node_allocator_type &node_alloc() const  { return internal_data;  }
+   node_allocator_type &priv_node_alloc()              { return internal_data;  }
+   const node_allocator_type &priv_node_alloc() const  { return internal_data;  }
 
    impl_type                           impl;
    /// @endcond
diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp
index 49f2974..ff1f8fd 100644
--- a/include/boost/container/string.hpp
+++ b/include/boost/container/string.hpp
@@ -68,13 +68,8 @@
 #include 
 #include 
 
-#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
 namespace boost {
 namespace container {
-#else
-namespace boost {
-namespace container {
-#endif
 
 /// @cond
 namespace container_detail {
@@ -624,7 +619,10 @@ class basic_string
    //! Throws: If allocator_type's default constructor throws.
    basic_string(const basic_string& s)
       :  base_t(allocator_traits_type::select_on_container_copy_construction(s.alloc()))
-   { this->priv_range_initialize(s.begin(), s.end()); }
+   {
+      this->priv_terminate_string();
+      this->assign(s.begin(), s.end());
+   }
 
    //! Effects: Move constructor. Moves s's resources to *this.
    //!
@@ -642,7 +640,10 @@ class basic_string
    //! Throws: If allocation throws.
    basic_string(const basic_string& s, const allocator_type &a)
       :  base_t(a)
-   { this->priv_range_initialize(s.begin(), s.end()); }
+   {
+      this->priv_terminate_string();
+      this->assign(s.begin(), s.end());
+   }
 
    //! Effects: Move constructor using the specified allocator.
    //!                 Moves s's resources to *this.
@@ -653,11 +654,12 @@ class basic_string
    basic_string(BOOST_RV_REF(basic_string) s, const allocator_type &a)
       : base_t(a)
    {
+      this->priv_terminate_string();
       if(a == this->alloc()){
          this->swap_data(s);
       }
       else{
-         this->priv_range_initialize(s.begin(), s.end());
+         this->assign(s.begin(), s.end());
       }
    }
 
@@ -667,10 +669,11 @@ class basic_string
                const allocator_type& a = allocator_type())
       : base_t(a)
    {
+      this->priv_terminate_string();
       if (pos > s.size())
          this->throw_out_of_range();
       else
-         this->priv_range_initialize
+         this->assign
             (s.begin() + pos, s.begin() + pos + container_detail::min_value(n, s.size() - pos));
    }
 
@@ -679,23 +682,29 @@ class basic_string
    basic_string(const CharT* s, size_type n,
                const allocator_type& a = allocator_type())
       : base_t(a)
-   { this->priv_range_initialize(s, s + n); }
+   {
+      this->priv_terminate_string();
+      this->assign(s, s + n);
+   }
 
    //! Effects: Constructs a basic_string taking the allocator as parameter,
    //!   and is initialized by the null-terminated s c-string.
    basic_string(const CharT* s,
                 const allocator_type& a = allocator_type())
       : base_t(a)
-   { this->priv_range_initialize(s, s + Traits::length(s)); }
+   {
+      this->priv_terminate_string();
+      this->assign(s, s + Traits::length(s));
+   }
 
    //! Effects: Constructs a basic_string taking the allocator as parameter,
    //!   and is initialized by n copies of c.
    basic_string(size_type n, CharT c,
                 const allocator_type& a = allocator_type())
       : base_t(a)
-   { 
-      this->priv_range_initialize(cvalue_iterator(c, n),
-                                  cvalue_iterator());
+   {
+      this->priv_terminate_string();
+      this->assign(n, c);
    }
 
    //! Effects: Constructs a basic_string taking the allocator as parameter,
@@ -705,10 +714,8 @@ class basic_string
                const allocator_type& a = allocator_type())
       : base_t(a)
    {
-      //Dispatch depending on integer/iterator
-      const bool aux_boolean = container_detail::is_convertible::value;
-      typedef container_detail::bool_ Result;
-      this->priv_initialize_dispatch(f, l, Result());
+      this->priv_terminate_string();
+      this->assign(f, l);
    }
 
    //! Effects: Destroys the basic_string. All used memory is deallocated.
@@ -1213,8 +1220,8 @@ class basic_string
    //! Throws: If memory allocation throws or out_of_range if pos > str.size().
    //!
    //! Returns: *this
-   basic_string& assign(const basic_string& s,
-                        size_type pos, size_type n) {
+   basic_string& assign(const basic_string& s, size_type pos, size_type n)
+   {
       if (pos > s.size())
       this->throw_out_of_range();
       return this->assign(s.begin() + pos,
@@ -1250,12 +1257,28 @@ class basic_string
    //!
    //! Returns: *this
    template 
-   basic_string& assign(InputIter first, InputIter last)
+   basic_string& assign(InputIter first, InputIter last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+         >::type * = 0
+      #endif
+      )
    {
-      //Dispatch depending on integer/iterator
-      const bool aux_boolean = container_detail::is_convertible::value;
-      typedef container_detail::bool_ Result;
-      return this->priv_assign_dispatch(first, last, Result());
+      size_type cur = 0;
+      CharT *ptr = container_detail::to_raw_pointer(this->priv_addr());
+      const size_type old_size = this->priv_size();
+      while (first != last && cur != old_size) {
+         Traits::assign(*ptr, *first);
+         ++first;
+         ++cur;
+         ++ptr;
+      }
+      if (first == last)
+         this->erase(this->priv_addr() + cur, this->priv_addr() + old_size);
+      else
+         this->append(first, last);
+      return *this;
    }
 
    //! Requires: pos <= size().
@@ -1283,8 +1306,7 @@ class basic_string
    //! Throws: If memory allocation throws or out_of_range if pos1 > size() or pos2 > str.size().
    //!
    //! Returns: *this
-   basic_string& insert(size_type pos1, const basic_string& s,
-                        size_type pos2, size_type n)
+   basic_string& insert(size_type pos1, const basic_string& s, size_type pos2, size_type n)
    {
       if (pos1 > this->size() || pos2 > s.size())
          this->throw_out_of_range();
@@ -1369,23 +1391,144 @@ class basic_string
    //! Requires: p is a valid iterator on *this.
    //!
    //! Effects: Inserts n copies of c before the character referred to by p.
-   void insert(const_iterator p, size_type n, CharT c)
-   {
-      this->insert(p, cvalue_iterator(c, n), cvalue_iterator());
-   }
+   //!
+   //! Returns: an iterator to the first inserted element or p if n is 0.
+   iterator insert(const_iterator p, size_type n, CharT c)
+   {  return this->insert(p, cvalue_iterator(c, n), cvalue_iterator());  }
 
    //! Requires: p is a valid iterator on *this. [first,last) is a valid range.
    //!
    //! Effects: Equivalent to insert(p - begin(), basic_string(first, last)).
+   //!
+   //! Returns: an iterator to the first inserted element or p if first == last.
    template 
-   void insert(const_iterator p, InputIter first, InputIter last)
+   iterator insert(const_iterator p, InputIter first, InputIter last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+            && container_detail::is_input_iterator::value
+         >::type * = 0
+      #endif
+      )
    {
-      //Dispatch depending on integer/iterator
-      const bool aux_boolean = container_detail::is_convertible::value;
-      typedef container_detail::bool_ Result;
-      this->priv_insert_dispatch(p, first, last, Result());
+      const size_type n_pos = p - this->cbegin();
+      for ( ; first != last; ++first, ++p) {
+         p = this->insert(p, *first);
+      }
+      return this->begin() + n_pos; 
    }
 
+   #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   template 
+   iterator insert(const_iterator p, ForwardIter first, ForwardIter last
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+            && !container_detail::is_input_iterator::value
+         >::type * = 0
+      )
+   {
+      const size_type n_pos = p - this->cbegin();
+      if (first != last) {
+         const size_type n = std::distance(first, last);
+         const size_type old_size = this->priv_size();
+         const size_type remaining = this->capacity() - old_size;
+         const pointer old_start = this->priv_addr();
+         bool enough_capacity = false;
+         std::pair allocation_ret;
+         size_type new_cap = 0;
+
+         //Check if we have enough capacity
+         if (remaining >= n){
+            enough_capacity = true;           
+         }
+         else {
+            //Otherwise expand current buffer or allocate new storage
+            new_cap  = this->next_capacity(n);
+            allocation_ret = this->allocation_command
+                  (allocate_new | expand_fwd | expand_bwd, old_size + n + 1,
+                     new_cap, new_cap, old_start);
+
+            //Check forward expansion
+            if(old_start == allocation_ret.first){
+               enough_capacity = true;
+               this->priv_storage(new_cap);
+            }
+         }
+
+         //Reuse same buffer
+         if(enough_capacity){
+            const size_type elems_after = old_size - (p - this->priv_addr());
+            const size_type old_length = old_size;
+            if (elems_after >= n) {
+               const pointer pointer_past_last = this->priv_addr() + old_size + 1;
+               priv_uninitialized_copy(this->priv_addr() + (old_size - n + 1),
+                                       pointer_past_last, pointer_past_last);
+
+               this->priv_size(old_size+n);
+               Traits::move(const_cast(container_detail::to_raw_pointer(p + n)),
+                           container_detail::to_raw_pointer(p),
+                           (elems_after - n) + 1);
+               this->priv_copy(first, last, const_cast(container_detail::to_raw_pointer(p)));
+            }
+            else {
+               ForwardIter mid = first;
+               std::advance(mid, elems_after + 1);
+
+               priv_uninitialized_copy(mid, last, this->priv_addr() + old_size + 1);
+               this->priv_size(old_size + (n - elems_after));
+               priv_uninitialized_copy
+                  (p, const_iterator(this->priv_addr() + old_length + 1),
+                  this->priv_addr() + this->priv_size());
+               this->priv_size(this->priv_size() + elems_after);
+               this->priv_copy(first, mid, const_cast(container_detail::to_raw_pointer(p)));
+            }
+         }
+         else{
+            pointer new_start = allocation_ret.first;
+            if(!allocation_ret.second){
+               //Copy data to new buffer
+               size_type new_length = 0;
+               //This can't throw, since characters are POD
+               new_length += priv_uninitialized_copy
+                              (const_iterator(this->priv_addr()), p, new_start);
+               new_length += priv_uninitialized_copy
+                              (first, last, new_start + new_length);
+               new_length += priv_uninitialized_copy
+                              (p, const_iterator(this->priv_addr() + old_size),
+                              new_start + new_length);
+               this->priv_construct_null(new_start + new_length);
+
+               this->deallocate_block();
+               this->is_short(false);
+               this->priv_long_addr(new_start);
+               this->priv_long_size(new_length);
+               this->priv_long_storage(new_cap);
+            }
+            else{
+               //value_type is POD, so backwards expansion is much easier
+               //than with vector
+               value_type * const oldbuf     = container_detail::to_raw_pointer(old_start);
+               value_type * const newbuf     = container_detail::to_raw_pointer(new_start);
+               const value_type *const pos   = container_detail::to_raw_pointer(p);
+               const size_type before  = pos - oldbuf;
+
+               //First move old data
+               Traits::move(newbuf, oldbuf, before);
+               Traits::move(newbuf + before + n, pos, old_size - before);
+               //Now initialize the new data
+               priv_uninitialized_copy(first, last, new_start + before);
+               this->priv_construct_null(new_start + (old_size + n));
+               this->is_short(false);
+               this->priv_long_addr(new_start);
+               this->priv_long_size(old_size + n);
+               this->priv_long_storage(new_cap);
+            }
+         }
+      }
+      return this->begin() + n_pos;
+   }
+   #endif
+
    //! Requires: pos <= size()
    //!
    //! Effects: Determines the effective length xlen of the string to be removed as the smaller of n and size() - pos.
@@ -1472,8 +1615,9 @@ class basic_string
       const size_type len = container_detail::min_value(n1, size() - pos1);
       if (this->size() - len >= this->max_size() - str.size())
          this->throw_length_error();
-      return this->replace(this->priv_addr() + pos1, this->priv_addr() + pos1 + len,
-                           str.begin(), str.end());
+      return this->replace( const_iterator(this->priv_addr() + pos1)
+                          , const_iterator(this->priv_addr() + pos1 + len)
+                          , str.begin(), str.end());
    }
 
    //! Requires: pos1 <= size() and pos2 <= str.size().
@@ -1512,16 +1656,14 @@ class basic_string
    //!   if the length of the  resulting string would exceed max_size()
    //!
    //! Returns: *this
-   basic_string& replace(size_type pos1, size_type n1,
-                        const CharT* s, size_type n2)
+   basic_string& replace(size_type pos1, size_type n1, const CharT* s, size_type n2)
    {
       if (pos1 > size())
          this->throw_out_of_range();
       const size_type len = container_detail::min_value(n1, size() - pos1);
       if (n2 > this->max_size() || size() - len >= this->max_size() - n2)
          this->throw_length_error();
-      return this->replace(this->priv_addr() + pos1, this->priv_addr() + pos1 + len,
-                     s, s + n2);
+      return this->replace(this->priv_addr() + pos1, this->priv_addr() + pos1 + len, s, s + n2);
    }
 
    //! Requires: pos1 <= size() and s points to an array of at least n2 elements of CharT.
@@ -1629,14 +1771,51 @@ class basic_string
    //!
    //! Returns: *this
    template 
-   basic_string& replace(const_iterator i1, const_iterator i2, InputIter j1, InputIter j2)
+   basic_string& replace(const_iterator i1, const_iterator i2, InputIter j1, InputIter j2
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+            && container_detail::is_input_iterator::value
+         >::type * = 0
+      #endif
+      )
    {
-      //Dispatch depending on integer/iterator
-      const bool aux_boolean = container_detail::is_convertible::value;
-      typedef container_detail::bool_ Result;
-      return this->priv_replace_dispatch(i1, i2, j1, j2,  Result());
+      for ( ; i1 != i2 && j1 != j2; ++i1, ++j1){
+         Traits::assign(*const_cast(container_detail::to_raw_pointer(i1)), *j1);
+      }
+
+      if (j1 == j2)
+         this->erase(i1, i2);
+      else
+         this->insert(i2, j1, j2);
+      return *this;
    }
 
+   #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   template 
+   basic_string& replace(const_iterator i1, const_iterator i2, ForwardIter j1, ForwardIter j2
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+            && !container_detail::is_input_iterator::value
+         >::type * = 0
+      )
+   {
+      difference_type n = std::distance(j1, j2);
+      const difference_type len = i2 - i1;
+      if (len >= n) {
+         this->priv_copy(j1, j2, const_cast(container_detail::to_raw_pointer(i1)));
+         this->erase(i1 + n, i2);
+      }
+      else {
+         ForwardIter m = j1;
+         std::advance(m, len);
+         this->priv_copy(j1, m, const_cast(container_detail::to_raw_pointer(i1)));
+         this->insert(i2, m, j2);
+      }
+      return *this;
+   }
+   #endif
+
    //! Requires: pos <= size()
    //!
    //! Effects: Determines the effective length rlen of the string to copy as the
@@ -2153,46 +2332,6 @@ class basic_string
    void priv_terminate_string()
    {  this->priv_construct_null(this->priv_addr() + this->priv_size());  }
 
-   template 
-   void priv_range_initialize(InputIter f, InputIter l,
-                              std::input_iterator_tag)
-   {
-      this->allocate_initial_block(InternalBufferChars);
-      this->priv_construct_null(this->priv_addr() + this->priv_size());
-      this->append(f, l);
-   }
-
-   template 
-   void priv_range_initialize(ForwardIter f, ForwardIter l,
-                              std::forward_iterator_tag)
-   {
-      difference_type n = std::distance(f, l);
-      this->allocate_initial_block(container_detail::max_value(n+1, InternalBufferChars));
-      priv_uninitialized_copy(f, l, this->priv_addr());
-      this->priv_size(n);
-      this->priv_terminate_string();
-   }
-
-   template 
-   void priv_range_initialize(InputIter f, InputIter l)
-   {
-      typedef typename std::iterator_traits::iterator_category Category;
-      this->priv_range_initialize(f, l, Category());
-   }
-
-   template 
-   void priv_initialize_dispatch(Integer n, Integer x, container_detail::true_)
-   {
-      this->allocate_initial_block(container_detail::max_value(n+1, InternalBufferChars));
-      priv_uninitialized_fill_n(this->priv_addr(), n, x);
-      this->priv_size(n);
-      this->priv_terminate_string();
-   }
-
-   template 
-   void priv_initialize_dispatch(InputIter f, InputIter l, container_detail::false_)
-   {  this->priv_range_initialize(f, l);  }
-
    template inline
    void priv_uninitialized_fill_n(FwdIt first, Count count, const CharT val)
    {
@@ -2238,14 +2377,9 @@ class basic_string
       BOOST_CATCH_END
       return (constructed);
    }
-
-   template 
-   basic_string& priv_assign_dispatch(Integer n, Integer x, container_detail::true_)
-   {  return this->assign((size_type) n, (CharT) x);   }
-
+/*
    template 
-   basic_string& priv_assign_dispatch(InputIter f, InputIter l,
-                                      container_detail::false_)
+   basic_string& priv_assign_dispatch(InputIter f, InputIter l, container_detail::false_)
    {
       size_type cur = 0;
       CharT *ptr = container_detail::to_raw_pointer(this->priv_addr());
@@ -2262,131 +2396,7 @@ class basic_string
          this->append(f, l);
       return *this;
    }
-
-   template 
-   void priv_insert(const_iterator p, InputIter first, InputIter last, std::input_iterator_tag)
-   {
-      for ( ; first != last; ++first, ++p) {
-         p = this->insert(p, *first);
-      }
-   }
-
-   template 
-   void priv_insert(const_iterator position, ForwardIter first,
-                    ForwardIter last,  std::forward_iterator_tag)
-   {
-      if (first != last) {
-         const size_type n = std::distance(first, last);
-         const size_type old_size = this->priv_size();
-         const size_type remaining = this->capacity() - old_size;
-         const pointer old_start = this->priv_addr();
-         bool enough_capacity = false;
-         std::pair allocation_ret;
-         size_type new_cap = 0;
-
-         //Check if we have enough capacity
-         if (remaining >= n){
-            enough_capacity = true;           
-         }
-         else {
-            //Otherwise expand current buffer or allocate new storage
-            new_cap  = this->next_capacity(n);
-            allocation_ret = this->allocation_command
-                  (allocate_new | expand_fwd | expand_bwd, old_size + n + 1,
-                     new_cap, new_cap, old_start);
-
-            //Check forward expansion
-            if(old_start == allocation_ret.first){
-               enough_capacity = true;
-               this->priv_storage(new_cap);
-            }
-         }
-
-         //Reuse same buffer
-         if(enough_capacity){
-            const size_type elems_after = old_size - (position - this->priv_addr());
-            const size_type old_length = old_size;
-            if (elems_after >= n) {
-               const pointer pointer_past_last = this->priv_addr() + old_size + 1;
-               priv_uninitialized_copy(this->priv_addr() + (old_size - n + 1),
-                                       pointer_past_last, pointer_past_last);
-
-               this->priv_size(old_size+n);
-               Traits::move(const_cast(container_detail::to_raw_pointer(position + n)),
-                           container_detail::to_raw_pointer(position),
-                           (elems_after - n) + 1);
-               this->priv_copy(first, last, const_cast(container_detail::to_raw_pointer(position)));
-            }
-            else {
-               ForwardIter mid = first;
-               std::advance(mid, elems_after + 1);
-
-               priv_uninitialized_copy(mid, last, this->priv_addr() + old_size + 1);
-               this->priv_size(old_size + (n - elems_after));
-               priv_uninitialized_copy
-                  (position, const_iterator(this->priv_addr() + old_length + 1),
-                  this->priv_addr() + this->priv_size());
-               this->priv_size(this->priv_size() + elems_after);
-               this->priv_copy(first, mid, const_cast(container_detail::to_raw_pointer(position)));
-            }
-         }
-         else{
-            pointer new_start = allocation_ret.first;
-            if(!allocation_ret.second){
-               //Copy data to new buffer
-               size_type new_length = 0;
-               //This can't throw, since characters are POD
-               new_length += priv_uninitialized_copy
-                              (const_iterator(this->priv_addr()), position, new_start);
-               new_length += priv_uninitialized_copy
-                              (first, last, new_start + new_length);
-               new_length += priv_uninitialized_copy
-                              (position, const_iterator(this->priv_addr() + old_size),
-                              new_start + new_length);
-               this->priv_construct_null(new_start + new_length);
-
-               this->deallocate_block();
-               this->is_short(false);
-               this->priv_long_addr(new_start);
-               this->priv_long_size(new_length);
-               this->priv_long_storage(new_cap);
-            }
-            else{
-               //value_type is POD, so backwards expansion is much easier
-               //than with vector
-               value_type * const oldbuf     = container_detail::to_raw_pointer(old_start);
-               value_type * const newbuf     = container_detail::to_raw_pointer(new_start);
-               const value_type *const pos   = container_detail::to_raw_pointer(position);
-               const size_type before  = pos - oldbuf;
-
-               //First move old data
-               Traits::move(newbuf, oldbuf, before);
-               Traits::move(newbuf + before + n, pos, old_size - before);
-               //Now initialize the new data
-               priv_uninitialized_copy(first, last, new_start + before);
-               this->priv_construct_null(new_start + (old_size + n));
-               this->is_short(false);
-               this->priv_long_addr(new_start);
-               this->priv_long_size(old_size + n);
-               this->priv_long_storage(new_cap);
-            }
-         }
-      }
-   }
-
-   template 
-   void priv_insert_dispatch(const_iterator p, Integer n, Integer x,
-                           container_detail::true_)
-   {  insert(p, (size_type) n, (CharT) x);   }
-
-   template 
-   void priv_insert_dispatch(const_iterator p, InputIter first, InputIter last,
-                           container_detail::false_)
-   {
-      typedef typename std::iterator_traits::iterator_category Category;
-      priv_insert(p, first, last, Category());
-   }
-
+*/
    template 
    void priv_copy(InputIterator first, InputIterator last, OutIterator result)
    {
@@ -2412,40 +2422,6 @@ class basic_string
       return this->priv_replace(first, last, f, l, Category());
    }
 
-
-   template 
-   basic_string& priv_replace(const_iterator first, const_iterator last,
-                              InputIter f, InputIter l, std::input_iterator_tag)
-   {
-      for ( ; first != last && f != l; ++first, ++f)
-         Traits::assign(*first, *f);
-
-      if (f == l)
-         this->erase(first, last);
-      else
-         this->insert(last, f, l);
-      return *this;
-   }
-
-   template 
-   basic_string& priv_replace(const_iterator first, const_iterator last,
-                              ForwardIter f, ForwardIter l,
-                              std::forward_iterator_tag)
-   {
-      difference_type n = std::distance(f, l);
-      const difference_type len = last - first;
-      if (len >= n) {
-         this->priv_copy(f, l, const_cast(container_detail::to_raw_pointer(first)));
-         this->erase(first + n, last);
-      }
-      else {
-         ForwardIter m = f;
-         std::advance(m, len);
-         this->priv_copy(f, m, const_cast(container_detail::to_raw_pointer(first)));
-         this->insert(last, m, l);
-      }
-      return *this;
-   }
    /// @endcond
 };
 
diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp
index f24699e..1180d96 100644
--- a/include/boost/container/vector.hpp
+++ b/include/boost/container/vector.hpp
@@ -489,8 +489,10 @@ class vector : private container_detail::vector_alloc_holder
    explicit vector(size_type n)
       :  base_t()
    {
+      this->resize(n);
+/*
       //Allocate
-      size_type real_cap;
+      size_type real_cap = 0;
       std::pair ret =
          this->allocation_command(allocate_new, n, n, real_cap, this->members_.m_start);
       T *new_mem = container_detail::to_raw_pointer(ret.first);
@@ -503,7 +505,7 @@ class vector : private container_detail::vector_alloc_holder
       this->members_.m_start = ret.first;
       this->members_.m_size  = n;
       this->members_.m_capacity = real_cap;
-      scoped_alloc.release();
+      scoped_alloc.release();*/
    }
 
    //! Effects: Constructs a vector that will use a copy of allocator a
@@ -515,7 +517,10 @@ class vector : private container_detail::vector_alloc_holder
    //! Complexity: Linear to n.
    vector(size_type n, const T& value, const allocator_type& a = allocator_type())
       :  base_t(a)
-   {  this->insert(this->cend(), n, value); }
+   {
+      this->resize(n, value);
+//      this->insert(this->cend(), n, value);
+   }
 
    //! Effects: Copy constructs a vector.
    //!
@@ -571,7 +576,7 @@ class vector : private container_detail::vector_alloc_holder
       }
       else{
          this->assign( container_detail::to_raw_pointer(mx.members_.m_start)
-                     , container_detail::to_raw_pointer(mx.members_.m_start + mx.members_.m_size));
+                     , container_detail::to_raw_pointer(mx.members_.m_start) + mx.members_.m_size);
       }
    }
 
@@ -1002,14 +1007,155 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Linear to n.
    template 
-   void assign(InIt first, InIt last)
+   void assign(InIt first, InIt last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+            && container_detail::is_input_iterator::value
+         >::type * = 0
+      #endif
+      )
    {
-      //Dispatch depending on integer/iterator
-      const bool aux_boolean = container_detail::is_convertible::value;
-      typedef container_detail::bool_ Result;
-      this->priv_assign_dispatch(first, last, Result());
+      //Overwrite all elements we can from [first, last)
+      iterator cur = begin();
+      for ( ; first != last && cur != end(); ++cur, ++first){
+         *cur = *first;
+      }
+
+      if (first == last){
+         //There are no more elements in the sequence, erase remaining
+         this->erase(cur, cend());
+      }
+      else{
+         //There are more elements in the range, insert the remaining ones
+         this->insert(this->cend(), first, last);
+      }
    }
 
+   #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   template 
+   void assign(FwdIt first, FwdIt last
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+            && !container_detail::is_input_iterator::value
+         >::type * = 0
+      )
+   {
+      const size_type n = std::distance(first, last);
+      
+      if(!n){
+         this->prot_destroy_all();
+         return;
+      }
+      //Check if we have enough memory or try to expand current memory
+      size_type remaining = this->members_.m_capacity - this->members_.m_size;
+      bool same_buffer_start;
+      std::pair ret;
+      size_type real_cap = this->members_.m_capacity;
+
+      if (n <= remaining){
+         same_buffer_start = true;
+      }
+      else{
+         //There is not enough memory, allocate a new buffer
+         size_type new_cap = this->next_capacity(n);
+         ret = this->allocation_command
+               (allocate_new | expand_fwd | expand_bwd,
+                  this->size() + n, new_cap, real_cap, this->members_.m_start);
+         same_buffer_start = ret.second && this->members_.m_start == ret.first;
+         if(same_buffer_start){
+            this->members_.m_capacity  = real_cap;
+         }
+      }
+     
+      if(same_buffer_start){
+         T *start = container_detail::to_raw_pointer(this->members_.m_start);
+         if (this->size() >= n){
+            //There is memory, but there are more old elements than new ones
+            //Overwrite old elements with new ones
+            std::copy(first, last, start);
+            //Destroy remaining old elements
+            this->destroy_n(start + n, this->members_.m_size - n);
+            this->members_.m_size = n;
+         }
+         else{
+            //There is memory, but there are less old elements than new ones
+            //First overwrite some old elements with new ones
+            FwdIt mid = first;
+            std::advance(mid, this->size());
+            T *end = std::copy(first, mid, start);
+            //Initialize the remaining new elements in the uninitialized memory
+            ::boost::container::uninitialized_copy_or_move_alloc(this->alloc(), mid, last, end);
+            this->members_.m_size = n;
+         }
+      }
+      else if(!ret.second){
+         typename value_traits::ArrayDeallocator scoped_alloc(ret.first, this->alloc(), real_cap);
+         ::boost::container::uninitialized_copy_or_move_alloc(this->alloc(), first, last, container_detail::to_raw_pointer(ret.first));
+         scoped_alloc.release();
+         //Destroy and deallocate old buffer
+         if(this->members_.m_start != 0){
+            this->destroy_n(container_detail::to_raw_pointer(this->members_.m_start), this->members_.m_size);
+            this->alloc().deallocate(this->members_.m_start, this->members_.m_capacity);
+         }
+         this->members_.m_start     = ret.first;
+         this->members_.m_size      = n;
+         this->members_.m_capacity  = real_cap;
+      }
+      else{
+         //Backwards expansion
+         //If anything goes wrong, this object will destroy old objects
+         T *old_start         = container_detail::to_raw_pointer(this->members_.m_start);
+         size_type old_size   = this->members_.m_size;
+         typename value_traits::OldArrayDestructor old_values_destroyer(old_start, this->alloc(), old_size);
+         //If something goes wrong size will be 0
+         //but holding the whole buffer
+         this->members_.m_size  = 0;
+         this->members_.m_start = ret.first;
+         this->members_.m_capacity = real_cap;
+        
+         //Backup old buffer data
+         size_type old_offset    = old_start - container_detail::to_raw_pointer(ret.first);
+         size_type first_count   = container_detail::min_value(n, old_offset);
+
+         FwdIt mid = first;
+         std::advance(mid, first_count);
+         ::boost::container::uninitialized_copy_or_move_alloc
+            (this->alloc(), first, mid, container_detail::to_raw_pointer(ret.first));
+
+         if(old_offset > n){
+            //All old elements will be destroyed by "old_values_destroyer"
+            this->members_.m_size = n;
+         }
+         else{
+            //We have constructed objects from the new begin until
+            //the old end so release the rollback destruction
+            old_values_destroyer.release();
+            this->members_.m_start  = ret.first;
+            this->members_.m_size   = first_count + old_size;
+            //Now overwrite the old values
+            size_type second_count = container_detail::min_value(old_size, n - first_count);
+            FwdIt mid2 = mid;
+            std::advance(mid2, second_count);
+            std::copy(mid, mid2, old_start);
+           
+            //Check if we still have to append elements in the
+            //uninitialized end
+            if(second_count == old_size){
+               std::copy(mid2, last, old_start + old_size);
+            }
+            else{
+               //We have to destroy some old values
+               this->destroy_n
+                  (old_start + second_count, old_size - second_count);
+               this->members_.m_size = n;
+            }
+            this->members_.m_size = n;                       
+         }
+      }
+   }
+   #endif
+
    #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
    //! Effects: Inserts a copy of x at the end of the vector.
    //!
@@ -1051,7 +1197,7 @@ class vector : private container_detail::vector_alloc_holder
       else{
          typedef container_detail::advanced_insert_aux_emplace type;
          type &&proxy = type(this->alloc(), ::boost::forward(args)...);
-         priv_range_insert(back_pos, 1, proxy);
+         this->priv_forward_range_insert(back_pos, 1, proxy);
       }
    }
 
@@ -1072,7 +1218,7 @@ class vector : private container_detail::vector_alloc_holder
       size_type pos_n = position - cbegin();
       typedef container_detail::advanced_insert_aux_emplace type;
       type &&proxy = type(this->alloc(), ::boost::forward(args)...);
-      priv_range_insert(position.get_ptr(), 1, proxy);
+      this->priv_forward_range_insert(position.get_ptr(), 1, proxy);
       return iterator(this->members_.m_start + pos_n);
    }
 
@@ -1093,7 +1239,7 @@ class vector : private container_detail::vector_alloc_holder
          container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)      \
              proxy                                   \
             (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));     \
-         priv_range_insert(back_pos, 1, proxy);                                                 \
+         this->priv_forward_range_insert(back_pos, 1, proxy);                                   \
       }                                                                                         \
    }                                                                                            \
                                                                                                 \
@@ -1105,7 +1251,7 @@ class vector : private container_detail::vector_alloc_holder
          container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)      \
              proxy                                   \
             (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));     \
-      priv_range_insert(container_detail::to_raw_pointer(pos.get_ptr()), 1, proxy);             \
+      this->priv_forward_range_insert(container_detail::to_raw_pointer(pos.get_ptr()), 1,proxy);\
       return iterator(this->members_.m_start + pos_n);                                          \
    }                                                                                            \
    //!
@@ -1152,32 +1298,63 @@ class vector : private container_detail::vector_alloc_holder
    BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator)
    #endif
 
-   //! Requires: pos must be a valid iterator of *this.
+   //! Requires: p must be a valid iterator of *this.
    //!
    //! Effects: Insert a copy of the [first, last) range before pos.
    //!
+   //! Returns: an iterator to the first inserted element or pos if first == last.
+   //!
    //! Throws: If memory allocation throws, T's constructor from a
    //!   dereferenced InpIt throws or T's copy/move constructor/assignment throws.
    //!
    //! Complexity: Linear to std::distance [first, last).
    template 
-   void insert(const_iterator pos, InIt first, InIt last)
+   iterator insert(const_iterator pos, InIt first, InIt last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+            && container_detail::is_input_iterator::value
+         >::type * = 0
+      #endif
+      )
    {
-      //Dispatch depending on integer/iterator
-      const bool aux_boolean = container_detail::is_convertible::value;
-      typedef container_detail::bool_ Result;
-      this->priv_insert_dispatch(pos, first, last, Result());
+      const size_type n_pos = pos - this->cbegin();
+      iterator it(pos.get_ptr());
+      for(;first != last; ++first){
+         it = this->emplace(it, *first);
+         ++it;
+      }
+      return this->begin() + n_pos;
    }
 
-   //! Requires: pos must be a valid iterator of *this.
+   #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   template 
+   iterator insert(const_iterator pos, FwdIt first, FwdIt last
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+            && !container_detail::is_input_iterator::value
+         >::type * = 0
+      )
+   {
+      const size_type n_pos = pos - this->cbegin();
+      const size_type n = std::distance(first, last);
+      container_detail::advanced_insert_aux_proxy proxy(this->alloc(), first, last);
+      this->priv_forward_range_insert(pos.get_ptr(), n, proxy);
+      return this->begin() + n_pos;
+   }
+   #endif
+
+   //! Requires: p must be a valid iterator of *this.
    //!
    //! Effects: Insert n copies of x before pos.
    //!
+   //! Returns: an iterator to the first inserted element or p if n is 0.
+   //!
    //! Throws: If memory allocation throws or T's copy constructor throws.
    //!
    //! Complexity: Linear to n.
-   void insert(const_iterator p, size_type n, const T& x)
-   {  this->insert(p, cvalue_iterator(x, n), cvalue_iterator());  }
+   iterator insert(const_iterator p, size_type n, const T& x)
+   {  return this->insert(p, cvalue_iterator(x, n), cvalue_iterator());  }
 
    //! Effects: Removes the last element from the vector.
    //!
@@ -1262,10 +1439,10 @@ class vector : private container_detail::vector_alloc_holder
          this->erase(const_iterator(this->members_.m_start + new_size), this->end());
       }
       else{
-         size_type n = new_size - this->size();
+         const size_type n = new_size - this->size();
          this->reserve(new_size);
          container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
-         priv_range_insert(this->cend().get_ptr(), n, proxy);
+         this->priv_forward_range_insert(this->cend().get_ptr(), n, proxy);
       }
    }
 
@@ -1399,27 +1576,7 @@ class vector : private container_detail::vector_alloc_holder
       }
    }
 
-   template 
-   void priv_range_insert(const_iterator pos, FwdIt first, FwdIt last, std::forward_iterator_tag)
-   {
-      if(first != last){       
-         const size_type n = std::distance(first, last);
-         container_detail::advanced_insert_aux_proxy proxy(this->alloc(), first, last);
-         priv_range_insert(pos.get_ptr(), n, proxy);
-      }
-   }
-
-   template 
-   void priv_range_insert(const_iterator pos, InIt first, InIt last, std::input_iterator_tag)
-   {
-      iterator it(pos.get_ptr());
-      for(;first != last; ++first){
-         it = this->emplace(it, *first);
-         ++it;
-      }
-   }
-
-   void priv_range_insert(pointer pos, const size_type n, advanced_insert_aux_int_t &interf)
+   void priv_forward_range_insert(pointer pos, const size_type n, advanced_insert_aux_int_t &interf)
    {
       //Check if we have enough memory or try to expand current memory
       size_type remaining = this->members_.m_capacity - this->members_.m_size;
@@ -1575,7 +1732,7 @@ class vector : private container_detail::vector_alloc_holder
    //                 |_>_>_>_>_>^                    
    //
    //
-   //New situation in Case B (hole_size >= 0):
+   //New situation in Case B (hole_size > 0):
    // range is moved through uninitialized moves
    //
    //       first_pos   last_pos         old_limit
@@ -2001,173 +2158,10 @@ class vector : private container_detail::vector_alloc_holder
       }
    }
 
-   template 
-   void priv_assign_aux(InIt first, InIt last, std::input_iterator_tag)
-   {
-      //Overwrite all elements we can from [first, last)
-      iterator cur = begin();
-      for ( ; first != last && cur != end(); ++cur, ++first){
-         *cur = *first;
-      }
-
-      if (first == last){
-         //There are no more elements in the sequence, erase remaining
-         this->erase(cur, cend());
-      }
-      else{
-         //There are more elements in the range, insert the remaining ones
-         this->insert(this->cend(), first, last);
-      }
-   }
-
-   template 
-   void priv_assign_aux(FwdIt first, FwdIt last, std::forward_iterator_tag)
-   {
-      size_type n = std::distance(first, last);
-      if(!n){
-         this->prot_destroy_all();
-         return;
-      }
-      //Check if we have enough memory or try to expand current memory
-      size_type remaining = this->members_.m_capacity - this->members_.m_size;
-      bool same_buffer_start;
-      std::pair ret;
-      size_type real_cap = this->members_.m_capacity;
-
-      if (n <= remaining){
-         same_buffer_start = true;
-      }
-      else{
-         //There is not enough memory, allocate a new buffer
-         size_type new_cap = this->next_capacity(n);
-         ret = this->allocation_command
-               (allocate_new | expand_fwd | expand_bwd,
-                  this->size() + n, new_cap, real_cap, this->members_.m_start);
-         same_buffer_start = ret.second && this->members_.m_start == ret.first;
-         if(same_buffer_start){
-            this->members_.m_capacity  = real_cap;
-         }
-      }
-     
-      if(same_buffer_start){
-         T *start = container_detail::to_raw_pointer(this->members_.m_start);
-         if (this->size() >= n){
-            //There is memory, but there are more old elements than new ones
-            //Overwrite old elements with new ones
-            std::copy(first, last, start);
-            //Destroy remaining old elements
-            this->destroy_n(start + n, this->members_.m_size - n);
-            this->members_.m_size = n;
-         }
-         else{
-            //There is memory, but there are less old elements than new ones
-            //First overwrite some old elements with new ones
-            FwdIt mid = first;
-            std::advance(mid, this->size());
-            // iG T *end = std::copy(first, mid, start);
-            T *end = std::copy(first, mid, start);
-            //Initialize the remaining new elements in the uninitialized memory
-            ::boost::container::uninitialized_copy_or_move_alloc(this->alloc(), mid, last, end);
-            this->members_.m_size = n;
-         }
-      }
-      else if(!ret.second){
-         typename value_traits::ArrayDeallocator scoped_alloc(ret.first, this->alloc(), real_cap);
-         ::boost::container::uninitialized_copy_or_move_alloc(this->alloc(), first, last, container_detail::to_raw_pointer(ret.first));
-         scoped_alloc.release();
-         //Destroy and deallocate old buffer
-         if(this->members_.m_start != 0){
-            this->destroy_n(container_detail::to_raw_pointer(this->members_.m_start), this->members_.m_size);
-            this->alloc().deallocate(this->members_.m_start, this->members_.m_capacity);
-         }
-         this->members_.m_start     = ret.first;
-         this->members_.m_size      = n;
-         this->members_.m_capacity  = real_cap;
-      }
-      else{
-         //Backwards expansion
-         //If anything goes wrong, this object will destroy old objects
-         T *old_start         = container_detail::to_raw_pointer(this->members_.m_start);
-         size_type old_size   = this->members_.m_size;
-         typename value_traits::OldArrayDestructor old_values_destroyer(old_start, this->alloc(), old_size);
-         //If something goes wrong size will be 0
-         //but holding the whole buffer
-         this->members_.m_size  = 0;
-         this->members_.m_start = ret.first;
-         this->members_.m_capacity = real_cap;
-        
-         //Backup old buffer data
-         size_type old_offset    = old_start - container_detail::to_raw_pointer(ret.first);
-         size_type first_count   = container_detail::min_value(n, old_offset);
-
-         FwdIt mid = first;
-         std::advance(mid, first_count);
-         ::boost::container::uninitialized_copy_or_move_alloc
-            (this->alloc(), first, mid, container_detail::to_raw_pointer(ret.first));
-
-         if(old_offset > n){
-            //All old elements will be destroyed by "old_values_destroyer"
-            this->members_.m_size = n;
-         }
-         else{
-            //We have constructed objects from the new begin until
-            //the old end so release the rollback destruction
-            old_values_destroyer.release();
-            this->members_.m_start  = ret.first;
-            this->members_.m_size   = first_count + old_size;
-            //Now overwrite the old values
-            size_type second_count = container_detail::min_value(old_size, n - first_count);
-            FwdIt mid2 = mid;
-            std::advance(mid2, second_count);
-            // iG std::copy(mid, mid2, old_start);
-            std::copy(mid, mid2, old_start);
-           
-            //Check if we still have to append elements in the
-            //uninitialized end
-            if(second_count == old_size){
-               // iG std::copy(mid2, last, old_start + old_size);
-               std::copy(mid2, last, old_start + old_size);
-            }
-            else{
-               //We have to destroy some old values
-               this->destroy_n
-                  (old_start + second_count, old_size - second_count);
-               this->members_.m_size = n;
-            }
-            this->members_.m_size = n;                       
-         }
-      }
-   }
-
-   template 
-   void priv_assign_dispatch(Integer n, Integer val, container_detail::true_)
-   { this->assign((size_type) n, (value_type)val); }
-
-   template 
-   void priv_assign_dispatch(InIt first, InIt last, container_detail::false_)
-   {
-      //Dispatch depending on integer/iterator
-      typedef typename std::iterator_traits::iterator_category ItCat;
-      this->priv_assign_aux(first, last, ItCat());
-   }
-
-   template 
-   void priv_insert_dispatch(const_iterator pos, Integer n, Integer val, container_detail::true_)
-   {  this->insert(pos, (size_type)n, (T)val);  }
-
-   template 
-   void priv_insert_dispatch(const_iterator pos, InIt first,
-                             InIt last,      container_detail::false_)
-   {
-      //Dispatch depending on integer/iterator
-      typedef typename std::iterator_traits::iterator_category ItCat;
-      this->priv_range_insert(pos, first, last, ItCat());
-   }
-
    void priv_check_range(size_type n) const
    {
       //If n is out of range, throw an out_of_range exception
-      if (n >= size())
+      if (n >= this->size())
          throw std::out_of_range("vector::at");
    }
 
diff --git a/proj/to-do.txt b/proj/to-do.txt
index 072519c..7cb2844 100644
--- a/proj/to-do.txt
+++ b/proj/to-do.txt
@@ -34,6 +34,17 @@ Write forward_list
 
 check move if noexcept conditions in vector, deque and stable_vector
 
+Add noexcept testing using static_assert (Howard Hinnants's suggestion):
+
+   #include 
+
+   struct A
+   {
+      void foo() noexcept;
+   };
+
+   static_assert(noexcept(std::declval().foo()), "A::foo() should be noexcept");
+
 Detect always equal or unequal allocators at compiler time. operator== returns true_type or false_type
 
 change virtual functions with pointers to avoid template instantiation for every type
diff --git a/proj/vc7ide/allocator_traits_test.vcproj b/proj/vc7ide/allocator_traits_test.vcproj
index ad50eba..6e73236 100644
--- a/proj/vc7ide/allocator_traits_test.vcproj
+++ b/proj/vc7ide/allocator_traits_test.vcproj
@@ -132,6 +132,9 @@
 			Name="Header Files"
 			Filter="h;hpp;hxx;hm;inl;inc;xsd"
 			UniqueIdentifier="{93815995-89BD-b043-5E8B-65FBE52E2AFB}">
+			
+			
 		
 	
 	
diff --git a/proj/vc7ide/container.sln b/proj/vc7ide/container.sln
index 591f0fc..68beb93 100644
--- a/proj/vc7ide/container.sln
+++ b/proj/vc7ide/container.sln
@@ -51,6 +51,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scoped_allocator_usage_test
 	ProjectSection(ProjectDependencies) = postProject
 	EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hash_table_test", "hash_table_test.vcproj", "{58CCE183-6092-48FE-A4F7-BA0D3A792606}"
+	ProjectSection(ProjectDependencies) = postProject
+	EndProjectSection
+EndProject
 Global
 	GlobalSection(SolutionConfiguration) = preSolution
 		Debug = Debug
@@ -111,6 +115,10 @@ Global
 		{B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Debug.Build.0 = Debug|Win32
 		{B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Release.ActiveCfg = Release|Win32
 		{B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Release.Build.0 = Release|Win32
+		{58CCE183-6092-48FE-A4F7-BA0D3A792606}.Debug.ActiveCfg = Debug|Win32
+		{58CCE183-6092-48FE-A4F7-BA0D3A792606}.Debug.Build.0 = Debug|Win32
+		{58CCE183-6092-48FE-A4F7-BA0D3A792606}.Release.ActiveCfg = Release|Win32
+		{58CCE183-6092-48FE-A4F7-BA0D3A792606}.Release.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 	EndGlobalSection
diff --git a/proj/vc7ide/container.vcproj b/proj/vc7ide/container.vcproj
index fcd9e8a..ca5a3e3 100644
--- a/proj/vc7ide/container.vcproj
+++ b/proj/vc7ide/container.vcproj
@@ -145,6 +145,9 @@
 			
 			
+			
+			
 			
 			
@@ -261,7 +264,7 @@
 					RelativePath="..\..\..\..\boost\container\detail\math_functions.hpp">
 				
 				
+					RelativePath="..\..\..\..\boost\container\detail\memory_util.hpp">
 				
 				
diff --git a/test/check_equal_containers.hpp b/test/check_equal_containers.hpp
index 69d642c..c094711 100644
--- a/test/check_equal_containers.hpp
+++ b/test/check_equal_containers.hpp
@@ -12,6 +12,8 @@
 #define BOOST_CONTAINER_TEST_CHECK_EQUAL_CONTAINER_HPP
 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -20,6 +22,24 @@ namespace boost{
 namespace container {
 namespace test{
 
+template< class T1, class T2>
+bool CheckEqual( const T1 &t1, const T2 &t2
+               , typename boost::container::container_detail::enable_if_c
+                  ::value && 
+                   !boost::container::container_detail::is_pair::value
+                  >::type* = 0)
+{  return t1 == t2;  }
+
+template< class Pair1, class Pair2>
+bool CheckEqual( const Pair1 &pair1, const Pair2 &pair2
+               , typename boost::container::container_detail::enable_if_c
+                  ::value && 
+                   boost::container::container_detail::is_pair::value
+                  >::type* = 0)
+{
+   return CheckEqual(pair1.first, pair2.first) && CheckEqual(pair1.second, pair2.second);
+}
+
 //Function to check if both containers are equal
 template
@@ -38,10 +58,13 @@ bool CheckEqualContainers(const MyBoostCont *boostcont, const MyStdCont *stdcont
    }
    std::size_t i = 0;
    for(; itboost != itboostend; ++itboost, ++itstd, ++i){
-      value_type val(*itstd);
+
+      if(!CheckEqual(*itstd, *itboost))
+         return false;
+/*    value_type val(*itstd);
       const value_type &v = *itboost;
       if(v != val)
-         return false;
+         return false;*/
    }
    return true;
 }
diff --git a/test/deque_test.cpp b/test/deque_test.cpp
index 53f17a3..fbc4ab6 100644
--- a/test/deque_test.cpp
+++ b/test/deque_test.cpp
@@ -63,7 +63,7 @@ bool deque_copyable_only(V1 *cntdeque, V2 *stddeque, container_detail::true_type
    typedef typename V1::value_type IntType;
    std::size_t size = cntdeque->size();
    stddeque->insert(stddeque->end(), 50, 1);
-   cntdeque->insert(cntdeque->end(), 50, 1);
+   cntdeque->insert(cntdeque->end(), 50, IntType(1));
    if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
    {
       IntType move_me(1);
diff --git a/test/input_from_forward_iterator.hpp b/test/input_from_forward_iterator.hpp
new file mode 100644
index 0000000..348d144
--- /dev/null
+++ b/test/input_from_forward_iterator.hpp
@@ -0,0 +1,80 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2012-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)
+//
+// See http://www.boost.org/libs/container for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_CONTAINER_TEST_FORWARD_TO_INPUT_ITERATOR_HPP
+#define BOOST_CONTAINER_TEST_FORWARD_TO_INPUT_ITERATOR_HPP
+
+#include 
+
+namespace boost{
+namespace container {
+namespace test{
+
+template
+class input_iterator_wrapper
+   : public std::iterator< std::input_iterator_tag
+                         , typename std::iterator_traits::value_type
+                         , typename std::iterator_traits::difference_type
+                         , typename std::iterator_traits::pointer
+                         , typename std::iterator_traits::reference
+                         >
+{
+   FwdIterator m_it;
+
+   public:
+   input_iterator_wrapper()
+      : m_it(0)
+   {}
+
+   explicit input_iterator_wrapper(FwdIterator it)
+      : m_it(it)
+   {}
+
+   //Default copy constructor...
+   //input_iterator_wrapper(const input_iterator_wrapper&);
+
+   //Default assignment...
+   //input_iterator_wrapper &operator=(const input_iterator_wrapper&);
+
+   //Default destructor...
+   //~input_iterator_wrapper();
+
+   typename std::iterator_traits::reference operator*() const
+   { return *m_it; }
+
+   typename std::iterator_traits::pointer operator->() const
+   { return m_it.operator->(); }
+
+   input_iterator_wrapper& operator++()
+   {  ++m_it;  return *this;  }
+
+   input_iterator_wrapper operator++(int )
+   {
+      input_iterator_wrapper tmp(m_it);
+      ++m_it;
+      return tmp;
+   }
+
+   friend bool operator==(const input_iterator_wrapper &left, const input_iterator_wrapper &right)
+   {  return left.m_it == right.m_it;  }
+
+   friend bool operator!=(const input_iterator_wrapper &left, const input_iterator_wrapper &right)
+   {  return left.m_it != right.m_it;  }
+};
+
+template
+input_iterator_wrapper make_input_from_forward_iterator(const FwdIterator &it)
+{  return input_iterator_wrapper(it); }
+
+}  //namespace test{
+}  //namespace container {
+}  //namespace boost{
+
+#endif //BOOST_CONTAINER_TEST_FORWARD_TO_INPUT_ITERATOR_HPP
diff --git a/test/list_test.hpp b/test/list_test.hpp
index 6862ffe..85f1b73 100644
--- a/test/list_test.hpp
+++ b/test/list_test.hpp
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include "print_container.hpp"
+#include "input_from_forward_iterator.hpp"
 #include 
 #include 
 
@@ -177,7 +178,20 @@ int list_test (bool copied_allocators_equal = true)
             aux_vect2[i] = -1;
          }
          boostlist->assign(boost::make_move_iterator(&aux_vect[0])
-                        ,boost::make_move_iterator(&aux_vect[50]));
+                          ,boost::make_move_iterator(&aux_vect[50]));
+         stdlist->assign(&aux_vect2[0], &aux_vect2[50]);
+         if(!CheckEqualContainers(boostlist, stdlist)) return 1;
+
+         for(int i = 0; i < 50; ++i){
+            IntType move_me(-1);
+            aux_vect[i] = boost::move(move_me);
+         }
+
+         for(int i = 0; i < 50; ++i){
+            aux_vect2[i] = -1;
+         }
+         boostlist->assign(boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0]))
+                          ,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[50])));
          stdlist->assign(&aux_vect2[0], &aux_vect2[50]);
          if(!CheckEqualContainers(boostlist, stdlist)) return 1;
       }
@@ -206,10 +220,36 @@ int list_test (bool copied_allocators_equal = true)
          for(int i = 0; i < 50; ++i){
             aux_vect2[i] = -1;
          }
-         boostlist->insert(boostlist->begin()
+         typename MyBoostList::iterator old_begin = boostlist->begin();
+         typename MyBoostList::iterator it_insert =
+            boostlist->insert(boostlist->begin()
                         ,boost::make_move_iterator(&aux_vect[0])
                         ,boost::make_move_iterator(&aux_vect[50]));
+         if(it_insert != boostlist->begin() || std::distance(it_insert, old_begin) != 50)
+            return 1;
+
          stdlist->insert(stdlist->begin(), &aux_vect2[0], &aux_vect2[50]);
+         if(!CheckEqualContainers(boostlist, stdlist))
+            return 1;
+
+         for(int i = 0; i < 50; ++i){
+            IntType move_me(-1);
+            aux_vect[i] = boost::move(move_me);
+         }
+
+         for(int i = 0; i < 50; ++i){
+            aux_vect2[i] = -1;
+         }
+
+         old_begin = boostlist->begin();
+         it_insert = boostlist->insert(boostlist->end()
+                        ,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0]))
+                        ,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[50])));
+         if(std::distance(it_insert, boostlist->end()) != 50)
+            return 1;
+         stdlist->insert(stdlist->end(), &aux_vect2[0], &aux_vect2[50]);
+         if(!CheckEqualContainers(boostlist, stdlist))
+            return 1;
       }
 
       boostlist->unique();
diff --git a/test/movable_int.hpp b/test/movable_int.hpp
index 9402b16..d895845 100644
--- a/test/movable_int.hpp
+++ b/test/movable_int.hpp
@@ -73,6 +73,12 @@ class movable_int
    int get_int() const
    {  return m_int;  }
 
+   friend bool operator==(const movable_int &l, int r)
+   {  return l.get_int() == r;   }
+
+   friend bool operator==(int l, const movable_int &r)
+   {  return l == r.get_int();   }
+
    private:
    int m_int;
 };
@@ -144,6 +150,12 @@ class movable_and_copyable_int
    int get_int() const
    {  return m_int;  }
 
+   friend bool operator==(const movable_and_copyable_int &l, int r)
+   {  return l.get_int() == r;   }
+
+   friend bool operator==(int l, const movable_and_copyable_int &r)
+   {  return l == r.get_int();   }
+
    private:
    int m_int;
 };
@@ -202,6 +214,12 @@ class copyable_int
    int get_int() const
    {  return m_int;  }
 
+   friend bool operator==(const copyable_int &l, int r)
+   {  return l.get_int() == r;   }
+
+   friend bool operator==(int l, const copyable_int &r)
+   {  return l == r.get_int();   }
+
    private:
    int m_int;
 };
@@ -256,10 +274,17 @@ class non_copymovable_int
    int get_int() const
    {  return m_int;  }
 
+   friend bool operator==(const non_copymovable_int &l, int r)
+   {  return l.get_int() == r;   }
+
+   friend bool operator==(int l, const non_copymovable_int &r)
+   {  return l == r.get_int();   }
+
    private:
    int m_int;
 };
 
+
 }  //namespace test {
 }  //namespace container {
 }  //namespace boost {
diff --git a/test/set_test.hpp b/test/set_test.hpp
index 2afe4ce..20554df 100644
--- a/test/set_test.hpp
+++ b/test/set_test.hpp
@@ -88,13 +88,13 @@ int set_test ()
          IntType move_me(i);
          aux_vect3[i] = boost::move(move_me);
       }
-/*
-      MyBoostSet *boostset3 = MyBoostSet
+
+      MyBoostSet *boostset3 = new MyBoostSet
             ( ordered_unique_range
             , boost::make_move_iterator(&aux_vect[0])
             , boost::make_move_iterator(aux_vect + 50));
       MyStdSet *stdset3 = new MyStdSet(aux_vect2, aux_vect2 + 50);
-      MyBoostMultiSet *boostmultiset3 = MyBoostMultiSet
+      MyBoostMultiSet *boostmultiset3 = new MyBoostMultiSet
             ( ordered_range
             , boost::make_move_iterator(&aux_vect3[0])
             , boost::make_move_iterator(aux_vect3 + 50));
@@ -108,15 +108,15 @@ int set_test ()
          std::cout << "Error in construct(MyBoostMultiSet3)" << std::endl;
          return 1;
       }
-*/
+
       delete boostset2;
       delete boostmultiset2;
       delete stdset2;
       delete stdmultiset2;
-      //delete boostset3;
-      //delete boostmultiset3;
-      //delete stdset3;
-      //delete stdmultiset3;
+      delete boostset3;
+      delete boostmultiset3;
+      delete stdset3;
+      delete stdmultiset3;
    }
 
    int i, j;
diff --git a/test/vector_test.hpp b/test/vector_test.hpp
index a46d42b..f868686 100644
--- a/test/vector_test.hpp
+++ b/test/vector_test.hpp
@@ -8,6 +8,9 @@
 //
 //////////////////////////////////////////////////////////////////////////////
 
+#ifndef BOOST_CONTAINER_TEST_VECTOR_TEST_HEADER
+#define BOOST_CONTAINER_TEST_VECTOR_TEST_HEADER
+
 #include 
 #include 
 #include 
@@ -24,6 +27,7 @@
 #include 
 #include 
 #include "emplace_test.hpp"
+#include "input_from_forward_iterator.hpp"
 
 namespace boost{
 namespace container {
@@ -133,10 +137,11 @@ int vector_test()
             for(int i = 0; i < 50; ++i){
                aux_vect2[i] = -1;
             }
-
-            boostvector->insert(boostvector->end()
+            typename MyBoostVector::iterator insert_it =
+               boostvector->insert(boostvector->end()
                               ,boost::make_move_iterator(&aux_vect[0])
                               ,boost::make_move_iterator(aux_vect + 50));
+            if(std::size_t(std::distance(insert_it, boostvector->end())) != 50) return 1;
             stdvector->insert(stdvector->end(), aux_vect2, aux_vect2 + 50);
             if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
 
@@ -156,9 +161,30 @@ int vector_test()
             for(int i = 0; i < 50; ++i){
                aux_vect2[i] = -1;
             }
-            boostvector->insert(boostvector->begin()
+            typename MyBoostVector::iterator insert_it =
+               boostvector->insert(boostvector->begin()
                               ,boost::make_move_iterator(&aux_vect[0])
                               ,boost::make_move_iterator(aux_vect + 50));
+            if(boostvector->begin() != insert_it) return 1;
+            stdvector->insert(stdvector->begin(), aux_vect2, aux_vect2 + 50);
+            if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
+
+            for(int i = 0; i < 50; ++i){
+               IntType new_int(-1);
+               aux_vect[i] = boost::move(new_int);
+            }
+
+            for(int i = 0; i < 50; ++i){
+               aux_vect2[i] = -1;
+            }
+            //Now try with input iterators instead
+            insert_it = boostvector->insert(boostvector->begin()
+//                              ,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0]))
+//                              ,boost::make_move_iterator(make_input_from_forward_iterator(aux_vect + 50))
+                              ,boost::make_move_iterator(&aux_vect[0])
+                              ,boost::make_move_iterator(aux_vect + 50)
+                           );
+            if(boostvector->begin() != insert_it) return 1;
             stdvector->insert(stdvector->begin(), aux_vect2, aux_vect2 + 50);
             if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
          }
@@ -204,12 +230,20 @@ int vector_test()
          //Test insertion from list
          {
             std::list l(50, int(1));
-            boostvector->insert(boostvector->begin(), l.begin(), l.end());
+            typename MyBoostVector::iterator it_insert =
+               boostvector->insert(boostvector->begin(), l.begin(), l.end());
+            if(boostvector->begin() != it_insert) return 1;
             stdvector->insert(stdvector->begin(), l.begin(), l.end());
             if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
             boostvector->assign(l.begin(), l.end());
             stdvector->assign(l.begin(), l.end());
             if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
+
+            boostvector->clear();
+            stdvector->clear();
+            boostvector->assign(make_input_from_forward_iterator(l.begin()), make_input_from_forward_iterator(l.end()));
+            stdvector->assign(l.begin(), l.end());
+            if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
          }
 /*
          std::size_t cap = boostvector->capacity();
@@ -252,3 +286,6 @@ int vector_test()
 }  //namespace boost{
 
 #include 
+
+#endif //BOOST_CONTAINER_TEST_VECTOR_TEST_HEADER
+

From a8d20305dc808ad26a9819be0c613fcd3bdbf44c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Wed, 5 Sep 2012 09:28:24 +0000
Subject: [PATCH 48/93] Improved type safety and strict aliasing

[SVN r80404]
---
 .../detail/multiallocation_chain.hpp          |  23 +-
 include/boost/container/stable_vector.hpp     | 498 +++++++++---------
 include/boost/container/string.hpp            | 364 +++++++------
 test/check_equal_containers.hpp               |   5 -
 4 files changed, 467 insertions(+), 423 deletions(-)

diff --git a/include/boost/container/detail/multiallocation_chain.hpp b/include/boost/container/detail/multiallocation_chain.hpp
index c995253..e701643 100644
--- a/include/boost/container/detail/multiallocation_chain.hpp
+++ b/include/boost/container/detail/multiallocation_chain.hpp
@@ -157,18 +157,20 @@ class transform_multiallocation_chain
    MultiallocationChain   holder_;
    typedef typename MultiallocationChain::void_pointer   void_pointer;
    typedef typename boost::intrusive::pointer_traits
-      ::template rebind_pointer::type   pointer;
+                                           void_pointer_traits;
+   typedef typename void_pointer_traits::template
+      rebind_pointer::type                            pointer;
+   typedef typename boost::intrusive::pointer_traits
+                                                pointer_traits;
 
-   static pointer cast(void_pointer p)
-   {
-      return pointer(static_cast(container_detail::to_raw_pointer(p)));
-   }
+   static pointer cast(const void_pointer &p)
+   {  return pointer_traits::static_cast_from(p);  }
 
    public:
    typedef transform_iterator
       < typename MultiallocationChain::iterator
-      , container_detail::cast_functor  >                 iterator;
-   typedef typename MultiallocationChain::size_type           size_type;
+      , container_detail::cast_functor  >             iterator;
+   typedef typename MultiallocationChain::size_type      size_type;
 
    transform_multiallocation_chain()
       : holder_()
@@ -234,8 +236,11 @@ class transform_multiallocation_chain
    static iterator iterator_to(pointer p)
    {  return iterator(MultiallocationChain::iterator_to(p));  }
 
-   std::pair extract_data()
-   {  return holder_.extract_data();  }
+   std::pair extract_data()
+   {
+      std::pair data(holder_.extract_data());
+      return std::pair(cast(data.first), cast(data.second));
+   }
 
    MultiallocationChain extract_multiallocation_chain()
    {
diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp
index f43db03..30f1a4f 100644
--- a/include/boost/container/stable_vector.hpp
+++ b/include/boost/container/stable_vector.hpp
@@ -36,10 +36,11 @@
 #include 
 #include 
 #include 
-
-#include 
+#include 
+#include  //max
 #include 
 #include 
+#include  //placement new
 
 ///@cond
 
@@ -104,23 +105,44 @@ class clear_on_destroy
    bool do_clear_;
 };
 
-template
-struct node_type_base
-{
-   node_type_base()
-   {}
-   void set_pointer(const VoidPtr &p)
-   {  up = p; }
+template
+struct node;
 
-   VoidPtr up;
+template
+struct node_base
+{
+   private:
+   typedef NodePtr                              node_ptr;
+   typedef typename boost::intrusive::
+      pointer_traits                  node_ptr_traits;
+   typedef typename node_ptr_traits::
+      template rebind_pointer
+         ::type                      node_base_ptr;
+   typedef typename node_ptr_traits::
+      template rebind_pointer
+         ::type                       node_ptr_ptr;
+
+   public:
+   node_base(const node_ptr_ptr &n)
+      : up(n)
+   {}
+
+   node_base()
+      : up()
+   {}
+
+   node_ptr_ptr up;
 };
 
 template
-struct node_type
-   : public node_type_base
+struct node
+   : public node_base
+   ::template
+            rebind_pointer< node >::type>
 {
    private:
-   node_type();
+   node();
 
    public:
    T value;
@@ -135,90 +157,67 @@ class iterator
                          , Pointer
                          , Reference>
 {
-   typedef typename boost::intrusive::
-      pointer_traits::template
-         rebind_pointer::type                void_ptr;
-   typedef typename boost::intrusive::
-      pointer_traits::template
-         rebind_pointer::type          const_void_ptr;
-   typedef node_type                  node_type_t;
-   typedef typename boost::intrusive::
-      pointer_traits::template
-         rebind_pointer::type         node_type_ptr_t;
-   typedef typename boost::intrusive::
-      pointer_traits::template
-         rebind_pointer::type   const_node_type_ptr_t;
-   typedef typename boost::intrusive::
-      pointer_traits::template
-         rebind_pointer::type            void_ptr_ptr;
+   typedef boost::intrusive::
+      pointer_traits                   ptr_traits;
+   typedef typename ptr_traits::template
+         rebind_pointer::type             void_ptr;
+   typedef node                    node_type;
+   typedef typename ptr_traits::template
+         rebind_pointer::type        node_ptr;
+   typedef typename ptr_traits::template
+         rebind_pointer::type         node_ptr_ptr;
+   typedef typename ptr_traits::template
+      rebind_pointer::type                   friend_iterator_pointer;
 
-   friend class iterator::template rebind_pointer::type>;
+   friend class iterator;
 
    public:
    typedef std::random_access_iterator_tag      iterator_category;
    typedef T                                    value_type;
-   typedef typename boost::intrusive::
-      pointer_traits::difference_type  difference_type;
+   typedef typename ptr_traits::difference_type difference_type;
    typedef Pointer                              pointer;
    typedef Reference                            reference;
 
    iterator()
    {}
 
-   explicit iterator(node_type_ptr_t pn)
-      : pn(pn)
+   explicit iterator(node_ptr p)
+      : pn(p)
    {}
 
-   iterator(const iterator::template rebind_pointer::type>& x)
+   iterator(const iterator& x)
       : pn(x.pn)
    {}
 
-   node_type_ptr_t node() const
-   {  return pn;  }
-  
-   private:
-   static node_type_ptr_t node_ptr_cast(const void_ptr &p)
-   {
-      return node_type_ptr_t(static_cast(container_detail::to_raw_pointer(p)));
-   }
-
-   static const_node_type_ptr_t node_ptr_cast(const const_void_ptr &p)
-   {
-      return const_node_type_ptr_t(static_cast(container_detail::to_raw_pointer(p)));
-   }
-
-   static void_ptr_ptr void_ptr_ptr_cast(const void_ptr &p)
-   {
-      return void_ptr_ptr(static_cast(container_detail::to_raw_pointer(p)));
-   }
-
-   reference dereference() const
-   {  return pn->value; }
-   bool equal(const iterator& x) const
-   {  return pn==x.pn;  }
-   void increment()
-   {  pn = node_ptr_cast(*(void_ptr_ptr_cast(pn->up)+1)); }
-   void decrement()
-   {  pn = node_ptr_cast(*(void_ptr_ptr_cast(pn->up)-1)); }
-   void advance(difference_type n)
-   {  pn = node_ptr_cast(*(void_ptr_ptr_cast(pn->up)+n)); }
-   difference_type distance_to(const iterator& x)const
-   {  return void_ptr_ptr_cast(x.pn->up) - void_ptr_ptr_cast(pn->up);   }
-
    public:
    //Pointer like operators
-   reference operator*()  const {  return  this->dereference();  }
-   pointer   operator->() const {  return  pointer(&this->dereference());  }
+   reference operator*()  const
+   {  return  pn->value;  }
+
+   pointer   operator->() const
+   {  return  ptr_traits::pointer_to(*this);  }
 
    //Increment / Decrement
    iterator& operator++() 
-   {  this->increment(); return *this;  }
+   {
+      if(node_ptr_ptr p = this->pn->up){
+         ++p;
+         this->pn = *p;
+      }
+      return *this;
+   }
 
    iterator operator++(int)
    {  iterator tmp(*this);  ++*this; return iterator(tmp); }
 
    iterator& operator--()
-   {  this->decrement(); return *this;  }
+   {
+      if(node_ptr_ptr p = this->pn->up){
+         --p;
+         this->pn = *p;
+      }
+      return *this;
+   }
 
    iterator operator--(int)
    {  iterator tmp(*this);  --*this; return iterator(tmp);  }
@@ -232,7 +231,10 @@ class iterator
 
    iterator& operator+=(difference_type off)
    {
-      pn = node_ptr_cast(*(void_ptr_ptr_cast(pn->up)+off));
+      if(node_ptr_ptr p = this->pn->up){
+         p += off;
+         this->pn = *p;
+      }
       return *this;
    }
 
@@ -262,7 +264,7 @@ class iterator
 
    friend difference_type operator-(const iterator& left, const iterator& right)
    {
-      return void_ptr_ptr_cast(left.pn->up) - void_ptr_ptr_cast(right.pn->up);
+      return left.pn->up - right.pn->up;
    }
 
    //Comparison operators
@@ -273,18 +275,18 @@ class iterator
    {  return l.pn != r.pn;  }
 
    friend bool operator<    (const iterator& l, const iterator& r)
-   {  return void_ptr_ptr_cast(l.pn->up) < void_ptr_ptr_cast(r.pn->up);  }
+   {  return l.pn->up < r.pn->up;  }
 
    friend bool operator<=   (const iterator& l, const iterator& r)
-   {  return void_ptr_ptr_cast(l.pn->up) <= void_ptr_ptr_cast(r.pn->up);  }
+   {  return l.pn->up <= r.pn->up;  }
 
    friend bool operator>    (const iterator& l, const iterator& r)
-   {  return void_ptr_ptr_cast(l.pn->up) > void_ptr_ptr_cast(r.pn->up);  }
+   {  return l.pn->up > r.pn->up;  }
 
    friend bool operator>=   (const iterator& l, const iterator& r)
-   {  return void_ptr_ptr_cast(l.pn->up) >= void_ptr_ptr_cast(r.pn->up);  }
+   {  return l.pn->up >= r.pn->up;  }
 
-   node_type_ptr_t pn;
+   node_ptr pn;
 };
 
 template
@@ -368,34 +370,32 @@ class stable_vector
    typedef allocator_traits                        allocator_traits_type;
    typedef typename container_detail::
       move_const_ref_type::type                    insert_const_ref_type;
+   typedef boost::intrusive::
+      pointer_traits
+             ptr_traits;
    typedef typename boost::intrusive::pointer_traits
       ::
          template rebind_pointer::type          void_ptr;
-   typedef typename boost::intrusive::pointer_traits
-      ::template
-         rebind_pointer::type             const_void_ptr;
-   typedef typename boost::intrusive::pointer_traits
-      ::template
-         rebind_pointer::type               void_ptr_ptr;
-   typedef typename boost::intrusive::pointer_traits
-      ::template
-         rebind_pointer::type         const_void_ptr_ptr;
-   typedef stable_vector_detail::node_type
-                                         node_type_t;
-   typedef typename boost::intrusive::pointer_traits
-      ::template
-         rebind_pointer::type            node_type_ptr_t;
-   typedef stable_vector_detail::node_type_base
-                                            node_type_base_t;
-   typedef typename boost::intrusive::pointer_traits
-      ::template
-         rebind_pointer::type       node_type_base_ptr_t;
-   typedef ::boost::container::vector    node_type;
+   typedef typename ptr_traits::template
+      rebind_pointer::type                 node_ptr;
+   typedef typename ptr_traits::template
+         rebind_pointer::type               node_ptr_ptr;
+   typedef stable_vector_detail::
+      node_base                             node_base_type;
+   typedef typename ptr_traits::template
+         rebind_pointer::type         node_base_ptr;
+   typedef boost::intrusive::
+      pointer_traits                   node_base_ptr_traits;
+   typedef boost::intrusive::
+      pointer_traits                        node_ptr_traits;
+   typedef boost::intrusive::
+      pointer_traits                    node_ptr_ptr_traits;
+   typedef ::boost::container::vector::type>                         impl_type;
+            ::type>                         impl_type;
    typedef typename impl_type::iterator               impl_iterator;
-   typedef typename impl_type::const_iterator         const_impl_iterator;
 
    typedef ::boost::container::container_detail::
       integral_constant                  allocator_v1;
@@ -406,37 +406,37 @@ class stable_vector
       version::value>                              alloc_version;
    typedef typename allocator_traits_type::
       template portable_rebind_alloc
-         ::type                          node_allocator_type;
+         ::type                            node_allocator_type;
 
-   node_type_ptr_t allocate_one()
+   node_ptr allocate_one()
    {  return this->allocate_one(alloc_version());   }
 
    template
-   node_type_ptr_t allocate_one(AllocatorVersion,
+   node_ptr allocate_one(AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
          
             ::value>::type * = 0)
    {  return this->priv_node_alloc().allocate(1);   }
 
    template
-   node_type_ptr_t allocate_one(AllocatorVersion,
+   node_ptr allocate_one(AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
          
             ::value>::type * = 0)
    {  return this->priv_node_alloc().allocate_one();   }
 
-   void deallocate_one(node_type_ptr_t p)
+   void deallocate_one(node_ptr p)
    {  return this->deallocate_one(p, alloc_version());   }
 
    template
-   void deallocate_one(node_type_ptr_t p, AllocatorVersion,
+   void deallocate_one(node_ptr p, AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
          
             ::value>::type * = 0)
    {  this->priv_node_alloc().deallocate(p, 1);   }
 
    template
-   void deallocate_one(node_type_ptr_t p, AllocatorVersion,
+   void deallocate_one(node_ptr p, AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
          
             ::value>::type * = 0)
@@ -469,11 +469,11 @@ class stable_vector
    private:
    BOOST_COPYABLE_AND_MOVABLE(stable_vector)
    static const size_type ExtraPointers = 3;
-   //This container stores metadata at the end of the void_ptr vector with additional 3 pointers:
-   //    back() is impl.back() - ExtraPointers;
-   //    end node index is impl.end()[-3]
-   //    Node cache first is impl.end()[-2];
-   //    Node cache last is  *impl.back();
+   //This container stores metadata at the end of the node_ptr vector with additional 3 pointers:
+   //    back() is this->impl.back() - ExtraPointers;
+   //    end node index is    *(this->impl.end() -3)
+   //    Node cache first is  *(this->impl.end() - 2);
+   //    Node cache last is   this->impl.back();
 
    typedef typename stable_vector_detail::
       select_multiallocation_chain
@@ -681,7 +681,6 @@ class stable_vector
          }
          //If unequal allocators, then do a one by one move
          else{
-            typedef typename std::iterator_traits::iterator_category ItCat;
             this->assign( boost::make_move_iterator(x.begin())
                         , boost::make_move_iterator(x.end()));
          }
@@ -757,14 +756,13 @@ class stable_vector
    stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
    {  return this->priv_node_alloc(); }
 
-
    //! Effects: Returns an iterator to the first element contained in the stable_vector.
    //!
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
    iterator  begin()
-   {   return (impl.empty()) ? end(): iterator(node_ptr_cast(impl.front())) ;   }
+   {   return (this->impl.empty()) ? this->end(): iterator(this->impl.front()) ;   }
 
    //! Effects: Returns a const_iterator to the first element contained in the stable_vector.
    //!
@@ -772,21 +770,21 @@ class stable_vector
    //!
    //! Complexity: Constant.
    const_iterator  begin()const
-   {   return (impl.empty()) ? cend() : const_iterator(node_ptr_cast(impl.front())) ;   }
+   {   return (this->impl.empty()) ? this->cend() : const_iterator(this->impl.front()) ;   }
 
    //! Effects: Returns an iterator to the end of the stable_vector.
    //!
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator        end()                {return iterator(get_end_node());}
+   iterator        end()                {return iterator(this->get_end_node());}
 
    //! Effects: Returns a const_iterator to the end of the stable_vector.
    //!
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator  end()const           {return const_iterator(get_end_node());}
+   const_iterator  end()const           {return const_iterator(this->get_end_node());}
 
    //! Effects: Returns a reverse_iterator pointing to the beginning
    //! of the reversed stable_vector.
@@ -856,7 +854,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    size_type size() const
-   {  return impl.empty() ? 0 : (impl.size() - ExtraPointers);   }
+   {  return this->impl.empty() ? 0 : (this->impl.size() - ExtraPointers);   }
 
    //! Effects: Returns the largest possible size of the stable_vector.
    //!
@@ -864,7 +862,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    size_type max_size() const
-   {  return impl.max_size() - ExtraPointers;  }
+   {  return this->impl.max_size() - ExtraPointers;  }
 
    //! Effects: Number of elements for which memory has been allocated.
    //!   capacity() is always greater than or equal to size().
@@ -874,7 +872,7 @@ class stable_vector
    //! Complexity: Constant.
    size_type capacity() const
    {
-      if(!impl.capacity()){
+      if(!this->impl.capacity()){
          return 0;
       }
       else{
@@ -890,7 +888,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    bool empty() const
-   {  return impl.empty() || impl.size() == ExtraPointers;  }
+   {  return this->impl.empty() || this->impl.size() == ExtraPointers;  }
 
    //! Effects: Inserts or erases elements at the end such that
    //!   the size becomes n. New elements are copy constructed from x.
@@ -901,7 +899,7 @@ class stable_vector
    void resize(size_type n, const T& t)
    {
       STABLE_VECTOR_CHECK_INVARIANT;
-      if(n > size())
+      if(n > this->size())
          this->insert(this->cend(), n - this->size(), t);
       else if(n < this->size())
          this->erase(this->cbegin() + n, this->cend());
@@ -917,7 +915,7 @@ class stable_vector
    {
       typedef default_construct_iterator default_iterator;
       STABLE_VECTOR_CHECK_INVARIANT;
-      if(n > size())
+      if(n > this->size())
          this->insert(this->cend(), default_iterator(n - this->size()), default_iterator());
       else if(n < this->size())
          this->erase(this->cbegin() + n, this->cend());
@@ -940,11 +938,11 @@ class stable_vector
       if(n > old_capacity){
          this->initialize_end_node(n);
          const void * old_ptr = &impl[0];
-         impl.reserve(n + ExtraPointers);
+         this->impl.reserve(n + ExtraPointers);
          bool realloced = &impl[0] != old_ptr;
          //Fix the pointers for the newly allocated buffer
          if(realloced){
-            this->align_nodes(impl.begin(), impl.begin()+size+1);
+            this->align_nodes(this->impl.begin(), this->impl.begin()+size+1);
          }
          //Now fill pool if data is not enough
          if((n - size) > this->internal_data.pool_size){
@@ -961,7 +959,8 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reference operator[](size_type n){return value(impl[n]);}
+   reference operator[](size_type n)
+   {  return this->impl[n]->value;   }
 
    //! Requires: size() > n.
    //!
@@ -971,7 +970,8 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reference operator[](size_type n)const{return value(impl[n]);}
+   const_reference operator[](size_type n)const
+   {  return this->impl[n]->value;  }
 
    //! Requires: size() > n.
    //!
@@ -983,7 +983,7 @@ class stable_vector
    //! Complexity: Constant.
    reference at(size_type n)
    {
-      if(n>=size())
+      if(n>=this->size())
          throw std::out_of_range("invalid subscript at stable_vector::at");
       return operator[](n);
    }
@@ -998,7 +998,7 @@ class stable_vector
    //! Complexity: Constant.
    const_reference at(size_type n)const
    {
-      if(n>=size())
+      if(n>=this->size())
          throw std::out_of_range("invalid subscript at stable_vector::at");
       return operator[](n);
    }
@@ -1012,7 +1012,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    reference front()
-   {  return value(impl.front());   }
+   {  return this->impl.front()->value;   }
 
    //! Requires: !empty()
    //!
@@ -1023,7 +1023,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    const_reference front()const
-   {  return value(impl.front());   }
+   {  return this->impl.front()->value;   }
 
    //! Requires: !empty()
    //!
@@ -1034,7 +1034,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    reference back()
-   {  return value(*(&impl.back() - ExtraPointers)); }
+   {  return (*(&this->impl.back() - ExtraPointers))->value; }
 
    //! Requires: !empty()
    //!
@@ -1045,7 +1045,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    const_reference back()const
-   {  return value(*(&impl.back() - ExtraPointers)); }
+   {  return (*(&this->impl.back() - ExtraPointers))->value; }
 
    //! Effects: Inserts a copy of x at the end of the stable_vector.
    //!
@@ -1183,10 +1183,10 @@ class stable_vector
       difference_type d = position - this->cbegin();
       if(n){
          this->insert_iter_prolog(n, d);
-         const impl_iterator it(impl.begin() + d);
+         const impl_iterator it(this->impl.begin() + d);
          this->priv_insert_iter_fwd(it, first, last, n);
          //Fix the pointers for the newly allocated buffer
-         this->align_nodes(it + n, get_last_align());
+         this->align_nodes(it + n, this->get_end_align());
       }
       return this->begin() + d;
    }
@@ -1277,10 +1277,10 @@ class stable_vector
    {
       STABLE_VECTOR_CHECK_INVARIANT;
       difference_type d = position - this->cbegin();
-      impl_iterator   it = impl.begin() + d;
+      impl_iterator   it = this->impl.begin() + d;
       this->delete_node(*it);
-      it = impl.erase(it);
-      this->align_nodes(it, get_last_align());
+      it = this->impl.erase(it);
+      this->align_nodes(it, this->get_end_align());
       return this->begin()+d;
    }
 
@@ -1295,11 +1295,11 @@ class stable_vector
       STABLE_VECTOR_CHECK_INVARIANT;
       difference_type d1 = first - this->cbegin(), d2 = last - this->cbegin();
       if(d1 != d2){
-         impl_iterator it1(impl.begin() + d1), it2(impl.begin() + d2);
+         impl_iterator it1(this->impl.begin() + d1), it2(this->impl.begin() + d2);
          for(impl_iterator it = it1; it != it2; ++it)
             this->delete_node(*it);
-         impl_iterator e = impl.erase(it1, it2);
-         this->align_nodes(e, get_last_align());
+         impl_iterator e = this->impl.erase(it1, it2);
+         this->align_nodes(e, this->get_end_align());
       }
       return iterator(this->begin() + d1);
    }
@@ -1342,7 +1342,7 @@ class stable_vector
          if(this->empty()){
             this->impl.clear();
             this->impl.shrink_to_fit();
-            this->internal_data.set_end_pointer_to_default_constructed();
+            this->internal_data.end_node.up = node_ptr_ptr();
          }
          //Otherwise, try to shrink-to-fit the index and readjust pointers if necessary
          else{
@@ -1352,7 +1352,7 @@ class stable_vector
             bool realloced = &impl[0] != old_ptr;
             //Fix the pointers for the newly allocated buffer
             if(realloced){
-               this->align_nodes(impl.begin(), impl.begin()+size+1);
+               this->align_nodes(this->impl.begin(), this->impl.begin()+size+1);
             }
          }
       }
@@ -1375,14 +1375,14 @@ class stable_vector
          
             ::value>::type * = 0)
    {
-      if(!impl.empty() && impl.back()){
-         void_ptr &pool_first_ref = impl.end()[-2];
-         void_ptr &pool_last_ref = impl.back();
+      if(!this->impl.empty() && this->impl.back()){
+         node_ptr &pool_first_ref = *(this->impl.end() - 2);
+         node_ptr &pool_last_ref  = this->impl.back();
 
          multiallocation_chain holder;
          holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, this->internal_data.pool_size);
          while(!holder.empty()){
-            node_type_ptr_t n = holder.front();
+            node_ptr n = holder.front();
             holder.pop_front();
             this->deallocate_one(n);
          }
@@ -1397,9 +1397,9 @@ class stable_vector
          
             ::value>::type * = 0)
    {
-      if(!impl.empty() && impl.back()){
-         void_ptr &pool_first_ref = impl.end()[-2];
-         void_ptr &pool_last_ref = impl.back();
+      if(!this->impl.empty() && this->impl.back()){
+         node_ptr &pool_first_ref = *(this->impl.end() - 2);
+         node_ptr &pool_last_ref  = this->impl.back();
          multiallocation_chain holder;
          holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
          this->priv_node_alloc().deallocate_individual(boost::move(holder));
@@ -1436,50 +1436,50 @@ class stable_vector
          
             ::value>::type * = 0)
    {
-      void_ptr &pool_first_ref = impl.end()[-2];
-      void_ptr &pool_last_ref = impl.back();
+      node_ptr &pool_first_ref = *(this->impl.end() - 2);
+      node_ptr &pool_last_ref  = this->impl.back();
       multiallocation_chain holder;
       holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
       //BOOST_STATIC_ASSERT((::boost::has_move_emulation_enabled::value == true));
       multiallocation_chain m (this->priv_node_alloc().allocate_individual(n));
       holder.splice_after(holder.before_begin(), m, m.before_begin(), m.last(), n);
       this->internal_data.pool_size += n;
-      std::pair data(holder.extract_data());
+      std::pair data(holder.extract_data());
       pool_first_ref = data.first;
       pool_last_ref = data.second;
    }
 
-   void put_in_pool(node_type_ptr_t p)
+   void put_in_pool(node_ptr p)
    {
-      void_ptr &pool_first_ref = impl.end()[-2];
-      void_ptr &pool_last_ref = impl.back();
+      node_ptr &pool_first_ref = *(this->impl.end()-2);
+      node_ptr &pool_last_ref  = this->impl.back();
       multiallocation_chain holder;
       holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
       holder.push_front(p);
       ++this->internal_data.pool_size;
-      std::pair ret(holder.extract_data());
+      std::pair ret(holder.extract_data());
       pool_first_ref = ret.first;
       pool_last_ref = ret.second;
    }
 
-   node_type_ptr_t priv_get_from_pool()
+   node_ptr priv_get_from_pool()
    {
-      if(!impl.back()){
-         return node_type_ptr_t(0);
+      if(!this->impl.back()){
+         return node_ptr(0);
       }
       else{
-         void_ptr &pool_first_ref = impl.end()[-2];
-         void_ptr &pool_last_ref = impl.back();
+         node_ptr &pool_first_ref = *(this->impl.end() - 2);
+         node_ptr &pool_last_ref  = this->impl.back();
          multiallocation_chain holder;
          holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
-         node_type_ptr_t ret = holder.front();
+         node_ptr ret = holder.front();
          holder.pop_front();
          --this->internal_data.pool_size;
          if(!internal_data.pool_size){
-            pool_first_ref = pool_last_ref = void_ptr(0);
+            pool_first_ref = pool_last_ref = node_ptr();
          }
          else{
-            std::pair data(holder.extract_data());
+            std::pair data(holder.extract_data());
             pool_first_ref = data.first;
             pool_last_ref = data.second;
          }
@@ -1491,79 +1491,62 @@ class stable_vector
    {
       initialize_end_node(n);
       const void* old_ptr = &impl[0];
-      //size_type old_capacity = capacity();
-      //size_type old_size = size();
-      impl.insert(impl.begin()+d, n, 0);
+      //size_type old_capacity = this->capacity();
+      //size_type old_size = this->size();
+      this->impl.insert(this->impl.begin()+d, n, 0);
       bool realloced = &impl[0] != old_ptr;
       //Fix the pointers for the newly allocated buffer
       if(realloced){
-         align_nodes(impl.begin(), impl.begin()+d);
+         align_nodes(this->impl.begin(), this->impl.begin()+d);
       }
    }
 
-   impl_iterator get_last_align()
+   impl_iterator get_end_align()
    {
-      return impl.end() - (ExtraPointers - 1);
+      return this->impl.end() - (ExtraPointers - 1);
    }
 
-   const_impl_iterator get_last_align() const
-   {
-      return impl.cend() - (ExtraPointers - 1);
-   }
+   static node_ptr_ptr ptr_to_node_ptr(node_ptr &n)
+   {  return node_ptr_ptr_traits::pointer_to(n);   }
 
-   static node_type_ptr_t node_ptr_cast(const void_ptr &p)
+   void initialize_end_node(const size_type impl_capacity = 0)
    {
-      return node_type_ptr_t(static_cast(container_detail::to_raw_pointer(p)));
-   }
-
-   static node_type_base_ptr_t node_base_ptr_cast(const void_ptr &p)
-   {
-      return node_type_base_ptr_t(static_cast(container_detail::to_raw_pointer(p)));
-   }
-
-   static value_type& value(const void_ptr &p)
-   {
-      return node_ptr_cast(p)->value;
-   }
-
-   void initialize_end_node(size_type impl_capacity = 0)
-   {
-      if(impl.empty()){
-         impl.reserve(impl_capacity + ExtraPointers);
-         impl.resize (ExtraPointers, void_ptr(0));
-         impl[0] = &this->internal_data.end_node;
-         this->internal_data.end_node.up = &impl[0];
+      if(this->impl.empty()){
+         this->impl.reserve(impl_capacity + ExtraPointers);
+         this->impl.resize(ExtraPointers);
+         node_ptr &end_node_ref = impl[0];
+         end_node_ref = this->get_end_node();
+         this->internal_data.end_node.up = stable_vector::ptr_to_node_ptr(end_node_ref);
       }
    }
 
    void readjust_end_node()
    {
       if(!this->impl.empty()){
-         void_ptr &end_node_ref = *(this->get_last_align()-1);
+         node_ptr &end_node_ref = *(this->get_end_align()-1);
          end_node_ref = this->get_end_node();
-         this->internal_data.end_node.up = &end_node_ref;
+         this->internal_data.end_node.up = node_ptr_ptr_traits::pointer_to(end_node_ref);
       }
       else{
-         this->internal_data.end_node.up = void_ptr(&this->internal_data.end_node.up);
+         this->internal_data.end_node.up = node_ptr_ptr();
       }
    }
 
-   node_type_ptr_t get_end_node() const
+   node_ptr get_end_node() const
    {
-      const node_type_base_t* cp = &this->internal_data.end_node;
-      node_type_base_t* p = const_cast(cp);
-      return node_ptr_cast(p);
+      return node_ptr_traits::static_cast_from
+         (node_base_ptr_traits::pointer_to(const_cast(this->internal_data.end_node)));
    }
 
    template
-   void_ptr new_node(const void_ptr &up, Iter it)
+   node_ptr new_node(const node_ptr_ptr &up, Iter it)
    {
-      node_type_ptr_t p = this->allocate_one();
+      node_ptr p = this->allocate_one();
       try{
          boost::container::construct_in_place(this->priv_node_alloc(), container_detail::addressof(p->value), it);
          //This does not throw
-         ::new(static_cast(container_detail::to_raw_pointer(p))) node_type_base_t;
-         p->set_pointer(up);
+         ::new(static_cast(container_detail::to_raw_pointer(p))) node_base_type;
+         p->up = up;
       }
       catch(...){
          this->deallocate_one(p);
@@ -1572,18 +1555,18 @@ class stable_vector
       return p;
    }
 
-   void delete_node(const void_ptr &p)
+   void delete_node(const node_ptr &n)
    {
-      node_type_ptr_t n(node_ptr_cast(p));
       allocator_traits::
          destroy(this->priv_node_alloc(), container_detail::to_raw_pointer(n));
+      static_cast(container_detail::to_raw_pointer(n))->~node_base_type();
       this->put_in_pool(n);
    }
 
    static void align_nodes(impl_iterator first, impl_iterator last)
    {
       while(first!=last){
-         node_ptr_cast(*first)->up = void_ptr(&*first);
+         (*first)->up = stable_vector::ptr_to_node_ptr(*first);
          ++first;
       }
    }
@@ -1594,14 +1577,14 @@ class stable_vector
       size_type i=0;
       try{
          while(first!=last){
-            it[i] = this->new_node(void_ptr_ptr(&it[i]), first);
+            it[i] = this->new_node(stable_vector::ptr_to_node_ptr(it[i]), first);
             ++first;
             ++i;
          }
       }
       catch(...){
-         impl_iterator e = impl.erase(it + i, it + n);
-         this->align_nodes(e, get_last_align());
+         impl_iterator e = this->impl.erase(it + i, it + n);
+         this->align_nodes(e, this->get_end_align());
          throw;
       }
    }
@@ -1612,7 +1595,7 @@ class stable_vector
       multiallocation_chain mem(this->priv_node_alloc().allocate_individual(n));
 
       size_type i = 0;
-      node_type_ptr_t p = 0;
+      node_ptr p = 0;
       try{
          while(first != last){
             p = mem.front();
@@ -1620,8 +1603,8 @@ class stable_vector
             //This can throw
             boost::container::construct_in_place(this->priv_node_alloc(), container_detail::addressof(p->value), first);
             //This does not throw
-            ::new(static_cast(container_detail::to_raw_pointer(p))) node_type_base_t;
-            p->set_pointer(void_ptr_ptr(&it[i]));
+            ::new(static_cast(container_detail::to_raw_pointer(p))) node_base_type;
+            p->up = stable_vector::ptr_to_node_ptr(it[i]);
             ++first;
             it[i] = p;
             ++i;
@@ -1630,8 +1613,8 @@ class stable_vector
       catch(...){
          this->priv_node_alloc().deallocate_one(p);
          this->priv_node_alloc().deallocate_many(boost::move(mem));
-         impl_iterator e = impl.erase(it+i, it+n);
-         this->align_nodes(e, get_last_align());
+         impl_iterator e = this->impl.erase(it+i, it+n);
+         this->align_nodes(e, this->get_end_align());
          throw;
       }
    }
@@ -1640,7 +1623,7 @@ class stable_vector
    void priv_insert_iter_fwd(const impl_iterator it, FwdIterator first, FwdIterator last, difference_type n)
    {
       size_type i = 0;
-      node_type_ptr_t p = 0;
+      node_ptr p = 0;
       try{
          while(first != last){
             p = this->priv_get_from_pool();
@@ -1651,8 +1634,8 @@ class stable_vector
             //This can throw
             boost::container::construct_in_place(this->priv_node_alloc(), container_detail::addressof(p->value), first);
             //This does not throw
-            ::new(static_cast(container_detail::to_raw_pointer(p))) node_type_base_t;
-            p->set_pointer(void_ptr_ptr(&it[i]));
+            ::new(static_cast(container_detail::to_raw_pointer(p))) node_base_type;
+            p->up = stable_vector::ptr_to_node_ptr(it[i]);
             ++first;
             it[i]=p;
             ++i;
@@ -1660,8 +1643,8 @@ class stable_vector
       }
       catch(...){
          put_in_pool(p);
-         impl_iterator e = impl.erase(it+i, it+n);
-         this->align_nodes(e, get_last_align());
+         impl_iterator e = this->impl.erase(it+i, it+n);
+         this->align_nodes(e, this->get_end_align());
          throw;
       }
    }
@@ -1676,23 +1659,32 @@ class stable_vector
    #if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING)
    bool priv_invariant()const
    {
-      if(impl.empty())
-         return !capacity() && !size();
-      if(get_end_node() != *(impl.end() - ExtraPointers)){
+      impl_type & impl_ref =  const_cast(this->impl);
+
+      if(impl_ref.empty())
+         return !this->capacity() && !this->size();
+      if(this->get_end_node() != *(impl_ref.end() - ExtraPointers)){
          return false;
       }
-      for(const_impl_iterator it = impl.begin(), it_end = get_last_align(); it != it_end; ++it){
-         if(const_void_ptr(node_ptr_cast(*it)->up) !=
-               const_void_ptr(const_void_ptr_ptr(&*it)))
+      for( impl_iterator it = impl_ref.begin()
+         , it_end = const_cast(*this).get_end_align()
+         ; it != it_end
+         ; ++it){
+         if((*it)->up != stable_vector::ptr_to_node_ptr(*it)){
             return false;
+         }
       }
-      size_type n = capacity()-size();
-      const void_ptr &pool_head = impl.back();
+
+      size_type n = this->capacity() - this->size();
+      node_ptr &pool_first_ref = *(impl_ref.end() - 2);
+      node_ptr &pool_last_ref  = impl_ref.back();
+      multiallocation_chain holder;
+      holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
+      multiallocation_chain::iterator beg(holder.begin()), end(holder.end());
       size_type num_pool = 0;
-      node_type_ptr_t p = node_ptr_cast(pool_head);
-      while(p){
+      while(beg != end){
          ++num_pool;
-         p = node_ptr_cast(p->up);
+         ++beg;
       }
       return n >= num_pool;
    }
@@ -1722,25 +1714,16 @@ class stable_vector
          : node_allocator_type(boost::forward(a))
          , pool_size(0)
          , end_node()
-      {
-         this->set_end_pointer_to_default_constructed();
-      }
+      {}
 
       ebo_holder()
          : node_allocator_type()
          , pool_size(0)
          , end_node()
-      {
-         this->set_end_pointer_to_default_constructed();
-      }
-
-      void set_end_pointer_to_default_constructed()
-      {
-         end_node.set_pointer(void_ptr(&end_node.up));
-      }
+      {}
 
       size_type pool_size;
-      node_type_base_t end_node;
+      node_base_type end_node;
    } internal_data;
 
    node_allocator_type &priv_node_alloc()              { return internal_data;  }
@@ -1805,3 +1788,24 @@ void swap(stable_vector& x,stable_vector& y)
 #include 
 
 #endif   //BOOST_CONTAINER_STABLE_VECTOR_HPP
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp
index ff1f8fd..4af2ae2 100644
--- a/include/boost/container/string.hpp
+++ b/include/boost/container/string.hpp
@@ -48,6 +48,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -92,10 +93,11 @@ class basic_string_base
  public:
    typedef A allocator_type;
    //! The stored allocator type
-   typedef allocator_type                          stored_allocator_type;
+   typedef allocator_type                              stored_allocator_type;
    typedef typename allocator_traits_type::pointer     pointer;
    typedef typename allocator_traits_type::value_type  value_type;
    typedef typename allocator_traits_type::size_type   size_type;
+   typedef ::boost::intrusive::pointer_traits pointer_traits;
 
    basic_string_base()
       : members_()
@@ -123,10 +125,7 @@ class basic_string_base
    { 
       if(!this->is_short()){
          this->deallocate_block();
-         allocator_traits_type::destroy
-            ( this->alloc()
-            , static_cast(static_cast(&this->members_.m_repr.r))
-            );
+         this->is_short(true);
       }
    }
 
@@ -198,11 +197,17 @@ class basic_string_base
       long_raw_t  r;
       short_t     s;
 
-      short_t &short_repr() const
-      {  return *const_cast(&s);  }
+      const short_t &short_repr() const
+      {  return s;  }
 
-      long_t &long_repr() const
-      {  return *const_cast(reinterpret_cast(&r));  }
+      const long_t &long_repr() const
+      {  return *static_cast(static_cast(&r));  }
+
+      short_t &short_repr()
+      {  return s;  }
+
+      long_t &long_repr()
+      {  return *static_cast(static_cast(&r));  }
    };
 
    struct members_holder
@@ -237,20 +242,22 @@ class basic_string_base
    {  return static_cast(this->members_.m_repr.s.h.is_short != 0);  }
 
    void is_short(bool yes)
-   { 
-      if(yes && !this->is_short()){
+   {
+      const bool was_short = this->is_short();
+      if(yes && !was_short){
          allocator_traits_type::destroy
             ( this->alloc()
             , static_cast(static_cast(&this->members_.m_repr.r))
             );
+         this->members_.m_repr.s.h.is_short = true;
       }
-      else{
+      else if(!yes && was_short){
          allocator_traits_type::construct
             ( this->alloc()
             , static_cast(static_cast(&this->members_.m_repr.r))
             );
+         this->members_.m_repr.s.h.is_short = false;
       }
-      this->members_.m_repr.s.h.is_short = yes;
    }
 
    private:
@@ -274,7 +281,7 @@ class basic_string_base
                          size_type &received_size, pointer reuse = 0)
    {
       if(this->is_short() && (command & (expand_fwd | expand_bwd)) ){
-         reuse = pointer(0);
+         reuse = pointer();
          command &= ~(expand_fwd | expand_bwd);
       }
       return this->allocation_command
@@ -292,7 +299,7 @@ class basic_string_base
       (void)limit_size;
       (void)reuse;
       if(!(command & allocate_new))
-         return std::pair(pointer(0), false);
+         return std::pair(pointer(), false);
       received_size = preferred_size;
       return std::make_pair(this->alloc().allocate(received_size), false);
    }
@@ -353,7 +360,7 @@ class basic_string_base
             pointer p = this->allocation_command(allocate_new, n, new_cap, new_cap).first;
             this->is_short(false);
             this->priv_long_addr(p);
-            this->priv_size(0);
+            this->priv_long_size(0);
             this->priv_storage(new_cap);
          }
       }
@@ -379,13 +386,26 @@ class basic_string_base
    { return this->priv_storage() - 1; }
 
    pointer priv_short_addr() const
-   {  return pointer(&this->members_.m_repr.short_repr().data[0]);  }
+   {  return pointer_traits::pointer_to(const_cast(this->members_.m_repr.short_repr().data[0]));  }
 
    pointer priv_long_addr() const
    {  return this->members_.m_repr.long_repr().start;  }
 
    pointer priv_addr() const
-   {  return this->is_short() ? pointer(&this->members_.m_repr.short_repr().data[0]) : this->members_.m_repr.long_repr().start;  }
+   {
+      return this->is_short()
+         ? priv_short_addr()
+         : priv_long_addr()
+         ;
+   }
+
+   pointer priv_end_addr() const
+   {
+      return this->is_short()
+         ? this->priv_short_addr() + this->priv_short_size()
+         : this->priv_long_addr()  + this->priv_long_size()
+         ;
+   }
 
    void priv_long_addr(pointer addr)
    {  this->members_.m_repr.long_repr().start = addr;  }
@@ -411,7 +431,7 @@ class basic_string_base
    }
 
    size_type priv_size() const
-   {  return this->is_short() ? priv_short_size() : priv_long_size();  }
+   {  return this->is_short() ? this->priv_short_size() : this->priv_long_size();  }
 
    size_type priv_short_size() const
    {  return this->members_.m_repr.short_repr().h.length;  }
@@ -434,7 +454,7 @@ class basic_string_base
 
    void priv_long_size(size_type sz)
    { 
-      this->members_.m_repr.long_repr().length = static_cast(sz);
+      this->members_.m_repr.long_repr().length = sz;
    }
 
    void swap_data(basic_string_base& other)
@@ -444,16 +464,22 @@ class basic_string_base
             container_detail::do_swap(this->members_.m_repr, other.members_.m_repr);
          }
          else{
-            repr_t copied(this->members_.m_repr);
-            this->members_.m_repr.long_repr() = other.members_.m_repr.long_repr();
-            other.members_.m_repr = copied;
+            short_t short_backup(this->members_.m_repr.short_repr());
+            long_t  long_backup (other.members_.m_repr.long_repr());
+            other.members_.m_repr.long_repr().~long_t();
+            ::new(&this->members_.m_repr.long_repr()) long_t;
+            this->members_.m_repr.long_repr()  = long_backup;
+            other.members_.m_repr.short_repr() = short_backup;
          }
       }
       else{
          if(other.is_short()){
-            repr_t copied(other.members_.m_repr);
-            other.members_.m_repr.long_repr() = this->members_.m_repr.long_repr();
-            this->members_.m_repr = copied;
+            short_t short_backup(other.members_.m_repr.short_repr());
+            long_t  long_backup (this->members_.m_repr.long_repr());
+            this->members_.m_repr.long_repr().~long_t();
+            ::new(&other.members_.m_repr.long_repr()) long_t;
+            other.members_.m_repr.long_repr()  = long_backup;
+            this->members_.m_repr.short_repr() = short_backup;
          }
          else{
             container_detail::do_swap(this->members_.m_repr.long_repr(), other.members_.m_repr.long_repr());
@@ -581,6 +607,7 @@ class basic_string
    typedef typename base_t::allocator_v1  allocator_v1;
    typedef typename base_t::allocator_v2  allocator_v2;
    typedef typename base_t::alloc_version  alloc_version;
+   typedef ::boost::intrusive::pointer_traits pointer_traits;
    /// @endcond
 
    public:                         // Constructor, destructor, assignment.
@@ -742,8 +769,8 @@ class basic_string
             if(!this->is_short()){
                this->deallocate_block();
                this->is_short(true);
-               Traits::assign(*this->priv_addr(), this->priv_null());
-               this->priv_size(0);
+               Traits::assign(*this->priv_addr(), CharT(0));
+               this->priv_short_size(0);
             }
          }
          container_detail::assign_alloc(this->alloc(), x.alloc(), flag);
@@ -818,7 +845,7 @@ class basic_string
    //!
    //! Complexity: Constant.
    iterator end()
-   { return this->priv_addr() + this->priv_size(); }
+   { return this->priv_end_addr(); }
 
    //! Effects: Returns a const_iterator to the end of the vector.
    //!
@@ -826,7 +853,7 @@ class basic_string
    //!
    //! Complexity: Constant.
    const_iterator end() const
-   { return this->priv_addr() + this->priv_size(); } 
+   { return this->priv_end_addr(); }
 
    //! Effects: Returns a const_iterator to the end of the vector.
    //!
@@ -834,7 +861,7 @@ class basic_string
    //!
    //! Complexity: Constant.
    const_iterator cend() const
-   { return this->priv_addr() + this->priv_size(); } 
+   { return this->priv_end_addr(); }
 
    //! Effects: Returns a reverse_iterator pointing to the beginning
    //! of the reversed vector.
@@ -843,7 +870,7 @@ class basic_string
    //!
    //! Complexity: Constant.
    reverse_iterator rbegin()            
-   { return reverse_iterator(this->priv_addr() + this->priv_size()); }
+   { return reverse_iterator(this->priv_end_addr()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
    //! of the reversed vector.
@@ -861,7 +888,7 @@ class basic_string
    //!
    //! Complexity: Constant.
    const_reverse_iterator crbegin() const
-   { return const_reverse_iterator(this->priv_addr() + this->priv_size()); }
+   { return const_reverse_iterator(this->priv_end_addr()); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
    //! of the reversed vector.
@@ -950,7 +977,7 @@ class basic_string
    //! Complexity: Linear to the difference between size() and new_size.
    void resize(size_type n, CharT c)
    {
-      if (n <= size())
+      if (n <= this->size())
          this->erase(this->begin() + n, this->end());
       else
          this->append(n - this->size(), c);
@@ -963,7 +990,7 @@ class basic_string
    //!
    //! Complexity: Linear to the difference between size() and new_size.
    void resize(size_type n)
-   { resize(n, this->priv_null()); }
+   { resize(n, CharT(0)); }
 
    //! Effects: If n is less than or equal to capacity(), this call has no
    //!   effect. Otherwise, it is a request for allocation of additional memory.
@@ -973,8 +1000,9 @@ class basic_string
    //! Throws: If memory allocation allocation throws
    void reserve(size_type res_arg)
    {
-      if (res_arg > this->max_size())
+      if (res_arg > this->max_size()){
          this->throw_length_error();
+      }
 
       if (this->capacity() < res_arg){
          size_type n = container_detail::max_value(res_arg, this->size()) + 1;
@@ -983,13 +1011,14 @@ class basic_string
             (allocate_new, n, new_cap, new_cap).first;
          size_type new_length = 0;
 
+         const pointer addr = this->priv_addr();
          new_length += priv_uninitialized_copy
-            (this->priv_addr(), this->priv_addr() + this->priv_size(), new_start);
+            (addr, addr + this->priv_size(), new_start);
          this->priv_construct_null(new_start + new_length);
          this->deallocate_block();
          this->is_short(false);
          this->priv_long_addr(new_start);
-         this->priv_size(new_length);
+         this->priv_long_size(new_length);
          this->priv_storage(new_cap);
       }
    }
@@ -1010,8 +1039,8 @@ class basic_string
    //! Complexity: Linear to the number of elements in the vector.
    void clear()
    {
-      if (!empty()) {
-         Traits::assign(*this->priv_addr(), this->priv_null());
+      if (!this->empty()) {
+         Traits::assign(*this->priv_addr(), CharT(0));
          this->priv_size(0);
       }
    }
@@ -1028,7 +1057,7 @@ class basic_string
       if(this->priv_storage() > InternalBufferChars){
          //Check if we should pass from dynamically allocated buffer
          //to the internal storage
-         if(this->priv_size() < (InternalBufferChars)){
+         if(this->priv_size() < InternalBufferChars){
             //Dynamically allocated buffer attributes
             pointer   long_addr    = this->priv_long_addr();
             size_type long_storage = this->priv_long_storage();
@@ -1085,9 +1114,10 @@ class basic_string
    //! Throws: std::range_error if n >= size()
    //!
    //! Complexity: Constant.
-   reference at(size_type n) {
-      if (n >= size())
-      this->throw_out_of_range();
+   reference at(size_type n)
+   {
+      if (n >= this->size())
+         this->throw_out_of_range();
       return *(this->priv_addr() + n);
    }
 
@@ -1100,7 +1130,7 @@ class basic_string
    //!
    //! Complexity: Constant.
    const_reference at(size_type n) const {
-      if (n >= size())
+      if (n >= this->size())
          this->throw_out_of_range();
       return *(this->priv_addr() + n);
    }
@@ -1186,13 +1216,14 @@ class basic_string
    {
       const size_type old_size = this->priv_size();
       if (old_size < this->capacity()){
-         this->priv_construct_null(this->priv_addr() + old_size + 1);
-         Traits::assign(this->priv_addr()[old_size], c);
+         const pointer addr = this->priv_addr();
+         this->priv_construct_null(addr + old_size + 1);
+         Traits::assign(addr[old_size], c);
          this->priv_size(old_size+1);
       }
       else{
          //No enough memory, insert a new object at the end
-         this->append((size_type)1, c);
+         this->append(size_type(1), c);
       }
    }
 
@@ -1266,7 +1297,8 @@ class basic_string
       )
    {
       size_type cur = 0;
-      CharT *ptr = container_detail::to_raw_pointer(this->priv_addr());
+      const pointer addr = this->priv_addr();
+      CharT *ptr = container_detail::to_raw_pointer(addr);
       const size_type old_size = this->priv_size();
       while (first != last && cur != old_size) {
          Traits::assign(*ptr, *first);
@@ -1275,7 +1307,7 @@ class basic_string
          ++ptr;
       }
       if (first == last)
-         this->erase(this->priv_addr() + cur, this->priv_addr() + old_size);
+         this->erase(addr + cur, addr + old_size);
       else
          this->append(first, last);
       return *this;
@@ -1290,9 +1322,10 @@ class basic_string
    //! Returns: *this
    basic_string& insert(size_type pos, const basic_string& s)
    {
-      if (pos > size())
+      const size_type size = this->size();
+      if (pos > size)
          this->throw_out_of_range();
-      if (this->size() > this->max_size() - s.size())
+      if (size > this->max_size() - s.size())
          this->throw_length_error();
       this->insert(this->priv_addr() + pos, s.begin(), s.end());
       return *this;
@@ -1308,10 +1341,12 @@ class basic_string
    //! Returns: *this
    basic_string& insert(size_type pos1, const basic_string& s, size_type pos2, size_type n)
    {
-      if (pos1 > this->size() || pos2 > s.size())
+      const size_type size = this->size();
+      const size_type str_size = s.size();
+      if (pos1 > size || pos2 > str_size)
          this->throw_out_of_range();
-      size_type len = container_detail::min_value(n, s.size() - pos2);
-      if (this->size() > this->max_size() - len)
+      size_type len = container_detail::min_value(n, str_size - pos2);
+      if (size > this->max_size() - len)
          this->throw_length_error();
       const CharT *beg_ptr = container_detail::to_raw_pointer(s.begin()) + pos2;
       const CharT *end_ptr = beg_ptr + len;
@@ -1350,7 +1385,7 @@ class basic_string
    //! Returns: *this
    basic_string& insert(size_type pos, const CharT* s)
    {
-      if (pos > size())
+      if (pos > this->size())
          this->throw_out_of_range();
       size_type len = Traits::length(s);
       if (this->size() > this->max_size() - len)
@@ -1457,11 +1492,11 @@ class basic_string
 
          //Reuse same buffer
          if(enough_capacity){
-            const size_type elems_after = old_size - (p - this->priv_addr());
+            const size_type elems_after = old_size - (p - old_start);
             const size_type old_length = old_size;
             if (elems_after >= n) {
-               const pointer pointer_past_last = this->priv_addr() + old_size + 1;
-               priv_uninitialized_copy(this->priv_addr() + (old_size - n + 1),
+               const pointer pointer_past_last = old_start + old_size + 1;
+               priv_uninitialized_copy(old_start + (old_size - n + 1),
                                        pointer_past_last, pointer_past_last);
 
                this->priv_size(old_size+n);
@@ -1474,12 +1509,13 @@ class basic_string
                ForwardIter mid = first;
                std::advance(mid, elems_after + 1);
 
-               priv_uninitialized_copy(mid, last, this->priv_addr() + old_size + 1);
-               this->priv_size(old_size + (n - elems_after));
+               priv_uninitialized_copy(mid, last, old_start + old_size + 1);
+               const size_type newer_size = old_size + (n - elems_after);
+               this->priv_size(newer_size);
                priv_uninitialized_copy
-                  (p, const_iterator(this->priv_addr() + old_length + 1),
-                  this->priv_addr() + this->priv_size());
-               this->priv_size(this->priv_size() + elems_after);
+                  (p, const_iterator(old_start + old_length + 1),
+                  old_start + newer_size);
+               this->priv_size(newer_size + elems_after);
                this->priv_copy(first, mid, const_cast(container_detail::to_raw_pointer(p)));
             }
          }
@@ -1490,11 +1526,11 @@ class basic_string
                size_type new_length = 0;
                //This can't throw, since characters are POD
                new_length += priv_uninitialized_copy
-                              (const_iterator(this->priv_addr()), p, new_start);
+                              (const_iterator(old_start), p, new_start);
                new_length += priv_uninitialized_copy
                               (first, last, new_start + new_length);
                new_length += priv_uninitialized_copy
-                              (p, const_iterator(this->priv_addr() + old_size),
+                              (p, const_iterator(old_start + old_size),
                               new_start + new_length);
                this->priv_construct_null(new_start + new_length);
 
@@ -1542,9 +1578,10 @@ class basic_string
    //! Returns: *this
    basic_string& erase(size_type pos = 0, size_type n = npos)
    {
-      if (pos > size())
+      if (pos > this->size())
          this->throw_out_of_range();
-      erase(this->priv_addr() + pos, this->priv_addr() + pos + container_detail::min_value(n, size() - pos));
+      const pointer addr = this->priv_addr();
+      erase(addr + pos, addr + pos + container_detail::min_value(n, this->size() - pos));
       return *this;
    } 
 
@@ -1597,7 +1634,7 @@ class basic_string
    void pop_back()
    {
       const size_type old_size = this->priv_size();
-      Traits::assign(this->priv_addr()[old_size-1], this->priv_null());
+      Traits::assign(this->priv_addr()[old_size-1], CharT(0));
       this->priv_size(old_size-1);;
    }
 
@@ -1610,13 +1647,14 @@ class basic_string
    //! Returns: *this
    basic_string& replace(size_type pos1, size_type n1, const basic_string& str)
    {
-      if (pos1 > size())
+      if (pos1 > this->size())
          this->throw_out_of_range();
-      const size_type len = container_detail::min_value(n1, size() - pos1);
+      const size_type len = container_detail::min_value(n1, this->size() - pos1);
       if (this->size() - len >= this->max_size() - str.size())
          this->throw_length_error();
-      return this->replace( const_iterator(this->priv_addr() + pos1)
-                          , const_iterator(this->priv_addr() + pos1 + len)
+      const pointer addr = this->priv_addr();
+      return this->replace( const_iterator(addr + pos1)
+                          , const_iterator(addr + pos1 + len)
                           , str.begin(), str.end());
    }
 
@@ -1632,14 +1670,16 @@ class basic_string
    basic_string& replace(size_type pos1, size_type n1,
                          const basic_string& str, size_type pos2, size_type n2)
    {
-      if (pos1 > size() || pos2 > str.size())
+      if (pos1 > this->size() || pos2 > str.size())
          this->throw_out_of_range();
-      const size_type len1 = container_detail::min_value(n1, size() - pos1);
+      const size_type len1 = container_detail::min_value(n1, this->size() - pos1);
       const size_type len2 = container_detail::min_value(n2, str.size() - pos2);
       if (this->size() - len1 >= this->max_size() - len2)
          this->throw_length_error();
-      return this->replace(this->priv_addr() + pos1, this->priv_addr() + pos1 + len1,
-                     str.priv_addr() + pos2, str.priv_addr() + pos2 + len2);
+      const pointer addr    = this->priv_addr();
+      const pointer straddr = str.priv_addr();
+      return this->replace(addr + pos1, addr + pos1 + len1,
+                     straddr + pos2, straddr + pos2 + len2);
    }
 
    //! Requires: pos1 <= size() and s points to an array of at least n2 elements of CharT.
@@ -1658,12 +1698,13 @@ class basic_string
    //! Returns: *this
    basic_string& replace(size_type pos1, size_type n1, const CharT* s, size_type n2)
    {
-      if (pos1 > size())
+      if (pos1 > this->size())
          this->throw_out_of_range();
-      const size_type len = container_detail::min_value(n1, size() - pos1);
+      const size_type len = container_detail::min_value(n1, this->size() - pos1);
       if (n2 > this->max_size() || size() - len >= this->max_size() - n2)
          this->throw_length_error();
-      return this->replace(this->priv_addr() + pos1, this->priv_addr() + pos1 + len, s, s + n2);
+      const pointer addr    = this->priv_addr();
+      return this->replace(addr + pos1, addr + pos1 + len, s, s + n2);
    }
 
    //! Requires: pos1 <= size() and s points to an array of at least n2 elements of CharT.
@@ -1682,13 +1723,14 @@ class basic_string
    //! Returns: *this
    basic_string& replace(size_type pos, size_type n1, const CharT* s)
    {
-      if (pos > size())
+      if (pos > this->size())
          this->throw_out_of_range();
-      const size_type len = container_detail::min_value(n1, size() - pos);
+      const size_type len = container_detail::min_value(n1, this->size() - pos);
       const size_type n2 = Traits::length(s);
-      if (n2 > this->max_size() || size() - len >= this->max_size() - n2)
+      if (n2 > this->max_size() || this->size() - len >= this->max_size() - n2)
          this->throw_length_error();
-      return this->replace(this->priv_addr() + pos, this->priv_addr() + pos + len,
+      const pointer addr    = this->priv_addr();
+      return this->replace(addr + pos, addr + pos + len,
                      s, s + Traits::length(s));
    }
 
@@ -1702,12 +1744,13 @@ class basic_string
    //! Returns: *this
    basic_string& replace(size_type pos1, size_type n1, size_type n2, CharT c)
    {
-      if (pos1 > size())
+      if (pos1 > this->size())
          this->throw_out_of_range();
-      const size_type len = container_detail::min_value(n1, size() - pos1);
-      if (n2 > this->max_size() || size() - len >= this->max_size() - n2)
+      const size_type len = container_detail::min_value(n1, this->size() - pos1);
+      if (n2 > this->max_size() || this->size() - len >= this->max_size() - n2)
          this->throw_length_error();
-      return this->replace(this->priv_addr() + pos1, this->priv_addr() + pos1 + len, n2, c);
+      const pointer addr    = this->priv_addr();
+      return this->replace(addr + pos1, addr + pos1 + len, n2, c);
    }
 
    //! Requires: [begin(),i1) and [i1,i2) are valid ranges.
@@ -1829,9 +1872,9 @@ class basic_string
    //! Returns: rlen
    size_type copy(CharT* s, size_type n, size_type pos = 0) const
    {
-      if (pos > size())
+      if (pos > this->size())
          this->throw_out_of_range();
-      const size_type len = container_detail::min_value(n, size() - pos);
+      const size_type len = container_detail::min_value(n, this->size() - pos);
       Traits::copy(s, container_detail::to_raw_pointer(this->priv_addr() + pos), len);
       return len;
    }
@@ -1880,12 +1923,13 @@ class basic_string
    //! Returns: find(basic_string(s,n),pos).
    size_type find(const CharT* s, size_type pos, size_type n) const
    {
-      if (pos + n > size())
+      if (pos + n > this->size())
          return npos;
       else {
-         pointer finish = this->priv_addr() + this->priv_size();
+         const pointer addr = this->priv_addr();
+         pointer finish = addr + this->priv_size();
          const const_iterator result =
-            std::search(container_detail::to_raw_pointer(this->priv_addr() + pos),
+            std::search(container_detail::to_raw_pointer(addr + pos),
                    container_detail::to_raw_pointer(finish),
                    s, s + n, Eq_traits());
          return result != finish ? result - begin() : npos;
@@ -1898,19 +1942,21 @@ class basic_string
    //!
    //! Returns: find(basic_string(s), pos).
    size_type find(const CharT* s, size_type pos = 0) const
-   { return find(s, pos, Traits::length(s)); }
+   { return this->find(s, pos, Traits::length(s)); }
 
    //! Throws: Nothing
    //!
    //! Returns: find(basic_string(1,c), pos).
    size_type find(CharT c, size_type pos = 0) const
    {
-      if (pos >= size())
+      const size_type size = this->size();
+      if (pos >= size)
          return npos;
       else {
-         pointer finish = this->priv_addr() + this->priv_size();
+         const pointer addr    = this->priv_addr();
+         pointer finish = addr + size;
          const const_iterator result =
-            std::find_if(this->priv_addr() + pos, finish,
+            std::find_if(addr + pos, finish,
                   std::bind2nd(Eq_traits(), c));
          return result != finish ? result - begin() : npos;
       }
@@ -1934,7 +1980,7 @@ class basic_string
    //! Returns: rfind(basic_string(s, n), pos).
    size_type rfind(const CharT* s, size_type pos, size_type n) const
    {
-      const size_type len = size();
+      const size_type len = this->size();
 
       if (n > len)
          return npos;
@@ -1963,7 +2009,7 @@ class basic_string
    //! Returns: rfind(basic_string(1,c),pos).
    size_type rfind(CharT c, size_type pos = npos) const
    {
-      const size_type len = size();
+      const size_type len = this->size();
 
       if (len < 1)
          return npos;
@@ -1993,14 +2039,15 @@ class basic_string
    //! Returns: find_first_of(basic_string(s, n), pos).
    size_type find_first_of(const CharT* s, size_type pos, size_type n) const
    {
-      if (pos >= size())
+      const size_type size = this->size();
+      if (pos >= size)
          return npos;
       else {
-         pointer finish = this->priv_addr() + this->priv_size();
-         const_iterator result = std::find_first_of(this->priv_addr() + pos, finish,
-                                                    s, s + n,
-                                                    Eq_traits());
-         return result != finish ? result - begin() : npos;
+         const pointer addr    = this->priv_addr();
+         pointer finish = addr + size;
+         const_iterator result = std::find_first_of
+            (addr + pos, finish, s, s + n, Eq_traits());
+         return result != finish ? result - this->begin() : npos;
       }
    }
 
@@ -2037,17 +2084,17 @@ class basic_string
    //! Returns: find_last_of(basic_string(s, n), pos).
    size_type find_last_of(const CharT* s, size_type pos, size_type n) const
    {
-      const size_type len = size();
+      const size_type len = this->size();
 
       if (len < 1)
          return npos;
       else {
-         const const_iterator last = this->priv_addr() + container_detail::min_value(len - 1, pos) + 1;
+         const pointer addr    = this->priv_addr();
+         const const_iterator last = addr + container_detail::min_value(len - 1, pos) + 1;
          const const_reverse_iterator rresult =
             std::find_first_of(const_reverse_iterator(last), rend(),
-                               s, s + n,
-                               Eq_traits());
-         return rresult != rend() ? (rresult.base() - 1) - this->priv_addr() : npos;
+                               s, s + n, Eq_traits());
+         return rresult != rend() ? (rresult.base() - 1) - addr : npos;
       }
    }
 
@@ -2083,13 +2130,14 @@ class basic_string
    //! Returns: find_first_not_of(basic_string(s, n), pos).
    size_type find_first_not_of(const CharT* s, size_type pos, size_type n) const
    {
-      if (pos > size())
+      if (pos > this->size())
          return npos;
       else {
-         const pointer finish = this->priv_addr() + this->priv_size();
-         const const_iterator result = std::find_if(this->priv_addr() + pos, finish,
-                                    Not_within_traits(s, s + n));
-         return result != finish ? result - this->priv_addr() : npos;
+         const pointer addr   = this->priv_addr();
+         const pointer finish = addr + this->priv_size();
+         const const_iterator result = std::find_if
+            (addr + pos, finish, Not_within_traits(s, s + n));
+         return result != finish ? result - addr : npos;
       }
    }
 
@@ -2106,12 +2154,13 @@ class basic_string
    //! Returns: find_first_not_of(basic_string(1, c), pos).
    size_type find_first_not_of(CharT c, size_type pos = 0) const
    {
-      if (pos > size())
+      if (pos > this->size())
          return npos;
       else {
-         const pointer finish = this->priv_addr() + this->priv_size();
+         const pointer addr   = this->priv_addr();
+         const pointer finish = addr + this->priv_size();
          const const_iterator result
-            = std::find_if(this->priv_addr() + pos, finish,
+            = std::find_if(addr + pos, finish,
                      std::not1(std::bind2nd(Eq_traits(), c)));
          return result != finish ? result - begin() : npos;
       }
@@ -2134,7 +2183,7 @@ class basic_string
    //! Returns: find_last_not_of(basic_string(s, n), pos).
    size_type find_last_not_of(const CharT* s, size_type pos, size_type n) const
    {
-      const size_type len = size();
+      const size_type len = this->size();
 
       if (len < 1)
          return npos;
@@ -2160,7 +2209,7 @@ class basic_string
    //! Returns: find_last_not_of(basic_string(1, c), pos).
    size_type find_last_not_of(CharT c, size_type pos = npos) const
    {
-      const size_type len = size();
+      const size_type len = this->size();
 
       if (len < 1)
          return npos;
@@ -2183,10 +2232,11 @@ class basic_string
    //! Returns: basic_string(data()+pos,rlen).
    basic_string substr(size_type pos = 0, size_type n = npos) const
    {
-      if (pos > size())
+      if (pos > this->size())
          this->throw_out_of_range();
-      return basic_string(this->priv_addr() + pos,
-                          this->priv_addr() + pos + container_detail::min_value(n, size() - pos), this->alloc());
+      const pointer addr = this->priv_addr();
+      return basic_string(addr + pos,
+                          addr + pos + container_detail::min_value(n, size() - pos), this->alloc());
    }
 
    //! Effects: Determines the effective length rlen of the string to copy as
@@ -2199,7 +2249,11 @@ class basic_string
    //!   Otherwise, returns a value < 0 if size() < str.size(), a 0 value if size() == str.size(),
    //!   and value > 0 if size() > str.size()
    int compare(const basic_string& str) const
-   { return s_compare(this->priv_addr(), this->priv_addr() + this->priv_size(), str.priv_addr(), str.priv_addr() + str.priv_size()); }
+   {
+      const pointer addr     = this->priv_addr();
+      const pointer str_addr = str.priv_addr();
+      return s_compare(addr, addr + this->priv_size(), str_addr, str_addr + str.priv_size());
+   }
 
    //! Requires: pos1 <= size()
    //!
@@ -2211,11 +2265,13 @@ class basic_string
    //! Returns:basic_string(*this,pos1,n1).compare(str).
    int compare(size_type pos1, size_type n1, const basic_string& str) const
    {
-      if (pos1 > size())
+      if (pos1 > this->size())
          this->throw_out_of_range();
-      return s_compare(this->priv_addr() + pos1,
-                        this->priv_addr() + pos1 + container_detail::min_value(n1, size() - pos1),
-                        str.priv_addr(), str.priv_addr() + str.priv_size());
+      const pointer addr    = this->priv_addr();
+      const pointer str_addr = str.priv_addr();
+      return s_compare(addr + pos1,
+                        addr + pos1 + container_detail::min_value(n1, this->size() - pos1),
+                        str_addr, str_addr + str.priv_size());
    }
 
    //! Requires: pos1 <= size() and pos2 <= str.size()
@@ -2228,19 +2284,24 @@ class basic_string
    //! Returns: basic_string(*this, pos1, n1).compare(basic_string(str, pos2, n2)).
    int compare(size_type pos1, size_type n1,
                const basic_string& str, size_type pos2, size_type n2) const {
-      if (pos1 > size() || pos2 > str.size())
+      if (pos1 > this->size() || pos2 > str.size())
          this->throw_out_of_range();
-      return s_compare(this->priv_addr() + pos1,
-                        this->priv_addr() + pos1 + container_detail::min_value(n1, size() - pos1),
-                        str.priv_addr() + pos2,
-                        str.priv_addr() + pos2 + container_detail::min_value(n2, size() - pos2));
+      const pointer addr     = this->priv_addr();
+      const pointer str_addr = str.priv_addr();
+      return s_compare(addr + pos1,
+                        addr + pos1 + container_detail::min_value(n1, this->size() - pos1),
+                        str_addr + pos2,
+                        str_addr + pos2 + container_detail::min_value(n2, str.size() - pos2));
    }
 
    //! Throws: Nothing
    //!
    //! Returns: compare(basic_string(s)).
    int compare(const CharT* s) const
-   {  return s_compare(this->priv_addr(), this->priv_addr() + this->priv_size(), s, s + Traits::length(s));   }
+   {
+      const pointer addr = this->priv_addr();
+      return s_compare(addr, addr + this->priv_size(), s, s + Traits::length(s));
+   }
 
 
    //! Requires: pos1 > size() and s points to an array of at least n2 elements of CharT.
@@ -2251,10 +2312,11 @@ class basic_string
    int compare(size_type pos1, size_type n1,
                const CharT* s, size_type n2) const
    {
-      if (pos1 > size())
+      if (pos1 > this->size())
          this->throw_out_of_range();
-      return s_compare(this->priv_addr() + pos1,
-                        this->priv_addr() + pos1 + container_detail::min_value(n1, size() - pos1),
+      const pointer addr = this->priv_addr();
+      return s_compare( addr + pos1,
+                        addr + pos1 + container_detail::min_value(n1, this->size() - pos1),
                         s, s + n2);
    }
 
@@ -2322,15 +2384,12 @@ class basic_string
    }
 
    void priv_construct_null(pointer p)
-   {  this->construct(p, 0);  }
-
-   static CharT priv_null()
-   {  return (CharT) 0; }
+   {  this->construct(p, CharT(0));  }
 
    // Helper functions used by constructors.  It is a severe error for
    // any of them to be called anywhere except from within constructors.
    void priv_terminate_string()
-   {  this->priv_construct_null(this->priv_addr() + this->priv_size());  }
+   {  this->priv_construct_null(this->priv_end_addr());  }
 
    template inline
    void priv_uninitialized_fill_n(FwdIt first, Count count, const CharT val)
@@ -2377,26 +2436,7 @@ class basic_string
       BOOST_CATCH_END
       return (constructed);
    }
-/*
-   template 
-   basic_string& priv_assign_dispatch(InputIter f, InputIter l, container_detail::false_)
-   {
-      size_type cur = 0;
-      CharT *ptr = container_detail::to_raw_pointer(this->priv_addr());
-      const size_type old_size = this->priv_size();
-      while (f != l && cur != old_size) {
-         Traits::assign(*ptr, *f);
-         ++f;
-         ++cur;
-         ++ptr;
-      }
-      if (f == l)
-         this->erase(this->priv_addr() + cur, this->priv_addr() + old_size);
-      else
-         this->append(f, l);
-      return *this;
-   }
-*/
+
    template 
    void priv_copy(InputIterator first, InputIterator last, OutIterator result)
    {
diff --git a/test/check_equal_containers.hpp b/test/check_equal_containers.hpp
index c094711..092846f 100644
--- a/test/check_equal_containers.hpp
+++ b/test/check_equal_containers.hpp
@@ -58,13 +58,8 @@ bool CheckEqualContainers(const MyBoostCont *boostcont, const MyStdCont *stdcont
    }
    std::size_t i = 0;
    for(; itboost != itboostend; ++itboost, ++itstd, ++i){
-
       if(!CheckEqual(*itstd, *itboost))
          return false;
-/*    value_type val(*itstd);
-      const value_type &v = *itboost;
-      if(v != val)
-         return false;*/
    }
    return true;
 }

From 22a18c25fbd2d507701f540834fb68b56cd8236b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Sun, 9 Sep 2012 21:47:32 +0000
Subject: [PATCH 49/93] Reduced template code bloat making stable_vector's
 index independent from value_type.

[SVN r80478]
---
 include/boost/container/detail/destroyers.hpp |  111 +-
 .../detail/multiallocation_chain.hpp          |    2 +-
 .../container/detail/node_alloc_holder.hpp    |   93 --
 include/boost/container/stable_vector.hpp     | 1027 +++++++++--------
 include/boost/container/vector.hpp            |    2 +-
 test/vector_test.hpp                          |   52 +-
 6 files changed, 700 insertions(+), 587 deletions(-)

diff --git a/include/boost/container/detail/destroyers.hpp b/include/boost/container/detail/destroyers.hpp
index d1b118c..befae3f 100644
--- a/include/boost/container/detail/destroyers.hpp
+++ b/include/boost/container/detail/destroyers.hpp
@@ -27,6 +27,68 @@ namespace boost {
 namespace container {
 namespace container_detail {
 
+//!A deleter for scoped_ptr that deallocates the memory
+//!allocated for an object using a STL allocator.
+template 
+struct scoped_deallocator
+{
+   typedef allocator_traits allocator_traits_type;
+   typedef typename allocator_traits_type::pointer pointer;
+   typedef container_detail::integral_constant::value>                   alloc_version;
+   typedef container_detail::integral_constant     allocator_v1;
+   typedef container_detail::integral_constant     allocator_v2;
+
+   private:
+   void priv_deallocate(allocator_v1)
+   {  m_alloc.deallocate(m_ptr, 1); }
+
+   void priv_deallocate(allocator_v2)
+   {  m_alloc.deallocate_one(m_ptr); }
+
+   BOOST_MOVABLE_BUT_NOT_COPYABLE(scoped_deallocator)
+
+   public:
+
+   pointer     m_ptr;
+   A&  m_alloc;
+
+   scoped_deallocator(pointer p, A& a)
+      : m_ptr(p), m_alloc(a)
+   {}
+
+   ~scoped_deallocator()
+   {  if (m_ptr)priv_deallocate(alloc_version());  }
+
+   scoped_deallocator(BOOST_RV_REF(scoped_deallocator) o)
+      :  m_ptr(o.m_ptr), m_alloc(o.m_alloc)
+   {  o.release();  }
+
+   pointer get() const
+   {  return m_ptr;  }
+
+   void release()
+   {  m_ptr = 0; }
+};
+
+template 
+struct null_scoped_deallocator
+{
+   typedef boost::container::allocator_traits AllocTraits;
+   typedef typename AllocTraits::pointer    pointer;
+   typedef typename AllocTraits::size_type  size_type;
+
+   null_scoped_deallocator(pointer, Allocator&, size_type)
+   {}
+
+   void release()
+   {}
+
+   pointer get() const
+   {  return pointer();  }
+};
+
 //!A deleter for scoped_ptr that deallocates the memory
 //!allocated for an array of objects using a STL allocator.
 template 
@@ -239,10 +301,57 @@ class allocator_destroyer
    void operator()(const pointer &p)
    {
       AllocTraits::destroy(a_, container_detail::to_raw_pointer(p));
-      priv_deallocate(p, alloc_version());
+      this->priv_deallocate(p, alloc_version());
    }
 };
 
+template 
+class allocator_destroyer_and_chain_builder
+{
+   typedef allocator_traits allocator_traits_type;
+   typedef typename allocator_traits_type::value_type value_type;
+   typedef typename A::multiallocation_chain    multiallocation_chain;
+
+   A & a_;
+   multiallocation_chain &c_;
+
+   public:
+   allocator_destroyer_and_chain_builder(A &a, multiallocation_chain &c)
+      :  a_(a), c_(c)
+   {}
+
+   void operator()(const typename A::pointer &p)
+   {
+      allocator_traits::destroy(a_, container_detail::to_raw_pointer(p));
+      c_.push_front(p);
+   }
+};
+
+template 
+class allocator_multialloc_chain_node_deallocator
+{
+   typedef allocator_traits allocator_traits_type;
+   typedef typename allocator_traits_type::value_type value_type;
+   typedef typename A::multiallocation_chain    multiallocation_chain;
+   typedef allocator_destroyer_and_chain_builder chain_builder;
+
+   A & a_;
+   multiallocation_chain c_;
+
+   public:
+   allocator_multialloc_chain_node_deallocator(A &a)
+      :  a_(a), c_()
+   {}
+
+   chain_builder get_chain_builder()
+   {  return chain_builder(a_, c_);  }
+
+   ~allocator_multialloc_chain_node_deallocator()
+   {
+      if(!c_.empty())
+         a_.deallocate_individual(boost::move(c_));
+   }
+};
 
 }  //namespace container_detail {
 }  //namespace container {
diff --git a/include/boost/container/detail/multiallocation_chain.hpp b/include/boost/container/detail/multiallocation_chain.hpp
index e701643..155e9bc 100644
--- a/include/boost/container/detail/multiallocation_chain.hpp
+++ b/include/boost/container/detail/multiallocation_chain.hpp
@@ -200,7 +200,7 @@ class transform_multiallocation_chain
    void splice_after(iterator after_this, transform_multiallocation_chain &x, iterator before_begin, iterator before_end, size_type n)
    {  holder_.splice_after(after_this.base(), x.holder_, before_begin.base(), before_end.base(), n);  }
 
-   void incorporate_after(iterator after_this, void_pointer begin, void_pointer before_end, size_type n)
+   void incorporate_after(iterator after_this, pointer begin, pointer before_end, size_type n)
    {  holder_.incorporate_after(after_this.base(), begin, before_end, n);  }
 
    void pop_front()
diff --git a/include/boost/container/detail/node_alloc_holder.hpp b/include/boost/container/detail/node_alloc_holder.hpp
index 9797f1f..8b0f8ba 100644
--- a/include/boost/container/detail/node_alloc_holder.hpp
+++ b/include/boost/container/detail/node_alloc_holder.hpp
@@ -43,99 +43,6 @@ namespace boost {
 namespace container {
 namespace container_detail {
 
-//!A deleter for scoped_ptr that deallocates the memory
-//!allocated for an object using a STL allocator.
-template 
-struct scoped_deallocator
-{
-   typedef allocator_traits allocator_traits_type;
-   typedef typename allocator_traits_type::pointer pointer;
-   typedef container_detail::integral_constant::value>                   alloc_version;
-   typedef container_detail::integral_constant     allocator_v1;
-   typedef container_detail::integral_constant     allocator_v2;
-
-   private:
-   void priv_deallocate(allocator_v1)
-   {  m_alloc.deallocate(m_ptr, 1); }
-
-   void priv_deallocate(allocator_v2)
-   {  m_alloc.deallocate_one(m_ptr); }
-
-   BOOST_MOVABLE_BUT_NOT_COPYABLE(scoped_deallocator)
-
-   public:
-
-   pointer     m_ptr;
-   A&  m_alloc;
-
-   scoped_deallocator(pointer p, A& a)
-      : m_ptr(p), m_alloc(a)
-   {}
-
-   ~scoped_deallocator()
-   {  if (m_ptr)priv_deallocate(alloc_version());  }
-
-   scoped_deallocator(BOOST_RV_REF(scoped_deallocator) o)
-      :  m_ptr(o.m_ptr), m_alloc(o.m_alloc)
-   {  o.release();  }
-
-   pointer get() const
-   {  return m_ptr;  }
-
-   void release()
-   {  m_ptr = 0; }
-};
-
-template 
-class allocator_destroyer_and_chain_builder
-{
-   typedef allocator_traits allocator_traits_type;
-   typedef typename allocator_traits_type::value_type value_type;
-   typedef typename A::multiallocation_chain    multiallocation_chain;
-
-   A & a_;
-   multiallocation_chain &c_;
-
-   public:
-   allocator_destroyer_and_chain_builder(A &a, multiallocation_chain &c)
-      :  a_(a), c_(c)
-   {}
-
-   void operator()(const typename A::pointer &p)
-   {
-      allocator_traits::destroy(a_, container_detail::to_raw_pointer(p));
-      c_.push_front(p);
-   }
-};
-
-template 
-class allocator_multialloc_chain_node_deallocator
-{
-   typedef allocator_traits allocator_traits_type;
-   typedef typename allocator_traits_type::value_type value_type;
-   typedef typename A::multiallocation_chain    multiallocation_chain;
-   typedef allocator_destroyer_and_chain_builder chain_builder;
-
-   A & a_;
-   multiallocation_chain c_;
-
-   public:
-   allocator_multialloc_chain_node_deallocator(A &a)
-      :  a_(a), c_()
-   {}
-
-   chain_builder get_chain_builder()
-   {  return chain_builder(a_, c_);  }
-
-   ~allocator_multialloc_chain_node_deallocator()
-   {
-      if(!c_.empty())
-         a_.deallocate_individual(boost::move(c_));
-   }
-};
-
 template
 struct node_compare
    :  private ValueCompare
diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp
index 30f1a4f..be0416c 100644
--- a/include/boost/container/stable_vector.hpp
+++ b/include/boost/container/stable_vector.hpp
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -48,10 +49,6 @@
 
 //#define STABLE_VECTOR_ENABLE_INVARIANT_CHECKING
 
-#if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING)
-#include 
-#endif
-
 ///@endcond
 
 namespace boost {
@@ -61,24 +58,6 @@ namespace container {
 
 namespace stable_vector_detail{
 
-template
-struct smart_ptr_type
-{
-   typedef typename SmartPtr::value_type value_type;
-   typedef value_type *pointer;
-   static pointer get (const SmartPtr &smartptr)
-   {  return smartptr.get();}
-};
-
-template
-struct smart_ptr_type
-{
-   typedef T value_type;
-   typedef value_type *pointer;
-   static pointer get (pointer ptr)
-   {  return ptr;}
-};
-
 template 
 class clear_on_destroy
 {
@@ -108,22 +87,21 @@ class clear_on_destroy
 template
 struct node;
 
-template
+template
 struct node_base
 {
    private:
-   typedef NodePtr                              node_ptr;
    typedef typename boost::intrusive::
-      pointer_traits                  node_ptr_traits;
-   typedef typename node_ptr_traits::
+      pointer_traits                   void_ptr_traits;
+   typedef typename void_ptr_traits::
       template rebind_pointer
          ::type                      node_base_ptr;
-   typedef typename node_ptr_traits::
+   typedef typename void_ptr_traits::
       template rebind_pointer
-         ::type                       node_ptr_ptr;
+         ::type                  node_base_ptr_ptr;
 
    public:
-   node_base(const node_ptr_ptr &n)
+   node_base(const node_base_ptr_ptr &n)
       : up(n)
    {}
 
@@ -131,15 +109,12 @@ struct node_base
       : up()
    {}
 
-   node_ptr_ptr up;
+   node_base_ptr_ptr up;
 };
 
 template
 struct node
-   : public node_base
-   ::template
-            rebind_pointer< node >::type>
+   : public node_base
 {
    private:
    node();
@@ -162,10 +137,15 @@ class iterator
    typedef typename ptr_traits::template
          rebind_pointer::type             void_ptr;
    typedef node                    node_type;
+   typedef node_base                  node_base_type;
    typedef typename ptr_traits::template
          rebind_pointer::type        node_ptr;
+   typedef boost::intrusive::
+      pointer_traits                  node_ptr_traits;
    typedef typename ptr_traits::template
-         rebind_pointer::type         node_ptr_ptr;
+         rebind_pointer::type   node_base_ptr;
+   typedef typename ptr_traits::template
+         rebind_pointer::type    node_base_ptr_ptr;
    typedef typename ptr_traits::template
       rebind_pointer::type                   friend_iterator_pointer;
 
@@ -189,20 +169,26 @@ class iterator
       : pn(x.pn)
    {}
 
+   node_ptr &node_pointer()
+   {  return pn;  }
+
+   const node_ptr &node_pointer() const
+   {  return pn;  }
+
    public:
    //Pointer like operators
    reference operator*()  const
    {  return  pn->value;  }
 
    pointer   operator->() const
-   {  return  ptr_traits::pointer_to(*this);  }
+   {  return  ptr_traits::pointer_to(this->operator*());  }
 
    //Increment / Decrement
-   iterator& operator++() 
+   iterator& operator++()
    {
-      if(node_ptr_ptr p = this->pn->up){
+      if(node_base_ptr_ptr p = this->pn->up){
          ++p;
-         this->pn = *p;
+         this->pn = node_ptr_traits::static_cast_from(*p);
       }
       return *this;
    }
@@ -212,9 +198,9 @@ class iterator
 
    iterator& operator--()
    {
-      if(node_ptr_ptr p = this->pn->up){
+      if(node_base_ptr_ptr p = this->pn->up){
          --p;
-         this->pn = *p;
+         this->pn = node_ptr_traits::static_cast_from(*p);
       }
       return *this;
    }
@@ -231,9 +217,9 @@ class iterator
 
    iterator& operator+=(difference_type off)
    {
-      if(node_ptr_ptr p = this->pn->up){
+      if(node_base_ptr_ptr p = this->pn->up){
          p += off;
-         this->pn = *p;
+         this->pn = node_ptr_traits::static_cast_from(*p);
       }
       return *this;
    }
@@ -309,39 +295,131 @@ struct select_multiallocation_chain
          , typename allocator_traits::value_type>        type;
 };
 
+template
+struct index_traits
+{
+   typedef boost::intrusive::
+      pointer_traits
+                                             void_ptr_traits;
+   typedef stable_vector_detail::
+      node_base                              node_base_type;
+   typedef typename void_ptr_traits::template
+         rebind_pointer::type         node_base_ptr;
+   typedef typename void_ptr_traits::template
+         rebind_pointer::type          node_base_ptr_ptr;
+   typedef boost::intrusive::
+      pointer_traits                   node_base_ptr_traits;
+   typedef boost::intrusive::
+      pointer_traits               node_base_ptr_ptr_traits;
+   typedef typename allocator_traits::
+         template portable_rebind_alloc
+            ::type                     node_base_ptr_allocator;
+   typedef ::boost::container::vector
+              index_type;
+   typedef typename index_type::iterator              index_iterator;
+   typedef typename index_type::const_iterator        const_index_iterator;
+   typedef typename index_type::size_type             size_type;
+
+   static const size_type ExtraPointers = 3;
+   //Stable vector stores metadata at the end of the index (node_base_ptr vector) with additional 3 pointers:
+   //    back() is this->index.back() - ExtraPointers;
+   //    end node index is    *(this->index.end() -3)
+   //    Node cache first is  *(this->index.end() - 2);
+   //    Node cache last is   this->index.back();
+
+   static node_base_ptr_ptr ptr_to_node_base_ptr(node_base_ptr &n)
+   {  return node_base_ptr_ptr_traits::pointer_to(n);   }
+
+   static void fix_up_pointers(index_iterator first, index_iterator last)
+   {
+      while(first != last){
+         typedef typename index_type::reference node_base_ptr_ref;
+         node_base_ptr_ref nbp = *first;
+         nbp->up = index_traits::ptr_to_node_base_ptr(nbp);
+         ++first;
+      }
+   }
+
+   static index_iterator get_fix_up_end(index_type &index)
+   {  return index.end() - (ExtraPointers - 1); }
+
+   static void fix_up_pointers_from(index_type & index, index_iterator first)
+   {  index_traits::fix_up_pointers(first, index_traits::get_fix_up_end(index));   }
+
+   static void readjust_end_node(index_type &index, node_base_type &end_node)
+   {
+      if(!index.empty()){
+         node_base_ptr &end_node_idx_ref = *(--index_traits::get_fix_up_end(index));
+         end_node_idx_ref = node_base_ptr_traits::pointer_to(end_node);
+         end_node.up      = node_base_ptr_ptr_traits::pointer_to(end_node_idx_ref);
+      }
+      else{
+         end_node.up = node_base_ptr_ptr();
+      }
+   }
+
+   static void initialize_end_node(index_type &index, node_base_type &end_node, const size_type index_capacity_if_empty)
+   {
+      if(index.empty()){
+         index.reserve(index_capacity_if_empty + ExtraPointers);
+         index.resize(ExtraPointers);
+         node_base_ptr &end_node_ref = *index.data();
+         end_node_ref = node_base_ptr_traits::pointer_to(end_node);
+         end_node.up = index_traits::ptr_to_node_base_ptr(end_node_ref);
+      }
+   }
+
+
+   #ifdef STABLE_VECTOR_ENABLE_INVARIANT_CHECKING
+   static bool invariants(index_type &index)
+   {
+      for( index_iterator it = index.begin()
+         , it_end = index_traits::get_fix_up_end(index)
+         ; it != it_end
+         ; ++it){
+         if((*it)->up != index_traits::ptr_to_node_base_ptr(*it)){
+            return false;
+         }
+      }
+      return true;
+   }
+   #endif   //STABLE_VECTOR_ENABLE_INVARIANT_CHECKING
+};
+
 } //namespace stable_vector_detail
 
 #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
-#if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING)
+   #if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING)
 
-#define STABLE_VECTOR_CHECK_INVARIANT \
-invariant_checker BOOST_JOIN(check_invariant_,__LINE__)(*this); \
-BOOST_JOIN(check_invariant_,__LINE__).touch();
-#else
+   #define STABLE_VECTOR_CHECK_INVARIANT \
+   invariant_checker BOOST_JOIN(check_invariant_,__LINE__)(*this); \
+   BOOST_JOIN(check_invariant_,__LINE__).touch();
 
-#define STABLE_VECTOR_CHECK_INVARIANT
+   #else //STABLE_VECTOR_ENABLE_INVARIANT_CHECKING
 
-#endif   //#if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING)
+   #define STABLE_VECTOR_CHECK_INVARIANT
+
+   #endif   //#if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING)
 
 #endif   //#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
 /// @endcond
 
-//! Originally developed by Joaquin M. Lopez Munoz, stable_vector is std::vector
+//! Originally developed by Joaquin M. Lopez Munoz, stable_vector is a std::vector
 //! drop-in replacement implemented as a node container, offering iterator and reference
 //! stability.
 //!
-//! More details taken the author's blog:
+//! Here are the details taken from the author's blog
 //! (
-//! Introducing stable_vector)
+//! Introducing stable_vector):
 //!
 //! We present stable_vector, a fully STL-compliant stable container that provides
 //! most of the features of std::vector except element contiguity.
 //!
 //! General properties: stable_vector satisfies all the requirements of a container,
 //! a reversible container and a sequence and provides all the optional operations
-//! present in std::vector. Like std::vector,  iterators are random access.
+//! present in std::vector. Like std::vector, iterators are random access.
 //! stable_vector does not provide element contiguity; in exchange for this absence,
 //! the container is stable, i.e. references and iterators to an element of a stable_vector
 //! remain valid as long as the element is not erased, and an iterator that has been
@@ -358,7 +436,7 @@ BOOST_JOIN(check_invariant_,__LINE__).touch();
 //! additional allocation per element.
 //!
 //! Exception safety: As stable_vector does not internally copy elements around, some
-//! operations provide stronger exception safety guarantees than in std::vector:
+//! operations provide stronger exception safety guarantees than in std::vector.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
 template  >
 #else
@@ -368,34 +446,43 @@ class stable_vector
 {
    ///@cond
    typedef allocator_traits                        allocator_traits_type;
+   typedef typename boost::intrusive::pointer_traits
+      ::
+         template rebind_pointer::type          void_ptr;
+   typedef typename allocator_traits_type::
+      template portable_rebind_alloc
+         ::type                                 void_allocator_type;
+   typedef stable_vector_detail::index_traits
+                       index_traits_type;
+   typedef typename index_traits_type::node_base_type node_base_type;
+   typedef typename index_traits_type::node_base_ptr  node_base_ptr;
+   typedef typename index_traits_type::
+      node_base_ptr_ptr                               node_base_ptr_ptr;
+   typedef typename index_traits_type::
+      node_base_ptr_traits                            node_base_ptr_traits;
+   typedef typename index_traits_type::
+      node_base_ptr_ptr_traits                        node_base_ptr_ptr_traits;
+   typedef typename index_traits_type::index_type     index_type;
+   typedef typename index_traits_type::index_iterator index_iterator;
+   typedef typename index_traits_type::
+      const_index_iterator                            const_index_iterator;
+
    typedef typename container_detail::
       move_const_ref_type::type                    insert_const_ref_type;
    typedef boost::intrusive::
       pointer_traits
              ptr_traits;
-   typedef typename boost::intrusive::pointer_traits
-      ::
-         template rebind_pointer::type          void_ptr;
    typedef stable_vector_detail::node    node_type;
    typedef typename ptr_traits::template
       rebind_pointer::type                 node_ptr;
-   typedef typename ptr_traits::template
-         rebind_pointer::type               node_ptr_ptr;
-   typedef stable_vector_detail::
-      node_base                             node_base_type;
-   typedef typename ptr_traits::template
-         rebind_pointer::type         node_base_ptr;
-   typedef boost::intrusive::
-      pointer_traits                   node_base_ptr_traits;
    typedef boost::intrusive::
       pointer_traits                        node_ptr_traits;
+   typedef typename ptr_traits::template
+      rebind_pointer::type           const_node_ptr;
    typedef boost::intrusive::
-      pointer_traits                    node_ptr_ptr_traits;
-   typedef ::boost::container::vector::type>                         impl_type;
-   typedef typename impl_type::iterator               impl_iterator;
+      pointer_traits                  const_node_ptr_traits;
+   typedef typename node_ptr_traits::reference        node_reference;
+   typedef typename const_node_ptr_traits::reference  const_node_reference;
 
    typedef ::boost::container::container_detail::
       integral_constant                  allocator_v1;
@@ -407,6 +494,11 @@ class stable_vector
    typedef typename allocator_traits_type::
       template portable_rebind_alloc
          ::type                            node_allocator_type;
+   typedef typename stable_vector_detail::
+      select_multiallocation_chain
+      < node_allocator_type
+      , alloc_version::value
+      >::type                                         multiallocation_chain;
 
    node_ptr allocate_one()
    {  return this->allocate_one(alloc_version());   }
@@ -442,6 +534,74 @@ class stable_vector
             ::value>::type * = 0)
    {  this->priv_node_alloc().deallocate_one(p);   }
 
+   multiallocation_chain allocate_individual(typename allocator_traits_type::size_type n)
+   {  return this->allocate_individual(n, alloc_version());   }
+
+   struct allocate_individual_rollback
+   {
+      allocate_individual_rollback(stable_vector &sv, multiallocation_chain &chain)
+         : mr_sv(sv), mr_chain(chain)
+      {}
+
+      ~allocate_individual_rollback()
+      {
+         if(!mr_chain.empty()){
+            mr_sv.deallocate_individual(mr_chain);
+         }
+      }
+
+      stable_vector &mr_sv;
+      multiallocation_chain &mr_chain;
+   };
+
+   template
+   multiallocation_chain allocate_individual
+      (typename allocator_traits_type::size_type n, AllocatorVersion,
+      typename boost::container::container_detail::enable_if_c
+         
+            ::value>::type * = 0)
+   {
+      multiallocation_chain m;
+      multiallocation_chain m_ret;
+      allocate_individual_rollback rollback(*this, m);
+      while(n--){
+         m.push_front(this->allocate_one());
+      }
+      m.swap(m_ret);
+      return ::boost::move(m_ret);
+   }
+
+   template
+   multiallocation_chain allocate_individual
+      (typename allocator_traits_type::size_type n, AllocatorVersion,
+      typename boost::container::container_detail::enable_if_c
+         
+            ::value>::type * = 0)
+   {  return this->priv_node_alloc().allocate_individual(n);   }
+
+   void deallocate_individual(multiallocation_chain &holder)
+   {  this->deallocate_individual(holder, alloc_version());   }
+
+   template
+   void deallocate_individual(multiallocation_chain & holder, AllocatorVersion,
+      typename boost::container::container_detail::enable_if_c
+         
+            ::value>::type * = 0)
+   {
+      while(!holder.empty()){
+         const node_ptr n = holder.front();
+         holder.pop_front();
+         this->deallocate_one(n);
+      }
+   }
+
+   template
+   void deallocate_individual(multiallocation_chain & holder, AllocatorVersion,
+      typename boost::container::container_detail::enable_if_c
+         
+            ::value>::type * = 0)
+   {  this->priv_node_alloc().deallocate_individual(boost::move(holder));  }
+
    friend class stable_vector_detail::clear_on_destroy;
    ///@endcond
    public:
@@ -457,7 +617,7 @@ class stable_vector
                                        iterator;
    typedef stable_vector_detail::iterator
                            const_iterator;
-   typedef typename impl_type::size_type              size_type;
+   typedef typename index_type::size_type             size_type;
    typedef typename iterator::difference_type         difference_type;
    typedef T                                          value_type;
    typedef A                                          allocator_type;
@@ -468,19 +628,15 @@ class stable_vector
    ///@cond
    private:
    BOOST_COPYABLE_AND_MOVABLE(stable_vector)
-   static const size_type ExtraPointers = 3;
-   //This container stores metadata at the end of the node_ptr vector with additional 3 pointers:
-   //    back() is this->impl.back() - ExtraPointers;
-   //    end node index is    *(this->impl.end() -3)
-   //    Node cache first is  *(this->impl.end() - 2);
-   //    Node cache last is   this->impl.back();
+   static const size_type ExtraPointers = index_traits_type::ExtraPointers;
 
-   typedef typename stable_vector_detail::
-      select_multiallocation_chain
-      < node_allocator_type
-      , alloc_version::value
-      >::type                                         multiallocation_chain;
+   class insert_rollback;
+   friend class insert_rollback;
+
+   class push_back_rollback;
+   friend class push_back_rollback;
    ///@endcond
+
    public:
 
    //! Effects: Default constructs a stable_vector.
@@ -489,7 +645,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    stable_vector()
-      : internal_data(), impl()
+      : internal_data(), index()
    {
       STABLE_VECTOR_CHECK_INVARIANT;
    }
@@ -500,7 +656,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    explicit stable_vector(const allocator_type& al)
-      : internal_data(al), impl(al)
+      : internal_data(al), index(al)
    {
       STABLE_VECTOR_CHECK_INVARIANT;
    }
@@ -513,7 +669,7 @@ class stable_vector
    //!
    //! Complexity: Linear to n.
    explicit stable_vector(size_type n)
-      : internal_data(), impl()
+      : internal_data(), index()
    {
       stable_vector_detail::clear_on_destroy cod(*this);
       this->resize(n);
@@ -529,7 +685,7 @@ class stable_vector
    //!
    //! Complexity: Linear to n.
    stable_vector(size_type n, const T& t, const allocator_type& al = allocator_type())
-      : internal_data(al), impl(al)
+      : internal_data(al), index(al)
    {
       stable_vector_detail::clear_on_destroy cod(*this);
       this->insert(this->cend(), n, t);
@@ -546,7 +702,7 @@ class stable_vector
    //! Complexity: Linear to the range [first, last).
    template 
    stable_vector(InputIterator first,InputIterator last, const allocator_type& al = allocator_type())
-      : internal_data(al), impl(al)
+      : internal_data(al), index(al)
    {
       stable_vector_detail::clear_on_destroy cod(*this);
       this->insert(this->cend(), first, last);
@@ -562,8 +718,8 @@ class stable_vector
    stable_vector(const stable_vector& x)
       : internal_data(allocator_traits::
          select_on_container_copy_construction(x.priv_node_alloc()))
-      , impl(allocator_traits::
-         select_on_container_copy_construction(x.impl.get_stored_allocator()))
+      , index(allocator_traits::
+         select_on_container_copy_construction(x.index.get_stored_allocator()))
    {
       stable_vector_detail::clear_on_destroy cod(*this);
       this->insert(this->cend(), x.begin(), x.end());
@@ -577,7 +733,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    stable_vector(BOOST_RV_REF(stable_vector) x)
-      : internal_data(boost::move(x.priv_node_alloc())), impl(boost::move(x.impl))
+      : internal_data(boost::move(x.priv_node_alloc())), index(boost::move(x.index))
    {
       this->priv_swap_members(x);
    }
@@ -588,7 +744,7 @@ class stable_vector
    //!
    //! Complexity: Linear to the elements x contains.
    stable_vector(const stable_vector& x, const allocator_type &a)
-      : internal_data(a), impl(a)
+      : internal_data(a), index(a)
    {
       stable_vector_detail::clear_on_destroy cod(*this);
       this->insert(this->cend(), x.begin(), x.end());
@@ -603,7 +759,7 @@ class stable_vector
    //!
    //! Complexity: Constant if a == x.get_allocator(), linear otherwise
    stable_vector(BOOST_RV_REF(stable_vector) x, const allocator_type &a)
-      : internal_data(a), impl(a)
+      : internal_data(a), index(a)
    {
       if(this->priv_node_alloc() == x.priv_node_alloc()){
          this->priv_swap_members(x);
@@ -625,7 +781,7 @@ class stable_vector
    ~stable_vector()
    {
       this->clear();
-      priv_clear_pool(); 
+      this->priv_clear_pool(); 
    }
 
    //! Effects: Makes *this contain the same elements as x.
@@ -649,7 +805,7 @@ class stable_vector
             this->shrink_to_fit();
          }
          container_detail::assign_alloc(this->priv_node_alloc(), x.priv_node_alloc(), flag);
-         container_detail::assign_alloc(this->impl.get_stored_allocator(), x.impl.get_stored_allocator(), flag);
+         container_detail::assign_alloc(this->index.get_stored_allocator(), x.index.get_stored_allocator(), flag);
          this->assign(x.begin(), x.end());
       }
       return *this;
@@ -672,7 +828,7 @@ class stable_vector
          if(this_alloc == x_alloc){
             //Destroy objects but retain memory
             this->clear();
-            this->impl = boost::move(x.impl);
+            this->index = boost::move(x.index);
             this->priv_swap_members(x);
             //Move allocator if needed
             container_detail::bool_Effects: Assigns the n copies of val to *this.
    //!
    //! Throws: If memory allocation throws or T's copy constructor throws.
    //!
    //! Complexity: Linear to n.
-   void assign(size_type n,const T& t)
+   void assign(size_type n, const T& t)
    {
       typedef constant_iterator cvalue_iterator;
       this->assign(cvalue_iterator(t, n), cvalue_iterator());
@@ -733,7 +888,7 @@ class stable_vector
    //! Throws: If allocator's copy constructor throws.
    //!
    //! Complexity: Constant.
-   allocator_type get_allocator()const
+   allocator_type get_allocator() const
    {  return this->priv_node_alloc();  }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -762,7 +917,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    iterator  begin()
-   {   return (this->impl.empty()) ? this->end(): iterator(this->impl.front()) ;   }
+   {   return (this->index.empty()) ? this->end(): iterator(node_ptr_traits::static_cast_from(this->index.front())); }
 
    //! Effects: Returns a const_iterator to the first element contained in the stable_vector.
    //!
@@ -770,21 +925,23 @@ class stable_vector
    //!
    //! Complexity: Constant.
    const_iterator  begin()const
-   {   return (this->impl.empty()) ? this->cend() : const_iterator(this->impl.front()) ;   }
+   {   return (this->index.empty()) ? this->cend() : const_iterator(node_ptr_traits::static_cast_from(this->index.front())) ;   }
 
    //! Effects: Returns an iterator to the end of the stable_vector.
    //!
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator        end()                {return iterator(this->get_end_node());}
+   iterator        end()
+   {  return iterator(this->priv_get_end_node());  }
 
    //! Effects: Returns a const_iterator to the end of the stable_vector.
    //!
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator  end()const           {return const_iterator(this->get_end_node());}
+   const_iterator  end() const
+   {  return const_iterator(this->priv_get_end_node());  }
 
    //! Effects: Returns a reverse_iterator pointing to the beginning
    //! of the reversed stable_vector.
@@ -792,7 +949,8 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reverse_iterator       rbegin()      {return reverse_iterator(this->end());}
+   reverse_iterator       rbegin()
+   {  return reverse_iterator(this->end());  }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
    //! of the reversed stable_vector.
@@ -800,7 +958,8 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator rbegin()const {return const_reverse_iterator(this->end());}
+   const_reverse_iterator rbegin() const
+   {  return const_reverse_iterator(this->end());  }
 
    //! Effects: Returns a reverse_iterator pointing to the end
    //! of the reversed stable_vector.
@@ -808,7 +967,8 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reverse_iterator       rend()        {return reverse_iterator(this->begin());}
+   reverse_iterator       rend()
+   {  return reverse_iterator(this->begin());   }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
    //! of the reversed stable_vector.
@@ -816,21 +976,24 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator rend()const   {return const_reverse_iterator(this->begin());}
+   const_reverse_iterator rend()const
+   {  return const_reverse_iterator(this->begin());   }
 
    //! Effects: Returns a const_iterator to the first element contained in the stable_vector.
    //!
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator         cbegin()const {return this->begin();}
+   const_iterator         cbegin() const
+   {  return this->begin();   }
 
    //! Effects: Returns a const_iterator to the end of the stable_vector.
    //!
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator         cend()const   {return this->end();}
+   const_iterator         cend()const
+   {  return this->end();  }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
    //! of the reversed stable_vector.
@@ -838,7 +1001,8 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin()const{return this->rbegin();}
+   const_reverse_iterator crbegin() const
+   {  return this->rbegin();  }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
    //! of the reversed stable_vector.
@@ -846,7 +1010,8 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator crend()const  {return this->rend();}
+   const_reverse_iterator crend()const
+   {  return this->rend(); }
 
    //! Effects: Returns the number of the elements contained in the stable_vector.
    //!
@@ -854,7 +1019,10 @@ class stable_vector
    //!
    //! Complexity: Constant.
    size_type size() const
-   {  return this->impl.empty() ? 0 : (this->impl.size() - ExtraPointers);   }
+   {
+      const size_type index_size = this->index.size();
+      return index_size ? (index_size - ExtraPointers) : 0;
+   }
 
    //! Effects: Returns the largest possible size of the stable_vector.
    //!
@@ -862,7 +1030,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    size_type max_size() const
-   {  return this->impl.max_size() - ExtraPointers;  }
+   {  return this->index.max_size() - ExtraPointers;  }
 
    //! Effects: Number of elements for which memory has been allocated.
    //!   capacity() is always greater than or equal to size().
@@ -872,14 +1040,13 @@ class stable_vector
    //! Complexity: Constant.
    size_type capacity() const
    {
-      if(!this->impl.capacity()){
-         return 0;
-      }
-      else{
-         const size_type num_nodes = this->impl.size() + this->internal_data.pool_size;
-         const size_type num_buck  = this->impl.capacity();
-         return (num_nodes < num_buck) ? num_nodes : num_buck;
-      }
+      const size_type index_size             = this->index.size();
+      BOOST_ASSERT(!index_size || index_size >= ExtraPointers);
+      const size_type bucket_extra_capacity = this->index.capacity()- index_size;
+      const size_type node_extra_capacity   = this->internal_data.pool_size;
+      const size_type extra_capacity        = (bucket_extra_capacity < node_extra_capacity)
+         ? bucket_extra_capacity : node_extra_capacity;
+      return (index_size ? (index_size - ExtraPointers + extra_capacity) : index_size);
    }
 
    //! Effects: Returns true if the stable_vector contains no elements.
@@ -888,7 +1055,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    bool empty() const
-   {  return this->impl.empty() || this->impl.size() == ExtraPointers;  }
+   {  return this->index.size() <= ExtraPointers;  }
 
    //! Effects: Inserts or erases elements at the end such that
    //!   the size becomes n. New elements are copy constructed from x.
@@ -933,20 +1100,20 @@ class stable_vector
       if(n > this->max_size())
          throw std::bad_alloc();
 
-      size_type size = this->size();  
+      size_type size         = this->size();  
       size_type old_capacity = this->capacity();
       if(n > old_capacity){
-         this->initialize_end_node(n);
-         const void * old_ptr = &impl[0];
-         this->impl.reserve(n + ExtraPointers);
-         bool realloced = &impl[0] != old_ptr;
+         index_traits_type::initialize_end_node(this->index, this->internal_data.end_node, n);
+         const void * old_ptr = &index[0];
+         this->index.reserve(n + ExtraPointers);
+         bool realloced = &index[0] != old_ptr;
          //Fix the pointers for the newly allocated buffer
          if(realloced){
-            this->align_nodes(this->impl.begin(), this->impl.begin()+size+1);
+            index_traits_type::fix_up_pointers_from(this->index, this->index.begin());
          }
          //Now fill pool if data is not enough
          if((n - size) > this->internal_data.pool_size){
-            this->priv_add_to_pool((n - size) - this->internal_data.pool_size);
+            this->priv_increase_pool((n - size) - this->internal_data.pool_size);
          }
       }
    }
@@ -960,7 +1127,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    reference operator[](size_type n)
-   {  return this->impl[n]->value;   }
+   {  return static_cast(*this->index[n]).value;  }
 
    //! Requires: size() > n.
    //!
@@ -971,7 +1138,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    const_reference operator[](size_type n)const
-   {  return this->impl[n]->value;  }
+   {  return static_cast(*this->index[n]).value;   }
 
    //! Requires: size() > n.
    //!
@@ -1012,7 +1179,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    reference front()
-   {  return this->impl.front()->value;   }
+   {  return static_cast(*this->index.front()).value;  }
 
    //! Requires: !empty()
    //!
@@ -1022,8 +1189,8 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reference front()const
-   {  return this->impl.front()->value;   }
+   const_reference front() const
+   {  return static_cast(*this->index.front()).value;  }
 
    //! Requires: !empty()
    //!
@@ -1034,7 +1201,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    reference back()
-   {  return (*(&this->impl.back() - ExtraPointers))->value; }
+   {  return static_cast(*this->index[this->size() - ExtraPointers]).value;  }
 
    //! Requires: !empty()
    //!
@@ -1045,25 +1212,16 @@ class stable_vector
    //!
    //! Complexity: Constant.
    const_reference back()const
-   {  return (*(&this->impl.back() - ExtraPointers))->value; }
+   {  return static_cast(*this->index[this->size() - ExtraPointers]).value;  }
 
+   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
    //! Effects: Inserts a copy of x at the end of the stable_vector.
    //!
    //! Throws: If memory allocation throws or
    //!   T's copy constructor throws.
    //!
    //! Complexity: Amortized constant time.
-   void push_back(insert_const_ref_type x)
-   {  return priv_push_back(x);  }
-
-   #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   void push_back(T &x) { push_back(const_cast(x)); }
-
-   template
-   void push_back(const U &u, typename container_detail::enable_if_c
-                  ::value && !::boost::has_move_emulation_enabled::value >::type* =0)
-   { return priv_push_back(u); }
-   #endif
+   void push_back(const T &x);
 
    //! Effects: Constructs a new element in the end of the stable_vector
    //!   and moves the resources of mx to this new element.
@@ -1071,8 +1229,10 @@ class stable_vector
    //! Throws: If memory allocation throws.
    //!
    //! Complexity: Amortized constant time.
-   void push_back(BOOST_RV_REF(T) t)
-   {  this->insert(end(), boost::move(t));  }
+   void push_back(T &&x);
+   #else
+   BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
+   #endif
 
    //! Effects: Removes the last element from the stable_vector.
    //!
@@ -1082,6 +1242,9 @@ class stable_vector
    void pop_back()
    {  this->erase(this->end()-1);   }
 
+
+
+   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
    //! Requires: position must be a valid iterator of *this.
    //!
    //! Effects: Insert a copy of x before position.
@@ -1092,17 +1255,7 @@ class stable_vector
    //!
    //! Complexity: If position is end(), amortized constant time
    //!   Linear time otherwise.
-   iterator insert(const_iterator position, insert_const_ref_type x)
-   {  return this->priv_insert(position, x); }
-
-   #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   iterator insert(const_iterator position, T &x) { return this->insert(position, const_cast(x)); }
-
-   template
-   iterator insert(const_iterator position, const U &u, typename container_detail::enable_if_c
-                  ::value && !::boost::has_move_emulation_enabled::value >::type* =0)
-   {  return this->priv_insert(position, u); }
-   #endif
+   iterator insert(const_iterator position, const T &x);
 
    //! Requires: position must be a valid iterator of *this.
    //!
@@ -1114,17 +1267,10 @@ class stable_vector
    //!
    //! Complexity: If position is end(), amortized constant time
    //!   Linear time otherwise.
-   iterator insert(const_iterator position, BOOST_RV_REF(T) x)
-   {
-      typedef repeat_iterator           repeat_it;
-      typedef boost::move_iterator repeat_move_it;
-      //Just call more general insert(pos, size, value) and return iterator
-      size_type pos_n = position - cbegin();
-      this->insert(position
-         ,repeat_move_it(repeat_it(x, 1))
-         ,repeat_move_it(repeat_it()));
-      return iterator(this->begin() + pos_n);
-   }
+   iterator insert(const_iterator position, T &&x);
+   #else
+   BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator)
+   #endif
 
    //! Requires: pos must be a valid iterator of *this.
    //!
@@ -1179,16 +1325,35 @@ class stable_vector
          >::type * = 0
       )
    {
-      size_type       n = (size_type)std::distance(first,last);
-      difference_type d = position - this->cbegin();
-      if(n){
-         this->insert_iter_prolog(n, d);
-         const impl_iterator it(this->impl.begin() + d);
-         this->priv_insert_iter_fwd(it, first, last, n);
-         //Fix the pointers for the newly allocated buffer
-         this->align_nodes(it + n, this->get_end_align());
+      const size_type num_new    = (size_type)std::distance(first,last);
+      const size_type pos        = static_cast(position - this->cbegin());
+      if(num_new){
+         //Fills the node pool and inserts num_new null pointers in pos.
+         //If a new buffer was needed fixes up pointers up to pos so
+         //past-new nodes are not aligned until the end of this function
+         //or in a rollback in case of exception
+         index_iterator it_past_newly_constructed(this->priv_insert_forward_non_templated(pos, num_new));
+         const index_iterator it_past_new(it_past_newly_constructed + num_new);
+         {
+            //Prepare rollback
+            insert_rollback rollback(*this, it_past_newly_constructed, it_past_new);
+            while(first != last){
+               const node_ptr p = this->priv_get_from_pool();
+               BOOST_ASSERT(!!p);
+               //Put it in the index so rollback can return it in pool if construct_in_place throws
+               *it_past_newly_constructed = p;
+               //Constructs and fixes up pointers This can throw
+               this->priv_build_node_from_it(p, it_past_newly_constructed, first);
+               ++first;
+               ++it_past_newly_constructed;
+            }
+            //rollback.~insert_rollback() called in case of exception
+         }
+         //Fix up pointers for past-new nodes (new nodes were fixed during construction) and
+         //nodes before insertion position in priv_insert_forward_non_templated(...)
+         index_traits_type::fix_up_pointers_from(this->index, it_past_newly_constructed);
       }
-      return this->begin() + d;
+      return this->begin() + pos;
    }
    #endif
 
@@ -1277,10 +1442,10 @@ class stable_vector
    {
       STABLE_VECTOR_CHECK_INVARIANT;
       difference_type d = position - this->cbegin();
-      impl_iterator   it = this->impl.begin() + d;
-      this->delete_node(*it);
-      it = this->impl.erase(it);
-      this->align_nodes(it, this->get_end_align());
+      index_iterator   it = this->index.begin() + d;
+      this->priv_delete_node(position.node_pointer());
+      it = this->index.erase(it);
+      index_traits_type::fix_up_pointers_from(this->index, it);
       return this->begin()+d;
    }
 
@@ -1295,11 +1460,12 @@ class stable_vector
       STABLE_VECTOR_CHECK_INVARIANT;
       difference_type d1 = first - this->cbegin(), d2 = last - this->cbegin();
       if(d1 != d2){
-         impl_iterator it1(this->impl.begin() + d1), it2(this->impl.begin() + d2);
-         for(impl_iterator it = it1; it != it2; ++it)
-            this->delete_node(*it);
-         impl_iterator e = this->impl.erase(it1, it2);
-         this->align_nodes(e, this->get_end_align());
+         index_iterator it1(this->index.begin() + d1), it2(it1 + (d2 - d1));
+         for(index_iterator it = it1; it != it2; ++it){
+            this->priv_delete_node(node_ptr_traits::static_cast_from(*it));
+         }
+         const index_iterator e = this->index.erase(it1, it2);
+         index_traits_type::fix_up_pointers_from(this->index, e);
       }
       return iterator(this->begin() + d1);
    }
@@ -1315,7 +1481,7 @@ class stable_vector
       container_detail::bool_ flag;
       container_detail::swap_alloc(this->priv_node_alloc(), x.priv_node_alloc(), flag);
       //vector's allocator is swapped here
-      this->impl.swap(x.impl);
+      this->index.swap(x.index);
       this->priv_swap_members(x);
    }
 
@@ -1340,19 +1506,18 @@ class stable_vector
          this->priv_clear_pool();
          //If empty completely destroy the index, let's recover default-constructed state
          if(this->empty()){
-            this->impl.clear();
-            this->impl.shrink_to_fit();
-            this->internal_data.end_node.up = node_ptr_ptr();
+            this->index.clear();
+            this->index.shrink_to_fit();
+            this->internal_data.end_node.up = node_base_ptr_ptr();
          }
          //Otherwise, try to shrink-to-fit the index and readjust pointers if necessary
          else{
-            const size_type size = this->size();
-            const void* old_ptr = &impl[0];
-            this->impl.shrink_to_fit();
-            bool realloced = &impl[0] != old_ptr;
+            const void* old_ptr = &index[0];
+            this->index.shrink_to_fit();
+            bool realloced = &index[0] != old_ptr;
             //Fix the pointers for the newly allocated buffer
             if(realloced){
-               this->align_nodes(this->impl.begin(), this->impl.begin()+size+1);
+               index_traits_type::fix_up_pointers_from(this->index, this->index.begin());
             }
          }
       }
@@ -1360,88 +1525,144 @@ class stable_vector
 
    /// @cond
 
+   private:
+
+   class insert_rollback
+   {
+      public:
+
+      insert_rollback(stable_vector &sv, index_iterator &it_past_constructed, const index_iterator &it_past_new)
+         : m_sv(sv), m_it_past_constructed(it_past_constructed), m_it_past_new(it_past_new)
+      {}
+
+      ~insert_rollback()
+      {
+         if(m_it_past_constructed != m_it_past_new){
+            m_sv.priv_put_in_pool(node_ptr_traits::static_cast_from(*m_it_past_constructed));
+            index_iterator e = m_sv.index.erase(m_it_past_constructed, m_it_past_new);
+            index_traits_type::fix_up_pointers_from(m_sv.index, e);
+         }
+      }
+
+      private:
+      stable_vector &m_sv;
+      index_iterator &m_it_past_constructed;
+      const index_iterator &m_it_past_new;
+   };
+
+   class push_back_rollback
+   {
+      public:
+      push_back_rollback(stable_vector &sv, const node_ptr &p)
+         : m_sv(sv), m_p(p)
+      {}
+
+      ~push_back_rollback()
+      {
+         if(m_p){
+            m_sv.priv_put_in_pool(m_p);
+         }
+      }
+
+      void release()
+      {  m_p = node_ptr();  }
+
+      private:
+      stable_vector &m_sv;
+      node_ptr m_p;
+   };
+
+   index_iterator priv_insert_forward_non_templated(size_type pos, size_type num_new)
+   {
+      index_traits_type::initialize_end_node(this->index, this->internal_data.end_node, num_new);
+
+      //Now try to fill the pool with new data
+      if(this->internal_data.pool_size < num_new){
+         this->priv_increase_pool(num_new - this->internal_data.pool_size);
+      }
+
+      //Now try to make room in the vector
+      const node_base_ptr_ptr old_buffer = this->index.data();
+      this->index.insert(this->index.begin() + pos, num_new, node_ptr());
+      bool new_buffer = this->index.data() != old_buffer;
+
+      //Fix the pointers for the newly allocated buffer
+      const index_iterator index_beg = this->index.begin();
+      if(new_buffer){
+         index_traits_type::fix_up_pointers(index_beg, index_beg + pos);
+      }
+      return index_beg + pos;
+   }
+
+   bool priv_capacity_bigger_than_size() const
+   {
+      return this->index.capacity() > this->index.size() &&
+             this->internal_data.pool_size > 0;
+   }
+
+   template 
+   void priv_push_back(BOOST_MOVE_CATCH_FWD(U) x)
+   {
+      if(this->priv_capacity_bigger_than_size()){
+         //Enough memory in the pool and in the index
+         const node_ptr p = this->priv_get_from_pool();
+         BOOST_ASSERT(!!p);
+         {
+            push_back_rollback rollback(*this, p);
+            //This might throw
+            this->priv_build_node_from_convertible(p, ::boost::forward(x));
+            rollback.release();
+         }
+         //This can't throw as there is room for a new elements in the index
+         index_iterator new_index = this->index.insert(this->index.end() - ExtraPointers, p);
+         index_traits_type::fix_up_pointers_from(this->index, new_index);
+      }
+      else{
+         this->insert(this->cend(), ::boost::forward(x));
+      }
+   }
+
    iterator priv_insert(const_iterator position, const value_type &t)
    {
       typedef constant_iterator cvalue_iterator;
       return this->insert(position, cvalue_iterator(t, 1), cvalue_iterator());
    }
 
-   void priv_push_back(const value_type &t)
-   {  this->insert(end(), t);  }
-
-   template
-   void priv_clear_pool(AllocatorVersion,
-      typename boost::container::container_detail::enable_if_c
-         
-            ::value>::type * = 0)
+   iterator priv_insert(const_iterator position, BOOST_RV_REF(T) x)
    {
-      if(!this->impl.empty() && this->impl.back()){
-         node_ptr &pool_first_ref = *(this->impl.end() - 2);
-         node_ptr &pool_last_ref  = this->impl.back();
-
-         multiallocation_chain holder;
-         holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, this->internal_data.pool_size);
-         while(!holder.empty()){
-            node_ptr n = holder.front();
-            holder.pop_front();
-            this->deallocate_one(n);
-         }
-         pool_first_ref = pool_last_ref = 0;
-         this->internal_data.pool_size = 0;
-      }
-   }
-
-   template
-   void priv_clear_pool(AllocatorVersion,
-      typename boost::container::container_detail::enable_if_c
-         
-            ::value>::type * = 0)
-   {
-      if(!this->impl.empty() && this->impl.back()){
-         node_ptr &pool_first_ref = *(this->impl.end() - 2);
-         node_ptr &pool_last_ref  = this->impl.back();
-         multiallocation_chain holder;
-         holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
-         this->priv_node_alloc().deallocate_individual(boost::move(holder));
-         pool_first_ref = pool_last_ref = 0;
-         this->internal_data.pool_size = 0;
-      }
+      typedef repeat_iterator  repeat_it;
+      typedef boost::move_iterator      repeat_move_it;
+      //Just call more general insert(pos, size, value) and return iterator
+      return this->insert(position, repeat_move_it(repeat_it(x, 1)), repeat_move_it(repeat_it()));
    }
 
    void priv_clear_pool()
    {
-      this->priv_clear_pool(alloc_version());
-   }
+      if(!this->index.empty() && this->index.back()){
+         node_base_ptr &pool_first_ref = *(this->index.end() - 2);
+         node_base_ptr &pool_last_ref  = this->index.back();
 
-   void priv_add_to_pool(size_type n)
-   {
-      this->priv_add_to_pool(n, alloc_version());
-   }
-
-   template
-   void priv_add_to_pool(size_type n, AllocatorVersion,
-      typename boost::container::container_detail::enable_if_c
-         
-            ::value>::type * = 0)
-   {
-      size_type remaining = n;
-      while(remaining--){
-         this->put_in_pool(this->allocate_one());
+         multiallocation_chain holder;
+         holder.incorporate_after( holder.before_begin()
+                                 , node_ptr_traits::static_cast_from(pool_first_ref)
+                                 , node_ptr_traits::static_cast_from(pool_last_ref)
+                                 , internal_data.pool_size);
+         this->deallocate_individual(holder);
+         pool_first_ref = pool_last_ref = 0;
+         this->internal_data.pool_size = 0;
       }
    }
 
-   template
-   void priv_add_to_pool(size_type n, AllocatorVersion,
-      typename boost::container::container_detail::enable_if_c
-         
-            ::value>::type * = 0)
+   void priv_increase_pool(size_type n)
    {
-      node_ptr &pool_first_ref = *(this->impl.end() - 2);
-      node_ptr &pool_last_ref  = this->impl.back();
+      node_base_ptr &pool_first_ref = *(this->index.end() - 2);
+      node_base_ptr &pool_last_ref  = this->index.back();
       multiallocation_chain holder;
-      holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
-      //BOOST_STATIC_ASSERT((::boost::has_move_emulation_enabled::value == true));
-      multiallocation_chain m (this->priv_node_alloc().allocate_individual(n));
+      holder.incorporate_after( holder.before_begin()
+                              , node_ptr_traits::static_cast_from(pool_first_ref)
+                              , node_ptr_traits::static_cast_from(pool_last_ref)
+                              , internal_data.pool_size);
+      multiallocation_chain m (this->allocate_individual(n));
       holder.splice_after(holder.before_begin(), m, m.before_begin(), m.last(), n);
       this->internal_data.pool_size += n;
       std::pair data(holder.extract_data());
@@ -1449,244 +1670,123 @@ class stable_vector
       pool_last_ref = data.second;
    }
 
-   void put_in_pool(node_ptr p)
+   void priv_put_in_pool(const node_ptr &p)
    {
-      node_ptr &pool_first_ref = *(this->impl.end()-2);
-      node_ptr &pool_last_ref  = this->impl.back();
+      node_base_ptr &pool_first_ref = *(this->index.end()-2);
+      node_base_ptr &pool_last_ref  = this->index.back();
       multiallocation_chain holder;
-      holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
+      holder.incorporate_after( holder.before_begin()
+                              , node_ptr_traits::static_cast_from(pool_first_ref)
+                              , node_ptr_traits::static_cast_from(pool_last_ref)
+                              , internal_data.pool_size);
       holder.push_front(p);
       ++this->internal_data.pool_size;
       std::pair ret(holder.extract_data());
       pool_first_ref = ret.first;
-      pool_last_ref = ret.second;
+      pool_last_ref  = ret.second;
    }
 
    node_ptr priv_get_from_pool()
    {
-      if(!this->impl.back()){
-         return node_ptr(0);
+      //Precondition: index is not empty
+      BOOST_ASSERT(!this->index.empty());
+      node_base_ptr &pool_first_ref = *(this->index.end() - 2);
+      node_base_ptr &pool_last_ref  = this->index.back();
+      multiallocation_chain holder;
+      holder.incorporate_after( holder.before_begin()
+                              , node_ptr_traits::static_cast_from(pool_first_ref)
+                              , node_ptr_traits::static_cast_from(pool_last_ref)
+                              , internal_data.pool_size);
+      node_ptr ret = holder.front();
+      holder.pop_front();
+      --this->internal_data.pool_size;
+      if(!internal_data.pool_size){
+         pool_first_ref = pool_last_ref = node_ptr();
       }
       else{
-         node_ptr &pool_first_ref = *(this->impl.end() - 2);
-         node_ptr &pool_last_ref  = this->impl.back();
-         multiallocation_chain holder;
-         holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
-         node_ptr ret = holder.front();
-         holder.pop_front();
-         --this->internal_data.pool_size;
-         if(!internal_data.pool_size){
-            pool_first_ref = pool_last_ref = node_ptr();
-         }
-         else{
-            std::pair data(holder.extract_data());
-            pool_first_ref = data.first;
-            pool_last_ref = data.second;
-         }
-         return ret;
+         std::pair data(holder.extract_data());
+         pool_first_ref = data.first;
+         pool_last_ref = data.second;
       }
+      return ret;
    }
 
-   void insert_iter_prolog(size_type n, difference_type d)
+   node_ptr priv_get_end_node() const
    {
-      initialize_end_node(n);
-      const void* old_ptr = &impl[0];
-      //size_type old_capacity = this->capacity();
-      //size_type old_size = this->size();
-      this->impl.insert(this->impl.begin()+d, n, 0);
-      bool realloced = &impl[0] != old_ptr;
-      //Fix the pointers for the newly allocated buffer
-      if(realloced){
-         align_nodes(this->impl.begin(), this->impl.begin()+d);
-      }
+      return node_ptr_traits::pointer_to
+         (static_cast(const_cast(this->internal_data.end_node)));
    }
 
-   impl_iterator get_end_align()
-   {
-      return this->impl.end() - (ExtraPointers - 1);
-   }
-
-   static node_ptr_ptr ptr_to_node_ptr(node_ptr &n)
-   {  return node_ptr_ptr_traits::pointer_to(n);   }
-
-   void initialize_end_node(const size_type impl_capacity = 0)
-   {
-      if(this->impl.empty()){
-         this->impl.reserve(impl_capacity + ExtraPointers);
-         this->impl.resize(ExtraPointers);
-         node_ptr &end_node_ref = impl[0];
-         end_node_ref = this->get_end_node();
-         this->internal_data.end_node.up = stable_vector::ptr_to_node_ptr(end_node_ref);
-      }
-   }
-
-   void readjust_end_node()
-   {
-      if(!this->impl.empty()){
-         node_ptr &end_node_ref = *(this->get_end_align()-1);
-         end_node_ref = this->get_end_node();
-         this->internal_data.end_node.up = node_ptr_ptr_traits::pointer_to(end_node_ref);
-      }
-      else{
-         this->internal_data.end_node.up = node_ptr_ptr();
-      }
-   }
-
-   node_ptr get_end_node() const
-   {
-      return node_ptr_traits::static_cast_from
-         (node_base_ptr_traits::pointer_to(const_cast(this->internal_data.end_node)));
-   }
-
-   template
-   node_ptr new_node(const node_ptr_ptr &up, Iter it)
-   {
-      node_ptr p = this->allocate_one();
-      try{
-         boost::container::construct_in_place(this->priv_node_alloc(), container_detail::addressof(p->value), it);
-         //This does not throw
-         ::new(static_cast(container_detail::to_raw_pointer(p))) node_base_type;
-         p->up = up;
-      }
-      catch(...){
-         this->deallocate_one(p);
-         throw;
-      }
-      return p;
-   }
-
-   void delete_node(const node_ptr &n)
+   void priv_delete_node(const node_ptr &n)
    {
       allocator_traits::
-         destroy(this->priv_node_alloc(), container_detail::to_raw_pointer(n));
+         destroy(this->priv_node_alloc(), container_detail::addressof(n->value));
       static_cast(container_detail::to_raw_pointer(n))->~node_base_type();
-      this->put_in_pool(n);
+      this->priv_put_in_pool(n);
    }
 
-   static void align_nodes(impl_iterator first, impl_iterator last)
+   template
+   void priv_build_node_from_it(const node_ptr &p, const index_iterator &up_index, const Iterator &it)
    {
-      while(first!=last){
-         (*first)->up = stable_vector::ptr_to_node_ptr(*first);
-         ++first;
-      }
+      //This can throw
+      boost::container::construct_in_place
+         ( this->priv_node_alloc()
+         , container_detail::addressof(p->value)
+         , it);
+      //This does not throw
+      ::new(static_cast(container_detail::to_raw_pointer(p)))
+         node_base_type(index_traits_type::ptr_to_node_base_ptr(*up_index));
    }
 
-   template 
-   void priv_insert_iter_fwd_alloc(const impl_iterator it, FwdIterator first, FwdIterator last, difference_type n, allocator_v1)
+   template
+   void priv_build_node_from_convertible(const node_ptr &p, BOOST_FWD_REF(ValueConvertible) value_convertible)
    {
-      size_type i=0;
-      try{
-         while(first!=last){
-            it[i] = this->new_node(stable_vector::ptr_to_node_ptr(it[i]), first);
-            ++first;
-            ++i;
-         }
-      }
-      catch(...){
-         impl_iterator e = this->impl.erase(it + i, it + n);
-         this->align_nodes(e, this->get_end_align());
-         throw;
-      }
-   }
-
-   template 
-   void priv_insert_iter_fwd_alloc(const impl_iterator it, FwdIterator first, FwdIterator last, difference_type n, allocator_v2)
-   {
-      multiallocation_chain mem(this->priv_node_alloc().allocate_individual(n));
-
-      size_type i = 0;
-      node_ptr p = 0;
-      try{
-         while(first != last){
-            p = mem.front();
-            mem.pop_front();
-            //This can throw
-            boost::container::construct_in_place(this->priv_node_alloc(), container_detail::addressof(p->value), first);
-            //This does not throw
-            ::new(static_cast(container_detail::to_raw_pointer(p))) node_base_type;
-            p->up = stable_vector::ptr_to_node_ptr(it[i]);
-            ++first;
-            it[i] = p;
-            ++i;
-         }
-      }
-      catch(...){
-         this->priv_node_alloc().deallocate_one(p);
-         this->priv_node_alloc().deallocate_many(boost::move(mem));
-         impl_iterator e = this->impl.erase(it+i, it+n);
-         this->align_nodes(e, this->get_end_align());
-         throw;
-      }
-   }
-
-   template 
-   void priv_insert_iter_fwd(const impl_iterator it, FwdIterator first, FwdIterator last, difference_type n)
-   {
-      size_type i = 0;
-      node_ptr p = 0;
-      try{
-         while(first != last){
-            p = this->priv_get_from_pool();
-            if(!p){
-               this->priv_insert_iter_fwd_alloc(it+i, first, last, n-i, alloc_version());
-               break;
-            }
-            //This can throw
-            boost::container::construct_in_place(this->priv_node_alloc(), container_detail::addressof(p->value), first);
-            //This does not throw
-            ::new(static_cast(container_detail::to_raw_pointer(p))) node_base_type;
-            p->up = stable_vector::ptr_to_node_ptr(it[i]);
-            ++first;
-            it[i]=p;
-            ++i;
-         }
-      }
-      catch(...){
-         put_in_pool(p);
-         impl_iterator e = this->impl.erase(it+i, it+n);
-         this->align_nodes(e, this->get_end_align());
-         throw;
-      }
+      //This can throw
+      boost::container::allocator_traits::construct
+         ( this->priv_node_alloc()
+         , container_detail::addressof(p->value)
+         , ::boost::forward(value_convertible));
+      //This does not throw
+      ::new(static_cast(container_detail::to_raw_pointer(p))) node_base_type;
    }
 
    void priv_swap_members(stable_vector &x)
    {
       container_detail::do_swap(this->internal_data.pool_size, x.internal_data.pool_size);
-      this->readjust_end_node();
-      x.readjust_end_node();
+      index_traits_type::readjust_end_node(this->index, this->internal_data.end_node);
+      index_traits_type::readjust_end_node(x.index, x.internal_data.end_node);
    }
 
    #if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING)
    bool priv_invariant()const
    {
-      impl_type & impl_ref =  const_cast(this->impl);
+      index_type & index_ref =  const_cast(this->index);
 
-      if(impl_ref.empty())
+      if(index.empty())
          return !this->capacity() && !this->size();
-      if(this->get_end_node() != *(impl_ref.end() - ExtraPointers)){
+      if(this->priv_get_end_node() != *(index.end() - ExtraPointers)){
          return false;
       }
-      for( impl_iterator it = impl_ref.begin()
-         , it_end = const_cast(*this).get_end_align()
-         ; it != it_end
-         ; ++it){
-         if((*it)->up != stable_vector::ptr_to_node_ptr(*it)){
-            return false;
-         }
+
+      if(!index_traits_type::invariants(index_ref)){
+         return false;
       }
 
       size_type n = this->capacity() - this->size();
-      node_ptr &pool_first_ref = *(impl_ref.end() - 2);
-      node_ptr &pool_last_ref  = impl_ref.back();
+      node_base_ptr &pool_first_ref = *(index_ref.end() - 2);
+      node_base_ptr &pool_last_ref  = index_ref.back();
       multiallocation_chain holder;
-      holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
-      multiallocation_chain::iterator beg(holder.begin()), end(holder.end());
+      holder.incorporate_after( holder.before_begin()
+                              , node_ptr_traits::static_cast_from(pool_first_ref)
+                              , node_ptr_traits::static_cast_from(pool_last_ref)
+                              , internal_data.pool_size);
+      typename multiallocation_chain::iterator beg(holder.begin()), end(holder.end());
       size_type num_pool = 0;
       while(beg != end){
          ++num_pool;
          ++beg;
       }
-      return n >= num_pool;
+      return n >= num_pool && num_pool == internal_data.pool_size;
    }
 
    class invariant_checker
@@ -1729,7 +1829,7 @@ class stable_vector
    node_allocator_type &priv_node_alloc()              { return internal_data;  }
    const node_allocator_type &priv_node_alloc() const  { return internal_data;  }
 
-   impl_type                           impl;
+   index_type                           index;
    /// @endcond
 };
 
@@ -1788,24 +1888,3 @@ void swap(stable_vector& x,stable_vector& y)
 #include 
 
 #endif   //BOOST_CONTAINER_STABLE_VECTOR_HPP
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp
index 1180d96..fd00705 100644
--- a/include/boost/container/vector.hpp
+++ b/include/boost/container/vector.hpp
@@ -1521,7 +1521,7 @@ class vector : private container_detail::vector_alloc_holder
                               container_detail::is_same::value >::type * = 0)
    {
       if(this->members_.m_capacity){
-         if(!size()){
+         if(!this->size()){
             this->prot_deallocate();
          }
          else{
diff --git a/test/vector_test.hpp b/test/vector_test.hpp
index f868686..5c262b0 100644
--- a/test/vector_test.hpp
+++ b/test/vector_test.hpp
@@ -152,43 +152,47 @@ int vector_test()
             if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
          }
          {
+            boostvector->resize(100);
+            stdvector->resize(100);
+            if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
+
             IntType aux_vect[50];
             for(int i = 0; i < 50; ++i){
-               IntType new_int(-1);
+               IntType new_int(-2);
                aux_vect[i] = boost::move(new_int);
             }
             int aux_vect2[50];
             for(int i = 0; i < 50; ++i){
-               aux_vect2[i] = -1;
+               aux_vect2[i] = -2;
             }
+            typename MyBoostVector::size_type old_size = boostvector->size();
             typename MyBoostVector::iterator insert_it =
-               boostvector->insert(boostvector->begin()
+               boostvector->insert(boostvector->begin() + old_size
                               ,boost::make_move_iterator(&aux_vect[0])
                               ,boost::make_move_iterator(aux_vect + 50));
-            if(boostvector->begin() != insert_it) return 1;
-            stdvector->insert(stdvector->begin(), aux_vect2, aux_vect2 + 50);
+            if(boostvector->begin() + old_size != insert_it) return 1;
+            stdvector->insert(stdvector->begin() + old_size, aux_vect2, aux_vect2 + 50);
             if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
 
             for(int i = 0; i < 50; ++i){
-               IntType new_int(-1);
+               IntType new_int(-3);
                aux_vect[i] = boost::move(new_int);
             }
 
             for(int i = 0; i < 50; ++i){
-               aux_vect2[i] = -1;
+               aux_vect2[i] = -3;
             }
+            old_size = boostvector->size();
             //Now try with input iterators instead
-            insert_it = boostvector->insert(boostvector->begin()
-//                              ,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0]))
-//                              ,boost::make_move_iterator(make_input_from_forward_iterator(aux_vect + 50))
-                              ,boost::make_move_iterator(&aux_vect[0])
-                              ,boost::make_move_iterator(aux_vect + 50)
+            insert_it = boostvector->insert(boostvector->begin() + old_size
+                              ,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0]))
+                              ,boost::make_move_iterator(make_input_from_forward_iterator(aux_vect + 50))
                            );
-            if(boostvector->begin() != insert_it) return 1;
-            stdvector->insert(stdvector->begin(), aux_vect2, aux_vect2 + 50);
+            if(boostvector->begin() + old_size != insert_it) return 1;
+            stdvector->insert(stdvector->begin() + old_size, aux_vect2, aux_vect2 + 50);
             if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
          }
-/*
+/*       //deque has no reserve
          boostvector->reserve(boostvector->size()*2);
          stdvector->reserve(stdvector->size()*2);
          if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
@@ -201,13 +205,27 @@ int vector_test()
          MyStdVector(*stdvector).swap(*stdvector);
          if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
 
+         {  //push_back with not enough capacity
          IntType push_back_this(1);
          boostvector->push_back(boost::move(push_back_this));
          stdvector->push_back(int(1));
          boostvector->push_back(IntType(1));
          stdvector->push_back(int(1));
-
          if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
+         }
+         {  //push_back with enough capacity
+         boostvector->pop_back();
+         boostvector->pop_back();
+         stdvector->pop_back();
+         stdvector->pop_back();
+
+         IntType push_back_this(1);
+         boostvector->push_back(boost::move(push_back_this));
+         stdvector->push_back(int(1));
+         boostvector->push_back(IntType(1));
+         stdvector->push_back(int(1));
+         if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
+         }
 
          if(!vector_copyable_only(boostvector, stdvector
                         ,container_detail::bool_::value>())){
@@ -245,7 +263,7 @@ int vector_test()
             stdvector->assign(l.begin(), l.end());
             if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
          }
-/*
+/*       deque has no reserve or capacity
          std::size_t cap = boostvector->capacity();
          boostvector->reserve(cap*2);
          stdvector->reserve(cap*2);

From 1582b2086dc255ed2b65152a873654fa71998023 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Thu, 13 Sep 2012 18:54:58 +0000
Subject: [PATCH 50/93] Corrected strict aliasing error in
 multiallocation_chain

[SVN r80514]
---
 .../detail/adaptive_node_pool_impl.hpp        |  3 +-
 .../detail/multiallocation_chain.hpp          | 53 ++++++++++++-------
 .../container/detail/node_alloc_holder.hpp    |  3 +-
 include/boost/container/stable_vector.hpp     |  7 +--
 include/boost/container/vector.hpp            | 21 ++++----
 5 files changed, 50 insertions(+), 37 deletions(-)

diff --git a/include/boost/container/detail/adaptive_node_pool_impl.hpp b/include/boost/container/detail/adaptive_node_pool_impl.hpp
index afba6b5..39b9942 100644
--- a/include/boost/container/detail/adaptive_node_pool_impl.hpp
+++ b/include/boost/container/detail/adaptive_node_pool_impl.hpp
@@ -348,8 +348,7 @@ class private_adaptive_node_pool_impl
    {
       block_iterator block_it(m_block_multiset.end());
       while(n--){
-         void *pElem = container_detail::to_raw_pointer(chain.front());
-         chain.pop_front();
+         void *pElem = container_detail::to_raw_pointer(chain.pop_front());
          priv_invariants();
          block_info_t *block_info = this->priv_block_from_node(pElem);
          BOOST_ASSERT(block_info->free_nodes.size() < m_real_num_node);
diff --git a/include/boost/container/detail/multiallocation_chain.hpp b/include/boost/container/detail/multiallocation_chain.hpp
index 155e9bc..98d0924 100644
--- a/include/boost/container/detail/multiallocation_chain.hpp
+++ b/include/boost/container/detail/multiallocation_chain.hpp
@@ -45,14 +45,30 @@ class basic_multiallocation_chain
                     > slist_impl_t;
    slist_impl_t slist_impl_;
 
-   static node & to_node(VoidPointer p)
-   {  return *static_cast(static_cast(container_detail::to_raw_pointer(p))); }
+   typedef typename boost::intrusive::pointer_traits
+      ::template rebind_pointer::type    node_ptr;
+   typedef typename boost::intrusive::
+      pointer_traits                              node_ptr_traits;
+
+   static node & build_node(const VoidPointer &p)
+   {
+      return *::new (static_cast(static_cast(container_detail::to_raw_pointer(p)))) node;
+   }
+
+   static VoidPointer destroy_node(node &n)
+   {
+      VoidPointer retptr = node_ptr_traits::pointer_to(n);
+      n.~node();
+      return retptr;
+   }
+
+   static node_ptr to_node_ptr(VoidPointer p)
+   {  return node_ptr_traits::static_cast_from(p);   }
 
    BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_multiallocation_chain)
 
    public:
 
-
    typedef VoidPointer  void_pointer;
    typedef typename slist_impl_t::iterator iterator;
    typedef typename slist_impl_t::size_type size_type;
@@ -94,19 +110,21 @@ class basic_multiallocation_chain
    {  slist_impl_.clear(); }
 
    iterator insert_after(iterator it, void_pointer m)
-   {  return slist_impl_.insert_after(it, to_node(m));   }
+   {  return slist_impl_.insert_after(it, build_node(m));   }
 
    void push_front(void_pointer m)
-   {  return slist_impl_.push_front(to_node(m));   }
+   {  return slist_impl_.push_front(build_node(m));  }
 
    void push_back(void_pointer m)
-   {  return slist_impl_.push_back(to_node(m));   }
+   {  return slist_impl_.push_back(build_node(m));   }
 
-   void pop_front()
-   {  return slist_impl_.pop_front();   }
-
-   void *front()
-   {  return &*slist_impl_.begin();   }
+   void_pointer pop_front()
+   {
+      node & n = slist_impl_.front();
+      void_pointer ret = destroy_node(n);
+      slist_impl_.pop_front();
+      return ret;
+   }
 
    void splice_after(iterator after_this, basic_multiallocation_chain &x, iterator before_begin, iterator before_end)
    {  slist_impl_.splice_after(after_this, x.slist_impl_, before_begin, before_end);   }
@@ -118,10 +136,12 @@ class basic_multiallocation_chain
    {  slist_impl_.splice_after(after_this, x.slist_impl_);   }
 
    void incorporate_after(iterator after_this, void_pointer begin , iterator before_end)
-   {  slist_impl_.incorporate_after(after_this, &to_node(begin), &to_node(before_end));   }
+   {
+      slist_impl_.incorporate_after(after_this, to_node_ptr(begin), to_node_ptr(before_end));
+   }
 
    void incorporate_after(iterator after_this, void_pointer begin, void_pointer before_end, size_type n)
-   {  slist_impl_.incorporate_after(after_this, &to_node(begin), &to_node(before_end), n);   }
+   {  slist_impl_.incorporate_after(after_this, to_node_ptr(begin), to_node_ptr(before_end), n);   }
 
    void swap(basic_multiallocation_chain &x)
    {  slist_impl_.swap(x.slist_impl_);   }
@@ -203,11 +223,8 @@ class transform_multiallocation_chain
    void incorporate_after(iterator after_this, pointer begin, pointer before_end, size_type n)
    {  holder_.incorporate_after(after_this.base(), begin, before_end, n);  }
 
-   void pop_front()
-   {  holder_.pop_front();  }
-
-   pointer front()
-   {  return cast(holder_.front());   }
+   pointer pop_front()
+   {  return cast(holder_.pop_front());  }
 
    bool empty() const
    {  return holder_.empty(); }
diff --git a/include/boost/container/detail/node_alloc_holder.hpp b/include/boost/container/detail/node_alloc_holder.hpp
index 8b0f8ba..68048bc 100644
--- a/include/boost/container/detail/node_alloc_holder.hpp
+++ b/include/boost/container/detail/node_alloc_holder.hpp
@@ -247,8 +247,7 @@ struct node_alloc_holder
          Node *p = 0;
          BOOST_TRY{
                for(difference_type i = 0; i < n; ++i, ++beg, --constructed){
-               p = container_detail::to_raw_pointer(mem.front());
-               mem.pop_front();
+               p = container_detail::to_raw_pointer(mem.pop_front());
                //This can throw
                constructed = 0;
                boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->m_data), beg);
diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp
index be0416c..f6c55c9 100644
--- a/include/boost/container/stable_vector.hpp
+++ b/include/boost/container/stable_vector.hpp
@@ -589,9 +589,7 @@ class stable_vector
             ::value>::type * = 0)
    {
       while(!holder.empty()){
-         const node_ptr n = holder.front();
-         holder.pop_front();
-         this->deallocate_one(n);
+         this->deallocate_one(holder.pop_front());
       }
    }
 
@@ -1697,8 +1695,7 @@ class stable_vector
                               , node_ptr_traits::static_cast_from(pool_first_ref)
                               , node_ptr_traits::static_cast_from(pool_last_ref)
                               , internal_data.pool_size);
-      node_ptr ret = holder.front();
-      holder.pop_front();
+      node_ptr ret = holder.pop_front();
       --this->internal_data.pool_size;
       if(!internal_data.pool_size){
          pool_first_ref = pool_last_ref = node_ptr();
diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp
index fd00705..87a09bc 100644
--- a/include/boost/container/vector.hpp
+++ b/include/boost/container/vector.hpp
@@ -1723,7 +1723,7 @@ class vector : private container_detail::vector_alloc_holder
    //New situation in Case A (hole_size == 0):
    // range is moved through move assignments
    //
-   //       first_pos   last_pos         old_limit
+   //       first_pos   last_pos         limit_pos
    //             |       |                  | 
    // ____________V_______V__________________V_____________
    //|   prefix'  |       |  | range |suffix'|raw_mem      ~
@@ -1735,7 +1735,7 @@ class vector : private container_detail::vector_alloc_holder
    //New situation in Case B (hole_size > 0):
    // range is moved through uninitialized moves
    //
-   //       first_pos   last_pos         old_limit
+   //       first_pos   last_pos         limit_pos
    //             |       |                  | 
    // ____________V_______V__________________V________________
    //|    prefix' |       |                  | [hole] | range |
@@ -1746,31 +1746,33 @@ class vector : private container_detail::vector_alloc_holder
    //New situation in Case C (hole_size == 0):
    // range is moved through move assignments and uninitialized moves
    //
-   //       first_pos   last_pos         old_limit
+   //       first_pos   last_pos         limit_pos
    //             |       |                  | 
    // ____________V_______V__________________V___
    //|   prefix'  |       |              | range |
    //|___________________________________|___^___|
    //                 |                      |
    //                 |_>_>_>_>_>_>_>_>_>_>_>^
-   size_type priv_insert_ordered_at_shift_range(size_type first_pos, size_type last_pos, size_type limit_pos, size_type shift_count)
+   size_type priv_insert_ordered_at_shift_range
+      (size_type first_pos, size_type last_pos, size_type limit_pos, size_type shift_count)
    {
       BOOST_ASSERT(first_pos <= last_pos);
       BOOST_ASSERT(last_pos <= limit_pos);
       //
       T* const begin_ptr = container_detail::to_raw_pointer(this->members_.m_start);
+      T* const first_ptr = begin_ptr + first_pos;
+      T* const last_ptr  = begin_ptr + last_pos;
 
       size_type hole_size = 0;
       //Case A:
       if((last_pos + shift_count) <= limit_pos){
          //All move assigned
-         boost::move_backward(begin_ptr + first_pos, begin_ptr + last_pos, begin_ptr + last_pos + shift_count);
+         boost::move_backward(first_ptr, last_ptr, last_ptr + shift_count);
       }
       //Case B:
       else if((first_pos + shift_count) >= limit_pos){
          //All uninitialized_moved
-         ::boost::container::uninitialized_move_alloc
-            (this->alloc(), begin_ptr + first_pos, begin_ptr + last_pos, begin_ptr + first_pos + shift_count);
+         ::boost::container::uninitialized_move_alloc(this->alloc(), first_ptr, last_ptr, first_ptr + shift_count);
          hole_size = last_pos + shift_count - limit_pos;
       }
       //Case C:
@@ -1778,10 +1780,9 @@ class vector : private container_detail::vector_alloc_holder
          //Some uninitialized_moved
          T* const limit_ptr    = begin_ptr + limit_pos;
          T* const boundary_ptr = limit_ptr - shift_count;
-         ::boost::container::uninitialized_move_alloc
-            (this->alloc(), boundary_ptr, begin_ptr + last_pos, limit_ptr);
+         ::boost::container::uninitialized_move_alloc(this->alloc(), boundary_ptr, last_ptr, limit_ptr);
          //The rest is move assigned
-         boost::move_backward(begin_ptr + first_pos, boundary_ptr, limit_ptr);
+         boost::move_backward(first_ptr, boundary_ptr, limit_ptr);
       }
       return hole_size;
    }

From de1caeb5d0a3f4e100d747d353e94a6cb32cd1f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Thu, 13 Sep 2012 22:07:37 +0000
Subject: [PATCH 51/93] Fixed test error (allocator might not have
 size_type) + modified changelog in documentation

[SVN r80522]
---
 doc/container.qbk                    | 2 ++
 test/scoped_allocator_usage_test.cpp | 6 ++----
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/container.qbk b/doc/container.qbk
index 0c760e0..60ef8c2 100644
--- a/doc/container.qbk
+++ b/doc/container.qbk
@@ -616,6 +616,8 @@ use [*Boost.Container]? There are several reasons for that:
 
 [section:release_notes_boost_1_52_00 Boost 1.52 Release]
 
+*  Improved `stable_vector`'s template code bloat and type safety.
+
 *  Fixed bugs
   [@https://svn.boost.org/trac/boost/ticket/6615 #6615],
   [@https://svn.boost.org/trac/boost/ticket/7139 #7139],
diff --git a/test/scoped_allocator_usage_test.cpp b/test/scoped_allocator_usage_test.cpp
index bb841a2..c0a4827 100644
--- a/test/scoped_allocator_usage_test.cpp
+++ b/test/scoped_allocator_usage_test.cpp
@@ -20,8 +20,6 @@ class SimpleAllocator
 {
 public:
 	typedef Ty value_type;
-	typedef typename std::allocator::pointer pointer;
-	typedef typename std::allocator::size_type size_type;
 
 	SimpleAllocator(int value)
 		: m_state(value)
@@ -32,12 +30,12 @@ public:
 		: m_state(other.m_state)
 	{}
 
-	pointer allocate(size_type n)
+	Ty* allocate(std::size_t n)
 	{
 		return m_allocator.allocate(n);
 	}
 
-	void deallocate(pointer p, size_type n)
+	void deallocate(Ty* p, std::size_t n)
 	{
 		m_allocator.deallocate(p, n);
 	}

From ac05be59476e9af6ef2b48d1a45761d5e55de5dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Mon, 24 Sep 2012 10:27:02 +0000
Subject: [PATCH 52/93] Reordered sequence container types and functions to
 improve Doxygen documentation

[SVN r80686]
---
 doc/Jamfile.v2                                |    2 +
 doc/container.qbk                             |    4 +-
 include/boost/container/allocator_traits.hpp  |   24 +-
 include/boost/container/detail/iterators.hpp  |   17 +-
 include/boost/container/detail/workaround.hpp |    4 +
 include/boost/container/list.hpp              |  958 ++++++++------
 include/boost/container/slist.hpp             | 1173 ++++++++++-------
 include/boost/container/stable_vector.hpp     |  453 ++++---
 include/boost/container/vector.hpp            |  883 ++++++-------
 proj/to-do.txt                                |  109 +-
 10 files changed, 2001 insertions(+), 1626 deletions(-)

diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2
index a9095bd..58865b4 100644
--- a/doc/Jamfile.v2
+++ b/doc/Jamfile.v2
@@ -27,6 +27,8 @@ doxygen autodoc
         MACRO_EXPANSION=YES
         "PREDEFINED=\"insert_const_ref_type= const T&\" \\
                                    \"BOOST_CONTAINER_DOXYGEN_INVOKED\" \\
+                                   \"BOOST_CONTAINER_IMPDEF(T)=implementation_defined\" \\
+                                   \"BOOST_CONTAINER_SEEDOC(T)=see_documentation\" \\
                                    \"BOOST_RV_REF(T)=T &&\" \\
                                    \"BOOST_RV_REF_BEG=\" \\
                                    \"BOOST_RV_REF_END=&&\" \\
diff --git a/doc/container.qbk b/doc/container.qbk
index 60ef8c2..8b71c43 100644
--- a/doc/container.qbk
+++ b/doc/container.qbk
@@ -617,13 +617,15 @@ use [*Boost.Container]? There are several reasons for that:
 [section:release_notes_boost_1_52_00 Boost 1.52 Release]
 
 *  Improved `stable_vector`'s template code bloat and type safety.
-
+*  Changed typedefs and reordered functions of sequence containers to improve doxygen documentation.
 *  Fixed bugs
   [@https://svn.boost.org/trac/boost/ticket/6615 #6615],
   [@https://svn.boost.org/trac/boost/ticket/7139 #7139],
   [@https://svn.boost.org/trac/boost/ticket/7215 #7215],
   [@https://svn.boost.org/trac/boost/ticket/7232 #7232],
   [@https://svn.boost.org/trac/boost/ticket/7269 #7269].
+*  Implemented LWG Issue #149 (range insertion now returns an iterator) & cleaned up insertion code in most containers
+*  Corrected aliasing errors.
 
 [endsect]
 
diff --git a/include/boost/container/allocator_traits.hpp b/include/boost/container/allocator_traits.hpp
index 8e537cc..11d948b 100644
--- a/include/boost/container/allocator_traits.hpp
+++ b/include/boost/container/allocator_traits.hpp
@@ -70,41 +70,41 @@ struct allocator_traits
       typedef unspecified pointer;
       //! Alloc::const_pointer if such a type exists ; otherwise, pointer_traits::rebind::rebind.
       //!
-      typedef unspecified void_pointer;
+      typedef see_documentation void_pointer;
       //! Alloc::const_void_pointer if such a type exists ; otherwis e, pointer_traits::rebind::difference_type.
       //!
-      typedef unspecified difference_type;
+      typedef see_documentation difference_type;
       //! Alloc::size_type if such a type exists ; otherwise, make_unsigned::type
       //!
-      typedef unspecified size_type;
+      typedef see_documentation size_type;
       //! Alloc::propagate_on_container_copy_assignment if such a type exists, otherwise an integral_constant
       //! type with internal constant static member `value` == false.
-      typedef unspecified propagate_on_container_copy_assignment;
+      typedef see_documentation propagate_on_container_copy_assignment;
       //! Alloc::propagate_on_container_move_assignment if such a type exists, otherwise an integral_constant
       //! type with internal constant static member `value` == false.
-      typedef unspecified propagate_on_container_move_assignment;
+      typedef see_documentation propagate_on_container_move_assignment;
       //! Alloc::propagate_on_container_swap if such a type exists, otherwise an integral_constant
       //! type with internal constant static member `value` == false.
-      typedef unspecified propagate_on_container_swap;
+      typedef see_documentation propagate_on_container_swap;
       //! Defines an allocator: Alloc::rebind::other if such a type exists; otherwise, Alloc
       //! if Alloc is a class template instantiation of the form Alloc, where Args is zero or
       //! more type arguments ; otherwise, the instantiation of rebind_alloc is ill-formed.
       //!
       //! In C++03 compilers `rebind_alloc` is a struct derived from an allocator
       //! deduced by previously detailed rules.
-      template  using rebind_alloc = unspecified;
+      template  using rebind_alloc = see_documentation;
 
       //! In C++03 compilers `rebind_traits` is a struct derived from
       //! `allocator_traits`, where `OtherAlloc` is
@@ -115,7 +115,7 @@ struct allocator_traits
       //! `type` is an allocator related to Alloc deduced deduced by rules explained in `rebind_alloc`.
       template 
       struct portable_rebind_alloc
-      {  typedef unspecified_type type;  };
+      {  typedef see_documentation type;  };
    #else
       //pointer
       typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc,
diff --git a/include/boost/container/detail/iterators.hpp b/include/boost/container/detail/iterators.hpp
index 78a0dda..3e77931 100644
--- a/include/boost/container/detail/iterators.hpp
+++ b/include/boost/container/detail/iterators.hpp
@@ -585,6 +585,22 @@ struct is_bidirectional_iterator
    static const bool value = false;
 };
 
+template
+struct iiterator_types
+{
+   typedef typename std::iterator_traits::pointer         it_pointer;
+   typedef typename std::iterator_traits::difference_type difference_type;
+   typedef typename ::boost::intrusive::pointer_traits::
+      template rebind_pointer::type                               pointer;
+   typedef typename ::boost::intrusive::pointer_traits::
+      template rebind_pointer::type                         const_pointer;
+   typedef typename ::boost::intrusive::
+      pointer_traits::reference                             reference;
+   typedef typename ::boost::intrusive::
+      pointer_traits::reference                       const_reference;
+};
+
+
 }  //namespace container_detail {
 
 }  //namespace container {
@@ -593,4 +609,3 @@ struct is_bidirectional_iterator
 #include 
 
 #endif   //#ifndef BOOST_CONTAINER_DETAIL_ITERATORS_HPP
-
diff --git a/include/boost/container/detail/workaround.hpp b/include/boost/container/detail/workaround.hpp
index c444074..7838a5d 100644
--- a/include/boost/container/detail/workaround.hpp
+++ b/include/boost/container/detail/workaround.hpp
@@ -31,6 +31,10 @@
    #define BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST
 #endif
 
+//Macros for documentation purposes. For code, expands to the argument
+#define BOOST_CONTAINER_IMPDEF(TYPE) TYPE
+#define BOOST_CONTAINER_SEEDOC(TYPE) TYPE
+
 #include 
 
 #endif   //#ifndef BOOST_CONTAINER_DETAIL_WORKAROUND_HPP
diff --git a/include/boost/container/list.hpp b/include/boost/container/list.hpp
index a991860..8f196d1 100644
--- a/include/boost/container/list.hpp
+++ b/include/boost/container/list.hpp
@@ -94,6 +94,111 @@ struct intrusive_list_type
    typedef container_type                       type ;
 };
 
+template
+class list_const_iterator
+   : public std::iterator< std::bidirectional_iterator_tag, T
+                         , typename iiterator_types::difference_type
+                         , typename iiterator_types::const_pointer
+                         , typename iiterator_types::const_reference>
+{
+   protected:
+
+   IIterator m_it;
+
+   public:
+   typedef typename iiterator_types::const_pointer     const_pointer;
+   typedef typename iiterator_types::const_reference   const_reference;
+
+   //Constructors
+   list_const_iterator()
+      : m_it()
+   {}
+
+   explicit list_const_iterator(const IIterator &it) 
+      : m_it(it)
+   {}
+
+   //Pointer like operators
+   const_reference operator*() const
+   { return this->m_it->m_data;  }
+
+   const_pointer   operator->() const
+   { return ::boost::intrusive::pointer_traits::to_pointer(this->m_it->m_data); }
+
+   //Increment / Decrement
+   list_const_iterator& operator++()      
+   { ++this->m_it;  return *this; }
+
+   list_const_iterator operator++(int)     
+   { IIterator tmp = this->m_it; ++*this; return list_const_iterator(tmp);  }
+
+   list_const_iterator& operator--()
+   { --this->m_it; return *this;   }
+
+   list_const_iterator operator--(int)
+   {  IIterator tmp = this->m_it; --*this; return list_const_iterator(tmp); }
+
+   //Comparison operators
+   friend bool operator== (const list_const_iterator& l, const list_const_iterator& r)
+   {  return l.m_it == r.m_it;  }
+
+   friend bool operator!= (const list_const_iterator& l, const list_const_iterator& r)
+   {  return l.m_it != r.m_it;  }
+
+   IIterator &get()
+   {  return this->m_it;   }
+
+   const IIterator &get() const
+   {  return this->m_it;   }
+};
+
+template
+class list_iterator
+   : public list_const_iterator
+{
+   private:
+   typedef list_const_iterator const_iterator;
+
+   public:
+   typedef typename iiterator_types::pointer           pointer;
+   typedef typename iiterator_types::reference         reference;
+
+   //Constructors
+   list_iterator()
+      : const_iterator()
+   {}
+
+   explicit list_iterator(const IIterator &it)
+      :  const_iterator(it)
+   {}
+
+   //Pointer like operators
+   reference operator*()  const
+   {  return  this->m_it->m_data;  }
+
+   pointer   operator->() const
+   { return ::boost::intrusive::pointer_traits::pointer_to(this->m_it->m_data); }
+
+   //Increment / Decrement
+   list_iterator& operator++() 
+   { ++this->m_it; return *this;  }
+
+   list_iterator operator++(int)
+   { IIterator tmp = this->m_it; ++*this; return list_iterator(tmp); }
+
+   list_iterator& operator--()
+   { --this->m_it; return *this;   }
+
+   list_iterator operator--(int)
+   {  IIterator tmp = this->m_it; --*this; return list_iterator(tmp); }
+
+   IIterator &get()
+   {  return this->m_it;   }
+
+   const IIterator &get() const
+   {  return this->m_it;   }
+};
+
 }  //namespace container_detail {
 /// @endcond
 
@@ -119,7 +224,6 @@ class list
    /// @cond
    typedef typename
       container_detail::intrusive_list_type::type Icont;
-   typedef list                                 ThisType;
    typedef container_detail::node_alloc_holder        AllocHolder;
    typedef typename AllocHolder::NodePtr              NodePtr;
    typedef typename AllocHolder::NodeAlloc            NodeAlloc;
@@ -159,141 +263,39 @@ class list
       bool operator()(const Node &a) const
       {  return static_cast(*this)(a.m_data);  }
    };
-   /// @endcond
 
-   public:
-   //! The type of object, T, stored in the list
-   typedef T                                                value_type;
-   //! Pointer to T
-   typedef typename allocator_traits_type::pointer          pointer;
-   //! Const pointer to T
-   typedef typename allocator_traits_type::const_pointer    const_pointer;
-   //! Reference to T
-   typedef typename allocator_traits_type::reference        reference;
-   //! Const reference to T
-   typedef typename allocator_traits_type::const_reference  const_reference;
-   //! An unsigned integral type
-   typedef typename allocator_traits_type::size_type        size_type;
-   //! A signed integral type
-   typedef typename allocator_traits_type::difference_type  difference_type;
-   //! The allocator type
-   typedef A                                                allocator_type;
-   //! Non-standard extension: the stored allocator type
-   typedef NodeAlloc                                        stored_allocator_type;
-
-   /// @cond
-   private:
    BOOST_COPYABLE_AND_MOVABLE(list)
-   typedef difference_type                         list_difference_type;
-   typedef pointer                                 list_pointer;
-   typedef const_pointer                           list_const_pointer;
-   typedef reference                               list_reference;
-   typedef const_reference                         list_const_reference;
+
+   typedef container_detail::list_iterator      iterator_impl;
+   typedef container_detail::list_const_iteratorconst_iterator_impl;
    /// @endcond
 
    public:
-   //! Const iterator used to iterate through a list.
-   class const_iterator
-      /// @cond
-      : public std::iterator
-   {
+   //////////////////////////////////////////////
+   //
+   //                    types
+   //
+   //////////////////////////////////////////////
 
-      protected:
-      typename Icont::iterator m_it;
-      explicit const_iterator(typename Icont::iterator it)  : m_it(it){}
-      void prot_incr() { ++m_it; }
-      void prot_decr() { --m_it; }
+   typedef T                                                                  value_type;
+   typedef typename ::boost::container::allocator_traits::pointer          pointer;
+   typedef typename ::boost::container::allocator_traits::const_pointer    const_pointer;
+   typedef typename ::boost::container::allocator_traits::reference        reference;
+   typedef typename ::boost::container::allocator_traits::const_reference  const_reference;
+   typedef typename ::boost::container::allocator_traits::size_type        size_type;
+   typedef typename ::boost::container::allocator_traits::difference_type  difference_type;
+   typedef A                                                                  allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(NodeAlloc)                                  stored_allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(iterator_impl)                              iterator;
+   typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl)                        const_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)            reverse_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)      const_reverse_iterator;
 
-      private:
-      typename Icont::iterator get()
-      {  return this->m_it;   }
-
-      public:
-      friend class list;
-      typedef list_difference_type        difference_type;
-
-      //Constructors
-      const_iterator()
-         :  m_it()
-      {}
-
-      //Pointer like operators
-      const_reference operator*()  const
-      { return  m_it->m_data;  }
-
-      const_pointer   operator->() const
-      { return  const_pointer(&m_it->m_data); }
-
-      //Increment / Decrement
-      const_iterator& operator++()      
-      { prot_incr();  return *this; }
-
-      const_iterator operator++(int)     
-      { typename Icont::iterator tmp = m_it; ++*this; return const_iterator(tmp);  }
-
-      const_iterator& operator--()
-      {   prot_decr(); return *this;   }
-
-      const_iterator operator--(int)
-      {  typename Icont::iterator tmp = m_it; --*this; return const_iterator(tmp); }
-
-      //Comparison operators
-      bool operator==   (const const_iterator& r)  const
-      {  return m_it == r.m_it;  }
-
-      bool operator!=   (const const_iterator& r)  const
-      {  return m_it != r.m_it;  }
-   }
-   /// @endcond
-   ;
-
-   //! Iterator used to iterate through a list
-   class iterator
-   /// @cond
-      : public const_iterator
-   {
-
-      private:
-      explicit iterator(typename Icont::iterator it)
-         :  const_iterator(it)
-      {}
-  
-      typename Icont::iterator get()
-      {  return this->m_it;   }
-
-      public:
-      friend class list;
-      typedef list_pointer       pointer;
-      typedef list_reference     reference;
-
-      //Constructors
-      iterator(){}
-
-      //Pointer like operators
-      reference operator*()  const {  return  this->m_it->m_data;  }
-      pointer   operator->() const {  return  pointer(&this->m_it->m_data);  }
-
-      //Increment / Decrement
-      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;  }
-
-      iterator operator--(int)
-         {  iterator tmp = *this; --*this; return tmp; }
-   };
-   /// @endcond
-
-   //! Iterator used to iterate backwards through a list.
-   typedef std::reverse_iterator        reverse_iterator;
-   //! Const iterator used to iterate backwards through a list.
-   typedef std::reverse_iterator  const_reverse_iterator;
+   //////////////////////////////////////////////
+   //
+   //          construct/copy/destroy
+   //
+   //////////////////////////////////////////////
 
    //! Effects: Default constructs a list.
    //!
@@ -404,6 +406,98 @@ class list
    ~list()
    {} //AllocHolder clears the list
 
+   //! Effects: Makes *this contain the same elements as x.
+   //!
+   //! Postcondition: this->size() == x.size(). *this contains a copy
+   //! of each of x's elements.
+   //!
+   //! Throws: If memory allocation throws or T's copy constructor throws.
+   //!
+   //! Complexity: Linear to the number of elements in x.
+   list& operator=(BOOST_COPY_ASSIGN_REF(list) x)
+   {
+      if (&x != this){
+         NodeAlloc &this_alloc     = this->node_alloc();
+         const NodeAlloc &x_alloc  = x.node_alloc();
+         container_detail::bool_ flag;
+         if(flag && this_alloc != x_alloc){
+            this->clear();
+         }
+         this->AllocHolder::copy_assign_alloc(x);
+         this->assign(x.begin(), x.end());
+      }
+      return *this;
+   }
+
+   //! Effects: Move assignment. All mx's values are transferred to *this.
+   //!
+   //! Postcondition: x.empty(). *this contains a the elements x had
+   //!   before the function.
+   //!
+   //! Throws: If allocator_type's copy constructor throws.
+   //!
+   //! Complexity: Constant.
+   list& operator=(BOOST_RV_REF(list) x)
+   {
+      if (&x != this){
+         NodeAlloc &this_alloc = this->node_alloc();
+         NodeAlloc &x_alloc    = x.node_alloc();
+         //If allocators are equal we can just swap pointers
+         if(this_alloc == x_alloc){
+            //Destroy and swap pointers
+            this->clear();
+            this->icont() = boost::move(x.icont());
+            //Move allocator if needed
+            this->AllocHolder::move_assign_alloc(x);
+         }
+         //If unequal allocators, then do a one by one move
+         else{
+            typedef typename std::iterator_traits::iterator_category ItCat;
+            this->assign( boost::make_move_iterator(x.begin())
+                        , boost::make_move_iterator(x.end()));
+         }
+      }
+      return *this;
+   }
+
+   //! Effects: Assigns the n copies of val to *this.
+   //!
+   //! Throws: If memory allocation throws or T's copy constructor throws.
+   //!
+   //! Complexity: Linear to n.
+   void assign(size_type n, const T& val)
+   {
+      typedef constant_iterator cvalue_iterator;
+      return this->assign(cvalue_iterator(val, n), cvalue_iterator());
+   }
+
+   //! Effects: Assigns the the range [first, last) to *this.
+   //!
+   //! Throws: If memory allocation throws or
+   //!   T's constructor from dereferencing InpIt throws.
+   //!
+   //! Complexity: Linear to n.
+   template 
+   void assign(InpIt first, InpIt last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+         >::type * = 0
+      #endif
+      )
+   {
+      iterator first1      = this->begin();
+      const iterator last1 = this->end();
+      for ( ; first1 != last1 && first != last; ++first1, ++first)
+         *first1 = *first;
+      if (first == last)
+         this->erase(first1, last1);
+      else{
+         this->insert(last1, first, last);
+      }
+   }
+
    //! Effects: Returns a copy of the internal allocator.
    //!
    //! Throws: If allocator's copy constructor throws.
@@ -412,19 +506,27 @@ class list
    allocator_type get_allocator() const
    {  return allocator_type(this->node_alloc()); }
 
+   //! Effects: Returns a copy of the internal allocator.
+   //!
+   //! Throws: If allocator's copy constructor throws.
+   //!
+   //! Complexity: Constant.
    const stored_allocator_type &get_stored_allocator() const
    {  return this->node_alloc(); }
 
+   //! Effects: Returns a copy of the internal allocator.
+   //!
+   //! Throws: If allocator's copy constructor throws.
+   //!
+   //! Complexity: Constant.
    stored_allocator_type &get_stored_allocator()
    {  return this->node_alloc(); }
 
-   //! Effects: Erases all the elements of the list.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Linear to the number of elements in the list.
-   void clear()
-   {  AllocHolder::clear(alloc_version());  }
+   //////////////////////////////////////////////
+   //
+   //                iterators
+   //
+   //////////////////////////////////////////////
 
    //! Effects: Returns an iterator to the first element contained in the list.
    //!
@@ -528,6 +630,12 @@ class list
    const_reverse_iterator crend() const
    {  return const_reverse_iterator(this->cbegin());   }
 
+   //////////////////////////////////////////////
+   //
+   //                capacity
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Returns true if the list contains no elements.
    //!
    //! Throws: Nothing.
@@ -552,61 +660,38 @@ class list
    size_type max_size() const
    {  return AllocHolder::max_size();  }
 
-   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   //! Effects: Inserts a copy of x at the beginning of the list.
+   //! Effects: Inserts or erases elements at the end such that
+   //!   the size becomes n. New elements are default constructed.
    //!
-   //! Throws: If memory allocation throws or
-   //!   T's copy constructor throws.
+   //! Throws: If memory allocation throws, or T's copy constructor throws.
    //!
-   //! Complexity: Amortized constant time.
-   void push_front(const T &x);
+   //! Complexity: Linear to the difference between size() and new_size.
+   void resize(size_type new_size)
+   {
+      if(!priv_try_shrink(new_size)){
+         typedef default_construct_iterator default_iterator;
+         this->insert(this->cend(), default_iterator(new_size - this->size()), default_iterator());
+      }
+   }
 
-   //! Effects: Constructs a new element in the beginning of the list
-   //!   and moves the resources of mx to this new element.
+   //! Effects: Inserts or erases elements at the end such that
+   //!   the size becomes n. New elements are copy constructed from x.
    //!
-   //! Throws: If memory allocation throws.
+   //! Throws: If memory allocation throws, or T's copy constructor throws.
    //!
-   //! Complexity: Amortized constant time.
-   void push_front(T &&x);
-   #else
-   BOOST_MOVE_CONVERSION_AWARE_CATCH(push_front, T, void, priv_push_front)
-   #endif
+   //! Complexity: Linear to the difference between size() and new_size.
+   void resize(size_type new_size, const T& x)
+   {
+      if(!priv_try_shrink(new_size)){
+         this->insert(this->cend(), new_size - this->size(), x);
+      }
+   }
 
-   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   //! Effects: Inserts a copy of x at the end of the list.
-   //!
-   //! Throws: If memory allocation throws or
-   //!   T's copy constructor throws.
-   //!
-   //! Complexity: Amortized constant time.
-   void push_back(const T &x);
-
-   //! Effects: Constructs a new element in the end of the list
-   //!   and moves the resources of mx to this new element.
-   //!
-   //! Throws: If memory allocation throws.
-   //!
-   //! Complexity: Amortized constant time.
-   void push_back(T &&x);
-   #else
-   BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
-   #endif
-
-   //! Effects: Removes the first element from the list.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Amortized constant time.
-   void pop_front()             
-   {  this->erase(this->cbegin());      }
-
-   //! Effects: Removes the last element from the list.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Amortized constant time.
-   void pop_back()              
-   {  const_iterator tmp = this->cend(); this->erase(--tmp);  }
+   //////////////////////////////////////////////
+   //
+   //               element access
+   //
+   //////////////////////////////////////////////
 
    //! Requires: !empty()
    //!
@@ -652,95 +737,146 @@ class list
    const_reference back()  const
    { return *(--this->end()); }
 
-   //! Effects: Inserts or erases elements at the end such that
-   //!   the size becomes n. New elements are copy constructed from x.
+   //////////////////////////////////////////////
+   //
+   //                modifiers
+   //
+   //////////////////////////////////////////////
+
+   #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+   //! Effects: Inserts an object of type T constructed with
+   //!   std::forward(args)... in the end of the list.
    //!
-   //! Throws: If memory allocation throws, or T's copy constructor throws.
+   //! Throws: If memory allocation throws or
+   //!   T's in-place constructor throws.
    //!
-   //! Complexity: Linear to the difference between size() and new_size.
-   void resize(size_type new_size, const T& x)
+   //! Complexity: Constant
+   template 
+   void emplace_back(Args&&... args)
+   {  this->emplace(this->cend(), boost::forward(args)...); }
+
+   //! Effects: Inserts an object of type T constructed with
+   //!   std::forward(args)... in the beginning of the list.
+   //!
+   //! Throws: If memory allocation throws or
+   //!   T's in-place constructor throws.
+   //!
+   //! Complexity: Constant
+   template 
+   void emplace_front(Args&&... args)
+   {  this->emplace(this->cbegin(), boost::forward(args)...);  }
+
+   //! Effects: Inserts an object of type T constructed with
+   //!   std::forward(args)... before p.
+   //!
+   //! Throws: If memory allocation throws or
+   //!   T's in-place constructor throws.
+   //!
+   //! Complexity: Constant
+   template 
+   iterator emplace(const_iterator p, Args&&... args)
    {
-      if(!priv_try_shrink(new_size)){
-         this->insert(this->cend(), new_size - this->size(), x);
-      }
+      NodePtr pnode(AllocHolder::create_node(boost::forward(args)...));
+      return iterator(this->icont().insert(p.get(), *pnode));
    }
 
-   //! Effects: Inserts or erases elements at the end such that
-   //!   the size becomes n. New elements are default constructed.
-   //!
-   //! Throws: If memory allocation throws, or T's copy constructor throws.
-   //!
-   //! Complexity: Linear to the difference between size() and new_size.
-   void resize(size_type new_size)
-   {
-      if(!priv_try_shrink(new_size)){
-         typedef default_construct_iterator default_iterator;
-         this->insert(this->cend(), default_iterator(new_size - this->size()), default_iterator());
-      }
-   }
+   #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
-   //! Effects: Swaps the contents of *this and x.
+   #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_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                        \
+   {                                                                                            \
+      this->emplace(this->cend()                                                                \
+                    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, >)       \
+   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(const_iterator p                                                            \
+                    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(p.get(), *pnode));                                   \
+   }                                                                                            \
    //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   void swap(ThisType& x)
-   {  AllocHolder::swap(x);   }
+   #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
+   #include BOOST_PP_LOCAL_ITERATE()
 
-   //! Effects: Makes *this contain the same elements as x.
-   //!
-   //! Postcondition: this->size() == x.size(). *this contains a copy
-   //! of each of x's elements.
-   //!
-   //! Throws: If memory allocation throws or T's copy constructor throws.
-   //!
-   //! Complexity: Linear to the number of elements in x.
-   ThisType& operator=(BOOST_COPY_ASSIGN_REF(ThisType) x)
-   {
-      if (&x != this){
-         NodeAlloc &this_alloc     = this->node_alloc();
-         const NodeAlloc &x_alloc  = x.node_alloc();
-         container_detail::bool_ flag;
-         if(flag && this_alloc != x_alloc){
-            this->clear();
-         }
-         this->AllocHolder::copy_assign_alloc(x);
-         this->assign(x.begin(), x.end());
-      }
-      return *this;
-   }
+   #endif   //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
-   //! Effects: Move assignment. All mx's values are transferred to *this.
+   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   //! Effects: Inserts a copy of x at the beginning of the list.
    //!
-   //! Postcondition: x.empty(). *this contains a the elements x had
-   //!   before the function.
+   //! Throws: If memory allocation throws or
+   //!   T's copy constructor throws.
    //!
-   //! Throws: If allocator_type's copy constructor throws.
+   //! Complexity: Amortized constant time.
+   void push_front(const T &x);
+
+   //! Effects: Constructs a new element in the beginning of the list
+   //!   and moves the resources of mx to this new element.
    //!
-   //! Complexity: Constant.
-   ThisType& operator=(BOOST_RV_REF(ThisType) x)
-   {
-      if (&x != this){
-         NodeAlloc &this_alloc = this->node_alloc();
-         NodeAlloc &x_alloc    = x.node_alloc();
-         //If allocators are equal we can just swap pointers
-         if(this_alloc == x_alloc){
-            //Destroy and swap pointers
-            this->clear();
-            this->icont() = boost::move(x.icont());
-            //Move allocator if needed
-            this->AllocHolder::move_assign_alloc(x);
-         }
-         //If unequal allocators, then do a one by one move
-         else{
-            typedef typename std::iterator_traits::iterator_category ItCat;
-            this->assign( boost::make_move_iterator(x.begin())
-                        , boost::make_move_iterator(x.end()));
-         }
-      }
-      return *this;
-   }
+   //! Throws: If memory allocation throws.
+   //!
+   //! Complexity: Amortized constant time.
+   void push_front(T &&x);
+   #else
+   BOOST_MOVE_CONVERSION_AWARE_CATCH(push_front, T, void, priv_push_front)
+   #endif
+
+   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   //! Effects: Inserts a copy of x at the end of the list.
+   //!
+   //! Throws: If memory allocation throws or
+   //!   T's copy constructor throws.
+   //!
+   //! Complexity: Amortized constant time.
+   void push_back(const T &x);
+
+   //! Effects: Constructs a new element in the end of the list
+   //!   and moves the resources of mx to this new element.
+   //!
+   //! Throws: If memory allocation throws.
+   //!
+   //! Complexity: Amortized constant time.
+   void push_back(T &&x);
+   #else
+   BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
+   #endif
+
+   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   //! Requires: position must be a valid iterator of *this.
+   //!
+   //! Effects: Insert a copy of x before position.
+   //!
+   //! Returns: an iterator to the inserted element.
+   //!
+   //! Throws: If memory allocation throws or x's copy constructor throws.
+   //!
+   //! Complexity: Amortized constant time.
+   iterator insert(const_iterator position, const T &x);
+
+   //! Requires: position must be a valid iterator of *this.
+   //!
+   //! Effects: Insert a new element before position with mx's resources.
+   //!
+   //! Returns: an iterator to the inserted element.
+   //!
+   //! Throws: If memory allocation throws.
+   //!
+   //! Complexity: Amortized constant time.
+   iterator insert(const_iterator position, T &&x);
+   #else
+   BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator)
+   #endif
 
    //! Requires: p must be a valid iterator of *this.
    //!
@@ -809,104 +945,21 @@ class list
    }
    #endif
 
-   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   //! Requires: position must be a valid iterator of *this.
+   //! Effects: Removes the first element from the list.
    //!
-   //! Effects: Insert a copy of x before position.
-   //!
-   //! Returns: an iterator to the inserted element.
-   //!
-   //! Throws: If memory allocation throws or x's copy constructor throws.
+   //! Throws: Nothing.
    //!
    //! Complexity: Amortized constant time.
-   iterator insert(const_iterator position, const T &x);
+   void pop_front()             
+   {  this->erase(this->cbegin());      }
 
-   //! Requires: position must be a valid iterator of *this.
+   //! Effects: Removes the last element from the list.
    //!
-   //! Effects: Insert a new element before position with mx's resources.
-   //!
-   //! Returns: an iterator to the inserted element.
-   //!
-   //! Throws: If memory allocation throws.
+   //! Throws: Nothing.
    //!
    //! Complexity: Amortized constant time.
-   iterator insert(const_iterator position, T &&x);
-   #else
-   BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator)
-   #endif
-
-   #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-   //! Effects: Inserts an object of type T constructed with
-   //!   std::forward(args)... in the end of the list.
-   //!
-   //! Throws: If memory allocation throws or
-   //!   T's in-place constructor throws.
-   //!
-   //! Complexity: Constant
-   template 
-   void emplace_back(Args&&... args)
-   {
-      this->emplace(this->cend(), boost::forward(args)...);
-   }
-
-   //! Effects: Inserts an object of type T constructed with
-   //!   std::forward(args)... in the beginning of the list.
-   //!
-   //! Throws: If memory allocation throws or
-   //!   T's in-place constructor throws.
-   //!
-   //! Complexity: Constant
-   template 
-   void emplace_front(Args&&... args)
-   {
-      this->emplace(this->cbegin(), boost::forward(args)...);
-   }
-
-   //! Effects: Inserts an object of type T constructed with
-   //!   std::forward(args)... before p.
-   //!
-   //! Throws: If memory allocation throws or
-   //!   T's in-place constructor throws.
-   //!
-   //! Complexity: Constant
-   template 
-   iterator emplace(const_iterator p, Args&&... args)
-   {
-      NodePtr pnode(AllocHolder::create_node(boost::forward(args)...));
-      return iterator(this->icont().insert(p.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_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                        \
-   {                                                                                            \
-      this->emplace(this->cend()                                                                \
-                    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, >)       \
-   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(const_iterator p                                                            \
-                    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(p.get(), *pnode));                                   \
-   }                                                                                            \
-   //!
-   #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
-   #include BOOST_PP_LOCAL_ITERATE()
-
-   #endif   //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
+   void pop_back()              
+   {  const_iterator tmp = this->cend(); this->erase(--tmp);  }
 
    //! Requires: p must be a valid iterator of *this.
    //!
@@ -928,41 +981,46 @@ class list
    iterator erase(const_iterator first, const_iterator last)
    {  return iterator(AllocHolder::erase_range(first.get(), last.get(), alloc_version())); }
 
-   //! Effects: Assigns the n copies of val to *this.
+   //! Effects: Swaps the contents of *this and x.
    //!
-   //! Throws: If memory allocation throws or T's copy constructor throws.
+   //! Throws: Nothing.
    //!
-   //! Complexity: Linear to n.
-   void assign(size_type n, const T& val)
-   {
-      typedef constant_iterator cvalue_iterator;
-      return this->assign(cvalue_iterator(val, n), cvalue_iterator());
-   }
+   //! Complexity: Constant.
+   void swap(list& x)
+   {  AllocHolder::swap(x);   }
 
-   //! Effects: Assigns the the range [first, last) to *this.
+   //! Effects: Erases all the elements of the list.
    //!
-   //! Throws: If memory allocation throws or
-   //!   T's constructor from dereferencing InpIt throws.
+   //! Throws: Nothing.
    //!
-   //! Complexity: Linear to n.
-   template 
-   void assign(InpIt first, InpIt last
-      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-      , typename container_detail::enable_if_c
-         < !container_detail::is_convertible::value
-         >::type * = 0
-      #endif
-      )
+   //! Complexity: Linear to the number of elements in the list.
+   void clear()
+   {  AllocHolder::clear(alloc_version());  }
+
+   //////////////////////////////////////////////
+   //
+   //              slist operations
+   //
+   //////////////////////////////////////////////
+
+   //! Requires: p must point to an element contained
+   //!   by the list. x != *this
+   //!
+   //! Effects: Transfers all the elements of list x to this list, before the
+   //!   the element pointed by p. No destructors or copy constructors are called.
+   //!
+   //! Throws: std::runtime_error if this' allocator and x's allocator
+   //!   are not equal.
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: 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, list& x) BOOST_CONTAINER_NOEXCEPT
    {
-      iterator first1      = this->begin();
-      const iterator last1 = this->end();
-      for ( ; first1 != last1 && first != last; ++first1, ++first)
-         *first1 = *first;
-      if (first == last)
-         this->erase(first1, last1);
-      else{
-         this->insert(last1, first, last);
-      }
+      BOOST_ASSERT(*this != x);
+      BOOST_ASSERT(this->node_alloc() == x.node_alloc());
+      this->icont().splice(p.get(), x.icont());
    }
 
    //! Requires: p must point to an element contained
@@ -978,10 +1036,28 @@ class list
    //!
    //! Note: 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
+   void splice(const_iterator p, BOOST_RV_REF(list) x) BOOST_CONTAINER_NOEXCEPT
+   {  this->splice(p, static_cast(x));  }
+
+   //! Requires: p must point to an element contained
+   //!   by this list. i must point to an element contained in list x.
+   //!
+   //! Effects: 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.
+   //!
+   //! Throws: std::runtime_error if this' allocator and x's allocator
+   //!   are not equal.
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: 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, list &x, const_iterator i) BOOST_CONTAINER_NOEXCEPT
    {
-      BOOST_ASSERT((NodeAlloc&)*this == (NodeAlloc&)x);
-      this->icont().splice(p.get(), x.icont());
+      BOOST_ASSERT(*this != x);
+      BOOST_ASSERT(this->node_alloc() == x.node_alloc());
+      this->icont().splice(p.get(), x.icont(), i.get());
    }
 
    //! Requires: p must point to an element contained
@@ -998,10 +1074,27 @@ class list
    //!
    //! Note: 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
+   void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator i) BOOST_CONTAINER_NOEXCEPT
+   {  this->splice(p, static_cast(x), i);  }
+
+   //! Requires: p must point to an element contained
+   //!   by this list. first and last must point to elements contained in list x.
+   //!
+   //! Effects: 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.
+   //!
+   //! Throws: std::runtime_error if this' allocator and x's allocator
+   //!   are not equal.
+   //!
+   //! Complexity: Linear to the number of elements transferred.
+   //!
+   //! Note: 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, list &x, const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
    {
-      BOOST_ASSERT((NodeAlloc&)*this == (NodeAlloc&)x);
-      this->icont().splice(p.get(), x.icont(), i.get());
+      BOOST_ASSERT(*this != x);
+      BOOST_ASSERT(this->node_alloc() == x.node_alloc());
+      this->icont().splice(p.get(), x.icont(), first.get(), last.get());
    }
 
    //! Requires: p must point to an element contained
@@ -1017,10 +1110,30 @@ class list
    //!
    //! Note: 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
+   void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
+   {  this->splice(p, static_cast(x), first, last);  }
+
+   //! Requires: 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)
+   //!
+   //! Effects: 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.
+   //!
+   //! Throws: std::runtime_error if this' allocator and x's allocator
+   //!   are not equal.
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: 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.
+   //!
+   //! Note: Non-standard extension
+   void splice(const_iterator p, list &x, const_iterator first, const_iterator last, size_type n) BOOST_CONTAINER_NOEXCEPT
    {
-      BOOST_ASSERT((NodeAlloc&)*this == (NodeAlloc&)x);
-      this->icont().splice(p.get(), x.icont(), first.get(), last.get());
+      BOOST_ASSERT(*this != x);
+      BOOST_ASSERT(this->node_alloc() == x.node_alloc());
+      this->icont().splice(p.get(), x.icont(), first.get(), last.get(), n);
    }
 
    //! Requires: p must point to an element contained
@@ -1037,21 +1150,10 @@ class list
    //!
    //! Note: 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
-   {
-      BOOST_ASSERT((NodeAlloc&)*this == (NodeAlloc&)x);
-      this->icont().splice(p.get(), x.icont(), first.get(), last.get(), n);
-   }
-
-   //! Effects: Reverses the order of elements in the list.
    //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: This function is linear time.
-   //!
-   //! Note: Iterators and references are not invalidated
-   void reverse()
-   {  this->icont().reverse(); }   
+   //! Note: Non-standard extension
+   void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator first, const_iterator last, size_type n) BOOST_CONTAINER_NOEXCEPT
+   {  this->splice(p, static_cast(x), first, last, n);  }
 
    //! Effects: Removes all the elements that compare equal to value.
    //!
@@ -1062,7 +1164,7 @@ class list
    //! Note: 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)
-   {  remove_if(equal_to_value(value));  }
+   {  this->remove_if(equal_to_value(value));  }
 
    //! Effects: Removes all the elements for which a specified
    //!   predicate is satisfied.
@@ -1119,9 +1221,23 @@ class list
    //!
    //! Complexity: This function is linear time: it performs at most
    //!   size() + x.size() - 1 comparisons.
-   void merge(list& x)
+   void merge(list &x)
    {  this->merge(x, value_less());  }
 
+   //! Requires: The lists x and *this must be distinct.
+   //!
+   //! Effects: This function removes all of x's elements and inserts them
+   //!   in order into *this according to std::less. 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.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: This function is linear time: it performs at most
+   //!   size() + x.size() - 1 comparisons.
+   void merge(BOOST_RV_REF(list) x)
+   {  this->merge(static_cast(x)); }
+
    //! Requires: 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.
@@ -1148,6 +1264,24 @@ class list
       }
    }
 
+   //! Requires: 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.
+   //!
+   //! Effects: 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.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: This function is linear time: it performs at most
+   //!   size() + x.size() - 1 comparisons.
+   //!
+   //! Note: Iterators and references to *this are not invalidated.
+   template 
+   void merge(BOOST_RV_REF(list) x, StrictWeakOrdering comp)
+   {  this->merge(static_cast(x), comp); }
+
    //! Effects: This function sorts the list *this according to std::less.
    //!   The sort is stable, that is, the relative order of equivalent elements is preserved.
    //!
@@ -1178,6 +1312,16 @@ class list
       this->icont().sort(ValueCompareToNodeCompare(comp));
    }
 
+   //! Effects: Reverses the order of elements in the list.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: This function is linear time.
+   //!
+   //! Note: Iterators and references are not invalidated
+   void reverse()
+   {  this->icont().reverse(); }   
+
    /// @cond
    private:
 
diff --git a/include/boost/container/slist.hpp b/include/boost/container/slist.hpp
index 553fb54..c5ca7fa 100644
--- a/include/boost/container/slist.hpp
+++ b/include/boost/container/slist.hpp
@@ -20,6 +20,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -53,6 +54,9 @@ namespace container {
 
 /// @cond
 
+template 
+class slist;
+
 namespace container_detail {
 
 template
@@ -96,6 +100,99 @@ struct intrusive_slist_type
    typedef container_type                       type ;
 };
 
+template
+class slist_const_iterator
+   : public std::iterator< std::forward_iterator_tag, T
+                         , typename iiterator_types::difference_type
+                         , typename iiterator_types::const_pointer
+                         , typename iiterator_types::const_reference>
+{
+   protected:
+
+   IIterator m_it;
+
+   public:
+   typedef typename iiterator_types::const_pointer     const_pointer;
+   typedef typename iiterator_types::const_reference   const_reference;
+
+   //Constructors
+   slist_const_iterator()
+      : m_it()
+   {}
+
+   explicit slist_const_iterator(const IIterator &it) 
+      : m_it(it)
+   {}
+
+   //Pointer like operators
+   const_reference operator*() const
+   { return this->m_it->m_data;  }
+
+   const_pointer   operator->() const
+   { return ::boost::intrusive::pointer_traits::pointer_to(this->m_it->m_data); }
+
+   //Increment / Decrement
+   slist_const_iterator& operator++()      
+   { ++this->m_it;  return *this; }
+
+   slist_const_iterator operator++(int)     
+   { IIterator tmp = this->m_it; ++*this; return slist_const_iterator(tmp);  }
+
+   //Comparison operators
+   friend bool operator== (const slist_const_iterator& l, const slist_const_iterator& r)
+   {  return l.m_it == r.m_it;  }
+
+   friend bool operator!= (const slist_const_iterator& l, const slist_const_iterator& r)
+   {  return l.m_it != r.m_it;  }
+
+   IIterator &get()
+   {  return this->m_it;   }
+
+   const IIterator &get() const
+   {  return this->m_it;   }
+};
+
+template
+class slist_iterator
+   : public slist_const_iterator
+{
+   private:
+   typedef slist_const_iterator const_iterator;
+
+   public:
+   typedef typename iiterator_types::pointer           pointer;
+   typedef typename iiterator_types::reference         reference;
+
+   //Constructors
+   slist_iterator()
+      : const_iterator()
+   {}
+
+   explicit slist_iterator(const IIterator &it)
+      :  const_iterator(it)
+   {}
+
+   //Pointer like operators
+   reference operator*()  const
+   {  return  this->m_it->m_data;  }
+
+   pointer   operator->() const
+   { return ::boost::intrusive::pointer_traits::to_pointer(this->m_it->m_data); }
+
+   //Increment / Decrement
+   slist_iterator& operator++() 
+   { ++this->m_it; return *this;  }
+
+   slist_iterator operator++(int)
+   { IIterator tmp = this->m_it; ++*this; return slist_iterator(tmp); }
+
+   IIterator &get()
+   {  return this->m_it;   }
+
+   const IIterator &get() const
+   {  return this->m_it;   }
+};
+
 }  //namespace container_detail {
 
 /// @endcond
@@ -142,13 +239,10 @@ class slist
       ::type>
 {
    /// @cond
-   typedef typename container_detail::
-      move_const_ref_type::type                    insert_const_ref_type;
    typedef typename
       container_detail::intrusive_slist_type::type           Icont;
    typedef container_detail::node_alloc_holder        AllocHolder;
    typedef typename AllocHolder::NodePtr              NodePtr;
-   typedef slist                                ThisType;
    typedef typename AllocHolder::NodeAlloc            NodeAlloc;
    typedef typename AllocHolder::ValAlloc             ValAlloc;
    typedef typename AllocHolder::Node                 Node;
@@ -186,126 +280,39 @@ class slist
       bool operator()(const Node &a) const
       {  return static_cast(*this)(a.m_data);  }
    };
-   /// @endcond
-   public:
-   //! The type of object, T, stored in the list
-   typedef T                                                value_type;
-   //! Pointer to T
-   typedef typename allocator_traits_type::pointer          pointer;
-   //! Const pointer to T
-   typedef typename allocator_traits_type::const_pointer    const_pointer;
-   //! Reference to T
-   typedef typename allocator_traits_type::reference        reference;
-   //! Const reference to T
-   typedef typename allocator_traits_type::const_reference  const_reference;
-   //! An unsigned integral type
-   typedef typename allocator_traits_type::size_type        size_type;
-   //! A signed integral type
-   typedef typename allocator_traits_type::difference_type  difference_type;
-   //! The allocator type
-   typedef A                                                allocator_type;
-   //! Non-standard extension: the stored allocator type
-   typedef NodeAlloc                                        stored_allocator_type;
 
-   /// @cond
-   private:
    BOOST_COPYABLE_AND_MOVABLE(slist)
-   typedef difference_type                         list_difference_type;
-   typedef pointer                                 list_pointer;
-   typedef const_pointer                           list_const_pointer;
-   typedef reference                               list_reference;
-   typedef const_reference                         list_const_reference;
+   typedef container_detail::slist_iterator      iterator_impl;
+   typedef container_detail::slist_const_iteratorconst_iterator_impl;
    /// @endcond
 
    public:
+   //////////////////////////////////////////////
+   //
+   //                    types
+   //
+   //////////////////////////////////////////////
 
-   //! Const iterator used to iterate through a list.
-   class const_iterator
-      /// @cond
-      : public std::iterator
-   {
-
-      protected:
-      typename Icont::iterator m_it;
-      explicit const_iterator(typename Icont::iterator it)  : m_it(it){}
-      void prot_incr(){ ++m_it; }
-
-      private:
-      typename Icont::iterator get()
-      {  return this->m_it;   }
-
-      public:
-      friend class slist;
-      typedef list_difference_type        difference_type;
-
-      //Constructors
-      const_iterator()
-         :  m_it()
-      {}
-
-      //Pointer like operators
-      const_reference operator*() const
-      { return m_it->m_data;  }
-
-      const_pointer   operator->() const
-      { return  const_pointer(&m_it->m_data); }
-
-      //Increment / Decrement
-      const_iterator& operator++()      
-      { prot_incr();  return *this; }
-
-      const_iterator operator++(int)     
-      { typename Icont::iterator tmp = m_it; ++*this; return const_iterator(tmp);  }
-
-      //Comparison operators
-      bool operator==   (const const_iterator& r)  const
-      {  return m_it == r.m_it;  }
-
-      bool operator!=   (const const_iterator& r)  const
-      {  return m_it != r.m_it;  }
-   }
-      /// @endcond
-   ;
-
-   //! Iterator used to iterate through a list
-   class iterator
-      /// @cond
-   : public const_iterator
-   {
-
-      private:
-      explicit iterator(typename Icont::iterator it)
-         :  const_iterator(it)
-      {}
-  
-      typename Icont::iterator get()
-      {  return this->m_it;   }
-
-      public:
-      friend class slist;
-      typedef list_pointer       pointer;
-      typedef list_reference     reference;
-
-      //Constructors
-      iterator(){}
-
-      //Pointer like operators
-      reference operator*()  const {  return  this->m_it->m_data;  }
-      pointer   operator->() const {  return  pointer(&this->m_it->m_data);  }
-
-      //Increment / Decrement
-      iterator& operator++() 
-         { this->prot_incr(); return *this;  }
-
-      iterator operator++(int)
-         { typename Icont::iterator tmp = this->m_it; ++*this; return iterator(tmp); }
-   }
-      /// @endcond
-   ;
+   typedef T                                                                  value_type;
+   typedef typename ::boost::container::allocator_traits::pointer          pointer;
+   typedef typename ::boost::container::allocator_traits::const_pointer    const_pointer;
+   typedef typename ::boost::container::allocator_traits::reference        reference;
+   typedef typename ::boost::container::allocator_traits::const_reference  const_reference;
+   typedef typename ::boost::container::allocator_traits::size_type        size_type;
+   typedef typename ::boost::container::allocator_traits::difference_type  difference_type;
+   typedef A                                                                  allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(NodeAlloc)                                  stored_allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(iterator_impl)                              iterator;
+   typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl)                        const_iterator;
 
    public:
+
+   //////////////////////////////////////////////
+   //
+   //          construct/copy/destroy
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Constructs a list taking the allocator as parameter.
    //!
    //! Throws: If allocator_type's copy constructor throws.
@@ -347,8 +354,7 @@ class slist
    //!
    //! Complexity: Linear to the range [first, last).
    template 
-   slist(InpIt first, InpIt last,
-         const allocator_type& a =  allocator_type())
+   slist(InpIt first, InpIt last, const allocator_type& a =  allocator_type())
       : AllocHolder(a)
    { this->insert_after(this->cbefore_begin(), first, last); }
 
@@ -400,6 +406,15 @@ class slist
       }
    }
 
+   //! Effects: Destroys the list. All stored values are destroyed
+   //!   and used memory is deallocated.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Linear to the number of elements.
+   ~slist()
+   {} //AllocHolder clears the slist
+
    //! Effects: Makes *this contain the same elements as x.
    //!
    //! Postcondition: this->size() == x.size(). *this contains a copy
@@ -455,31 +470,6 @@ class slist
       return *this;
    }
 
-   //! Effects: Destroys the list. All stored values are destroyed
-   //!   and used memory is deallocated.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Linear to the number of elements.
-   ~slist()
-   {} //AllocHolder clears the slist
-
-   //! Effects: Returns a copy of the internal allocator.
-   //!
-   //! Throws: If allocator's copy constructor throws.
-   //!
-   //! Complexity: Constant.
-   allocator_type get_allocator() const
-   {  return allocator_type(this->node_alloc()); }
-
-   const stored_allocator_type &get_stored_allocator() const
-   {  return this->node_alloc(); }
-
-   stored_allocator_type &get_stored_allocator()
-   {  return this->node_alloc(); }
-
-   public:
-
    //! Effects: Assigns the n copies of val to *this.
    //!
    //! Throws: If memory allocation throws or T's copy constructor throws.
@@ -521,6 +511,58 @@ class slist
          this->erase_after(prev, end_n);
    }
 
+   //! Effects: Returns a copy of the internal allocator.
+   //!
+   //! Throws: If allocator's copy constructor throws.
+   //!
+   //! Complexity: Constant.
+   allocator_type get_allocator() const
+   {  return allocator_type(this->node_alloc()); }
+
+   //! Effects: Returns a copy of the internal allocator.
+   //!
+   //! Throws: If allocator's copy constructor throws.
+   //!
+   //! Complexity: Constant.
+   const stored_allocator_type &get_stored_allocator() const
+   {  return this->node_alloc(); }
+
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
+   stored_allocator_type &get_stored_allocator()
+   {  return this->node_alloc(); }
+
+   //////////////////////////////////////////////
+   //
+   //                iterators
+   //
+   //////////////////////////////////////////////
+
+   //! Effects: Returns a non-dereferenceable iterator that,
+   //! when incremented, yields begin().  This iterator may be used
+   //! as the argument to insert_after, erase_after, etc.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   iterator before_begin()
+   {  return iterator(end());  }
+
+   //! Effects: Returns a non-dereferenceable const_iterator
+   //! that, when incremented, yields begin().  This iterator may be used
+   //! as the argument to insert_after, erase_after, etc.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_iterator before_begin() const
+   {  return this->cbefore_begin();  }
+
    //! Effects: Returns an iterator to the first element contained in the list.
    //!
    //! Throws: Nothing.
@@ -553,16 +595,6 @@ class slist
    const_iterator end() const
    {  return this->cend();   }
 
-   //! Effects: Returns a non-dereferenceable iterator that,
-   //! when incremented, yields begin().  This iterator may be used
-   //! as the argument to insert_after, erase_after, etc.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   iterator before_begin()
-   {  return iterator(end());  }
-
    //! Effects: Returns a non-dereferenceable const_iterator
    //! that, when incremented, yields begin().  This iterator may be used
    //! as the argument to insert_after, erase_after, etc.
@@ -570,8 +602,8 @@ class slist
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator before_begin() const
-   {  return this->cbefore_begin();  }
+   const_iterator cbefore_begin() const
+   {  return const_iterator(end());  }
 
    //! Effects: Returns a const_iterator to the first element contained in the list.
    //!
@@ -589,15 +621,43 @@ class slist
    const_iterator cend() const
    {  return const_iterator(this->non_const_icont().end());   }
 
-   //! Effects: Returns a non-dereferenceable const_iterator
-   //! that, when incremented, yields begin().  This iterator may be used
-   //! as the argument to insert_after, erase_after, etc.
+   //! Returns: The iterator to the element before i in the sequence.
+   //!   Returns the end-iterator, if either i is the begin-iterator or the
+   //!   sequence is empty.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Linear to the number of elements before i.
+   //!
+   //! Note: Non-standard extension.
+   iterator previous(iterator p)
+   {  return iterator(this->icont().previous(p.get())); }
+
+   //! Returns: The const_iterator to the element before i in the sequence.
+   //!   Returns the end-const_iterator, if either i is the begin-const_iterator or
+   //!   the sequence is empty.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Linear to the number of elements before i.
+   //!
+   //! Note: Non-standard extension.
+   const_iterator previous(const_iterator p)
+   {  return const_iterator(this->icont().previous(p.get())); }
+
+   //////////////////////////////////////////////
+   //
+   //                capacity
+   //
+   //////////////////////////////////////////////
+
+   //! Effects: Returns true if the list contains no elements.
    //!
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator cbefore_begin() const
-   {  return const_iterator(end());  }
+   bool empty() const
+   {  return !this->size();   }
 
    //! Effects: Returns the number of the elements contained in the list.
    //!
@@ -615,21 +675,40 @@ class slist
    size_type max_size() const
    {  return AllocHolder::max_size();  }
 
-   //! Effects: Returns true if the list contains no elements.
+   //! Effects: Inserts or erases elements at the end such that
+   //!   the size becomes n. New elements are default constructed.
    //!
-   //! Throws: Nothing.
+   //! Throws: If memory allocation throws, or T's copy constructor throws.
    //!
-   //! Complexity: Constant.
-   bool empty() const
-   {  return !this->size();   }
+   //! Complexity: Linear to the difference between size() and new_size.
+   void resize(size_type new_size)
+   {
+      const_iterator last_pos;
+      if(!priv_try_shrink(new_size, last_pos)){
+         typedef default_construct_iterator default_iterator;
+         this->insert_after(last_pos, default_iterator(new_size - this->size()), default_iterator());
+      }
+   }
 
-   //! Effects: Swaps the contents of *this and x.
+   //! Effects: Inserts or erases elements at the end such that
+   //!   the size becomes n. New elements are copy constructed from x.
    //!
-   //! Throws: Nothing.
+   //! Throws: If memory allocation throws, or T's copy constructor throws.
    //!
-   //! Complexity: Linear to the number of elements on *this and x.
-   void swap(slist& x)
-   {  AllocHolder::swap(x);   }
+   //! Complexity: Linear to the difference between size() and new_size.
+   void resize(size_type new_size, const T& x)
+   {
+      const_iterator last_pos;
+      if(!priv_try_shrink(new_size, last_pos)){
+         this->insert_after(last_pos, new_size, x);
+      }
+   }
+
+   //////////////////////////////////////////////
+   //
+   //               element access
+   //
+   //////////////////////////////////////////////
 
    //! Requires: !empty()
    //!
@@ -653,64 +732,88 @@ class slist
    const_reference front() const
    {  return *this->begin();  }
 
-   //! Effects: Inserts a copy of t in the beginning of the list.
+   //////////////////////////////////////////////
+   //
+   //                modifiers
+   //
+   //////////////////////////////////////////////
+
+   #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+   //! Effects: Inserts an object of type T constructed with
+   //!   std::forward(args)... in the front of the list
    //!
    //! Throws: If memory allocation throws or
    //!   T's copy constructor throws.
    //!
    //! Complexity: Amortized constant time.
-   void push_front(insert_const_ref_type x)
-   {  return priv_push_front(x); }
+   template 
+   void emplace_front(Args&&... args)
+   {  this->emplace_after(this->cbefore_begin(), boost::forward(args)...); }
 
-   #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   void push_front(T &x) { push_front(const_cast(x)); }
+   //! Effects: Inserts an object of type T constructed with
+   //!   std::forward(args)... after prev
+   //!
+   //! Throws: If memory allocation throws or
+   //!   T's in-place constructor throws.
+   //!
+   //! Complexity: Constant
+   template 
+   iterator emplace_after(const_iterator prev, Args&&... args)
+   {
+      NodePtr pnode(AllocHolder::create_node(boost::forward(args)...));
+      return iterator(this->icont().insert_after(prev.get(), *pnode));
+   }
 
-   template
-   void push_front(const U &u
-      , typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0)
-   {  return priv_push_front(u); }
-   #endif
+   #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
+
+   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   //! Effects: Inserts a copy of x at the beginning of the list.
+   //!
+   //! Throws: If memory allocation throws or
+   //!   T's copy constructor throws.
+   //!
+   //! Complexity: Amortized constant time.
+   void push_front(const T &x);
 
    //! Effects: Constructs a new element in the beginning of the list
-   //!   and moves the resources of t to this new element.
+   //!   and moves the resources of mx to this new element.
    //!
    //! Throws: If memory allocation throws.
    //!
    //! Complexity: Amortized constant time.
-   void push_front(BOOST_RV_REF(T) x)
-   {  this->icont().push_front(*this->create_node(boost::move(x)));  }
+   void push_front(T &&x);
+   #else
+   BOOST_MOVE_CONVERSION_AWARE_CATCH(push_front, T, void, priv_push_front)
+   #endif
 
-   //! Effects: Removes the first element from the list.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Amortized constant time.
-   void pop_front()
-   {  this->icont().pop_front_and_dispose(Destroyer(this->node_alloc()));      }
-
-   //! Returns: The iterator to the element before i in the sequence.
-   //!   Returns the end-iterator, if either i is the begin-iterator or the
-   //!   sequence is empty.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Linear to the number of elements before i.
-   iterator previous(iterator p)
-   {  return iterator(this->icont().previous(p.get())); }
-
-   //! Returns: The const_iterator to the element before i in the sequence.
-   //!   Returns the end-const_iterator, if either i is the begin-const_iterator or
-   //!   the sequence is empty.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Linear to the number of elements before i.
-   const_iterator previous(const_iterator p)
-   {  return const_iterator(this->icont().previous(p.get())); }
 
+   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
    //! Requires: p must be a valid iterator of *this.
    //!
-   //! Effects: Inserts a copy of the value after the p pointed
+   //! Effects: Inserts a copy of the value after the position pointed
    //!    by prev_p.
    //!
    //! Returns: An iterator to the inserted element.
@@ -721,18 +824,7 @@ class slist
    //!
    //! Note: Does not affect the validity of iterators and references of
    //!   previous values.
-   iterator insert_after(const_iterator prev_pos, insert_const_ref_type x)
-   {  return this->priv_insert_after(prev_pos, x); }
-
-   #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   iterator insert_after(const_iterator position, T &x)
-   { return this->insert_after(position, const_cast(x)); }
-
-   template
-   iterator insert_after( const_iterator position, const U &u
-                        , typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0)
-   {  return this->priv_insert_after(position, u); }
-   #endif
+   iterator insert_after(const_iterator prev_pos, const T &x);
 
    //! Requires: prev_pos must be a valid iterator of *this.
    //!
@@ -747,8 +839,10 @@ class slist
    //!
    //! Note: Does not affect the validity of iterators and references of
    //!   previous values.
-   iterator insert_after(const_iterator prev_pos, BOOST_RV_REF(value_type) x)
-   {  return iterator(this->icont().insert_after(prev_pos.get(), *this->create_node(boost::move(x)))); }
+   iterator insert_after(const_iterator prev_pos, T &&x);
+   #else
+   BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert_after, T, iterator, priv_insert_after, const_iterator)
+   #endif
 
    //! Requires: prev_pos must be a valid iterator of *this.
    //!
@@ -772,7 +866,7 @@ class slist
    //! Requires: prev_pos must be a valid iterator of *this.
    //!
    //! Effects: Inserts the range pointed by [first, last)
-   //!   after the p prev_pos.
+   //!   after the position prev_pos.
    //!
    //! Returns: an iterator to the last inserted element or prev_pos if first == last.
    //!
@@ -820,145 +914,13 @@ class slist
    }
    #endif
 
-   //! Requires: p must be a valid iterator of *this.
+   //! Effects: Removes the first element from the list.
    //!
-   //! Effects: Insert a copy of x before p.
-   //!
-   //! Returns: an iterator to the inserted element.
-   //!
-   //! Throws: If memory allocation throws or x's copy constructor throws.
-   //!
-   //! Complexity: Linear to the elements before p.
-   iterator insert(const_iterator position, insert_const_ref_type x)
-   {  return this->priv_insert(position, x); }
-
-   #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   iterator insert(const_iterator position, T &x)
-   { return this->insert(position, const_cast(x)); }
-
-   template
-   iterator insert( const_iterator position, const U &u
-                  , typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0)
-   {  return this->priv_insert(position, u); }
-   #endif
-
-   //! Requires: p must be a valid iterator of *this.
-   //!
-   //! Effects: Insert a new element before p with mx's resources.
-   //!
-   //! Returns: an iterator to the inserted element.
-   //!
-   //! Throws: If memory allocation throws.
-   //!
-   //! Complexity: Linear to the elements before p.
-   iterator insert(const_iterator p, BOOST_RV_REF(value_type) x)
-   {  return this->insert_after(previous(p), boost::move(x)); }
-
-   //! Requires: p must be a valid iterator of *this.
-   //!
-   //! Effects: Inserts n copies of x before p.
-   //!
-   //! Returns: an iterator to the first inserted element or p if n == 0.
-   //!
-   //! Throws: If memory allocation throws or T's copy constructor throws.
-   //!
-   //! Complexity: Linear to n plus linear to the elements before p.
-   iterator insert(const_iterator p, size_type n, const value_type& x)
-   {
-      const_iterator prev(this->previous(p));
-      this->insert_after(prev, n, x);
-      return ++iterator(prev.get());
-   }
-     
-   //! Requires: p must be a valid iterator of *this.
-   //!
-   //! Effects: Insert a copy of the [first, last) range before p.
-   //!
-   //! Returns: an iterator to the first inserted element or p if first == last.
-   //!
-   //! Throws: If memory allocation throws, T's constructor from a
-   //!   dereferenced InpIt throws.
-   //!
-   //! Complexity: Linear to std::distance [first, last) plus
-   //!    linear to the elements before p.
-   template 
-   iterator insert(const_iterator p, InIter first, InIter last)
-   {
-      const_iterator prev(this->previous(p));
-      this->insert_after(prev, first, last);
-      return ++iterator(prev.get());
-   }
-
-   #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-   //! Effects: Inserts an object of type T constructed with
-   //!   std::forward(args)... in the front of the list
-   //!
-   //! Throws: If memory allocation throws or
-   //!   T's copy constructor throws.
+   //! Throws: Nothing.
    //!
    //! Complexity: Amortized constant time.
-   template 
-   void emplace_front(Args&&... args)
-   {  this->emplace_after(this->cbefore_begin(), boost::forward(args)...); }
-
-   //! Effects: Inserts an object of type T constructed with
-   //!   std::forward(args)... before p
-   //!
-   //! Throws: If memory allocation throws or
-   //!   T's in-place constructor throws.
-   //!
-   //! Complexity: Linear to the elements before p
-   template 
-   iterator emplace(const_iterator p, Args&&... args)
-   {  return this->emplace_after(this->previous(p), boost::forward(args)...);  }
-
-   //! Effects: Inserts an object of type T constructed with
-   //!   std::forward(args)... after prev
-   //!
-   //! Throws: If memory allocation throws or
-   //!   T's in-place constructor throws.
-   //!
-   //! Complexity: Constant
-   template 
-   iterator emplace_after(const_iterator prev, Args&&... args)
-   {
-      NodePtr pnode(AllocHolder::create_node(boost::forward(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 (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, _));                   \
-   }                                                                                         \
-                                                                                             \
-   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
+   void pop_front()
+   {  this->icont().pop_front_and_dispose(Destroyer(this->node_alloc()));      }
 
    //! Effects: Erases the element after the element pointed by prev_pos
    //!    of the list.
@@ -992,55 +954,13 @@ class slist
       return iterator(this->icont().erase_after_and_dispose(before_first.get(), last.get(), Destroyer(this->node_alloc())));
    }
 
-   //! Requires: p must be a valid iterator of *this.
-   //!
-   //! Effects: Erases the element at p p.
+   //! Effects: Swaps the contents of *this and x.
    //!
    //! Throws: Nothing.
    //!
-   //! Complexity: Linear to the number of elements before p.
-   iterator erase(const_iterator p)
-   {  return iterator(this->erase_after(previous(p))); }
-
-   //! Requires: first and last must be valid iterator to elements in *this.
-   //!
-   //! Effects: Erases the elements pointed by [first, last).
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Linear to the distance between first and last plus
-   //!   linear to the elements before first.
-   iterator erase(const_iterator first, const_iterator last)
-   {  return iterator(this->erase_after(previous(first), last)); }
-
-   //! Effects: Inserts or erases elements at the end such that
-   //!   the size becomes n. New elements are copy constructed from x.
-   //!
-   //! Throws: If memory allocation throws, or T's copy constructor throws.
-   //!
-   //! Complexity: Linear to the difference between size() and new_size.
-   void resize(size_type new_size, const T& x)
-   {
-      const_iterator last_pos;
-      if(!priv_try_shrink(new_size, last_pos)){
-         this->insert_after(last_pos, new_size, x);
-      }
-   }
-
-   //! Effects: Inserts or erases elements at the end such that
-   //!   the size becomes n. New elements are default constructed.
-   //!
-   //! Throws: If memory allocation throws, or T's copy constructor throws.
-   //!
-   //! Complexity: Linear to the difference between size() and new_size.
-   void resize(size_type new_size)
-   {
-      const_iterator last_pos;
-      if(!priv_try_shrink(new_size, last_pos)){
-         typedef default_construct_iterator default_iterator;
-         this->insert_after(last_pos, default_iterator(new_size - this->size()), default_iterator());
-      }
-   }
+   //! Complexity: Linear to the number of elements on *this and x.
+   void swap(slist& x)
+   {  AllocHolder::swap(x);   }
 
    //! Effects: Erases all the elements of the list.
    //!
@@ -1050,6 +970,12 @@ class slist
    void clear()
    {  this->icont().clear_and_dispose(Destroyer(this->node_alloc()));  }
 
+   //////////////////////////////////////////////
+   //
+   //              slist operations
+   //
+   //////////////////////////////////////////////
+
    //! Requires: p must point to an element contained
    //!   by the list. x != *this
    //!
@@ -1065,14 +991,27 @@ class slist
    //!    this list. Iterators of this list and all the references are not invalidated.
    void splice_after(const_iterator prev_pos, slist& x)
    {
-      if((NodeAlloc&)*this == (NodeAlloc&)x){
-         this->icont().splice_after(prev_pos.get(), x.icont());
-      }
-      else{
-         throw std::runtime_error("slist::splice called with unequal allocators");
-      }
+      BOOST_ASSERT(*this != x);
+      BOOST_ASSERT(this->node_alloc() == x.node_alloc());
+      this->icont().splice_after(prev_pos.get(), x.icont());
    }
 
+   //! Requires: p must point to an element contained
+   //!   by the list. x != *this
+   //!
+   //! Effects: Transfers all the elements of list x to this list, after the
+   //!   the element pointed by p. No destructors or copy constructors are called.
+   //!
+   //! Throws: std::runtime_error if this' allocator and x's allocator
+   //!   are not equal.
+   //!
+   //! Complexity: Linear to the elements in x.
+   //!
+   //! Note: 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_pos, BOOST_RV_REF(slist) x)
+   {  this->splice_after(prev_pos, static_cast(x));  }
+
    //! Requires: prev_pos must be a valid iterator of this.
    //!   i must point to an element contained in list x.
    //!
@@ -1089,14 +1028,28 @@ class slist
    //!   list. Iterators of this list and all the references are not invalidated.
    void splice_after(const_iterator prev_pos, slist& x, const_iterator prev)
    {
-      if((NodeAlloc&)*this == (NodeAlloc&)x){
-         this->icont().splice_after(prev_pos.get(), x.icont(), prev.get());
-      }
-      else{
-         throw std::runtime_error("slist::splice called with unequal allocators");
-      }
+      BOOST_ASSERT(*this != x);
+      BOOST_ASSERT(this->node_alloc() == x.node_alloc());
+      this->icont().splice_after(prev_pos.get(), x.icont(), prev.get());
    }
 
+   //! Requires: prev_pos must be a valid iterator of this.
+   //!   i must point to an element contained in list x.
+   //!
+   //! Effects: Transfers the value pointed by i, from list x to this list,
+   //!   after the element pointed by prev_pos.
+   //!   If prev_pos == prev or prev_pos == ++prev, this function is a null operation.
+   //!
+   //! Throws: std::runtime_error if this' allocator and x's allocator
+   //!   are not equal.
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: 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_pos, BOOST_RV_REF(slist) x, const_iterator prev)
+   {  this->splice_after(prev_pos, static_cast(x), prev);  }
+
    //! Requires: prev_pos must be a valid iterator of this.
    //!   before_first and before_last must be valid iterators of x.
    //!   prev_pos must not be contained in [before_first, before_last) range.
@@ -1114,15 +1067,30 @@ class slist
    void splice_after(const_iterator prev_pos,      slist& x,
       const_iterator before_first,  const_iterator before_last)
    {
-      if((NodeAlloc&)*this == (NodeAlloc&)x){
-         this->icont().splice_after
-            (prev_pos.get(), x.icont(), before_first.get(), before_last.get());
-      }
-      else{
-         throw std::runtime_error("slist::splice called with unequal allocators");
-      }
+      BOOST_ASSERT(*this != x);
+      BOOST_ASSERT(this->node_alloc() == x.node_alloc());
+      this->icont().splice_after
+         (prev_pos.get(), x.icont(), before_first.get(), before_last.get());
    }
 
+   //! Requires: prev_pos must be a valid iterator of this.
+   //!   before_first and before_last must be valid iterators of x.
+   //!   prev_pos must not be contained in [before_first, before_last) range.
+   //!
+   //! Effects: Transfers the range [before_first + 1, before_last + 1)
+   //!   from list x to this list, after the element pointed by prev_pos.
+   //!
+   //! Throws: std::runtime_error if this' allocator and x's allocator
+   //!   are not equal.
+   //!
+   //! Complexity: Linear to the number of transferred elements.
+   //!
+   //! Note: 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_pos,      BOOST_RV_REF(slist) x,
+      const_iterator before_first,  const_iterator before_last)
+   {  this->splice_after(prev_pos, static_cast(x), before_first, before_last);  }
+
    //! Requires: prev_pos must be a valid iterator of this.
    //!   before_first and before_last must be valid iterators of x.
    //!   prev_pos must not be contained in [before_first, before_last) range.
@@ -1142,74 +1110,31 @@ class slist
                      const_iterator before_first,  const_iterator before_last,
                      size_type n)
    {
-      if((NodeAlloc&)*this == (NodeAlloc&)x){
-         this->icont().splice_after
-            (prev_pos.get(), x.icont(), before_first.get(), before_last.get(), n);
-      }
-      else{
-         throw std::runtime_error("slist::splice called with unequal allocators");
-      }
+      BOOST_ASSERT(*this != x);
+      BOOST_ASSERT(this->node_alloc() == x.node_alloc());
+      this->icont().splice_after
+         (prev_pos.get(), x.icont(), before_first.get(), before_last.get(), n);
    }
 
-   //! Requires: p must point to an element contained
-   //!   by the list. x != *this
+   //! Requires: prev_pos must be a valid iterator of this.
+   //!   before_first and before_last must be valid iterators of x.
+   //!   prev_pos must not be contained in [before_first, before_last) range.
+   //!   n == std::distance(before_first, before_last)
    //!
-   //! Effects: Transfers all the elements of list x to this list, before the
-   //!   the element pointed by p. No destructors or copy constructors are called.
+   //! Effects: Transfers the range [before_first + 1, before_last + 1)
+   //!   from list x to this list, after the element pointed by prev_pos.
    //!
    //! Throws: std::runtime_error if this' allocator and x's allocator
    //!   are not equal.
    //!
-   //! Complexity: Linear in distance(begin(), p), and linear in x.size().
-   //!
-   //! Note: 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)
-   {  this->splice_after(this->previous(p), x);  }
-
-   //! Requires: p must point to an element contained
-   //!   by this list. i must point to an element contained in list x.
-   //!
-   //! Effects: 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.
-   //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
-   //!
-   //! Complexity: Linear in distance(begin(), p), and in distance(x.begin(), i).
+   //! Complexity: Constant.
    //!
    //! Note: 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)
-   {  this->splice_after(previous(p), x, i);  }
-
-   //! Requires: p must point to an element contained
-   //!   by this list. first and last must point to elements contained in list x.
-   //!
-   //! Effects: 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.
-   //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
-   //!
-   //! Complexity: Linear in distance(begin(), p), in distance(x.begin(), first),
-   //!   and in distance(first, last).
-   //!
-   //! Note: 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)
-   {  this->splice_after(previous(p), x, previous(first), previous(last));  }
-
-   //! Effects: Reverses the order of elements in the list.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: This function is linear time.
-   //!
-   //! Note: Iterators and references are not invalidated
-   void reverse()
-   {  this->icont().reverse();  }
+   void splice_after(const_iterator prev_pos,      BOOST_RV_REF(slist) x,
+                     const_iterator before_first,  const_iterator before_last,
+                     size_type n)
+   {  this->splice_after(prev_pos, static_cast(x), before_first, before_last, n);  }
 
    //! Effects: Removes all the elements that compare equal to value.
    //!
@@ -1220,7 +1145,7 @@ class slist
    //! Note: 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)
-   {  remove_if(equal_to_value(value));  }
+   {  this->remove_if(equal_to_value(value));  }
 
    //! Effects: Removes all the elements for which a specified
    //!   predicate is satisfied.
@@ -1280,6 +1205,20 @@ class slist
    void merge(slist & x)
    {  this->merge(x, value_less()); }
 
+   //! Requires: The lists x and *this must be distinct.
+   //!
+   //! Effects: This function removes all of x's elements and inserts them
+   //!   in order into *this according to std::less. 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.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: This function is linear time: it performs at most
+   //!   size() + x.size() - 1 comparisons.
+   void merge(BOOST_RV_REF(slist) x)
+   {  this->merge(static_cast(x)); }
+
    //! Requires: 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.
@@ -1306,6 +1245,24 @@ class slist
       }
    }
 
+   //! Requires: 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.
+   //!
+   //! Effects: 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.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: This function is linear time: it performs at most
+   //!   size() + x.size() - 1 comparisons.
+   //!
+   //! Note: Iterators and references to *this are not invalidated.
+   template 
+   void merge(BOOST_RV_REF(slist) x, StrictWeakOrdering comp)
+   {  this->merge(static_cast(x), comp); }
+
    //! Effects: This function sorts the list *this according to std::less.
    //!   The sort is stable, that is, the relative order of equivalent elements is preserved.
    //!
@@ -1336,9 +1293,242 @@ class slist
       this->icont().sort(ValueCompareToNodeCompare(comp));
    }
 
+   //! Effects: Reverses the order of elements in the list.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: This function is linear time.
+   //!
+   //! Note: Iterators and references are not invalidated
+   void reverse()
+   {  this->icont().reverse();  }
+
+   //////////////////////////////////////////////
+   //
+   //       list compatibility interface
+   //
+   //////////////////////////////////////////////
+
+   #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+   //! Effects: Inserts an object of type T constructed with
+   //!   std::forward(args)... before p
+   //!
+   //! Throws: If memory allocation throws or
+   //!   T's in-place constructor throws.
+   //!
+   //! Complexity: Linear to the elements before p
+   template 
+   iterator emplace(const_iterator p, Args&&... args)
+   {  return this->emplace_after(this->previous(p), boost::forward(args)...);  }
+
+   #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, >)    \
+   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
+
+   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   //! Requires: p must be a valid iterator of *this.
+   //!
+   //! Effects: Insert a copy of x before p.
+   //!
+   //! Returns: an iterator to the inserted element.
+   //!
+   //! Throws: If memory allocation throws or x's copy constructor throws.
+   //!
+   //! Complexity: Linear to the elements before p.
+   iterator insert(const_iterator position, const T &x);
+
+   //! Requires: p must be a valid iterator of *this.
+   //!
+   //! Effects: Insert a new element before p with mx's resources.
+   //!
+   //! Returns: an iterator to the inserted element.
+   //!
+   //! Throws: If memory allocation throws.
+   //!
+   //! Complexity: Linear to the elements before p.
+   iterator insert(const_iterator prev_pos, T &&x);
+   #else
+   BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator)
+   #endif
+
+   //! Requires: p must be a valid iterator of *this.
+   //!
+   //! Effects: Inserts n copies of x before p.
+   //!
+   //! Returns: an iterator to the first inserted element or p if n == 0.
+   //!
+   //! Throws: If memory allocation throws or T's copy constructor throws.
+   //!
+   //! Complexity: Linear to n plus linear to the elements before p.
+   iterator insert(const_iterator p, size_type n, const value_type& x)
+   {
+      const_iterator prev(this->previous(p));
+      this->insert_after(prev, n, x);
+      return ++iterator(prev.get());
+   }
+     
+   //! Requires: p must be a valid iterator of *this.
+   //!
+   //! Effects: Insert a copy of the [first, last) range before p.
+   //!
+   //! Returns: an iterator to the first inserted element or p if first == last.
+   //!
+   //! Throws: If memory allocation throws, T's constructor from a
+   //!   dereferenced InpIt throws.
+   //!
+   //! Complexity: Linear to std::distance [first, last) plus
+   //!    linear to the elements before p.
+   template 
+   iterator insert(const_iterator p, InIter first, InIter last)
+   {
+      const_iterator prev(this->previous(p));
+      this->insert_after(prev, first, last);
+      return ++iterator(prev.get());
+   }
+
+   //! Requires: p must be a valid iterator of *this.
+   //!
+   //! Effects: Erases the element at p p.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Linear to the number of elements before p.
+   iterator erase(const_iterator p)
+   {  return iterator(this->erase_after(previous(p))); }
+
+   //! Requires: first and last must be valid iterator to elements in *this.
+   //!
+   //! Effects: Erases the elements pointed by [first, last).
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Linear to the distance between first and last plus
+   //!   linear to the elements before first.
+   iterator erase(const_iterator first, const_iterator last)
+   {  return iterator(this->erase_after(previous(first), last)); }
+
+   //! Requires: p must point to an element contained
+   //!   by the list. x != *this
+   //!
+   //! Effects: Transfers all the elements of list x to this list, before the
+   //!   the element pointed by p. No destructors or copy constructors are called.
+   //!
+   //! Throws: std::runtime_error if this' allocator and x's allocator
+   //!   are not equal.
+   //!
+   //! Complexity: Linear in distance(begin(), p), and linear in x.size().
+   //!
+   //! Note: 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)
+   {  this->splice_after(this->previous(p), x);  }
+
+   //! Requires: p must point to an element contained
+   //!   by the list. x != *this
+   //!
+   //! Effects: Transfers all the elements of list x to this list, before the
+   //!   the element pointed by p. No destructors or copy constructors are called.
+   //!
+   //! Throws: std::runtime_error if this' allocator and x's allocator
+   //!   are not equal.
+   //!
+   //! Complexity: Linear in distance(begin(), p), and linear in x.size().
+   //!
+   //! Note: 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)
+   {  this->splice(p, static_cast(x));  }
+
+   //! Requires: p must point to an element contained
+   //!   by this list. i must point to an element contained in list x.
+   //!
+   //! Effects: 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.
+   //!
+   //! Throws: std::runtime_error if this' allocator and x's allocator
+   //!   are not equal.
+   //!
+   //! Complexity: Linear in distance(begin(), p), and in distance(x.begin(), i).
+   //!
+   //! Note: 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)
+   {  this->splice_after(this->previous(p), x, this->previous(i));  }
+
+   //! Requires: p must point to an element contained
+   //!   by this list. i must point to an element contained in list x.
+   //!
+   //! Effects: 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.
+   //!
+   //! Throws: std::runtime_error if this' allocator and x's allocator
+   //!   are not equal.
+   //!
+   //! Complexity: Linear in distance(begin(), p), and in distance(x.begin(), i).
+   //!
+   //! Note: 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)
+   {  this->splice(p, static_cast(x), i);  }
+
+   //! Requires: p must point to an element contained
+   //!   by this list. first and last must point to elements contained in list x.
+   //!
+   //! Effects: 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.
+   //!
+   //! Throws: std::runtime_error if this' allocator and x's allocator
+   //!   are not equal.
+   //!
+   //! Complexity: Linear in distance(begin(), p), in distance(x.begin(), first),
+   //!   and in distance(first, last).
+   //!
+   //! Note: 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)
+   {  this->splice_after(this->previous(p), x, this->previous(first), this->previous(last));  }
+
+   //! Requires: p must point to an element contained
+   //!   by this list. first and last must point to elements contained in list x.
+   //!
+   //! Effects: 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.
+   //!
+   //! Throws: std::runtime_error if this' allocator and x's allocator
+   //!   are not equal.
+   //!
+   //! Complexity: Linear in distance(begin(), p), in distance(x.begin(), first),
+   //!   and in distance(first, last).
+   //!
+   //! Note: 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)
+   {  this->splice(p, static_cast(x), first, last);  }
+
    /// @cond
    private:
 
+   void priv_push_front (const T &x)  
+   {  this->insert(this->cbegin(), x);  }
+
+   void priv_push_front (BOOST_RV_REF(T) x)
+   {  this->insert(this->cbegin(), ::boost::move(x));  }
+
    bool priv_try_shrink(size_type new_size, const_iterator &last_pos)
    {
       typename Icont::iterator end_n(this->icont().end()), cur(this->icont().before_begin()), cur_next;
@@ -1356,14 +1546,13 @@ class slist
       }
    }
 
-   iterator priv_insert(const_iterator p, const value_type& x)
-   {  return this->insert_after(previous(p), x); }
+   template
+   iterator priv_insert(const_iterator p, BOOST_FWD_REF(U) x)
+   {  return this->insert_after(previous(p), ::boost::forward(x)); }
 
-   iterator priv_insert_after(const_iterator prev_pos, const value_type& x)
-   {  return iterator(this->icont().insert_after(prev_pos.get(), *this->create_node(x))); }
-
-   void priv_push_front(const value_type &x)
-   {  this->icont().push_front(*this->create_node(x));  }
+   template
+   iterator priv_insert_after(const_iterator prev_pos, BOOST_FWD_REF(U) x)
+   {  return iterator(this->icont().insert_after(prev_pos.get(), *this->create_node(::boost::forward(x)))); }
 
    class insertion_functor;
    friend class insertion_functor;
diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp
index f6c55c9..3e45e7e 100644
--- a/include/boost/container/stable_vector.hpp
+++ b/include/boost/container/stable_vector.hpp
@@ -466,9 +466,6 @@ class stable_vector
    typedef typename index_traits_type::index_iterator index_iterator;
    typedef typename index_traits_type::
       const_index_iterator                            const_index_iterator;
-
-   typedef typename container_detail::
-      move_const_ref_type::type                    insert_const_ref_type;
    typedef boost::intrusive::
       pointer_traits
              ptr_traits;
@@ -601,27 +598,35 @@ class stable_vector
    {  this->priv_node_alloc().deallocate_individual(boost::move(holder));  }
 
    friend class stable_vector_detail::clear_on_destroy;
+   typedef stable_vector_detail::iterator
+      < T
+      , typename allocator_traits::reference
+      , typename allocator_traits::pointer>              iterator_impl;
+   typedef stable_vector_detail::iterator
+      < T
+      , typename allocator_traits::const_reference
+      , typename allocator_traits::const_pointer>        const_iterator_impl;
    ///@endcond
    public:
 
-
-   // types:
-
-   typedef typename allocator_traits_type::reference              reference;
-   typedef typename allocator_traits_type::const_reference        const_reference;
-   typedef typename allocator_traits_type::pointer                pointer;
-   typedef typename allocator_traits_type::const_pointer          const_pointer;
-   typedef stable_vector_detail::iterator
-                                       iterator;
-   typedef stable_vector_detail::iterator
-                           const_iterator;
-   typedef typename index_type::size_type             size_type;
-   typedef typename iterator::difference_type         difference_type;
-   typedef T                                          value_type;
-   typedef A                                          allocator_type;
-   typedef std::reverse_iterator            reverse_iterator;
-   typedef std::reverse_iterator      const_reverse_iterator;
-   typedef node_allocator_type                        stored_allocator_type;
+   //////////////////////////////////////////////
+   //
+   //                    types
+   //
+   //////////////////////////////////////////////
+   typedef T                                                                  value_type;
+   typedef typename ::boost::container::allocator_traits::pointer          pointer;
+   typedef typename ::boost::container::allocator_traits::const_pointer    const_pointer;
+   typedef typename ::boost::container::allocator_traits::reference        reference;
+   typedef typename ::boost::container::allocator_traits::const_reference  const_reference;
+   typedef typename ::boost::container::allocator_traits::size_type        size_type;
+   typedef typename ::boost::container::allocator_traits::difference_type  difference_type;
+   typedef A                                                                  allocator_type;
+   typedef node_allocator_type                                                stored_allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(iterator_impl)                              iterator;
+   typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl)                        const_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)            reverse_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)      const_reverse_iterator;
 
    ///@cond
    private:
@@ -636,6 +641,11 @@ class stable_vector
    ///@endcond
 
    public:
+   //////////////////////////////////////////////
+   //
+   //          construct/copy/destroy
+   //
+   //////////////////////////////////////////////
 
    //! Effects: Default constructs a stable_vector.
    //!
@@ -842,6 +852,18 @@ class stable_vector
       return *this;
    }
 
+
+   //! Effects: Assigns the n copies of val to *this.
+   //!
+   //! Throws: If memory allocation throws or T's copy constructor throws.
+   //!
+   //! Complexity: Linear to n.
+   void assign(size_type n, const T& t)
+   {
+      typedef constant_iterator cvalue_iterator;
+      this->assign(cvalue_iterator(t, n), cvalue_iterator());
+   }
+
    //! Effects: Assigns the the range [first, last) to *this.
    //!
    //! Throws: If memory allocation throws or
@@ -870,17 +892,6 @@ class stable_vector
       }
    }
 
-   //! Effects: Assigns the n copies of val to *this.
-   //!
-   //! Throws: If memory allocation throws or T's copy constructor throws.
-   //!
-   //! Complexity: Linear to n.
-   void assign(size_type n, const T& t)
-   {
-      typedef constant_iterator cvalue_iterator;
-      this->assign(cvalue_iterator(t, n), cvalue_iterator());
-   }
-
    //! Effects: Returns a copy of the internal allocator.
    //!
    //! Throws: If allocator's copy constructor throws.
@@ -909,6 +920,12 @@ class stable_vector
    stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
    {  return this->priv_node_alloc(); }
 
+   //////////////////////////////////////////////
+   //
+   //                iterators
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Returns an iterator to the first element contained in the stable_vector.
    //!
    //! Throws: Nothing.
@@ -1011,6 +1028,20 @@ class stable_vector
    const_reverse_iterator crend()const
    {  return this->rend(); }
 
+   //////////////////////////////////////////////
+   //
+   //                capacity
+   //
+   //////////////////////////////////////////////
+
+   //! Effects: Returns true if the stable_vector contains no elements.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   bool empty() const
+   {  return this->index.size() <= ExtraPointers;  }
+
    //! Effects: Returns the number of the elements contained in the stable_vector.
    //!
    //! Throws: Nothing.
@@ -1030,31 +1061,22 @@ class stable_vector
    size_type max_size() const
    {  return this->index.max_size() - ExtraPointers;  }
 
-   //! Effects: Number of elements for which memory has been allocated.
-   //!   capacity() is always greater than or equal to size().
+   //! Effects: Inserts or erases elements at the end such that
+   //!   the size becomes n. New elements are default constructed.
    //!
-   //! Throws: Nothing.
+   //! Throws: If memory allocation throws, or T's copy constructor throws.
    //!
-   //! Complexity: Constant.
-   size_type capacity() const
+   //! Complexity: Linear to the difference between size() and new_size.
+   void resize(size_type n)
    {
-      const size_type index_size             = this->index.size();
-      BOOST_ASSERT(!index_size || index_size >= ExtraPointers);
-      const size_type bucket_extra_capacity = this->index.capacity()- index_size;
-      const size_type node_extra_capacity   = this->internal_data.pool_size;
-      const size_type extra_capacity        = (bucket_extra_capacity < node_extra_capacity)
-         ? bucket_extra_capacity : node_extra_capacity;
-      return (index_size ? (index_size - ExtraPointers + extra_capacity) : index_size);
+      typedef default_construct_iterator default_iterator;
+      STABLE_VECTOR_CHECK_INVARIANT;
+      if(n > this->size())
+         this->insert(this->cend(), default_iterator(n - this->size()), default_iterator());
+      else if(n < this->size())
+         this->erase(this->cbegin() + n, this->cend());
    }
 
-   //! Effects: Returns true if the stable_vector contains no elements.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   bool empty() const
-   {  return this->index.size() <= ExtraPointers;  }
-
    //! Effects: Inserts or erases elements at the end such that
    //!   the size becomes n. New elements are copy constructed from x.
    //!
@@ -1070,20 +1092,21 @@ class stable_vector
          this->erase(this->cbegin() + n, this->cend());
    }
 
-   //! Effects: Inserts or erases elements at the end such that
-   //!   the size becomes n. New elements are default constructed.
+   //! Effects: Number of elements for which memory has been allocated.
+   //!   capacity() is always greater than or equal to size().
    //!
-   //! Throws: If memory allocation throws, or T's copy constructor throws.
+   //! Throws: Nothing.
    //!
-   //! Complexity: Linear to the difference between size() and new_size.
-   void resize(size_type n)
+   //! Complexity: Constant.
+   size_type capacity() const
    {
-      typedef default_construct_iterator default_iterator;
-      STABLE_VECTOR_CHECK_INVARIANT;
-      if(n > this->size())
-         this->insert(this->cend(), default_iterator(n - this->size()), default_iterator());
-      else if(n < this->size())
-         this->erase(this->cbegin() + n, this->cend());
+      const size_type index_size             = this->index.size();
+      BOOST_ASSERT(!index_size || index_size >= ExtraPointers);
+      const size_type bucket_extra_capacity = this->index.capacity()- index_size;
+      const size_type node_extra_capacity   = this->internal_data.pool_size;
+      const size_type extra_capacity        = (bucket_extra_capacity < node_extra_capacity)
+         ? bucket_extra_capacity : node_extra_capacity;
+      return (index_size ? (index_size - ExtraPointers + extra_capacity) : index_size);
    }
 
    //! Effects: If n is less than or equal to capacity(), this call has no
@@ -1116,6 +1139,86 @@ class stable_vector
       }
    }
 
+   //! Effects: Tries to deallocate the excess of memory created
+   //!   with previous allocations. The size of the stable_vector is unchanged
+   //!
+   //! Throws: If memory allocation throws.
+   //!
+   //! Complexity: Linear to size().
+   void shrink_to_fit()
+   {
+      if(this->capacity()){
+         //First empty allocated node pool
+         this->priv_clear_pool();
+         //If empty completely destroy the index, let's recover default-constructed state
+         if(this->empty()){
+            this->index.clear();
+            this->index.shrink_to_fit();
+            this->internal_data.end_node.up = node_base_ptr_ptr();
+         }
+         //Otherwise, try to shrink-to-fit the index and readjust pointers if necessary
+         else{
+            const void* old_ptr = &index[0];
+            this->index.shrink_to_fit();
+            bool realloced = &index[0] != old_ptr;
+            //Fix the pointers for the newly allocated buffer
+            if(realloced){
+               index_traits_type::fix_up_pointers_from(this->index, this->index.begin());
+            }
+         }
+      }
+   }
+
+   //////////////////////////////////////////////
+   //
+   //               element access
+   //
+   //////////////////////////////////////////////
+
+   //! Requires: !empty()
+   //!
+   //! Effects: Returns a reference to the first
+   //!   element of the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   reference front()
+   {  return static_cast(*this->index.front()).value;  }
+
+   //! Requires: !empty()
+   //!
+   //! Effects: Returns a const reference to the first
+   //!   element of the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_reference front() const
+   {  return static_cast(*this->index.front()).value;  }
+
+   //! Requires: !empty()
+   //!
+   //! Effects: Returns a reference to the last
+   //!   element of the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   reference back()
+   {  return static_cast(*this->index[this->size() - ExtraPointers]).value;  }
+
+   //! Requires: !empty()
+   //!
+   //! Effects: Returns a const reference to the last
+   //!   element of the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_reference back()const
+   {  return static_cast(*this->index[this->size() - ExtraPointers]).value;  }
+
    //! Requires: size() > n.
    //!
    //! Effects: Returns a reference to the nth element
@@ -1168,49 +1271,86 @@ class stable_vector
       return operator[](n);
    }
 
-   //! Requires: !empty()
-   //!
-   //! Effects: Returns a reference to the first
-   //!   element of the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   reference front()
-   {  return static_cast(*this->index.front()).value;  }
+   //////////////////////////////////////////////
+   //
+   //                modifiers
+   //
+   //////////////////////////////////////////////
 
-   //! Requires: !empty()
-   //!
-   //! Effects: Returns a const reference to the first
-   //!   element of the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_reference front() const
-   {  return static_cast(*this->index.front()).value;  }
+   #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
-   //! Requires: !empty()
+   //! Effects: Inserts an object of type T constructed with
+   //!   std::forward(args)... in the end of the stable_vector.
    //!
-   //! Effects: Returns a reference to the last
-   //!   element of the container.
+   //! Throws: If memory allocation throws or the in-place constructor throws.
    //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   reference back()
-   {  return static_cast(*this->index[this->size() - ExtraPointers]).value;  }
+   //! Complexity: Amortized constant time.
+   template
+   void emplace_back(Args &&...args)
+   {
+      typedef emplace_functor         EmplaceFunctor;
+      typedef emplace_iterator EmplaceIterator;
+      EmplaceFunctor &&ef = EmplaceFunctor(boost::forward(args)...);
+      this->insert(this->cend(), EmplaceIterator(ef), EmplaceIterator());
+   }
 
-   //! Requires: !empty()
+   //! Requires: position must be a valid iterator of *this.
    //!
-   //! Effects: Returns a const reference to the last
-   //!   element of the container.
+   //! Effects: Inserts an object of type T constructed with
+   //!   std::forward(args)... before position
    //!
-   //! Throws: Nothing.
+   //! Throws: If memory allocation throws or the in-place constructor throws.
    //!
-   //! Complexity: Constant.
-   const_reference back()const
-   {  return static_cast(*this->index[this->size() - ExtraPointers]).value;  }
+   //! Complexity: If position is end(), amortized constant time
+   //!   Linear time otherwise.
+   template
+   iterator emplace(const_iterator position, Args && ...args)
+   {
+      //Just call more general insert(pos, size, value) and return iterator
+      size_type pos_n = position - cbegin();
+      typedef emplace_functor         EmplaceFunctor;
+      typedef emplace_iterator EmplaceIterator;
+      EmplaceFunctor &&ef = EmplaceFunctor(boost::forward(args)...);
+      this->insert(position, EmplaceIterator(ef), EmplaceIterator());
+      return iterator(this->begin() + pos_n);
+   }
+
+   #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, >)       \
+   void emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                        \
+   {                                                                                            \
+      typedef BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg)                               \
+         BOOST_PP_EXPR_IF(n, <) BOOST_PP_ENUM_PARAMS(n, P) BOOST_PP_EXPR_IF(n, >)               \
+            EmplaceFunctor;                                                                     \
+      typedef emplace_iterator  EmplaceIterator;   \
+      EmplaceFunctor ef BOOST_PP_LPAREN_IF(n)                                                   \
+                        BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)                   \
+                        BOOST_PP_RPAREN_IF(n);                                                  \
+      this->insert(this->cend() , EmplaceIterator(ef), EmplaceIterator());                      \
+   }                                                                                            \
+                                                                                                \
+   BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >)       \
+   iterator emplace(const_iterator pos                                                          \
+           BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                         \
+   {                                                                                            \
+      typedef BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg)                               \
+         BOOST_PP_EXPR_IF(n, <) BOOST_PP_ENUM_PARAMS(n, P) BOOST_PP_EXPR_IF(n, >)               \
+            EmplaceFunctor;                                                                     \
+      typedef emplace_iterator  EmplaceIterator;   \
+      EmplaceFunctor ef BOOST_PP_LPAREN_IF(n)                                                   \
+                        BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)                   \
+                        BOOST_PP_RPAREN_IF(n);                                                  \
+      size_type pos_n = pos - this->cbegin();                                                   \
+      this->insert(pos, EmplaceIterator(ef), EmplaceIterator());                                \
+      return iterator(this->begin() + pos_n);                                                   \
+   }                                                                                            \
+   //!
+   #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
+   #include BOOST_PP_LOCAL_ITERATE()
+
+   #endif   //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
    #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
    //! Effects: Inserts a copy of x at the end of the stable_vector.
@@ -1232,16 +1372,6 @@ class stable_vector
    BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
    #endif
 
-   //! Effects: Removes the last element from the stable_vector.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant time.
-   void pop_back()
-   {  this->erase(this->end()-1);   }
-
-
-
    #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
    //! Requires: position must be a valid iterator of *this.
    //!
@@ -1355,80 +1485,13 @@ class stable_vector
    }
    #endif
 
-   #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-   //! Effects: Inserts an object of type T constructed with
-   //!   std::forward(args)... in the end of the stable_vector.
+   //! Effects: Removes the last element from the stable_vector.
    //!
-   //! Throws: If memory allocation throws or the in-place constructor throws.
+   //! Throws: Nothing.
    //!
-   //! Complexity: Amortized constant time.
-   template
-   void emplace_back(Args &&...args)
-   {
-      typedef emplace_functor         EmplaceFunctor;
-      typedef emplace_iterator EmplaceIterator;
-      EmplaceFunctor &&ef = EmplaceFunctor(boost::forward(args)...);
-      this->insert(this->cend(), EmplaceIterator(ef), EmplaceIterator());
-   }
-
-   //! Requires: position must be a valid iterator of *this.
-   //!
-   //! Effects: Inserts an object of type T constructed with
-   //!   std::forward(args)... before position
-   //!
-   //! Throws: If memory allocation throws or the in-place constructor throws.
-   //!
-   //! Complexity: If position is end(), amortized constant time
-   //!   Linear time otherwise.
-   template
-   iterator emplace(const_iterator position, Args && ...args)
-   {
-      //Just call more general insert(pos, size, value) and return iterator
-      size_type pos_n = position - cbegin();
-      typedef emplace_functor         EmplaceFunctor;
-      typedef emplace_iterator EmplaceIterator;
-      EmplaceFunctor &&ef = EmplaceFunctor(boost::forward(args)...);
-      this->insert(position, EmplaceIterator(ef), EmplaceIterator());
-      return iterator(this->begin() + pos_n);
-   }
-
-   #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, >)       \
-   void emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                        \
-   {                                                                                            \
-      typedef BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg)                               \
-         BOOST_PP_EXPR_IF(n, <) BOOST_PP_ENUM_PARAMS(n, P) BOOST_PP_EXPR_IF(n, >)               \
-            EmplaceFunctor;                                                                     \
-      typedef emplace_iterator  EmplaceIterator;   \
-      EmplaceFunctor ef BOOST_PP_LPAREN_IF(n)                                                   \
-                        BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)                   \
-                        BOOST_PP_RPAREN_IF(n);                                                  \
-      this->insert(this->cend() , EmplaceIterator(ef), EmplaceIterator());                      \
-   }                                                                                            \
-                                                                                                \
-   BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >)       \
-   iterator emplace(const_iterator pos                                                          \
-           BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                         \
-   {                                                                                            \
-      typedef BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg)                               \
-         BOOST_PP_EXPR_IF(n, <) BOOST_PP_ENUM_PARAMS(n, P) BOOST_PP_EXPR_IF(n, >)               \
-            EmplaceFunctor;                                                                     \
-      typedef emplace_iterator  EmplaceIterator;   \
-      EmplaceFunctor ef BOOST_PP_LPAREN_IF(n)                                                   \
-                        BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)                   \
-                        BOOST_PP_RPAREN_IF(n);                                                  \
-      size_type pos_n = pos - this->cbegin();                                                   \
-      this->insert(pos, EmplaceIterator(ef), EmplaceIterator());                                \
-      return iterator(this->begin() + pos_n);                                                   \
-   }                                                                                            \
-   //!
-   #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
-   #include BOOST_PP_LOCAL_ITERATE()
-
-   #endif   //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
+   //! Complexity: Constant time.
+   void pop_back()
+   {  this->erase(--this->cend());   }
 
    //! Effects: Erases the element at position pos.
    //!
@@ -1491,36 +1554,6 @@ class stable_vector
    void clear()
    {   this->erase(this->cbegin(),this->cend()); }
 
-   //! Effects: Tries to deallocate the excess of memory created
-   //!   with previous allocations. The size of the stable_vector is unchanged
-   //!
-   //! Throws: If memory allocation throws.
-   //!
-   //! Complexity: Linear to size().
-   void shrink_to_fit()
-   {
-      if(this->capacity()){
-         //First empty allocated node pool
-         this->priv_clear_pool();
-         //If empty completely destroy the index, let's recover default-constructed state
-         if(this->empty()){
-            this->index.clear();
-            this->index.shrink_to_fit();
-            this->internal_data.end_node.up = node_base_ptr_ptr();
-         }
-         //Otherwise, try to shrink-to-fit the index and readjust pointers if necessary
-         else{
-            const void* old_ptr = &index[0];
-            this->index.shrink_to_fit();
-            bool realloced = &index[0] != old_ptr;
-            //Fix the pointers for the newly allocated buffer
-            if(realloced){
-               index_traits_type::fix_up_pointers_from(this->index, this->index.begin());
-            }
-         }
-      }
-   }
-
    /// @cond
 
    private:
diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp
index 87a09bc..91f4207 100644
--- a/include/boost/container/vector.hpp
+++ b/include/boost/container/vector.hpp
@@ -86,7 +86,7 @@ class vector_const_iterator
    {  return *m_ptr;  }
 
    const value_type * operator->()  const 
-   {  return  container_detail::to_raw_pointer(m_ptr);  }
+   {  return container_detail::to_raw_pointer(m_ptr);  }
 
    reference operator[](difference_type off) const
    {  return m_ptr[off];   }
@@ -408,40 +408,29 @@ template 
 class vector : private container_detail::vector_alloc_holder
 {
    /// @cond
-   typedef vector                   self_t;
    typedef container_detail::vector_alloc_holder base_t;
    typedef allocator_traits            allocator_traits_type;
    /// @endcond
    public:
-   //! The type of object, T, stored in the vector
-   typedef T                                                value_type;
-   //! Pointer to T
-   typedef typename allocator_traits_type::pointer          pointer;
-   //! Const pointer to T
-   typedef typename allocator_traits_type::const_pointer    const_pointer;
-   //! Reference to T
-   typedef typename allocator_traits_type::reference        reference;
-   //! Const reference to T
-   typedef typename allocator_traits_type::const_reference  const_reference;
-   //! An unsigned integral type
-   typedef typename allocator_traits_type::size_type        size_type;
-   //! A signed integral type
-   typedef typename allocator_traits_type::difference_type  difference_type;
-   //! The allocator type
-   typedef A                                       allocator_type;
-   //! The random access iterator
-   typedef container_detail::vector_iterator        iterator;
-   //! The random access const_iterator
-   typedef container_detail::vector_const_iterator  const_iterator;
+   //////////////////////////////////////////////
+   //
+   //                    types
+   //
+   //////////////////////////////////////////////
 
-   //! Iterator used to iterate backwards through a vector.
-   typedef std::reverse_iterator  
-      reverse_iterator;
-   //! Const iterator used to iterate backwards through a vector.
-   typedef std::reverse_iterator                
-      const_reverse_iterator;
-   //! The stored allocator type
-   typedef allocator_type                          stored_allocator_type;
+   typedef T                                                                        value_type;
+   typedef typename ::boost::container::allocator_traits::pointer                pointer;
+   typedef typename ::boost::container::allocator_traits::const_pointer          const_pointer;
+   typedef typename ::boost::container::allocator_traits::reference              reference;
+   typedef typename ::boost::container::allocator_traits::const_reference        const_reference;
+   typedef typename ::boost::container::allocator_traits::size_type              size_type;
+   typedef typename ::boost::container::allocator_traits::difference_type        difference_type;
+   typedef A                                                                        allocator_type;
+   typedef allocator_type                                                           stored_allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(container_detail::vector_iterator)       iterator;
+   typedef BOOST_CONTAINER_IMPDEF(container_detail::vector_const_iterator) const_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)                  reverse_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)            const_reverse_iterator;
 
    /// @cond
    private:
@@ -459,6 +448,11 @@ class vector : private container_detail::vector_alloc_holder
    /// @endcond
 
    public:
+   //////////////////////////////////////////////
+   //
+   //          construct/copy/destroy
+   //
+   //////////////////////////////////////////////
 
    //! Effects: Constructs a vector taking the allocator as parameter.
    //!
@@ -488,25 +482,7 @@ class vector : private container_detail::vector_alloc_holder
    //! Complexity: Linear to n.
    explicit vector(size_type n)
       :  base_t()
-   {
-      this->resize(n);
-/*
-      //Allocate
-      size_type real_cap = 0;
-      std::pair ret =
-         this->allocation_command(allocate_new, n, n, real_cap, this->members_.m_start);
-      T *new_mem = container_detail::to_raw_pointer(ret.first);
-      //Anti-exception rollback
-      typename value_traits::ArrayDeallocator scoped_alloc(new_mem, this->alloc(), real_cap);
-      //Default constructor
-      container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
-      proxy.uninitialized_copy_remaining_to(new_mem);
-      //All ok, commit
-      this->members_.m_start = ret.first;
-      this->members_.m_size  = n;
-      this->members_.m_capacity = real_cap;
-      scoped_alloc.release();*/
-   }
+   {  this->resize(n);  }
 
    //! Effects: Constructs a vector that will use a copy of allocator a
    //!   and inserts n copies of value.
@@ -517,10 +493,19 @@ class vector : private container_detail::vector_alloc_holder
    //! Complexity: Linear to n.
    vector(size_type n, const T& value, const allocator_type& a = allocator_type())
       :  base_t(a)
-   {
-      this->resize(n, value);
-//      this->insert(this->cend(), n, value);
-   }
+   {  this->resize(n, value); }
+
+   //! Effects: Constructs a vector that will use a copy of allocator a
+   //!   and inserts a copy of the range [first, last) in the vector.
+   //!
+   //! Throws: If allocator_type's default constructor or allocation
+   //!   throws or T's constructor taking an dereferenced InIt throws.
+   //!
+   //! Complexity: Linear to the range [first, last).
+   template 
+   vector(InIt first, InIt last, const allocator_type& a = allocator_type())
+      :  base_t(a)
+   {  this->assign(first, last); }
 
    //! Effects: Copy constructs a vector.
    //!
@@ -580,18 +565,6 @@ class vector : private container_detail::vector_alloc_holder
       }
    }
 
-   //! Effects: Constructs a vector that will use a copy of allocator a
-   //!   and inserts a copy of the range [first, last) in the vector.
-   //!
-   //! Throws: If allocator_type's default constructor or allocation
-   //!   throws or T's constructor taking an dereferenced InIt throws.
-   //!
-   //! Complexity: Linear to the range [first, last).
-   template 
-   vector(InIt first, InIt last, const allocator_type& a = allocator_type())
-      :  base_t(a)
-   {  this->assign(first, last); }
-
    //! Effects: Destroys the vector. All stored values are destroyed
    //!   and used memory is deallocated.
    //!
@@ -601,6 +574,141 @@ class vector : private container_detail::vector_alloc_holder
    ~vector() BOOST_CONTAINER_NOEXCEPT
    {} //vector_alloc_holder clears the data
 
+   //! Effects: Makes *this contain the same elements as x.
+   //!
+   //! Postcondition: this->size() == x.size(). *this contains a copy
+   //! of each of x's elements.
+   //!
+   //! Throws: If memory allocation throws or T's copy/move constructor/assignment throws.
+   //!
+   //! Complexity: Linear to the number of elements in x.
+   vector& operator=(BOOST_COPY_ASSIGN_REF(vector) x)
+   {
+      if (&x != this){
+         allocator_type &this_alloc     = this->alloc();
+         const allocator_type &x_alloc  = x.alloc();
+         container_detail::bool_ flag;
+         if(flag && this_alloc != x_alloc){
+            this->clear();
+            this->shrink_to_fit();
+         }
+         container_detail::assign_alloc(this_alloc, x_alloc, flag);
+         this->assign( container_detail::to_raw_pointer(x.members_.m_start)
+                     , container_detail::to_raw_pointer(x.members_.m_start + x.members_.m_size));
+      }
+      return *this;
+   }
+
+   //! Effects: Move assignment. All mx's values are transferred to *this.
+   //!
+   //! Postcondition: x.empty(). *this contains a the elements x had
+   //!   before the function.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Linear.
+   vector& operator=(BOOST_RV_REF(vector) x)
+      //iG BOOST_CONTAINER_NOEXCEPT_IF(!allocator_type::propagate_on_container_move_assignment::value || is_nothrow_move_assignable::value);)
+      BOOST_CONTAINER_NOEXCEPT
+   {
+      if (&x != this){
+         allocator_type &this_alloc = this->alloc();
+         allocator_type &x_alloc    = x.alloc();
+         //If allocators are equal we can just swap pointers
+         if(this_alloc == x_alloc){
+            //Destroy objects but retain memory in case x reuses it in the future
+            this->clear();
+            this->swap_members(x);
+            //Move allocator if needed
+            container_detail::bool_ flag;
+            container_detail::move_alloc(this_alloc, x_alloc, flag);
+         }
+         //If unequal allocators, then do a one by one move
+         else{
+            this->assign( boost::make_move_iterator(container_detail::to_raw_pointer(x.members_.m_start))
+                        , boost::make_move_iterator(container_detail::to_raw_pointer(x.members_.m_start + x.members_.m_size)));
+         }
+      }
+      return *this;
+   }
+
+   //! Effects: Assigns the the range [first, last) to *this.
+   //!
+   //! Throws: If memory allocation throws or T's copy/move constructor/assignment or
+   //!   T's constructor/assignment from dereferencing InpIt throws.
+   //!
+   //! Complexity: Linear to n.
+   template 
+   void assign(InIt first, InIt last
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+            //&& container_detail::is_input_iterator::value
+         >::type * = 0
+      #endif
+      )
+   {
+      //Overwrite all elements we can from [first, last)
+      iterator cur = this->begin();
+      for ( ; first != last && cur != end(); ++cur, ++first){
+         *cur = *first;
+      }
+
+      if (first == last){
+         //There are no more elements in the sequence, erase remaining
+         this->erase(cur, this->cend());
+      }
+      else{
+         //There are more elements in the range, insert the remaining ones
+         this->insert(this->cend(), first, last);
+      }
+   }
+
+   //! Effects: Assigns the n copies of val to *this.
+   //!
+   //! Throws: If memory allocation throws or
+   //!   T's copy/move constructor/assignment throws.
+   //!
+   //! Complexity: Linear to n.
+   void assign(size_type n, const value_type& val)
+   {  this->assign(cvalue_iterator(val, n), cvalue_iterator());   }
+
+   //! Effects: Returns a copy of the internal allocator.
+   //!
+   //! Throws: If allocator's copy constructor throws.
+   //!
+   //! Complexity: Constant.
+   allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
+   { return this->alloc();  }
+
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
+   const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
+   {  return this->alloc(); }
+
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
+   stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
+   {  return this->alloc(); }
+
+   //////////////////////////////////////////////
+   //
+   //                iterators
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Returns an iterator to the first element contained in the vector.
    //!
    //! Throws: Nothing.
@@ -703,67 +811,19 @@ class vector : private container_detail::vector_alloc_holder
    const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
    { return const_reverse_iterator(this->begin()); }
 
-   //! Requires: !empty()
-   //!
-   //! Effects: Returns a reference to the first
-   //!   element of the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   reference         front() BOOST_CONTAINER_NOEXCEPT
-   { return *this->members_.m_start; }
+   //////////////////////////////////////////////
+   //
+   //                capacity
+   //
+   //////////////////////////////////////////////
 
-   //! Requires: !empty()
-   //!
-   //! Effects: Returns a const reference to the first
-   //!   element of the container.
+   //! Effects: Returns true if the vector contains no elements.
    //!
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reference   front() const BOOST_CONTAINER_NOEXCEPT
-   { return *this->members_.m_start; }
-
-   //! Requires: !empty()
-   //!
-   //! Effects: Returns a reference to the last
-   //!   element of the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   reference         back() BOOST_CONTAINER_NOEXCEPT
-   { return this->members_.m_start[this->members_.m_size - 1]; }
-
-   //! Requires: !empty()
-   //!
-   //! Effects: Returns a const reference to the last
-   //!   element of the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_reference   back()  const BOOST_CONTAINER_NOEXCEPT
-   { return this->members_.m_start[this->members_.m_size - 1]; }
-
-   //! Returns: A pointer such that [data(),data() + size()) is a valid range.
-   //!   For a non-empty vector, data() == &front().
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   pointer data() BOOST_CONTAINER_NOEXCEPT
-   { return this->members_.m_start; }
-
-   //! Returns: A pointer such that [data(),data() + size()) is a valid range.
-   //!   For a non-empty vector, data() == &front().
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_pointer data()  const BOOST_CONTAINER_NOEXCEPT
-   { return this->members_.m_start; }
+   bool empty() const BOOST_CONTAINER_NOEXCEPT
+   { return !this->members_.m_size; }
 
    //! Effects: Returns the number of the elements contained in the vector.
    //!
@@ -781,6 +841,45 @@ class vector : private container_detail::vector_alloc_holder
    size_type max_size() const BOOST_CONTAINER_NOEXCEPT
    { return allocator_traits_type::max_size(this->alloc()); }
 
+   //! Effects: Inserts or erases elements at the end such that
+   //!   the size becomes n. New elements are default constructed.
+   //!
+   //! Throws: If memory allocation throws, or T's copy constructor throws.
+   //!
+   //! Complexity: Linear to the difference between size() and new_size.
+   void resize(size_type new_size)
+   {
+      if (new_size < this->size()){
+         //Destroy last elements
+         this->erase(const_iterator(this->members_.m_start + new_size), this->end());
+      }
+      else{
+         const size_type n = new_size - this->size();
+         this->reserve(new_size);
+         container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
+         this->priv_forward_range_insert(this->cend().get_ptr(), n, proxy);
+      }
+   }
+
+   //! Effects: Inserts or erases elements at the end such that
+   //!   the size becomes n. New elements are copy constructed from x.
+   //!
+   //! Throws: If memory allocation throws, or T's copy constructor throws.
+   //!
+   //! Complexity: Linear to the difference between size() and new_size.
+   void resize(size_type new_size, const T& x)
+   {
+      pointer finish = this->members_.m_start + this->members_.m_size;
+      if (new_size < size()){
+         //Destroy last elements
+         this->erase(const_iterator(this->members_.m_start + new_size), this->end());
+      }
+      else{
+         //Insert new elements at the end
+         this->insert(const_iterator(finish), new_size - this->size(), x);
+      }
+   }
+
    //! Effects: Number of elements for which memory has been allocated.
    //!   capacity() is always greater than or equal to size().
    //!
@@ -790,86 +889,6 @@ class vector : private container_detail::vector_alloc_holder
    size_type capacity() const BOOST_CONTAINER_NOEXCEPT
    { return this->members_.m_capacity; }
 
-   //! Effects: Returns true if the vector contains no elements.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   bool empty() const BOOST_CONTAINER_NOEXCEPT
-   { return !this->members_.m_size; }
-
-   //! Requires: size() > n.
-   //!
-   //! Effects: Returns a reference to the nth element
-   //!   from the beginning of the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   reference operator[](size_type n)        
-   { return this->members_.m_start[n]; }
-
-   //! Requires: size() > n.
-   //!
-   //! Effects: Returns a const reference to the nth element
-   //!   from the beginning of the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT
-   { return this->members_.m_start[n]; }
-
-   //! Requires: size() > n.
-   //!
-   //! Effects: Returns a reference to the nth element
-   //!   from the beginning of the container.
-   //!
-   //! Throws: std::range_error if n >= size()
-   //!
-   //! Complexity: Constant.
-   reference at(size_type n)
-   { this->priv_check_range(n); return this->members_.m_start[n]; }
-
-   //! Requires: size() > n.
-   //!
-   //! Effects: Returns a const reference to the nth element
-   //!   from the beginning of the container.
-   //!
-   //! Throws: std::range_error if n >= size()
-   //!
-   //! Complexity: Constant.
-   const_reference at(size_type n) const
-   { this->priv_check_range(n); return this->members_.m_start[n]; }
-
-   //! Effects: Returns a copy of the internal allocator.
-   //!
-   //! Throws: If allocator's copy constructor throws.
-   //!
-   //! Complexity: Constant.
-   allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
-   { return this->alloc();  }
-
-   //! Effects: Returns a reference to the internal allocator.
-   //!
-   //! Throws: Nothing
-   //!
-   //! Complexity: Constant.
-   //!
-   //! Note: Non-standard extension.
-   const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
-   {  return this->alloc(); }
-
-   //! Effects: Returns a reference to the internal allocator.
-   //!
-   //! Throws: Nothing
-   //!
-   //! Complexity: Constant.
-   //!
-   //! Note: Non-standard extension.
-   stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
-   {  return this->alloc(); }
-
    //! Effects: If n is less than or equal to capacity(), this call has no
    //!   effect. Otherwise, it is a request for allocation of additional memory.
    //!   If the request is successful, then capacity() is greater than or equal to
@@ -931,251 +950,138 @@ class vector : private container_detail::vector_alloc_holder
       }
    }
 
-   //! Effects: Makes *this contain the same elements as x.
+   //! Effects: Tries to deallocate the excess of memory created
+   //!   with previous allocations. The size of the vector is unchanged
    //!
-   //! Postcondition: this->size() == x.size(). *this contains a copy
-   //! of each of x's elements.
+   //! Throws: If memory allocation throws, or T's copy/move constructor throws.
    //!
-   //! Throws: If memory allocation throws or T's copy/move constructor/assignment throws.
-   //!
-   //! Complexity: Linear to the number of elements in x.
-   vector& operator=(BOOST_COPY_ASSIGN_REF(vector) x)
-   {
-      if (&x != this){
-         allocator_type &this_alloc     = this->alloc();
-         const allocator_type &x_alloc  = x.alloc();
-         container_detail::bool_ flag;
-         if(flag && this_alloc != x_alloc){
-            this->clear();
-            this->shrink_to_fit();
-         }
-         container_detail::assign_alloc(this_alloc, x_alloc, flag);
-         this->assign( container_detail::to_raw_pointer(x.members_.m_start)
-                     , container_detail::to_raw_pointer(x.members_.m_start + x.members_.m_size));
-      }
-      return *this;
-   }
+   //! Complexity: Linear to size().
+   void shrink_to_fit()
+   {  priv_shrink_to_fit(alloc_version());   }
 
-   //! Effects: Move assignment. All mx's values are transferred to *this.
-   //!
-   //! Postcondition: x.empty(). *this contains a the elements x had
-   //!   before the function.
-   //!
-   //! Throws: Nothing
-   //!
-   //! Complexity: Linear.
-   vector& operator=(BOOST_RV_REF(vector) x)
-      //iG BOOST_CONTAINER_NOEXCEPT_IF(!allocator_type::propagate_on_container_move_assignment::value || is_nothrow_move_assignable::value);)
-      BOOST_CONTAINER_NOEXCEPT
-   {
-      if (&x != this){
-         allocator_type &this_alloc = this->alloc();
-         allocator_type &x_alloc    = x.alloc();
-         //If allocators are equal we can just swap pointers
-         if(this_alloc == x_alloc){
-            //Destroy objects but retain memory in case x reuses it in the future
-            this->clear();
-            this->swap_members(x);
-            //Move allocator if needed
-            container_detail::bool_ flag;
-            container_detail::move_alloc(this_alloc, x_alloc, flag);
-         }
-         //If unequal allocators, then do a one by one move
-         else{
-            this->assign( boost::make_move_iterator(container_detail::to_raw_pointer(x.members_.m_start))
-                        , boost::make_move_iterator(container_detail::to_raw_pointer(x.members_.m_start + x.members_.m_size)));
-         }
-      }
-      return *this;
-   }
+   //////////////////////////////////////////////
+   //
+   //               element access
+   //
+   //////////////////////////////////////////////
 
-   //! Effects: Assigns the n copies of val to *this.
+   //! Requires: !empty()
    //!
-   //! Throws: If memory allocation throws or
-   //!   T's copy/move constructor/assignment throws.
+   //! Effects: Returns a reference to the first
+   //!   element of the container.
    //!
-   //! Complexity: Linear to n.
-   void assign(size_type n, const value_type& val)
-   {  this->assign(cvalue_iterator(val, n), cvalue_iterator());   }
-
-   //! Effects: Assigns the the range [first, last) to *this.
+   //! Throws: Nothing.
    //!
-   //! Throws: If memory allocation throws or T's copy/move constructor/assignment or
-   //!   T's constructor/assignment from dereferencing InpIt throws.
+   //! Complexity: Constant.
+   reference         front() BOOST_CONTAINER_NOEXCEPT
+   { return *this->members_.m_start; }
+
+   //! Requires: !empty()
    //!
-   //! Complexity: Linear to n.
-   template 
-   void assign(InIt first, InIt last
-      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-      , typename container_detail::enable_if_c
-         < !container_detail::is_convertible::value
-            && container_detail::is_input_iterator::value
-         >::type * = 0
-      #endif
-      )
-   {
-      //Overwrite all elements we can from [first, last)
-      iterator cur = begin();
-      for ( ; first != last && cur != end(); ++cur, ++first){
-         *cur = *first;
-      }
-
-      if (first == last){
-         //There are no more elements in the sequence, erase remaining
-         this->erase(cur, cend());
-      }
-      else{
-         //There are more elements in the range, insert the remaining ones
-         this->insert(this->cend(), first, last);
-      }
-   }
-
-   #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   template 
-   void assign(FwdIt first, FwdIt last
-      , typename container_detail::enable_if_c
-         < !container_detail::is_convertible::value
-            && !container_detail::is_input_iterator::value
-         >::type * = 0
-      )
-   {
-      const size_type n = std::distance(first, last);
-      
-      if(!n){
-         this->prot_destroy_all();
-         return;
-      }
-      //Check if we have enough memory or try to expand current memory
-      size_type remaining = this->members_.m_capacity - this->members_.m_size;
-      bool same_buffer_start;
-      std::pair ret;
-      size_type real_cap = this->members_.m_capacity;
-
-      if (n <= remaining){
-         same_buffer_start = true;
-      }
-      else{
-         //There is not enough memory, allocate a new buffer
-         size_type new_cap = this->next_capacity(n);
-         ret = this->allocation_command
-               (allocate_new | expand_fwd | expand_bwd,
-                  this->size() + n, new_cap, real_cap, this->members_.m_start);
-         same_buffer_start = ret.second && this->members_.m_start == ret.first;
-         if(same_buffer_start){
-            this->members_.m_capacity  = real_cap;
-         }
-      }
-     
-      if(same_buffer_start){
-         T *start = container_detail::to_raw_pointer(this->members_.m_start);
-         if (this->size() >= n){
-            //There is memory, but there are more old elements than new ones
-            //Overwrite old elements with new ones
-            std::copy(first, last, start);
-            //Destroy remaining old elements
-            this->destroy_n(start + n, this->members_.m_size - n);
-            this->members_.m_size = n;
-         }
-         else{
-            //There is memory, but there are less old elements than new ones
-            //First overwrite some old elements with new ones
-            FwdIt mid = first;
-            std::advance(mid, this->size());
-            T *end = std::copy(first, mid, start);
-            //Initialize the remaining new elements in the uninitialized memory
-            ::boost::container::uninitialized_copy_or_move_alloc(this->alloc(), mid, last, end);
-            this->members_.m_size = n;
-         }
-      }
-      else if(!ret.second){
-         typename value_traits::ArrayDeallocator scoped_alloc(ret.first, this->alloc(), real_cap);
-         ::boost::container::uninitialized_copy_or_move_alloc(this->alloc(), first, last, container_detail::to_raw_pointer(ret.first));
-         scoped_alloc.release();
-         //Destroy and deallocate old buffer
-         if(this->members_.m_start != 0){
-            this->destroy_n(container_detail::to_raw_pointer(this->members_.m_start), this->members_.m_size);
-            this->alloc().deallocate(this->members_.m_start, this->members_.m_capacity);
-         }
-         this->members_.m_start     = ret.first;
-         this->members_.m_size      = n;
-         this->members_.m_capacity  = real_cap;
-      }
-      else{
-         //Backwards expansion
-         //If anything goes wrong, this object will destroy old objects
-         T *old_start         = container_detail::to_raw_pointer(this->members_.m_start);
-         size_type old_size   = this->members_.m_size;
-         typename value_traits::OldArrayDestructor old_values_destroyer(old_start, this->alloc(), old_size);
-         //If something goes wrong size will be 0
-         //but holding the whole buffer
-         this->members_.m_size  = 0;
-         this->members_.m_start = ret.first;
-         this->members_.m_capacity = real_cap;
-        
-         //Backup old buffer data
-         size_type old_offset    = old_start - container_detail::to_raw_pointer(ret.first);
-         size_type first_count   = container_detail::min_value(n, old_offset);
-
-         FwdIt mid = first;
-         std::advance(mid, first_count);
-         ::boost::container::uninitialized_copy_or_move_alloc
-            (this->alloc(), first, mid, container_detail::to_raw_pointer(ret.first));
-
-         if(old_offset > n){
-            //All old elements will be destroyed by "old_values_destroyer"
-            this->members_.m_size = n;
-         }
-         else{
-            //We have constructed objects from the new begin until
-            //the old end so release the rollback destruction
-            old_values_destroyer.release();
-            this->members_.m_start  = ret.first;
-            this->members_.m_size   = first_count + old_size;
-            //Now overwrite the old values
-            size_type second_count = container_detail::min_value(old_size, n - first_count);
-            FwdIt mid2 = mid;
-            std::advance(mid2, second_count);
-            std::copy(mid, mid2, old_start);
-           
-            //Check if we still have to append elements in the
-            //uninitialized end
-            if(second_count == old_size){
-               std::copy(mid2, last, old_start + old_size);
-            }
-            else{
-               //We have to destroy some old values
-               this->destroy_n
-                  (old_start + second_count, old_size - second_count);
-               this->members_.m_size = n;
-            }
-            this->members_.m_size = n;                       
-         }
-      }
-   }
-   #endif
-
-   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   //! Effects: Inserts a copy of x at the end of the vector.
+   //! Effects: Returns a const reference to the first
+   //!   element of the container.
    //!
-   //! Throws: If memory allocation throws or
-   //!   T's copy/move constructor throws.
+   //! Throws: Nothing.
    //!
-   //! Complexity: Amortized constant time.
-   void push_back(const T &x);
+   //! Complexity: Constant.
+   const_reference   front() const BOOST_CONTAINER_NOEXCEPT
+   { return *this->members_.m_start; }
 
-   //! Effects: Constructs a new element in the end of the vector
-   //!   and moves the resources of mx to this new element.
+   //! Requires: !empty()
    //!
-   //! Throws: If memory allocation throws or
-   //!   T's move constructor throws.
+   //! Effects: Returns a reference to the last
+   //!   element of the container.
    //!
-   //! Complexity: Amortized constant time.
-   void push_back(T &&x);
-   #else
-   BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
-   #endif
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   reference         back() BOOST_CONTAINER_NOEXCEPT
+   { return this->members_.m_start[this->members_.m_size - 1]; }
+
+   //! Requires: !empty()
+   //!
+   //! Effects: Returns a const reference to the last
+   //!   element of the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_reference   back()  const BOOST_CONTAINER_NOEXCEPT
+   { return this->members_.m_start[this->members_.m_size - 1]; }
+
+   //! Requires: size() > n.
+   //!
+   //! Effects: Returns a reference to the nth element
+   //!   from the beginning of the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   reference operator[](size_type n)        
+   { return this->members_.m_start[n]; }
+
+   //! Requires: size() > n.
+   //!
+   //! Effects: Returns a const reference to the nth element
+   //!   from the beginning of the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT
+   { return this->members_.m_start[n]; }
+
+   //! Requires: size() > n.
+   //!
+   //! Effects: Returns a reference to the nth element
+   //!   from the beginning of the container.
+   //!
+   //! Throws: std::range_error if n >= size()
+   //!
+   //! Complexity: Constant.
+   reference at(size_type n)
+   { this->priv_check_range(n); return this->members_.m_start[n]; }
+
+   //! Requires: size() > n.
+   //!
+   //! Effects: Returns a const reference to the nth element
+   //!   from the beginning of the container.
+   //!
+   //! Throws: std::range_error if n >= size()
+   //!
+   //! Complexity: Constant.
+   const_reference at(size_type n) const
+   { this->priv_check_range(n); return this->members_.m_start[n]; }
+
+   //////////////////////////////////////////////
+   //
+   //                 data access
+   //
+   //////////////////////////////////////////////
+
+   //! Returns: A pointer such that [data(),data() + size()) is a valid range.
+   //!   For a non-empty vector, data() == &front().
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   T* data() BOOST_CONTAINER_NOEXCEPT
+   { return container_detail::to_raw_pointer(this->members_.m_start); }
+
+   //! Returns: A pointer such that [data(),data() + size()) is a valid range.
+   //!   For a non-empty vector, data() == &front().
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const T * data()  const BOOST_CONTAINER_NOEXCEPT
+   { return container_detail::to_raw_pointer(this->members_.m_start); }
+
+   //////////////////////////////////////////////
+   //
+   //                modifiers
+   //
+   //////////////////////////////////////////////
 
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
    //! Effects: Inserts an object of type T constructed with
@@ -1259,21 +1165,28 @@ class vector : private container_detail::vector_alloc_holder
    #include BOOST_PP_LOCAL_ITERATE()
 
    #endif   //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
- 
-   //! Effects: Swaps the contents of *this and x.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   void swap(vector& x)
-   {
-      //Just swap internals
-      this->swap_members(x);
-      //And now the allocator
-      container_detail::bool_ flag;
-      container_detail::swap_alloc(this->alloc(), x.alloc(), flag);
-   }
 
+   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   //! Effects: Inserts a copy of x at the end of the vector.
+   //!
+   //! Throws: If memory allocation throws or
+   //!   T's copy/move constructor throws.
+   //!
+   //! Complexity: Amortized constant time.
+   void push_back(const T &x);
+
+   //! Effects: Constructs a new element in the end of the vector
+   //!   and moves the resources of mx to this new element.
+   //!
+   //! Throws: If memory allocation throws or
+   //!   T's move constructor throws.
+   //!
+   //! Complexity: Amortized constant time.
+   void push_back(T &&x);
+   #else
+   BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
+   #endif
+ 
    #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
    //! Requires: position must be a valid iterator of *this.
    //!
@@ -1298,6 +1211,18 @@ class vector : private container_detail::vector_alloc_holder
    BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator)
    #endif
 
+   //! Requires: p must be a valid iterator of *this.
+   //!
+   //! Effects: Insert n copies of x before pos.
+   //!
+   //! Returns: an iterator to the first inserted element or p if n is 0.
+   //!
+   //! Throws: If memory allocation throws or T's copy constructor throws.
+   //!
+   //! Complexity: Linear to n.
+   iterator insert(const_iterator p, size_type n, const T& x)
+   {  return this->insert(p, cvalue_iterator(x, n), cvalue_iterator());  }
+
    //! Requires: p must be a valid iterator of *this.
    //!
    //! Effects: Insert a copy of the [first, last) range before pos.
@@ -1344,18 +1269,6 @@ class vector : private container_detail::vector_alloc_holder
    }
    #endif
 
-   //! Requires: p must be a valid iterator of *this.
-   //!
-   //! Effects: Insert n copies of x before pos.
-   //!
-   //! Returns: an iterator to the first inserted element or p if n is 0.
-   //!
-   //! Throws: If memory allocation throws or T's copy constructor throws.
-   //!
-   //! Complexity: Linear to n.
-   iterator insert(const_iterator p, size_type n, const T& x)
-   {  return this->insert(p, cvalue_iterator(x, n), cvalue_iterator());  }
-
    //! Effects: Removes the last element from the vector.
    //!
    //! Throws: Nothing.
@@ -1407,43 +1320,18 @@ class vector : private container_detail::vector_alloc_holder
       return iterator(first.get_ptr());
    }
 
-   //! Effects: Inserts or erases elements at the end such that
-   //!   the size becomes n. New elements are copy constructed from x.
+   //! Effects: Swaps the contents of *this and x.
    //!
-   //! Throws: If memory allocation throws, or T's copy constructor throws.
+   //! Throws: Nothing.
    //!
-   //! Complexity: Linear to the difference between size() and new_size.
-   void resize(size_type new_size, const T& x)
+   //! Complexity: Constant.
+   void swap(vector& x)
    {
-      pointer finish = this->members_.m_start + this->members_.m_size;
-      if (new_size < size()){
-         //Destroy last elements
-         this->erase(const_iterator(this->members_.m_start + new_size), this->end());
-      }
-      else{
-         //Insert new elements at the end
-         this->insert(const_iterator(finish), new_size - this->size(), x);
-      }
-   }
-
-   //! Effects: Inserts or erases elements at the end such that
-   //!   the size becomes n. New elements are default constructed.
-   //!
-   //! Throws: If memory allocation throws, or T's copy constructor throws.
-   //!
-   //! Complexity: Linear to the difference between size() and new_size.
-   void resize(size_type new_size)
-   {
-      if (new_size < this->size()){
-         //Destroy last elements
-         this->erase(const_iterator(this->members_.m_start + new_size), this->end());
-      }
-      else{
-         const size_type n = new_size - this->size();
-         this->reserve(new_size);
-         container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
-         this->priv_forward_range_insert(this->cend().get_ptr(), n, proxy);
-      }
+      //Just swap internals
+      this->swap_members(x);
+      //And now the allocator
+      container_detail::bool_ flag;
+      container_detail::swap_alloc(this->alloc(), x.alloc(), flag);
    }
 
    //! Effects: Erases all the elements of the vector.
@@ -1454,15 +1342,6 @@ class vector : private container_detail::vector_alloc_holder
    void clear() BOOST_CONTAINER_NOEXCEPT
    {  this->prot_destroy_all();  }
 
-   //! Effects: Tries to deallocate the excess of memory created
-   //!   with previous allocations. The size of the vector is unchanged
-   //!
-   //! Throws: If memory allocation throws, or T's copy/move constructor throws.
-   //!
-   //! Complexity: Linear to size().
-   void shrink_to_fit()
-   {  priv_shrink_to_fit(alloc_version());   }
-
    /// @cond
 
    //Absolutely experimental. This function might change, disappear or simply crash!
diff --git a/proj/to-do.txt b/proj/to-do.txt
index 7cb2844..b548cbc 100644
--- a/proj/to-do.txt
+++ b/proj/to-do.txt
@@ -51,4 +51,111 @@ change virtual functions with pointers to avoid template instantiation for every
 
 Add hash for containers
 
-Add std:: hashing support
\ No newline at end of file
+Add std:: hashing support
+
+Take out from class definition iterators in slist & list
+
+Fix trivial destructor after move and other optimizing traits
+
+Define typedefs exactly like the standard to generate better documentation. for implementation defined types:
+   #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      #define BOOST_CONTAINER_IMPLDEF(TYPE) TYPE
+   #else
+      #define BOOST_CONTAINER_IMPLDEF(TYPE) implementation_defined
+   #endif
+Mark previous() in slist/and forward_list as non-standard
+
+Replace all insert_const_ref_type with BOOST_MOVE_CONVERSION_AWARE_CATCH_XXX
+
+
+
+Function order:
+
+----------type------------
+value_type;
+pointer;
+const_pointer;
+reference;
+const_reference;
+size_type;
+difference_type;
+allocator_type;
+stored_allocator_type;
+iterator;
+const_iterator;
+reverse_iterator;
+const_reverse_iterator;
+----------func------------
+container()
+container(allocator_type)
+container(size_type)
+container(size_type, value_type, allocator_type = ())
+container(InpIt, InpIt)
+container(const container &)
+container(container &&)
+container(const container &, allocator_type)
+container(container &&, allocator_type)
+container(initializer_list, allocator)
+~container()
+container operator=(const container &)
+container operator=(container &&)
+container operator=(initializer_list)
+assign(size_type, const T &)
+
+assign(InpIt, InptIt)
+assign(initializer_list)
+get_allocator()
+
+begin()
+begin() const
+end()
+end() const
+rbegin()
+rbegin() const
+rend()
+rend() const
+
+cbegin() const
+cend() const
+crbegin() const
+crend() const
+
+empty()
+size()
+max_size()
+resize(size_type)
+resize(size_type, cont T&)
+capacity()
+reserve(size_type)
+shrink_to_fit()
+
+front()
+front() const
+back()
+back() const
+operator[] ()
+operator[] ()const
+at()
+at() const
+
+
+data()
+data() const
+
+emplace_front()
+emplace_back()
+emplace()
+push_front(const T&)
+push_front(T&&)
+push_back(const T&)
+push_back(T&&)
+insert(iterator, const T &)
+insert(iterator, T &&)
+insert(size_type, const T &)
+insert(InpIt, InpIt)
+pop_front()
+pop_back()
+erase(const_iterator)
+erase(const_iterator, const_iterator)
+swap(container &)
+clear()
\ No newline at end of file

From 17e5e64dd6b59f5e3fcba91428a269f3bea52132 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Mon, 24 Sep 2012 10:27:53 +0000
Subject: [PATCH 53/93] Reordered sequence container types and functions to
 improve Doxygen documentation

[SVN r80687]
---
 include/boost/container/deque.hpp | 1148 +++++++++++++++--------------
 1 file changed, 580 insertions(+), 568 deletions(-)

diff --git a/include/boost/container/deque.hpp b/include/boost/container/deque.hpp
index c7f1aca..52b3b68 100644
--- a/include/boost/container/deque.hpp
+++ b/include/boost/container/deque.hpp
@@ -101,17 +101,17 @@ class deque_base
 {
    BOOST_COPYABLE_AND_MOVABLE(deque_base)
    public:
-   typedef allocator_traits                                     val_alloc_traits_type;
-   typedef typename val_alloc_traits_type::value_type              val_alloc_val;
-   typedef typename val_alloc_traits_type::pointer                 val_alloc_ptr;
-   typedef typename val_alloc_traits_type::const_pointer           val_alloc_cptr;
-   typedef typename val_alloc_traits_type::reference               val_alloc_ref;
-   typedef typename val_alloc_traits_type::const_reference         val_alloc_cref;
-   typedef typename val_alloc_traits_type::difference_type         val_alloc_diff;
-   typedef typename val_alloc_traits_type::size_type               val_alloc_size;
+   typedef allocator_traits                                    val_alloc_traits_type;
+   typedef typename val_alloc_traits_type::value_type             val_alloc_val;
+   typedef typename val_alloc_traits_type::pointer                val_alloc_ptr;
+   typedef typename val_alloc_traits_type::const_pointer          val_alloc_cptr;
+   typedef typename val_alloc_traits_type::reference              val_alloc_ref;
+   typedef typename val_alloc_traits_type::const_reference        val_alloc_cref;
+   typedef typename val_alloc_traits_type::difference_type        val_alloc_diff;
+   typedef typename val_alloc_traits_type::size_type              val_alloc_size;
    typedef typename val_alloc_traits_type::template
-      portable_rebind_alloc::type                   ptr_alloc_t;
-   typedef allocator_traits                           ptr_alloc_traits_type;
+      portable_rebind_alloc::type                  ptr_alloc_t;
+   typedef allocator_traits                          ptr_alloc_traits_type;
    typedef typename ptr_alloc_traits_type::value_type             ptr_alloc_val;
    typedef typename ptr_alloc_traits_type::pointer                ptr_alloc_ptr;
    typedef typename ptr_alloc_traits_type::const_pointer          ptr_alloc_cptr;
@@ -534,46 +534,35 @@ class deque : protected deque_base
    /// @cond
    private:
    typedef deque_base Base;
-   typedef typename Base::val_alloc_val            val_alloc_val;
-   typedef typename Base::val_alloc_ptr            val_alloc_ptr;
-   typedef typename Base::val_alloc_cptr           val_alloc_cptr;
-   typedef typename Base::val_alloc_ref            val_alloc_ref;
-   typedef typename Base::val_alloc_cref           val_alloc_cref;
-   typedef typename Base::val_alloc_size           val_alloc_size;
-   typedef typename Base::val_alloc_diff           val_alloc_diff;
-
-   typedef typename Base::ptr_alloc_t              ptr_alloc_t;
-   typedef typename Base::ptr_alloc_val            ptr_alloc_val;
-   typedef typename Base::ptr_alloc_ptr            ptr_alloc_ptr;
-   typedef typename Base::ptr_alloc_cptr           ptr_alloc_cptr;
-   typedef typename Base::ptr_alloc_ref            ptr_alloc_ref;
-   typedef typename Base::ptr_alloc_cref           ptr_alloc_cref;
    /// @endcond
 
-   public:                         // Basic types
-   typedef T                                    value_type;
-   typedef val_alloc_ptr                        pointer;
-   typedef val_alloc_cptr                       const_pointer;
-   typedef val_alloc_ref                        reference;
-   typedef val_alloc_cref                       const_reference;
-   typedef val_alloc_size                       size_type;
-   typedef val_alloc_diff                       difference_type;
-   typedef typename Base::allocator_type        allocator_type;
+   public:
 
-   public:                                // Iterators
-   typedef typename Base::iterator              iterator;
-   typedef typename Base::const_iterator        const_iterator;
+   //////////////////////////////////////////////
+   //
+   //                    types
+   //
+   //////////////////////////////////////////////
 
-   typedef std::reverse_iterator const_reverse_iterator;
-   typedef std::reverse_iterator      reverse_iterator;
-
-   typedef allocator_type                       stored_allocator_type;
+   typedef T                                                                  value_type;
+   typedef typename ::boost::container::allocator_traits::pointer          pointer;
+   typedef typename ::boost::container::allocator_traits::const_pointer    const_pointer;
+   typedef typename ::boost::container::allocator_traits::reference        reference;
+   typedef typename ::boost::container::allocator_traits::const_reference  const_reference;
+   typedef typename ::boost::container::allocator_traits::size_type        size_type;
+   typedef typename ::boost::container::allocator_traits::difference_type  difference_type;
+   typedef A                                                                  allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(allocator_type)                             stored_allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(typename Base::iterator)                    iterator;
+   typedef BOOST_CONTAINER_IMPDEF(typename Base::const_iterator)              const_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)            reverse_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)      const_reverse_iterator;
 
    /// @cond
 
    private:                      // Internal typedefs
    BOOST_COPYABLE_AND_MOVABLE(deque)
-   typedef ptr_alloc_ptr index_pointer;
+   typedef typename Base::ptr_alloc_ptr index_pointer;
    static size_type s_buffer_size()
       { return Base::s_buffer_size(); }
    typedef container_detail::advanced_insert_aux_int advanced_insert_aux_int_t;
@@ -584,248 +573,11 @@ class deque : protected deque_base
    /// @endcond
 
    public:
-
-   //! Effects: Returns a copy of the internal allocator.
-   //!
-   //! Throws: If allocator's copy constructor throws.
-   //!
-   //! Complexity: Constant.
-   allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
-   { return Base::alloc(); }
-
-   //! Effects: Returns a reference to the internal allocator.
-   //!
-   //! Throws: Nothing
-   //!
-   //! Complexity: Constant.
-   //!
-   //! Note: Non-standard extension.
-   const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
-   {  return Base::alloc(); }
-
-   //! Effects: Returns a reference to the internal allocator.
-   //!
-   //! Throws: Nothing
-   //!
-   //! Complexity: Constant.
-   //!
-   //! Note: Non-standard extension.
-   stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
-   {  return Base::alloc(); }
-
-   //! Effects: Returns an iterator to the first element contained in the deque.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   iterator begin() BOOST_CONTAINER_NOEXCEPT
-      { return this->members_.m_start; }
-
-   //! Effects: Returns an iterator to the end of the deque.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   iterator end() BOOST_CONTAINER_NOEXCEPT
-      { return this->members_.m_finish; }
-
-   //! Effects: Returns a const_iterator to the first element contained in the deque.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
-      { return this->members_.m_start; }
-
-   //! Effects: Returns a const_iterator to the end of the deque.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_iterator end() const BOOST_CONTAINER_NOEXCEPT
-      { return this->members_.m_finish; }
-
-   //! Effects: Returns a reverse_iterator pointing to the beginning
-   //! of the reversed deque.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT
-      { return reverse_iterator(this->members_.m_finish); }
-
-   //! Effects: Returns a reverse_iterator pointing to the end
-   //! of the reversed deque.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT
-      { return reverse_iterator(this->members_.m_start); }
-
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning
-   //! of the reversed deque.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
-      { return const_reverse_iterator(this->members_.m_finish); }
-
-   //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed deque.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT
-      { return const_reverse_iterator(this->members_.m_start); }
-
-   //! Effects: Returns a const_iterator to the first element contained in the deque.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
-      { return this->members_.m_start; }
-
-   //! Effects: Returns a const_iterator to the end of the deque.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
-      { return this->members_.m_finish; }
-
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning
-   //! of the reversed deque.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT
-      { return const_reverse_iterator(this->members_.m_finish); }
-
-   //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed deque.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
-      { return const_reverse_iterator(this->members_.m_start); }
-
-   //! Requires: size() > n.
-   //!
-   //! Effects: Returns a reference to the nth element
-   //!   from the beginning of the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT
-      { return this->members_.m_start[difference_type(n)]; }
-
-   //! Requires: size() > n.
-   //!
-   //! Effects: Returns a const reference to the nth element
-   //!   from the beginning of the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT
-      { return this->members_.m_start[difference_type(n)]; }
-
-   //! Requires: size() > n.
-   //!
-   //! Effects: Returns a reference to the nth element
-   //!   from the beginning of the container.
-   //!
-   //! Throws: std::range_error if n >= size()
-   //!
-   //! Complexity: Constant.
-   reference at(size_type n)
-      { this->priv_range_check(n); return (*this)[n]; }
-
-   //! Requires: size() > n.
-   //!
-   //! Effects: Returns a const reference to the nth element
-   //!   from the beginning of the container.
-   //!
-   //! Throws: std::range_error if n >= size()
-   //!
-   //! Complexity: Constant.
-   const_reference at(size_type n) const
-      { this->priv_range_check(n); return (*this)[n]; }
-
-   //! Requires: !empty()
-   //!
-   //! Effects: Returns a reference to the first
-   //!   element of the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   reference front() BOOST_CONTAINER_NOEXCEPT
-      { return *this->members_.m_start; }
-
-   //! Requires: !empty()
-   //!
-   //! Effects: Returns a const reference to the first element
-   //!   from the beginning of the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_reference front() const BOOST_CONTAINER_NOEXCEPT
-      { return *this->members_.m_start; }
-
-   //! Requires: !empty()
-   //!
-   //! Effects: Returns a reference to the last
-   //!   element of the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   reference back() BOOST_CONTAINER_NOEXCEPT
-      {  return *(end()-1); }
-
-   //! Requires: !empty()
-   //!
-   //! Effects: Returns a const reference to the last
-   //!   element of the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_reference back() const BOOST_CONTAINER_NOEXCEPT
-      {  return *(cend()-1);  }
-
-   //! Effects: Returns the number of the elements contained in the deque.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   size_type size() const BOOST_CONTAINER_NOEXCEPT
-      { return this->members_.m_finish - this->members_.m_start; }
-
-   //! Effects: Returns the largest possible size of the deque.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   size_type max_size() const BOOST_CONTAINER_NOEXCEPT
-      { return allocator_traits_type::max_size(this->alloc()); }
-
-   //! Effects: Returns true if the deque contains no elements.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   bool empty() const BOOST_CONTAINER_NOEXCEPT
-   { return this->members_.m_finish == this->members_.m_start; }
+   //////////////////////////////////////////////
+   //
+   //          construct/copy/destroy
+   //
+   //////////////////////////////////////////////
 
    //! Effects: Default constructors a deque.
    //!
@@ -872,6 +624,27 @@ class deque : protected deque_base
       : Base(n, a)
    { this->priv_fill_initialize(value); }
 
+   //! Effects: Constructs a deque that will use a copy of allocator a
+   //!   and inserts a copy of the range [first, last) in the deque.
+   //!
+   //! Throws: If allocator_type's default constructor or copy constructor
+   //!   throws or T's constructor taking an dereferenced InIt throws.
+   //!
+   //! Complexity: Linear to the range [first, last).
+   template 
+   deque(InIt first, InIt last, const allocator_type& a = allocator_type()
+      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+      , typename container_detail::enable_if_c
+         < !container_detail::is_convertible::value
+         >::type * = 0
+      #endif
+      )
+      : Base(a)
+   {
+      typedef typename std::iterator_traits::iterator_category ItCat;
+      this->priv_range_initialize(first, last, ItCat());
+   }
+
    //! Effects: Copy constructs a deque.
    //!
    //! Postcondition: x == *this.
@@ -936,27 +709,6 @@ class deque : protected deque_base
       }
    }
 
-   //! Effects: Constructs a deque that will use a copy of allocator a
-   //!   and inserts a copy of the range [first, last) in the deque.
-   //!
-   //! Throws: If allocator_type's default constructor or copy constructor
-   //!   throws or T's constructor taking an dereferenced InIt throws.
-   //!
-   //! Complexity: Linear to the range [first, last).
-   template 
-   deque(InIt first, InIt last, const allocator_type& a = allocator_type()
-      #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-      , typename container_detail::enable_if_c
-         < !container_detail::is_convertible::value
-         >::type * = 0
-      #endif
-      )
-      : Base(a)
-   {
-      typedef typename std::iterator_traits::iterator_category ItCat;
-      this->priv_range_initialize(first, last, ItCat());
-   }
-
    //! Effects: Destroys the deque. All stored values are destroyed
    //!   and used memory is deallocated.
    //!
@@ -1028,19 +780,6 @@ class deque : protected deque_base
       return *this;
    }
 
-   //! Effects: Swaps the contents of *this and x.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   void swap(deque &x)
-   {
-      this->swap_members(x);
-      container_detail::bool_ flag;
-      container_detail::swap_alloc(this->alloc(), x.alloc(), flag);
-      container_detail::swap_alloc(this->ptr_alloc(), x.ptr_alloc(), flag);
-   }
-
    //! Effects: Assigns the n copies of val to *this.
    //!
    //! Throws: If memory allocation throws or T's copy constructor throws.
@@ -1068,15 +807,15 @@ class deque : protected deque_base
       #endif
       )
    {
-      iterator cur = begin();
+      iterator cur = this->begin();
       for ( ; first != last && cur != end(); ++cur, ++first){
          *cur = *first;
       }
       if (first == last){
-         this->erase(cur, cend());
+         this->erase(cur, this->cend());
       }
       else{
-         this->insert(cend(), first, last);
+         this->insert(this->cend(), first, last);
       }
    }
 
@@ -1092,35 +831,473 @@ class deque : protected deque_base
       const size_type len = std::distance(first, last);
       if (len > size()) {
          FwdIt mid = first;
-         std::advance(mid, size());
+         std::advance(mid, this->size());
          boost::copy_or_move(first, mid, begin());
-         this->insert(cend(), mid, last);
+         this->insert(this->cend(), mid, last);
       }
       else{
-         this->erase(boost::copy_or_move(first, last, begin()), cend());
+         this->erase(boost::copy_or_move(first, last, this->begin()), cend());
       }
    }
    #endif
 
-   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   //! Effects: Inserts a copy of x at the end of the deque.
+   //! Effects: Returns a copy of the internal allocator.
    //!
-   //! Throws: If memory allocation throws or
-   //!   T's copy constructor throws.
+   //! Throws: If allocator's copy constructor throws.
    //!
-   //! Complexity: Amortized constant time.
-   void push_back(const T &x);
+   //! Complexity: Constant.
+   allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
+   { return Base::alloc(); }
 
-   //! Effects: Constructs a new element in the end of the deque
-   //!   and moves the resources of mx to this new element.
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
+   const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
+   {  return Base::alloc(); }
+
+   //////////////////////////////////////////////
+   //
+   //                iterators
+   //
+   //////////////////////////////////////////////
+
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
+   stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
+   {  return Base::alloc(); }
+
+   //! Effects: Returns an iterator to the first element contained in the deque.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   iterator begin() BOOST_CONTAINER_NOEXCEPT
+      { return this->members_.m_start; }
+
+   //! Effects: Returns a const_iterator to the first element contained in the deque.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
+      { return this->members_.m_start; }
+
+   //! Effects: Returns an iterator to the end of the deque.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   iterator end() BOOST_CONTAINER_NOEXCEPT
+      { return this->members_.m_finish; }
+
+   //! Effects: Returns a const_iterator to the end of the deque.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_iterator end() const BOOST_CONTAINER_NOEXCEPT
+      { return this->members_.m_finish; }
+
+   //! Effects: Returns a reverse_iterator pointing to the beginning
+   //! of the reversed deque.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT
+      { return reverse_iterator(this->members_.m_finish); }
+
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed deque.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
+      { return const_reverse_iterator(this->members_.m_finish); }
+
+   //! Effects: Returns a reverse_iterator pointing to the end
+   //! of the reversed deque.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT
+      { return reverse_iterator(this->members_.m_start); }
+
+   //! Effects: Returns a const_reverse_iterator pointing to the end
+   //! of the reversed deque.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT
+      { return const_reverse_iterator(this->members_.m_start); }
+
+   //! Effects: Returns a const_iterator to the first element contained in the deque.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
+      { return this->members_.m_start; }
+
+   //! Effects: Returns a const_iterator to the end of the deque.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
+      { return this->members_.m_finish; }
+
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed deque.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT
+      { return const_reverse_iterator(this->members_.m_finish); }
+
+   //! Effects: Returns a const_reverse_iterator pointing to the end
+   //! of the reversed deque.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
+      { return const_reverse_iterator(this->members_.m_start); }
+
+   //////////////////////////////////////////////
+   //
+   //                capacity
+   //
+   //////////////////////////////////////////////
+
+   //! Effects: Returns true if the deque contains no elements.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   bool empty() const BOOST_CONTAINER_NOEXCEPT
+   { return this->members_.m_finish == this->members_.m_start; }
+
+   //! Effects: Returns the number of the elements contained in the deque.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   size_type size() const BOOST_CONTAINER_NOEXCEPT
+      { return this->members_.m_finish - this->members_.m_start; }
+
+   //! Effects: Returns the largest possible size of the deque.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   size_type max_size() const BOOST_CONTAINER_NOEXCEPT
+      { return allocator_traits_type::max_size(this->alloc()); }
+
+   //! Effects: Inserts or erases elements at the end such that
+   //!   the size becomes n. New elements are default constructed.
+   //!
+   //! Throws: If memory allocation throws, or T's copy constructor throws.
+   //!
+   //! Complexity: Linear to the difference between size() and new_size.
+   void resize(size_type new_size)
+   {
+      const size_type len = size();
+      if (new_size < len)
+         this->priv_erase_last_n(len - new_size);
+      else{
+         const size_type n = new_size - this->size();
+         container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
+         priv_insert_back_aux_impl(n, proxy);
+      }
+   }
+
+   //! Effects: Inserts or erases elements at the end such that
+   //!   the size becomes n. New elements are copy constructed from x.
+   //!
+   //! Throws: If memory allocation throws, or T's copy constructor throws.
+   //!
+   //! Complexity: Linear to the difference between size() and new_size.
+   void resize(size_type new_size, const value_type& x)
+   {
+      const size_type len = size();
+      if (new_size < len)
+         this->erase(this->members_.m_start + new_size, this->members_.m_finish);
+      else
+         this->insert(this->members_.m_finish, new_size - len, x);
+   }
+
+   //! Effects: Tries to deallocate the excess of memory created
+   //!   with previous allocations. The size of the deque is unchanged
    //!
    //! Throws: If memory allocation throws.
    //!
-   //! Complexity: Amortized constant time.
-   void push_back(T &&x);
-   #else
-   BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
-   #endif
+   //! Complexity: Constant.
+   void shrink_to_fit()
+   {
+      //This deque implementation already
+      //deallocates excess nodes when erasing
+      //so there is nothing to do except for
+      //empty deque
+      if(this->empty()){
+         this->priv_clear_map();
+      }
+   }
+
+   //////////////////////////////////////////////
+   //
+   //               element access
+   //
+   //////////////////////////////////////////////
+
+   //! Requires: !empty()
+   //!
+   //! Effects: Returns a reference to the first
+   //!   element of the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   reference front() BOOST_CONTAINER_NOEXCEPT
+      { return *this->members_.m_start; }
+
+   //! Requires: !empty()
+   //!
+   //! Effects: Returns a const reference to the first element
+   //!   from the beginning of the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_reference front() const BOOST_CONTAINER_NOEXCEPT
+      { return *this->members_.m_start; }
+
+   //! Requires: !empty()
+   //!
+   //! Effects: Returns a reference to the last
+   //!   element of the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   reference back() BOOST_CONTAINER_NOEXCEPT
+      {  return *(end()-1); }
+
+   //! Requires: !empty()
+   //!
+   //! Effects: Returns a const reference to the last
+   //!   element of the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_reference back() const BOOST_CONTAINER_NOEXCEPT
+      {  return *(cend()-1);  }
+
+   //! Requires: size() > n.
+   //!
+   //! Effects: Returns a reference to the nth element
+   //!   from the beginning of the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT
+      { return this->members_.m_start[difference_type(n)]; }
+
+   //! Requires: size() > n.
+   //!
+   //! Effects: Returns a const reference to the nth element
+   //!   from the beginning of the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT
+      { return this->members_.m_start[difference_type(n)]; }
+
+   //! Requires: size() > n.
+   //!
+   //! Effects: Returns a reference to the nth element
+   //!   from the beginning of the container.
+   //!
+   //! Throws: std::range_error if n >= size()
+   //!
+   //! Complexity: Constant.
+   reference at(size_type n)
+      { this->priv_range_check(n); return (*this)[n]; }
+
+   //! Requires: size() > n.
+   //!
+   //! Effects: Returns a const reference to the nth element
+   //!   from the beginning of the container.
+   //!
+   //! Throws: std::range_error if n >= size()
+   //!
+   //! Complexity: Constant.
+   const_reference at(size_type n) const
+      { this->priv_range_check(n); return (*this)[n]; }
+
+   //////////////////////////////////////////////
+   //
+   //                modifiers
+   //
+   //////////////////////////////////////////////
+
+   #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+   //! Effects: Inserts an object of type T constructed with
+   //!   std::forward(args)... in the beginning of the deque.
+   //!
+   //! Throws: If memory allocation throws or the in-place constructor throws.
+   //!
+   //! Complexity: Amortized constant time
+   template 
+   void emplace_front(Args&&... args)
+   {
+      if(this->priv_push_front_simple_available()){
+         allocator_traits_type::construct
+            ( this->alloc()
+            , this->priv_push_front_simple_pos()
+            , boost::forward(args)...);
+         this->priv_push_front_simple_commit();
+      }
+      else{
+         typedef container_detail::advanced_insert_aux_non_movable_emplace type;
+         type &&proxy = type(this->alloc(), boost::forward(args)...);
+         this->priv_insert_front_aux_impl(1, proxy);
+      }
+   }
+
+   //! Effects: Inserts an object of type T constructed with
+   //!   std::forward(args)... in the end of the deque.
+   //!
+   //! Throws: If memory allocation throws or the in-place constructor throws.
+   //!
+   //! Complexity: Amortized constant time
+   template 
+   void emplace_back(Args&&... args)
+   {
+      if(this->priv_push_back_simple_available()){
+         allocator_traits_type::construct
+            ( this->alloc()
+            , this->priv_push_back_simple_pos()
+            , boost::forward(args)...);
+         this->priv_push_back_simple_commit();
+      }
+      else{
+         typedef container_detail::advanced_insert_aux_non_movable_emplace type;
+         type &&proxy = type(this->alloc(), boost::forward(args)...);
+         this->priv_insert_back_aux_impl(1, proxy);
+      }
+   }
+
+   //! Requires: position must be a valid iterator of *this.
+   //!
+   //! Effects: Inserts an object of type T constructed with
+   //!   std::forward(args)... before position
+   //!
+   //! Throws: If memory allocation throws or the in-place constructor throws.
+   //!
+   //! Complexity: If position is end(), amortized constant time
+   //!   Linear time otherwise.
+   template 
+   iterator emplace(const_iterator p, Args&&... args)
+   {
+      if(p == this->cbegin()){
+         this->emplace_front(boost::forward(args)...);
+         return this->begin();
+      }
+      else if(p == this->cend()){
+         this->emplace_back(boost::forward(args)...);
+         return (this->end()-1);
+      }
+      else{
+         typedef container_detail::advanced_insert_aux_emplace type;
+         type &&proxy = type(this->alloc(), boost::forward(args)...);
+         return this->priv_insert_aux_impl(p, 1, proxy);
+      }
+   }
+
+   #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
+
+   //advanced_insert_int.hpp includes all necessary preprocessor machinery...
+   #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, _))                    \
+   {                                                                                         \
+      if(priv_push_front_simple_available()){                                                \
+         allocator_traits_type::construct                                                    \
+            ( this->alloc()                                                                  \
+            , this->priv_push_front_simple_pos()                                             \
+              BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));               \
+         priv_push_front_simple_commit();                                                    \
+      }                                                                                      \
+      else{                                                                                  \
+         container_detail::BOOST_PP_CAT(BOOST_PP_CAT                                         \
+            (advanced_insert_aux_non_movable_emplace, n), arg)                               \
+                proxy                       \
+            (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));  \
+         priv_insert_front_aux_impl(1, proxy);                                               \
+      }                                                                                      \
+   }                                                                                         \
+                                                                                             \
+   BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >)    \
+   void emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                     \
+   {                                                                                         \
+      if(priv_push_back_simple_available()){                                                 \
+         allocator_traits_type::construct                                                    \
+            ( this->alloc()                                                                  \
+            , this->priv_push_back_simple_pos()                                              \
+              BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));               \
+         priv_push_back_simple_commit();                                                     \
+      }                                                                                      \
+      else{                                                                                  \
+         container_detail::BOOST_PP_CAT(BOOST_PP_CAT(                                        \
+            advanced_insert_aux_non_movable_emplace, n), arg)                                \
+                proxy                       \
+            (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));  \
+         priv_insert_back_aux_impl(1, proxy);                                                \
+      }                                                                                      \
+   }                                                                                         \
+                                                                                             \
+   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, _))             \
+   {                                                                                         \
+      if(p == this->cbegin()){                                                               \
+         this->emplace_front(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));         \
+         return this->begin();                                                               \
+      }                                                                                      \
+      else if(p == cend()){                                                                  \
+         this->emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));          \
+         return (this->end()-1);                                                             \
+      }                                                                                      \
+      else{                                                                                  \
+         container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)   \
+             proxy                          \
+            (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));  \
+         return this->priv_insert_aux_impl(p, 1, proxy);                                     \
+      }                                                                                      \
+   }                                                                                         \
+   //!
+   #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
+   #include BOOST_PP_LOCAL_ITERATE()
+
+   #endif   //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
    #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
    //! Effects: Inserts a copy of x at the front of the deque.
@@ -1142,41 +1319,25 @@ class deque : protected deque_base
    BOOST_MOVE_CONVERSION_AWARE_CATCH(push_front, T, void, priv_push_front)
    #endif
 
-   //! Effects: Removes the last element from the deque.
+   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   //! Effects: Inserts a copy of x at the end of the deque.
    //!
-   //! Throws: Nothing.
+   //! Throws: If memory allocation throws or
+   //!   T's copy constructor throws.
    //!
-   //! Complexity: Constant time.
-   void pop_back() BOOST_CONTAINER_NOEXCEPT
-   {
-      if (this->members_.m_finish.m_cur != this->members_.m_finish.m_first) {
-         --this->members_.m_finish.m_cur;
-         allocator_traits_type::destroy
-            ( this->alloc()
-            , container_detail::to_raw_pointer(this->members_.m_finish.m_cur)
-            );
-      }
-      else
-         this->priv_pop_back_aux();
-   }
+   //! Complexity: Amortized constant time.
+   void push_back(const T &x);
 
-   //! Effects: Removes the first element from the deque.
+   //! Effects: Constructs a new element in the end of the deque
+   //!   and moves the resources of mx to this new element.
    //!
-   //! Throws: Nothing.
+   //! Throws: If memory allocation throws.
    //!
-   //! Complexity: Constant time.
-   void pop_front() BOOST_CONTAINER_NOEXCEPT
-   {
-      if (this->members_.m_start.m_cur != this->members_.m_start.m_last - 1) {
-         allocator_traits_type::destroy
-            ( this->alloc()
-            , container_detail::to_raw_pointer(this->members_.m_start.m_cur)
-            );
-         ++this->members_.m_start.m_cur;
-      }
-      else
-         this->priv_pop_front_aux();
-   }
+   //! Complexity: Amortized constant time.
+   void push_back(T &&x);
+   #else
+   BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
+   #endif
 
    #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
@@ -1268,179 +1429,40 @@ class deque : protected deque_base
    }
    #endif
 
-   #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-   //! Effects: Inserts an object of type T constructed with
-   //!   std::forward(args)... in the end of the deque.
+   //! Effects: Removes the first element from the deque.
    //!
-   //! Throws: If memory allocation throws or the in-place constructor throws.
+   //! Throws: Nothing.
    //!
-   //! Complexity: Amortized constant time
-   template 
-   void emplace_back(Args&&... args)
+   //! Complexity: Constant time.
+   void pop_front() BOOST_CONTAINER_NOEXCEPT
    {
-      if(this->priv_push_back_simple_available()){
-         allocator_traits_type::construct
+      if (this->members_.m_start.m_cur != this->members_.m_start.m_last - 1) {
+         allocator_traits_type::destroy
             ( this->alloc()
-            , this->priv_push_back_simple_pos()
-            , boost::forward(args)...);
-         this->priv_push_back_simple_commit();
+            , container_detail::to_raw_pointer(this->members_.m_start.m_cur)
+            );
+         ++this->members_.m_start.m_cur;
       }
-      else{
-         typedef container_detail::advanced_insert_aux_non_movable_emplace type;
-         type &&proxy = type(this->alloc(), boost::forward(args)...);
-         this->priv_insert_back_aux_impl(1, proxy);
-      }
-   }
-
-   //! Effects: Inserts an object of type T constructed with
-   //!   std::forward(args)... in the beginning of the deque.
-   //!
-   //! Throws: If memory allocation throws or the in-place constructor throws.
-   //!
-   //! Complexity: Amortized constant time
-   template 
-   void emplace_front(Args&&... args)
-   {
-      if(this->priv_push_front_simple_available()){
-         allocator_traits_type::construct
-            ( this->alloc()
-            , this->priv_push_front_simple_pos()
-            , boost::forward(args)...);
-         this->priv_push_front_simple_commit();
-      }
-      else{
-         typedef container_detail::advanced_insert_aux_non_movable_emplace type;
-         type &&proxy = type(this->alloc(), boost::forward(args)...);
-         this->priv_insert_front_aux_impl(1, proxy);
-      }
-   }
-
-   //! Requires: position must be a valid iterator of *this.
-   //!
-   //! Effects: Inserts an object of type T constructed with
-   //!   std::forward(args)... before position
-   //!
-   //! Throws: If memory allocation throws or the in-place constructor throws.
-   //!
-   //! Complexity: If position is end(), amortized constant time
-   //!   Linear time otherwise.
-   template 
-   iterator emplace(const_iterator p, Args&&... args)
-   {
-      if(p == this->cbegin()){
-         this->emplace_front(boost::forward(args)...);
-         return this->begin();
-      }
-      else if(p == this->cend()){
-         this->emplace_back(boost::forward(args)...);
-         return (this->end()-1);
-      }
-      else{
-         typedef container_detail::advanced_insert_aux_emplace type;
-         type &&proxy = type(this->alloc(), boost::forward(args)...);
-         return this->priv_insert_aux_impl(p, 1, proxy);
-      }
-   }
-
-   #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-
-   //advanced_insert_int.hpp includes all necessary preprocessor machinery...
-   #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_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                     \
-   {                                                                                         \
-      if(priv_push_back_simple_available()){                                                 \
-         allocator_traits_type::construct                                                    \
-            ( this->alloc()                                                                  \
-            , this->priv_push_back_simple_pos()                                              \
-              BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));               \
-         priv_push_back_simple_commit();                                                     \
-      }                                                                                      \
-      else{                                                                                  \
-         container_detail::BOOST_PP_CAT(BOOST_PP_CAT(                                        \
-            advanced_insert_aux_non_movable_emplace, n), arg)                                \
-                proxy                       \
-            (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));  \
-         priv_insert_back_aux_impl(1, proxy);                                                \
-      }                                                                                      \
-   }                                                                                         \
-                                                                                             \
-   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, _))                    \
-   {                                                                                         \
-      if(priv_push_front_simple_available()){                                                \
-         allocator_traits_type::construct                                                    \
-            ( this->alloc()                                                                  \
-            , this->priv_push_front_simple_pos()                                             \
-              BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));               \
-         priv_push_front_simple_commit();                                                    \
-      }                                                                                      \
-      else{                                                                                  \
-         container_detail::BOOST_PP_CAT(BOOST_PP_CAT                                         \
-            (advanced_insert_aux_non_movable_emplace, n), arg)                               \
-                proxy                       \
-            (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));  \
-         priv_insert_front_aux_impl(1, proxy);                                               \
-      }                                                                                      \
-   }                                                                                         \
-                                                                                             \
-   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, _))             \
-   {                                                                                         \
-      if(p == this->cbegin()){                                                               \
-         this->emplace_front(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));         \
-         return this->begin();                                                               \
-      }                                                                                      \
-      else if(p == cend()){                                                                  \
-         this->emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));          \
-         return (this->end()-1);                                                             \
-      }                                                                                      \
-      else{                                                                                  \
-         container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)   \
-             proxy                          \
-            (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));  \
-         return this->priv_insert_aux_impl(p, 1, proxy);                                     \
-      }                                                                                      \
-   }                                                                                         \
-   //!
-   #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
-   #include BOOST_PP_LOCAL_ITERATE()
-
-   #endif   //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-
-   //! Effects: Inserts or erases elements at the end such that
-   //!   the size becomes n. New elements are copy constructed from x.
-   //!
-   //! Throws: If memory allocation throws, or T's copy constructor throws.
-   //!
-   //! Complexity: Linear to the difference between size() and new_size.
-   void resize(size_type new_size, const value_type& x)
-   {
-      const size_type len = size();
-      if (new_size < len)
-         this->erase(this->members_.m_start + new_size, this->members_.m_finish);
       else
-         this->insert(this->members_.m_finish, new_size - len, x);
+         this->priv_pop_front_aux();
    }
 
-   //! Effects: Inserts or erases elements at the end such that
-   //!   the size becomes n. New elements are default constructed.
+   //! Effects: Removes the last element from the deque.
    //!
-   //! Throws: If memory allocation throws, or T's copy constructor throws.
+   //! Throws: Nothing.
    //!
-   //! Complexity: Linear to the difference between size() and new_size.
-   void resize(size_type new_size)
+   //! Complexity: Constant time.
+   void pop_back() BOOST_CONTAINER_NOEXCEPT
    {
-      const size_type len = size();
-      if (new_size < len)
-         this->priv_erase_last_n(len - new_size);
-      else{
-         const size_type n = new_size - this->size();
-         container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
-         priv_insert_back_aux_impl(n, proxy);
+      if (this->members_.m_finish.m_cur != this->members_.m_finish.m_first) {
+         --this->members_.m_finish.m_cur;
+         allocator_traits_type::destroy
+            ( this->alloc()
+            , container_detail::to_raw_pointer(this->members_.m_finish.m_cur)
+            );
       }
+      else
+         this->priv_pop_back_aux();
    }
 
    //! Effects: Erases the element at position pos.
@@ -1504,18 +1526,17 @@ class deque : protected deque_base
       }
    }
 
-   void priv_erase_last_n(size_type n)
+   //! Effects: Swaps the contents of *this and x.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   void swap(deque &x)
    {
-      if(n == this->size()) {
-         this->clear();
-      }
-      else {
-         iterator new_finish = this->members_.m_finish - n;
-         if(!Base::traits_t::trivial_dctr_after_move)
-            this->priv_destroy_range(new_finish, this->members_.m_finish);
-         this->priv_destroy_nodes(new_finish.m_node + 1, this->members_.m_finish.m_node + 1);
-         this->members_.m_finish = new_finish;
-      }
+      this->swap_members(x);
+      container_detail::bool_ flag;
+      container_detail::swap_alloc(this->alloc(), x.alloc(), flag);
+      container_detail::swap_alloc(this->ptr_alloc(), x.ptr_alloc(), flag);
    }
 
    //! Effects: Erases all the elements of the deque.
@@ -1543,25 +1564,23 @@ class deque : protected deque_base
       this->members_.m_finish = this->members_.m_start;
    }
 
-   //! Effects: Tries to deallocate the excess of memory created
-   //!   with previous allocations. The size of the deque is unchanged
-   //!
-   //! Throws: If memory allocation throws.
-   //!
-   //! Complexity: Constant.
-   void shrink_to_fit()
+   /// @cond
+   private:
+
+   void priv_erase_last_n(size_type n)
    {
-      //This deque implementation already
-      //deallocates excess nodes when erasing
-      //so there is nothing to do except for
-      //empty deque
-      if(this->empty()){
-         this->priv_clear_map();
+      if(n == this->size()) {
+         this->clear();
+      }
+      else {
+         iterator new_finish = this->members_.m_finish - n;
+         if(!Base::traits_t::trivial_dctr_after_move)
+            this->priv_destroy_range(new_finish, this->members_.m_finish);
+         this->priv_destroy_nodes(new_finish.m_node + 1, this->members_.m_finish.m_node + 1);
+         this->members_.m_finish = new_finish;
       }
    }
 
-   /// @cond
-   private:
    void priv_range_check(size_type n) const
       {  if (n >= this->size())  BOOST_RETHROW std::out_of_range("deque");   }
 
@@ -1960,39 +1979,32 @@ class deque : protected deque_base
 
 // Nonmember functions.
 template 
-inline bool operator==(const deque& x,
-                       const deque& y)
+inline bool operator==(const deque& x, const deque& y)
 {
    return x.size() == y.size() && equal(x.begin(), x.end(), y.begin());
 }
 
 template 
-inline bool operator<(const deque& x,
-                      const deque& y)
+inline bool operator<(const deque& x, const deque& y)
 {
    return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
 }
 
 template 
-inline bool operator!=(const deque& x,
-                       const deque& y)
+inline bool operator!=(const deque& x, const deque& y)
    {  return !(x == y);   }
 
 template 
-inline bool operator>(const deque& x,
-                      const deque& y)
+inline bool operator>(const deque& x, const deque& y)
    {  return y < x; }
 
 template 
-inline bool operator<=(const deque& x,
-                       const deque& y)
-   {  return !(y < x); }
-
-template 
-inline bool operator>=(const deque& x,
-                       const deque& y)
+inline bool operator>=(const deque& x, const deque& y)
    {  return !(x < y); }
 
+template 
+inline bool operator<=(const deque& x, const deque& y)
+   {  return !(y < x); }
 
 template 
 inline void swap(deque& x, deque& y)

From 42974d17fc91609bdb1744253a04c36abe669351 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Fri, 28 Sep 2012 21:03:07 +0000
Subject: [PATCH 54/93] Doxygen documentation fixes

[SVN r80742]
---
 include/boost/container/flat_map.hpp | 659 ++++++++++++++++-----------
 include/boost/container/flat_set.hpp |  36 +-
 include/boost/container/list.hpp     |  16 +-
 include/boost/container/map.hpp      |  36 +-
 include/boost/container/set.hpp      |  32 +-
 include/boost/container/slist.hpp    |  10 +-
 include/boost/container/string.hpp   |   4 +-
 7 files changed, 498 insertions(+), 295 deletions(-)

diff --git a/include/boost/container/flat_map.hpp b/include/boost/container/flat_map.hpp
index 27f1074..24ee997 100644
--- a/include/boost/container/flat_map.hpp
+++ b/include/boost/container/flat_map.hpp
@@ -127,48 +127,54 @@ class flat_map
    typedef typename impl_tree_t::const_reverse_iterator  impl_const_reverse_iterator;
    typedef typename impl_tree_t::allocator_type          impl_allocator_type;
    typedef allocator_traits                           allocator_traits_type;
-
-
+   typedef container_detail::flat_tree_value_compare
+      < Pred
+      , container_detail::select1st< std::pair >
+      , std::pair >                                                value_compare_impl;
+   typedef typename container_detail::get_flat_tree_iterators
+         ::pointer>::iterator                 iterator_impl;
+   typedef typename container_detail::get_flat_tree_iterators
+      ::pointer>::const_iterator              const_iterator_impl;
+   typedef typename container_detail::get_flat_tree_iterators
+         ::pointer>::reverse_iterator         reverse_iterator_impl;
+   typedef typename container_detail::get_flat_tree_iterators
+         ::pointer>::const_reverse_iterator   const_reverse_iterator_impl;
 
    /// @endcond
 
    public:
 
-   // typedefs:
-   typedef Key                                              key_type;
-   typedef T                                                mapped_type;
-   typedef typename std::pair        value_type;
-   typedef typename allocator_traits_type::pointer          pointer;
-   typedef typename allocator_traits_type::const_pointer    const_pointer;
-   typedef typename allocator_traits_type::reference        reference;
-   typedef typename allocator_traits_type::const_reference  const_reference;
-   typedef typename impl_tree_t::size_type                  size_type;
-   typedef typename impl_tree_t::difference_type            difference_type;
-
-   typedef container_detail::flat_tree_value_compare
-      < Pred
-      , container_detail::select1st< std::pair >
-      , std::pair >                                 value_compare;
-   typedef Pred                                             key_compare;
-   typedef typename container_detail::
-      get_flat_tree_iterators::iterator            iterator;
-   typedef typename container_detail::
-      get_flat_tree_iterators::const_iterator      const_iterator;
-   typedef typename container_detail::
-      get_flat_tree_iterators
-         ::reverse_iterator                        reverse_iterator;
-   typedef typename container_detail::
-      get_flat_tree_iterators
-         ::const_reverse_iterator                  const_reverse_iterator;
-   typedef A                                                allocator_type;
-  
-   //!Standard extension
-   typedef A                                                stored_allocator_type;
-
-   //!Standard extension for C++03 compilers with non-movable std::pair
-   typedef impl_value_type                                  movable_value_type;
+   //////////////////////////////////////////////
+   //
+   //                    types
+   //
+   //////////////////////////////////////////////
+   typedef Key                                                             key_type;
+   typedef T                                                               mapped_type;
+   typedef typename std::pair                       value_type;
+   typedef typename boost::container::allocator_traits::pointer         pointer;
+   typedef typename boost::container::allocator_traits::const_pointer   const_pointer;
+   typedef typename boost::container::allocator_traits::reference       reference;
+   typedef typename boost::container::allocator_traits::const_reference const_reference;
+   typedef typename boost::container::allocator_traits::size_type       size_type;
+   typedef typename boost::container::allocator_traits::difference_type difference_type;
+   typedef A                                                               allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(A)                                       stored_allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(value_compare_impl)                      value_compare;
+   typedef Pred                                                            key_compare;
+   typedef BOOST_CONTAINER_IMPDEF(iterator_impl)                           iterator;
+   typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl)                     const_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(reverse_iterator_impl)                   reverse_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(const_reverse_iterator_impl)             const_reverse_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(impl_value_type)                         movable_value_type;
 
    public:
+   //////////////////////////////////////////////
+   //
+   //          construct/copy/destroy
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Default constructs an empty flat_map.
    //!
    //! Complexity: Constant.
@@ -255,20 +261,6 @@ class flat_map
    flat_map& operator=(BOOST_RV_REF(flat_map) mx)
    {  m_flat_tree = boost::move(mx.m_flat_tree);   return *this;  }
 
-   //! Effects: Returns the comparison object out
-   //!   of which a was constructed.
-   //!
-   //! Complexity: Constant.
-   key_compare key_comp() const
-      { return container_detail::force_copy(m_flat_tree.key_comp()); }
-
-   //! Effects: Returns an object of value_compare constructed out
-   //!   of the comparison object.
-   //!
-   //! Complexity: Constant.
-   value_compare value_comp() const
-      { return value_compare(container_detail::force_copy(m_flat_tree.key_comp())); }
-
    //! Effects: Returns a copy of the Allocator that
    //!   was passed to the object's constructor.
    //!
@@ -276,11 +268,31 @@ class flat_map
    allocator_type get_allocator() const
       { return container_detail::force_copy(m_flat_tree.get_allocator()); }
 
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
+   stored_allocator_type &get_stored_allocator()
+      { return container_detail::force(m_flat_tree.get_stored_allocator()); }
+
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
    const stored_allocator_type &get_stored_allocator() const
       { return container_detail::force(m_flat_tree.get_stored_allocator()); }
 
-   stored_allocator_type &get_stored_allocator()
-      { return container_detail::force(m_flat_tree.get_stored_allocator()); }
+   //////////////////////////////////////////////
+   //
+   //                iterators
+   //
+   //////////////////////////////////////////////
 
    //! Effects: Returns an iterator to the first element contained in the container.
    //!
@@ -384,6 +396,12 @@ class flat_map
    const_reverse_iterator crend() const
       { return container_detail::force_copy(m_flat_tree.crend()); }
 
+   //////////////////////////////////////////////
+   //
+   //                capacity
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Returns true if the container contains no elements.
    //!
    //! Throws: Nothing.
@@ -408,6 +426,42 @@ class flat_map
    size_type max_size() const
       { return m_flat_tree.max_size(); }
 
+   //! Effects: Number of elements for which memory has been allocated.
+   //!   capacity() is always greater than or equal to size().
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   size_type capacity() const          
+      { return m_flat_tree.capacity(); }
+
+   //! Effects: If n is less than or equal to capacity(), this call has no
+   //!   effect. Otherwise, it is a request for allocation of additional memory.
+   //!   If the request is successful, then capacity() is greater than or equal to
+   //!   n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
+   //!
+   //! Throws: If memory allocation allocation throws or T's copy constructor throws.
+   //!
+   //! Note: If capacity() is less than "count", iterators and references to
+   //!   to values might be invalidated.
+   void reserve(size_type count)      
+      { m_flat_tree.reserve(count);   }
+
+   //! Effects: Tries to deallocate the excess of memory created
+   //    with previous allocations. The size of the vector is unchanged
+   //!
+   //! Throws: If memory allocation throws, or T's copy constructor throws.
+   //!
+   //! Complexity: Linear to size().
+   void shrink_to_fit()
+      { m_flat_tree.shrink_to_fit(); }
+
+   //////////////////////////////////////////////
+   //
+   //               element access
+   //
+   //////////////////////////////////////////////
+
    #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
    //! Effects: If there is no key equivalent to x in the flat_map, inserts
    //!   value_type(x, T()) into the flat_map.
@@ -430,7 +484,9 @@ class flat_map
    #endif
 
    //! Returns: A reference to the element whose key is equivalent to x.
+   //!
    //! Throws: An exception object of type out_of_range if no such element is present.
+   //!
    //! Complexity: logarithmic.
    T& at(const key_type& k)
    {
@@ -442,7 +498,9 @@ class flat_map
    }
 
    //! Returns: A reference to the element whose key is equivalent to x.
+   //!
    //! Throws: An exception object of type out_of_range if no such element is present.
+   //!
    //! Complexity: logarithmic.
    const T& at(const key_type& k) const
    {
@@ -453,13 +511,69 @@ class flat_map
       return i->second;
    }
 
-   //! Effects: Swaps the contents of *this and x.
+   //////////////////////////////////////////////
+   //
+   //                modifiers
+   //
+   //////////////////////////////////////////////
+
+   #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+   //! Effects: Inserts an object x of type T constructed with
+   //!   std::forward(args)... if and only if there is no element in the container
+   //!   with key equivalent to the key of x.
    //!
-   //! Throws: Nothing.
+   //! Returns: The bool component of the returned pair is true if and only
+   //!   if the insertion takes place, and the iterator component of the pair
+   //!   points to the element with key equivalent to the key of x.
    //!
-   //! Complexity: Constant.
-   void swap(flat_map& x)
-   { m_flat_tree.swap(x.m_flat_tree); }
+   //! Complexity: Logarithmic search time plus linear insertion
+   //!   to the elements with bigger keys than x.
+   //!
+   //! Note: If an element is inserted it might invalidate elements.
+   template 
+   std::pair emplace(Args&&... args)
+   {  return container_detail::force_copy< std::pair >(m_flat_tree.emplace_unique(boost::forward(args)...)); }
+
+   //! Effects: Inserts an object of type T constructed with
+   //!   std::forward(args)... in the container if and only if there is
+   //!   no element in the container with key equivalent to the key of x.
+   //!   p is a hint pointing to where the insert should start to search.
+   //!
+   //! Returns: An iterator pointing to the element with key equivalent
+   //!   to the key of x.
+   //!
+   //! Complexity: Logarithmic search time (constant if x is inserted
+   //!   right before p) plus insertion linear to the elements with bigger keys than x.
+   //!
+   //! Note: If an element is inserted it might invalidate elements.
+   template 
+   iterator emplace_hint(const_iterator hint, Args&&... args)
+   {
+      return container_detail::force_copy
+         (m_flat_tree.emplace_hint_unique( container_detail::force_copy(hint)
+                                         , boost::forward(args)...));
+   }
+
+   #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, >)          \
+   std::pair emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))            \
+   {  return container_detail::force_copy< std::pair >                             \
+         (m_flat_tree.emplace_unique(BOOST_PP_ENUM(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_hint(const_iterator hint                                                       \
+                         BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _))              \
+   {  return container_detail::force_copy(m_flat_tree.emplace_hint_unique                \
+            (container_detail::force_copy(hint)                               \
+               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
 
    //! Effects: Inserts x if and only if there is no element in the container
    //!   with key equivalent to the key of x.
@@ -587,64 +701,6 @@ class flat_map
    void insert(ordered_unique_range_t, InputIterator first, InputIterator last)
       {  m_flat_tree.insert_unique(ordered_unique_range, first, last); }
 
-   #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-   //! Effects: Inserts an object x of type T constructed with
-   //!   std::forward(args)... if and only if there is no element in the container
-   //!   with key equivalent to the key of x.
-   //!
-   //! Returns: The bool component of the returned pair is true if and only
-   //!   if the insertion takes place, and the iterator component of the pair
-   //!   points to the element with key equivalent to the key of x.
-   //!
-   //! Complexity: Logarithmic search time plus linear insertion
-   //!   to the elements with bigger keys than x.
-   //!
-   //! Note: If an element is inserted it might invalidate elements.
-   template 
-   std::pair emplace(Args&&... args)
-   {  return container_detail::force_copy< std::pair >(m_flat_tree.emplace_unique(boost::forward(args)...)); }
-
-   //! Effects: Inserts an object of type T constructed with
-   //!   std::forward(args)... in the container if and only if there is
-   //!   no element in the container with key equivalent to the key of x.
-   //!   p is a hint pointing to where the insert should start to search.
-   //!
-   //! Returns: An iterator pointing to the element with key equivalent
-   //!   to the key of x.
-   //!
-   //! Complexity: Logarithmic search time (constant if x is inserted
-   //!   right before p) plus insertion linear to the elements with bigger keys than x.
-   //!
-   //! Note: If an element is inserted it might invalidate elements.
-   template 
-   iterator emplace_hint(const_iterator hint, Args&&... args)
-   {
-      return container_detail::force_copy
-         (m_flat_tree.emplace_hint_unique( container_detail::force_copy(hint)
-                                         , boost::forward(args)...));
-   }
-
-   #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, >)          \
-   std::pair emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))            \
-   {  return container_detail::force_copy< std::pair >                             \
-         (m_flat_tree.emplace_unique(BOOST_PP_ENUM(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_hint(const_iterator hint                                                       \
-                         BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _))              \
-   {  return container_detail::force_copy(m_flat_tree.emplace_hint_unique                \
-            (container_detail::force_copy(hint)                               \
-               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
-
    //! Effects: Erases the element pointed to by position.
    //!
    //! Returns: Returns an iterator pointing to the element immediately
@@ -685,6 +741,14 @@ class flat_map
                           , container_detail::force_copy(last)));
    }
 
+   //! Effects: Swaps the contents of *this and x.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   void swap(flat_map& x)
+   { m_flat_tree.swap(x.m_flat_tree); }
+
    //! Effects: erase(a.begin(),a.end()).
    //!
    //! Postcondition: size() == 0.
@@ -693,14 +757,31 @@ class flat_map
    void clear()
       { m_flat_tree.clear(); }
 
-   //! Effects: Tries to deallocate the excess of memory created
-   //    with previous allocations. The size of the vector is unchanged
+   //////////////////////////////////////////////
+   //
+   //                observers
+   //
+   //////////////////////////////////////////////
+
+   //! Effects: Returns the comparison object out
+   //!   of which a was constructed.
    //!
-   //! Throws: If memory allocation throws, or T's copy constructor throws.
+   //! Complexity: Constant.
+   key_compare key_comp() const
+      { return container_detail::force_copy(m_flat_tree.key_comp()); }
+
+   //! Effects: Returns an object of value_compare constructed out
+   //!   of the comparison object.
    //!
-   //! Complexity: Linear to size().
-   void shrink_to_fit()
-      { m_flat_tree.shrink_to_fit(); }
+   //! Complexity: Constant.
+   value_compare value_comp() const
+      { return value_compare(container_detail::force_copy(m_flat_tree.key_comp())); }
+
+   //////////////////////////////////////////////
+   //
+   //              map operations
+   //
+   //////////////////////////////////////////////
 
    //! Returns: An iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
@@ -762,27 +843,6 @@ class flat_map
    std::pair equal_range(const key_type& x) const
       {  return container_detail::force_copy >(m_flat_tree.equal_range(x)); }
 
-   //! Effects: Number of elements for which memory has been allocated.
-   //!   capacity() is always greater than or equal to size().
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   size_type capacity() const          
-      { return m_flat_tree.capacity(); }
-
-   //! Effects: If n is less than or equal to capacity(), this call has no
-   //!   effect. Otherwise, it is a request for allocation of additional memory.
-   //!   If the request is successful, then capacity() is greater than or equal to
-   //!   n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
-   //!
-   //! Throws: If memory allocation allocation throws or T's copy constructor throws.
-   //!
-   //! Note: If capacity() is less than "count", iterators and references to
-   //!   to values might be invalidated.
-   void reserve(size_type count)      
-      { m_flat_tree.reserve(count);   }
-
    /// @cond
    template 
    friend bool operator== (const flat_map&,
@@ -928,42 +988,51 @@ class flat_multimap
    typedef typename impl_tree_t::const_reverse_iterator  impl_const_reverse_iterator;
    typedef typename impl_tree_t::allocator_type          impl_allocator_type;
    typedef allocator_traits                           allocator_traits_type;
-
+   typedef container_detail::flat_tree_value_compare
+      < Pred
+      , container_detail::select1st< std::pair >
+      , std::pair >                                                value_compare_impl;
+   typedef typename container_detail::get_flat_tree_iterators
+         ::pointer>::iterator                 iterator_impl;
+   typedef typename container_detail::get_flat_tree_iterators
+      ::pointer>::const_iterator              const_iterator_impl;
+   typedef typename container_detail::get_flat_tree_iterators
+         ::pointer>::reverse_iterator         reverse_iterator_impl;
+   typedef typename container_detail::get_flat_tree_iterators
+         ::pointer>::const_reverse_iterator   const_reverse_iterator_impl;
    /// @endcond
 
    public:
 
-   // typedefs:
-   typedef Key                                              key_type;
-   typedef T                                                mapped_type;
-   typedef Pred                                             key_compare;
-   typedef typename std::pair        value_type;
-   typedef typename allocator_traits_type::pointer          pointer;
-   typedef typename allocator_traits_type::const_pointer    const_pointer;
-   typedef typename allocator_traits_type::reference        reference;
-   typedef typename allocator_traits_type::const_reference  const_reference;
-   typedef typename impl_tree_t::size_type                  size_type;
-   typedef typename impl_tree_t::difference_type            difference_type;
-   typedef container_detail::flat_tree_value_compare
-      < Pred
-      , container_detail::select1st< std::pair >
-      , std::pair >                                 value_compare;
+   //////////////////////////////////////////////
+   //
+   //                    types
+   //
+   //////////////////////////////////////////////
+   typedef Key                                                             key_type;
+   typedef T                                                               mapped_type;
+   typedef typename std::pair                       value_type;
+   typedef typename boost::container::allocator_traits::pointer         pointer;
+   typedef typename boost::container::allocator_traits::const_pointer   const_pointer;
+   typedef typename boost::container::allocator_traits::reference       reference;
+   typedef typename boost::container::allocator_traits::const_reference const_reference;
+   typedef typename boost::container::allocator_traits::size_type       size_type;
+   typedef typename boost::container::allocator_traits::difference_type difference_type;
+   typedef A                                                               allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(A)                                       stored_allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(value_compare_impl)                      value_compare;
+   typedef Pred                                                            key_compare;
+   typedef BOOST_CONTAINER_IMPDEF(iterator_impl)                           iterator;
+   typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl)                     const_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(reverse_iterator_impl)                   reverse_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(const_reverse_iterator_impl)             const_reverse_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(impl_value_type)                         movable_value_type;
 
-   typedef typename container_detail::
-      get_flat_tree_iterators::iterator            iterator;
-   typedef typename container_detail::
-      get_flat_tree_iterators::const_iterator      const_iterator;
-   typedef typename container_detail::
-      get_flat_tree_iterators
-         ::reverse_iterator                        reverse_iterator;
-   typedef typename container_detail::
-      get_flat_tree_iterators
-         ::const_reverse_iterator                  const_reverse_iterator;
-   typedef A                                                allocator_type;
-   //Non-standard extension
-   typedef A                                                stored_allocator_type;
-   //!Standard extension for C++03 compilers with non-movable std::pair
-   typedef impl_value_type                                  movable_value_type;
+   //////////////////////////////////////////////
+   //
+   //          construct/copy/destroy
+   //
+   //////////////////////////////////////////////
 
    //! Effects: Default constructs an empty flat_map.
    //!
@@ -1020,7 +1089,7 @@ class flat_multimap
    //! Postcondition: x is emptied.
    flat_multimap(BOOST_RV_REF(flat_multimap) x)
       : m_flat_tree(boost::move(x.m_flat_tree))
-   { }
+   {}
 
    //! Effects: Copy constructs a flat_multimap using the specified allocator.
    //!
@@ -1049,20 +1118,6 @@ class flat_multimap
    flat_multimap& operator=(BOOST_RV_REF(flat_multimap) mx)
       {  m_flat_tree = boost::move(mx.m_flat_tree);   return *this;  }
 
-   //! Effects: Returns the comparison object out
-   //!   of which a was constructed.
-   //!
-   //! Complexity: Constant.
-   key_compare key_comp() const
-      { return container_detail::force_copy(m_flat_tree.key_comp()); }
-
-   //! Effects: Returns an object of value_compare constructed out
-   //!   of the comparison object.
-   //!
-   //! Complexity: Constant.
-   value_compare value_comp() const
-      { return value_compare(container_detail::force_copy(m_flat_tree.key_comp())); }
-
    //! Effects: Returns a copy of the Allocator that
    //!   was passed to the object's constructor.
    //!
@@ -1070,11 +1125,31 @@ class flat_multimap
    allocator_type get_allocator() const
       { return container_detail::force_copy(m_flat_tree.get_allocator()); }
 
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
+   stored_allocator_type &get_stored_allocator()
+      { return container_detail::force(m_flat_tree.get_stored_allocator()); }
+
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
    const stored_allocator_type &get_stored_allocator() const
       { return container_detail::force(m_flat_tree.get_stored_allocator()); }
 
-   stored_allocator_type &get_stored_allocator()
-      { return container_detail::force(m_flat_tree.get_stored_allocator()); }
+   //////////////////////////////////////////////
+   //
+   //                iterators
+   //
+   //////////////////////////////////////////////
 
    //! Effects: Returns an iterator to the first element contained in the container.
    //!
@@ -1178,6 +1253,12 @@ class flat_multimap
    const_reverse_iterator crend() const
       { return container_detail::force_copy(m_flat_tree.crend()); }
 
+   //////////////////////////////////////////////
+   //
+   //                capacity
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Returns true if the container contains no elements.
    //!
    //! Throws: Nothing.
@@ -1202,13 +1283,94 @@ class flat_multimap
    size_type max_size() const
       { return m_flat_tree.max_size(); }
 
-   //! Effects: Swaps the contents of *this and x.
+   //! Effects: Number of elements for which memory has been allocated.
+   //!   capacity() is always greater than or equal to size().
    //!
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   void swap(flat_multimap& x)
-   { m_flat_tree.swap(x.m_flat_tree); }
+   size_type capacity() const          
+      { return m_flat_tree.capacity(); }
+
+   //! Effects: If n is less than or equal to capacity(), this call has no
+   //!   effect. Otherwise, it is a request for allocation of additional memory.
+   //!   If the request is successful, then capacity() is greater than or equal to
+   //!   n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
+   //!
+   //! Throws: If memory allocation allocation throws or T's copy constructor throws.
+   //!
+   //! Note: If capacity() is less than "count", iterators and references to
+   //!   to values might be invalidated.
+   void reserve(size_type count)      
+      { m_flat_tree.reserve(count);   }
+
+   //! Effects: Tries to deallocate the excess of memory created
+   //    with previous allocations. The size of the vector is unchanged
+   //!
+   //! Throws: If memory allocation throws, or T's copy constructor throws.
+   //!
+   //! Complexity: Linear to size().
+   void shrink_to_fit()
+      { m_flat_tree.shrink_to_fit(); }
+
+   //////////////////////////////////////////////
+   //
+   //                modifiers
+   //
+   //////////////////////////////////////////////
+
+   #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+   //! Effects: Inserts an object of type T constructed with
+   //!   std::forward(args)... and returns the iterator pointing to the
+   //!   newly inserted element.
+   //!
+   //! Complexity: Logarithmic search time plus linear insertion
+   //!   to the elements with bigger keys than x.
+   //!
+   //! Note: If an element is inserted it might invalidate elements.
+   template 
+   iterator emplace(Args&&... args)
+   {  return container_detail::force_copy(m_flat_tree.emplace_equal(boost::forward(args)...)); }
+
+   //! Effects: Inserts an object of type T constructed with
+   //!   std::forward(args)... in the container.
+   //!   p is a hint pointing to where the insert should start to search.
+   //!
+   //! Returns: An iterator pointing to the element with key equivalent
+   //!   to the key of x.
+   //!
+   //! Complexity: Logarithmic search time (constant time if the value
+   //!   is to be inserted before p) plus linear insertion
+   //!   to the elements with bigger keys than x.
+   //!
+   //! Note: If an element is inserted it might invalidate elements.
+   template 
+   iterator emplace_hint(const_iterator hint, Args&&... args)
+   {
+      return container_detail::force_copy(m_flat_tree.emplace_hint_equal
+         (container_detail::force_copy(hint), boost::forward(args)...));
+   }
+
+   #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, >)          \
+   iterator emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                            \
+   {  return container_detail::force_copy(m_flat_tree.emplace_equal                      \
+               (BOOST_PP_ENUM(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_hint(const_iterator hint                                                       \
+                         BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _))              \
+   {  return container_detail::force_copy(m_flat_tree.emplace_hint_equal                 \
+            (container_detail::force_copy(hint)                               \
+               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
 
    //! Effects: Inserts x and returns the iterator pointing to the
    //!   newly inserted element.
@@ -1324,59 +1486,6 @@ class flat_multimap
    void insert(ordered_range_t, InputIterator first, InputIterator last)
       {  m_flat_tree.insert_equal(ordered_range, first, last); }
 
-   #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-   //! Effects: Inserts an object of type T constructed with
-   //!   std::forward(args)... and returns the iterator pointing to the
-   //!   newly inserted element.
-   //!
-   //! Complexity: Logarithmic search time plus linear insertion
-   //!   to the elements with bigger keys than x.
-   //!
-   //! Note: If an element is inserted it might invalidate elements.
-   template 
-   iterator emplace(Args&&... args)
-   {  return container_detail::force_copy(m_flat_tree.emplace_equal(boost::forward(args)...)); }
-
-   //! Effects: Inserts an object of type T constructed with
-   //!   std::forward(args)... in the container.
-   //!   p is a hint pointing to where the insert should start to search.
-   //!
-   //! Returns: An iterator pointing to the element with key equivalent
-   //!   to the key of x.
-   //!
-   //! Complexity: Logarithmic search time (constant time if the value
-   //!   is to be inserted before p) plus linear insertion
-   //!   to the elements with bigger keys than x.
-   //!
-   //! Note: If an element is inserted it might invalidate elements.
-   template 
-   iterator emplace_hint(const_iterator hint, Args&&... args)
-   {
-      return container_detail::force_copy(m_flat_tree.emplace_hint_equal
-         (container_detail::force_copy(hint), boost::forward(args)...));
-   }
-
-   #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, >)          \
-   iterator emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                            \
-   {  return container_detail::force_copy(m_flat_tree.emplace_equal                      \
-               (BOOST_PP_ENUM(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_hint(const_iterator hint                                                       \
-                         BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _))              \
-   {  return container_detail::force_copy(m_flat_tree.emplace_hint_equal                 \
-            (container_detail::force_copy(hint)                               \
-               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
-
    //! Effects: Erases the element pointed to by position.
    //!
    //! Returns: Returns an iterator pointing to the element immediately
@@ -1417,6 +1526,14 @@ class flat_multimap
                            , container_detail::force_copy(last)));
    }
 
+   //! Effects: Swaps the contents of *this and x.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   void swap(flat_multimap& x)
+   { m_flat_tree.swap(x.m_flat_tree); }
+
    //! Effects: erase(a.begin(),a.end()).
    //!
    //! Postcondition: size() == 0.
@@ -1425,14 +1542,31 @@ class flat_multimap
    void clear()
       { m_flat_tree.clear(); }
 
-   //! Effects: Tries to deallocate the excess of memory created
-   //    with previous allocations. The size of the vector is unchanged
+   //////////////////////////////////////////////
+   //
+   //                observers
+   //
+   //////////////////////////////////////////////
+
+   //! Effects: Returns the comparison object out
+   //!   of which a was constructed.
    //!
-   //! Throws: If memory allocation throws, or T's copy constructor throws.
+   //! Complexity: Constant.
+   key_compare key_comp() const
+      { return container_detail::force_copy(m_flat_tree.key_comp()); }
+
+   //! Effects: Returns an object of value_compare constructed out
+   //!   of the comparison object.
    //!
-   //! Complexity: Linear to size().
-   void shrink_to_fit()
-      { m_flat_tree.shrink_to_fit(); }
+   //! Complexity: Constant.
+   value_compare value_comp() const
+      { return value_compare(container_detail::force_copy(m_flat_tree.key_comp())); }
+
+   //////////////////////////////////////////////
+   //
+   //              map operations
+   //
+   //////////////////////////////////////////////
 
    //! Returns: An iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
@@ -1459,7 +1593,7 @@ class flat_multimap
    //!
    //! Complexity: Logarithmic
    iterator lower_bound(const key_type& x)
-      {return container_detail::force_copy(m_flat_tree.lower_bound(x)); }
+      {  return container_detail::force_copy(m_flat_tree.lower_bound(x)); }
 
    //! Returns: A const iterator pointing to the first element with key
    //!   not less than k, or a.end() if such an element is not found.
@@ -1495,27 +1629,6 @@ class flat_multimap
       equal_range(const key_type& x) const
       {  return container_detail::force_copy >(m_flat_tree.equal_range(x));   }
 
-   //! Effects: Number of elements for which memory has been allocated.
-   //!   capacity() is always greater than or equal to size().
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   size_type capacity() const          
-      { return m_flat_tree.capacity(); }
-
-   //! Effects: If n is less than or equal to capacity(), this call has no
-   //!   effect. Otherwise, it is a request for allocation of additional memory.
-   //!   If the request is successful, then capacity() is greater than or equal to
-   //!   n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
-   //!
-   //! Throws: If memory allocation allocation throws or T's copy constructor throws.
-   //!
-   //! Note: If capacity() is less than "count", iterators and references to
-   //!   to values might be invalidated.
-   void reserve(size_type count)      
-      { m_flat_tree.reserve(count);   }
-
    /// @cond
    template 
    friend bool operator== (const flat_multimap& x,
diff --git a/include/boost/container/flat_set.hpp b/include/boost/container/flat_set.hpp
index 513d487..6af6827 100644
--- a/include/boost/container/flat_set.hpp
+++ b/include/boost/container/flat_set.hpp
@@ -209,10 +209,24 @@ class flat_set
    allocator_type get_allocator() const
       { return m_flat_tree.get_allocator(); }
 
-   const stored_allocator_type &get_stored_allocator() const
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
+   stored_allocator_type &get_stored_allocator()
    {  return m_flat_tree.get_stored_allocator(); }
 
-   stored_allocator_type &get_stored_allocator()
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
+   const stored_allocator_type &get_stored_allocator() const
    {  return m_flat_tree.get_stored_allocator(); }
 
    //! Effects: Returns an iterator to the first element contained in the container.
@@ -860,10 +874,24 @@ class flat_multiset
    allocator_type get_allocator() const
    { return m_flat_tree.get_allocator(); }
 
-   const stored_allocator_type &get_stored_allocator() const
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
+   stored_allocator_type &get_stored_allocator()
    { return m_flat_tree.get_stored_allocator(); }
 
-   stored_allocator_type &get_stored_allocator()
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
+   const stored_allocator_type &get_stored_allocator() const
    { return m_flat_tree.get_stored_allocator(); }
 
    //! Effects: Returns an iterator to the first element contained in the container.
diff --git a/include/boost/container/list.hpp b/include/boost/container/list.hpp
index 8f196d1..1433fb1 100644
--- a/include/boost/container/list.hpp
+++ b/include/boost/container/list.hpp
@@ -506,20 +506,24 @@ class list
    allocator_type get_allocator() const
    {  return allocator_type(this->node_alloc()); }
 
-   //! Effects: Returns a copy of the internal allocator.
+   //! Effects: Returns a reference to the internal allocator.
    //!
-   //! Throws: If allocator's copy constructor throws.
+   //! Throws: Nothing
    //!
    //! Complexity: Constant.
-   const stored_allocator_type &get_stored_allocator() const
+   //!
+   //! Note: Non-standard extension.
+   stored_allocator_type &get_stored_allocator()
    {  return this->node_alloc(); }
 
-   //! Effects: Returns a copy of the internal allocator.
+   //! Effects: Returns a reference to the internal allocator.
    //!
-   //! Throws: If allocator's copy constructor throws.
+   //! Throws: Nothing
    //!
    //! Complexity: Constant.
-   stored_allocator_type &get_stored_allocator()
+   //!
+   //! Note: Non-standard extension.
+   const stored_allocator_type &get_stored_allocator() const
    {  return this->node_alloc(); }
 
    //////////////////////////////////////////////
diff --git a/include/boost/container/map.hpp b/include/boost/container/map.hpp
index d31122c..3cff41b 100644
--- a/include/boost/container/map.hpp
+++ b/include/boost/container/map.hpp
@@ -256,10 +256,24 @@ class map
    allocator_type get_allocator() const
    { return m_tree.get_allocator(); }
 
-   const stored_allocator_type &get_stored_allocator() const
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
+   stored_allocator_type &get_stored_allocator()
    { return m_tree.get_stored_allocator(); }
 
-   stored_allocator_type &get_stored_allocator()
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
+   const stored_allocator_type &get_stored_allocator() const
    { return m_tree.get_stored_allocator(); }
 
    //! Effects: Returns an iterator to the first element contained in the container.
@@ -998,10 +1012,24 @@ class multimap
    allocator_type get_allocator() const
    { return m_tree.get_allocator(); }
 
-   const stored_allocator_type &get_stored_allocator() const
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
+   stored_allocator_type &get_stored_allocator()
    { return m_tree.get_stored_allocator(); }
 
-   stored_allocator_type &get_stored_allocator()
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
+   const stored_allocator_type &get_stored_allocator() const
    { return m_tree.get_stored_allocator(); }
 
    //! Effects: Returns an iterator to the first element contained in the container.
diff --git a/include/boost/container/set.hpp b/include/boost/container/set.hpp
index 44a854c..87473a4 100644
--- a/include/boost/container/set.hpp
+++ b/include/boost/container/set.hpp
@@ -199,9 +199,23 @@ class set
    allocator_type get_allocator() const
    { return m_tree.get_allocator(); }
 
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
    const stored_allocator_type &get_stored_allocator() const
    { return m_tree.get_stored_allocator(); }
 
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
    stored_allocator_type &get_stored_allocator()
    { return m_tree.get_stored_allocator(); }
 
@@ -788,10 +802,24 @@ class multiset
    allocator_type get_allocator() const
    { return m_tree.get_allocator(); }
 
-   const stored_allocator_type &get_stored_allocator() const
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
+   stored_allocator_type &get_stored_allocator()
    { return m_tree.get_stored_allocator(); }
 
-   stored_allocator_type &get_stored_allocator()
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
+   const stored_allocator_type &get_stored_allocator() const
    { return m_tree.get_stored_allocator(); }
 
    //! Effects: Returns an iterator to the first element contained in the container.
diff --git a/include/boost/container/slist.hpp b/include/boost/container/slist.hpp
index c5ca7fa..2af3c39 100644
--- a/include/boost/container/slist.hpp
+++ b/include/boost/container/slist.hpp
@@ -519,12 +519,14 @@ class slist
    allocator_type get_allocator() const
    {  return allocator_type(this->node_alloc()); }
 
-   //! Effects: Returns a copy of the internal allocator.
+   //! Effects: Returns a reference to the internal allocator.
    //!
-   //! Throws: If allocator's copy constructor throws.
+   //! Throws: Nothing
    //!
    //! Complexity: Constant.
-   const stored_allocator_type &get_stored_allocator() const
+   //!
+   //! Note: Non-standard extension.
+   stored_allocator_type &get_stored_allocator()
    {  return this->node_alloc(); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -534,7 +536,7 @@ class slist
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   stored_allocator_type &get_stored_allocator()
+   const stored_allocator_type &get_stored_allocator() const
    {  return this->node_alloc(); }
 
    //////////////////////////////////////////////
diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp
index 4af2ae2..42caee0 100644
--- a/include/boost/container/string.hpp
+++ b/include/boost/container/string.hpp
@@ -932,7 +932,7 @@ class basic_string
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
+   stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
    {  return this->alloc(); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -942,7 +942,7 @@ class basic_string
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
+   const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
    {  return this->alloc(); }
 
    //! Effects: Returns the number of the elements contained in the vector.

From 42ea3ca8c7e427046be9942d8b5408627489467e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Fri, 28 Sep 2012 21:07:02 +0000
Subject: [PATCH 55/93] Bug #7439

[SVN r80743]
---
 include/boost/container/detail/flat_tree.hpp | 21 +++++++------
 include/boost/container/vector.hpp           | 31 ++++++++++----------
 2 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp
index 55fac62..aa68687 100644
--- a/include/boost/container/detail/flat_tree.hpp
+++ b/include/boost/container/detail/flat_tree.hpp
@@ -491,9 +491,9 @@ class flat_tree
       const const_iterator beg(this->cbegin());
       const_iterator pos(beg);
       const value_compare &value_comp = this->m_data;
+      skips[0u] = 0u;
       //Loop in burst sizes
       while(len){
-         skips[0u] = 0u;
          const size_type burst = len < BurstSize ? len : BurstSize;
          size_type unique_burst = 0u;
          const const_iterator cend(this->cend());
@@ -503,20 +503,23 @@ class flat_tree
             --len;
             pos = const_cast(*this).priv_lower_bound(pos, cend, KeyOfValue()(val));
             //Check if already present
-            if(pos != cend && !value_comp(*pos, val)){
-               ++skips[unique_burst];
+            if(pos != cend && !value_comp(val, *pos)){
+               if(unique_burst > 0){
+                  ++skips[unique_burst-1];
+               }
                continue;
             }
 
             //If not present, calculate position
             positions[unique_burst] = static_cast(pos - beg);
-            if(++unique_burst < burst)
-               skips[unique_burst] = 0u;
+            skips[unique_burst++] = 0u;
+         }
+         if(unique_burst){
+            //Insert all in a single step in the precalculated positions
+            this->m_data.m_vect.insert_ordered_at(unique_burst, positions + unique_burst, skips + unique_burst, first);
+            //Next search position updated
+            pos += unique_burst;
          }
-         //Insert all in a single step in the precalculated positions
-         this->m_data.m_vect.insert_ordered_at(unique_burst, positions + unique_burst, skips + unique_burst, first);
-         //Next search position updated
-         pos += unique_burst;
       }
    }
 
diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp
index 91f4207..12067d7 100644
--- a/include/boost/container/vector.hpp
+++ b/include/boost/container/vector.hpp
@@ -683,15 +683,6 @@ class vector : private container_detail::vector_alloc_holder
    allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
    { return this->alloc();  }
 
-   //! Effects: Returns a reference to the internal allocator.
-   //!
-   //! Throws: Nothing
-   //!
-   //! Complexity: Constant.
-   //!
-   //! Note: Non-standard extension.
-   const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
-   {  return this->alloc(); }
 
    //! Effects: Returns a reference to the internal allocator.
    //!
@@ -703,6 +694,16 @@ class vector : private container_detail::vector_alloc_holder
    stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
    {  return this->alloc(); }
 
+   //! Effects: Returns a reference to the internal allocator.
+   //!
+   //! Throws: Nothing
+   //!
+   //! Complexity: Constant.
+   //!
+   //! Note: Non-standard extension.
+   const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
+   {  return this->alloc(); }
+
    //////////////////////////////////////////////
    //
    //                iterators
@@ -957,7 +958,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Linear to size().
    void shrink_to_fit()
-   {  priv_shrink_to_fit(alloc_version());   }
+   {  this->priv_shrink_to_fit(alloc_version());   }
 
    //////////////////////////////////////////////
    //
@@ -1535,6 +1536,10 @@ class vector : private container_detail::vector_alloc_holder
       //Loop for each insertion backwards, first moving the elements after the insertion point,
       //then inserting the element.
       while(insertions_left){
+         if(do_skip){
+            size_type n = *(--last_skip_it);
+            std::advance(last_value_it, -difference_type(n));
+         }
          const size_type pos = static_cast(*(--last_position_it));
          BOOST_ASSERT(pos <= old_size_pos);
          //If needed shift the range after the insertion point and the previous insertion point.
@@ -1569,12 +1574,6 @@ class vector : private container_detail::vector_alloc_holder
             //Insert the new value in the already constructed range
             begin_ptr[pos + insertions_left - 1] = *(--last_value_it);
          }
-         if(do_skip){
-            size_type n = *(--last_skip_it);
-            while(n--){
-               --last_value_it;
-            }
-         }
          --insertions_left;
          hole_size = new_hole_size;
          next_pos = pos;

From 853083822dec21b8871592ae58376aa75ed8f2f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Fri, 28 Sep 2012 21:11:08 +0000
Subject: [PATCH 56/93] Updated changelog with bug #7439

[SVN r80744]
---
 doc/container.qbk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/doc/container.qbk b/doc/container.qbk
index 8b71c43..75f4a3f 100644
--- a/doc/container.qbk
+++ b/doc/container.qbk
@@ -623,7 +623,8 @@ use [*Boost.Container]? There are several reasons for that:
   [@https://svn.boost.org/trac/boost/ticket/7139 #7139],
   [@https://svn.boost.org/trac/boost/ticket/7215 #7215],
   [@https://svn.boost.org/trac/boost/ticket/7232 #7232],
-  [@https://svn.boost.org/trac/boost/ticket/7269 #7269].
+  [@https://svn.boost.org/trac/boost/ticket/7269 #7269],
+  [@https://svn.boost.org/trac/boost/ticket/7439 #7439].
 *  Implemented LWG Issue #149 (range insertion now returns an iterator) & cleaned up insertion code in most containers
 *  Corrected aliasing errors.
 

From b480cc235ff446eadd4004495a692529c580503d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Sun, 30 Sep 2012 20:38:04 +0000
Subject: [PATCH 57/93] More Doxygen documentation improvements

[SVN r80795]
---
 doc/Jamfile.v2                               |   4 +-
 include/boost/container/container_fwd.hpp    |  52 +-
 include/boost/container/deque.hpp            | 116 +--
 include/boost/container/detail/flat_tree.hpp |   3 +-
 include/boost/container/detail/tree.hpp      |  10 +-
 include/boost/container/detail/utilities.hpp |  30 -
 include/boost/container/flat_map.hpp         | 310 +++----
 include/boost/container/flat_set.hpp         | 910 ++++++++++---------
 include/boost/container/list.hpp             | 113 ++-
 include/boost/container/map.hpp              | 802 ++++++++--------
 include/boost/container/scoped_allocator.hpp |  32 +-
 include/boost/container/set.hpp              | 696 +++++++-------
 include/boost/container/slist.hpp            |  81 +-
 include/boost/container/stable_vector.hpp    | 279 +++---
 include/boost/container/string.hpp           | 315 +++----
 include/boost/container/vector.hpp           | 136 ++-
 proj/to-do.txt                               |  15 +-
 test/string_test.cpp                         |  22 +-
 18 files changed, 1954 insertions(+), 1972 deletions(-)

diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2
index 58865b4..f0d1056 100644
--- a/doc/Jamfile.v2
+++ b/doc/Jamfile.v2
@@ -29,12 +29,12 @@ doxygen autodoc
                                    \"BOOST_CONTAINER_DOXYGEN_INVOKED\" \\
                                    \"BOOST_CONTAINER_IMPDEF(T)=implementation_defined\" \\
                                    \"BOOST_CONTAINER_SEEDOC(T)=see_documentation\" \\
+                                   \"BOOST_CONTAINER_NOEXCEPT=noexcept\" \\
+                                   \"BOOST_CONTAINER_NOEXCEPT_IF(T)=noexcept(T)\" \\
                                    \"BOOST_RV_REF(T)=T &&\" \\
                                    \"BOOST_RV_REF_BEG=\" \\
                                    \"BOOST_RV_REF_END=&&\" \\
                                    \"BOOST_COPY_ASSIGN_REF(T)=const T &\" \\
-                                   \"BOOST_RV_REF_2_TEMPL_ARGS(T,a,b)=T &&\" \\
-                                   \"BOOST_RV_REF_3_TEMPL_ARGS(T,a,b,c)=TT &&\" \\
                                    \"BOOST_FWD_REF(a)=a &&\""
         "boost.doxygen.reftitle=Boost.Container Header Reference"
    ;
diff --git a/include/boost/container/container_fwd.hpp b/include/boost/container/container_fwd.hpp
index c52b04a..bdefd81 100644
--- a/include/boost/container/container_fwd.hpp
+++ b/include/boost/container/container_fwd.hpp
@@ -49,85 +49,85 @@ namespace container {
 
 //vector class
 template  >
+         ,class Allocator = std::allocator >
 class vector;
 
 //vector class
 template  >
+         ,class Allocator = std::allocator >
 class stable_vector;
 
 //vector class
 template  >
+         ,class Allocator = std::allocator >
 class deque;
 
 //list class
 template  >
+         ,class Allocator = std::allocator >
 class list;
 
 //slist class
 template  >
+         ,class Allocator = std::allocator >
 class slist;
 
 //set class
-template 
-         ,class A = std::allocator >
+template 
+         ,class Allocator = std::allocator >
 class set;
 
 //multiset class
-template 
-         ,class A = std::allocator >
+template 
+         ,class Allocator = std::allocator >
 class multiset;
 
 //map class
 template 
-         ,class A = std::allocator > >
+         ,class Compare  = std::less
+         ,class Allocator = std::allocator > >
 class map;
 
 //multimap class
 template 
-         ,class A = std::allocator > >
+         ,class Compare  = std::less
+         ,class Allocator = std::allocator > >
 class multimap;
 
 //flat_set class
-template 
-         ,class A = std::allocator >
+template 
+         ,class Allocator = std::allocator >
 class flat_set;
 
 //flat_multiset class
-template 
-         ,class A = std::allocator >
+template 
+         ,class Allocator = std::allocator >
 class flat_multiset;
 
 //flat_map class
 template 
-         ,class A = std::allocator > >
+         ,class Compare  = std::less
+         ,class Allocator = std::allocator > >
 class flat_map;
 
 //flat_multimap class
 template 
-         ,class A = std::allocator > >
+         ,class Compare  = std::less
+         ,class Allocator = std::allocator > >
 class flat_multimap;
 
 //basic_string class
 template 
-         ,class A  = std::allocator >
+         ,class Allocator  = std::allocator >
 class basic_string;
 
 //! Type used to tag that the input range is
diff --git a/include/boost/container/deque.hpp b/include/boost/container/deque.hpp
index 52b3b68..b63dab3 100644
--- a/include/boost/container/deque.hpp
+++ b/include/boost/container/deque.hpp
@@ -67,17 +67,17 @@ namespace container {
 
 /// @cond
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template  >
+template  >
 #else
-template 
+template 
 #endif
 class deque;
 
-template 
+template 
 struct deque_value_traits
 {
    typedef T value_type;
-   typedef A allocator_type;
+   typedef Allocator allocator_type;
    static const bool trivial_dctr = boost::has_trivial_destructor::value;
    static const bool trivial_dctr_after_move = false;
       //::boost::has_trivial_destructor_after_move::value || trivial_dctr;
@@ -96,12 +96,12 @@ inline std::size_t deque_buf_size(std::size_t size)
 // Deque base class.  It has two purposes.  First, its constructor
 //  and destructor allocate (but don't initialize) storage.  This makes
 //  exception safety easier.
-template 
+template 
 class deque_base
 {
    BOOST_COPYABLE_AND_MOVABLE(deque_base)
    public:
-   typedef allocator_traits                                    val_alloc_traits_type;
+   typedef allocator_traits                            val_alloc_traits_type;
    typedef typename val_alloc_traits_type::value_type             val_alloc_val;
    typedef typename val_alloc_traits_type::pointer                val_alloc_ptr;
    typedef typename val_alloc_traits_type::const_pointer          val_alloc_cptr;
@@ -117,13 +117,13 @@ class deque_base
    typedef typename ptr_alloc_traits_type::const_pointer          ptr_alloc_cptr;
    typedef typename ptr_alloc_traits_type::reference              ptr_alloc_ref;
    typedef typename ptr_alloc_traits_type::const_reference        ptr_alloc_cref;
-   typedef A                                                      allocator_type;
+   typedef Allocator                                                      allocator_type;
    typedef allocator_type                                         stored_allocator_type;
    typedef val_alloc_size                                         size_type;
 
    protected:
 
-   typedef deque_value_traits             traits_t;
+   typedef deque_value_traits             traits_t;
    typedef ptr_alloc_t                          map_allocator_type;
 
    static size_type s_buffer_size() { return deque_buf_size(sizeof(T)); }
@@ -163,7 +163,7 @@ class deque_base
    //  [map, map + map_size) is a valid, non-empty range. 
    //  [start.node, finish.node] is a valid range contained within
    //    [map, map + map_size). 
-   //  A pointer in the range [map, map + map_size) points to an allocated node
+   //  Allocator pointer in the range [map, map + map_size) points to an allocated node
    //    if and only if the pointer is in the range [start.node, finish.node].
    class const_iterator
       : public std::iterator
    {
       public:
-      static size_type s_buffer_size() { return deque_base::s_buffer_size(); }
+      static size_type s_buffer_size() { return deque_base::s_buffer_size(); }
 
       typedef std::random_access_iterator_tag   iterator_category;
       typedef val_alloc_val                     value_type;
@@ -182,8 +182,8 @@ class deque_base
       typedef ptr_alloc_ptr                     index_pointer;
       typedef const_iterator                    self_t;
 
-      friend class deque;
-      friend class deque_base;
+      friend class deque;
+      friend class deque_base;
 
       protected:
       val_alloc_ptr  m_cur;
@@ -323,8 +323,8 @@ class deque_base
       typedef ptr_alloc_ptr                     index_pointer;
       typedef const_iterator                    self_t;
 
-      friend class deque;
-      friend class deque_base;
+      friend class deque;
+      friend class deque_base;
 
       private:
       explicit iterator(const const_iterator& x) : const_iterator(x){}
@@ -525,15 +525,15 @@ class deque_base
 //! Deque class
 //!
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template  >
+template  >
 #else
-template 
+template 
 #endif
-class deque : protected deque_base
+class deque : protected deque_base
 {
    /// @cond
    private:
-   typedef deque_base Base;
+   typedef deque_base Base;
    /// @endcond
 
    public:
@@ -544,19 +544,19 @@ class deque : protected deque_base
    //
    //////////////////////////////////////////////
 
-   typedef T                                                                  value_type;
-   typedef typename ::boost::container::allocator_traits::pointer          pointer;
-   typedef typename ::boost::container::allocator_traits::const_pointer    const_pointer;
-   typedef typename ::boost::container::allocator_traits::reference        reference;
-   typedef typename ::boost::container::allocator_traits::const_reference  const_reference;
-   typedef typename ::boost::container::allocator_traits::size_type        size_type;
-   typedef typename ::boost::container::allocator_traits::difference_type  difference_type;
-   typedef A                                                                  allocator_type;
-   typedef BOOST_CONTAINER_IMPDEF(allocator_type)                             stored_allocator_type;
-   typedef BOOST_CONTAINER_IMPDEF(typename Base::iterator)                    iterator;
-   typedef BOOST_CONTAINER_IMPDEF(typename Base::const_iterator)              const_iterator;
-   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)            reverse_iterator;
-   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)      const_reverse_iterator;
+   typedef T                                                                           value_type;
+   typedef typename ::boost::container::allocator_traits::pointer           pointer;
+   typedef typename ::boost::container::allocator_traits::const_pointer     const_pointer;
+   typedef typename ::boost::container::allocator_traits::reference         reference;
+   typedef typename ::boost::container::allocator_traits::const_reference   const_reference;
+   typedef typename ::boost::container::allocator_traits::size_type         size_type;
+   typedef typename ::boost::container::allocator_traits::difference_type   difference_type;
+   typedef Allocator                                                                   allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(allocator_type)                                      stored_allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(typename Base::iterator)                             iterator;
+   typedef BOOST_CONTAINER_IMPDEF(typename Base::const_iterator)                       const_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)                     reverse_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)               const_reverse_iterator;
 
    /// @cond
 
@@ -568,7 +568,7 @@ class deque : protected deque_base
    typedef container_detail::advanced_insert_aux_int advanced_insert_aux_int_t;
    typedef repeat_iterator  r_iterator;
    typedef boost::move_iterator     move_it;
-   typedef allocator_traits                  allocator_traits_type;
+   typedef allocator_traits                  allocator_traits_type;
 
    /// @endcond
 
@@ -607,7 +607,7 @@ class deque : protected deque_base
    explicit deque(size_type n)
       : Base(n, allocator_type())
    {
-      container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
+      container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
       proxy.uninitialized_copy_remaining_to(this->begin());
       //deque_base will deallocate in case of exception...
    }
@@ -1020,7 +1020,7 @@ class deque : protected deque_base
          this->priv_erase_last_n(len - new_size);
       else{
          const size_type n = new_size - this->size();
-         container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
+         container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
          priv_insert_back_aux_impl(n, proxy);
       }
    }
@@ -1176,7 +1176,7 @@ class deque : protected deque_base
          this->priv_push_front_simple_commit();
       }
       else{
-         typedef container_detail::advanced_insert_aux_non_movable_emplace type;
+         typedef container_detail::advanced_insert_aux_non_movable_emplace type;
          type &&proxy = type(this->alloc(), boost::forward(args)...);
          this->priv_insert_front_aux_impl(1, proxy);
       }
@@ -1199,7 +1199,7 @@ class deque : protected deque_base
          this->priv_push_back_simple_commit();
       }
       else{
-         typedef container_detail::advanced_insert_aux_non_movable_emplace type;
+         typedef container_detail::advanced_insert_aux_non_movable_emplace type;
          type &&proxy = type(this->alloc(), boost::forward(args)...);
          this->priv_insert_back_aux_impl(1, proxy);
       }
@@ -1226,7 +1226,7 @@ class deque : protected deque_base
          return (this->end()-1);
       }
       else{
-         typedef container_detail::advanced_insert_aux_emplace type;
+         typedef container_detail::advanced_insert_aux_emplace type;
          type &&proxy = type(this->alloc(), boost::forward(args)...);
          return this->priv_insert_aux_impl(p, 1, proxy);
       }
@@ -1249,7 +1249,7 @@ class deque : protected deque_base
       else{                                                                                  \
          container_detail::BOOST_PP_CAT(BOOST_PP_CAT                                         \
             (advanced_insert_aux_non_movable_emplace, n), arg)                               \
-                proxy                       \
+                proxy                       \
             (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));  \
          priv_insert_front_aux_impl(1, proxy);                                               \
       }                                                                                      \
@@ -1268,7 +1268,7 @@ class deque : protected deque_base
       else{                                                                                  \
          container_detail::BOOST_PP_CAT(BOOST_PP_CAT(                                        \
             advanced_insert_aux_non_movable_emplace, n), arg)                                \
-                proxy                       \
+                proxy                       \
             (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));  \
          priv_insert_back_aux_impl(1, proxy);                                                \
       }                                                                                      \
@@ -1288,7 +1288,7 @@ class deque : protected deque_base
       }                                                                                      \
       else{                                                                                  \
          container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)   \
-             proxy                          \
+             proxy                          \
             (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));  \
          return this->priv_insert_aux_impl(p, 1, proxy);                                     \
       }                                                                                      \
@@ -1424,7 +1424,7 @@ class deque : protected deque_base
       #endif
       )
    {
-      container_detail::advanced_insert_aux_proxy proxy(this->alloc(), first, last);
+      container_detail::advanced_insert_aux_proxy proxy(this->alloc(), first, last);
       return priv_insert_aux_impl(p, (size_type)std::distance(first, last), proxy);
    }
    #endif
@@ -1978,36 +1978,36 @@ class deque : protected deque_base
 };
 
 // Nonmember functions.
-template 
-inline bool operator==(const deque& x, const deque& y)
+template 
+inline bool operator==(const deque& x, const deque& y)
 {
    return x.size() == y.size() && equal(x.begin(), x.end(), y.begin());
 }
 
-template 
-inline bool operator<(const deque& x, const deque& y)
+template 
+inline bool operator<(const deque& x, const deque& y)
 {
    return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
 }
 
-template 
-inline bool operator!=(const deque& x, const deque& y)
+template 
+inline bool operator!=(const deque& x, const deque& y)
    {  return !(x == y);   }
 
-template 
-inline bool operator>(const deque& x, const deque& y)
+template 
+inline bool operator>(const deque& x, const deque& y)
    {  return y < x; }
 
-template 
-inline bool operator>=(const deque& x, const deque& y)
+template 
+inline bool operator>=(const deque& x, const deque& y)
    {  return !(x < y); }
 
-template 
-inline bool operator<=(const deque& x, const deque& y)
+template 
+inline bool operator<=(const deque& x, const deque& y)
    {  return !(y < x); }
 
-template 
-inline void swap(deque& x, deque& y)
+template 
+inline void swap(deque& x, deque& y)
 {  x.swap(y);  }
 
 }}
@@ -2018,10 +2018,10 @@ namespace boost {
 /*
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
-template 
-struct has_trivial_destructor_after_move >
+template 
+struct has_trivial_destructor_after_move >
 {
-   enum {   value = has_trivial_destructor::value  };
+   enum {   value = has_trivial_destructor::value  };
 };
 */
 }
diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp
index aa68687..b6f9214 100644
--- a/include/boost/container/detail/flat_tree.hpp
+++ b/include/boost/container/detail/flat_tree.hpp
@@ -414,7 +414,8 @@ class flat_tree
    void insert_equal(ordered_range_t, FwdIt first, FwdIt last
       #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
       , typename container_detail::enable_if_c
-         < container_detail::is_forward_iterator::value
+         < !container_detail::is_input_iterator::value &&
+		   container_detail::is_forward_iterator::value
          >::type * = 0
       #endif
       )
diff --git a/include/boost/container/detail/tree.hpp b/include/boost/container/detail/tree.hpp
index 96db26f..12342a8 100644
--- a/include/boost/container/detail/tree.hpp
+++ b/include/boost/container/detail/tree.hpp
@@ -41,7 +41,7 @@ namespace container {
 namespace container_detail {
 
 template
-struct value_compare_impl
+struct tree_value_compare
    :  public KeyCompare
 {
    typedef Value        value_type;
@@ -49,7 +49,7 @@ struct value_compare_impl
    typedef KeyOfValue   key_of_value;
    typedef Key          key_type;
 
-   value_compare_impl(const key_compare &kcomp)
+   tree_value_compare(const key_compare &kcomp)
       :  key_compare(kcomp)
    {}
 
@@ -209,13 +209,13 @@ class rbtree
    : protected container_detail::node_alloc_holder
       < A
       , typename container_detail::intrusive_rbtree_type
-          
+          
          >::type
       , KeyCompare
       >
 {
    typedef typename container_detail::intrusive_rbtree_type
-         < A, value_compare_impl
+         < A, tree_value_compare
             
          >::type                                            Icont;
    typedef container_detail::node_alloc_holder 
@@ -315,7 +315,7 @@ class rbtree
    typedef Value                                      value_type;
    typedef A                                          allocator_type;
    typedef KeyCompare                                 key_compare;
-   typedef value_compare_impl< Key, Value
+   typedef tree_value_compare< Key, Value
                         , KeyCompare, KeyOfValue>     value_compare;
    typedef typename boost::container::
       allocator_traits::pointer                    pointer;
diff --git a/include/boost/container/detail/utilities.hpp b/include/boost/container/detail/utilities.hpp
index 152b5e1..ece9a2e 100644
--- a/include/boost/container/detail/utilities.hpp
+++ b/include/boost/container/detail/utilities.hpp
@@ -122,36 +122,6 @@ struct ct_rounded_size
 {
    enum { value = ((OrigSize-1)/RoundTo+1)*RoundTo };
 };
-/*
-template 
-struct __rw_is_enum
-{
-   struct _C_no { };
-   struct _C_yes { int _C_dummy [2]; };
-
-   struct _C_indirect {
-   // prevent classes with user-defined conversions from matching
-
-   // use double to prevent float->int gcc conversion warnings
-   _C_indirect (double);
-};
-
-// nested struct gets rid of bogus gcc errors
-struct _C_nest {
-   // supply first argument to prevent HP aCC warnings
-   static _C_no _C_is (int, ...);
-   static _C_yes _C_is (int, _C_indirect);
-
-   static _TypeT _C_make_T ();
-};
-
-enum {
-   _C_val = sizeof (_C_yes) == sizeof (_C_nest::_C_is (0, _C_nest::_C_make_T ()))
-   && !::boost::is_fundamental<_TypeT>::value
-};
-
-};
-*/
 
 template
 struct move_const_ref_type
diff --git a/include/boost/container/flat_map.hpp b/include/boost/container/flat_map.hpp
index 24ee997..1422d31 100644
--- a/include/boost/container/flat_map.hpp
+++ b/include/boost/container/flat_map.hpp
@@ -28,27 +28,23 @@
 #include 
 #include 
 #include 
+#include 
 
-#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
 namespace boost {
 namespace container {
-#else
-namespace boost {
-namespace container {
-#endif
 
 /// @cond
 // Forward declarations of operators == and <, needed for friend declarations.
-template 
+template 
 class flat_map;
 
-template 
-inline bool operator==(const flat_map& x,
-                       const flat_map& y);
+template 
+inline bool operator==(const flat_map& x,
+                       const flat_map& y);
 
-template 
-inline bool operator<(const flat_map& x,
-                      const flat_map& y);
+template 
+inline bool operator<(const flat_map& x,
+                      const flat_map& y);
 
 namespace container_detail{
 
@@ -78,9 +74,9 @@ static D force_copy(S s)
 //! flat_map the key_type is Key and the value_type is std::pair
 //! (unlike std::map which value_type is std::pair<const Key, T>).
 //!
-//! Pred is the ordering function for Keys (e.g. std::less).
+//! Compare is the ordering function for Keys (e.g. std::less).
 //!
-//! A is the allocator to allocate the value_types
+//! Allocator is the allocator to allocate the value_types
 //! (e.g. allocator< std::pair >).
 //!
 //! flat_map is similar to std::map but it's implemented like an ordered vector.
@@ -90,9 +86,9 @@ static D force_copy(S s)
 //! Erasing an element of a flat_map invalidates iterators and references
 //! pointing to elements that come after (their keys are bigger) the erased element.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template , class A = std::allocator< std::pair< Key, T> > >
+template , class Allocator = std::allocator< std::pair< Key, T> > >
 #else
-template 
+template 
 #endif
 class flat_map
 {
@@ -103,43 +99,33 @@ class flat_map
    typedef container_detail::flat_tree,
                            container_detail::select1st< std::pair >,
-                           Pred,
-                           A> tree_t;
+                           Compare,
+                           Allocator> tree_t;
 
    //This is the real tree stored here. It's based on a movable pair
    typedef container_detail::flat_tree,
                            container_detail::select1st >,
-                           Pred,
-                           typename allocator_traits::template portable_rebind_alloc
+                           Compare,
+                           typename allocator_traits::template portable_rebind_alloc
                                >::type> impl_tree_t;
    impl_tree_t m_flat_tree;  // flat tree representing flat_map
 
    typedef typename impl_tree_t::value_type              impl_value_type;
-   typedef typename impl_tree_t::pointer                 impl_pointer;
-   typedef typename impl_tree_t::const_pointer           impl_const_pointer;
-   typedef typename impl_tree_t::reference               impl_reference;
-   typedef typename impl_tree_t::const_reference         impl_const_reference;
-   typedef typename impl_tree_t::value_compare           impl_value_compare;
-   typedef typename impl_tree_t::iterator                impl_iterator;
    typedef typename impl_tree_t::const_iterator          impl_const_iterator;
-   typedef typename impl_tree_t::reverse_iterator        impl_reverse_iterator;
-   typedef typename impl_tree_t::const_reverse_iterator  impl_const_reverse_iterator;
    typedef typename impl_tree_t::allocator_type          impl_allocator_type;
-   typedef allocator_traits                           allocator_traits_type;
    typedef container_detail::flat_tree_value_compare
-      < Pred
+      < Compare
       , container_detail::select1st< std::pair >
-      , std::pair >                                                value_compare_impl;
+      , std::pair >                                                         value_compare_impl;
    typedef typename container_detail::get_flat_tree_iterators
-         ::pointer>::iterator                 iterator_impl;
+         ::pointer>::iterator                  iterator_impl;
    typedef typename container_detail::get_flat_tree_iterators
-      ::pointer>::const_iterator              const_iterator_impl;
+      ::pointer>::const_iterator               const_iterator_impl;
    typedef typename container_detail::get_flat_tree_iterators
-         ::pointer>::reverse_iterator         reverse_iterator_impl;
+         ::pointer>::reverse_iterator          reverse_iterator_impl;
    typedef typename container_detail::get_flat_tree_iterators
-         ::pointer>::const_reverse_iterator   const_reverse_iterator_impl;
-
+         ::pointer>::const_reverse_iterator    const_reverse_iterator_impl;
    /// @endcond
 
    public:
@@ -149,24 +135,24 @@ class flat_map
    //                    types
    //
    //////////////////////////////////////////////
-   typedef Key                                                             key_type;
-   typedef T                                                               mapped_type;
-   typedef typename std::pair                       value_type;
-   typedef typename boost::container::allocator_traits::pointer         pointer;
-   typedef typename boost::container::allocator_traits::const_pointer   const_pointer;
-   typedef typename boost::container::allocator_traits::reference       reference;
-   typedef typename boost::container::allocator_traits::const_reference const_reference;
-   typedef typename boost::container::allocator_traits::size_type       size_type;
-   typedef typename boost::container::allocator_traits::difference_type difference_type;
-   typedef A                                                               allocator_type;
-   typedef BOOST_CONTAINER_IMPDEF(A)                                       stored_allocator_type;
-   typedef BOOST_CONTAINER_IMPDEF(value_compare_impl)                      value_compare;
-   typedef Pred                                                            key_compare;
-   typedef BOOST_CONTAINER_IMPDEF(iterator_impl)                           iterator;
-   typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl)                     const_iterator;
-   typedef BOOST_CONTAINER_IMPDEF(reverse_iterator_impl)                   reverse_iterator;
-   typedef BOOST_CONTAINER_IMPDEF(const_reverse_iterator_impl)             const_reverse_iterator;
-   typedef BOOST_CONTAINER_IMPDEF(impl_value_type)                         movable_value_type;
+   typedef Key                                                                      key_type;
+   typedef T                                                                        mapped_type;
+   typedef std::pair                                                        value_type;
+   typedef typename boost::container::allocator_traits::pointer          pointer;
+   typedef typename boost::container::allocator_traits::const_pointer    const_pointer;
+   typedef typename boost::container::allocator_traits::reference        reference;
+   typedef typename boost::container::allocator_traits::const_reference  const_reference;
+   typedef typename boost::container::allocator_traits::size_type        size_type;
+   typedef typename boost::container::allocator_traits::difference_type  difference_type;
+   typedef Allocator                                                                allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(Allocator)                                        stored_allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(value_compare_impl)                               value_compare;
+   typedef Compare                                                                  key_compare;
+   typedef BOOST_CONTAINER_IMPDEF(iterator_impl)                                    iterator;
+   typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl)                              const_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(reverse_iterator_impl)                            reverse_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(const_reverse_iterator_impl)                      const_reverse_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(impl_value_type)                                  movable_value_type;
 
    public:
    //////////////////////////////////////////////
@@ -185,7 +171,7 @@ class flat_map
    //! comparison object and allocator.
    //!
    //! Complexity: Constant.
-   explicit flat_map(const Pred& comp, const allocator_type& a = allocator_type())
+   explicit flat_map(const Compare& comp, const allocator_type& a = allocator_type())
       : m_flat_tree(comp, container_detail::force(a)) {}
 
    //! Effects: Constructs an empty flat_map using the specified comparison object and
@@ -194,7 +180,7 @@ class flat_map
    //! Complexity: Linear in N if the range [first ,last ) is already sorted using
    //! comp and otherwise N logN, where N is last - first.
    template 
-   flat_map(InputIterator first, InputIterator last, const Pred& comp = Pred(),
+   flat_map(InputIterator first, InputIterator last, const Compare& comp = Compare(),
          const allocator_type& a = allocator_type())
       : m_flat_tree(true, first, last, comp, container_detail::force(a))
    {}
@@ -211,7 +197,7 @@ class flat_map
    //! Note: Non-standard extension.
    template 
    flat_map( ordered_unique_range_t, InputIterator first, InputIterator last
-           , const Pred& comp = Pred(), const allocator_type& a = allocator_type())
+           , const Compare& comp = Compare(), const allocator_type& a = allocator_type())
       : m_flat_tree(ordered_range, first, last, comp, a)
    {}
 
@@ -466,7 +452,7 @@ class flat_map
    //! Effects: If there is no key equivalent to x in the flat_map, inserts
    //!   value_type(x, T()) into the flat_map.
    //!
-   //! Returns: A reference to the mapped_type corresponding to x in *this.
+   //! Returns: Allocator reference to the mapped_type corresponding to x in *this.
    //!
    //! Complexity: Logarithmic.
    mapped_type &operator[](const key_type& k);
@@ -474,16 +460,16 @@ class flat_map
    //! Effects: If there is no key equivalent to x in the flat_map, inserts
    //! value_type(move(x), T()) into the flat_map (the key is move-constructed)
    //!
-   //! Returns: A reference to the mapped_type corresponding to x in *this.
+   //! Returns: Allocator reference to the mapped_type corresponding to x in *this.
    //!
    //! Complexity: Logarithmic.
    mapped_type &operator[](key_type &&k) ;
 
    #else
-   BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, priv_subscript)
+   BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript)
    #endif
 
-   //! Returns: A reference to the element whose key is equivalent to x.
+   //! Returns: Allocator reference to the element whose key is equivalent to x.
    //!
    //! Throws: An exception object of type out_of_range if no such element is present.
    //!
@@ -497,7 +483,7 @@ class flat_map
       return i->second;
    }
 
-   //! Returns: A reference to the element whose key is equivalent to x.
+   //! Returns: Allocator reference to the element whose key is equivalent to x.
    //!
    //! Throws: An exception object of type out_of_range if no such element is present.
    //!
@@ -790,7 +776,7 @@ class flat_map
    iterator find(const key_type& x)
       { return container_detail::force_copy(m_flat_tree.find(x)); }
 
-   //! Returns: A const_iterator pointing to an element with the key
+   //! Returns: Allocator const_iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.s
@@ -810,7 +796,7 @@ class flat_map
    iterator lower_bound(const key_type& x)
       {  return container_detail::force_copy(m_flat_tree.lower_bound(x)); }
 
-   //! Returns: A const iterator pointing to the first element with key not
+   //! Returns: Allocator const iterator pointing to the first element with key not
    //!   less than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
@@ -824,7 +810,7 @@ class flat_map
    iterator upper_bound(const key_type& x)
       {  return container_detail::force_copy(m_flat_tree.upper_bound(x)); }
 
-   //! Returns: A const iterator pointing to the first element with key not
+   //! Returns: Allocator const iterator pointing to the first element with key not
    //!   less than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
@@ -876,39 +862,39 @@ class flat_map
    /// @endcond
 };
 
-template 
-inline bool operator==(const flat_map& x,
-                       const flat_map& y)
+template 
+inline bool operator==(const flat_map& x,
+                       const flat_map& y)
    {  return x.m_flat_tree == y.m_flat_tree;  }
 
-template 
-inline bool operator<(const flat_map& x,
-                      const flat_map& y)
+template 
+inline bool operator<(const flat_map& x,
+                      const flat_map& y)
    {  return x.m_flat_tree < y.m_flat_tree;   }
 
-template 
-inline bool operator!=(const flat_map& x,
-                       const flat_map& y)
+template 
+inline bool operator!=(const flat_map& x,
+                       const flat_map& y)
    {  return !(x == y); }
 
-template 
-inline bool operator>(const flat_map& x,
-                      const flat_map& y)
+template 
+inline bool operator>(const flat_map& x,
+                      const flat_map& y)
    {  return y < x;  }
 
-template 
-inline bool operator<=(const flat_map& x,
-                       const flat_map& y)
+template 
+inline bool operator<=(const flat_map& x,
+                       const flat_map& y)
    {  return !(y < x);  }
 
-template 
-inline bool operator>=(const flat_map& x,
-                       const flat_map& y)
+template 
+inline bool operator>=(const flat_map& x,
+                       const flat_map& y)
    {  return !(x < y);  }
 
-template 
-inline void swap(flat_map& x,
-                 flat_map& y)
+template 
+inline void swap(flat_map& x,
+                 flat_map& y)
    {  x.swap(y);  }
 
 /// @cond
@@ -917,25 +903,25 @@ inline void swap(flat_map& x,
 /*
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
-template 
-struct has_trivial_destructor_after_move >
+template 
+struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
 };
 */
 namespace container {
 
 // Forward declaration of operators < and ==, needed for friend declaration.
-template 
+template 
 class flat_multimap;
 
-template 
-inline bool operator==(const flat_multimap& x,
-                       const flat_multimap& y);
+template 
+inline bool operator==(const flat_multimap& x,
+                       const flat_multimap& y);
 
-template 
-inline bool operator<(const flat_multimap& x,
-                      const flat_multimap& y);
+template 
+inline bool operator<(const flat_multimap& x,
+                      const flat_multimap& y);
 /// @endcond
 
 //! A flat_multimap is a kind of associative container that supports equivalent keys
@@ -948,14 +934,14 @@ inline bool operator<(const flat_multimap& x,
 //! flat_multimap the key_type is Key and the value_type is std::pair
 //! (unlike std::multimap which value_type is std::pair<const Key, T>).
 //!
-//! Pred is the ordering function for Keys (e.g. std::less).
+//! Compare is the ordering function for Keys (e.g. std::less).
 //!
-//! A is the allocator to allocate the value_types
+//! Allocator is the allocator to allocate the value_types
 //! (e.g. allocator< std::pair >).
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template , class A = std::allocator< std::pair< Key, T> > >
+template , class Allocator = std::allocator< std::pair< Key, T> > >
 #else
-template 
+template 
 #endif
 class flat_multimap
 {
@@ -965,41 +951,32 @@ class flat_multimap
    typedef container_detail::flat_tree,
                            container_detail::select1st< std::pair >,
-                           Pred,
-                           A> tree_t;
+                           Compare,
+                           Allocator> tree_t;
    //This is the real tree stored here. It's based on a movable pair
    typedef container_detail::flat_tree,
                            container_detail::select1st >,
-                           Pred,
-                           typename allocator_traits::template portable_rebind_alloc
+                           Compare,
+                           typename allocator_traits::template portable_rebind_alloc
                                >::type> impl_tree_t;
    impl_tree_t m_flat_tree;  // flat tree representing flat_map
 
    typedef typename impl_tree_t::value_type              impl_value_type;
-   typedef typename impl_tree_t::pointer                 impl_pointer;
-   typedef typename impl_tree_t::const_pointer           impl_const_pointer;
-   typedef typename impl_tree_t::reference               impl_reference;
-   typedef typename impl_tree_t::const_reference         impl_const_reference;
-   typedef typename impl_tree_t::value_compare           impl_value_compare;
-   typedef typename impl_tree_t::iterator                impl_iterator;
    typedef typename impl_tree_t::const_iterator          impl_const_iterator;
-   typedef typename impl_tree_t::reverse_iterator        impl_reverse_iterator;
-   typedef typename impl_tree_t::const_reverse_iterator  impl_const_reverse_iterator;
    typedef typename impl_tree_t::allocator_type          impl_allocator_type;
-   typedef allocator_traits                           allocator_traits_type;
    typedef container_detail::flat_tree_value_compare
-      < Pred
+      < Compare
       , container_detail::select1st< std::pair >
-      , std::pair >                                                value_compare_impl;
+      , std::pair >                                                         value_compare_impl;
    typedef typename container_detail::get_flat_tree_iterators
-         ::pointer>::iterator                 iterator_impl;
+         ::pointer>::iterator                  iterator_impl;
    typedef typename container_detail::get_flat_tree_iterators
-      ::pointer>::const_iterator              const_iterator_impl;
+      ::pointer>::const_iterator               const_iterator_impl;
    typedef typename container_detail::get_flat_tree_iterators
-         ::pointer>::reverse_iterator         reverse_iterator_impl;
+         ::pointer>::reverse_iterator          reverse_iterator_impl;
    typedef typename container_detail::get_flat_tree_iterators
-         ::pointer>::const_reverse_iterator   const_reverse_iterator_impl;
+         ::pointer>::const_reverse_iterator    const_reverse_iterator_impl;
    /// @endcond
 
    public:
@@ -1009,24 +986,24 @@ class flat_multimap
    //                    types
    //
    //////////////////////////////////////////////
-   typedef Key                                                             key_type;
-   typedef T                                                               mapped_type;
-   typedef typename std::pair                       value_type;
-   typedef typename boost::container::allocator_traits::pointer         pointer;
-   typedef typename boost::container::allocator_traits::const_pointer   const_pointer;
-   typedef typename boost::container::allocator_traits::reference       reference;
-   typedef typename boost::container::allocator_traits::const_reference const_reference;
-   typedef typename boost::container::allocator_traits::size_type       size_type;
-   typedef typename boost::container::allocator_traits::difference_type difference_type;
-   typedef A                                                               allocator_type;
-   typedef BOOST_CONTAINER_IMPDEF(A)                                       stored_allocator_type;
-   typedef BOOST_CONTAINER_IMPDEF(value_compare_impl)                      value_compare;
-   typedef Pred                                                            key_compare;
-   typedef BOOST_CONTAINER_IMPDEF(iterator_impl)                           iterator;
-   typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl)                     const_iterator;
-   typedef BOOST_CONTAINER_IMPDEF(reverse_iterator_impl)                   reverse_iterator;
-   typedef BOOST_CONTAINER_IMPDEF(const_reverse_iterator_impl)             const_reverse_iterator;
-   typedef BOOST_CONTAINER_IMPDEF(impl_value_type)                         movable_value_type;
+   typedef Key                                                                      key_type;
+   typedef T                                                                        mapped_type;
+   typedef std::pair                                                        value_type;
+   typedef typename boost::container::allocator_traits::pointer          pointer;
+   typedef typename boost::container::allocator_traits::const_pointer    const_pointer;
+   typedef typename boost::container::allocator_traits::reference        reference;
+   typedef typename boost::container::allocator_traits::const_reference  const_reference;
+   typedef typename boost::container::allocator_traits::size_type        size_type;
+   typedef typename boost::container::allocator_traits::difference_type  difference_type;
+   typedef Allocator                                                                allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(Allocator)                                        stored_allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(value_compare_impl)                               value_compare;
+   typedef Compare                                                                  key_compare;
+   typedef BOOST_CONTAINER_IMPDEF(iterator_impl)                                    iterator;
+   typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl)                              const_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(reverse_iterator_impl)                            reverse_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(const_reverse_iterator_impl)                      const_reverse_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(impl_value_type)                                  movable_value_type;
 
    //////////////////////////////////////////////
    //
@@ -1044,7 +1021,7 @@ class flat_multimap
    //!   object and allocator.
    //!
    //! Complexity: Constant.
-   explicit flat_multimap(const Pred& comp,
+   explicit flat_multimap(const Compare& comp,
                           const allocator_type& a = allocator_type())
       : m_flat_tree(comp, container_detail::force(a)) { }
 
@@ -1055,7 +1032,7 @@ class flat_multimap
    //! comp and otherwise N logN, where N is last - first.
    template 
    flat_multimap(InputIterator first, InputIterator last,
-            const Pred& comp        = Pred(),
+            const Compare& comp        = Compare(),
             const allocator_type& a = allocator_type())
       : m_flat_tree(false, first, last, comp, container_detail::force(a))
    {}
@@ -1071,7 +1048,7 @@ class flat_multimap
    //! Note: Non-standard extension.
    template 
    flat_multimap(ordered_range_t, InputIterator first, InputIterator last,
-            const Pred& comp        = Pred(),
+            const Compare& comp        = Compare(),
             const allocator_type& a = allocator_type())
       : m_flat_tree(ordered_range, first, last, comp, a)
    {}
@@ -1595,7 +1572,7 @@ class flat_multimap
    iterator lower_bound(const key_type& x)
       {  return container_detail::force_copy(m_flat_tree.lower_bound(x)); }
 
-   //! Returns: A const iterator pointing to the first element with key
+   //! Returns: Allocator const iterator pointing to the first element with key
    //!   not less than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
@@ -1609,7 +1586,7 @@ class flat_multimap
    iterator upper_bound(const key_type& x)
       {return container_detail::force_copy(m_flat_tree.upper_bound(x)); }
 
-   //! Returns: A const iterator pointing to the first element with key
+   //! Returns: Allocator const iterator pointing to the first element with key
    //!   not less than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
@@ -1625,8 +1602,7 @@ class flat_multimap
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair
-      equal_range(const key_type& x) const
+   std::pair equal_range(const key_type& x) const
       {  return container_detail::force_copy >(m_flat_tree.equal_range(x));   }
 
    /// @cond
@@ -1640,38 +1616,38 @@ class flat_multimap
    /// @endcond
 };
 
-template 
-inline bool operator==(const flat_multimap& x,
-                       const flat_multimap& y)
+template 
+inline bool operator==(const flat_multimap& x,
+                       const flat_multimap& y)
    {  return x.m_flat_tree == y.m_flat_tree;  }
 
-template 
-inline bool operator<(const flat_multimap& x,
-                      const flat_multimap& y)
+template 
+inline bool operator<(const flat_multimap& x,
+                      const flat_multimap& y)
    {  return x.m_flat_tree < y.m_flat_tree;   }
 
-template 
-inline bool operator!=(const flat_multimap& x,
-                       const flat_multimap& y)
+template 
+inline bool operator!=(const flat_multimap& x,
+                       const flat_multimap& y)
    {  return !(x == y);  }
 
-template 
-inline bool operator>(const flat_multimap& x,
-                      const flat_multimap& y)
+template 
+inline bool operator>(const flat_multimap& x,
+                      const flat_multimap& y)
    {  return y < x;  }
 
-template 
-inline bool operator<=(const flat_multimap& x,
-                       const flat_multimap& y)
+template 
+inline bool operator<=(const flat_multimap& x,
+                       const flat_multimap& y)
    {  return !(y < x);  }
 
-template 
-inline bool operator>=(const flat_multimap& x,
-                       const flat_multimap& y)
+template 
+inline bool operator>=(const flat_multimap& x,
+                       const flat_multimap& y)
    {  return !(x < y);  }
 
-template 
-inline void swap(flat_multimap& x, flat_multimap& y)
+template 
+inline void swap(flat_multimap& x, flat_multimap& y)
    {  x.swap(y);  }
 
 }}
@@ -1682,10 +1658,10 @@ namespace boost {
 /*
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
-template 
-struct has_trivial_destructor_after_move< boost::container::flat_multimap >
+template 
+struct has_trivial_destructor_after_move< boost::container::flat_multimap >
 {
-   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
 };
 */
 }  //namespace boost {
diff --git a/include/boost/container/flat_set.hpp b/include/boost/container/flat_set.hpp
index 6af6827..a2fbae9 100644
--- a/include/boost/container/flat_set.hpp
+++ b/include/boost/container/flat_set.hpp
@@ -24,33 +24,30 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 
-#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
 namespace boost {
 namespace container {
-#else
-namespace boost {
-namespace container {
-#endif
 
 /// @cond
 // Forward declarations of operators < and ==, needed for friend declaration.
 
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template , class A = std::allocator >
+template , class Allocator = std::allocator >
 #else
-template 
+template 
 #endif
 class flat_set;
 
-template 
-inline bool operator==(const flat_set& x,
-                       const flat_set& y);
+template 
+inline bool operator==(const flat_set& x,
+                       const flat_set& y);
 
-template 
-inline bool operator<(const flat_set& x,
-                      const flat_set& y);
+template 
+inline bool operator<(const flat_set& x,
+                      const flat_set& y);
 /// @endcond
 
 //! flat_set is a Sorted Associative Container that stores objects of type Key.
@@ -65,40 +62,48 @@ inline bool operator<(const flat_set& x,
 //! Erasing an element of a flat_set invalidates iterators and references
 //! pointing to elements that come after (their keys are bigger) the erased element.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template , class A = std::allocator >
+template , class Allocator = std::allocator >
 #else
-template 
+template 
 #endif
 class flat_set
 {
    /// @cond
    private:
    BOOST_COPYABLE_AND_MOVABLE(flat_set)
-   typedef container_detail::flat_tree, Pred, A> tree_t;
+   typedef container_detail::flat_tree, Compare, Allocator> tree_t;
    tree_t m_flat_tree;  // flat tree representing flat_set
-   typedef typename container_detail::
-      move_const_ref_type::type insert_const_ref_type;
    /// @endcond
 
    public:
+   //////////////////////////////////////////////
+   //
+   //                    types
+   //
+   //////////////////////////////////////////////
+   typedef Key                                                                         key_type;
+   typedef Key                                                                         value_type;
+   typedef Compare                                                                     key_compare;
+   typedef Compare                                                                     value_compare;
+   typedef typename ::boost::container::allocator_traits::pointer           pointer;
+   typedef typename ::boost::container::allocator_traits::const_pointer     const_pointer;
+   typedef typename ::boost::container::allocator_traits::reference         reference;
+   typedef typename ::boost::container::allocator_traits::const_reference   const_reference;
+   typedef typename ::boost::container::allocator_traits::size_type         size_type;
+   typedef typename ::boost::container::allocator_traits::difference_type   difference_type;
+   typedef Allocator                                                                   allocator_type;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::stored_allocator_type)              stored_allocator_type;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::iterator)                           iterator;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_iterator)                     const_iterator;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::reverse_iterator)                   reverse_iterator;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_reverse_iterator)             const_reverse_iterator;
 
-   // typedefs:
-   typedef typename tree_t::key_type               key_type;
-   typedef typename tree_t::value_type             value_type;
-   typedef typename tree_t::pointer                pointer;
-   typedef typename tree_t::const_pointer          const_pointer;
-   typedef typename tree_t::reference              reference;
-   typedef typename tree_t::const_reference        const_reference;
-   typedef typename tree_t::key_compare            key_compare;
-   typedef typename tree_t::value_compare          value_compare;
-   typedef typename tree_t::iterator               iterator;
-   typedef typename tree_t::const_iterator         const_iterator;
-   typedef typename tree_t::reverse_iterator       reverse_iterator;
-   typedef typename tree_t::const_reverse_iterator const_reverse_iterator;
-   typedef typename tree_t::size_type              size_type;
-   typedef typename tree_t::difference_type        difference_type;
-   typedef typename tree_t::allocator_type         allocator_type;
-   typedef typename tree_t::stored_allocator_type  stored_allocator_type;
+   public:
+   //////////////////////////////////////////////
+   //
+   //          construct/copy/destroy
+   //
+   //////////////////////////////////////////////
 
    //! Effects: Default constructs an empty flat_set.
    //!
@@ -111,7 +116,7 @@ class flat_set
    //! comparison object and allocator.
    //!
    //! Complexity: Constant.
-   explicit flat_set(const Pred& comp,
+   explicit flat_set(const Compare& comp,
                      const allocator_type& a = allocator_type())
       : m_flat_tree(comp, a)
    {}
@@ -123,7 +128,7 @@ class flat_set
    //! comp and otherwise N logN, where N is last - first.
    template 
    flat_set(InputIterator first, InputIterator last,
-            const Pred& comp = Pred(),
+            const Compare& comp = Compare(),
             const allocator_type& a = allocator_type())
       : m_flat_tree(true, first, last, comp, a)
    {}
@@ -140,7 +145,7 @@ class flat_set
    //! Note: Non-standard extension.
    template 
    flat_set(ordered_unique_range_t, InputIterator first, InputIterator last,
-            const Pred& comp = Pred(),
+            const Compare& comp = Compare(),
             const allocator_type& a = allocator_type())
       : m_flat_tree(ordered_range, first, last, comp, a)
    {}
@@ -188,20 +193,6 @@ class flat_set
    flat_set& operator=(BOOST_RV_REF(flat_set) mx)
    {  m_flat_tree = boost::move(mx.m_flat_tree);   return *this;  }
 
-   //! Effects: Returns the comparison object out
-   //!   of which a was constructed.
-   //!
-   //! Complexity: Constant.
-   key_compare key_comp() const
-      { return m_flat_tree.key_comp(); }
-
-   //! Effects: Returns an object of value_compare constructed out
-   //!   of the comparison object.
-   //!
-   //! Complexity: Constant.
-   value_compare value_comp() const
-      { return m_flat_tree.key_comp(); }
-
    //! Effects: Returns a copy of the Allocator that
    //!   was passed to the object's constructor.
    //!
@@ -229,6 +220,12 @@ class flat_set
    const stored_allocator_type &get_stored_allocator() const
    {  return m_flat_tree.get_stored_allocator(); }
 
+   //////////////////////////////////////////////
+   //
+   //                iterators
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Returns an iterator to the first element contained in the container.
    //!
    //! Throws: Nothing.
@@ -245,14 +242,6 @@ class flat_set
    const_iterator begin() const
       { return m_flat_tree.begin(); }
 
-   //! Effects: Returns a const_iterator to the first element contained in the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_iterator cbegin() const
-      { return m_flat_tree.cbegin(); }
-
    //! Effects: Returns an iterator to the end of the container.
    //!
    //! Throws: Nothing.
@@ -269,14 +258,6 @@ class flat_set
    const_iterator end() const
       { return m_flat_tree.end(); }
 
-   //! Effects: Returns a const_iterator to the end of the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_iterator cend() const
-      { return m_flat_tree.cend(); }
-
    //! Effects: Returns a reverse_iterator pointing to the beginning
    //! of the reversed container.
    //!
@@ -295,15 +276,6 @@ class flat_set
    const_reverse_iterator rbegin() const
       { return m_flat_tree.rbegin(); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning
-   //! of the reversed container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_reverse_iterator crbegin() const
-      { return m_flat_tree.crbegin(); }
-
    //! Effects: Returns a reverse_iterator pointing to the end
    //! of the reversed container.
    //!
@@ -322,6 +294,31 @@ class flat_set
    const_reverse_iterator rend() const
       { return m_flat_tree.rend(); }
 
+   //! Effects: Returns a const_iterator to the first element contained in the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_iterator cbegin() const
+      { return m_flat_tree.cbegin(); }
+
+   //! Effects: Returns a const_iterator to the end of the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_iterator cend() const
+      { return m_flat_tree.cend(); }
+
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_reverse_iterator crbegin() const
+      { return m_flat_tree.crbegin(); }
+
    //! Effects: Returns a const_reverse_iterator pointing to the end
    //! of the reversed container.
    //!
@@ -331,6 +328,13 @@ class flat_set
    const_reverse_iterator crend() const
       { return m_flat_tree.crend(); }
 
+
+   //////////////////////////////////////////////
+   //
+   //                capacity
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Returns true if the container contains no elements.
    //!
    //! Throws: Nothing.
@@ -355,117 +359,45 @@ class flat_set
    size_type max_size() const
       { return m_flat_tree.max_size(); }
 
-   //! Effects: Swaps the contents of *this and x.
+   //! Effects: Number of elements for which memory has been allocated.
+   //!   capacity() is always greater than or equal to size().
    //!
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   void swap(flat_set& x)
-   { m_flat_tree.swap(x.m_flat_tree); }
+   size_type capacity() const          
+      { return m_flat_tree.capacity(); }
 
-   //! Effects: Inserts x if and only if there is no element in the container
-   //!   with key equivalent to the key of x.
+   //! Effects: If n is less than or equal to capacity(), this call has no
+   //!   effect. Otherwise, it is a request for allocation of additional memory.
+   //!   If the request is successful, then capacity() is greater than or equal to
+   //!   n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
    //!
-   //! Returns: The bool component of the returned pair is true if and only
-   //!   if the insertion takes place, and the iterator component of the pair
-   //!   points to the element with key equivalent to the key of x.
+   //! Throws: If memory allocation allocation throws or Key's copy constructor throws.
    //!
-   //! Complexity: Logarithmic search time plus linear insertion
-   //!   to the elements with bigger keys than x.
-   //!
-   //! Note: If an element is inserted it might invalidate elements.
-   std::pair insert(insert_const_ref_type x)
-   {  return priv_insert(x); }
+   //! Note: If capacity() is less than "count", iterators and references to
+   //!   to values might be invalidated.
+   void reserve(size_type count)      
+      { m_flat_tree.reserve(count);   }
 
-   #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   std::pair insert(T &x)
-   { return this->insert(const_cast(x)); }
+   //! Effects: Tries to deallocate the excess of memory created
+   //    with previous allocations. The size of the vector is unchanged
+   //!
+   //! Throws: If memory allocation throws, or Key's copy constructor throws.
+   //!
+   //! Complexity: Linear to size().
+   void shrink_to_fit()
+      { m_flat_tree.shrink_to_fit(); }
 
-   template
-   std::pair insert(const U &u, typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0)
-   {  return priv_insert(u); }
-   #endif
-
-   //! Effects: Inserts a new value_type move constructed from the pair if and
-   //! only if there is no element in the container with key equivalent to the key of x.
-   //!
-   //! Returns: The bool component of the returned pair is true if and only
-   //!   if the insertion takes place, and the iterator component of the pair
-   //!   points to the element with key equivalent to the key of x.
-   //!
-   //! Complexity: Logarithmic search time plus linear insertion
-   //!   to the elements with bigger keys than x.
-   //!
-   //! Note: If an element is inserted it might invalidate elements.
-   std::pair insert(BOOST_RV_REF(value_type) x)
-   {  return m_flat_tree.insert_unique(boost::move(x));  }
-
-   //! Effects: Inserts a copy of x in the container if and only if there is
-   //!   no element in the container with key equivalent to the key of x.
-   //!   p is a hint pointing to where the insert should start to search.
-   //!
-   //! Returns: An iterator pointing to the element with key equivalent
-   //!   to the key of x.
-   //!
-   //! Complexity: Logarithmic search time (constant if x is inserted
-   //!   right before p) plus insertion linear to the elements with bigger keys than x.
-   //!
-   //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(const_iterator p, insert_const_ref_type x)
-   {  return priv_insert(p, x); }
-
-   #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   iterator insert(const_iterator position, T &x)
-   { return this->insert(position, const_cast(x)); }
-
-   template
-   iterator insert(const_iterator position, const U &u, typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0)
-   {  return priv_insert(position, u); }
-   #endif
-
-   //! Effects: Inserts an element move constructed from x in the container.
-   //!   p is a hint pointing to where the insert should start to search.
-   //!
-   //! Returns: An iterator pointing to the element with key equivalent to the key of x.
-   //!
-   //! Complexity: Logarithmic search time (constant if x is inserted
-   //!   right before p) plus insertion linear to the elements with bigger keys than x.
-   //!
-   //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(const_iterator position, BOOST_RV_REF(value_type) x)
-   {  return m_flat_tree.insert_unique(position, boost::move(x)); }
-
-   //! Requires: first, last are not iterators into *this.
-   //!
-   //! Effects: inserts each element from the range [first,last) if and only
-   //!   if there is no element with key equivalent to the key of that element.
-   //!
-   //! Complexity: At most N log(size()+N) (N is the distance from first to last)
-   //!   search time plus N*size() insertion time.
-   //!
-   //! Note: If an element is inserted it might invalidate elements.
-   template 
-   void insert(InputIterator first, InputIterator last)
-      {  m_flat_tree.insert_unique(first, last);  }
-
-   //! Requires: first, last are not iterators into *this and
-   //! must be ordered according to the predicate and must be
-   //! unique values.
-   //!
-   //! Effects: inserts each element from the range [first,last) .This function
-   //! is more efficient than the normal range creation for ordered ranges.
-   //!
-   //! Complexity: At most N log(size()+N) (N is the distance from first to last)
-   //!   search time plus N*size() insertion time.
-   //!
-   //! Note: Non-standard extension. If an element is inserted it might invalidate elements.
-   template 
-   void insert(ordered_unique_range_t, InputIterator first, InputIterator last)
-      {  m_flat_tree.insert_unique(ordered_unique_range, first, last);  }
+   //////////////////////////////////////////////
+   //
+   //                modifiers
+   //
+   //////////////////////////////////////////////
 
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
-   //! Effects: Inserts an object x of type T constructed with
+   //! Effects: Inserts an object x of type Key constructed with
    //!   std::forward(args)... if and only if there is no element in the container
    //!   with key equivalent to the key of x.
    //!
@@ -481,7 +413,7 @@ class flat_set
    std::pair emplace(Args&&... args)
    {  return m_flat_tree.emplace_unique(boost::forward(args)...); }
 
-   //! Effects: Inserts an object of type T constructed with
+   //! Effects: Inserts an object of type Key constructed with
    //!   std::forward(args)... in the container if and only if there is
    //!   no element in the container with key equivalent to the key of x.
    //!   p is a hint pointing to where the insert should start to search.
@@ -515,6 +447,95 @@ class flat_set
 
    #endif   //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
+   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   //! Effects: Inserts x if and only if there is no element in the container
+   //!   with key equivalent to the key of x.
+   //!
+   //! Returns: The bool component of the returned pair is true if and only
+   //!   if the insertion takes place, and the iterator component of the pair
+   //!   points to the element with key equivalent to the key of x.
+   //!
+   //! Complexity: Logarithmic search time plus linear insertion
+   //!   to the elements with bigger keys than x.
+   //!
+   //! Note: If an element is inserted it might invalidate elements.
+   std::pair insert(const value_type &x);
+
+   //! Effects: Inserts a new value_type move constructed from the pair if and
+   //! only if there is no element in the container with key equivalent to the key of x.
+   //!
+   //! Returns: The bool component of the returned pair is true if and only
+   //!   if the insertion takes place, and the iterator component of the pair
+   //!   points to the element with key equivalent to the key of x.
+   //!
+   //! Complexity: Logarithmic search time plus linear insertion
+   //!   to the elements with bigger keys than x.
+   //!
+   //! Note: If an element is inserted it might invalidate elements.
+   std::pair insert(value_type &&x);
+   #else
+   private:
+   typedef std::pair insert_return_pair;
+   public:
+   BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, insert_return_pair, this->priv_insert)
+   #endif
+
+   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   //! Effects: Inserts a copy of x in the container if and only if there is
+   //!   no element in the container with key equivalent to the key of x.
+   //!   p is a hint pointing to where the insert should start to search.
+   //!
+   //! Returns: An iterator pointing to the element with key equivalent
+   //!   to the key of x.
+   //!
+   //! Complexity: Logarithmic search time (constant if x is inserted
+   //!   right before p) plus insertion linear to the elements with bigger keys than x.
+   //!
+   //! Note: If an element is inserted it might invalidate elements.
+   iterator insert(const_iterator p, const value_type &x);
+
+   //! Effects: Inserts an element move constructed from x in the container.
+   //!   p is a hint pointing to where the insert should start to search.
+   //!
+   //! Returns: An iterator pointing to the element with key equivalent to the key of x.
+   //!
+   //! Complexity: Logarithmic search time (constant if x is inserted
+   //!   right before p) plus insertion linear to the elements with bigger keys than x.
+   //!
+   //! Note: If an element is inserted it might invalidate elements.
+   iterator insert(const_iterator position, value_type &&x);
+   #else
+   BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator)
+   #endif
+
+   //! Requires: first, last are not iterators into *this.
+   //!
+   //! Effects: inserts each element from the range [first,last) if and only
+   //!   if there is no element with key equivalent to the key of that element.
+   //!
+   //! Complexity: At most N log(size()+N) (N is the distance from first to last)
+   //!   search time plus N*size() insertion time.
+   //!
+   //! Note: If an element is inserted it might invalidate elements.
+   template 
+   void insert(InputIterator first, InputIterator last)
+      {  m_flat_tree.insert_unique(first, last);  }
+
+   //! Requires: first, last are not iterators into *this and
+   //! must be ordered according to the predicate and must be
+   //! unique values.
+   //!
+   //! Effects: inserts each element from the range [first,last) .This function
+   //! is more efficient than the normal range creation for ordered ranges.
+   //!
+   //! Complexity: At most N log(size()+N) (N is the distance from first to last)
+   //!   search time plus N*size() insertion time.
+   //!
+   //! Note: Non-standard extension. If an element is inserted it might invalidate elements.
+   template 
+   void insert(ordered_unique_range_t, InputIterator first, InputIterator last)
+      {  m_flat_tree.insert_unique(ordered_unique_range, first, last);  }
+
    //! Effects: Erases the element pointed to by position.
    //!
    //! Returns: Returns an iterator pointing to the element immediately
@@ -548,6 +569,14 @@ class flat_set
    iterator erase(const_iterator first, const_iterator last)
       {  return m_flat_tree.erase(first, last);  }
 
+   //! Effects: Swaps the contents of *this and x.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   void swap(flat_set& x)
+   { m_flat_tree.swap(x.m_flat_tree); }
+
    //! Effects: erase(a.begin(),a.end()).
    //!
    //! Postcondition: size() == 0.
@@ -556,14 +585,31 @@ class flat_set
    void clear()
       { m_flat_tree.clear(); }
 
-   //! Effects: Tries to deallocate the excess of memory created
-   //    with previous allocations. The size of the vector is unchanged
+   //////////////////////////////////////////////
+   //
+   //                observers
+   //
+   //////////////////////////////////////////////
+
+   //! Effects: Returns the comparison object out
+   //!   of which a was constructed.
    //!
-   //! Throws: If memory allocation throws, or T's copy constructor throws.
+   //! Complexity: Constant.
+   key_compare key_comp() const
+      { return m_flat_tree.key_comp(); }
+
+   //! Effects: Returns an object of value_compare constructed out
+   //!   of the comparison object.
    //!
-   //! Complexity: Linear to size().
-   void shrink_to_fit()
-      { m_flat_tree.shrink_to_fit(); }
+   //! Complexity: Constant.
+   value_compare value_comp() const
+      { return m_flat_tree.key_comp(); }
+
+   //////////////////////////////////////////////
+   //
+   //              set operations
+   //
+   //////////////////////////////////////////////
 
    //! Returns: An iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
@@ -572,7 +618,7 @@ class flat_set
    iterator find(const key_type& x)
       { return m_flat_tree.find(x); }
 
-   //! Returns: A const_iterator pointing to an element with the key
+   //! Returns: Allocator const_iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.s
@@ -592,7 +638,7 @@ class flat_set
    iterator lower_bound(const key_type& x)
       {  return m_flat_tree.lower_bound(x); }
 
-   //! Returns: A const iterator pointing to the first element with key not
+   //! Returns: Allocator const iterator pointing to the first element with key not
    //!   less than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
@@ -606,7 +652,7 @@ class flat_set
    iterator upper_bound(const key_type& x)
       {  return m_flat_tree.upper_bound(x);    }
 
-   //! Returns: A const iterator pointing to the first element with key not
+   //! Returns: Allocator const iterator pointing to the first element with key not
    //!   less than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
@@ -616,38 +662,15 @@ class flat_set
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair
-      equal_range(const key_type& x) const
+   std::pair equal_range(const key_type& x) const
       {  return m_flat_tree.equal_range(x); }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair
-      equal_range(const key_type& x)
+   std::pair equal_range(const key_type& x)
       {  return m_flat_tree.equal_range(x); }
 
-   //! Effects: Number of elements for which memory has been allocated.
-   //!   capacity() is always greater than or equal to size().
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   size_type capacity() const          
-      { return m_flat_tree.capacity(); }
-
-   //! Effects: If n is less than or equal to capacity(), this call has no
-   //!   effect. Otherwise, it is a request for allocation of additional memory.
-   //!   If the request is successful, then capacity() is greater than or equal to
-   //!   n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
-   //!
-   //! Throws: If memory allocation allocation throws or T's copy constructor throws.
-   //!
-   //! Note: If capacity() is less than "count", iterators and references to
-   //!   to values might be invalidated.
-   void reserve(size_type count)      
-      { m_flat_tree.reserve(count);   }
-
    /// @cond
    template 
    friend bool operator== (const flat_set&, const flat_set&);
@@ -656,46 +679,48 @@ class flat_set
    friend bool operator< (const flat_set&, const flat_set&);
 
    private:
-   std::pair priv_insert(const T &x)
-   {  return m_flat_tree.insert_unique(x);  }
+   template
+   std::pair priv_insert(BOOST_FWD_REF(KeyType) x)
+   {  return m_flat_tree.insert_unique(::boost::forward(x));  }
 
-   iterator priv_insert(const_iterator p, const T &x)
-   {  return m_flat_tree.insert_unique(p, x); }
+   template
+   iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x)
+   {  return m_flat_tree.insert_unique(p, ::boost::forward(x)); }
    /// @endcond
 };
 
-template 
-inline bool operator==(const flat_set& x,
-                       const flat_set& y)
+template 
+inline bool operator==(const flat_set& x,
+                       const flat_set& y)
    {  return x.m_flat_tree == y.m_flat_tree;  }
 
-template 
-inline bool operator<(const flat_set& x,
-                      const flat_set& y)
+template 
+inline bool operator<(const flat_set& x,
+                      const flat_set& y)
    {  return x.m_flat_tree < y.m_flat_tree;   }
 
-template 
-inline bool operator!=(const flat_set& x,
-                       const flat_set& y)
+template 
+inline bool operator!=(const flat_set& x,
+                       const flat_set& y)
    {  return !(x == y);   }
 
-template 
-inline bool operator>(const flat_set& x,
-                      const flat_set& y)
+template 
+inline bool operator>(const flat_set& x,
+                      const flat_set& y)
    {  return y < x; }
 
-template 
-inline bool operator<=(const flat_set& x,
-                       const flat_set& y)
+template 
+inline bool operator<=(const flat_set& x,
+                       const flat_set& y)
    {  return !(y < x); }
 
-template 
-inline bool operator>=(const flat_set& x,
-                       const flat_set& y)
+template 
+inline bool operator>=(const flat_set& x,
+                       const flat_set& y)
    {  return !(x < y);  }
 
-template 
-inline void swap(flat_set& x, flat_set& y)
+template 
+inline void swap(flat_set& x, flat_set& y)
    {  x.swap(y);  }
 
 /// @cond
@@ -704,10 +729,10 @@ inline void swap(flat_set& x, flat_set& y)
 /*
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
-template 
-struct has_trivial_destructor_after_move >
+template 
+struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value &&has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor::value &&has_trivial_destructor::value;
 };
 */
 namespace container {
@@ -715,19 +740,19 @@ namespace container {
 // Forward declaration of operators < and ==, needed for friend declaration.
 
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template , class A = std::allocator >
+template , class Allocator = std::allocator >
 #else
-template 
+template 
 #endif
 class flat_multiset;
 
-template 
-inline bool operator==(const flat_multiset& x,
-                       const flat_multiset& y);
+template 
+inline bool operator==(const flat_multiset& x,
+                       const flat_multiset& y);
 
-template 
-inline bool operator<(const flat_multiset& x,
-                      const flat_multiset& y);
+template 
+inline bool operator<(const flat_multiset& x,
+                      const flat_multiset& y);
 /// @endcond
 
 //! flat_multiset is a Sorted Associative Container that stores objects of type Key.
@@ -742,39 +767,41 @@ inline bool operator<(const flat_multiset& x,
 //! Erasing an element of a flat_multiset invalidates iterators and references
 //! pointing to elements that come after (their keys are equal or bigger) the erased element.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template , class A = std::allocator >
+template , class Allocator = std::allocator >
 #else
-template 
+template 
 #endif
 class flat_multiset
 {
    /// @cond
    private:
    BOOST_COPYABLE_AND_MOVABLE(flat_multiset)
-   typedef container_detail::flat_tree, Pred, A> tree_t;
+   typedef container_detail::flat_tree, Compare, Allocator> tree_t;
    tree_t m_flat_tree;  // flat tree representing flat_multiset
-   typedef typename container_detail::
-      move_const_ref_type::type insert_const_ref_type;
    /// @endcond
 
    public:
-   // typedefs:
-   typedef typename tree_t::key_type               key_type;
-   typedef typename tree_t::value_type             value_type;
-   typedef typename tree_t::pointer                pointer;
-   typedef typename tree_t::const_pointer          const_pointer;
-   typedef typename tree_t::reference              reference;
-   typedef typename tree_t::const_reference        const_reference;
-   typedef typename tree_t::key_compare            key_compare;
-   typedef typename tree_t::value_compare          value_compare;
-   typedef typename tree_t::iterator               iterator;
-   typedef typename tree_t::const_iterator         const_iterator;
-   typedef typename tree_t::reverse_iterator       reverse_iterator;
-   typedef typename tree_t::const_reverse_iterator const_reverse_iterator;
-   typedef typename tree_t::size_type              size_type;
-   typedef typename tree_t::difference_type        difference_type;
-   typedef typename tree_t::allocator_type         allocator_type;
-   typedef typename tree_t::stored_allocator_type  stored_allocator_type;
+   //////////////////////////////////////////////
+   //
+   //                    types
+   //
+   //////////////////////////////////////////////
+   typedef Key                                                                         key_type;
+   typedef Key                                                                         value_type;
+   typedef Compare                                                                     key_compare;
+   typedef Compare                                                                     value_compare;
+   typedef typename ::boost::container::allocator_traits::pointer           pointer;
+   typedef typename ::boost::container::allocator_traits::const_pointer     const_pointer;
+   typedef typename ::boost::container::allocator_traits::reference         reference;
+   typedef typename ::boost::container::allocator_traits::const_reference   const_reference;
+   typedef typename ::boost::container::allocator_traits::size_type         size_type;
+   typedef typename ::boost::container::allocator_traits::difference_type   difference_type;
+   typedef Allocator                                                                   allocator_type;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::stored_allocator_type)              stored_allocator_type;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::iterator)                           iterator;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_iterator)                     const_iterator;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::reverse_iterator)                   reverse_iterator;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_reverse_iterator)             const_reverse_iterator;
 
    //! Effects: Default constructs an empty flat_multiset.
    //!
@@ -783,13 +810,13 @@ class flat_multiset
       : m_flat_tree()
    {}
 
-   explicit flat_multiset(const Pred& comp,
+   explicit flat_multiset(const Compare& comp,
                           const allocator_type& a = allocator_type())
       : m_flat_tree(comp, a) {}
 
    template 
    flat_multiset(InputIterator first, InputIterator last,
-                 const Pred& comp        = Pred(),
+                 const Compare& comp        = Compare(),
                  const allocator_type& a = allocator_type())
       : m_flat_tree(false, first, last, comp, a)
    {}
@@ -805,7 +832,7 @@ class flat_multiset
    //! Note: Non-standard extension.
    template 
    flat_multiset(ordered_range_t, InputIterator first, InputIterator last,
-                 const Pred& comp        = Pred(),
+                 const Compare& comp        = Compare(),
                  const allocator_type& a = allocator_type())
       : m_flat_tree(ordered_range, first, last, comp, a)
    {}
@@ -853,20 +880,6 @@ class flat_multiset
    flat_multiset& operator=(BOOST_RV_REF(flat_multiset) mx)
    {  m_flat_tree = boost::move(mx.m_flat_tree);   return *this;  }
 
-   //! Effects: Returns the comparison object out
-   //!   of which a was constructed.
-   //!
-   //! Complexity: Constant.
-   key_compare key_comp() const
-      { return m_flat_tree.key_comp(); }
-
-   //! Effects: Returns an object of value_compare constructed out
-   //!   of the comparison object.
-   //!
-   //! Complexity: Constant.
-   value_compare value_comp() const
-      { return m_flat_tree.key_comp(); }
-
    //! Effects: Returns a copy of the Allocator that
    //!   was passed to the object's constructor.
    //!
@@ -996,6 +1009,12 @@ class flat_multiset
    const_reverse_iterator crend() const
       { return m_flat_tree.crend(); }
 
+   //////////////////////////////////////////////
+   //
+   //                capacity
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Returns true if the container contains no elements.
    //!
    //! Throws: Nothing.
@@ -1020,108 +1039,45 @@ class flat_multiset
    size_type max_size() const
       { return m_flat_tree.max_size(); }
 
-   //! Effects: Swaps the contents of *this and x.
+   //! Effects: Number of elements for which memory has been allocated.
+   //!   capacity() is always greater than or equal to size().
    //!
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   void swap(flat_multiset& x)
-   { m_flat_tree.swap(x.m_flat_tree); }
+   size_type capacity() const          
+      { return m_flat_tree.capacity(); }
 
-   //! Effects: Inserts x and returns the iterator pointing to the
-   //!   newly inserted element.
+   //! Effects: If n is less than or equal to capacity(), this call has no
+   //!   effect. Otherwise, it is a request for allocation of additional memory.
+   //!   If the request is successful, then capacity() is greater than or equal to
+   //!   n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
    //!
-   //! Complexity: Logarithmic search time plus linear insertion
-   //!   to the elements with bigger keys than x.
+   //! Throws: If memory allocation allocation throws or Key's copy constructor throws.
    //!
-   //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(insert_const_ref_type x)
-   {  return priv_insert(x); }
+   //! Note: If capacity() is less than "count", iterators and references to
+   //!   to values might be invalidated.
+   void reserve(size_type count)      
+      { m_flat_tree.reserve(count);   }
 
-   #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   iterator insert(T &x)
-   { return this->insert(const_cast(x)); }
+   //! Effects: Tries to deallocate the excess of memory created
+   //    with previous allocations. The size of the vector is unchanged
+   //!
+   //! Throws: If memory allocation throws, or Key's copy constructor throws.
+   //!
+   //! Complexity: Linear to size().
+   void shrink_to_fit()
+      { m_flat_tree.shrink_to_fit(); }
 
-   template
-   iterator insert(const U &u, typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0)
-   {  return priv_insert(u); }
-   #endif
-
-   //! Effects: Inserts a new value_type move constructed from x
-   //!   and returns the iterator pointing to the newly inserted element.
-   //!
-   //! Complexity: Logarithmic search time plus linear insertion
-   //!   to the elements with bigger keys than x.
-   //!
-   //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(BOOST_RV_REF(value_type) x)
-   {  return m_flat_tree.insert_equal(boost::move(x));   }
-
-   //! Effects: Inserts a copy of x in the container.
-   //!   p is a hint pointing to where the insert should start to search.
-   //!
-   //! Returns: An iterator pointing to the element with key equivalent
-   //!   to the key of x.
-   //!
-   //! Complexity: Logarithmic search time (constant if x is inserted
-   //!   right before p) plus insertion linear to the elements with bigger keys than x.
-   //!
-   //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(const_iterator p, insert_const_ref_type x)
-   {  return priv_insert(p, x); }
-
-   #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   iterator insert(const_iterator position, T &x)
-   { return this->insert(position, const_cast(x)); }
-
-   template
-   iterator insert( const_iterator position, const U &u
-                  , typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0)
-   {  return priv_insert(position, u); }
-   #endif
-
-   //! Effects: Inserts a new value move constructed  from x in the container.
-   //!   p is a hint pointing to where the insert should start to search.
-   //!
-   //! Returns: An iterator pointing to the element with key equivalent
-   //!   to the key of x.
-   //!
-   //! Complexity: Logarithmic search time (constant if x is inserted
-   //!   right before p) plus insertion linear to the elements with bigger keys than x.
-   //!
-   //! Note: If an element is inserted it might invalidate elements.
-   iterator insert(const_iterator position, BOOST_RV_REF(value_type) x)
-   {  return m_flat_tree.insert_equal(position, boost::move(x));  }
-
-   //! Requires: first, last are not iterators into *this.
-   //!
-   //! Effects: inserts each element from the range [first,last) .
-   //!
-   //! Complexity: At most N log(size()+N) (N is the distance from first to last)
-   //!   search time plus N*size() insertion time.
-   //!
-   //! Note: If an element is inserted it might invalidate elements.
-   template 
-   void insert(InputIterator first, InputIterator last)
-      {  m_flat_tree.insert_equal(first, last);  }
-
-   //! Requires: first, last are not iterators into *this and
-   //! must be ordered according to the predicate.
-   //!
-   //! Effects: inserts each element from the range [first,last) .This function
-   //! is more efficient than the normal range creation for ordered ranges.
-   //!
-   //! Complexity: At most N log(size()+N) (N is the distance from first to last)
-   //!   search time plus N*size() insertion time.
-   //!
-   //! Note: Non-standard extension. If an element is inserted it might invalidate elements.
-   template 
-   void insert(ordered_range_t, InputIterator first, InputIterator last)
-      {  m_flat_tree.insert_equal(ordered_range, first, last);  }
+   //////////////////////////////////////////////
+   //
+   //                modifiers
+   //
+   //////////////////////////////////////////////
 
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
-   //! Effects: Inserts an object of type T constructed with
+   //! Effects: Inserts an object of type Key constructed with
    //!   std::forward(args)... and returns the iterator pointing to the
    //!   newly inserted element.
    //!
@@ -1133,7 +1089,7 @@ class flat_multiset
    iterator emplace(Args&&... args)
    {  return m_flat_tree.emplace_equal(boost::forward(args)...); }
 
-   //! Effects: Inserts an object of type T constructed with
+   //! Effects: Inserts an object of type Key constructed with
    //!   std::forward(args)... in the container.
    //!   p is a hint pointing to where the insert should start to search.
    //!
@@ -1166,6 +1122,82 @@ class flat_multiset
 
    #endif   //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
+   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   //! Effects: Inserts x and returns the iterator pointing to the
+   //!   newly inserted element.
+   //!
+   //! Complexity: Logarithmic search time plus linear insertion
+   //!   to the elements with bigger keys than x.
+   //!
+   //! Note: If an element is inserted it might invalidate elements.
+   iterator insert(const value_type &x);
+
+   //! Effects: Inserts a new value_type move constructed from x
+   //!   and returns the iterator pointing to the newly inserted element.
+   //!
+   //! Complexity: Logarithmic search time plus linear insertion
+   //!   to the elements with bigger keys than x.
+   //!
+   //! Note: If an element is inserted it might invalidate elements.
+   iterator insert(value_type &&x);
+   #else
+   BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, iterator, this->priv_insert)
+   #endif
+
+   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   //! Effects: Inserts a copy of x in the container.
+   //!   p is a hint pointing to where the insert should start to search.
+   //!
+   //! Returns: An iterator pointing to the element with key equivalent
+   //!   to the key of x.
+   //!
+   //! Complexity: Logarithmic search time (constant if x is inserted
+   //!   right before p) plus insertion linear to the elements with bigger keys than x.
+   //!
+   //! Note: If an element is inserted it might invalidate elements.
+   iterator insert(const_iterator p, const value_type &x);
+
+   //! Effects: Inserts a new value move constructed  from x in the container.
+   //!   p is a hint pointing to where the insert should start to search.
+   //!
+   //! Returns: An iterator pointing to the element with key equivalent
+   //!   to the key of x.
+   //!
+   //! Complexity: Logarithmic search time (constant if x is inserted
+   //!   right before p) plus insertion linear to the elements with bigger keys than x.
+   //!
+   //! Note: If an element is inserted it might invalidate elements.
+   iterator insert(const_iterator position, value_type &&x);
+   #else
+   BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator)
+   #endif
+
+   //! Requires: first, last are not iterators into *this.
+   //!
+   //! Effects: inserts each element from the range [first,last) .
+   //!
+   //! Complexity: At most N log(size()+N) (N is the distance from first to last)
+   //!   search time plus N*size() insertion time.
+   //!
+   //! Note: If an element is inserted it might invalidate elements.
+   template 
+   void insert(InputIterator first, InputIterator last)
+      {  m_flat_tree.insert_equal(first, last);  }
+
+   //! Requires: first, last are not iterators into *this and
+   //! must be ordered according to the predicate.
+   //!
+   //! Effects: inserts each element from the range [first,last) .This function
+   //! is more efficient than the normal range creation for ordered ranges.
+   //!
+   //! Complexity: At most N log(size()+N) (N is the distance from first to last)
+   //!   search time plus N*size() insertion time.
+   //!
+   //! Note: Non-standard extension. If an element is inserted it might invalidate elements.
+   template 
+   void insert(ordered_range_t, InputIterator first, InputIterator last)
+      {  m_flat_tree.insert_equal(ordered_range, first, last);  }
+
    //! Effects: Erases the element pointed to by position.
    //!
    //! Returns: Returns an iterator pointing to the element immediately
@@ -1199,6 +1231,14 @@ class flat_multiset
    iterator erase(const_iterator first, const_iterator last)
       {  return m_flat_tree.erase(first, last);  }
 
+   //! Effects: Swaps the contents of *this and x.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   void swap(flat_multiset& x)
+   { m_flat_tree.swap(x.m_flat_tree); }
+
    //! Effects: erase(a.begin(),a.end()).
    //!
    //! Postcondition: size() == 0.
@@ -1207,14 +1247,31 @@ class flat_multiset
    void clear()
       { m_flat_tree.clear(); }
 
-   //! Effects: Tries to deallocate the excess of memory created
-   //    with previous allocations. The size of the vector is unchanged
+   //////////////////////////////////////////////
+   //
+   //                observers
+   //
+   //////////////////////////////////////////////
+
+   //! Effects: Returns the comparison object out
+   //!   of which a was constructed.
    //!
-   //! Throws: If memory allocation throws, or T's copy constructor throws.
+   //! Complexity: Constant.
+   key_compare key_comp() const
+      { return m_flat_tree.key_comp(); }
+
+   //! Effects: Returns an object of value_compare constructed out
+   //!   of the comparison object.
    //!
-   //! Complexity: Linear to size().
-   void shrink_to_fit()
-      { m_flat_tree.shrink_to_fit(); }
+   //! Complexity: Constant.
+   value_compare value_comp() const
+      { return m_flat_tree.key_comp(); }
+
+   //////////////////////////////////////////////
+   //
+   //              set operations
+   //
+   //////////////////////////////////////////////
 
    //! Returns: An iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
@@ -1223,7 +1280,7 @@ class flat_multiset
    iterator find(const key_type& x)
       { return m_flat_tree.find(x); }
 
-   //! Returns: A const_iterator pointing to an element with the key
+   //! Returns: Allocator const_iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.s
@@ -1243,7 +1300,7 @@ class flat_multiset
    iterator lower_bound(const key_type& x)
       {  return m_flat_tree.lower_bound(x); }
 
-   //! Returns: A const iterator pointing to the first element with key not
+   //! Returns: Allocator const iterator pointing to the first element with key not
    //!   less than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
@@ -1257,7 +1314,7 @@ class flat_multiset
    iterator upper_bound(const key_type& x)
       {  return m_flat_tree.upper_bound(x);    }
 
-   //! Returns: A const iterator pointing to the first element with key not
+   //! Returns: Allocator const iterator pointing to the first element with key not
    //!   less than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
@@ -1267,38 +1324,15 @@ class flat_multiset
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair
-      equal_range(const key_type& x) const
+   std::pair equal_range(const key_type& x) const
       {  return m_flat_tree.equal_range(x); }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair
-      equal_range(const key_type& x)
+   std::pair equal_range(const key_type& x)
       {  return m_flat_tree.equal_range(x); }
 
-   //! Effects: Number of elements for which memory has been allocated.
-   //!   capacity() is always greater than or equal to size().
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   size_type capacity() const          
-      { return m_flat_tree.capacity(); }
-
-   //! Effects: If n is less than or equal to capacity(), this call has no
-   //!   effect. Otherwise, it is a request for allocation of additional memory.
-   //!   If the request is successful, then capacity() is greater than or equal to
-   //!   n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
-   //!
-   //! Throws: If memory allocation allocation throws or T's copy constructor throws.
-   //!
-   //! Note: If capacity() is less than "count", iterators and references to
-   //!   to values might be invalidated.
-   void reserve(size_type count)      
-      { m_flat_tree.reserve(count);   }
-
    /// @cond
    template 
    friend bool operator== (const flat_multiset&,
@@ -1307,46 +1341,48 @@ class flat_multiset
    friend bool operator< (const flat_multiset&,
                           const flat_multiset&);
    private:
-   iterator priv_insert(const T &x)
-   {  return m_flat_tree.insert_equal(x);  }
+   template 
+   iterator priv_insert(BOOST_FWD_REF(KeyType) x)
+   {  return m_flat_tree.insert_equal(::boost::forward(x));  }
 
-   iterator priv_insert(const_iterator p, const T &x)
-   {  return m_flat_tree.insert_equal(p, x); }
+   template 
+   iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x)
+   {  return m_flat_tree.insert_equal(p, ::boost::forward(x)); }
    /// @endcond
 };
 
-template 
-inline bool operator==(const flat_multiset& x,
-                       const flat_multiset& y)
+template 
+inline bool operator==(const flat_multiset& x,
+                       const flat_multiset& y)
    {  return x.m_flat_tree == y.m_flat_tree;  }
 
-template 
-inline bool operator<(const flat_multiset& x,
-                      const flat_multiset& y)
+template 
+inline bool operator<(const flat_multiset& x,
+                      const flat_multiset& y)
    {  return x.m_flat_tree < y.m_flat_tree;   }
 
-template 
-inline bool operator!=(const flat_multiset& x,
-                       const flat_multiset& y)
+template 
+inline bool operator!=(const flat_multiset& x,
+                       const flat_multiset& y)
    {  return !(x == y);  }
 
-template 
-inline bool operator>(const flat_multiset& x,
-                      const flat_multiset& y)
+template 
+inline bool operator>(const flat_multiset& x,
+                      const flat_multiset& y)
    {  return y < x;  }
 
-template 
-inline bool operator<=(const flat_multiset& x,
-                       const flat_multiset& y)
+template 
+inline bool operator<=(const flat_multiset& x,
+                       const flat_multiset& y)
    {  return !(y < x);  }
 
-template 
-inline bool operator>=(const flat_multiset& x,
-                       const flat_multiset& y)
+template 
+inline bool operator>=(const flat_multiset& x,
+                       const flat_multiset& y)
 {  return !(x < y);  }
 
-template 
-inline void swap(flat_multiset& x, flat_multiset& y)
+template 
+inline void swap(flat_multiset& x, flat_multiset& y)
    {  x.swap(y);  }
 
 /// @cond
@@ -1355,10 +1391,10 @@ inline void swap(flat_multiset& x, flat_multiset& y)
 /*
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
-template 
-struct has_trivial_destructor_after_move >
+template 
+struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
 };
 */
 namespace container {
diff --git a/include/boost/container/list.hpp b/include/boost/container/list.hpp
index 1433fb1..38f7c54 100644
--- a/include/boost/container/list.hpp
+++ b/include/boost/container/list.hpp
@@ -7,8 +7,8 @@
 // See http://www.boost.org/libs/container for documentation.
 //
 
-#ifndef BOOST_CONTAINER_LIST_HPP_
-#define BOOST_CONTAINER_LIST_HPP_
+#ifndef BOOST_CONTAINER_LIST_HPP
+#define BOOST_CONTAINER_LIST_HPP
 
 #if (defined _MSC_VER) && (_MSC_VER >= 1200)
 #  pragma once
@@ -43,13 +43,8 @@
 #include 
 #include 
 
-#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
 namespace boost {
 namespace container {
-#else
-namespace boost {
-namespace container {
-#endif
 
 /// @cond
 namespace container_detail {
@@ -73,10 +68,10 @@ struct list_node
    T m_data;
 };
 
-template
+template
 struct intrusive_list_type
 {
-   typedef boost::container::allocator_traits   allocator_traits_type;
+   typedef boost::container::allocator_traits   allocator_traits_type;
    typedef typename allocator_traits_type::value_type value_type;
    typedef typename boost::intrusive::pointer_traits
       ::template
@@ -213,27 +208,27 @@ class list_iterator
 //! not be invalidated or made to point to different elements unless that invalidation
 //! or mutation is explicit.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template  >
+template  >
 #else
-template 
+template 
 #endif
 class list
    : protected container_detail::node_alloc_holder
-      ::type>
+      ::type>
 {
    /// @cond
    typedef typename
-      container_detail::intrusive_list_type::type Icont;
-   typedef container_detail::node_alloc_holder        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     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_traits_type;
+      container_detail::intrusive_list_type::type Icont;
+   typedef container_detail::node_alloc_holder  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       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_traits_type;
 
    class equal_to_value
    {
@@ -277,19 +272,19 @@ class list
    //
    //////////////////////////////////////////////
 
-   typedef T                                                                  value_type;
-   typedef typename ::boost::container::allocator_traits::pointer          pointer;
-   typedef typename ::boost::container::allocator_traits::const_pointer    const_pointer;
-   typedef typename ::boost::container::allocator_traits::reference        reference;
-   typedef typename ::boost::container::allocator_traits::const_reference  const_reference;
-   typedef typename ::boost::container::allocator_traits::size_type        size_type;
-   typedef typename ::boost::container::allocator_traits::difference_type  difference_type;
-   typedef A                                                                  allocator_type;
-   typedef BOOST_CONTAINER_IMPDEF(NodeAlloc)                                  stored_allocator_type;
-   typedef BOOST_CONTAINER_IMPDEF(iterator_impl)                              iterator;
-   typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl)                        const_iterator;
-   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)            reverse_iterator;
-   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)      const_reverse_iterator;
+   typedef T                                                                           value_type;
+   typedef typename ::boost::container::allocator_traits::pointer           pointer;
+   typedef typename ::boost::container::allocator_traits::const_pointer     const_pointer;
+   typedef typename ::boost::container::allocator_traits::reference         reference;
+   typedef typename ::boost::container::allocator_traits::const_reference   const_reference;
+   typedef typename ::boost::container::allocator_traits::size_type         size_type;
+   typedef typename ::boost::container::allocator_traits::difference_type   difference_type;
+   typedef Allocator                                                                   allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(NodeAlloc)                                           stored_allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(iterator_impl)                                       iterator;
+   typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl)                                 const_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)                     reverse_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)               const_reverse_iterator;
 
    //////////////////////////////////////////////
    //
@@ -323,7 +318,7 @@ class list
    //!
    //! Complexity: Linear to n.
    explicit list(size_type n)
-      : AllocHolder(A())
+      : AllocHolder(Allocator())
    {  this->resize(n);  }
 
    //! Effects: Constructs a list that will use a copy of allocator a
@@ -333,7 +328,7 @@ class list
    //!   throws or T's default or copy constructor throws.
    //!
    //! Complexity: Linear to n.
-   list(size_type n, const T& value, const A& a = A())
+   list(size_type n, const T& value, const Allocator& a = Allocator())
       : AllocHolder(a)
    {  this->insert(this->cbegin(), n, value);  }
 
@@ -393,7 +388,7 @@ class list
    //!
    //! Complexity: Linear to the range [first, last).
    template 
-   list(InpIt first, InpIt last, const A &a = A())
+   list(InpIt first, InpIt last, const Allocator &a = Allocator())
       : AllocHolder(a)
    {  this->insert(this->cbegin(), first, last);  }
 
@@ -1430,13 +1425,13 @@ class list
 
 };
 
-template 
-inline bool operator==(const list& x, const list& y)
+template 
+inline bool operator==(const list& x, const list& y)
 {
    if(x.size() != y.size()){
       return false;
    }
-   typedef typename list::const_iterator const_iterator;
+   typedef typename list::const_iterator const_iterator;
    const_iterator end1 = x.end();
 
    const_iterator i1 = x.begin();
@@ -1448,39 +1443,39 @@ inline bool operator==(const list& x, const list& y)
    return i1 == end1;
 }
 
-template 
-inline bool operator<(const list& x,
-                      const list& y)
+template 
+inline bool operator<(const list& x,
+                      const list& y)
 {
   return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
 }
 
-template 
-inline bool operator!=(const list& x, const list& y)
+template 
+inline bool operator!=(const list& x, const list& y)
 {
   return !(x == y);
 }
 
-template 
-inline bool operator>(const list& x, const list& y)
+template 
+inline bool operator>(const list& x, const list& y)
 {
   return y < x;
 }
 
-template 
-inline bool operator<=(const list& x, const list& y)
+template 
+inline bool operator<=(const list& x, const list& y)
 {
   return !(y < x);
 }
 
-template 
-inline bool operator>=(const list& x, const list& y)
+template 
+inline bool operator>=(const list& x, const list& y)
 {
   return !(x < y);
 }
 
-template 
-inline void swap(list& x, list& y)
+template 
+inline void swap(list& x, list& y)
 {
   x.swap(y);
 }
@@ -1491,10 +1486,10 @@ inline void swap(list& x, list& y)
 /*
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
-template 
-struct has_trivial_destructor_after_move >
+template 
+struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor::value;
 };
 */
 namespace container {
@@ -1505,4 +1500,4 @@ namespace container {
 
 #include 
 
-#endif // BOOST_CONTAINER_LIST_HPP_
+#endif // BOOST_CONTAINER_LIST_HPP
diff --git a/include/boost/container/map.hpp b/include/boost/container/map.hpp
index 3cff41b..cde829e 100644
--- a/include/boost/container/map.hpp
+++ b/include/boost/container/map.hpp
@@ -35,24 +35,18 @@
 #include 
 #include 
 
-
-#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
 namespace boost {
 namespace container {
-#else
-namespace boost {
-namespace container {
-#endif
 
 /// @cond
 // Forward declarations of operators == and <, needed for friend declarations.
-template 
-inline bool operator==(const map& x,
-                       const map& y);
+template 
+inline bool operator==(const map& x,
+                       const map& y);
 
-template 
-inline bool operator<(const map& x,
-                      const map& y);
+template 
+inline bool operator<(const map& x,
+                      const map& y);
 /// @endcond
 
 //! A map is a kind of associative container that supports unique keys (contains at
@@ -63,67 +57,63 @@ inline bool operator<(const map& x,
 //! container and of an associative container. For a
 //! map the key_type is Key and the value_type is std::pair.
 //!
-//! Pred is the ordering function for Keys (e.g. std::less).
+//! Compare is the ordering function for Keys (e.g. std::less).
 //!
-//! A is the allocator to allocate the value_types
+//! Allocator is the allocator to allocate the value_types
 //! (e.g. allocator< std::pair > ).
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template , class A = std::allocator< std::pair< const Key, T> > >
+template , class Allocator = std::allocator< std::pair< const Key, T> > >
 #else
-template 
+template 
 #endif
 class map
 {
    /// @cond
    private:
    BOOST_COPYABLE_AND_MOVABLE(map)
-   typedef container_detail::rbtree,
-                           container_detail::select1st< std::pair >,
-                           Pred,
-                           A> tree_t;
-   tree_t m_tree;  // red-black tree representing map
 
+   typedef std::pair  value_type_impl;
+   typedef container_detail::rbtree
+      , Compare, Allocator> tree_t;
+   typedef container_detail::pair  movable_value_type_impl;
+   typedef container_detail::tree_value_compare
+      < Key, value_type_impl, Compare, container_detail::select1st
+      >  value_compare_impl;
+   tree_t m_tree;  // red-black tree representing map
    /// @endcond
 
    public:
+   //////////////////////////////////////////////
+   //
+   //                    types
+   //
+   //////////////////////////////////////////////
 
-   // typedefs:
-   typedef typename tree_t::key_type               key_type;
-   typedef typename tree_t::value_type             value_type;
-   typedef typename tree_t::pointer                pointer;
-   typedef typename tree_t::const_pointer          const_pointer;
-   typedef typename tree_t::reference              reference;
-   typedef typename tree_t::const_reference        const_reference;
-   typedef T                                       mapped_type;
-   typedef Pred                                    key_compare;
-   typedef typename tree_t::iterator               iterator;
-   typedef typename tree_t::const_iterator         const_iterator;
-   typedef typename tree_t::reverse_iterator       reverse_iterator;
-   typedef typename tree_t::const_reverse_iterator const_reverse_iterator;
-   typedef typename tree_t::size_type              size_type;
-   typedef typename tree_t::difference_type        difference_type;
-   typedef typename tree_t::allocator_type         allocator_type;
-   typedef typename tree_t::stored_allocator_type  stored_allocator_type;
-   typedef std::pair        nonconst_value_type;
-   typedef container_detail::pair
-                            nonconst_impl_value_type;
+   typedef Key                                                                      key_type;
+   typedef T                                                                        mapped_type;
+   typedef std::pair                                                  value_type;
+   typedef typename boost::container::allocator_traits::pointer          pointer;
+   typedef typename boost::container::allocator_traits::const_pointer    const_pointer;
+   typedef typename boost::container::allocator_traits::reference        reference;
+   typedef typename boost::container::allocator_traits::const_reference  const_reference;
+   typedef typename boost::container::allocator_traits::size_type        size_type;
+   typedef typename boost::container::allocator_traits::difference_type  difference_type;
+   typedef Allocator                                                                allocator_type;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::stored_allocator_type)           stored_allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(value_compare_impl)                               value_compare;
+   typedef Compare                                                                  key_compare;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::iterator)                        iterator;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_iterator)                  const_iterator;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::reverse_iterator)                reverse_iterator;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_reverse_iterator)          const_reverse_iterator;
+   typedef std::pair                                         nonconst_value_type;
+   typedef BOOST_CONTAINER_IMPDEF(movable_value_type_impl)                          movable_value_type;
 
-   /// @cond
-   class value_compare_impl
-      :  public Pred,
-         public std::binary_function
-   {
-      friend class map;
-    protected :
-      value_compare_impl(const Pred &c) : Pred(c) {}
-    public:
-      bool operator()(const value_type& x, const value_type& y) const {
-         return Pred::operator()(x.first, y.first);
-      }
-   };
-   /// @endcond
-   typedef value_compare_impl             value_compare;
+   //////////////////////////////////////////////
+   //
+   //          construct/copy/destroy
+   //
+   //////////////////////////////////////////////
 
    //! Effects: Default constructs an empty map.
    //!
@@ -132,19 +122,19 @@ class map
       : m_tree()
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value));
    }
 
    //! Effects: Constructs an empty map using the specified comparison object
    //! and allocator.
    //!
    //! Complexity: Constant.
-   explicit map(const Pred& comp,
+   explicit map(const Compare& comp,
                 const allocator_type& a = allocator_type())
       : m_tree(comp, a)
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value));
    }
 
    //! Effects: Constructs an empty map using the specified comparison object and
@@ -153,12 +143,12 @@ class map
    //! Complexity: Linear in N if the range [first ,last ) is already sorted using
    //! comp and otherwise N logN, where N is last - first.
    template 
-   map(InputIterator first, InputIterator last, const Pred& comp = Pred(),
+   map(InputIterator first, InputIterator last, const Compare& comp = Compare(),
          const allocator_type& a = allocator_type())
       : m_tree(true, first, last, comp, a)
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value));
    }
 
    //! Effects: Constructs an empty map using the specified comparison object and
@@ -171,11 +161,11 @@ class map
    //! Complexity: Linear in N.
    template 
    map( ordered_unique_range_t, InputIterator first, InputIterator last
-      , const Pred& comp = Pred(), const allocator_type& a = allocator_type())
+      , const Compare& comp = Compare(), const allocator_type& a = allocator_type())
       : m_tree(ordered_range, first, last, comp, a)
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value));
    }
 
    //! Effects: Copy constructs a map.
@@ -185,7 +175,7 @@ class map
       : m_tree(x.m_tree)
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value));
    }
 
    //! Effects: Move constructs a map. Constructs *this using x's resources.
@@ -197,7 +187,7 @@ class map
       : m_tree(boost::move(x.m_tree))
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value));
    }
 
    //! Effects: Copy constructs a map using the specified allocator.
@@ -207,7 +197,7 @@ class map
       : m_tree(x.m_tree, a)
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value));
    }
 
    //! Effects: Move constructs a map using the specified allocator.
@@ -220,7 +210,7 @@ class map
       : m_tree(boost::move(x.m_tree), a)
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value));
    }
 
    //! Effects: Makes *this a copy of x.
@@ -235,20 +225,6 @@ class map
    map& operator=(BOOST_RV_REF(map) x)
    {  m_tree = boost::move(x.m_tree);   return *this;  }
 
-   //! Effects: Returns the comparison object out
-   //!   of which a was constructed.
-   //!
-   //! Complexity: Constant.
-   key_compare key_comp() const
-   { return m_tree.key_comp(); }
-
-   //! Effects: Returns an object of value_compare constructed out
-   //!   of the comparison object.
-   //!
-   //! Complexity: Constant.
-   value_compare value_comp() const
-   { return value_compare(m_tree.key_comp()); }
-
    //! Effects: Returns a copy of the Allocator that
    //!   was passed to the object's constructor.
    //!
@@ -276,6 +252,12 @@ class map
    const stored_allocator_type &get_stored_allocator() const
    { return m_tree.get_stored_allocator(); }
 
+   //////////////////////////////////////////////
+   //
+   //                iterators
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Returns an iterator to the first element contained in the container.
    //!
    //! Throws: Nothing.
@@ -292,14 +274,6 @@ class map
    const_iterator begin() const
    { return this->cbegin(); }
 
-   //! Effects: Returns a const_iterator to the first element contained in the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_iterator cbegin() const
-   { return m_tree.begin(); }
-
    //! Effects: Returns an iterator to the end of the container.
    //!
    //! Throws: Nothing.
@@ -316,14 +290,6 @@ class map
    const_iterator end() const
    { return this->cend(); }
 
-   //! Effects: Returns a const_iterator to the end of the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_iterator cend() const
-   { return m_tree.end(); }
-
    //! Effects: Returns a reverse_iterator pointing to the beginning
    //! of the reversed container.
    //!
@@ -342,15 +308,6 @@ class map
    const_reverse_iterator rbegin() const
    { return this->crbegin(); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning
-   //! of the reversed container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_reverse_iterator crbegin() const
-   { return m_tree.rbegin(); }
-
    //! Effects: Returns a reverse_iterator pointing to the end
    //! of the reversed container.
    //!
@@ -369,6 +326,31 @@ class map
    const_reverse_iterator rend() const
    { return this->crend(); }
 
+   //! Effects: Returns a const_iterator to the first element contained in the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_iterator cbegin() const
+   { return m_tree.begin(); }
+
+   //! Effects: Returns a const_iterator to the end of the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_iterator cend() const
+   { return m_tree.end(); }
+
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_reverse_iterator crbegin() const
+   { return m_tree.rbegin(); }
+
    //! Effects: Returns a const_reverse_iterator pointing to the end
    //! of the reversed container.
    //!
@@ -378,6 +360,12 @@ class map
    const_reverse_iterator crend() const
    { return m_tree.rend(); }
 
+   //////////////////////////////////////////////
+   //
+   //                capacity
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Returns true if the container contains no elements.
    //!
    //! Throws: Nothing.
@@ -402,11 +390,17 @@ class map
    size_type max_size() const
    { return m_tree.max_size(); }
 
+   //////////////////////////////////////////////
+   //
+   //               element access
+   //
+   //////////////////////////////////////////////
+
    #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
    //! Effects: If there is no key equivalent to x in the map, inserts
    //! value_type(x, T()) into the map.
    //!
-   //! Returns: A reference to the mapped_type corresponding to x in *this.
+   //! Returns: Allocator reference to the mapped_type corresponding to x in *this.
    //!
    //! Complexity: Logarithmic.
    mapped_type& operator[](const key_type &k);
@@ -414,15 +408,15 @@ class map
    //! Effects: If there is no key equivalent to x in the map, inserts
    //! value_type(boost::move(x), T()) into the map (the key is move-constructed)
    //!
-   //! Returns: A reference to the mapped_type corresponding to x in *this.
+   //! Returns: Allocator reference to the mapped_type corresponding to x in *this.
    //!
    //! Complexity: Logarithmic.
    mapped_type& operator[](key_type &&k);
    #else
-   BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, priv_subscript)
+   BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript)
    #endif
 
-   //! Returns: A reference to the element whose key is equivalent to x.
+   //! Returns: Allocator reference to the element whose key is equivalent to x.
    //! Throws: An exception object of type out_of_range if no such element is present.
    //! Complexity: logarithmic.
    T& at(const key_type& k)
@@ -434,7 +428,7 @@ class map
       return i->second;
    }
 
-   //! Returns: A reference to the element whose key is equivalent to x.
+   //! Returns: Allocator reference to the element whose key is equivalent to x.
    //! Throws: An exception object of type out_of_range if no such element is present.
    //! Complexity: logarithmic.
    const T& at(const key_type& k) const
@@ -446,13 +440,11 @@ class map
       return i->second;
    }
 
-   //! Effects: Swaps the contents of *this and x.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   void swap(map& x)
-   { m_tree.swap(x.m_tree); }
+   //////////////////////////////////////////////
+   //
+   //                modifiers
+   //
+   //////////////////////////////////////////////
 
    //! Effects: Inserts x if and only if there is no element in the container
    //!   with key equivalent to the key of x.
@@ -495,7 +487,7 @@ class map
    //!   points to the element with key equivalent to the key of x.
    //!
    //! Complexity: Logarithmic.
-   std::pair insert(BOOST_RV_REF(nonconst_impl_value_type) x)
+   std::pair insert(BOOST_RV_REF(movable_value_type) x)
    { return m_tree.insert_unique(boost::move(x)); }
 
    //! Effects: Move constructs a new value from x if and only if there is
@@ -518,7 +510,7 @@ class map
    //!
    //! Complexity: Logarithmic in general, but amortized constant if t
    //!   is inserted right before p.
-   iterator insert(iterator position, const value_type& x)
+   iterator insert(const_iterator position, const value_type& x)
    { return m_tree.insert_unique(position, x); }
 
    //! Effects: Move constructs a new value from x if and only if there is
@@ -530,7 +522,7 @@ class map
    //!
    //! Complexity: Logarithmic in general, but amortized constant if t
    //!   is inserted right before p.
-   iterator insert(iterator position, BOOST_RV_REF(nonconst_value_type) x)
+   iterator insert(const_iterator position, BOOST_RV_REF(nonconst_value_type) x)
    { return m_tree.insert_unique(position, boost::move(x)); }
 
    //! Effects: Move constructs a new value from x if and only if there is
@@ -542,7 +534,7 @@ class map
    //!
    //! Complexity: Logarithmic in general, but amortized constant if t
    //!   is inserted right before p.
-   iterator insert(iterator position, BOOST_RV_REF(nonconst_impl_value_type) x)
+   iterator insert(const_iterator position, BOOST_RV_REF(movable_value_type) x)
    { return m_tree.insert_unique(position, boost::move(x)); }
 
    //! Effects: Inserts a copy of x in the container.
@@ -551,7 +543,7 @@ class map
    //! Returns: An iterator pointing to the element with key equivalent to the key of x.
    //!
    //! Complexity: Logarithmic.
-   iterator insert(iterator position, const nonconst_value_type& x)
+   iterator insert(const_iterator position, const nonconst_value_type& x)
    { return m_tree.insert_unique(position, x); }
 
    //! Effects: Inserts an element move constructed from x in the container.
@@ -560,7 +552,7 @@ class map
    //! Returns: An iterator pointing to the element with key equivalent to the key of x.
    //!
    //! Complexity: Logarithmic.
-   iterator insert(iterator position, BOOST_RV_REF(value_type) x)
+   iterator insert(const_iterator position, BOOST_RV_REF(value_type) x)
    { return m_tree.insert_unique(position, boost::move(x)); }
 
    //! Requires: first, last are not iterators into *this.
@@ -648,6 +640,14 @@ class map
    iterator erase(const_iterator first, const_iterator last)
    { return m_tree.erase(first, last); }
 
+   //! Effects: Swaps the contents of *this and x.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   void swap(map& x)
+   { m_tree.swap(x.m_tree); }
+
    //! Effects: erase(a.begin(),a.end()).
    //!
    //! Postcondition: size() == 0.
@@ -656,6 +656,32 @@ class map
    void clear()
    { m_tree.clear(); }
 
+   //////////////////////////////////////////////
+   //
+   //                observers
+   //
+   //////////////////////////////////////////////
+
+   //! Effects: Returns the comparison object out
+   //!   of which a was constructed.
+   //!
+   //! Complexity: Constant.
+   key_compare key_comp() const
+   { return m_tree.key_comp(); }
+
+   //! Effects: Returns an object of value_compare constructed out
+   //!   of the comparison object.
+   //!
+   //! Complexity: Constant.
+   value_compare value_comp() const
+   { return value_compare(m_tree.key_comp()); }
+
+   //////////////////////////////////////////////
+   //
+   //              map operations
+   //
+   //////////////////////////////////////////////
+
    //! Returns: An iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
@@ -663,7 +689,7 @@ class map
    iterator find(const key_type& x)
    { return m_tree.find(x); }
 
-   //! Returns: A const_iterator pointing to an element with the key
+   //! Returns: Allocator const_iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.
@@ -683,7 +709,7 @@ class map
    iterator lower_bound(const key_type& x)
    {  return m_tree.lower_bound(x); }
 
-   //! Returns: A const iterator pointing to the first element with key not
+   //! Returns: Allocator const iterator pointing to the first element with key not
    //!   less than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
@@ -697,7 +723,7 @@ class map
    iterator upper_bound(const key_type& x)
    {  return m_tree.upper_bound(x); }
 
-   //! Returns: A const iterator pointing to the first element with key not
+   //! Returns: Allocator const iterator pointing to the first element with key not
    //!   less than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
@@ -731,7 +757,7 @@ class map
       // i->first is greater than or equivalent to k.
       if (i == end() || key_comp()(k, (*i).first)){
          container_detail::value_init m;
-         nonconst_impl_value_type val(k, boost::move(m.m_t));
+         movable_value_type val(k, boost::move(m.m_t));
          i = insert(i, boost::move(val));
       }
       return (*i).second;
@@ -745,7 +771,7 @@ class map
       // i->first is greater than or equivalent to k.
       if (i == end() || key_comp()(k, (*i).first)){
          container_detail::value_init m;
-         nonconst_impl_value_type val(boost::move(k), boost::move(m.m_t));
+         movable_value_type val(boost::move(k), boost::move(m.m_t));
          i = insert(i, boost::move(val));
       }
       return (*i).second;
@@ -754,60 +780,60 @@ class map
    /// @endcond
 };
 
-template 
-inline bool operator==(const map& x,
-                       const map& y)
+template 
+inline bool operator==(const map& x,
+                       const map& y)
    {  return x.m_tree == y.m_tree;  }
 
-template 
-inline bool operator<(const map& x,
-                      const map& y)
+template 
+inline bool operator<(const map& x,
+                      const map& y)
    {  return x.m_tree < y.m_tree;   }
 
-template 
-inline bool operator!=(const map& x,
-                       const map& y)
+template 
+inline bool operator!=(const map& x,
+                       const map& y)
    {  return !(x == y); }
 
-template 
-inline bool operator>(const map& x,
-                      const map& y)
+template 
+inline bool operator>(const map& x,
+                      const map& y)
    {  return y < x;  }
 
-template 
-inline bool operator<=(const map& x,
-                       const map& y)
+template 
+inline bool operator<=(const map& x,
+                       const map& y)
    {  return !(y < x);  }
 
-template 
-inline bool operator>=(const map& x,
-                       const map& y)
+template 
+inline bool operator>=(const map& x,
+                       const map& y)
    {  return !(x < y);  }
 
-template 
-inline void swap(map& x, map& y)
+template 
+inline void swap(map& x, map& y)
    {  x.swap(y);  }
 
 /// @cond
 
 // Forward declaration of operators < and ==, needed for friend declaration.
 
-template 
-inline bool operator==(const multimap& x,
-                       const multimap& y);
+template 
+inline bool operator==(const multimap& x,
+                       const multimap& y);
 
-template 
-inline bool operator<(const multimap& x,
-                      const multimap& y);
+template 
+inline bool operator<(const multimap& x,
+                      const multimap& y);
 
 }  //namespace container {
 /*
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
-template 
-struct has_trivial_destructor_after_move >
+template 
+struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
 };
 */
 namespace container {
@@ -823,68 +849,63 @@ namespace container {
 //! container and of an associative container. For a
 //! map the key_type is Key and the value_type is std::pair.
 //!
-//! Pred is the ordering function for Keys (e.g. std::less).
+//! Compare is the ordering function for Keys (e.g. std::less).
 //!
-//! A is the allocator to allocate the value_types
+//! Allocator is the allocator to allocate the value_types
 //!(e.g. allocator< std::pair<const Key, T> >).
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template , class A = std::allocator< std::pair< const Key, T> > >
+template , class Allocator = std::allocator< std::pair< const Key, T> > >
 #else
-template 
+template 
 #endif
 class multimap
 {
    /// @cond
    private:
    BOOST_COPYABLE_AND_MOVABLE(multimap)
-   typedef container_detail::rbtree,
-                           container_detail::select1st< std::pair >,
-                           Pred,
-                           A> tree_t;
+
+   typedef std::pair  value_type_impl;
+   typedef container_detail::rbtree
+      , Compare, Allocator> tree_t;
+   typedef container_detail::pair  movable_value_type_impl;
+   typedef container_detail::tree_value_compare
+      < Key, value_type_impl, Compare, container_detail::select1st
+      >  value_compare_impl;
    tree_t m_tree;  // red-black tree representing map
-   typedef typename container_detail::
-      move_const_ref_type::type insert_key_const_ref_type;
    /// @endcond
 
    public:
+   //////////////////////////////////////////////
+   //
+   //                    types
+   //
+   //////////////////////////////////////////////
 
-   // typedefs:
-   typedef typename tree_t::key_type               key_type;
-   typedef typename tree_t::value_type             value_type;
-   typedef typename tree_t::pointer                pointer;
-   typedef typename tree_t::const_pointer          const_pointer;
-   typedef typename tree_t::reference              reference;
-   typedef typename tree_t::const_reference        const_reference;
-   typedef T                                       mapped_type;
-   typedef Pred                                    key_compare;
-   typedef typename tree_t::iterator               iterator;
-   typedef typename tree_t::const_iterator         const_iterator;
-   typedef typename tree_t::reverse_iterator       reverse_iterator;
-   typedef typename tree_t::const_reverse_iterator const_reverse_iterator;
-   typedef typename tree_t::size_type              size_type;
-   typedef typename tree_t::difference_type        difference_type;
-   typedef typename tree_t::allocator_type         allocator_type;
-   typedef typename tree_t::stored_allocator_type  stored_allocator_type;
-   typedef std::pair        nonconst_value_type;
-   typedef container_detail::pair
-                            nonconst_impl_value_type;
+   typedef Key                                                                      key_type;
+   typedef T                                                                        mapped_type;
+   typedef std::pair                                                  value_type;
+   typedef typename boost::container::allocator_traits::pointer          pointer;
+   typedef typename boost::container::allocator_traits::const_pointer    const_pointer;
+   typedef typename boost::container::allocator_traits::reference        reference;
+   typedef typename boost::container::allocator_traits::const_reference  const_reference;
+   typedef typename boost::container::allocator_traits::size_type        size_type;
+   typedef typename boost::container::allocator_traits::difference_type  difference_type;
+   typedef Allocator                                                                allocator_type;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::stored_allocator_type)           stored_allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(value_compare_impl)                               value_compare;
+   typedef Compare                                                                  key_compare;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::iterator)                        iterator;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_iterator)                  const_iterator;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::reverse_iterator)                reverse_iterator;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_reverse_iterator)          const_reverse_iterator;
+   typedef std::pair                                         nonconst_value_type;
+   typedef BOOST_CONTAINER_IMPDEF(movable_value_type_impl)                          movable_value_type;
 
-   /// @cond
-   class value_compare_impl
-      :  public Pred,
-         public std::binary_function
-   {
-      friend class multimap;
-    protected :
-      value_compare_impl(const Pred &c) : Pred(c) {}
-    public:
-      bool operator()(const value_type& x, const value_type& y) const {
-         return Pred::operator()(x.first, y.first);
-      }
-   };
-   /// @endcond
-   typedef value_compare_impl                      value_compare;
+   //////////////////////////////////////////////
+   //
+   //          construct/copy/destroy
+   //
+   //////////////////////////////////////////////
 
    //! Effects: Default constructs an empty multimap.
    //!
@@ -893,18 +914,18 @@ class multimap
       : m_tree()
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value));
    }
 
    //! Effects: Constructs an empty multimap using the specified comparison
    //!   object and allocator.
    //!
    //! Complexity: Constant.
-   explicit multimap(const Pred& comp, const allocator_type& a = allocator_type())
+   explicit multimap(const Compare& comp, const allocator_type& a = allocator_type())
       : m_tree(comp, a)
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value));
    }
 
    //! Effects: Constructs an empty multimap using the specified comparison object
@@ -914,12 +935,12 @@ class multimap
    //! comp and otherwise N logN, where N is last - first.
    template 
    multimap(InputIterator first, InputIterator last,
-            const Pred& comp = Pred(),
+            const Compare& comp = Compare(),
             const allocator_type& a = allocator_type())
       : m_tree(false, first, last, comp, a)
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value));
    }
 
    //! Effects: Constructs an empty multimap using the specified comparison object and
@@ -930,7 +951,7 @@ class multimap
    //!
    //! Complexity: Linear in N.
    template 
-   multimap(ordered_range_t ordered_range, InputIterator first, InputIterator last, const Pred& comp = Pred(),
+   multimap(ordered_range_t ordered_range, InputIterator first, InputIterator last, const Compare& comp = Compare(),
          const allocator_type& a = allocator_type())
       : m_tree(ordered_range, first, last, comp, a)
    {}
@@ -942,7 +963,7 @@ class multimap
       : m_tree(x.m_tree)
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value));
    }
 
    //! Effects: Move constructs a multimap. Constructs *this using x's resources.
@@ -954,7 +975,7 @@ class multimap
       : m_tree(boost::move(x.m_tree))
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value));
    }
 
    //! Effects: Copy constructs a multimap.
@@ -964,7 +985,7 @@ class multimap
       : m_tree(x.m_tree, a)
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value));
    }
 
    //! Effects: Move constructs a multimap using the specified allocator.
@@ -976,7 +997,7 @@ class multimap
       : m_tree(boost::move(x.m_tree), a)
    {
       //Allocator type must be std::pair
-      BOOST_STATIC_ASSERT((container_detail::is_same, typename A::value_type>::value));
+      BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value));
    }
 
    //! Effects: Makes *this a copy of x.
@@ -991,20 +1012,6 @@ class multimap
    multimap& operator=(BOOST_RV_REF(multimap) x)
    {  m_tree = boost::move(x.m_tree);   return *this;  }
 
-   //! Effects: Returns the comparison object out
-   //!   of which a was constructed.
-   //!
-   //! Complexity: Constant.
-   key_compare key_comp() const
-   { return m_tree.key_comp(); }
-
-   //! Effects: Returns an object of value_compare constructed out
-   //!   of the comparison object.
-   //!
-   //! Complexity: Constant.
-   value_compare value_comp() const
-   { return value_compare(m_tree.key_comp()); }
-
    //! Effects: Returns a copy of the Allocator that
    //!   was passed to the object's constructor.
    //!
@@ -1032,6 +1039,12 @@ class multimap
    const stored_allocator_type &get_stored_allocator() const
    { return m_tree.get_stored_allocator(); }
 
+   //////////////////////////////////////////////
+   //
+   //                iterators
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Returns an iterator to the first element contained in the container.
    //!
    //! Throws: Nothing.
@@ -1048,14 +1061,6 @@ class multimap
    const_iterator begin() const
    { return this->cbegin(); }
 
-   //! Effects: Returns a const_iterator to the first element contained in the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_iterator cbegin() const
-   { return m_tree.begin(); }
-
    //! Effects: Returns an iterator to the end of the container.
    //!
    //! Throws: Nothing.
@@ -1072,14 +1077,6 @@ class multimap
    const_iterator end() const
    { return this->cend(); }
 
-   //! Effects: Returns a const_iterator to the end of the container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_iterator cend() const
-   { return m_tree.end(); }
-
    //! Effects: Returns a reverse_iterator pointing to the beginning
    //! of the reversed container.
    //!
@@ -1098,15 +1095,6 @@ class multimap
    const_reverse_iterator rbegin() const
    { return this->crbegin(); }
 
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning
-   //! of the reversed container.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_reverse_iterator crbegin() const
-   { return m_tree.rbegin(); }
-
    //! Effects: Returns a reverse_iterator pointing to the end
    //! of the reversed container.
    //!
@@ -1125,6 +1113,31 @@ class multimap
    const_reverse_iterator rend() const
    { return this->crend(); }
 
+   //! Effects: Returns a const_iterator to the first element contained in the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_iterator cbegin() const
+   { return m_tree.begin(); }
+
+   //! Effects: Returns a const_iterator to the end of the container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_iterator cend() const
+   { return m_tree.end(); }
+
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed container.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_reverse_iterator crbegin() const
+   { return m_tree.rbegin(); }
+
    //! Effects: Returns a const_reverse_iterator pointing to the end
    //! of the reversed container.
    //!
@@ -1134,6 +1147,12 @@ class multimap
    const_reverse_iterator crend() const
    { return m_tree.rend(); }
 
+   //////////////////////////////////////////////
+   //
+   //                capacity
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Returns true if the container contains no elements.
    //!
    //! Throws: Nothing.
@@ -1158,94 +1177,11 @@ class multimap
    size_type max_size() const
    { return m_tree.max_size(); }
 
-   //! Effects: Swaps the contents of *this and x.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   void swap(multimap& x)
-   { m_tree.swap(x.m_tree); }
-
-   //! Effects: Inserts x and returns the iterator pointing to the
-   //!   newly inserted element.
-   //!
-   //! Complexity: Logarithmic.
-   iterator insert(const value_type& x)
-   { return m_tree.insert_equal(x); }
-
-   //! Effects: Inserts a new value constructed from x and returns
-   //!   the iterator pointing to the newly inserted element.
-   //!
-   //! Complexity: Logarithmic.
-   iterator insert(const nonconst_value_type& x)
-   { return m_tree.insert_equal(x); }
-
-   //! Effects: Inserts a new value move-constructed from x and returns
-   //!   the iterator pointing to the newly inserted element.
-   //!
-   //! Complexity: Logarithmic.
-   iterator insert(BOOST_RV_REF(nonconst_value_type) x)
-   { return m_tree.insert_equal(boost::move(x)); }
-
-   //! Effects: Inserts a new value move-constructed from x and returns
-   //!   the iterator pointing to the newly inserted element.
-   //!
-   //! Complexity: Logarithmic.
-   iterator insert(BOOST_RV_REF(nonconst_impl_value_type) x)
-   { return m_tree.insert_equal(boost::move(x)); }
-
-   //! Effects: Inserts a copy of x in the container.
-   //!   p is a hint pointing to where the insert should start to search.
-   //!
-   //! Returns: An iterator pointing to the element with key equivalent
-   //!   to the key of x.
-   //!
-   //! Complexity: Logarithmic in general, but amortized constant if t
-   //!   is inserted right before p.
-   iterator insert(iterator position, const value_type& x)
-   { return m_tree.insert_equal(position, x); }
-
-   //! Effects: Inserts a new value constructed from x in the container.
-   //!   p is a hint pointing to where the insert should start to search.
-   //!
-   //! Returns: An iterator pointing to the element with key equivalent
-   //!   to the key of x.
-   //!
-   //! Complexity: Logarithmic in general, but amortized constant if t
-   //!   is inserted right before p.
-   iterator insert(iterator position, const nonconst_value_type& x)
-   { return m_tree.insert_equal(position, x); }
-
-   //! Effects: Inserts a new value move constructed from x in the container.
-   //!   p is a hint pointing to where the insert should start to search.
-   //!
-   //! Returns: An iterator pointing to the element with key equivalent
-   //!   to the key of x.
-   //!
-   //! Complexity: Logarithmic in general, but amortized constant if t
-   //!   is inserted right before p.
-   iterator insert(iterator position, BOOST_RV_REF(nonconst_value_type) x)
-   { return m_tree.insert_equal(position, boost::move(x)); }
-
-   //! Effects: Inserts a new value move constructed from x in the container.
-   //!   p is a hint pointing to where the insert should start to search.
-   //!
-   //! Returns: An iterator pointing to the element with key equivalent
-   //!   to the key of x.
-   //!
-   //! Complexity: Logarithmic in general, but amortized constant if t
-   //!   is inserted right before p.
-   iterator insert(iterator position, BOOST_RV_REF(nonconst_impl_value_type) x)
-   { return m_tree.insert_equal(position, boost::move(x)); }
-
-   //! Requires: first, last are not iterators into *this.
-   //!
-   //! Effects: inserts each element from the range [first,last) .
-   //!
-   //! Complexity: At most N log(size()+N) (N is the distance from first to last)
-   template 
-   void insert(InputIterator first, InputIterator last)
-   {  m_tree.insert_equal(first, last); }
+   //////////////////////////////////////////////
+   //
+   //                modifiers
+   //
+   //////////////////////////////////////////////
 
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
@@ -1293,6 +1229,87 @@ class multimap
 
    #endif   //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
+   //! Effects: Inserts x and returns the iterator pointing to the
+   //!   newly inserted element.
+   //!
+   //! Complexity: Logarithmic.
+   iterator insert(const value_type& x)
+   { return m_tree.insert_equal(x); }
+
+   //! Effects: Inserts a new value constructed from x and returns
+   //!   the iterator pointing to the newly inserted element.
+   //!
+   //! Complexity: Logarithmic.
+   iterator insert(const nonconst_value_type& x)
+   { return m_tree.insert_equal(x); }
+
+   //! Effects: Inserts a new value move-constructed from x and returns
+   //!   the iterator pointing to the newly inserted element.
+   //!
+   //! Complexity: Logarithmic.
+   iterator insert(BOOST_RV_REF(nonconst_value_type) x)
+   { return m_tree.insert_equal(boost::move(x)); }
+
+   //! Effects: Inserts a new value move-constructed from x and returns
+   //!   the iterator pointing to the newly inserted element.
+   //!
+   //! Complexity: Logarithmic.
+   iterator insert(BOOST_RV_REF(movable_value_type) x)
+   { return m_tree.insert_equal(boost::move(x)); }
+
+   //! Effects: Inserts a copy of x in the container.
+   //!   p is a hint pointing to where the insert should start to search.
+   //!
+   //! Returns: An iterator pointing to the element with key equivalent
+   //!   to the key of x.
+   //!
+   //! Complexity: Logarithmic in general, but amortized constant if t
+   //!   is inserted right before p.
+   iterator insert(const_iterator position, const value_type& x)
+   { return m_tree.insert_equal(position, x); }
+
+   //! Effects: Inserts a new value constructed from x in the container.
+   //!   p is a hint pointing to where the insert should start to search.
+   //!
+   //! Returns: An iterator pointing to the element with key equivalent
+   //!   to the key of x.
+   //!
+   //! Complexity: Logarithmic in general, but amortized constant if t
+   //!   is inserted right before p.
+   iterator insert(const_iterator position, const nonconst_value_type& x)
+   { return m_tree.insert_equal(position, x); }
+
+   //! Effects: Inserts a new value move constructed from x in the container.
+   //!   p is a hint pointing to where the insert should start to search.
+   //!
+   //! Returns: An iterator pointing to the element with key equivalent
+   //!   to the key of x.
+   //!
+   //! Complexity: Logarithmic in general, but amortized constant if t
+   //!   is inserted right before p.
+   iterator insert(const_iterator position, BOOST_RV_REF(nonconst_value_type) x)
+   { return m_tree.insert_equal(position, boost::move(x)); }
+
+   //! Effects: Inserts a new value move constructed from x in the container.
+   //!   p is a hint pointing to where the insert should start to search.
+   //!
+   //! Returns: An iterator pointing to the element with key equivalent
+   //!   to the key of x.
+   //!
+   //! Complexity: Logarithmic in general, but amortized constant if t
+   //!   is inserted right before p.
+   iterator insert(const_iterator position, BOOST_RV_REF(movable_value_type) x)
+   { return m_tree.insert_equal(position, boost::move(x)); }
+
+   //! Requires: first, last are not iterators into *this.
+   //!
+   //! Effects: inserts each element from the range [first,last) .
+   //!
+   //! Complexity: At most N log(size()+N) (N is the distance from first to last)
+   template 
+   void insert(InputIterator first, InputIterator last)
+   {  m_tree.insert_equal(first, last); }
+
    //! Effects: Erases the element pointed to by position.
    //!
    //! Returns: Returns an iterator pointing to the element immediately
@@ -1319,6 +1336,14 @@ class multimap
    iterator erase(const_iterator first, const_iterator last)
    { return m_tree.erase(first, last); }
 
+   //! Effects: Swaps the contents of *this and x.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   void swap(multimap& x)
+   { m_tree.swap(x.m_tree); }
+
    //! Effects: erase(a.begin(),a.end()).
    //!
    //! Postcondition: size() == 0.
@@ -1327,6 +1352,32 @@ class multimap
    void clear()
    { m_tree.clear(); }
 
+   //////////////////////////////////////////////
+   //
+   //                observers
+   //
+   //////////////////////////////////////////////
+
+   //! Effects: Returns the comparison object out
+   //!   of which a was constructed.
+   //!
+   //! Complexity: Constant.
+   key_compare key_comp() const
+   { return m_tree.key_comp(); }
+
+   //! Effects: Returns an object of value_compare constructed out
+   //!   of the comparison object.
+   //!
+   //! Complexity: Constant.
+   value_compare value_comp() const
+   { return value_compare(m_tree.key_comp()); }
+
+   //////////////////////////////////////////////
+   //
+   //              map operations
+   //
+   //////////////////////////////////////////////
+
    //! Returns: An iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
@@ -1334,7 +1385,7 @@ class multimap
    iterator find(const key_type& x)
    { return m_tree.find(x); }
 
-   //! Returns: A const iterator pointing to an element with the key
+   //! Returns: Allocator const iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.
@@ -1354,7 +1405,7 @@ class multimap
    iterator lower_bound(const key_type& x)
    {return m_tree.lower_bound(x); }
 
-   //! Returns: A const iterator pointing to the first element with key not
+   //! Returns: Allocator const iterator pointing to the first element with key not
    //!   less than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
@@ -1368,13 +1419,7 @@ class multimap
    iterator upper_bound(const key_type& x)
    {  return m_tree.upper_bound(x); }
 
-   //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
-   //!
-   //! Complexity: Logarithmic
-   std::pair equal_range(const key_type& x)
-   {  return m_tree.equal_range(x);   }
-
-   //! Returns: A const iterator pointing to the first element with key not
+   //! Returns: Allocator const iterator pointing to the first element with key not
    //!   less than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
@@ -1384,8 +1429,13 @@ class multimap
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair
-      equal_range(const key_type& x) const
+   std::pair equal_range(const key_type& x)
+   {  return m_tree.equal_range(x);   }
+
+   //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
+   //!
+   //! Complexity: Logarithmic
+   std::pair equal_range(const key_type& x) const
    {  return m_tree.equal_range(x);   }
 
    /// @cond
@@ -1399,38 +1449,38 @@ class multimap
    /// @endcond
 };
 
-template 
-inline bool operator==(const multimap& x,
-                       const multimap& y)
+template 
+inline bool operator==(const multimap& x,
+                       const multimap& y)
 {  return x.m_tree == y.m_tree;  }
 
-template 
-inline bool operator<(const multimap& x,
-                      const multimap& y)
+template 
+inline bool operator<(const multimap& x,
+                      const multimap& y)
 {  return x.m_tree < y.m_tree;   }
 
-template 
-inline bool operator!=(const multimap& x,
-                       const multimap& y)
+template 
+inline bool operator!=(const multimap& x,
+                       const multimap& y)
 {  return !(x == y);  }
 
-template 
-inline bool operator>(const multimap& x,
-                      const multimap& y)
+template 
+inline bool operator>(const multimap& x,
+                      const multimap& y)
 {  return y < x;  }
 
-template 
-inline bool operator<=(const multimap& x,
-                       const multimap& y)
+template 
+inline bool operator<=(const multimap& x,
+                       const multimap& y)
 {  return !(y < x);  }
 
-template 
-inline bool operator>=(const multimap& x,
-                       const multimap& y)
+template 
+inline bool operator>=(const multimap& x,
+                       const multimap& y)
 {  return !(x < y);  }
 
-template 
-inline void swap(multimap& x, multimap& y)
+template 
+inline void swap(multimap& x, multimap& y)
 {  x.swap(y);  }
 
 /// @cond
@@ -1439,10 +1489,10 @@ inline void swap(multimap& x, multimap& y)
 /*
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
-template 
-struct has_trivial_destructor_after_move >
+template 
+struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
 };
 */
 namespace container {
diff --git a/include/boost/container/scoped_allocator.hpp b/include/boost/container/scoped_allocator.hpp
index 7da71bd..5111d37 100644
--- a/include/boost/container/scoped_allocator.hpp
+++ b/include/boost/container/scoped_allocator.hpp
@@ -47,10 +47,10 @@ namespace boost { namespace container {
 //! ill-formed.
 //!
 //! [Example:
-//!  template  >  
+//!  template  >  
 //!  class Z {
 //!    public:
-//!      typedef A allocator_type;
+//!      typedef Allocator allocator_type;
 //!
 //!    // Default constructor with optional allocator suffix
 //!    Z(const allocator_type& a = allocator_type());
@@ -61,8 +61,8 @@ namespace boost { namespace container {
 //! };
 //!
 //! // Specialize trait for class template Z
-//! template  >
-//! struct constructible_with_allocator_suffix > 
+//! template  >
+//! struct constructible_with_allocator_suffix > 
 //!      : ::boost::true_type { };
 //! -- end example]
 //!
@@ -91,10 +91,10 @@ struct constructible_with_allocator_suffix
 //! a constructor, then the program is ill-formed.
 //!
 //! [Example:
-//! template  >
+//! template  >
 //! class Y {
 //!    public:
-//!       typedef A allocator_type;
+//!       typedef Allocator allocator_type;
 //! 
 //!       // Default constructor with and allocator-extended default constructor
 //!       Y();
@@ -111,8 +111,8 @@ struct constructible_with_allocator_suffix
 //! };
 //! 
 //! // Specialize trait for class template Y
-//! template  >
-//! struct constructible_with_allocator_prefix > 
+//! template  >
+//! struct constructible_with_allocator_prefix > 
 //!       : ::boost::true_type { };
 //! 
 //! -- end example]
@@ -1036,16 +1036,16 @@ class scoped_allocator_adaptor
    typedef typename outer_traits_type::const_pointer        const_pointer;
    typedef typename outer_traits_type::void_pointer         void_pointer;
    typedef typename outer_traits_type::const_void_pointer   const_void_pointer;
-   //! Type: `true_type` if `allocator_traits::propagate_on_container_copy_assignment::value` is
-   //! true for any `A` in the set of `OuterAlloc` and `InnerAllocs...`; otherwise, false_type.
+   //! Type: `true_type` if `allocator_traits::propagate_on_container_copy_assignment::value` is
+   //! true for any `Allocator` in the set of `OuterAlloc` and `InnerAllocs...`; otherwise, false_type.
    typedef typename base_type::
       propagate_on_container_copy_assignment                propagate_on_container_copy_assignment;
-   //! Type: `true_type` if `allocator_traits::propagate_on_container_move_assignment::value` is
-   //! true for any `A` in the set of `OuterAlloc` and `InnerAllocs...`; otherwise, false_type.
+   //! Type: `true_type` if `allocator_traits::propagate_on_container_move_assignment::value` is
+   //! true for any `Allocator` in the set of `OuterAlloc` and `InnerAllocs...`; otherwise, false_type.
    typedef typename base_type::
       propagate_on_container_move_assignment                propagate_on_container_move_assignment;
-   //! Type: `true_type` if `allocator_traits::propagate_on_container_swap::value` is true for any
-   //! `A` in the set of `OuterAlloc` and `InnerAllocs...`; otherwise, false_type.
+   //! Type: `true_type` if `allocator_traits::propagate_on_container_swap::value` is true for any
+   //! `Allocator` in the set of `OuterAlloc` and `InnerAllocs...`; otherwise, false_type.
    typedef typename base_type::
       propagate_on_container_swap                           propagate_on_container_swap;
 
@@ -1211,9 +1211,9 @@ class scoped_allocator_adaptor
       outer_traits_type::deallocate(this->outer_allocator(), p, n);
    }
 
-   //! Returns: A new scoped_allocator_adaptor object where each allocator
+   //! Returns: Allocator new scoped_allocator_adaptor object where each allocator
    //! A in the adaptor is initialized from the result of calling
-   //! `allocator_traits::select_on_container_copy_construction()` on
+   //! `allocator_traits::select_on_container_copy_construction()` on
    //! the corresponding allocator in *this.
    scoped_allocator_adaptor select_on_container_copy_construction() const
    {
diff --git a/include/boost/container/set.hpp b/include/boost/container/set.hpp
index 87473a4..bdb89f2 100644
--- a/include/boost/container/set.hpp
+++ b/include/boost/container/set.hpp
@@ -24,6 +24,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -31,23 +32,18 @@
 #include 
 #endif
 
-#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
 namespace boost {
 namespace container {
-#else
-namespace boost {
-namespace container {
-#endif
 
 /// @cond
 // Forward declarations of operators < and ==, needed for friend declaration.
-template 
-inline bool operator==(const set& x,
-                       const set& y);
+template 
+inline bool operator==(const set& x,
+                       const set& y);
 
-template 
-inline bool operator<(const set& x,
-                      const set& y);
+template 
+inline bool operator<(const set& x,
+                      const set& y);
 /// @endcond
 
 //! A set is a kind of associative container that supports unique keys (contains at
@@ -58,41 +54,48 @@ inline bool operator<(const set& x,
 //! , and of an associative container. A set also provides most operations described in
 //! for unique keys.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template , class A = std::allocator >
+template , class Allocator = std::allocator >
 #else
-template 
+template 
 #endif
 class set
 {
    /// @cond
    private:
    BOOST_COPYABLE_AND_MOVABLE(set)
-   typedef container_detail::rbtree, Pred, A> tree_t;
+   typedef container_detail::rbtree, Compare, Allocator> tree_t;
    tree_t m_tree;  // red-black tree representing set
-   typedef typename container_detail::
-      move_const_ref_type::type insert_const_ref_type;
    /// @endcond
 
    public:
+   //////////////////////////////////////////////
+   //
+   //                    types
+   //
+   //////////////////////////////////////////////
+   typedef Key                                                                         key_type;
+   typedef Key                                                                         value_type;
+   typedef Compare                                                                     key_compare;
+   typedef Compare                                                                     value_compare;
+   typedef typename ::boost::container::allocator_traits::pointer           pointer;
+   typedef typename ::boost::container::allocator_traits::const_pointer     const_pointer;
+   typedef typename ::boost::container::allocator_traits::reference         reference;
+   typedef typename ::boost::container::allocator_traits::const_reference   const_reference;
+   typedef typename ::boost::container::allocator_traits::size_type         size_type;
+   typedef typename ::boost::container::allocator_traits::difference_type   difference_type;
+   typedef Allocator                                                                   allocator_type;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::stored_allocator_type)              stored_allocator_type;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::iterator)                           iterator;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_iterator)                     const_iterator;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::reverse_iterator)                   reverse_iterator;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_reverse_iterator)             const_reverse_iterator;
 
-   // typedefs:
-   typedef typename tree_t::key_type               key_type;
-   typedef typename tree_t::value_type             value_type;
-   typedef typename tree_t::pointer                pointer;
-   typedef typename tree_t::const_pointer          const_pointer;
-   typedef typename tree_t::reference              reference;
-   typedef typename tree_t::const_reference        const_reference;
-   typedef Pred                                    key_compare;
-   typedef Pred                                    value_compare;
-   typedef typename tree_t::iterator               iterator;
-   typedef typename tree_t::const_iterator         const_iterator;
-   typedef typename tree_t::reverse_iterator       reverse_iterator;
-   typedef typename tree_t::const_reverse_iterator const_reverse_iterator;
-   typedef typename tree_t::size_type              size_type;
-   typedef typename tree_t::difference_type        difference_type;
-   typedef typename tree_t::allocator_type         allocator_type;
-   typedef typename tree_t::stored_allocator_type  stored_allocator_type;
+   //////////////////////////////////////////////
+   //
+   //          construct/copy/destroy
+   //
+   //////////////////////////////////////////////
 
    //! Effects: Default constructs an empty set.
    //!
@@ -105,7 +108,7 @@ class set
    //! and allocator.
    //!
    //! Complexity: Constant.
-   explicit set(const Pred& comp,
+   explicit set(const Compare& comp,
                 const allocator_type& a = allocator_type())
       : m_tree(comp, a)
    {}
@@ -116,7 +119,7 @@ class set
    //! Complexity: Linear in N if the range [first ,last ) is already sorted using
    //! comp and otherwise N logN, where N is last - first.
    template 
-   set(InputIterator first, InputIterator last, const Pred& comp = Pred(),
+   set(InputIterator first, InputIterator last, const Compare& comp = Compare(),
          const allocator_type& a = allocator_type())
       : m_tree(true, first, last, comp, a)
    {}
@@ -131,7 +134,7 @@ class set
    //! Complexity: Linear in N.
    template 
    set( ordered_unique_range_t, InputIterator first, InputIterator last
-      , const Pred& comp = Pred(), const allocator_type& a = allocator_type())
+      , const Compare& comp = Compare(), const allocator_type& a = allocator_type())
       : m_tree(ordered_range, first, last, comp, a)
    {}
 
@@ -178,20 +181,6 @@ class set
    set& operator=(BOOST_RV_REF(set) x)
    {  m_tree = boost::move(x.m_tree);   return *this;  }
 
-   //! Effects: Returns the comparison object out
-   //!   of which a was constructed.
-   //!
-   //! Complexity: Constant.
-   key_compare key_comp() const
-   { return m_tree.key_comp(); }
-
-   //! Effects: Returns an object of value_compare constructed out
-   //!   of the comparison object.
-   //!
-   //! Complexity: Constant.
-   value_compare value_comp() const
-   { return m_tree.key_comp(); }
-
    //! Effects: Returns a copy of the Allocator that
    //!   was passed to the object's constructor.
    //!
@@ -219,6 +208,12 @@ class set
    stored_allocator_type &get_stored_allocator()
    { return m_tree.get_stored_allocator(); }
 
+   //////////////////////////////////////////////
+   //
+   //                capacity
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Returns an iterator to the first element contained in the container.
    //!
    //! Throws: Nothing.
@@ -321,6 +316,12 @@ class set
    const_reverse_iterator crend() const
    { return m_tree.crend(); }
 
+   //////////////////////////////////////////////
+   //
+   //                capacity
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Returns true if the container contains no elements.
    //!
    //! Throws: Nothing.
@@ -345,90 +346,15 @@ class set
    size_type max_size() const
    { return m_tree.max_size(); }
 
-   //! Effects: Swaps the contents of *this and x.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   void swap(set& x)
-   { m_tree.swap(x.m_tree); }
-
-   //! Effects: Inserts x if and only if there is no element in the container
-   //!   with key equivalent to the key of x.
-   //!
-   //! Returns: The bool component of the returned pair is true if and only
-   //!   if the insertion takes place, and the iterator component of the pair
-   //!   points to the element with key equivalent to the key of x.
-   //!
-   //! Complexity: Logarithmic.
-   std::pair insert(insert_const_ref_type x)
-   {  return priv_insert(x); }
-
-   #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   std::pair insert(T &x)
-   { return this->insert(const_cast(x)); }
-
-   template
-   std::pair insert(const U &u
-      , typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0)
-   {  return priv_insert(u); }
-   #endif
-
-   //! Effects: Move constructs a new value from x if and only if there is
-   //!   no element in the container with key equivalent to the key of x.
-   //!
-   //! Returns: The bool component of the returned pair is true if and only
-   //!   if the insertion takes place, and the iterator component of the pair
-   //!   points to the element with key equivalent to the key of x.
-   //!
-   //! Complexity: Logarithmic.
-   std::pair insert(BOOST_RV_REF(value_type) x)
-   {  return m_tree.insert_unique(boost::move(x));  }
-
-   //! Effects: Inserts a copy of x in the container if and only if there is
-   //!   no element in the container with key equivalent to the key of x.
-   //!   p is a hint pointing to where the insert should start to search.
-   //!
-   //! Returns: An iterator pointing to the element with key equivalent
-   //!   to the key of x.
-   //!
-   //! Complexity: Logarithmic in general, but amortized constant if t
-   //!   is inserted right before p.
-   iterator insert(const_iterator p, insert_const_ref_type x)
-   {  return priv_insert(p, x); }
-
-   #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   iterator insert(const_iterator position, T &x)
-   { return this->insert(position, const_cast(x)); }
-
-   template
-   iterator insert( const_iterator position, const U &u
-                  , typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0)
-   {  return priv_insert(position, u); }
-   #endif
-
-   //! Effects: Inserts an element move constructed from x in the container.
-   //!   p is a hint pointing to where the insert should start to search.
-   //!
-   //! Returns: An iterator pointing to the element with key equivalent to the key of x.
-   //!
-   //! Complexity: Logarithmic.
-   iterator insert(const_iterator p, BOOST_RV_REF(value_type) x)
-   {  return m_tree.insert_unique(p, boost::move(x)); }
-
-   //! Requires: first, last are not iterators into *this.
-   //!
-   //! Effects: inserts each element from the range [first,last) if and only
-   //!   if there is no element with key equivalent to the key of that element.
-   //!
-   //! Complexity: At most N log(size()+N) (N is the distance from first to last)
-   template 
-   void insert(InputIterator first, InputIterator last)
-   {  m_tree.insert_unique(first, last);  }
+   //////////////////////////////////////////////
+   //
+   //                modifiers
+   //
+   //////////////////////////////////////////////
 
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
-   //! Effects:  Inserts an object x of type T constructed with
+   //! Effects:  Inserts an object x of type Key constructed with
    //!   std::forward(args)... if and only if there is
    //!   no element in the container with equivalent value.
    //!   and returns the iterator pointing to the
@@ -439,14 +365,14 @@ class set
    //!   points to the element with key equivalent to the key of x.
    //!
    //! Throws: If memory allocation throws or
-   //!   T's in-place constructor throws.
+   //!   Key's in-place constructor throws.
    //!
    //! Complexity: Logarithmic.
    template 
    std::pair emplace(Args&&... args)
    {  return m_tree.emplace_unique(boost::forward(args)...); }
 
-   //! Effects:  Inserts an object of type T constructed with
+   //! Effects:  Inserts an object of type Key constructed with
    //!   std::forward(args)... if and only if there is
    //!   no element in the container with equivalent value.
    //!   p is a hint pointing to where the insert
@@ -477,6 +403,66 @@ class set
 
    #endif   //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
+   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   //! Effects: Inserts x if and only if there is no element in the container
+   //!   with key equivalent to the key of x.
+   //!
+   //! Returns: The bool component of the returned pair is true if and only
+   //!   if the insertion takes place, and the iterator component of the pair
+   //!   points to the element with key equivalent to the key of x.
+   //!
+   //! Complexity: Logarithmic.
+   std::pair insert(const value_type &x);
+
+   //! Effects: Move constructs a new value from x if and only if there is
+   //!   no element in the container with key equivalent to the key of x.
+   //!
+   //! Returns: The bool component of the returned pair is true if and only
+   //!   if the insertion takes place, and the iterator component of the pair
+   //!   points to the element with key equivalent to the key of x.
+   //!
+   //! Complexity: Logarithmic.
+   std::pair insert(value_type &&x);
+   #else
+   private:
+   typedef std::pair insert_return_pair;
+   public:
+   BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, insert_return_pair, this->priv_insert)
+   #endif
+
+   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   //! Effects: Inserts a copy of x in the container if and only if there is
+   //!   no element in the container with key equivalent to the key of x.
+   //!   p is a hint pointing to where the insert should start to search.
+   //!
+   //! Returns: An iterator pointing to the element with key equivalent
+   //!   to the key of x.
+   //!
+   //! Complexity: Logarithmic in general, but amortized constant if t
+   //!   is inserted right before p.
+   iterator insert(const_iterator p, const value_type &x);
+
+   //! Effects: Inserts an element move constructed from x in the container.
+   //!   p is a hint pointing to where the insert should start to search.
+   //!
+   //! Returns: An iterator pointing to the element with key equivalent to the key of x.
+   //!
+   //! Complexity: Logarithmic.
+   iterator insert(const_iterator position, value_type &&x);
+   #else
+   BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator)
+   #endif
+
+   //! Requires: first, last are not iterators into *this.
+   //!
+   //! Effects: inserts each element from the range [first,last) if and only
+   //!   if there is no element with key equivalent to the key of that element.
+   //!
+   //! Complexity: At most N log(size()+N) (N is the distance from first to last)
+   template 
+   void insert(InputIterator first, InputIterator last)
+   {  m_tree.insert_unique(first, last);  }
+
    //! Effects: Erases the element pointed to by p.
    //!
    //! Returns: Returns an iterator pointing to the element immediately
@@ -503,6 +489,14 @@ class set
    iterator erase(const_iterator first, const_iterator last)
    {  return m_tree.erase(first, last);  }
 
+   //! Effects: Swaps the contents of *this and x.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   void swap(set& x)
+   { m_tree.swap(x.m_tree); }
+
    //! Effects: erase(a.begin(),a.end()).
    //!
    //! Postcondition: size() == 0.
@@ -511,6 +505,32 @@ class set
    void clear()
    { m_tree.clear(); }
 
+   //////////////////////////////////////////////
+   //
+   //                observers
+   //
+   //////////////////////////////////////////////
+
+   //! Effects: Returns the comparison object out
+   //!   of which a was constructed.
+   //!
+   //! Complexity: Constant.
+   key_compare key_comp() const
+   { return m_tree.key_comp(); }
+
+   //! Effects: Returns an object of value_compare constructed out
+   //!   of the comparison object.
+   //!
+   //! Complexity: Constant.
+   value_compare value_comp() const
+   { return m_tree.key_comp(); }
+
+   //////////////////////////////////////////////
+   //
+   //              set operations
+   //
+   //////////////////////////////////////////////
+
    //! Returns: An iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
@@ -518,7 +538,7 @@ class set
    iterator find(const key_type& x)
    { return m_tree.find(x); }
 
-   //! Returns: A const_iterator pointing to an element with the key
+   //! Returns: Allocator const_iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.
@@ -538,7 +558,7 @@ class set
    iterator lower_bound(const key_type& x)
    {  return m_tree.lower_bound(x); }
 
-   //! Returns: A const iterator pointing to the first element with key not
+   //! Returns: Allocator const iterator pointing to the first element with key not
    //!   less than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
@@ -552,7 +572,7 @@ class set
    iterator upper_bound(const key_type& x)
    {  return m_tree.upper_bound(x);    }
 
-   //! Returns: A const iterator pointing to the first element with key not
+   //! Returns: Allocator const iterator pointing to the first element with key not
    //!   less than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
@@ -562,15 +582,13 @@ class set
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair
-      equal_range(const key_type& x)
+   std::pair equal_range(const key_type& x)
    {  return m_tree.equal_range(x); }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair
-      equal_range(const key_type& x) const
+   std::pair equal_range(const key_type& x) const
    {  return m_tree.equal_range(x); }
 
    /// @cond
@@ -581,47 +599,48 @@ class set
    friend bool operator< (const set&, const set&);
 
    private:
-   std::pair priv_insert(const T &x)
-   {  return m_tree.insert_unique(x);  }
-
-   iterator priv_insert(const_iterator p, const T &x)
-   {  return m_tree.insert_unique(p, x); }
+   template 
+   std::pair priv_insert(BOOST_FWD_REF(KeyType) x)
+   {  return m_tree.insert_unique(::boost::forward(x));  }
 
+   template 
+   iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x)
+   {  return m_tree.insert_unique(p, ::boost::forward(x)); }
    /// @endcond
 };
 
-template 
-inline bool operator==(const set& x,
-                       const set& y)
+template 
+inline bool operator==(const set& x,
+                       const set& y)
 {  return x.m_tree == y.m_tree;  }
 
-template 
-inline bool operator<(const set& x,
-                      const set& y)
+template 
+inline bool operator<(const set& x,
+                      const set& y)
 {  return x.m_tree < y.m_tree;   }
 
-template 
-inline bool operator!=(const set& x,
-                       const set& y)
+template 
+inline bool operator!=(const set& x,
+                       const set& y)
 {  return !(x == y);   }
 
-template 
-inline bool operator>(const set& x,
-                      const set& y)
+template 
+inline bool operator>(const set& x,
+                      const set& y)
 {  return y < x; }
 
-template 
-inline bool operator<=(const set& x,
-                       const set& y)
+template 
+inline bool operator<=(const set& x,
+                       const set& y)
 {  return !(y < x); }
 
-template 
-inline bool operator>=(const set& x,
-                       const set& y)
+template 
+inline bool operator>=(const set& x,
+                       const set& y)
 {  return !(x < y);  }
 
-template 
-inline void swap(set& x, set& y)
+template 
+inline void swap(set& x, set& y)
 {  x.swap(y);  }
 
 /// @cond
@@ -630,23 +649,23 @@ inline void swap(set& x, set& y)
 /*
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
-template 
-struct has_trivial_destructor_after_move >
+template 
+struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
 };
 */
 namespace container {
 
 // Forward declaration of operators < and ==, needed for friend declaration.
 
-template 
-inline bool operator==(const multiset& x,
-                       const multiset& y);
+template 
+inline bool operator==(const multiset& x,
+                       const multiset& y);
 
-template 
-inline bool operator<(const multiset& x,
-                      const multiset& y);
+template 
+inline bool operator<(const multiset& x,
+                      const multiset& y);
 /// @endcond
 
 //! A multiset is a kind of associative container that supports equivalent keys
@@ -657,41 +676,49 @@ inline bool operator<(const multiset& x,
 //! container, and of an associative container). multiset also provides most operations
 //! described for duplicate keys.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template , class A = std::allocator >
+template , class Allocator = std::allocator >
 #else
-template 
+template 
 #endif
 class multiset
 {
    /// @cond
    private:
    BOOST_COPYABLE_AND_MOVABLE(multiset)
-   typedef container_detail::rbtree, Pred, A> tree_t;
+   typedef container_detail::rbtree, Compare, Allocator> tree_t;
    tree_t m_tree;  // red-black tree representing multiset
-   typedef typename container_detail::
-      move_const_ref_type::type insert_const_ref_type;
    /// @endcond
 
    public:
 
-   // typedefs:
-   typedef typename tree_t::key_type               key_type;
-   typedef typename tree_t::value_type             value_type;
-   typedef typename tree_t::pointer                pointer;
-   typedef typename tree_t::const_pointer          const_pointer;
-   typedef typename tree_t::reference              reference;
-   typedef typename tree_t::const_reference        const_reference;
-   typedef Pred                                    key_compare;
-   typedef Pred                                    value_compare;
-   typedef typename tree_t::iterator               iterator;
-   typedef typename tree_t::const_iterator         const_iterator;
-   typedef typename tree_t::reverse_iterator       reverse_iterator;
-   typedef typename tree_t::const_reverse_iterator const_reverse_iterator;
-   typedef typename tree_t::size_type              size_type;
-   typedef typename tree_t::difference_type        difference_type;
-   typedef typename tree_t::allocator_type         allocator_type;
-   typedef typename tree_t::stored_allocator_type  stored_allocator_type;
+   //////////////////////////////////////////////
+   //
+   //                    types
+   //
+   //////////////////////////////////////////////
+   typedef Key                                                                         key_type;
+   typedef Key                                                                         value_type;
+   typedef Compare                                                                     key_compare;
+   typedef Compare                                                                     value_compare;
+   typedef typename ::boost::container::allocator_traits::pointer           pointer;
+   typedef typename ::boost::container::allocator_traits::const_pointer     const_pointer;
+   typedef typename ::boost::container::allocator_traits::reference         reference;
+   typedef typename ::boost::container::allocator_traits::const_reference   const_reference;
+   typedef typename ::boost::container::allocator_traits::size_type         size_type;
+   typedef typename ::boost::container::allocator_traits::difference_type   difference_type;
+   typedef Allocator                                                                   allocator_type;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::stored_allocator_type)              stored_allocator_type;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::iterator)                           iterator;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_iterator)                     const_iterator;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::reverse_iterator)                   reverse_iterator;
+   typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_reverse_iterator)             const_reverse_iterator;
+
+   //////////////////////////////////////////////
+   //
+   //          construct/copy/destroy
+   //
+   //////////////////////////////////////////////
 
    //! Effects: Constructs an empty multiset using the specified comparison
    //!   object and allocator.
@@ -705,7 +732,7 @@ class multiset
    //!   object and allocator.
    //!
    //! Complexity: Constant.
-   explicit multiset(const Pred& comp,
+   explicit multiset(const Compare& comp,
                      const allocator_type& a = allocator_type())
       : m_tree(comp, a)
    {}
@@ -717,7 +744,7 @@ class multiset
    //! comp and otherwise N logN, where N is last - first.
    template 
    multiset(InputIterator first, InputIterator last,
-            const Pred& comp = Pred(),
+            const Compare& comp = Compare(),
             const allocator_type& a = allocator_type())
       : m_tree(false, first, last, comp, a)
    {}
@@ -731,7 +758,7 @@ class multiset
    //! Complexity: Linear in N.
    template 
    multiset( ordered_range_t ordered_range, InputIterator first, InputIterator last
-           , const Pred& comp = Pred()
+           , const Compare& comp = Compare()
            , const allocator_type& a = allocator_type())
       : m_tree(ordered_range, first, last, comp, a)
    {}
@@ -781,20 +808,6 @@ class multiset
    multiset& operator=(BOOST_RV_REF(multiset) x)
    {  m_tree = boost::move(x.m_tree);   return *this;  }
 
-   //! Effects: Returns the comparison object out
-   //!   of which a was constructed.
-   //!
-   //! Complexity: Constant.
-   key_compare key_comp() const
-   { return m_tree.key_comp(); }
-
-   //! Effects: Returns an object of value_compare constructed out
-   //!   of the comparison object.
-   //!
-   //! Complexity: Constant.
-   value_compare value_comp() const
-   { return m_tree.key_comp(); }
-
    //! Effects: Returns a copy of the Allocator that
    //!   was passed to the object's constructor.
    //!
@@ -822,6 +835,12 @@ class multiset
    const stored_allocator_type &get_stored_allocator() const
    { return m_tree.get_stored_allocator(); }
 
+   //////////////////////////////////////////////
+   //
+   //                iterators
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Returns an iterator to the first element contained in the container.
    //!
    //! Throws: Nothing.
@@ -924,6 +943,12 @@ class multiset
    const_reverse_iterator crend() const
    { return m_tree.crend(); }
 
+   //////////////////////////////////////////////
+   //
+   //                capacity
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Returns true if the container contains no elements.
    //!
    //! Throws: Nothing.
@@ -948,85 +973,15 @@ class multiset
    size_type max_size() const
    { return m_tree.max_size(); }
 
-   //! Effects: Swaps the contents of *this and x.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   void swap(multiset& x)
-   { m_tree.swap(x.m_tree); }
-
-   //! Effects: Inserts x and returns the iterator pointing to the
-   //!   newly inserted element.
-   //!
-   //! Complexity: Logarithmic.
-   iterator insert(insert_const_ref_type x)
-   {  return priv_insert(x); }
-
-   #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   iterator insert(T &x)
-   { return this->insert(const_cast(x)); }
-
-   template
-   iterator insert(const U &u
-      , typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0)
-   {  return priv_insert(u); }
-   #endif
-
-   //! Effects: Inserts a copy of x in the container.
-   //!
-   //! Returns: An iterator pointing to the element with key equivalent
-   //!   to the key of x.
-   //!
-   //! Complexity: Logarithmic in general, but amortized constant if t
-   //!   is inserted right before p.
-   iterator insert(BOOST_RV_REF(value_type) x)
-   {  return m_tree.insert_equal(boost::move(x));  }
-
-   //! Effects: Inserts a copy of x in the container.
-   //!   p is a hint pointing to where the insert should start to search.
-   //!
-   //! Returns: An iterator pointing to the element with key equivalent
-   //!   to the key of x.
-   //!
-   //! Complexity: Logarithmic in general, but amortized constant if t
-   //!   is inserted right before p.
-   iterator insert(const_iterator p, insert_const_ref_type x)
-   {  return priv_insert(p, x); }
-
-   #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-   iterator insert(const_iterator position, T &x)
-   { return this->insert(position, const_cast(x)); }
-
-   template
-   iterator insert( const_iterator position, const U &u
-                  , typename container_detail::enable_if_c::value && !::boost::has_move_emulation_enabled::value >::type* =0)
-   {  return priv_insert(position, u); }
-   #endif
-
-   //! Effects: Inserts a value move constructed from x in the container.
-   //!   p is a hint pointing to where the insert should start to search.
-   //!
-   //! Returns: An iterator pointing to the element with key equivalent
-   //!   to the key of x.
-   //!
-   //! Complexity: Logarithmic in general, but amortized constant if t
-   //!   is inserted right before p.
-   iterator insert(const_iterator p, BOOST_RV_REF(value_type) x)
-   {  return m_tree.insert_equal(p, boost::move(x));  }
-
-   //! Requires: first, last are not iterators into *this.
-   //!
-   //! Effects: inserts each element from the range [first,last) .
-   //!
-   //! Complexity: At most N log(size()+N) (N is the distance from first to last)
-   template 
-   void insert(InputIterator first, InputIterator last)
-   {  m_tree.insert_equal(first, last);  }
+   //////////////////////////////////////////////
+   //
+   //                modifiers
+   //
+   //////////////////////////////////////////////
 
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
-   //! Effects: Inserts an object of type T constructed with
+   //! Effects: Inserts an object of type Key constructed with
    //!   std::forward(args)... and returns the iterator pointing to the
    //!   newly inserted element.
    //!
@@ -1035,7 +990,7 @@ class multiset
    iterator emplace(Args&&... args)
    {  return m_tree.emplace_equal(boost::forward(args)...); }
 
-   //! Effects: Inserts an object of type T constructed with
+   //! Effects: Inserts an object of type Key constructed with
    //!   std::forward(args)...
    //!
    //! Returns: An iterator pointing to the element with key equivalent
@@ -1065,6 +1020,61 @@ class multiset
 
    #endif   //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
+
+
+
+   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   //! Effects: Inserts x and returns the iterator pointing to the
+   //!   newly inserted element.
+   //!
+   //! Complexity: Logarithmic.
+   iterator insert(const value_type &x);
+
+   //! Effects: Inserts a copy of x in the container.
+   //!
+   //! Returns: An iterator pointing to the element with key equivalent
+   //!   to the key of x.
+   //!
+   //! Complexity: Logarithmic in general, but amortized constant if t
+   //!   is inserted right before p.
+   iterator insert(value_type &&x);
+   #else
+   BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, iterator, this->priv_insert)
+   #endif
+
+   #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   //! Effects: Inserts a copy of x in the container.
+   //!   p is a hint pointing to where the insert should start to search.
+   //!
+   //! Returns: An iterator pointing to the element with key equivalent
+   //!   to the key of x.
+   //!
+   //! Complexity: Logarithmic in general, but amortized constant if t
+   //!   is inserted right before p.
+   iterator insert(const_iterator p, const value_type &x);
+
+   //! Effects: Inserts a value move constructed from x in the container.
+   //!   p is a hint pointing to where the insert should start to search.
+   //!
+   //! Returns: An iterator pointing to the element with key equivalent
+   //!   to the key of x.
+   //!
+   //! Complexity: Logarithmic in general, but amortized constant if t
+   //!   is inserted right before p.
+   iterator insert(const_iterator position, value_type &&x);
+   #else
+   BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator)
+   #endif
+
+   //! Requires: first, last are not iterators into *this.
+   //!
+   //! Effects: inserts each element from the range [first,last) .
+   //!
+   //! Complexity: At most N log(size()+N) (N is the distance from first to last)
+   template 
+   void insert(InputIterator first, InputIterator last)
+   {  m_tree.insert_equal(first, last);  }
+
    //! Effects: Erases the element pointed to by p.
    //!
    //! Returns: Returns an iterator pointing to the element immediately
@@ -1091,6 +1101,14 @@ class multiset
    iterator erase(const_iterator first, const_iterator last)
    {  return m_tree.erase(first, last); }
 
+   //! Effects: Swaps the contents of *this and x.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   void swap(multiset& x)
+   { m_tree.swap(x.m_tree); }
+
    //! Effects: erase(a.begin(),a.end()).
    //!
    //! Postcondition: size() == 0.
@@ -1099,6 +1117,32 @@ class multiset
    void clear()
    { m_tree.clear(); }
 
+   //////////////////////////////////////////////
+   //
+   //                observers
+   //
+   //////////////////////////////////////////////
+
+   //! Effects: Returns the comparison object out
+   //!   of which a was constructed.
+   //!
+   //! Complexity: Constant.
+   key_compare key_comp() const
+   { return m_tree.key_comp(); }
+
+   //! Effects: Returns an object of value_compare constructed out
+   //!   of the comparison object.
+   //!
+   //! Complexity: Constant.
+   value_compare value_comp() const
+   { return m_tree.key_comp(); }
+
+   //////////////////////////////////////////////
+   //
+   //              set operations
+   //
+   //////////////////////////////////////////////
+
    //! Returns: An iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
@@ -1106,7 +1150,7 @@ class multiset
    iterator find(const key_type& x)
    { return m_tree.find(x); }
 
-   //! Returns: A const iterator pointing to an element with the key
+   //! Returns: Allocator const iterator pointing to an element with the key
    //!   equivalent to x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic.
@@ -1126,7 +1170,7 @@ class multiset
    iterator lower_bound(const key_type& x)
    {  return m_tree.lower_bound(x); }
 
-   //! Returns: A const iterator pointing to the first element with key not
+   //! Returns: Allocator const iterator pointing to the first element with key not
    //!   less than k, or a.end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
@@ -1140,7 +1184,7 @@ class multiset
    iterator upper_bound(const key_type& x)
    {  return m_tree.upper_bound(x);    }
 
-   //! Returns: A const iterator pointing to the first element with key not
+   //! Returns: Allocator const iterator pointing to the first element with key not
    //!   less than x, or end() if such an element is not found.
    //!
    //! Complexity: Logarithmic
@@ -1150,15 +1194,13 @@ class multiset
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair
-      equal_range(const key_type& x)
+   std::pair equal_range(const key_type& x)
    {  return m_tree.equal_range(x); }
 
    //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
    //!
    //! Complexity: Logarithmic
-   std::pair
-      equal_range(const key_type& x) const
+   std::pair equal_range(const key_type& x) const
    {  return m_tree.equal_range(x); }
 
    /// @cond
@@ -1169,47 +1211,49 @@ class multiset
    friend bool operator< (const multiset&,
                           const multiset&);
    private:
-   iterator priv_insert(const T &x)
-   {  return m_tree.insert_equal(x);  }
+   template 
+   iterator priv_insert(BOOST_FWD_REF(KeyType) x)
+   {  return m_tree.insert_equal(::boost::forward(x));  }
 
-   iterator priv_insert(const_iterator p, const T &x)
-   {  return m_tree.insert_equal(p, x); }
+   template 
+   iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x)
+   {  return m_tree.insert_equal(p, ::boost::forward(x)); }
 
    /// @endcond
 };
 
-template 
-inline bool operator==(const multiset& x,
-                       const multiset& y)
+template 
+inline bool operator==(const multiset& x,
+                       const multiset& y)
 {  return x.m_tree == y.m_tree;  }
 
-template 
-inline bool operator<(const multiset& x,
-                      const multiset& y)
+template 
+inline bool operator<(const multiset& x,
+                      const multiset& y)
 {  return x.m_tree < y.m_tree;   }
 
-template 
-inline bool operator!=(const multiset& x,
-                       const multiset& y)
+template 
+inline bool operator!=(const multiset& x,
+                       const multiset& y)
 {  return !(x == y);  }
 
-template 
-inline bool operator>(const multiset& x,
-                      const multiset& y)
+template 
+inline bool operator>(const multiset& x,
+                      const multiset& y)
 {  return y < x;  }
 
-template 
-inline bool operator<=(const multiset& x,
-                       const multiset& y)
+template 
+inline bool operator<=(const multiset& x,
+                       const multiset& y)
 {  return !(y < x);  }
 
-template 
-inline bool operator>=(const multiset& x,
-                       const multiset& y)
+template 
+inline bool operator>=(const multiset& x,
+                       const multiset& y)
 {  return !(x < y);  }
 
-template 
-inline void swap(multiset& x, multiset& y)
+template 
+inline void swap(multiset& x, multiset& y)
 {  x.swap(y);  }
 
 /// @cond
@@ -1218,10 +1262,10 @@ inline void swap(multiset& x, multiset& y)
 /*
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
-template 
-struct has_trivial_destructor_after_move >
+template 
+struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
 };
 */
 namespace container {
diff --git a/include/boost/container/slist.hpp b/include/boost/container/slist.hpp
index 2af3c39..c65a9a2 100644
--- a/include/boost/container/slist.hpp
+++ b/include/boost/container/slist.hpp
@@ -44,17 +44,12 @@
 #include 
 #include 
 
-#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
 namespace boost {
 namespace container {
-#else
-namespace boost {
-namespace container {
-#endif
 
 /// @cond
 
-template 
+template 
 class slist;
 
 namespace container_detail {
@@ -78,10 +73,10 @@ struct slist_node
    T m_data;
 };
 
-template
+template
 struct intrusive_slist_type
 {
-   typedef boost::container::allocator_traits      allocator_traits_type;
+   typedef boost::container::allocator_traits      allocator_traits_type;
    typedef typename allocator_traits_type::value_type value_type;
    typedef typename boost::intrusive::pointer_traits
       ::template
@@ -230,18 +225,18 @@ class slist_iterator
 //! needs, and that you often need to use insert and erase in the middle of the list,
 //! then you should probably use list instead of slist.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template  >
+template  >
 #else
-template 
+template 
 #endif
 class slist
    : protected container_detail::node_alloc_holder
-      ::type>
+      ::type>
 {
    /// @cond
    typedef typename
-      container_detail::intrusive_slist_type::type           Icont;
-   typedef container_detail::node_alloc_holder        AllocHolder;
+      container_detail::intrusive_slist_type::type           Icont;
+   typedef container_detail::node_alloc_holder        AllocHolder;
    typedef typename AllocHolder::NodePtr              NodePtr;
    typedef typename AllocHolder::NodeAlloc            NodeAlloc;
    typedef typename AllocHolder::ValAlloc             ValAlloc;
@@ -250,7 +245,7 @@ class slist
    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_traits_type;
+   typedef boost::container::allocator_traits      allocator_traits_type;
 
    class equal_to_value
    {
@@ -294,13 +289,13 @@ class slist
    //////////////////////////////////////////////
 
    typedef T                                                                  value_type;
-   typedef typename ::boost::container::allocator_traits::pointer          pointer;
-   typedef typename ::boost::container::allocator_traits::const_pointer    const_pointer;
-   typedef typename ::boost::container::allocator_traits::reference        reference;
-   typedef typename ::boost::container::allocator_traits::const_reference  const_reference;
-   typedef typename ::boost::container::allocator_traits::size_type        size_type;
-   typedef typename ::boost::container::allocator_traits::difference_type  difference_type;
-   typedef A                                                                  allocator_type;
+   typedef typename ::boost::container::allocator_traits::pointer          pointer;
+   typedef typename ::boost::container::allocator_traits::const_pointer    const_pointer;
+   typedef typename ::boost::container::allocator_traits::reference        reference;
+   typedef typename ::boost::container::allocator_traits::const_reference  const_reference;
+   typedef typename ::boost::container::allocator_traits::size_type        size_type;
+   typedef typename ::boost::container::allocator_traits::difference_type  difference_type;
+   typedef Allocator                                                                  allocator_type;
    typedef BOOST_CONTAINER_IMPDEF(NodeAlloc)                                  stored_allocator_type;
    typedef BOOST_CONTAINER_IMPDEF(iterator_impl)                              iterator;
    typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl)                        const_iterator;
@@ -1607,14 +1602,14 @@ class slist
    /// @endcond
 };
 
-template 
+template 
 inline bool
-operator==(const slist& x, const slist& y)
+operator==(const slist& x, const slist& y)
 {
    if(x.size() != y.size()){
       return false;
    }
-   typedef typename slist::const_iterator const_iterator;
+   typedef typename slist::const_iterator const_iterator;
    const_iterator end1 = x.end();
 
    const_iterator i1 = x.begin();
@@ -1626,36 +1621,36 @@ operator==(const slist& x, const slist& y)
    return i1 == end1;
 }
 
-template 
+template 
 inline bool
-operator<(const slist& sL1, const slist& sL2)
+operator<(const slist& sL1, const slist& sL2)
 {
    return std::lexicographical_compare
       (sL1.begin(), sL1.end(), sL2.begin(), sL2.end());
 }
 
-template 
+template 
 inline bool
-operator!=(const slist& sL1, const slist& sL2)
+operator!=(const slist& sL1, const slist& sL2)
    {  return !(sL1 == sL2);   }
 
-template 
+template 
 inline bool
-operator>(const slist& sL1, const slist& sL2)
+operator>(const slist& sL1, const slist& sL2)
    {  return sL2 < sL1; }
 
-template 
+template 
 inline bool
-operator<=(const slist& sL1, const slist& sL2)
+operator<=(const slist& sL1, const slist& sL2)
    {  return !(sL2 < sL1); }
 
-template 
+template 
 inline bool
-operator>=(const slist& sL1, const slist& sL2)
+operator>=(const slist& sL1, const slist& sL2)
    {  return !(sL1 < sL2); }
 
-template 
-inline void swap(slist& x, slist& y)
+template 
+inline void swap(slist& x, slist& y)
    {  x.swap(y);  }
 
 }}
@@ -1666,10 +1661,10 @@ namespace boost {
 /*
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
-template 
-struct has_trivial_destructor_after_move >
+template 
+struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor::value;
 };
 */
 namespace container {
@@ -1687,11 +1682,11 @@ namespace container {
 //there is no other way
 namespace std {
 
-template 
-class insert_iterator >
+template 
+class insert_iterator >
 {
  protected:
-   typedef boost::container::slist Container;
+   typedef boost::container::slist Container;
    Container* container;
    typename Container::iterator iter;
    public:
@@ -1724,4 +1719,4 @@ class insert_iterator >
 
 #include 
 
-#endif /* BOOST_CONTAINER_SLIST_HPP */
+#endif // BOOST_CONTAINER_SLIST_HPP
diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp
index 3e45e7e..03f7d92 100644
--- a/include/boost/container/stable_vector.hpp
+++ b/include/boost/container/stable_vector.hpp
@@ -275,26 +275,6 @@ class iterator
    node_ptr pn;
 };
 
-template
-struct select_multiallocation_chain
-{
-   typedef typename A::multiallocation_chain type;
-};
-
-template
-struct select_multiallocation_chain
-{
-   typedef typename boost::intrusive::pointer_traits
-      ::pointer>::
-         template rebind_pointer::type                void_ptr;
-   typedef container_detail::basic_multiallocation_chain
-                                                  multialloc_cached_counted;
-   typedef boost::container::container_detail::
-      transform_multiallocation_chain
-         < multialloc_cached_counted
-         , typename allocator_traits::value_type>        type;
-};
-
 template
 struct index_traits
 {
@@ -386,6 +366,89 @@ struct index_traits
    #endif   //STABLE_VECTOR_ENABLE_INVARIANT_CHECKING
 };
 
+template::value>
+struct allocator_version_wrapper
+{
+   typedef ::boost::container::container_detail::integral_constant
+       alloc_version;
+
+   typedef typename Allocator::multiallocation_chain multiallocation_chain;
+
+   typedef typename boost::container::allocator_traits::pointer    pointer;
+   typedef typename boost::container::allocator_traits::size_type  size_type;
+
+   static pointer allocate_one(Allocator &a)
+   {  return a.allocate_one();   }
+
+   static void deallocate_one(Allocator &a, const pointer &p)
+   {  a.deallocate_one(p);   }
+
+   static multiallocation_chain allocate_individual(Allocator &a, size_type n)
+   {  return a.allocate_individual(n);   }
+
+   static void deallocate_individual(Allocator &a, multiallocation_chain &holder)
+   {  a.deallocate_individual(::boost::move(holder));   }
+};
+
+template
+struct allocator_version_wrapper
+{
+   typedef ::boost::container::container_detail::integral_constant
+       alloc_version;
+
+   typedef typename boost::container::allocator_traits::pointer    pointer;
+   typedef typename boost::container::allocator_traits::size_type  size_type;
+   typedef typename boost::container::allocator_traits::value_type value_type;
+
+   typedef typename boost::intrusive::pointer_traits::
+         template rebind_pointer::type                void_ptr;
+   typedef container_detail::basic_multiallocation_chain
+                                                  multialloc_cached_counted;
+   typedef boost::container::container_detail::
+      transform_multiallocation_chain
+         < multialloc_cached_counted, value_type>           multiallocation_chain;
+
+   static pointer allocate_one(Allocator &a)
+   {  return a.allocate(1);   }
+
+   static void deallocate_one(Allocator &a, const pointer &p)
+   {  a.deallocate(p, 1);   }
+
+   static void deallocate_individual(Allocator &a, multiallocation_chain &holder)
+   {
+      while(!holder.empty()){
+         a.deallocate(holder.pop_front(), 1);
+      }
+   }
+
+   struct allocate_individual_rollback
+   {
+      allocate_individual_rollback(Allocator &a, multiallocation_chain &chain)
+         : mr_a(a), mr_chain(chain)
+      {}
+
+      ~allocate_individual_rollback()
+      {
+         allocator_version_wrapper::deallocate_individual(mr_a, mr_chain);
+      }
+
+      Allocator &mr_a;
+      multiallocation_chain &mr_chain;
+   };
+
+   static multiallocation_chain allocate_individual(Allocator &a, size_type n)
+   {
+      multiallocation_chain m;
+      multiallocation_chain m_ret;
+      allocate_individual_rollback rollback(a, m);
+      while(n--){
+         m.push_front(a.allocate(1));
+      }
+      m.swap(m_ret);
+      return ::boost::move(m_ret);
+   }
+};
+
 } //namespace stable_vector_detail
 
 #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -438,14 +501,14 @@ struct index_traits
 //! Exception safety: As stable_vector does not internally copy elements around, some
 //! operations provide stronger exception safety guarantees than in std::vector.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template  >
+template  >
 #else
-template 
+template 
 #endif
 class stable_vector
 {
    ///@cond
-   typedef allocator_traits                        allocator_traits_type;
+   typedef allocator_traits                allocator_traits_type;
    typedef typename boost::intrusive::pointer_traits
       ::
          template rebind_pointer::type          void_ptr;
@@ -487,125 +550,35 @@ class stable_vector
       integral_constant                  allocator_v2;
    typedef ::boost::container::container_detail::integral_constant
       ::value>                              alloc_version;
+      version::value>                              alloc_version;
    typedef typename allocator_traits_type::
       template portable_rebind_alloc
          ::type                            node_allocator_type;
-   typedef typename stable_vector_detail::
-      select_multiallocation_chain
-      < node_allocator_type
-      , alloc_version::value
-      >::type                                         multiallocation_chain;
+
+   typedef stable_vector_detail::allocator_version_wrapper allocator_version_wrapper_t;
+   typedef typename allocator_version_wrapper_t::multiallocation_chain multiallocation_chain;
 
    node_ptr allocate_one()
-   {  return this->allocate_one(alloc_version());   }
+   {  return allocator_version_wrapper_t::allocate_one(this->priv_node_alloc());   }
 
-   template
-   node_ptr allocate_one(AllocatorVersion,
-      typename boost::container::container_detail::enable_if_c
-         
-            ::value>::type * = 0)
-   {  return this->priv_node_alloc().allocate(1);   }
-
-   template
-   node_ptr allocate_one(AllocatorVersion,
-      typename boost::container::container_detail::enable_if_c
-         
-            ::value>::type * = 0)
-   {  return this->priv_node_alloc().allocate_one();   }
-
-   void deallocate_one(node_ptr p)
-   {  return this->deallocate_one(p, alloc_version());   }
-
-   template
-   void deallocate_one(node_ptr p, AllocatorVersion,
-      typename boost::container::container_detail::enable_if_c
-         
-            ::value>::type * = 0)
-   {  this->priv_node_alloc().deallocate(p, 1);   }
-
-   template
-   void deallocate_one(node_ptr p, AllocatorVersion,
-      typename boost::container::container_detail::enable_if_c
-         
-            ::value>::type * = 0)
-   {  this->priv_node_alloc().deallocate_one(p);   }
+   void deallocate_one(const node_ptr &p)
+   {  allocator_version_wrapper_t::deallocate_one(this->priv_node_alloc(), p);   }
 
    multiallocation_chain allocate_individual(typename allocator_traits_type::size_type n)
-   {  return this->allocate_individual(n, alloc_version());   }
-
-   struct allocate_individual_rollback
-   {
-      allocate_individual_rollback(stable_vector &sv, multiallocation_chain &chain)
-         : mr_sv(sv), mr_chain(chain)
-      {}
-
-      ~allocate_individual_rollback()
-      {
-         if(!mr_chain.empty()){
-            mr_sv.deallocate_individual(mr_chain);
-         }
-      }
-
-      stable_vector &mr_sv;
-      multiallocation_chain &mr_chain;
-   };
-
-   template
-   multiallocation_chain allocate_individual
-      (typename allocator_traits_type::size_type n, AllocatorVersion,
-      typename boost::container::container_detail::enable_if_c
-         
-            ::value>::type * = 0)
-   {
-      multiallocation_chain m;
-      multiallocation_chain m_ret;
-      allocate_individual_rollback rollback(*this, m);
-      while(n--){
-         m.push_front(this->allocate_one());
-      }
-      m.swap(m_ret);
-      return ::boost::move(m_ret);
-   }
-
-   template
-   multiallocation_chain allocate_individual
-      (typename allocator_traits_type::size_type n, AllocatorVersion,
-      typename boost::container::container_detail::enable_if_c
-         
-            ::value>::type * = 0)
-   {  return this->priv_node_alloc().allocate_individual(n);   }
+   {  return allocator_version_wrapper_t::allocate_individual(this->priv_node_alloc(), n);   }
 
    void deallocate_individual(multiallocation_chain &holder)
-   {  this->deallocate_individual(holder, alloc_version());   }
-
-   template
-   void deallocate_individual(multiallocation_chain & holder, AllocatorVersion,
-      typename boost::container::container_detail::enable_if_c
-         
-            ::value>::type * = 0)
-   {
-      while(!holder.empty()){
-         this->deallocate_one(holder.pop_front());
-      }
-   }
-
-   template
-   void deallocate_individual(multiallocation_chain & holder, AllocatorVersion,
-      typename boost::container::container_detail::enable_if_c
-         
-            ::value>::type * = 0)
-   {  this->priv_node_alloc().deallocate_individual(boost::move(holder));  }
+   {  allocator_version_wrapper_t::deallocate_individual(this->priv_node_alloc(), holder);   }
 
    friend class stable_vector_detail::clear_on_destroy;
    typedef stable_vector_detail::iterator
       < T
-      , typename allocator_traits::reference
-      , typename allocator_traits::pointer>              iterator_impl;
+      , typename allocator_traits::reference
+      , typename allocator_traits::pointer>              iterator_impl;
    typedef stable_vector_detail::iterator
       < T
-      , typename allocator_traits::const_reference
-      , typename allocator_traits::const_pointer>        const_iterator_impl;
+      , typename allocator_traits::const_reference
+      , typename allocator_traits::const_pointer>        const_iterator_impl;
    ///@endcond
    public:
 
@@ -614,19 +587,19 @@ class stable_vector
    //                    types
    //
    //////////////////////////////////////////////
-   typedef T                                                                  value_type;
-   typedef typename ::boost::container::allocator_traits::pointer          pointer;
-   typedef typename ::boost::container::allocator_traits::const_pointer    const_pointer;
-   typedef typename ::boost::container::allocator_traits::reference        reference;
-   typedef typename ::boost::container::allocator_traits::const_reference  const_reference;
-   typedef typename ::boost::container::allocator_traits::size_type        size_type;
-   typedef typename ::boost::container::allocator_traits::difference_type  difference_type;
-   typedef A                                                                  allocator_type;
-   typedef node_allocator_type                                                stored_allocator_type;
-   typedef BOOST_CONTAINER_IMPDEF(iterator_impl)                              iterator;
-   typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl)                        const_iterator;
-   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)            reverse_iterator;
-   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)      const_reverse_iterator;
+   typedef T                                                                           value_type;
+   typedef typename ::boost::container::allocator_traits::pointer           pointer;
+   typedef typename ::boost::container::allocator_traits::const_pointer     const_pointer;
+   typedef typename ::boost::container::allocator_traits::reference         reference;
+   typedef typename ::boost::container::allocator_traits::const_reference   const_reference;
+   typedef typename ::boost::container::allocator_traits::size_type         size_type;
+   typedef typename ::boost::container::allocator_traits::difference_type   difference_type;
+   typedef Allocator                                                                   allocator_type;
+   typedef node_allocator_type                                                         stored_allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(iterator_impl)                                       iterator;
+   typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl)                                 const_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)                     reverse_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)               const_reverse_iterator;
 
    ///@cond
    private:
@@ -1863,46 +1836,46 @@ class stable_vector
    /// @endcond
 };
 
-template 
-bool operator==(const stable_vector& x,const stable_vector& y)
+template 
+bool operator==(const stable_vector& x,const stable_vector& y)
 {
    return x.size()==y.size()&&std::equal(x.begin(),x.end(),y.begin());
 }
 
-template 
-bool operator< (const stable_vector& x,const stable_vector& y)
+template 
+bool operator< (const stable_vector& x,const stable_vector& y)
 {
    return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end());
 }
 
-template 
-bool operator!=(const stable_vector& x,const stable_vector& y)
+template 
+bool operator!=(const stable_vector& x,const stable_vector& y)
 {
    return !(x==y);
 }
 
-template 
-bool operator> (const stable_vector& x,const stable_vector& y)
+template 
+bool operator> (const stable_vector& x,const stable_vector& y)
 {
    return y
-bool operator>=(const stable_vector& x,const stable_vector& y)
+template 
+bool operator>=(const stable_vector& x,const stable_vector& y)
 {
    return !(x
-bool operator<=(const stable_vector& x,const stable_vector& y)
+template 
+bool operator<=(const stable_vector& x,const stable_vector& y)
 {
    return !(x>y);
 }
 
 // specialized algorithms:
 
-template 
-void swap(stable_vector& x,stable_vector& y)
+template 
+void swap(stable_vector& x,stable_vector& y)
 {
    x.swap(y);
 }
diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp
index 42caee0..48f672a 100644
--- a/include/boost/container/string.hpp
+++ b/include/boost/container/string.hpp
@@ -84,14 +84,14 @@ namespace container_detail {
 // memory.  The destructor assumes that the memory either is the internal buffer,
 // or else points to a block of memory that was allocated using _String_base's
 // allocator and whose size is this->m_storage.
-template 
+template 
 class basic_string_base
 {
    BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_string_base)
 
-   typedef allocator_traits allocator_traits_type;
+   typedef allocator_traits allocator_traits_type;
  public:
-   typedef A allocator_type;
+   typedef Allocator                                  allocator_type;
    //! The stored allocator type
    typedef allocator_type                              stored_allocator_type;
    typedef typename allocator_traits_type::pointer     pointer;
@@ -211,24 +211,24 @@ class basic_string_base
    };
 
    struct members_holder
-      :  public A
+      :  public Allocator
    {
       members_holder()
-         : A()
+         : Allocator()
       {}
 
       template
       explicit members_holder(BOOST_FWD_REF(AllocatorConvertible) a)
-         :  A(boost::forward(a))
+         :  Allocator(boost::forward(a))
       {}
 
       repr_t m_repr;
    } members_;
 
-   const A &alloc() const
+   const Allocator &alloc() const
    {  return members_;  }
 
-   A &alloc()
+   Allocator &alloc()
    {  return members_;  }
 
    static const size_type InternalBufferChars = (sizeof(repr_t) - ShortDataOffset)/sizeof(value_type);
@@ -272,7 +272,7 @@ class basic_string_base
    typedef container_detail::integral_constant      allocator_v1;
    typedef container_detail::integral_constant      allocator_v2;
    typedef container_detail::integral_constant::value> alloc_version;
+      boost::container::container_detail::version::value> alloc_version;
 
    std::pair
       allocation_command(allocation_type command,
@@ -521,22 +521,22 @@ class basic_string_base
 //! In this implementation, iterators are only invalidated by member functions that
 //! explicitly change the string's contents.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template , class A = std::allocator >
+template , class Allocator = std::allocator >
 #else
-template 
+template 
 #endif
 class basic_string
-   :  private container_detail::basic_string_base
+   :  private container_detail::basic_string_base
 {
    /// @cond
    private:
-   typedef allocator_traits allocator_traits_type;
+   typedef allocator_traits allocator_traits_type;
    BOOST_COPYABLE_AND_MOVABLE(basic_string)
-   typedef container_detail::basic_string_base base_t;
+   typedef container_detail::basic_string_base base_t;
    static const typename base_t::size_type InternalBufferChars = base_t::InternalBufferChars;
 
    protected:
-   // A helper class to use a char_traits as a function object.
+   // Allocator helper class to use a char_traits as a function object.
 
    template 
    struct Eq_traits
@@ -571,7 +571,7 @@ class basic_string
    public:
 
    //! The allocator type
-   typedef A                                       allocator_type;
+   typedef Allocator                                       allocator_type;
    //! The stored allocator type
    typedef allocator_type                          stored_allocator_type;
    //! The type of object, CharT, stored in the string
@@ -1892,7 +1892,7 @@ class basic_string
 
    //! Requires: The program shall not alter any of the values stored in the character array.
    //!
-   //! Returns: A pointer p such that p + i == &operator[](i) for each i in [0,size()].
+   //! Returns: Allocator pointer p such that p + i == &operator[](i) for each i in [0,size()].
    //!
    //! Complexity: constant time.
    const CharT* c_str() const
@@ -1900,7 +1900,7 @@ class basic_string
 
    //! Requires: The program shall not alter any of the values stored in the character array.
    //!
-   //! Returns: A pointer p such that p + i == &operator[](i) for each i in [0,size()].
+   //! Returns: Allocator pointer p such that p + i == &operator[](i) for each i in [0,size()].
    //!
    //! Complexity: constant time.
    const CharT* data()  const
@@ -2483,10 +2483,10 @@ wstring;
 
 /// @cond
 
-template 
-const typename basic_string::size_type
-basic_string::npos
-  = (typename basic_string::size_type) -1;
+template 
+const typename basic_string::size_type
+basic_string::npos
+  = (typename basic_string::size_type) -1;
 
 /// @endcond
 
@@ -2495,273 +2495,212 @@ basic_string::npos
 
 // Operator+
 
-template 
-inline basic_string
-operator+(const basic_string& x,
-          const basic_string& y)
+template  inline 
+   basic_string
+   operator+(const basic_string& x
+            ,const basic_string& y)
 {
-   typedef basic_string str_t;
+   typedef basic_string str_t;
    typedef typename str_t::reserve_t reserve_t;
    reserve_t reserve;
    str_t result(reserve, x.size() + y.size(), x.get_stored_allocator());
    result.append(x);
    result.append(y);
-   return boost::move(result);
+   return result;
 }
 
-template  inline
-BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A)
-   operator+(
-   BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) mx
-   , BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) my)
+template  inline
+   basic_string operator+
+      ( BOOST_RV_REF_BEG basic_string BOOST_RV_REF_END mx
+      , BOOST_RV_REF_BEG basic_string BOOST_RV_REF_END my)
 {
    mx += my;
    return boost::move(mx);
 }
 
-template  inline
-BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A)
-   operator+(
-   BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) mx
-   , const basic_string& y)
+template  inline
+   basic_string operator+
+      ( BOOST_RV_REF_BEG basic_string BOOST_RV_REF_END mx
+      , const basic_string& y)
 {
    mx += y;
    return boost::move(mx);
 }
 
-template  inline
-BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A)
-   operator+(const basic_string& x,
-         BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) my)
+template  inline
+   basic_string operator+
+      (const basic_string& x
+      ,BOOST_RV_REF_BEG basic_string BOOST_RV_REF_END my)
 {
-   typedef typename basic_string::size_type size_type;
-   my.replace(size_type(0), size_type(0), x);
+   my.insert(my.begin(), x.begin(), x.end());
    return boost::move(my);
 }
 
-template 
-inline basic_string
-operator+(const CharT* s, const basic_string& y)
+template  inline
+   basic_string operator+
+      (const CharT* s, basic_string y)
 {
-   typedef basic_string str_t;
-   typedef typename str_t::reserve_t reserve_t;
-   reserve_t reserve;
-   const typename str_t::size_type n = Traits::length(s);
-   str_t result(reserve, n + y.size());
-   result.append(s, s + n);
-   result.append(y);
-   return boost::move(result);
+   y.insert(y.begin(), s, s + Traits::length(s));
+   return y;
 }
 
-template  inline
-BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A)
-operator+(const CharT* s,
-         BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) my)
+template  inline 
+   basic_string operator+
+      (basic_string x, const CharT* s)
 {
-   typedef typename basic_string::size_type size_type;
-   return boost::move(my.replace(size_type(0), size_type(0), s));
+   x += s;
+   return x;
 }
 
-template 
-inline basic_string
-operator+(CharT c, const basic_string& y)
+template  inline
+   basic_string operator+
+      (CharT c, basic_string y)
 {
-   typedef basic_string str_t;
-   typedef typename str_t::reserve_t reserve_t;
-   reserve_t reserve;
-   str_t result(reserve, 1 + y.size());
-   result.push_back(c);
-   result.append(y);
-   return boost::move(result);
+   y.insert(y.begin(), c);
+   return y;
 }
 
-template  inline
-BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A)
-operator+(CharT c,
-         BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) my)
+template  inline 
+   basic_string operator+
+      (basic_string x, const CharT c)
 {
-   typedef typename basic_string::size_type size_type;
-   return boost::move(my.replace(size_type(0), size_type(0), &c, &c + 1));
-}
-
-template 
-inline basic_string
-operator+(const basic_string& x, const CharT* s)
-{
-   typedef basic_string str_t;
-   typedef typename str_t::reserve_t reserve_t;
-   reserve_t reserve;
-   const typename str_t::size_type n = Traits::length(s);
-   str_t result(reserve, x.size() + n, x.get_stored_allocator());
-   result.append(x);
-   result.append(s, s + n);
-   return boost::move(result);
-}
-
-template 
-BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A)
-operator+(BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) mx
-         , const CharT* s)
-{
-   mx += s;
-   return boost::move(mx);
-}
-
-template 
-inline basic_string
-operator+(const basic_string& x, const CharT c)
-{
-   typedef basic_string str_t;
-   typedef typename str_t::reserve_t reserve_t;
-   reserve_t reserve;
-   str_t result(reserve, x.size() + 1, x.get_stored_allocator());
-   result.append(x);
-   result.push_back(c);
-   return boost::move(result);
-}
-
-template 
-BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A)
-operator+( BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) mx
-         , const CharT c)
-{
-   mx += c;
-   return boost::move(mx);
+   x += c;
+   return x;
 }
 
 // Operator== and operator!=
 
-template 
+template 
 inline bool
-operator==(const basic_string& x,
-           const basic_string& y)
+operator==(const basic_string& x,
+           const basic_string& y)
 {
    return x.size() == y.size() &&
           Traits::compare(x.data(), y.data(), x.size()) == 0;
 }
 
-template 
+template 
 inline bool
-operator==(const CharT* s, const basic_string& y)
+operator==(const CharT* s, const basic_string& y)
 {
-   typename basic_string::size_type n = Traits::length(s);
+   typename basic_string::size_type n = Traits::length(s);
    return n == y.size() && Traits::compare(s, y.data(), n) == 0;
 }
 
-template 
+template 
 inline bool
-operator==(const basic_string& x, const CharT* s)
+operator==(const basic_string& x, const CharT* s)
 {
-   typename basic_string::size_type n = Traits::length(s);
+   typename basic_string::size_type n = Traits::length(s);
    return x.size() == n && Traits::compare(x.data(), s, n) == 0;
 }
 
-template 
+template 
 inline bool
-operator!=(const basic_string& x,
-           const basic_string& y)
+operator!=(const basic_string& x,
+           const basic_string& y)
    {  return !(x == y);  }
 
-template 
+template 
 inline bool
-operator!=(const CharT* s, const basic_string& y)
+operator!=(const CharT* s, const basic_string& y)
    {  return !(s == y); }
 
-template 
+template 
 inline bool
-operator!=(const basic_string& x, const CharT* s)
+operator!=(const basic_string& x, const CharT* s)
    {  return !(x == s);   }
 
 
 // Operator< (and also >, <=, and >=).
 
-template 
+template 
 inline bool
-operator<(const basic_string& x, const basic_string& y)
+operator<(const basic_string& x, const basic_string& y)
 {
    return x.compare(y) < 0;
-//   return basic_string
+//   return basic_string
 //      ::s_compare(x.begin(), x.end(), y.begin(), y.end()) < 0;
 }
 
-template 
+template 
 inline bool
-operator<(const CharT* s, const basic_string& y)
+operator<(const CharT* s, const basic_string& y)
 {
    return y.compare(s) > 0;
-//   basic_string::size_type n = Traits::length(s);
-//   return basic_string
+//   basic_string::size_type n = Traits::length(s);
+//   return basic_string
 //          ::s_compare(s, s + n, y.begin(), y.end()) < 0;
 }
 
-template 
+template 
 inline bool
-operator<(const basic_string& x,
+operator<(const basic_string& x,
           const CharT* s)
 {
    return x.compare(s) < 0;
-//   basic_string::size_type n = Traits::length(s);
-//   return basic_string
+//   basic_string::size_type n = Traits::length(s);
+//   return basic_string
 //      ::s_compare(x.begin(), x.end(), s, s + n) < 0;
 }
 
-template 
+template 
 inline bool
-operator>(const basic_string& x,
-          const basic_string& y) {
+operator>(const basic_string& x,
+          const basic_string& y) {
    return y < x;
 }
 
-template 
+template 
 inline bool
-operator>(const CharT* s, const basic_string& y) {
+operator>(const CharT* s, const basic_string& y) {
    return y < s;
 }
 
-template 
+template 
 inline bool
-operator>(const basic_string& x, const CharT* s)
+operator>(const basic_string& x, const CharT* s)
 {
    return s < x;
 }
 
-template 
+template 
 inline bool
-operator<=(const basic_string& x,
-           const basic_string& y)
+operator<=(const basic_string& x,
+           const basic_string& y)
 {
   return !(y < x);
 }
 
-template 
+template 
 inline bool
-operator<=(const CharT* s, const basic_string& y)
+operator<=(const CharT* s, const basic_string& y)
    {  return !(y < s);  }
 
-template 
+template 
 inline bool
-operator<=(const basic_string& x, const CharT* s)
+operator<=(const basic_string& x, const CharT* s)
    {  return !(s < x);  }
 
-template 
+template 
 inline bool
-operator>=(const basic_string& x,
-           const basic_string& y)
+operator>=(const basic_string& x,
+           const basic_string& y)
    {  return !(x < y);  }
 
-template 
+template 
 inline bool
-operator>=(const CharT* s, const basic_string& y)
+operator>=(const CharT* s, const basic_string& y)
    {  return !(s < y);  }
 
-template 
+template 
 inline bool
-operator>=(const basic_string& x, const CharT* s)
+operator>=(const basic_string& x, const CharT* s)
    {  return !(x < s);  }
 
 // Swap.
-template 
-inline void swap(basic_string& x, basic_string& y)
+template 
+inline void swap(basic_string& x, basic_string& y)
 {  x.swap(y);  }
 
 /// @cond
@@ -2786,17 +2725,17 @@ string_fill(std::basic_ostream& os,
 }  //namespace container_detail {
 /// @endcond
 
-template 
+template 
 std::basic_ostream&
-operator<<(std::basic_ostream& os, const basic_string& s)
+operator<<(std::basic_ostream& os, const basic_string& s)
 {
    typename std::basic_ostream::sentry sentry(os);
    bool ok = false;
 
    if (sentry) {
       ok = true;
-      typename basic_string::size_type n = s.size();
-      typename basic_string::size_type pad_len = 0;
+      typename basic_string::size_type n = s.size();
+      typename basic_string::size_type pad_len = 0;
       const bool left = (os.flags() & std::ios::left) != 0;
       const std::size_t w = os.width(0);
       std::basic_streambuf* buf = os.rdbuf();
@@ -2821,9 +2760,9 @@ operator<<(std::basic_ostream& os, const basic_string
+template 
 std::basic_istream&
-operator>>(std::basic_istream& is, basic_string& s)
+operator>>(std::basic_istream& is, basic_string& s)
 {
    typename std::basic_istream::sentry sentry(is);
 
@@ -2868,11 +2807,11 @@ operator>>(std::basic_istream& is, basic_string&
    return is;
 }
 
-template    
+template    
 std::basic_istream&
-getline(std::istream& is, basic_string& s,CharT delim)
+getline(std::istream& is, basic_string& s,CharT delim)
 {
-   typename basic_string::size_type nread = 0;
+   typename basic_string::size_type nread = 0;
    typename std::basic_istream::sentry sentry(is, true);
    if (sentry) {
       std::basic_streambuf* buf = is.rdbuf();
@@ -2900,15 +2839,15 @@ getline(std::istream& is, basic_string& s,CharT delim)
    return is;
 }
 
-template    
+template    
 inline std::basic_istream&
-getline(std::basic_istream& is, basic_string& s)
+getline(std::basic_istream& is, basic_string& s)
 {
    return getline(is, s, '\n');
 }
 
-template 
-inline std::size_t hash_value(basic_string, A> const& v)
+template 
+inline std::size_t hash_value(basic_string, Allocator> const& v)
 {
    return hash_range(v.begin(), v.end());
 }
@@ -2921,10 +2860,10 @@ namespace boost {
 /*
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
-template 
-struct has_trivial_destructor_after_move >
+template 
+struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor::value;
 };
 */
 }
diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp
index 12067d7..972db9e 100644
--- a/include/boost/container/vector.hpp
+++ b/include/boost/container/vector.hpp
@@ -207,11 +207,11 @@ class vector_iterator
    {  return static_cast&>(*this) - right;   }
 };
 
-template 
+template 
 struct vector_value_traits
 {
    typedef T value_type;
-   typedef A allocator_type;
+   typedef Allocator allocator_type;
    static const bool trivial_dctr = boost::has_trivial_destructor::value;
    static const bool trivial_dctr_after_move = trivial_dctr;
       //::boost::has_trivial_destructor_after_move::value || trivial_dctr;
@@ -229,37 +229,37 @@ struct vector_value_traits
    //to deallocate values already constructed
    typedef typename container_detail::if_c
       
-      ,container_detail::scoped_destructor_n
+      ,container_detail::null_scoped_destructor_n
+      ,container_detail::scoped_destructor_n
       >::type   OldArrayDestructor;
    //This is the anti-exception array destructor
    //to destroy objects created with copy construction
    typedef typename container_detail::if_c
       
-      ,container_detail::scoped_destructor_n
+      ,container_detail::null_scoped_destructor_n
+      ,container_detail::scoped_destructor_n
       >::type   ArrayDestructor;
    //This is the anti-exception array deallocator
    typedef typename container_detail::if_c
       
-      ,container_detail::scoped_array_deallocator
+      ,container_detail::null_scoped_array_deallocator
+      ,container_detail::scoped_array_deallocator
       >::type   ArrayDeallocator;
 };
 
 //!This struct deallocates and allocated memory
-template 
+template 
 struct vector_alloc_holder
 {
-   typedef boost::container::allocator_traits         allocator_traits_type;
+   typedef boost::container::allocator_traits allocator_traits_type;
    typedef typename allocator_traits_type::pointer       pointer;
    typedef typename allocator_traits_type::size_type     size_type;
    typedef typename allocator_traits_type::value_type    value_type;
-   typedef vector_value_traits            value_traits;
+   typedef vector_value_traits    value_traits;
 
    //Constructor, does not throw
    vector_alloc_holder()
-      BOOST_CONTAINER_NOEXCEPT_IF(::boost::has_nothrow_default_constructor::value)
+      BOOST_CONTAINER_NOEXCEPT_IF(::boost::has_nothrow_default_constructor::value)
       : members_()
    {}
 
@@ -279,7 +279,7 @@ struct vector_alloc_holder
    typedef container_detail::integral_constant      allocator_v1;
    typedef container_detail::integral_constant      allocator_v2;
    typedef container_detail::integral_constant::value> alloc_version;
+      boost::container::container_detail::version::value> alloc_version;
    std::pair
       allocation_command(allocation_type command,
                          size_type limit_size,
@@ -325,7 +325,7 @@ struct vector_alloc_holder
    }
 
    struct members_holder
-      : public A
+      : public Allocator
    {
       private:
       members_holder(const members_holder&);
@@ -333,11 +333,11 @@ struct vector_alloc_holder
       public:
       template
       explicit members_holder(BOOST_FWD_REF(Alloc) alloc)
-         :  A(boost::forward(alloc)), m_start(0), m_size(0), m_capacity(0)
+         :  Allocator(boost::forward(alloc)), m_start(0), m_size(0), m_capacity(0)
       {}
 
       members_holder()
-         :  A(), m_start(0), m_size(0), m_capacity(0)
+         :  Allocator(), m_start(0), m_size(0), m_capacity(0)
       {}
 
       pointer     m_start;
@@ -352,10 +352,10 @@ struct vector_alloc_holder
       container_detail::do_swap(this->members_.m_capacity, x.members_.m_capacity);
    }
 
-   A &alloc()
+   Allocator &alloc()
    {  return members_;  }
 
-   const A &alloc() const
+   const Allocator &alloc() const
    {  return members_;  }
 
    protected:
@@ -401,15 +401,15 @@ struct vector_alloc_holder
 //! boost::container::vector is similar to std::vector but it's compatible
 //! with shared memory and memory mapped files.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template  >
+template  >
 #else
-template 
+template 
 #endif
-class vector : private container_detail::vector_alloc_holder
+class vector : private container_detail::vector_alloc_holder
 {
    /// @cond
-   typedef container_detail::vector_alloc_holder base_t;
-   typedef allocator_traits            allocator_traits_type;
+   typedef container_detail::vector_alloc_holder base_t;
+   typedef allocator_traits            allocator_traits_type;
    /// @endcond
    public:
    //////////////////////////////////////////////
@@ -418,25 +418,25 @@ class vector : private container_detail::vector_alloc_holder
    //
    //////////////////////////////////////////////
 
-   typedef T                                                                        value_type;
-   typedef typename ::boost::container::allocator_traits::pointer                pointer;
-   typedef typename ::boost::container::allocator_traits::const_pointer          const_pointer;
-   typedef typename ::boost::container::allocator_traits::reference              reference;
-   typedef typename ::boost::container::allocator_traits::const_reference        const_reference;
-   typedef typename ::boost::container::allocator_traits::size_type              size_type;
-   typedef typename ::boost::container::allocator_traits::difference_type        difference_type;
-   typedef A                                                                        allocator_type;
-   typedef allocator_type                                                           stored_allocator_type;
-   typedef BOOST_CONTAINER_IMPDEF(container_detail::vector_iterator)       iterator;
-   typedef BOOST_CONTAINER_IMPDEF(container_detail::vector_const_iterator) const_iterator;
-   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)                  reverse_iterator;
-   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)            const_reverse_iterator;
+   typedef T                                                                           value_type;
+   typedef typename ::boost::container::allocator_traits::pointer           pointer;
+   typedef typename ::boost::container::allocator_traits::const_pointer     const_pointer;
+   typedef typename ::boost::container::allocator_traits::reference         reference;
+   typedef typename ::boost::container::allocator_traits::const_reference   const_reference;
+   typedef typename ::boost::container::allocator_traits::size_type         size_type;
+   typedef typename ::boost::container::allocator_traits::difference_type   difference_type;
+   typedef Allocator                                                                   allocator_type;
+   typedef Allocator                                                                   stored_allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(container_detail::vector_iterator)          iterator;
+   typedef BOOST_CONTAINER_IMPDEF(container_detail::vector_const_iterator)    const_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)                     reverse_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)               const_reverse_iterator;
 
    /// @cond
    private:
    BOOST_COPYABLE_AND_MOVABLE(vector)
    typedef container_detail::advanced_insert_aux_int    advanced_insert_aux_int_t;
-   typedef container_detail::vector_value_traits value_traits;
+   typedef container_detail::vector_value_traits value_traits;
 
    typedef typename base_t::allocator_v1           allocator_v1;
    typedef typename base_t::allocator_v2           allocator_v2;
@@ -460,7 +460,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    vector()
-      BOOST_CONTAINER_NOEXCEPT_IF(::boost::has_nothrow_default_constructor::value)
+      BOOST_CONTAINER_NOEXCEPT_IF(::boost::has_nothrow_default_constructor::value)
       : base_t()
    {}
 
@@ -469,7 +469,7 @@ class vector : private container_detail::vector_alloc_holder
    //! Throws: Nothing
    //!
    //! Complexity: Constant.
-   explicit vector(const A& a) BOOST_CONTAINER_NOEXCEPT
+   explicit vector(const Allocator& a) BOOST_CONTAINER_NOEXCEPT
       : base_t(a)
    {}
 
@@ -857,7 +857,7 @@ class vector : private container_detail::vector_alloc_holder
       else{
          const size_type n = new_size - this->size();
          this->reserve(new_size);
-         container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
+         container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
          this->priv_forward_range_insert(this->cend().get_ptr(), n, proxy);
       }
    }
@@ -921,7 +921,7 @@ class vector : private container_detail::vector_alloc_holder
          else{
             //We will reuse insert code, so create a dummy input iterator
             T *dummy_it(container_detail::to_raw_pointer(this->members_.m_start));
-            container_detail::advanced_insert_aux_proxy, T*>
+            container_detail::advanced_insert_aux_proxy, T*>
                proxy(this->alloc(), ::boost::make_move_iterator(dummy_it), ::boost::make_move_iterator(dummy_it));
             //Backwards (and possibly forward) expansion
             if(ret.second){
@@ -1060,7 +1060,7 @@ class vector : private container_detail::vector_alloc_holder
    //
    //////////////////////////////////////////////
 
-   //! Returns: A pointer such that [data(),data() + size()) is a valid range.
+   //! Returns: Allocator pointer such that [data(),data() + size()) is a valid range.
    //!   For a non-empty vector, data() == &front().
    //!
    //! Throws: Nothing.
@@ -1069,7 +1069,7 @@ class vector : private container_detail::vector_alloc_holder
    T* data() BOOST_CONTAINER_NOEXCEPT
    { return container_detail::to_raw_pointer(this->members_.m_start); }
 
-   //! Returns: A pointer such that [data(),data() + size()) is a valid range.
+   //! Returns: Allocator pointer such that [data(),data() + size()) is a valid range.
    //!   For a non-empty vector, data() == &front().
    //!
    //! Throws: Nothing.
@@ -1102,7 +1102,7 @@ class vector : private container_detail::vector_alloc_holder
          ++this->members_.m_size;
       }
       else{
-         typedef container_detail::advanced_insert_aux_emplace type;
+         typedef container_detail::advanced_insert_aux_emplace type;
          type &&proxy = type(this->alloc(), ::boost::forward(args)...);
          this->priv_forward_range_insert(back_pos, 1, proxy);
       }
@@ -1123,7 +1123,7 @@ class vector : private container_detail::vector_alloc_holder
    {
       //Just call more general insert(pos, size, value) and return iterator
       size_type pos_n = position - cbegin();
-      typedef container_detail::advanced_insert_aux_emplace type;
+      typedef container_detail::advanced_insert_aux_emplace type;
       type &&proxy = type(this->alloc(), ::boost::forward(args)...);
       this->priv_forward_range_insert(position.get_ptr(), 1, proxy);
       return iterator(this->members_.m_start + pos_n);
@@ -1144,7 +1144,7 @@ class vector : private container_detail::vector_alloc_holder
       }                                                                                         \
       else{                                                                                     \
          container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)      \
-             proxy                                   \
+             proxy                                   \
             (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));     \
          this->priv_forward_range_insert(back_pos, 1, proxy);                                   \
       }                                                                                         \
@@ -1156,7 +1156,7 @@ class vector : private container_detail::vector_alloc_holder
    {                                                                                            \
       size_type pos_n = pos - cbegin();                                                         \
          container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)      \
-             proxy                                   \
+             proxy                                   \
             (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));     \
       this->priv_forward_range_insert(container_detail::to_raw_pointer(pos.get_ptr()), 1,proxy);\
       return iterator(this->members_.m_start + pos_n);                                          \
@@ -1264,7 +1264,7 @@ class vector : private container_detail::vector_alloc_holder
    {
       const size_type n_pos = pos - this->cbegin();
       const size_type n = std::distance(first, last);
-      container_detail::advanced_insert_aux_proxy proxy(this->alloc(), first, last);
+      container_detail::advanced_insert_aux_proxy proxy(this->alloc(), first, last);
       this->priv_forward_range_insert(pos.get_ptr(), n, proxy);
       return this->begin() + n_pos;
    }
@@ -1395,10 +1395,7 @@ class vector : private container_detail::vector_alloc_holder
       }
    }
 
-   template
-   void priv_shrink_to_fit( AllocVersion
-                          , typename container_detail::enable_if_c<
-                              container_detail::is_same::value >::type * = 0)
+   void priv_shrink_to_fit(allocator_v1)
    {
       if(this->members_.m_capacity){
          if(!this->size()){
@@ -1413,7 +1410,7 @@ class vector : private container_detail::vector_alloc_holder
             if(real_cap < this->capacity()){
                //We will reuse insert code, so create a dummy input iterator
                T *dummy_it(container_detail::to_raw_pointer(this->members_.m_start));
-               container_detail::advanced_insert_aux_proxy, T*>
+               container_detail::advanced_insert_aux_proxy, T*>
                   proxy(this->alloc(), ::boost::make_move_iterator(dummy_it), ::boost::make_move_iterator(dummy_it));
                #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
                ++this->num_alloc;
@@ -1432,10 +1429,7 @@ class vector : private container_detail::vector_alloc_holder
       }
    }
 
-   template
-   void priv_shrink_to_fit(AllocVersion
-                          , typename container_detail::enable_if_c<
-                              !container_detail::is_same::value >::type * = 0)
+   void priv_shrink_to_fit(allocator_v2)
    {
       if(this->members_.m_capacity){
          if(!size()){
@@ -1443,7 +1437,7 @@ class vector : private container_detail::vector_alloc_holder
          }
          else{
             size_type received_size;
-            if(this->alloc().allocation_command
+            if(this->allocation_command
                ( shrink_in_place | nothrow_allocation
                , this->capacity(), this->size()
                , received_size,   this->members_.m_start).first){
@@ -1598,7 +1592,7 @@ class vector : private container_detail::vector_alloc_holder
    //|   prefix   | range |     suffix       |raw_mem      ~
    //|____________|_______|__________________|_____________~
    //
-   //New situation in Case A (hole_size == 0):
+   //New situation in Case Allocator (hole_size == 0):
    // range is moved through move assignments
    //
    //       first_pos   last_pos         limit_pos
@@ -1642,7 +1636,7 @@ class vector : private container_detail::vector_alloc_holder
       T* const last_ptr  = begin_ptr + last_pos;
 
       size_type hole_size = 0;
-      //Case A:
+      //Case Allocator:
       if((last_pos + shift_count) <= limit_pos){
          //All move assigned
          boost::move_backward(first_ptr, last_ptr, last_ptr + shift_count);
@@ -2056,31 +2050,31 @@ class vector : private container_detail::vector_alloc_holder
    /// @endcond
 };
 
-template 
+template 
 inline bool
-operator==(const vector& x, const vector& y)
+operator==(const vector& x, const vector& y)
 {
    //Check first size and each element if needed
    return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin());
 }
 
-template 
+template 
 inline bool
-operator!=(const vector& x, const vector& y)
+operator!=(const vector& x, const vector& y)
 {
    //Check first size and each element if needed
   return x.size() != y.size() || !std::equal(x.begin(), x.end(), y.begin());
 }
 
-template 
+template 
 inline bool
-operator<(const vector& x, const vector& y)
+operator<(const vector& x, const vector& y)
 {
    return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
 }
 
-template 
-inline void swap(vector& x, vector& y)
+template 
+inline void swap(vector& x, vector& y)
 {  x.swap(y);  }
 
 }}
@@ -2093,10 +2087,10 @@ namespace boost {
 
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
-template 
-struct has_trivial_destructor_after_move >
+template 
+struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor::value;
 };
 
 */
diff --git a/proj/to-do.txt b/proj/to-do.txt
index b548cbc..f0c9890 100644
--- a/proj/to-do.txt
+++ b/proj/to-do.txt
@@ -2,6 +2,9 @@
 ->Add an example with stateful allocators
 ->Add test to check convertible types in push_back/insert
 ->Add SCARY iterators.
+->Align with C++11 [multi]map::insert(P &&p) overload.
+->Unify all allocator version traits in one class (starting from stable_vector_detail::allocator_version_wrapper)
+   maybe in allocator_traits?
 
 
 Review allocator traits
@@ -53,22 +56,10 @@ Add hash for containers
 
 Add std:: hashing support
 
-Take out from class definition iterators in slist & list
-
 Fix trivial destructor after move and other optimizing traits
 
-Define typedefs exactly like the standard to generate better documentation. for implementation defined types:
-   #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-      #define BOOST_CONTAINER_IMPLDEF(TYPE) TYPE
-   #else
-      #define BOOST_CONTAINER_IMPLDEF(TYPE) implementation_defined
-   #endif
 Mark previous() in slist/and forward_list as non-standard
 
-Replace all insert_const_ref_type with BOOST_MOVE_CONVERSION_AWARE_CATCH_XXX
-
-
-
 Function order:
 
 ----------type------------
diff --git a/test/string_test.cpp b/test/string_test.cpp
index ce0e9c6..4b6ff25 100644
--- a/test/string_test.cpp
+++ b/test/string_test.cpp
@@ -85,7 +85,8 @@ struct string_literals
       {  return "Suffix";  }
    static const char *LongString()
       {  return "LongLongLongLongLongLongLongLongLongLongLongLongLongString";  }
-
+   static char Char()
+      {  return 'C';  }
    static void sprintf_number(char *buf, int number)
    {
       std::sprintf(buf, "%i", number);
@@ -103,7 +104,8 @@ struct string_literals
       {  return L"Suffix";  }
    static const wchar_t *LongString()
       {  return L"LongLongLongLongLongLongLongLongLongLongLongLongLongString";  }
-
+   static wchar_t Char()
+      {  return L'C';  }
    static void sprintf_number(wchar_t *buffer, unsigned int number)
    {
       //For compilers without wsprintf, print it backwards
@@ -398,6 +400,22 @@ int string_test()
          if(!StringEqual()(bs4, ss4)){
             return 1;
          }
+
+         bs2 = string_literals::String();
+         ss2 = string_literals::String();
+         bs4 = string_literals::Char() + bs2;
+         ss4 = string_literals::Char() + ss2;
+         if(!StringEqual()(bs4, ss4)){
+            return 1;
+         }
+
+         bs2 = string_literals::String();
+         ss2 = string_literals::String();
+         bs4 = bs2 + string_literals::Char();
+         ss4 = ss2 + string_literals::Char();
+         if(!StringEqual()(bs4, ss4)){
+            return 1;
+         }
       }
 
       //When done, delete vector

From 546a3f0f1256f112cad593764cf71ffaa1f91e22 Mon Sep 17 00:00:00 2001
From: "Jeffrey Lee Hellrung, Jr." 
Date: Tue, 23 Oct 2012 12:56:01 +0000
Subject: [PATCH 58/93] refs #7531 (variable shadowing in container and
 intrusive)

[SVN r81050]
---
 include/boost/container/detail/flat_tree.hpp  | 56 +++++++++----------
 .../detail/multiallocation_chain.hpp          | 24 ++++----
 include/boost/container/flat_map.hpp          | 12 ++--
 include/boost/container/flat_set.hpp          | 12 ++--
 include/boost/container/map.hpp               |  4 +-
 include/boost/container/set.hpp               |  4 +-
 include/boost/container/stable_vector.hpp     |  6 +-
 include/boost/container/string.hpp            | 28 +++++-----
 8 files changed, 73 insertions(+), 73 deletions(-)

diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp
index b6f9214..9146fd4 100644
--- a/include/boost/container/detail/flat_tree.hpp
+++ b/include/boost/container/detail/flat_tree.hpp
@@ -48,7 +48,7 @@ class flat_tree_value_compare
    typedef Value              first_argument_type;
    typedef Value              second_argument_type;
    typedef bool               return_type;
-   public:    
+   public:
    flat_tree_value_compare()
       : Compare()
    {}
@@ -65,7 +65,7 @@ class flat_tree_value_compare
 
    const Compare &get_comp() const
       {  return *this;  }
-  
+
    Compare &get_comp()
       {  return *this;  }
 };
@@ -238,7 +238,7 @@ class flat_tree
    flat_tree&  operator=(BOOST_RV_REF(flat_tree) mx)
    {  m_data = boost::move(mx.m_data); return *this;  }
 
-   public:   
+   public:
    // accessors:
    Compare key_comp() const
    { return this->m_data.get_comp(); }
@@ -446,11 +446,11 @@ class flat_tree
       //Loop in burst sizes
       while(len){
          const size_type burst = len < BurstSize ? len : BurstSize;
-         const const_iterator cend(this->cend());
+         const const_iterator cend_(this->cend());
          len -= burst;
          for(size_type i = 0; i != burst; ++i){
             //Get the insertion position for each key
-            pos = const_cast(*this).priv_upper_bound(pos, cend, KeyOfValue()(*first));
+            pos = const_cast(*this).priv_upper_bound(pos, cend_, KeyOfValue()(*first));
             positions[i] = static_cast(pos - beg);
             ++first;
          }
@@ -497,14 +497,14 @@ class flat_tree
       while(len){
          const size_type burst = len < BurstSize ? len : BurstSize;
          size_type unique_burst = 0u;
-         const const_iterator cend(this->cend());
+         const const_iterator cend_(this->cend());
          while(unique_burst < burst && len > 0){
             //Get the insertion position for each key
             const value_type & val = *first++;
             --len;
-            pos = const_cast(*this).priv_lower_bound(pos, cend, KeyOfValue()(val));
+            pos = const_cast(*this).priv_lower_bound(pos, cend_, KeyOfValue()(val));
             //Check if already present
-            if(pos != cend && !value_comp(val, *pos)){
+            if(pos != cend_ && !value_comp(val, *pos)){
                if(unique_burst > 0){
                   ++skips[unique_burst-1];
                }
@@ -692,22 +692,22 @@ class flat_tree
    // set operations:
    iterator find(const key_type& k)
    {
-      const Compare &key_comp = this->m_data.get_comp();
+      const Compare &key_comp_ = this->m_data.get_comp();
       iterator i = this->lower_bound(k);
 
-      if (i != this->end() && key_comp(k, KeyOfValue()(*i))){ 
-         i = this->end(); 
+      if (i != this->end() && key_comp_(k, KeyOfValue()(*i))){
+         i = this->end();
       }
       return i;
    }
 
    const_iterator find(const key_type& k) const
    {
-      const Compare &key_comp = this->m_data.get_comp();
+      const Compare &key_comp_ = this->m_data.get_comp();
       const_iterator i = this->lower_bound(k);
 
-      if (i != this->end() && key_comp(k, KeyOfValue()(*i))){ 
-         i = this->end(); 
+      if (i != this->end() && key_comp_(k, KeyOfValue()(*i))){
+         i = this->end();
       }
       return i;
    }
@@ -737,11 +737,11 @@ class flat_tree
    std::pair equal_range(const key_type& k) const
    {  return this->priv_equal_range(this->begin(), this->end(), k);  }
 
-   size_type capacity() const          
+   size_type capacity() const
    { return this->m_data.m_vect.capacity(); }
 
-   void reserve(size_type count)      
-   { this->m_data.m_vect.reserve(count);   }
+   void reserve(size_type count_)
+   { this->m_data.m_vect.reserve(count_);   }
 
    private:
    struct insert_commit_data
@@ -780,13 +780,13 @@ class flat_tree
    }
 
    std::pair priv_insert_unique_prepare
-      (const_iterator beg, const_iterator end, const value_type& val, insert_commit_data &commit_data)
+      (const_iterator beg, const_iterator end_, const value_type& val, insert_commit_data &commit_data)
    {
       const value_compare &value_comp  = this->m_data;
-      commit_data.position = this->priv_lower_bound(beg, end, KeyOfValue()(val));
+      commit_data.position = this->priv_lower_bound(beg, end_, KeyOfValue()(val));
       return std::pair
          ( *reinterpret_cast(&commit_data.position)
-         , commit_data.position == end || value_comp(val, *commit_data.position));
+         , commit_data.position == end_ || value_comp(val, *commit_data.position));
    }
 
    std::pair priv_insert_unique_prepare
@@ -854,7 +854,7 @@ class flat_tree
    RanIt priv_lower_bound(RanIt first, RanIt last,
                           const key_type & key) const
    {
-      const Compare &key_comp = this->m_data.get_comp();
+      const Compare &key_comp_ = this->m_data.get_comp();
       KeyOfValue key_extract;
       difference_type len = last - first, half;
       RanIt middle;
@@ -864,7 +864,7 @@ class flat_tree
          middle = first;
          middle += half;
 
-         if (key_comp(key_extract(*middle), key)) {
+         if (key_comp_(key_extract(*middle), key)) {
             ++middle;
             first = middle;
             len = len - half - 1;
@@ -879,7 +879,7 @@ class flat_tree
    RanIt priv_upper_bound(RanIt first, RanIt last,
                           const key_type & key) const
    {
-      const Compare &key_comp = this->m_data.get_comp();
+      const Compare &key_comp_ = this->m_data.get_comp();
       KeyOfValue key_extract;
       difference_type len = last - first, half;
       RanIt middle;
@@ -889,12 +889,12 @@ class flat_tree
          middle = first;
          middle += half;
 
-         if (key_comp(key, key_extract(*middle))) {
+         if (key_comp_(key, key_extract(*middle))) {
             len = half;
          }
          else{
             first = ++middle;
-            len = len - half - 1; 
+            len = len - half - 1;
          }
       }
       return first;
@@ -904,7 +904,7 @@ class flat_tree
    std::pair
       priv_equal_range(RanIt first, RanIt last, const key_type& key) const
    {
-      const Compare &key_comp = this->m_data.get_comp();
+      const Compare &key_comp_ = this->m_data.get_comp();
       KeyOfValue key_extract;
       difference_type len = last - first, half;
       RanIt middle, left, right;
@@ -914,12 +914,12 @@ class flat_tree
          middle = first;
          middle += half;
 
-         if (key_comp(key_extract(*middle), key)){
+         if (key_comp_(key_extract(*middle), key)){
             first = middle;
             ++first;
             len = len - half - 1;
          }
-         else if (key_comp(key, key_extract(*middle))){
+         else if (key_comp_(key, key_extract(*middle))){
             len = half;
          }
          else {
diff --git a/include/boost/container/detail/multiallocation_chain.hpp b/include/boost/container/detail/multiallocation_chain.hpp
index 98d0924..5752083 100644
--- a/include/boost/container/detail/multiallocation_chain.hpp
+++ b/include/boost/container/detail/multiallocation_chain.hpp
@@ -126,22 +126,22 @@ class basic_multiallocation_chain
       return ret;
    }
 
-   void splice_after(iterator after_this, basic_multiallocation_chain &x, iterator before_begin, iterator before_end)
-   {  slist_impl_.splice_after(after_this, x.slist_impl_, before_begin, before_end);   }
+   void splice_after(iterator after_this, basic_multiallocation_chain &x, iterator before_begin_, iterator before_end)
+   {  slist_impl_.splice_after(after_this, x.slist_impl_, before_begin_, before_end);   }
 
-   void splice_after(iterator after_this, basic_multiallocation_chain &x, iterator before_begin, iterator before_end, size_type n)
-   {  slist_impl_.splice_after(after_this, x.slist_impl_, before_begin, before_end, n);   }
+   void splice_after(iterator after_this, basic_multiallocation_chain &x, iterator before_begin_, iterator before_end, size_type n)
+   {  slist_impl_.splice_after(after_this, x.slist_impl_, before_begin_, before_end, n);   }
 
    void splice_after(iterator after_this, basic_multiallocation_chain &x)
    {  slist_impl_.splice_after(after_this, x.slist_impl_);   }
 
-   void incorporate_after(iterator after_this, void_pointer begin , iterator before_end)
+   void incorporate_after(iterator after_this, void_pointer begin_ , iterator before_end)
    {
-      slist_impl_.incorporate_after(after_this, to_node_ptr(begin), to_node_ptr(before_end));
+      slist_impl_.incorporate_after(after_this, to_node_ptr(begin_), to_node_ptr(before_end));
    }
 
-   void incorporate_after(iterator after_this, void_pointer begin, void_pointer before_end, size_type n)
-   {  slist_impl_.incorporate_after(after_this, to_node_ptr(begin), to_node_ptr(before_end), n);   }
+   void incorporate_after(iterator after_this, void_pointer begin_, void_pointer before_end, size_type n)
+   {  slist_impl_.incorporate_after(after_this, to_node_ptr(begin_), to_node_ptr(before_end), n);   }
 
    void swap(basic_multiallocation_chain &x)
    {  slist_impl_.swap(x.slist_impl_);   }
@@ -217,11 +217,11 @@ class transform_multiallocation_chain
    void swap(transform_multiallocation_chain &other_chain)
    {  holder_.swap(other_chain.holder_); }
 
-   void splice_after(iterator after_this, transform_multiallocation_chain &x, iterator before_begin, iterator before_end, size_type n)
-   {  holder_.splice_after(after_this.base(), x.holder_, before_begin.base(), before_end.base(), n);  }
+   void splice_after(iterator after_this, transform_multiallocation_chain &x, iterator before_begin_, iterator before_end, size_type n)
+   {  holder_.splice_after(after_this.base(), x.holder_, before_begin_.base(), before_end.base(), n);  }
 
-   void incorporate_after(iterator after_this, pointer begin, pointer before_end, size_type n)
-   {  holder_.incorporate_after(after_this.base(), begin, before_end, n);  }
+   void incorporate_after(iterator after_this, pointer begin_, pointer before_end, size_type n)
+   {  holder_.incorporate_after(after_this.base(), begin_, before_end, n);  }
 
    pointer pop_front()
    {  return cast(holder_.pop_front());  }
diff --git a/include/boost/container/flat_map.hpp b/include/boost/container/flat_map.hpp
index 1422d31..4fb9e07 100644
--- a/include/boost/container/flat_map.hpp
+++ b/include/boost/container/flat_map.hpp
@@ -418,7 +418,7 @@ class flat_map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type capacity() const          
+   size_type capacity() const
       { return m_flat_tree.capacity(); }
 
    //! Effects: If n is less than or equal to capacity(), this call has no
@@ -430,8 +430,8 @@ class flat_map
    //!
    //! Note: If capacity() is less than "count", iterators and references to
    //!   to values might be invalidated.
-   void reserve(size_type count)      
-      { m_flat_tree.reserve(count);   }
+   void reserve(size_type count_)
+      { m_flat_tree.reserve(count_);   }
 
    //! Effects: Tries to deallocate the excess of memory created
    //    with previous allocations. The size of the vector is unchanged
@@ -1266,7 +1266,7 @@ class flat_multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type capacity() const          
+   size_type capacity() const
       { return m_flat_tree.capacity(); }
 
    //! Effects: If n is less than or equal to capacity(), this call has no
@@ -1278,8 +1278,8 @@ class flat_multimap
    //!
    //! Note: If capacity() is less than "count", iterators and references to
    //!   to values might be invalidated.
-   void reserve(size_type count)      
-      { m_flat_tree.reserve(count);   }
+   void reserve(size_type count_)
+      { m_flat_tree.reserve(count_);   }
 
    //! Effects: Tries to deallocate the excess of memory created
    //    with previous allocations. The size of the vector is unchanged
diff --git a/include/boost/container/flat_set.hpp b/include/boost/container/flat_set.hpp
index a2fbae9..b6266e6 100644
--- a/include/boost/container/flat_set.hpp
+++ b/include/boost/container/flat_set.hpp
@@ -365,7 +365,7 @@ class flat_set
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type capacity() const          
+   size_type capacity() const
       { return m_flat_tree.capacity(); }
 
    //! Effects: If n is less than or equal to capacity(), this call has no
@@ -377,8 +377,8 @@ class flat_set
    //!
    //! Note: If capacity() is less than "count", iterators and references to
    //!   to values might be invalidated.
-   void reserve(size_type count)      
-      { m_flat_tree.reserve(count);   }
+   void reserve(size_type count_)
+      { m_flat_tree.reserve(count_);   }
 
    //! Effects: Tries to deallocate the excess of memory created
    //    with previous allocations. The size of the vector is unchanged
@@ -1045,7 +1045,7 @@ class flat_multiset
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type capacity() const          
+   size_type capacity() const
       { return m_flat_tree.capacity(); }
 
    //! Effects: If n is less than or equal to capacity(), this call has no
@@ -1057,8 +1057,8 @@ class flat_multiset
    //!
    //! Note: If capacity() is less than "count", iterators and references to
    //!   to values might be invalidated.
-   void reserve(size_type count)      
-      { m_flat_tree.reserve(count);   }
+   void reserve(size_type count_)
+      { m_flat_tree.reserve(count_);   }
 
    //! Effects: Tries to deallocate the excess of memory created
    //    with previous allocations. The size of the vector is unchanged
diff --git a/include/boost/container/map.hpp b/include/boost/container/map.hpp
index cde829e..92d499a 100644
--- a/include/boost/container/map.hpp
+++ b/include/boost/container/map.hpp
@@ -951,9 +951,9 @@ class multimap
    //!
    //! Complexity: Linear in N.
    template 
-   multimap(ordered_range_t ordered_range, InputIterator first, InputIterator last, const Compare& comp = Compare(),
+   multimap(ordered_range_t ordered_range_, InputIterator first, InputIterator last, const Compare& comp = Compare(),
          const allocator_type& a = allocator_type())
-      : m_tree(ordered_range, first, last, comp, a)
+      : m_tree(ordered_range_, first, last, comp, a)
    {}
 
    //! Effects: Copy constructs a multimap.
diff --git a/include/boost/container/set.hpp b/include/boost/container/set.hpp
index bdb89f2..3c6fcd5 100644
--- a/include/boost/container/set.hpp
+++ b/include/boost/container/set.hpp
@@ -757,10 +757,10 @@ class multiset
    //!
    //! Complexity: Linear in N.
    template 
-   multiset( ordered_range_t ordered_range, InputIterator first, InputIterator last
+   multiset( ordered_range_t ordered_range_, InputIterator first, InputIterator last
            , const Compare& comp = Compare()
            , const allocator_type& a = allocator_type())
-      : m_tree(ordered_range, first, last, comp, a)
+      : m_tree(ordered_range_, first, last, comp, a)
    {}
 
    //! Effects: Copy constructs a multiset.
diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp
index 03f7d92..8d23672 100644
--- a/include/boost/container/stable_vector.hpp
+++ b/include/boost/container/stable_vector.hpp
@@ -1094,7 +1094,7 @@ class stable_vector
       if(n > this->max_size())
          throw std::bad_alloc();
 
-      size_type size         = this->size();  
+      size_type size_        = this->size();  
       size_type old_capacity = this->capacity();
       if(n > old_capacity){
          index_traits_type::initialize_end_node(this->index, this->internal_data.end_node, n);
@@ -1106,8 +1106,8 @@ class stable_vector
             index_traits_type::fix_up_pointers_from(this->index, this->index.begin());
          }
          //Now fill pool if data is not enough
-         if((n - size) > this->internal_data.pool_size){
-            this->priv_increase_pool((n - size) - this->internal_data.pool_size);
+         if((n - size_) > this->internal_data.pool_size){
+            this->priv_increase_pool((n - size_) - this->internal_data.pool_size);
          }
       }
    }
diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp
index 48f672a..7cbd447 100644
--- a/include/boost/container/string.hpp
+++ b/include/boost/container/string.hpp
@@ -1322,10 +1322,10 @@ class basic_string
    //! Returns: *this
    basic_string& insert(size_type pos, const basic_string& s)
    {
-      const size_type size = this->size();
-      if (pos > size)
+      const size_type size_ = this->size();
+      if (pos > size_)
          this->throw_out_of_range();
-      if (size > this->max_size() - s.size())
+      if (size_ > this->max_size() - s.size())
          this->throw_length_error();
       this->insert(this->priv_addr() + pos, s.begin(), s.end());
       return *this;
@@ -1341,12 +1341,12 @@ class basic_string
    //! Returns: *this
    basic_string& insert(size_type pos1, const basic_string& s, size_type pos2, size_type n)
    {
-      const size_type size = this->size();
+      const size_type size_ = this->size();
       const size_type str_size = s.size();
-      if (pos1 > size || pos2 > str_size)
+      if (pos1 > size_ || pos2 > str_size)
          this->throw_out_of_range();
       size_type len = container_detail::min_value(n, str_size - pos2);
-      if (size > this->max_size() - len)
+      if (size_ > this->max_size() - len)
          this->throw_length_error();
       const CharT *beg_ptr = container_detail::to_raw_pointer(s.begin()) + pos2;
       const CharT *end_ptr = beg_ptr + len;
@@ -1949,12 +1949,12 @@ class basic_string
    //! Returns: find(basic_string(1,c), pos).
    size_type find(CharT c, size_type pos = 0) const
    {
-      const size_type size = this->size();
-      if (pos >= size)
+      const size_type size_ = this->size();
+      if (pos >= size_)
          return npos;
       else {
-         const pointer addr    = this->priv_addr();
-         pointer finish = addr + size;
+         const pointer addr = this->priv_addr();
+         pointer finish = addr + size_;
          const const_iterator result =
             std::find_if(addr + pos, finish,
                   std::bind2nd(Eq_traits(), c));
@@ -2039,12 +2039,12 @@ class basic_string
    //! Returns: find_first_of(basic_string(s, n), pos).
    size_type find_first_of(const CharT* s, size_type pos, size_type n) const
    {
-      const size_type size = this->size();
-      if (pos >= size)
+      const size_type size_ = this->size();
+      if (pos >= size_)
          return npos;
       else {
-         const pointer addr    = this->priv_addr();
-         pointer finish = addr + size;
+         const pointer addr = this->priv_addr();
+         pointer finish = addr + size_;
          const_iterator result = std::find_first_of
             (addr + pos, finish, s, s + n, Eq_traits());
          return result != finish ? result - this->begin() : npos;

From 22e74d279c7c73588e5c1c97e8f54381fd0308b3 Mon Sep 17 00:00:00 2001
From: Marshall Clow 
Date: Tue, 20 Nov 2012 23:06:46 +0000
Subject: [PATCH 59/93] Remove usage of deprecated macros

[SVN r81447]
---
 include/boost/container/allocator_traits.hpp  |  6 +-
 include/boost/container/detail/pair.hpp       |  2 +-
 .../boost/container/detail/preprocessor.hpp   | 26 +++----
 .../boost/container/detail/type_traits.hpp    |  2 +-
 include/boost/container/detail/workaround.hpp |  6 +-
 include/boost/container/scoped_allocator.hpp  | 72 +++++++++----------
 .../boost/container/scoped_allocator_fwd.hpp  |  6 +-
 7 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/include/boost/container/allocator_traits.hpp b/include/boost/container/allocator_traits.hpp
index 11d948b..b1c4e5e 100644
--- a/include/boost/container/allocator_traits.hpp
+++ b/include/boost/container/allocator_traits.hpp
@@ -165,11 +165,11 @@ struct allocator_traits
          propagate_on_container_swap, boost::false_type)
             propagate_on_container_swap;
 
-      #if !defined(BOOST_NO_TEMPLATE_ALIASES)
+      #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
          //C++11
          template  using rebind_alloc  = typename boost::intrusive::detail::type_rebinder::type;
          template  using rebind_traits = allocator_traits< rebind_alloc >;
-      #else    // #if !defined(BOOST_NO_TEMPLATE_ALIASES)
+      #else    // #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
          //Some workaround for C++03 or C++11 compilers with no template aliases
          template 
          struct rebind_alloc : boost::intrusive::detail::type_rebinder::type
@@ -196,7 +196,7 @@ struct allocator_traits
          struct rebind_traits
             : allocator_traits::type>
          {};
-      #endif   // #if !defined(BOOST_NO_TEMPLATE_ALIASES)
+      #endif   // #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
       template 
       struct portable_rebind_alloc
       {  typedef typename boost::intrusive::detail::type_rebinder::type type;  };
diff --git a/include/boost/container/detail/pair.hpp b/include/boost/container/detail/pair.hpp
index 2a20ed1..d5cd65a 100644
--- a/include/boost/container/detail/pair.hpp
+++ b/include/boost/container/detail/pair.hpp
@@ -336,7 +336,7 @@ struct is_class< ::boost::container::container_detail::pair >
    : public ::boost::true_type
 {};
 
-#ifdef BOOST_NO_RVALUE_REFERENCES
+#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
 
 template
 struct has_move_emulation_enabled< ::boost::container::container_detail::pair >
diff --git a/include/boost/container/detail/preprocessor.hpp b/include/boost/container/detail/preprocessor.hpp
index 5129ea1..599215f 100644
--- a/include/boost/container/detail/preprocessor.hpp
+++ b/include/boost/container/detail/preprocessor.hpp
@@ -47,7 +47,7 @@
 //This cast is ugly but it is necessary until "perfect forwarding"
 //is achieved in C++0x. Meanwhile, if we want to be able to
 //bind rvalues with non-const references, we have to be ugly
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
    #define BOOST_CONTAINER_PP_PARAM_LIST(z, n, data) \
    BOOST_PP_CAT(P, n) && BOOST_PP_CAT(p, n) \
    //!
@@ -55,13 +55,13 @@
    #define BOOST_CONTAINER_PP_PARAM_LIST(z, n, data) \
    const BOOST_PP_CAT(P, n) & BOOST_PP_CAT(p, n) \
    //!
-#endif   //#ifndef BOOST_NO_RVALUE_REFERENCES
+#endif   //#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
 
 #define BOOST_CONTAINER_PP_CONST_REF_PARAM_LIST_Q(z, n, Data) \
 const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \
 //!
 
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
    #define BOOST_CONTAINER_PP_PARAM(U, u) \
    U && u \
    //!
@@ -69,22 +69,22 @@ const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \
    #define BOOST_CONTAINER_PP_PARAM(U, u) \
    const U & u \
    //!
-#endif   //#ifndef BOOST_NO_RVALUE_REFERENCES
+#endif   //#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
 
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
 
    #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \
    BOOST_PP_CAT(m_p, n) (::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) ))           \
    //!
 
-#else //BOOST_NO_RVALUE_REFERENCES
+#else //BOOST_NO_CXX11_RVALUE_REFERENCES
 
    #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \
    BOOST_PP_CAT(m_p, n) (const_cast(BOOST_PP_CAT(p, n))) \
    //!
-#endif   //#ifndef BOOST_NO_RVALUE_REFERENCES
+#endif   //#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
 
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
 
    #if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
 
@@ -160,25 +160,25 @@ const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \
 
    #endif //defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
 
-#else //BOOST_NO_RVALUE_REFERENCES
+#else //BOOST_NO_CXX11_RVALUE_REFERENCES
 
    #define BOOST_CONTAINER_PP_PARAM_DEFINE(z, n, data)  \
    BOOST_PP_CAT(P, n) & BOOST_PP_CAT(m_p, n);             \
    //!
-#endif   //#ifndef BOOST_NO_RVALUE_REFERENCES
+#endif   //#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
 
-#if !defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
 
    #define BOOST_CONTAINER_PP_MEMBER_FORWARD(z, n, data) BOOST_PP_CAT(this->m_p, n).get() \
    //!
 
-#else //!defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
+#else //!defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
 
    #define BOOST_CONTAINER_PP_MEMBER_FORWARD(z, n, data) \
    ::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(this->m_p, n) ) \
    //!
 
-#endif   //!defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
+#endif   //!defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
 
 #define BOOST_CONTAINER_PP_PARAM_INC(z, n, data)   \
   BOOST_PP_CAT(++this->m_p, n)                     \
diff --git a/include/boost/container/detail/type_traits.hpp b/include/boost/container/detail/type_traits.hpp
index 0e096e5..c1de447 100644
--- a/include/boost/container/detail/type_traits.hpp
+++ b/include/boost/container/detail/type_traits.hpp
@@ -90,7 +90,7 @@ struct remove_reference
    typedef T type;
 };
 
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
 
 template
 struct remove_reference
diff --git a/include/boost/container/detail/workaround.hpp b/include/boost/container/detail/workaround.hpp
index 7838a5d..317bbb2 100644
--- a/include/boost/container/detail/workaround.hpp
+++ b/include/boost/container/detail/workaround.hpp
@@ -13,12 +13,12 @@
 
 #include 
 
-#if    !defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_NO_VARIADIC_TEMPLATES)\
+#if    !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)\
     && !defined(BOOST_INTERPROCESS_DISABLE_VARIADIC_TMPL)
    #define BOOST_CONTAINER_PERFECT_FORWARDING
 #endif
 
-#if defined(BOOST_NO_NOEXCEPT)
+#if defined(BOOST_NO_CXX11_NOEXCEPT)
    #define BOOST_CONTAINER_NOEXCEPT
    #define BOOST_CONTAINER_NOEXCEPT_IF(x)
 #else
@@ -26,7 +26,7 @@
    #define BOOST_CONTAINER_NOEXCEPT_IF(x) noexcept(x)
 #endif
 
-#if !defined(BOOST_NO_VARIADIC_TEMPLATES) && defined(__GXX_EXPERIMENTAL_CXX0X__)\
+#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && defined(__GXX_EXPERIMENTAL_CXX0X__)\
     && (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__ < 40700)
    #define BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST
 #endif
diff --git a/include/boost/container/scoped_allocator.hpp b/include/boost/container/scoped_allocator.hpp
index 5111d37..c49c3cf 100644
--- a/include/boost/container/scoped_allocator.hpp
+++ b/include/boost/container/scoped_allocator.hpp
@@ -259,7 +259,7 @@ namespace container_detail {
    //! Thanks Mathias!
 
    //With variadic templates, we need a single class to implement the trait
-   #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+   #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 
    template
    struct is_constructible_impl
@@ -290,7 +290,7 @@ namespace container_detail {
       : is_constructible
    {};
 
-   #else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+   #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 
    //Without variadic templates, we need to use de preprocessor to generate
    //some specializations.
@@ -382,14 +382,14 @@ namespace container_detail {
          >
    {};*/
 
-   #endif   // #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+   #endif   // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 
 #else    // #if !defined(BOOST_NO_SFINAE_EXPR)
 
    //Without advanced SFINAE expressions, we can't use is_constructible
    //so backup to constructible_with_allocator_xxx
 
-   #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+   #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 
    template < class T, class InnerAlloc, class ...Args>
    struct is_constructible_with_allocator_prefix
@@ -401,7 +401,7 @@ namespace container_detail {
       : constructible_with_allocator_suffix
    {};*/
 
-   #else    // #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+   #else    // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 
    template < class T
             , class InnerAlloc
@@ -423,11 +423,11 @@ namespace container_detail {
       : constructible_with_allocator_suffix
    {};*/
 
-   #endif   // #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+   #endif   // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 
 #endif   // #if !defined(BOOST_NO_SFINAE_EXPR)
 
-#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 
 template < typename OutermostAlloc
          , typename InnerAlloc
@@ -489,7 +489,7 @@ inline void dispatch_uses_allocator
       (outermost_alloc, p, ::boost::forward(args)...);
 }
 
-#else    //#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+#else    //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 
 #define BOOST_PP_LOCAL_MACRO(n)                                                              \
 template < typename OutermostAlloc                                                           \
@@ -564,9 +564,9 @@ inline void dispatch_uses_allocator(boost::false_type uses_allocator
 #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
 #include BOOST_PP_LOCAL_ITERATE()
 
-#endif   //#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+#endif   //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 
-#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 
 template 
 class scoped_allocator_adaptor_base
@@ -679,7 +679,7 @@ class scoped_allocator_adaptor_base
    inner_allocator_type m_inner;
 };
 
-#else //#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+#else //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 
 //Let's add a dummy first template parameter to allow creating
 //specializations up to maximum InnerAlloc count
@@ -829,13 +829,13 @@ class scoped_allocator_adaptor_base
 class scoped_allocator_adaptor_base
    < OuterAlloc
-   #if defined(BOOST_NO_VARIADIC_TEMPLATES)
+   #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
       , true
       BOOST_PP_ENUM_TRAILING(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, BOOST_CONTAINER_PP_IDENTITY, nat)
    #endif
@@ -850,7 +850,7 @@ class scoped_allocator_adaptor_base
    {
       typedef scoped_allocator_adaptor_base
          ::template portable_rebind_alloc::type
-         #if defined(BOOST_NO_VARIADIC_TEMPLATES)
+         #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
          , true
          BOOST_PP_ENUM_TRAILING(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, BOOST_CONTAINER_PP_IDENTITY, container_detail::nat)
          #endif
@@ -887,7 +887,7 @@ class scoped_allocator_adaptor_base
    scoped_allocator_adaptor_base
       (const scoped_allocator_adaptor_base<
          OuterA2
-         #if defined(BOOST_NO_VARIADIC_TEMPLATES)
+         #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
          , true
          BOOST_PP_ENUM_TRAILING(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, BOOST_CONTAINER_PP_IDENTITY, container_detail::nat)
          #endif
@@ -899,7 +899,7 @@ class scoped_allocator_adaptor_base
    scoped_allocator_adaptor_base
       (BOOST_RV_REF_BEG scoped_allocator_adaptor_base<
          OuterA2
-         #if defined(BOOST_NO_VARIADIC_TEMPLATES)
+         #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
          , true
          BOOST_PP_ENUM_TRAILING(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, BOOST_CONTAINER_PP_IDENTITY, container_detail::nat)
          #endif
@@ -946,7 +946,7 @@ class scoped_allocator_adaptor_base
 ///@endcond
 
 //Scoped allocator
-#if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
    #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
 
@@ -992,7 +992,7 @@ class scoped_allocator_adaptor_base
 
    #endif   // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
 
-#else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+#else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
 template ::type
-         #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+         #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
          , InnerAllocs...
          #else
          BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, Q)
@@ -1086,7 +1086,7 @@ class scoped_allocator_adaptor
       : base_type(::boost::move(other.base()))
       {}
 
-   #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
    //! Requires: OuterAlloc shall be constructible from OuterA2.
    //!
@@ -1097,7 +1097,7 @@ class scoped_allocator_adaptor
    scoped_allocator_adaptor(BOOST_FWD_REF(OuterA2) outerAlloc, const InnerAllocs & ...innerAllocs)
       : base_type(::boost::forward(outerAlloc), innerAllocs...)
       {}
-   #else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
    #define BOOST_PP_LOCAL_MACRO(n)                                                              \
    template                                                                      \
@@ -1111,14 +1111,14 @@ class scoped_allocator_adaptor
    #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
    #include BOOST_PP_LOCAL_ITERATE()
 
-   #endif   // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   #endif   // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
    //! Requires: OuterAlloc shall be constructible from OuterA2.
    //!
    //! Effects: initializes each allocator within the adaptor with the corresponding allocator from other.
    template 
    scoped_allocator_adaptor(const scoped_allocator_adaptor
    scoped_allocator_adaptor(BOOST_RV_REF_BEG scoped_allocator_adaptorEffects:
    //! 1) If `uses_allocator::value` is false calls
@@ -1274,7 +1274,7 @@ class scoped_allocator_adaptor
          , p, ::boost::forward(args)...);
    }
 
-   #else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
    //Disable this overload if the first argument is pair as some compilers have
    //overload selection problems when the first parameter is a pair.
@@ -1295,7 +1295,7 @@ class scoped_allocator_adaptor
    #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
    #include BOOST_PP_LOCAL_ITERATE()
 
-   #endif   // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   #endif   // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
    template 
    void construct(std::pair* p)
@@ -1399,7 +1399,7 @@ class scoped_allocator_adaptor
 };
 
 template 
 inline bool operator==(
    const scoped_allocator_adaptor& a,
    const scoped_allocator_adaptor& b)
 {
-   #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)  
+   #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)  
    const bool has_zero_inner = sizeof...(InnerAllocs) == 0u;
    #else
    const bool has_zero_inner =
@@ -1434,7 +1434,7 @@ inline bool operator==(
 }
 
 template 
 inline bool operator!=(
    const scoped_allocator_adaptor& a,
    const scoped_allocator_adaptor
 #include 
 
-#if defined(BOOST_NO_VARIADIC_TEMPLATES)
+#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 #include 
 #include 
 #endif
@@ -27,7 +27,7 @@ namespace boost { namespace container {
 
 ///@cond
 
-#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 
    #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
 
@@ -45,7 +45,7 @@ namespace boost { namespace container {
    #endif   // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
 
 
-#else    // #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+#else    // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 
 template 
Date: Tue, 20 Nov 2012 23:10:46 +0000
Subject: [PATCH 60/93] Sigh. Missed one file when updating Boost.Container to
 use new macro scheme

[SVN r81448]
---
 include/boost/container/allocator_traits.hpp | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/boost/container/allocator_traits.hpp b/include/boost/container/allocator_traits.hpp
index b1c4e5e..c8bf708 100644
--- a/include/boost/container/allocator_traits.hpp
+++ b/include/boost/container/allocator_traits.hpp
@@ -175,12 +175,12 @@ struct allocator_traits
          struct rebind_alloc : boost::intrusive::detail::type_rebinder::type
          {
             typedef typename boost::intrusive::detail::type_rebinder::type Base;
-            #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+            #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
             template 
             rebind_alloc(BOOST_FWD_REF(Args)... args)
                : Base(boost::forward(args)...)
             {}
-            #else    // #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+            #else    // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
             #define BOOST_PP_LOCAL_MACRO(n)                                                        \
             BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
             rebind_alloc(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                       \
@@ -189,7 +189,7 @@ struct allocator_traits
             //
             #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
             #include BOOST_PP_LOCAL_ITERATE()
-            #endif   // #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+            #endif   // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
          };
 
          template 
@@ -259,7 +259,7 @@ struct allocator_traits
       return allocator_traits::priv_select_on_container_copy_construction(flag, a);
    }
 
-   #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+   #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
       //! Effects: calls `a.construct(p, std::forward(args)...)` if that call is well-formed;
       //! otherwise, invokes `::new (static_cast(p)) T(std::forward(args)...)`
       template 
@@ -298,7 +298,7 @@ struct allocator_traits
       static Alloc priv_select_on_container_copy_construction(boost::false_type, const Alloc &a)
       {  return a;  }
 
-      #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+      #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
          template
          static void priv_construct(boost::false_type, Alloc &a, T *p, BOOST_FWD_REF(Args) ...args)                   
          {                                                                                                 
@@ -322,7 +322,7 @@ struct allocator_traits
          template
          static void priv_construct_dispatch2(boost::false_type, Alloc &, T *p, BOOST_FWD_REF(Args) ...args)
          {  ::new((void*)p) T(::boost::forward(args)...); }
-      #else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+      #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
          public:
          #define BOOST_PP_LOCAL_MACRO(n)                                                              \
          template                                 \
@@ -371,7 +371,7 @@ struct allocator_traits
          //
          #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
          #include BOOST_PP_LOCAL_ITERATE()
-      #endif   // #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+      #endif   // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
    #endif   //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
    ///@endcond

From bc5c91bb79e931745e43dcf5fa28531660947cd4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Sat, 24 Nov 2012 21:08:18 +0000
Subject: [PATCH 61/93] *  Improved `vector`'s insertion performance. * 
 Changed again experimental multiallocation interface for better performance
 (still experimental). *  Added no exception support for those willing to
 disable exceptions in their compilers. *  Fixed GCC -Wshadow warnings. * 
 Replaced deprecated BOOST_NO_XXXX with newer BOOST_NO_CXX11_XXX macros.

[SVN r81518]
---
 include/boost/container/allocator_traits.hpp  |   2 +-
 include/boost/container/deque.hpp             | 261 +++----
 .../detail/adaptive_node_pool_impl.hpp        | 726 ++++++++++++------
 .../container/detail/advanced_insert_int.hpp  | 505 +++++-------
 .../detail/allocator_version_traits.hpp       | 163 ++++
 include/boost/container/detail/destroyers.hpp |  11 +-
 include/boost/container/detail/flat_tree.hpp  |  72 +-
 include/boost/container/detail/iterators.hpp  |   2 +-
 .../detail/multiallocation_chain.hpp          | 132 ++--
 .../container/detail/node_alloc_holder.hpp    | 101 +--
 .../boost/container/detail/node_pool_impl.hpp |  32 +-
 include/boost/container/detail/pair.hpp       |   2 +-
 .../boost/container/detail/pool_common.hpp    |   2 +-
 .../boost/container/detail/preprocessor.hpp   |  16 +-
 include/boost/container/detail/tree.hpp       |  19 +-
 .../boost/container/detail/type_traits.hpp    |   2 +-
 include/boost/container/detail/utilities.hpp  | 369 ++++++++-
 include/boost/container/detail/workaround.hpp |   8 +-
 include/boost/container/flat_map.hpp          | 108 +--
 include/boost/container/flat_set.hpp          | 106 +--
 include/boost/container/list.hpp              | 177 ++---
 include/boost/container/map.hpp               | 108 +--
 include/boost/container/scoped_allocator.hpp  |  32 +-
 include/boost/container/set.hpp               |  22 +-
 include/boost/container/slist.hpp             | 172 ++---
 include/boost/container/stable_vector.hpp     | 253 +++---
 include/boost/container/string.hpp            | 513 ++++++-------
 include/boost/container/vector.hpp            | 425 +++++-----
 28 files changed, 2449 insertions(+), 1892 deletions(-)
 create mode 100644 include/boost/container/detail/allocator_version_traits.hpp

diff --git a/include/boost/container/allocator_traits.hpp b/include/boost/container/allocator_traits.hpp
index c8bf708..828d664 100644
--- a/include/boost/container/allocator_traits.hpp
+++ b/include/boost/container/allocator_traits.hpp
@@ -28,7 +28,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include  //numeric_limits<>::max()
 #include     //placement new
 #include  //std::allocator
diff --git a/include/boost/container/deque.hpp b/include/boost/container/deque.hpp
index b63dab3..32fa480 100644
--- a/include/boost/container/deque.hpp
+++ b/include/boost/container/deque.hpp
@@ -58,9 +58,11 @@
 #include 
 #include 
 #include 
-#include 
-#include 
+#include 
+#include 
+#include 
 #include 
+#include 
 
 namespace boost {
 namespace container {
@@ -79,8 +81,7 @@ struct deque_value_traits
    typedef T value_type;
    typedef Allocator allocator_type;
    static const bool trivial_dctr = boost::has_trivial_destructor::value;
-   static const bool trivial_dctr_after_move = false;
-      //::boost::has_trivial_destructor_after_move::value || trivial_dctr;
+   static const bool trivial_dctr_after_move = ::boost::has_trivial_destructor_after_move::value;
    static const bool trivial_copy = has_trivial_copy::value;
    static const bool nothrow_copy = has_nothrow_copy::value;
    static const bool trivial_assign = has_trivial_assign::value;
@@ -304,7 +305,7 @@ class deque_base
       {
          this->m_node = new_node;
          this->m_first = *new_node;
-         this->m_last = this->m_first + difference_type(this->s_buffer_size());
+         this->m_last = this->m_first + this->s_buffer_size();
       }
 
       friend const_iterator operator+(difference_type n, const const_iterator& x)
@@ -565,9 +566,6 @@ class deque : protected deque_base
    typedef typename Base::ptr_alloc_ptr index_pointer;
    static size_type s_buffer_size()
       { return Base::s_buffer_size(); }
-   typedef container_detail::advanced_insert_aux_int advanced_insert_aux_int_t;
-   typedef repeat_iterator  r_iterator;
-   typedef boost::move_iterator     move_it;
    typedef allocator_traits                  allocator_traits_type;
 
    /// @endcond
@@ -590,10 +588,10 @@ class deque : protected deque_base
 
    //! Effects: Constructs a deque taking the allocator as parameter.
    //!
-   //! Throws: If allocator_type's copy constructor throws.
+   //! Throws: Nothing
    //!
    //! Complexity: Constant.
-   explicit deque(const allocator_type& a)
+   explicit deque(const allocator_type& a) BOOST_CONTAINER_NOEXCEPT
       : Base(a)
    {}
 
@@ -607,8 +605,8 @@ class deque : protected deque_base
    explicit deque(size_type n)
       : Base(n, allocator_type())
    {
-      container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
-      proxy.uninitialized_copy_remaining_to(this->begin());
+      container_detail::insert_default_constructed_n_proxy proxy(this->alloc());
+      proxy.uninitialized_copy_n_and_update(this->begin(), n);
       //deque_base will deallocate in case of exception...
    }
 
@@ -717,7 +715,7 @@ class deque : protected deque_base
    //! Complexity: Linear to the number of elements.
    ~deque() BOOST_CONTAINER_NOEXCEPT
    {
-      priv_destroy_range(this->members_.m_start, this->members_.m_finish);
+      this->priv_destroy_range(this->members_.m_start, this->members_.m_finish);
    }
 
    //! Effects: Makes *this contain the same elements as x.
@@ -1020,7 +1018,7 @@ class deque : protected deque_base
          this->priv_erase_last_n(len - new_size);
       else{
          const size_type n = new_size - this->size();
-         container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
+         container_detail::insert_default_constructed_n_proxy proxy(this->alloc());
          priv_insert_back_aux_impl(n, proxy);
       }
    }
@@ -1176,9 +1174,8 @@ class deque : protected deque_base
          this->priv_push_front_simple_commit();
       }
       else{
-         typedef container_detail::advanced_insert_aux_non_movable_emplace type;
-         type &&proxy = type(this->alloc(), boost::forward(args)...);
-         this->priv_insert_front_aux_impl(1, proxy);
+         typedef container_detail::insert_non_movable_emplace_proxy type;
+         this->priv_insert_front_aux_impl(1, type(this->alloc(), boost::forward(args)...));
       }
    }
 
@@ -1199,9 +1196,8 @@ class deque : protected deque_base
          this->priv_push_back_simple_commit();
       }
       else{
-         typedef container_detail::advanced_insert_aux_non_movable_emplace type;
-         type &&proxy = type(this->alloc(), boost::forward(args)...);
-         this->priv_insert_back_aux_impl(1, proxy);
+         typedef container_detail::insert_non_movable_emplace_proxy type;
+         this->priv_insert_back_aux_impl(1, type(this->alloc(), boost::forward(args)...));
       }
    }
 
@@ -1226,9 +1222,8 @@ class deque : protected deque_base
          return (this->end()-1);
       }
       else{
-         typedef container_detail::advanced_insert_aux_emplace type;
-         type &&proxy = type(this->alloc(), boost::forward(args)...);
-         return this->priv_insert_aux_impl(p, 1, proxy);
+         typedef container_detail::insert_emplace_proxy type;
+         return this->priv_insert_aux_impl(p, 1, type(this->alloc(), boost::forward(args)...));
       }
    }
 
@@ -1247,9 +1242,8 @@ class deque : protected deque_base
          priv_push_front_simple_commit();                                                    \
       }                                                                                      \
       else{                                                                                  \
-         container_detail::BOOST_PP_CAT(BOOST_PP_CAT                                         \
-            (advanced_insert_aux_non_movable_emplace, n), arg)                               \
-                proxy                       \
+         container_detail::BOOST_PP_CAT(insert_non_movable_emplace_proxy_arg, n)             \
+                proxy               \
             (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));  \
          priv_insert_front_aux_impl(1, proxy);                                               \
       }                                                                                      \
@@ -1266,9 +1260,8 @@ class deque : protected deque_base
          priv_push_back_simple_commit();                                                     \
       }                                                                                      \
       else{                                                                                  \
-         container_detail::BOOST_PP_CAT(BOOST_PP_CAT(                                        \
-            advanced_insert_aux_non_movable_emplace, n), arg)                                \
-                proxy                       \
+         container_detail::BOOST_PP_CAT(insert_non_movable_emplace_proxy_arg, n)             \
+                proxy               \
             (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));  \
          priv_insert_back_aux_impl(1, proxy);                                                \
       }                                                                                      \
@@ -1287,8 +1280,8 @@ class deque : protected deque_base
          return (this->end()-1);                                                             \
       }                                                                                      \
       else{                                                                                  \
-         container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)   \
-             proxy                          \
+         container_detail::BOOST_PP_CAT(insert_emplace_proxy_arg, n)                         \
+             proxy                  \
             (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));  \
          return this->priv_insert_aux_impl(p, 1, proxy);                                     \
       }                                                                                      \
@@ -1424,7 +1417,7 @@ class deque : protected deque_base
       #endif
       )
    {
-      container_detail::advanced_insert_aux_proxy proxy(this->alloc(), first, last);
+      container_detail::insert_range_proxy proxy(this->alloc(), first);
       return priv_insert_aux_impl(p, (size_type)std::distance(first, last), proxy);
    }
    #endif
@@ -1477,8 +1470,8 @@ class deque : protected deque_base
    {
       const_iterator next = pos;
       ++next;
-      difference_type index = pos - this->members_.m_start;
-      if (size_type(index) < (this->size() >> 1)) {
+      size_type index = pos - this->members_.m_start;
+      if (index < (this->size()/2)) {
          boost::move_backward(begin(), iterator(pos), iterator(next));
          pop_front();
       }
@@ -1504,9 +1497,9 @@ class deque : protected deque_base
          return this->members_.m_finish;
       }
       else {
-         difference_type n = last - first;
-         difference_type elems_before = first - this->members_.m_start;
-         if (elems_before < static_cast(this->size() - n) - elems_before) {
+         const size_type n = static_cast(last - first);
+         const size_type elems_before = static_cast(first - this->members_.m_start);
+         if (elems_before < (this->size() - n) - elems_before) {
             boost::move_backward(begin(), iterator(first), iterator(last));
             iterator new_start = this->members_.m_start + n;
             if(!Base::traits_t::trivial_dctr_after_move)
@@ -1584,81 +1577,49 @@ class deque : protected deque_base
    void priv_range_check(size_type n) const
       {  if (n >= this->size())  BOOST_RETHROW std::out_of_range("deque");   }
 
-   iterator priv_insert(const_iterator position, const value_type &x)
+   template 
+   iterator priv_insert(const_iterator position, BOOST_FWD_REF(U) x)
    {
       if (position == cbegin()){
-         this->push_front(x);
+         this->push_front(::boost::forward(x));
          return begin();
       }
       else if (position == cend()){
-         this->push_back(x);
-         return (end()-1);
+         this->push_back(::boost::forward(x));
+         return --end();
       }
       else {
-         return this->insert(position, size_type(1), x);
+         return priv_insert_aux_impl
+            (position, (size_type)1, container_detail::get_insert_value_proxy(this->alloc(), ::boost::forward(x)));
       }
    }
 
-   iterator priv_insert(const_iterator position, BOOST_RV_REF(value_type) mx)
-   {
-      if (position == cbegin()) {
-         this->push_front(boost::move(mx));
-         return begin();
-      }
-      else if (position == cend()) {
-         this->push_back(boost::move(mx));
-         return(end()-1);
-      }
-      else {
-         return this->insert(position, move_it(r_iterator(mx, 1)), move_it(r_iterator()));
-      }
-   }
-
-   void priv_push_front(const value_type &t)
+   template 
+   void priv_push_front(BOOST_FWD_REF(U) x)
    {
       if(this->priv_push_front_simple_available()){
          allocator_traits_type::construct
-            ( this->alloc(), this->priv_push_front_simple_pos(), t);
+            ( this->alloc(), this->priv_push_front_simple_pos(), ::boost::forward(x));
          this->priv_push_front_simple_commit();
       }
       else{
-         this->insert(cbegin(), size_type(1), t);
+         priv_insert_aux_impl
+            (this->cbegin(), (size_type)1, container_detail::get_insert_value_proxy(this->alloc(), ::boost::forward(x)));
       }
    }
 
-   void priv_push_front(BOOST_RV_REF(value_type) t)
-   {
-      if(this->priv_push_front_simple_available()){
-         allocator_traits_type::construct
-            ( this->alloc(), this->priv_push_front_simple_pos(), boost::move(t));
-         this->priv_push_front_simple_commit();
-      }
-      else{
-         this->insert(cbegin(), move_it(r_iterator(t, 1)), move_it(r_iterator()));
-      }
-   }
-
-   void priv_push_back(const value_type &t)
+   template 
+   void priv_push_back(BOOST_FWD_REF(U) x)
    {
       if(this->priv_push_back_simple_available()){
          allocator_traits_type::construct
-            ( this->alloc(), this->priv_push_back_simple_pos(), t);
+            ( this->alloc(), this->priv_push_back_simple_pos(), ::boost::forward(x));
          this->priv_push_back_simple_commit();
       }
       else{
-         this->insert(cend(), size_type(1), t);
-      }
-   }
-
-   void priv_push_back(BOOST_RV_REF(T) t)
-   {
-      if(this->priv_push_back_simple_available()){
-         allocator_traits_type::construct
-            ( this->alloc(), this->priv_push_back_simple_pos(), boost::move(t));
-         this->priv_push_back_simple_commit();
-      }
-      else{
-         this->insert(cend(), move_it(r_iterator(t, 1)), move_it(r_iterator()));
+         priv_insert_aux_impl
+            (this->cend(), (size_type)1, container_detail::get_insert_value_proxy(this->alloc(), ::boost::forward(x)));
+         container_detail::insert_copy_proxy proxy(this->alloc(), x);
       }
    }
 
@@ -1710,7 +1671,8 @@ class deque : protected deque_base
       }
    }
 
-   iterator priv_insert_aux_impl(const_iterator p, size_type n, advanced_insert_aux_int_t &interf)
+   template
+   iterator priv_insert_aux_impl(const_iterator p, size_type n, InsertProxy interf)
    {
       iterator pos(p);
       const size_type pos_n = p - this->cbegin();
@@ -1719,58 +1681,85 @@ class deque : protected deque_base
          pos = this->begin();
       }
 
-      const difference_type elemsbefore = pos - this->members_.m_start;
-      size_type length = this->size();
-      if (elemsbefore < static_cast(length / 2)) {
-         iterator new_start = this->priv_reserve_elements_at_front(n);
-         iterator old_start = this->members_.m_start;
-         pos = this->members_.m_start + elemsbefore;
-         if (elemsbefore >= difference_type(n)) {
-            iterator start_n = this->members_.m_start + difference_type(n);
-            ::boost::container::uninitialized_move_alloc
-               (this->alloc(), this->members_.m_start, start_n, new_start);
+      const size_type elemsbefore = static_cast(pos - this->members_.m_start);
+      const size_type length = this->size();
+      if (elemsbefore < length / 2) {
+         const iterator new_start = this->priv_reserve_elements_at_front(n);
+         const iterator old_start = this->members_.m_start;
+         if(!elemsbefore){
+            interf.uninitialized_copy_n_and_update(new_start, n);
             this->members_.m_start = new_start;
-            boost::move(start_n, pos, old_start);
-            interf.copy_remaining_to(pos - difference_type(n));
          }
-         else {
-            difference_type mid_count = (difference_type(n) - elemsbefore);
-            iterator mid_start = old_start - mid_count;
-            interf.uninitialized_copy_some_and_update(mid_start, mid_count, true);
-            this->members_.m_start = mid_start;
-            ::boost::container::uninitialized_move_alloc
-               (this->alloc(), old_start, pos, new_start);
-            this->members_.m_start = new_start;
-            interf.copy_remaining_to(old_start);
+         else{
+            pos = this->members_.m_start + elemsbefore;
+            if (elemsbefore >= n) {
+               const iterator start_n = this->members_.m_start + n;
+               ::boost::container::uninitialized_move_alloc
+                  (this->alloc(), this->members_.m_start, start_n, new_start);
+               this->members_.m_start = new_start;
+               boost::move(start_n, pos, old_start);
+               interf.copy_n_and_update(pos - n, n);
+            }
+            else {
+               const size_type mid_count = n - elemsbefore;
+               const iterator mid_start = old_start - mid_count;
+               interf.uninitialized_copy_n_and_update(mid_start, mid_count);
+               this->members_.m_start = mid_start;
+               ::boost::container::uninitialized_move_alloc
+                  (this->alloc(), old_start, pos, new_start);
+               this->members_.m_start = new_start;
+               interf.copy_n_and_update(old_start, elemsbefore);
+            }
          }
       }
       else {
-         iterator new_finish = this->priv_reserve_elements_at_back(n);
-         iterator old_finish = this->members_.m_finish;
-         const difference_type elemsafter =
-            difference_type(length) - elemsbefore;
-         pos = this->members_.m_finish - elemsafter;
-         if (elemsafter >= difference_type(n)) {
-            iterator finish_n = this->members_.m_finish - difference_type(n);
-            ::boost::container::uninitialized_move_alloc
-               (this->alloc(), finish_n, this->members_.m_finish, this->members_.m_finish);
+         const iterator new_finish = this->priv_reserve_elements_at_back(n);
+         const iterator old_finish = this->members_.m_finish;
+         const size_type elemsafter = length - elemsbefore;
+         if(!elemsafter){
+            interf.uninitialized_copy_n_and_update(old_finish, n);
             this->members_.m_finish = new_finish;
-            boost::move_backward(pos, finish_n, old_finish);
-            interf.copy_remaining_to(pos);
          }
-         else {
-            interf.uninitialized_copy_some_and_update(old_finish, elemsafter, false);
-            this->members_.m_finish += n-elemsafter;
-            ::boost::container::uninitialized_move_alloc
-               (this->alloc(), pos, old_finish, this->members_.m_finish);
-            this->members_.m_finish = new_finish;
-            interf.copy_remaining_to(pos);
+         else{
+            pos = this->members_.m_finish - elemsafter;
+            if (elemsafter >= n) {
+               iterator finish_n = this->members_.m_finish - difference_type(n);
+               ::boost::container::uninitialized_move_alloc
+                  (this->alloc(), finish_n, this->members_.m_finish, this->members_.m_finish);
+               this->members_.m_finish = new_finish;
+               boost::move_backward(pos, finish_n, old_finish);
+               interf.copy_n_and_update(pos, n);
+            }
+            else {
+               const size_type raw_gap = n - elemsafter;
+               ::boost::container::uninitialized_move_alloc
+                  (this->alloc(), pos, old_finish, this->members_.m_finish + raw_gap);
+               BOOST_TRY{
+                  interf.uninitialized_copy_n_and_update(old_finish, raw_gap);
+               }
+               BOOST_CATCH(...){
+                  this->priv_destroy_range(this->members_.m_finish, this->members_.m_finish + (old_finish - pos));
+                  BOOST_RETHROW
+               }
+               BOOST_CATCH_END
+               this->members_.m_finish = new_finish;
+               interf.copy_n_and_update(pos, elemsafter);
+   /*
+               interf.uninitialized_copy_some_and_update(old_finish, elemsafter, false);
+               this->members_.m_finish += n-elemsafter;
+               ::boost::container::uninitialized_move_alloc
+                  (this->alloc(), pos, old_finish, this->members_.m_finish);
+               this->members_.m_finish = new_finish;
+               interf.copy_remaining_to(pos);
+   */
+            }
          }
       }
       return this->begin() + pos_n;
    }
 
-   iterator priv_insert_back_aux_impl(size_type n, advanced_insert_aux_int_t &interf)
+   template 
+   iterator priv_insert_back_aux_impl(size_type n, InsertProxy interf)
    {
       if(!this->members_.m_map){
          this->priv_initialize_map(0);
@@ -1778,19 +1767,20 @@ class deque : protected deque_base
 
       iterator new_finish = this->priv_reserve_elements_at_back(n);
       iterator old_finish = this->members_.m_finish;
-      interf.uninitialized_copy_some_and_update(old_finish, n, true);
+      interf.uninitialized_copy_n_and_update(old_finish, n);
       this->members_.m_finish = new_finish;
       return iterator(this->members_.m_finish - n);
    }
 
-   iterator priv_insert_front_aux_impl(size_type n, advanced_insert_aux_int_t &interf)
+   template 
+   iterator priv_insert_front_aux_impl(size_type n, InsertProxy interf)
    {
       if(!this->members_.m_map){
          this->priv_initialize_map(0);
       }
 
       iterator new_start = this->priv_reserve_elements_at_front(n);
-      interf.uninitialized_copy_some_and_update(new_start, difference_type(n), true);
+      interf.uninitialized_copy_n_and_update(new_start, n);
       this->members_.m_start = new_start;
       return new_start;
    }
@@ -2015,15 +2005,14 @@ inline void swap(deque& x, deque& y)
 /// @cond
 
 namespace boost {
-/*
+
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
 template 
 struct has_trivial_destructor_after_move >
-{
-   enum {   value = has_trivial_destructor::value  };
-};
-*/
+   : public ::boost::has_trivial_destructor_after_move
+{};
+
 }
 
 /// @endcond
diff --git a/include/boost/container/detail/adaptive_node_pool_impl.hpp b/include/boost/container/detail/adaptive_node_pool_impl.hpp
index 39b9942..42bdf43 100644
--- a/include/boost/container/detail/adaptive_node_pool_impl.hpp
+++ b/include/boost/container/detail/adaptive_node_pool_impl.hpp
@@ -21,16 +21,28 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 namespace boost {
 namespace container {
+
+namespace adaptive_pool_flag {
+
+static const unsigned int none            = 0u;
+static const unsigned int align_only      = 1u << 0u;
+static const unsigned int size_ordered    = 1u << 1u;
+static const unsigned int address_ordered = 1u << 2u;
+
+}  //namespace adaptive_pool_flag{
+
 namespace container_detail {
 
 template
@@ -42,42 +54,160 @@ struct hdr_offset_holder_t
    size_type hdr_offset;
 };
 
+template
+struct less_func;
+
+template
+struct less_func
+{
+   static bool less(SizeType, SizeType, const void *, const void *)
+   {  return true;   }
+};
+
+template
+struct less_func
+{
+   static bool less(SizeType ls, SizeType rs, const void *, const void *)
+   {  return ls < rs;   }
+};
+
+template
+struct less_func
+{
+   static bool less(SizeType, SizeType, const void *la, const void *ra)
+   {  return &la < &ra;   }
+};
+
+template
+struct less_func
+{
+   static bool less(SizeType ls, SizeType rs, const void *la, const void *ra)
+   {  return (ls < rs) || ((ls == rs) && (la < ra));  }
+};
+
+template
+struct block_container_traits
+{
+   typedef typename bi::make_set_base_hook
+      < bi::void_pointer
+      , bi::optimize_size
+      , bi::link_mode >::type hook_t;
+
+   template
+   struct container
+   {
+      typedef typename bi::make_multiset
+         , bi::size_type >::type  type;
+   };
+
+   template
+   static void reinsert_was_used(Container &container, typename Container::reference v, bool)
+   {
+      typedef typename Container::const_iterator const_block_iterator;
+      const const_block_iterator this_block
+         (Container::s_iterator_to(const_cast(v)));
+      const_block_iterator next_block(this_block);
+      if(++next_block != container.cend()){
+         if(this_block->free_nodes.size() > next_block->free_nodes.size()){
+            container.erase(this_block);
+            container.insert(v);
+         }
+      }
+   }
+
+   template
+   static void insert_was_empty(Container &container, typename Container::value_type &v, bool)
+   {
+      container.insert(v);
+   }
+
+   template
+   static void erase_first(Container &container)
+   {
+      container.erase(container.cbegin());
+   }
+
+   template
+   static void erase_last(Container &container)
+   {
+      container.erase(--container.cend());
+   }
+};
+
 template
+struct block_container_traits
+{
+   typedef typename bi::make_list_base_hook
+      < bi::void_pointer
+      , bi::link_mode >::type hook_t;
+
+   template
+   struct container
+   {
+      typedef typename bi::make_list
+         , bi::size_type, bi::constant_time_size >::type  type;
+   };
+
+   template
+   static void reinsert_was_used(Container &container, typename Container::value_type &v, bool is_full)
+   {
+      if(is_full){
+         container.erase(Container::s_iterator_to(v));
+         container.push_back(v);
+      }
+   }
+
+   template
+   static void insert_was_empty(Container &container, typename Container::value_type &v, bool is_full)
+   {
+      if(is_full){
+         container.push_back(v);
+      }
+      else{
+         container.push_front(v);
+      }
+   }
+
+   template
+   static void erase_first(Container &container)
+   {
+      container.pop_front();
+   }
+
+   template
+   static void erase_last(Container &container)
+   {
+      container.pop_back();
+   }
+};
+
+template
 struct adaptive_pool_types
 {
    typedef VoidPointer void_pointer;
-   typedef typename bi::make_set_base_hook
-      < bi::void_pointer
-      , bi::optimize_size
-      , bi::constant_time_size
-      , bi::link_mode >::type multiset_hook_t;
-  
+   static const bool ordered = (Flags & (adaptive_pool_flag::size_ordered | adaptive_pool_flag::address_ordered)) != 0;
+   typedef block_container_traits block_container_traits_t;
+   typedef typename block_container_traits_t::hook_t hook_t;
    typedef hdr_offset_holder_t hdr_offset_holder;
+   static const unsigned int order_flags = Flags & (adaptive_pool_flag::size_ordered | adaptive_pool_flag::address_ordered);
+   typedef MultiallocationChain free_nodes_t;
 
    struct block_info_t
-      : 
-         public hdr_offset_holder,
-         public multiset_hook_t
+      : public hdr_offset_holder,
+        public hook_t
    {
-      typedef typename node_slist::node_slist_t free_nodes_t;
       //An intrusive list of free node from this block
       free_nodes_t free_nodes;
       friend bool operator <(const block_info_t &l, const block_info_t &r)
       {
-//      {  return l.free_nodes.size() < r.free_nodes.size();   }
-         //Let's order blocks first by free nodes and then by address
-         //so that highest address fully free blocks are deallocated.
-         //This improves returning memory to the OS (trimming).
-         const bool is_less  = l.free_nodes.size() < r.free_nodes.size();
-         const bool is_equal = l.free_nodes.size() == r.free_nodes.size();
-         return is_less || (is_equal && (&l < &r));
+         return less_func::
+            less(l.free_nodes.size(), r.free_nodes.size(), &l , &r);
       }
 
       friend bool operator ==(const block_info_t &l, const block_info_t &r)
       {  return &l == &r;  }
    };
-   typedef typename bi::make_multiset
-       >::type  block_multiset_t;
+   typedef typename block_container_traits_t:: template container::type  block_container_t;
 };
 
 template
@@ -113,9 +243,9 @@ inline void calculate_num_subblocks
    , size_type &num_subblocks, size_type &real_num_node, size_type overhead_percent
    , size_type hdr_size, size_type hdr_offset_size, size_type payload_per_allocation)
 {
+   const size_type hdr_subblock_elements = (alignment - hdr_size - payload_per_allocation)/real_node_size;
    size_type elements_per_subblock = (alignment - hdr_offset_size)/real_node_size;
    size_type possible_num_subblock = (elements_per_block - 1)/elements_per_subblock + 1;
-   size_type hdr_subblock_elements = (alignment - hdr_size - payload_per_allocation)/real_node_size;
    while(((possible_num_subblock-1)*elements_per_subblock + hdr_subblock_elements) < elements_per_block){
       ++possible_num_subblock;
    }
@@ -135,7 +265,7 @@ inline void calculate_num_subblocks
    real_num_node = (possible_num_subblock-1)*elements_per_subblock + hdr_subblock_elements;
 }
 
-template
+template
 class private_adaptive_node_pool_impl
 {
    //Non-copyable
@@ -147,27 +277,42 @@ class private_adaptive_node_pool_impl
    typedef typename SegmentManagerBase::void_pointer void_pointer;
    static const typename SegmentManagerBase::
       size_type PayloadPerAllocation = SegmentManagerBase::PayloadPerAllocation;
+   //Flags
+   //align_only
+   static const bool AlignOnly      = (Flags & adaptive_pool_flag::align_only) != 0;
    typedef bool_            IsAlignOnly;
    typedef true_                       AlignOnlyTrue;
    typedef false_                      AlignOnlyFalse;
+   //size_ordered
+   static const bool SizeOrdered    = (Flags & adaptive_pool_flag::size_ordered) != 0;
+   typedef bool_          IsSizeOrdered;
+   typedef true_                       SizeOrderedTrue;
+   typedef false_                      SizeOrderedFalse;
+   //address_ordered
+   static const bool AddressOrdered = (Flags & adaptive_pool_flag::address_ordered) != 0;
+   typedef bool_       IsAddressOrdered;
+   typedef true_                       AddressOrderedTrue;
+   typedef false_                      AddressOrderedFalse;
 
    public:
-   typedef typename node_slist::node_t node_t;
-   typedef typename node_slist::node_slist_t free_nodes_t;
-   typedef typename SegmentManagerBase::multiallocation_chain     multiallocation_chain;
-   typedef typename SegmentManagerBase::size_type                 size_type;
+   typedef typename SegmentManagerBase::multiallocation_chain        multiallocation_chain;
+   typedef typename SegmentManagerBase::size_type                    size_type;
 
    private:
-   typedef typename adaptive_pool_types::block_info_t      block_info_t;
-   typedef typename adaptive_pool_types::block_multiset_t  block_multiset_t;
-   typedef typename block_multiset_t::iterator                                      block_iterator;
-   typedef typename adaptive_pool_types::hdr_offset_holder hdr_offset_holder;
+   typedef adaptive_pool_types
+              adaptive_pool_types_t;
+   typedef typename adaptive_pool_types_t::free_nodes_t              free_nodes_t;
+   typedef typename adaptive_pool_types_t::block_info_t              block_info_t;
+   typedef typename adaptive_pool_types_t::block_container_t         block_container_t;
+   typedef typename adaptive_pool_types_t::block_container_traits_t  block_container_traits_t;
+   typedef typename block_container_t::iterator                      block_iterator;
+   typedef typename block_container_t::const_iterator                const_block_iterator;
+   typedef typename adaptive_pool_types_t::hdr_offset_holder         hdr_offset_holder;
 
-   static const size_type MaxAlign = alignment_of::value;
+   static const size_type MaxAlign = alignment_of::value;
    static const size_type HdrSize  = ((sizeof(block_info_t)-1)/MaxAlign+1)*MaxAlign;
    static const size_type HdrOffsetSize = ((sizeof(hdr_offset_holder)-1)/MaxAlign+1)*MaxAlign;
 
-
    public:
    //!Segment manager typedef
    typedef SegmentManagerBase                 segment_manager_base_type;
@@ -181,7 +326,7 @@ class private_adaptive_node_pool_impl
       , unsigned char overhead_percent
       )
    :  m_max_free_blocks(max_free_blocks)
-   ,  m_real_node_size(lcm(node_size, size_type(alignment_of::value)))
+   ,  m_real_node_size(lcm(node_size, size_type(alignment_of::value)))
       //Round the size to a power of two value.
       //This is the total memory size (including payload) that we want to
       //allocate from the general-purpose allocator
@@ -195,7 +340,7 @@ class private_adaptive_node_pool_impl
    ,  m_real_num_node(AlignOnly ? (m_real_block_alignment - PayloadPerAllocation - HdrSize)/m_real_node_size : 0)
       //General purpose allocator
    ,  mp_segment_mngr_base(segment_mngr_base)
-   ,  m_block_multiset()
+   ,  m_block_container()
    ,  m_totally_free_blocks(0)
    {
       if(!AlignOnly){
@@ -214,7 +359,7 @@ class private_adaptive_node_pool_impl
 
    //!Destructor. Deallocates all allocated blocks. Never throws
    ~private_adaptive_node_pool_impl()
-   {  priv_clear();  }
+   {  this->priv_clear();  }
 
    size_type get_real_num_node() const
    {  return m_real_num_node; }
@@ -226,84 +371,157 @@ class private_adaptive_node_pool_impl
    //!Allocates array of count elements. Can throw
    void *allocate_node()
    {
-      priv_invariants();
+      this->priv_invariants();
       //If there are no free nodes we allocate a new block
-      if (m_block_multiset.empty()){
-         priv_alloc_block(1);
+      if(!m_block_container.empty()){
+         //We take the first free node the multiset can't be empty
+         free_nodes_t &free_nodes = m_block_container.begin()->free_nodes;
+         BOOST_ASSERT(!free_nodes.empty());
+         const size_type free_nodes_count = free_nodes.size();
+         void *first_node = container_detail::to_raw_pointer(free_nodes.pop_front());
+         if(free_nodes.empty()){
+            block_container_traits_t::erase_first(m_block_container);
+         }
+         m_totally_free_blocks -= static_cast(free_nodes_count == m_real_num_node);
+         this->priv_invariants();
+         return first_node;
+      }
+      else{
+         multiallocation_chain chain;
+         this->priv_append_from_new_blocks(1, chain, IsAlignOnly());
+         return container_detail::to_raw_pointer(chain.pop_front());
       }
-      //We take the first free node the multiset can't be empty
-      return priv_take_first_node();
    }
 
    //!Deallocates an array pointed by ptr. Never throws
    void deallocate_node(void *pElem)
    {
-      multiallocation_chain chain;
-      chain.push_front(void_pointer(pElem));
-      this->priv_reinsert_nodes_in_block(chain, 1);
-      //Update free block count<
-      if(m_totally_free_blocks > m_max_free_blocks){
-         this->priv_deallocate_free_blocks(m_max_free_blocks);
-      }
-      priv_invariants();
+      this->priv_invariants();
+      block_info_t &block_info = *this->priv_block_from_node(pElem);
+      BOOST_ASSERT(block_info.free_nodes.size() < m_real_num_node);
+
+      //We put the node at the beginning of the free node list
+      block_info.free_nodes.push_back(void_pointer(pElem));
+
+      //The loop reinserts all blocks except the last one
+      this->priv_reinsert_block(block_info, block_info.free_nodes.size() == 1);
+      this->priv_deallocate_free_blocks(m_max_free_blocks);
+      this->priv_invariants();
    }
 
    //!Allocates n nodes.
    //!Can throw
-   multiallocation_chain allocate_nodes(const size_type n)
+   void allocate_nodes(const size_type n, multiallocation_chain &chain)
    {
-      multiallocation_chain chain;
       size_type i = 0;
-      try{
-         priv_invariants();
+      BOOST_TRY{
+         this->priv_invariants();
          while(i != n){
             //If there are no free nodes we allocate all needed blocks
-            if (m_block_multiset.empty()){
-               priv_alloc_block(((n - i) - 1)/m_real_num_node + 1);
+            if (m_block_container.empty()){
+               this->priv_append_from_new_blocks(n - i, chain, IsAlignOnly());
+               BOOST_ASSERT(m_block_container.empty() || (++m_block_container.cbegin() == m_block_container.cend()));
+               BOOST_ASSERT(chain.size() == n);
+               break;
             }
-            free_nodes_t &free_nodes = m_block_multiset.begin()->free_nodes;
+            free_nodes_t &free_nodes = m_block_container.begin()->free_nodes;
             const size_type free_nodes_count_before = free_nodes.size();
-            if(free_nodes_count_before == m_real_num_node){
-               --m_totally_free_blocks;
-            }
-            const size_type num_elems = ((n-i) < free_nodes_count_before) ? (n-i) : free_nodes_count_before;
-            for(size_type j = 0; j != num_elems; ++j){
-               void *new_node = &free_nodes.front();
-               free_nodes.pop_front();
-               chain.push_back(new_node);
-            }
+            m_totally_free_blocks -= static_cast(free_nodes_count_before == m_real_num_node);
+            const size_type num_left  = n-i;
+            const size_type num_elems = (num_left < free_nodes_count_before) ? num_left : free_nodes_count_before;
+            typedef typename free_nodes_t::iterator free_nodes_iterator;
 
-            if(free_nodes.empty()){
-               m_block_multiset.erase(m_block_multiset.begin());
+            if(num_left < free_nodes_count_before){
+               const free_nodes_iterator it_bbeg(free_nodes.before_begin());
+               free_nodes_iterator it_bend(it_bbeg);
+               for(size_type j = 0; j != num_elems; ++j){
+                  ++it_bend;
+               }
+               free_nodes_iterator it_end = it_bend; ++it_end;
+               free_nodes_iterator it_beg = it_bbeg; ++it_beg;
+               free_nodes.erase_after(it_bbeg, it_end, num_elems);
+               chain.incorporate_after(chain.last(), &*it_beg, &*it_bend, num_elems);
+               //chain.splice_after(chain.last(), free_nodes, it_bbeg, it_bend, num_elems);
+               BOOST_ASSERT(!free_nodes.empty());
+            }
+            else{
+               const free_nodes_iterator it_beg(free_nodes.begin()), it_bend(free_nodes.last());
+               free_nodes.clear();
+               chain.incorporate_after(chain.last(), &*it_beg, &*it_bend, num_elems);
+               block_container_traits_t::erase_first(m_block_container);
             }
             i += num_elems;
          }
       }
-      catch(...){
-         this->deallocate_nodes(boost::move(chain));
-         throw;
+      BOOST_CATCH(...){
+         this->deallocate_nodes(chain);
+         BOOST_RETHROW
       }
-      priv_invariants();
-      return boost::move(chain);
+      BOOST_CATCH_END
+      this->priv_invariants();
    }
 
    //!Deallocates a linked list of nodes. Never throws
-   void deallocate_nodes(multiallocation_chain nodes)
+   void deallocate_nodes(multiallocation_chain &nodes)
    {
-      this->priv_reinsert_nodes_in_block(nodes, nodes.size());
-      if(m_totally_free_blocks > m_max_free_blocks){
+      this->priv_invariants();
+      //To take advantage of node locality, wait until two
+      //nodes belong to different blocks. Only then reinsert
+      //the block of the first node in the block tree.
+      //Cache of the previous block
+      block_info_t *prev_block_info = 0;
+
+      //If block was empty before this call, it's not already
+      //inserted in the block tree.
+      bool prev_block_was_empty     = false;
+      typedef typename free_nodes_t::iterator free_nodes_iterator;
+      {
+         const free_nodes_iterator itbb(nodes.before_begin()), ite(nodes.end());
+         free_nodes_iterator itf(nodes.begin()), itbf(itbb);
+         size_type splice_node_count = size_type(-1);
+         while(itf != ite){
+            void *pElem = container_detail::to_raw_pointer(&*itf);
+            block_info_t &block_info = *this->priv_block_from_node(pElem);
+            BOOST_ASSERT(block_info.free_nodes.size() < m_real_num_node);
+            ++splice_node_count;
+
+            //If block change is detected calculate the cached block position in the tree
+            if(&block_info != prev_block_info){
+               if(prev_block_info){ //Make sure we skip the initial "dummy" cache
+                  free_nodes_iterator it(itbb); ++it;
+                  nodes.erase_after(itbb, itf, splice_node_count);
+                  prev_block_info->free_nodes.incorporate_after(prev_block_info->free_nodes.last(), &*it, &*itbf, splice_node_count);
+                  this->priv_reinsert_block(*prev_block_info, prev_block_was_empty);
+                  splice_node_count = 0;
+               }
+               //Update cache with new data
+               prev_block_was_empty = block_info.free_nodes.empty();
+               prev_block_info = &block_info;
+            }
+            itbf = itf;
+            ++itf;
+         }
+      }
+      if(prev_block_info){
+         //The loop reinserts all blocks except the last one
+         const free_nodes_iterator itfirst(nodes.begin()), itlast(nodes.last());
+         const size_type splice_node_count = nodes.size();
+         nodes.clear();
+         prev_block_info->free_nodes.incorporate_after(prev_block_info->free_nodes.last(), &*itfirst, &*itlast, splice_node_count);
+         this->priv_reinsert_block(*prev_block_info, prev_block_was_empty);
+         this->priv_invariants();
          this->priv_deallocate_free_blocks(m_max_free_blocks);
       }
    }
 
    void deallocate_free_blocks()
-   {  this->priv_deallocate_free_blocks(0);   }
+   {  this->priv_deallocate_free_blocks(0);  }
 
    size_type num_free_nodes()
    {
-      typedef typename block_multiset_t::const_iterator citerator;
+      typedef typename block_container_t::const_iterator citerator;
       size_type count = 0;
-      citerator it (m_block_multiset.begin()), itend(m_block_multiset.end());
+      citerator it (m_block_container.begin()), itend(m_block_container.end());
       for(; it != itend; ++it){
          count += it->free_nodes.size();
       }
@@ -318,7 +536,7 @@ class private_adaptive_node_pool_impl
       BOOST_ASSERT(m_real_num_node == other.m_real_num_node);
       std::swap(mp_segment_mngr_base, other.mp_segment_mngr_base);
       std::swap(m_totally_free_blocks, other.m_totally_free_blocks);
-      m_block_multiset.swap(other.m_block_multiset);
+      m_block_container.swap(other.m_block_container);
    }
 
    //Deprecated, use deallocate_free_blocks
@@ -326,83 +544,54 @@ class private_adaptive_node_pool_impl
    {  this->priv_deallocate_free_blocks(0);   }
 
    private:
+
    void priv_deallocate_free_blocks(size_type max_free_blocks)
+   {  //Trampoline function to ease inlining
+      if(m_totally_free_blocks > max_free_blocks){
+         this->priv_deallocate_free_blocks_impl(max_free_blocks);
+      }
+   }
+
+   void priv_deallocate_free_blocks_impl(size_type max_free_blocks)
    {
-      priv_invariants();
+      this->priv_invariants();
       //Now check if we've reached the free nodes limit
       //and check if we have free blocks. If so, deallocate as much
       //as we can to stay below the limit
-      for( block_iterator itend = m_block_multiset.end()
-         ; m_totally_free_blocks > max_free_blocks
-         ; --m_totally_free_blocks
-         ){
-         BOOST_ASSERT(!m_block_multiset.empty());
-         block_iterator it = itend;
+      multiallocation_chain chain;
+      {
+         const const_block_iterator itend = m_block_container.cend();
+         const_block_iterator it = itend;
          --it;
-         BOOST_ASSERT(it->free_nodes.size() == m_real_num_node);
-         m_block_multiset.erase_and_dispose(it, block_destroyer(this));
+         size_type totally_free_blocks = m_totally_free_blocks;
+
+         for( ; totally_free_blocks > max_free_blocks; --totally_free_blocks){
+            BOOST_ASSERT(it->free_nodes.size() == m_real_num_node);
+            void *addr = priv_first_subblock_from_block(const_cast(&*it));
+            --it;
+            block_container_traits_t::erase_last(m_block_container);
+            chain.push_front(void_pointer(addr));
+         }
+         BOOST_ASSERT((m_totally_free_blocks - max_free_blocks) == chain.size());
+         m_totally_free_blocks = max_free_blocks;
       }
+      this->mp_segment_mngr_base->deallocate_many(chain);
    }
 
-   void priv_reinsert_nodes_in_block(multiallocation_chain &chain, size_type n)
+   void priv_reinsert_block(block_info_t &prev_block_info, const bool prev_block_was_empty)
    {
-      block_iterator block_it(m_block_multiset.end());
-      while(n--){
-         void *pElem = container_detail::to_raw_pointer(chain.pop_front());
-         priv_invariants();
-         block_info_t *block_info = this->priv_block_from_node(pElem);
-         BOOST_ASSERT(block_info->free_nodes.size() < m_real_num_node);
-         //We put the node at the beginning of the free node list
-         node_t * to_deallocate = static_cast(pElem);
-         block_info->free_nodes.push_front(*to_deallocate);
+      //Cache the free nodes from the block
+      const size_type this_block_free_nodes = prev_block_info.free_nodes.size();
+      const bool is_full = this_block_free_nodes == m_real_num_node;
 
-         block_iterator this_block(block_multiset_t::s_iterator_to(*block_info));
-         block_iterator next_block(this_block);
-         ++next_block;
-
-         //Cache the free nodes from the block
-         size_type this_block_free_nodes = this_block->free_nodes.size();
-
-         if(this_block_free_nodes == 1){
-            m_block_multiset.insert(m_block_multiset.begin(), *block_info);
-         }
-         else{
-            block_iterator next_block(this_block);
-            ++next_block;
-            if(next_block != block_it){
-               size_type next_free_nodes = next_block->free_nodes.size();
-               if(this_block_free_nodes > next_free_nodes){
-                  //Now move the block to the new position
-                  m_block_multiset.erase(this_block);
-                  m_block_multiset.insert(*block_info);
-               }
-            }
-         }
-         //Update free block count
-         if(this_block_free_nodes == m_real_num_node){
-            ++m_totally_free_blocks;
-         }
-         priv_invariants();
+      //Update free block count
+      m_totally_free_blocks += static_cast(is_full);
+      if(prev_block_was_empty){
+         block_container_traits_t::insert_was_empty(m_block_container, prev_block_info, is_full);
       }
-   }
-
-   node_t *priv_take_first_node()
-   {
-      BOOST_ASSERT(m_block_multiset.begin() != m_block_multiset.end());
-      //We take the first free node the multiset can't be empty
-      free_nodes_t &free_nodes = m_block_multiset.begin()->free_nodes;
-      node_t *first_node = &free_nodes.front();
-      const size_type free_nodes_count = free_nodes.size();
-      BOOST_ASSERT(0 != free_nodes_count);
-      free_nodes.pop_front();
-      if(free_nodes_count == 1){
-         m_block_multiset.erase(m_block_multiset.begin());
+      else{
+         block_container_traits_t::reinsert_was_used(m_block_container, prev_block_info, is_full);
       }
-      else if(free_nodes_count == m_real_num_node){
-         --m_totally_free_blocks;
-      }
-      priv_invariants();
-      return first_node;
    }
 
    class block_destroyer;
@@ -411,33 +600,31 @@ class private_adaptive_node_pool_impl
    class block_destroyer
    {
       public:
-      block_destroyer(const this_type *impl)
-         :  mp_impl(impl)
+      block_destroyer(const this_type *impl, multiallocation_chain &chain)
+         :  mp_impl(impl), m_chain(chain)
       {}
 
-      void operator()(typename block_multiset_t::pointer to_deallocate)
+      void operator()(typename block_container_t::pointer to_deallocate)
       {  return this->do_destroy(to_deallocate, IsAlignOnly()); }
 
       private:
-      void do_destroy(typename block_multiset_t::pointer to_deallocate, AlignOnlyTrue)
+      void do_destroy(typename block_container_t::pointer to_deallocate, AlignOnlyTrue)
       {
-         size_type free_nodes = to_deallocate->free_nodes.size();
-         (void)free_nodes;
-         BOOST_ASSERT(free_nodes == mp_impl->m_real_num_node);
-         mp_impl->mp_segment_mngr_base->deallocate(to_deallocate);
+         BOOST_ASSERT(to_deallocate->free_nodes.size() == mp_impl->m_real_num_node);
+         m_chain.push_back(to_deallocate);
       }
 
-      void do_destroy(typename block_multiset_t::pointer to_deallocate, AlignOnlyFalse)
+      void do_destroy(typename block_container_t::pointer to_deallocate, AlignOnlyFalse)
       {
-         size_type free_nodes = to_deallocate->free_nodes.size();
-         (void)free_nodes;
-         BOOST_ASSERT(free_nodes == mp_impl->m_real_num_node);
+         BOOST_ASSERT(to_deallocate->free_nodes.size() == mp_impl->m_real_num_node);
          BOOST_ASSERT(0 == to_deallocate->hdr_offset);
-         hdr_offset_holder *hdr_off_holder = mp_impl->priv_first_subblock_from_block(container_detail::to_raw_pointer(to_deallocate));
-         mp_impl->mp_segment_mngr_base->deallocate(hdr_off_holder);
+         hdr_offset_holder *hdr_off_holder =
+            mp_impl->priv_first_subblock_from_block(container_detail::to_raw_pointer(to_deallocate));
+         m_chain.push_back(hdr_off_holder);
       }
 
       const this_type *mp_impl;
+      multiallocation_chain &m_chain;
    };
 
    //This macro will activate invariant checking. Slow, but helpful for debugging the code.
@@ -446,44 +633,45 @@ class private_adaptive_node_pool_impl
    #ifdef BOOST_CONTAINER_ADAPTIVE_NODE_POOL_CHECK_INVARIANTS
    #undef BOOST_CONTAINER_ADAPTIVE_NODE_POOL_CHECK_INVARIANTS
    {
-      //We iterate through the block tree to free the memory
-      block_iterator it(m_block_multiset.begin()),
-                     itend(m_block_multiset.end()), to_deallocate;
-      if(it != itend){
-         for(++it; it != itend; ++it){
-            block_iterator prev(it);
-            --prev;
-            size_type sp = prev->free_nodes.size(),
-                        si = it->free_nodes.size();
-            BOOST_ASSERT(sp <= si);
-            (void)sp;   (void)si;
+      const const_block_iterator itend(m_block_container.end());
+
+      {  //We iterate through the block tree to free the memory
+         const_block_iterator it(m_block_container.begin());
+   
+         if(it != itend){
+            for(++it; it != itend; ++it){
+               const_block_iterator prev(it);
+               --prev;
+               BOOST_ASSERT(*prev < *it);
+               (void)prev;   (void)it;
+            }
          }
       }
-      //Check that the total free nodes are correct
-      it    = m_block_multiset.begin();
-      itend = m_block_multiset.end();
-      size_type total_free_nodes = 0;
-      for(; it != itend; ++it){
-         total_free_nodes += it->free_nodes.size();
+      {  //Check that the total free nodes are correct
+         const_block_iterator it(m_block_container.cbegin());
+         size_type total_free_nodes = 0;
+         for(; it != itend; ++it){
+            total_free_nodes += it->free_nodes.size();
+         }
+         BOOST_ASSERT(total_free_nodes >= m_totally_free_blocks*m_real_num_node);
       }
-      BOOST_ASSERT(total_free_nodes >= m_totally_free_blocks*m_real_num_node);
-
-      //Check that the total totally free blocks are correct
-      it    = m_block_multiset.begin();
-      itend = m_block_multiset.end();
-      total_free = 0;
-      for(; it != itend; ++it){
-         total_free += it->free_nodes.size() == m_real_num_node;
+      {  //Check that the total totally free blocks are correct
+         BOOST_ASSERT(m_block_container.size() >= m_totally_free_blocks);
+         const_block_iterator it = m_block_container.cend();
+         size_type total_free_blocks = m_totally_free_blocks;
+         while(total_free_blocks--){
+            BOOST_ASSERT((--it)->free_nodes.size() == m_real_num_node);
+         }
       }
-      BOOST_ASSERT(total_free >= m_totally_free_blocks);
 
       if(!AlignOnly){
          //Check that header offsets are correct
-         it = m_block_multiset.begin();
+         const_block_iterator it = m_block_container.begin();
          for(; it != itend; ++it){
-            hdr_offset_holder *hdr_off_holder = priv_first_subblock_from_block(&*it);
+            hdr_offset_holder *hdr_off_holder = this->priv_first_subblock_from_block(const_cast(&*it));
             for(size_type i = 0, max = m_num_subblocks; i < max; ++i){
-               BOOST_ASSERT(hdr_off_holder->hdr_offset == size_type(reinterpret_cast(&*it)- reinterpret_cast(hdr_off_holder)));
+               const size_type offset = reinterpret_cast(const_cast(&*it)) - reinterpret_cast(hdr_off_holder);
+               BOOST_ASSERT(hdr_off_holder->hdr_offset == offset);
                BOOST_ASSERT(0 == ((size_type)hdr_off_holder & (m_real_block_alignment - 1)));
                BOOST_ASSERT(0 == (hdr_off_holder->hdr_offset & (m_real_block_alignment - 1)));
                hdr_off_holder = reinterpret_cast(reinterpret_cast(hdr_off_holder) + m_real_block_alignment);
@@ -499,19 +687,21 @@ class private_adaptive_node_pool_impl
    void priv_clear()
    {
       #ifndef NDEBUG
-      block_iterator it    = m_block_multiset.begin();
-      block_iterator itend = m_block_multiset.end();
-      size_type num_free_nodes = 0;
+      block_iterator it    = m_block_container.begin();
+      block_iterator itend = m_block_container.end();
+      size_type n_free_nodes = 0;
       for(; it != itend; ++it){
          //Check for memory leak
          BOOST_ASSERT(it->free_nodes.size() == m_real_num_node);
-         ++num_free_nodes;
+         ++n_free_nodes;
       }
-      BOOST_ASSERT(num_free_nodes == m_totally_free_blocks);
+      BOOST_ASSERT(n_free_nodes == m_totally_free_blocks);
       #endif
       //Check for memory leaks
-      priv_invariants();
-      m_block_multiset.clear_and_dispose(block_destroyer(this));
+      this->priv_invariants();
+      multiallocation_chain chain;
+      m_block_container.clear_and_dispose(block_destroyer(this, chain));
+      this->mp_segment_mngr_base->deallocate_many(chain);
       m_totally_free_blocks = 0;
    }
 
@@ -533,93 +723,129 @@ class private_adaptive_node_pool_impl
    }
 
    block_info_t *priv_block_from_node(void *node) const
-   {  return priv_block_from_node(node, IsAlignOnly());   }
+   {  return this->priv_block_from_node(node, IsAlignOnly());   }
 
    hdr_offset_holder *priv_first_subblock_from_block(block_info_t *block) const
+   {  return this->priv_first_subblock_from_block(block, IsAlignOnly());   }
+
+   hdr_offset_holder *priv_first_subblock_from_block(block_info_t *block, AlignOnlyFalse) const
    {
-      hdr_offset_holder *hdr_off_holder = reinterpret_cast
+      hdr_offset_holder *const hdr_off_holder = reinterpret_cast
             (reinterpret_cast(block) - (m_num_subblocks-1)*m_real_block_alignment);
       BOOST_ASSERT(hdr_off_holder->hdr_offset == size_type(reinterpret_cast(block) - reinterpret_cast(hdr_off_holder)));
-     BOOST_ASSERT(0 == ((std::size_t)hdr_off_holder & (m_real_block_alignment - 1)));
+      BOOST_ASSERT(0 == ((std::size_t)hdr_off_holder & (m_real_block_alignment - 1)));
       BOOST_ASSERT(0 == (hdr_off_holder->hdr_offset & (m_real_block_alignment - 1)));
       return hdr_off_holder;
    }
 
-   //!Allocates a several blocks of nodes. Can throw
-   void priv_alloc_block(size_type n, AlignOnlyTrue)
+   hdr_offset_holder *priv_first_subblock_from_block(block_info_t *block, AlignOnlyTrue) const
    {
-      size_type real_block_size = m_real_block_alignment - PayloadPerAllocation;
-      for(size_type i = 0; i != n; ++i){
-         //We allocate a new NodeBlock and put it the last
-         //element of the tree
-         char *mem_address = static_cast
-            (mp_segment_mngr_base->allocate_aligned(real_block_size, m_real_block_alignment));
-         if(!mem_address)   throw std::bad_alloc();
-         ++m_totally_free_blocks;
-         block_info_t *c_info = new(mem_address)block_info_t();
-         m_block_multiset.insert(m_block_multiset.end(), *c_info);
-        
-         mem_address += HdrSize;
-         //We initialize all Nodes in Node Block to insert
-         //them in the free Node list
-         typename free_nodes_t::iterator prev_insert_pos = c_info->free_nodes.before_begin();
-         for(size_type i = 0; i < m_real_num_node; ++i){
-            prev_insert_pos = c_info->free_nodes.insert_after(prev_insert_pos, *(node_t*)mem_address);
-            mem_address   += m_real_node_size;
+      return reinterpret_cast(block);
+   }
+
+   void priv_dispatch_block_chain_or_free
+      ( multiallocation_chain &chain, block_info_t &c_info, size_type num_node
+      , char *mem_address, size_type total_elements, bool insert_block_if_free)
+   {
+      BOOST_ASSERT(chain.size() <= total_elements);
+      //First add all possible nodes to the chain
+      const size_type left = total_elements - chain.size();
+      const size_type max_chain = (num_node < left) ? num_node : left;
+      mem_address = static_cast(container_detail::to_raw_pointer
+         (chain.incorporate_after(chain.last(), void_pointer(mem_address), m_real_node_size, max_chain)));
+      //Now store remaining nodes in the free list
+      if(const size_type max_free = num_node - max_chain){
+         free_nodes_t & free_nodes = c_info.free_nodes;
+         free_nodes.incorporate_after(free_nodes.last(), void_pointer(mem_address), m_real_node_size, max_free);
+         if(insert_block_if_free){
+            m_block_container.push_front(c_info);
          }
       }
    }
 
-   void priv_alloc_block(size_type n, AlignOnlyFalse)
+   //!Allocates a several blocks of nodes. Can throw
+   void priv_append_from_new_blocks(size_type min_elements, multiallocation_chain &chain, AlignOnlyTrue)
    {
-      size_type real_block_size = m_real_block_alignment*m_num_subblocks - PayloadPerAllocation;
-      size_type elements_per_subblock = (m_real_block_alignment - HdrOffsetSize)/m_real_node_size;
-      size_type hdr_subblock_elements = (m_real_block_alignment - HdrSize - PayloadPerAllocation)/m_real_node_size;
+      BOOST_ASSERT(m_block_container.empty());
+      BOOST_ASSERT(min_elements > 0);
+      const size_type n = (min_elements - 1)/m_real_num_node + 1;
+      const size_type real_block_size = m_real_block_alignment - PayloadPerAllocation;
+      const size_type total_elements = chain.size() + min_elements;
+      for(size_type i = 0; i != n; ++i){
+         //We allocate a new NodeBlock and put it the last
+         //element of the tree
+         char *mem_address = static_cast
+            (mp_segment_mngr_base->allocate_aligned(real_block_size, m_real_block_alignment));
+         if(!mem_address){
+            //In case of error, free memory deallocating all nodes (the new ones allocated
+            //in this function plus previously stored nodes in chain).
+            this->deallocate_nodes(chain);
+            throw std::bad_alloc();
+         }
+         block_info_t &c_info = *new(mem_address)block_info_t();
+         mem_address += HdrSize;
+         if(i != (n-1)){
+            chain.incorporate_after(chain.last(), void_pointer(mem_address), m_real_node_size, m_real_num_node);
+         }
+         else{
+            this->priv_dispatch_block_chain_or_free(chain, c_info, m_real_num_node, mem_address, total_elements, true);
+         }
+      }
+   }
+
+   void priv_append_from_new_blocks(size_type min_elements, multiallocation_chain &chain, AlignOnlyFalse)
+   {
+      BOOST_ASSERT(m_block_container.empty());
+      BOOST_ASSERT(min_elements > 0);
+      const size_type n = (min_elements - 1)/m_real_num_node + 1;
+      const size_type real_block_size = m_real_block_alignment*m_num_subblocks - PayloadPerAllocation;
+      const size_type elements_per_subblock = (m_real_block_alignment - HdrOffsetSize)/m_real_node_size;
+      const size_type hdr_subblock_elements = (m_real_block_alignment - HdrSize - PayloadPerAllocation)/m_real_node_size;
+      const size_type total_elements = chain.size() + min_elements;
 
       for(size_type i = 0; i != n; ++i){
          //We allocate a new NodeBlock and put it the last
          //element of the tree
          char *mem_address = static_cast
             (mp_segment_mngr_base->allocate_aligned(real_block_size, m_real_block_alignment));
-         if(!mem_address)   throw std::bad_alloc();
-         ++m_totally_free_blocks;
-
+         if(!mem_address){
+            //In case of error, free memory deallocating all nodes (the new ones allocated
+            //in this function plus previously stored nodes in chain).
+            this->deallocate_nodes(chain);
+            throw std::bad_alloc();
+         }
          //First initialize header information on the last subblock
          char *hdr_addr = mem_address + m_real_block_alignment*(m_num_subblocks-1);
-         block_info_t *c_info = new(hdr_addr)block_info_t();
+         block_info_t &c_info = *new(hdr_addr)block_info_t();
          //Some structural checks
-         BOOST_ASSERT(static_cast(&static_cast(c_info)->hdr_offset) ==
-                static_cast(c_info));
-         typename free_nodes_t::iterator prev_insert_pos = c_info->free_nodes.before_begin();
-         for( size_type subblock = 0, maxsubblock = m_num_subblocks - 1
-            ; subblock < maxsubblock
-            ; ++subblock, mem_address += m_real_block_alignment){
-            //Initialize header offset mark
-            new(mem_address) hdr_offset_holder(size_type(hdr_addr - mem_address));
-            char *pNode = mem_address + HdrOffsetSize;
-            for(size_type i = 0; i < elements_per_subblock; ++i){
-               prev_insert_pos = c_info->free_nodes.insert_after(prev_insert_pos, *new (pNode) node_t);
-               pNode   += m_real_node_size;
+         BOOST_ASSERT(static_cast(&static_cast(c_info).hdr_offset) ==
+                      static_cast(&c_info));   (void)c_info;
+         if(i != (n-1)){
+            for( size_type subblock = 0, maxsubblock = m_num_subblocks - 1
+               ; subblock < maxsubblock
+               ; ++subblock, mem_address += m_real_block_alignment){
+               //Initialize header offset mark
+               new(mem_address) hdr_offset_holder(size_type(hdr_addr - mem_address));
+               chain.incorporate_after
+                  (chain.last(), void_pointer(mem_address + HdrOffsetSize), m_real_node_size, elements_per_subblock);
             }
+            chain.incorporate_after(chain.last(), void_pointer(hdr_addr + HdrSize), m_real_node_size, hdr_subblock_elements);
          }
-         {
-            char *pNode = hdr_addr + HdrSize;
-            //We initialize all Nodes in Node Block to insert
-            //them in the free Node list
-            for(size_type i = 0; i < hdr_subblock_elements; ++i){
-               prev_insert_pos = c_info->free_nodes.insert_after(prev_insert_pos, *new (pNode) node_t);
-               pNode   += m_real_node_size;
+         else{
+            for( size_type subblock = 0, maxsubblock = m_num_subblocks - 1
+               ; subblock < maxsubblock
+               ; ++subblock, mem_address += m_real_block_alignment){
+               //Initialize header offset mark
+               new(mem_address) hdr_offset_holder(size_type(hdr_addr - mem_address));
+               this->priv_dispatch_block_chain_or_free
+                  (chain, c_info, elements_per_subblock, mem_address + HdrOffsetSize, total_elements, false);
             }
+            this->priv_dispatch_block_chain_or_free
+               (chain, c_info, hdr_subblock_elements, hdr_addr + HdrSize, total_elements, true);
          }
-         //Insert the block after the free node list is full
-         m_block_multiset.insert(m_block_multiset.end(), *c_info);
       }
    }
 
-   //!Allocates a block of nodes. Can throw std::bad_alloc
-   void priv_alloc_block(size_type n)
-   {  return priv_alloc_block(n, IsAlignOnly());   }
-
    private:
    typedef typename boost::intrusive::pointer_traits
       ::template rebind_pointer::type   segment_mngr_base_ptr_t;
@@ -633,9 +859,9 @@ class private_adaptive_node_pool_impl
    //This is the real number of nodes per block
    //const
    size_type m_real_num_node;
-   segment_mngr_base_ptr_t                mp_segment_mngr_base;   //Segment manager
-   block_multiset_t                       m_block_multiset;       //Intrusive block list
-   size_type                            m_totally_free_blocks;  //Free blocks
+   segment_mngr_base_ptr_t             mp_segment_mngr_base;   //Segment manager
+   block_container_t                    m_block_container;       //Intrusive block list
+   size_type                           m_totally_free_blocks;  //Free blocks
 };
 
 }  //namespace container_detail {
diff --git a/include/boost/container/detail/advanced_insert_int.hpp b/include/boost/container/detail/advanced_insert_int.hpp
index e7adcd2..4c4fef6 100644
--- a/include/boost/container/detail/advanced_insert_int.hpp
+++ b/include/boost/container/detail/advanced_insert_int.hpp
@@ -20,160 +20,177 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include   //std::iterator_traits
 #include 
+#include 
 
 namespace boost { namespace container { namespace container_detail {
 
-//This class will be interface for operations dependent on FwdIt types used advanced_insert_aux_impl
-template
-struct advanced_insert_aux_int
-{
-   typedef typename std::iterator_traits::difference_type difference_type;
-   virtual void copy_remaining_to(Iterator p) = 0;
-   virtual void uninitialized_copy_remaining_to(Iterator p) = 0;
-   virtual void uninitialized_copy_some_and_update(Iterator pos, difference_type division_count, bool first) = 0;
-   virtual void copy_some_and_update(Iterator pos, difference_type division_count, bool first) = 0;
-   virtual ~advanced_insert_aux_int() {}
-};
-
-//This class template will adapt each FwIt types to advanced_insert_aux_int
 template
-struct advanced_insert_aux_proxy
-   :  public advanced_insert_aux_int
+struct insert_range_proxy
 {
    typedef typename allocator_traits::size_type size_type;
    typedef typename allocator_traits::value_type value_type;
-   typedef typename advanced_insert_aux_int::difference_type difference_type;
 
-   advanced_insert_aux_proxy(A& a, FwdIt first, FwdIt last)
-      :  a_(a), first_(first), last_(last)
+   insert_range_proxy(A& a, FwdIt first)
+      :  a_(a), first_(first)
    {}
 
-   virtual ~advanced_insert_aux_proxy()
-   {}
-
-   virtual void copy_remaining_to(Iterator p)
-   {  ::boost::copy_or_move(this->first_, this->last_, p);  }
-
-   virtual void uninitialized_copy_remaining_to(Iterator p)
-   {  ::boost::container::uninitialized_copy_or_move_alloc(this->a_, this->first_, this->last_, p);  }
-
-   virtual void uninitialized_copy_some_and_update(Iterator pos, difference_type division_count, bool first_n)
+   void uninitialized_copy_n_and_update(Iterator pos, size_type n)
    {
-      FwdIt mid = this->first_;
-      std::advance(mid, division_count);
-      if(first_n){
-         ::boost::container::uninitialized_copy_or_move_alloc(this->a_, this->first_, mid, pos);
-         this->first_ = mid;
-      }
-      else{
-         ::boost::container::uninitialized_copy_or_move_alloc(this->a_, mid, this->last_, pos);
-         this->last_ = mid;
-      }
+      this->first_ = ::boost::container::uninitialized_copy_or_move_alloc_n_source
+         (this->a_, this->first_, n, pos);
    }
 
-   virtual void copy_some_and_update(Iterator pos, difference_type division_count, bool first_n)
+   void copy_n_and_update(Iterator pos, size_type n)
    {
-      FwdIt mid = this->first_;
-      std::advance(mid, division_count);
-      if(first_n){
-         ::boost::copy_or_move(this->first_, mid, pos);
-         this->first_ = mid;
-      }
-      else{
-         ::boost::copy_or_move(mid, this->last_, pos);
-         this->last_ = mid;
-      }
+      this->first_ = ::boost::container::copy_or_move_n_source(this->first_, n, pos);
    }
+
    A &a_;
-   FwdIt first_, last_;
+   FwdIt first_;
 };
 
-//This class template will adapt default construction insertions to advanced_insert_aux_int
+
 template
-struct default_construct_aux_proxy
-   :  public advanced_insert_aux_int
+struct insert_n_copies_proxy
+{
+   typedef typename allocator_traits::size_type size_type;
+   typedef typename allocator_traits::value_type value_type;
+
+   insert_n_copies_proxy(A& a, const value_type &v)
+      :  a_(a), v_(v)
+   {}
+
+   void uninitialized_copy_n_and_update(Iterator p, size_type n)
+   {  std::uninitialized_fill_n(p, n, v_);   }
+
+   void copy_n_and_update(Iterator p, size_type n)
+   {  std::fill_n(p, n, v_);  }
+
+   A &a_;
+   const value_type &v_;
+};
+
+template
+struct insert_default_constructed_n_proxy
 {
    typedef ::boost::container::allocator_traits alloc_traits;
    typedef typename allocator_traits::size_type size_type;
    typedef typename allocator_traits::value_type value_type;
-   typedef typename advanced_insert_aux_int::difference_type difference_type;
 
-   default_construct_aux_proxy(A &a, size_type count)
-      :  a_(a), count_(count)
+
+   explicit insert_default_constructed_n_proxy(A &a)
+      :  a_(a)
    {}
 
-   virtual ~default_construct_aux_proxy()
-   {}
-
-   virtual void copy_remaining_to(Iterator)
-   {  //This should never be called with any count
-      BOOST_ASSERT(this->count_ == 0);
-   }
-
-   virtual void uninitialized_copy_remaining_to(Iterator p)
-   {  this->priv_uninitialized_copy(p, this->count_); }
-
-   virtual void uninitialized_copy_some_and_update(Iterator pos, difference_type division_count, bool first_n)
+   void uninitialized_copy_n_and_update(Iterator p, size_type n)
    {
-      size_type new_count;
-      if(first_n){
-         new_count = division_count;
-      }
-      else{
-         BOOST_ASSERT(difference_type(this->count_)>= division_count);
-         new_count = this->count_ - division_count;
-      }
-      this->priv_uninitialized_copy(pos, new_count);
-   }
-
-   virtual void copy_some_and_update(Iterator , difference_type division_count, bool first_n)
-   {
-      BOOST_ASSERT(this->count_ == 0);
-      size_type new_count;
-      if(first_n){
-         new_count = division_count;
-      }
-      else{
-         BOOST_ASSERT(difference_type(this->count_)>= division_count);
-         new_count = this->count_ - division_count;
-      }
-      //This function should never called with a count different to zero
-      BOOST_ASSERT(new_count == 0);
-      (void)new_count;
-   }
-
-   private:
-   void priv_uninitialized_copy(Iterator p, const size_type n)
-   {
-      BOOST_ASSERT(n <= this->count_);
       Iterator orig_p = p;
-      size_type i = 0;
-      try{
-         for(; i < n; ++i, ++p){
+      size_type n_left = n;
+      BOOST_TRY{
+         for(; n_left--; ++p){
             alloc_traits::construct(this->a_, container_detail::to_raw_pointer(&*p));
          }
       }
-      catch(...){
-         while(i--){
+      BOOST_CATCH(...){
+         for(; orig_p != p; ++orig_p){
             alloc_traits::destroy(this->a_, container_detail::to_raw_pointer(&*orig_p++));
          }
-         throw;
+         BOOST_RETHROW
       }
-      this->count_ -= n;
+      BOOST_CATCH_END
    }
+
+   void copy_n_and_update(Iterator, size_type)
+   {
+      BOOST_ASSERT(false);
+   }
+
+   private:
    A &a_;
-   size_type count_;
 };
 
+template
+struct insert_copy_proxy
+{
+   typedef boost::container::allocator_traits alloc_traits;
+   typedef typename alloc_traits::size_type size_type;
+   typedef typename alloc_traits::value_type value_type;
+
+   insert_copy_proxy(A& a, const value_type &v)
+      :  a_(a), v_(v)
+   {}
+
+   void uninitialized_copy_n_and_update(Iterator p, size_type n)
+   {
+      BOOST_ASSERT(n == 1);  (void)n;
+      alloc_traits::construct( this->a_
+                              , container_detail::to_raw_pointer(&*p)
+                              , v_
+                              );
+   }
+
+   void copy_n_and_update(Iterator p, size_type n)
+   {
+      BOOST_ASSERT(n == 1);  (void)n;
+      *p =v_;
+   }
+
+   A &a_;
+   const value_type &v_;
+};
+
+
+template
+struct insert_move_proxy
+{
+   typedef boost::container::allocator_traits alloc_traits;
+   typedef typename alloc_traits::size_type size_type;
+   typedef typename alloc_traits::value_type value_type;
+
+   insert_move_proxy(A& a, value_type &v)
+      :  a_(a), v_(v)
+   {}
+
+   void uninitialized_copy_n_and_update(Iterator p, size_type n)
+   {
+      BOOST_ASSERT(n == 1);  (void)n;
+      alloc_traits::construct( this->a_
+                              , container_detail::to_raw_pointer(&*p)
+                              , ::boost::move(v_)
+                              );
+   }
+
+   void copy_n_and_update(Iterator p, size_type n)
+   {
+      BOOST_ASSERT(n == 1);  (void)n;
+      *p = ::boost::move(v_);
+   }
+
+   A &a_;
+   value_type &v_;
+};
+
+template
+insert_move_proxy get_insert_value_proxy(A& a, BOOST_RV_REF(typename std::iterator_traits::value_type) v)
+{
+   return insert_move_proxy(a, v);
+}
+
+template
+insert_copy_proxy get_insert_value_proxy(A& a, const typename std::iterator_traits::value_type &v)
+{
+   return insert_copy_proxy(a, v);
+}
+
 }}}   //namespace boost { namespace container { namespace container_detail {
 
 #ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
 #include 
-#include 
+#include 
 #include 
 //#include  //For debugging purposes
 
@@ -181,138 +198,74 @@ namespace boost {
 namespace container {
 namespace container_detail {
 
-
-//This class template will adapt emplace construction insertions of movable types
-//to advanced_insert_aux_int
 template
-struct advanced_insert_aux_non_movable_emplace
-   :  public advanced_insert_aux_int
+struct insert_non_movable_emplace_proxy
 {
-   typedef boost::container::allocator_traits alloc_traits;
-   typedef typename allocator_traits::size_type size_type;
-   typedef typename allocator_traits::value_type value_type;
-   typedef typename advanced_insert_aux_int::difference_type difference_type;
-   typedef typename build_number_seq::type             index_tuple_t;
+   typedef boost::container::allocator_traits   alloc_traits;
+   typedef typename alloc_traits::size_type        size_type;
+   typedef typename alloc_traits::value_type       value_type;
 
-   explicit advanced_insert_aux_non_movable_emplace(A &a, Args&&... args)
-      : a_(a)
-      , args_(args...)
-      , used_(false)
+   typedef typename build_number_seq::type index_tuple_t;
+
+   explicit insert_non_movable_emplace_proxy(A &a, Args&&... args)
+      : a_(a), args_(args...)
    {}
 
-   ~advanced_insert_aux_non_movable_emplace()
-   {}
-
-   virtual void copy_remaining_to(Iterator)
-   //This code can't be called since value_type is not movable or copyable
-   {  BOOST_ASSERT(false);   }
-
-   virtual void uninitialized_copy_remaining_to(Iterator p)
-   {  this->priv_uninitialized_copy_remaining_to(index_tuple_t(), p);   }
-
-   virtual void uninitialized_copy_some_and_update(Iterator p, difference_type division_count, bool first_n)
-   {  this->priv_uninitialized_copy_some_and_update(index_tuple_t(), p, division_count, first_n);  }
-
-   virtual void copy_some_and_update(Iterator, difference_type, bool )
-   //This code can't be called since value_type is not movable or copyable
-   {  BOOST_ASSERT(false);   }
+   void uninitialized_copy_n_and_update(Iterator p, size_type n)
+   {  this->priv_uninitialized_copy_some_and_update(index_tuple_t(), p, n);  }
 
    private:
    template
-   void priv_uninitialized_copy_some_and_update(const index_tuple&, Iterator p, difference_type division_count, bool first_n)
+   void priv_uninitialized_copy_some_and_update(const index_tuple&, Iterator p, size_type n)
    {
-      BOOST_ASSERT(division_count <=1);
-      if((first_n && division_count == 1) || (!first_n && division_count == 0)){
-         if(!this->used_){
-            alloc_traits::construct( this->a_
-                                   , container_detail::to_raw_pointer(&*p)
-                                   , ::boost::forward(get(this->args_))...
-                                   );
-            this->used_ = true;
-         }
-      }
-   }
-
-   template
-   void priv_uninitialized_copy_remaining_to(const index_tuple&, Iterator p)
-   {
-      if(!this->used_){
-         alloc_traits::construct( this->a_
-                                , container_detail::to_raw_pointer(&*p)
-                                  , ::boost::forward(get(this->args_))...
-                                );
-         this->used_ = true;
-      }
+      BOOST_ASSERT(n == 1); (void)n;
+      alloc_traits::construct( this->a_
+                              , container_detail::to_raw_pointer(&*p)
+                              , ::boost::forward(get(this->args_))...
+                              );
    }
 
    protected:
    A &a_;
    tuple args_;
-   bool used_;
 };
 
-//This class template will adapt emplace construction insertions of movable types
-//to advanced_insert_aux_int
 template
-struct advanced_insert_aux_emplace
-   :  public advanced_insert_aux_non_movable_emplace
+struct insert_emplace_proxy
+   :  public insert_non_movable_emplace_proxy
 {
-   typedef advanced_insert_aux_non_movable_emplace base_t;
-   typedef boost::container::allocator_traits alloc_traits;
-   typedef typename base_t::value_type       value_type;
-   typedef typename base_t::difference_type  difference_type;
-   typedef typename base_t::index_tuple_t    index_tuple_t;
+   typedef insert_non_movable_emplace_proxy base_t;
+   typedef boost::container::allocator_traits   alloc_traits;
+   typedef typename base_t::value_type             value_type;
+   typedef typename base_t::size_type              size_type;
+   typedef typename base_t::index_tuple_t          index_tuple_t;
 
-   explicit advanced_insert_aux_emplace(A &a, Args&&... args)
+   explicit insert_emplace_proxy(A &a, Args&&... args)
       : base_t(a, ::boost::forward(args)...)
    {}
 
-   ~advanced_insert_aux_emplace()
-   {}
-
-   //Override only needed functions
-   virtual void copy_remaining_to(Iterator p)
-   {  this->priv_copy_remaining_to(index_tuple_t(), p);   }
-
-   virtual void copy_some_and_update(Iterator p, difference_type division_count, bool first_n)
-   {  this->priv_copy_some_and_update(index_tuple_t(), p, division_count, first_n);  }
+   void copy_n_and_update(Iterator p, size_type n)
+   {  this->priv_copy_some_and_update(index_tuple_t(), p, n);  }
 
    private:
-   template
-   void priv_copy_remaining_to(const index_tuple&, Iterator p)
-   {
-      if(!this->used_){
-         aligned_storage::value> v;
-         value_type *vp = static_cast(static_cast(&v));
-         alloc_traits::construct(this->a_, vp,
-            ::boost::forward(get(this->args_))...);
-         scoped_destructor d(this->a_, vp);
-         *p = ::boost::move(*vp);
-         d.release();
-         this->used_ = true;
-      }
-   }
 
    template
-   void priv_copy_some_and_update(const index_tuple&, Iterator p, difference_type division_count, bool first_n)
+   void priv_copy_some_and_update(const index_tuple&, Iterator p, size_type n)
    {
-      BOOST_ASSERT(division_count <=1);
-      if((first_n && division_count == 1) || (!first_n && division_count == 0)){
-         if(!this->used_){
-            aligned_storage::value> v;
-            value_type *vp = static_cast(static_cast(&v));
-            alloc_traits::construct(this->a_, vp,
-               ::boost::forward(get(this->args_))...);
-            try {
-               *p = ::boost::move(*vp);
-            } catch (...) {
-               alloc_traits::destroy(this->a_, vp);
-               throw;
-            }
-            alloc_traits::destroy(this->a_, vp);
-            this->used_ = true;
-         }
+      BOOST_ASSERT(n ==1); (void)n;
+      aligned_storage::value> v;
+      value_type *vp = static_cast(static_cast(&v));
+      alloc_traits::construct(this->a_, vp,
+         ::boost::forward(get(this->args_))...);
+      BOOST_TRY{
+         *p = ::boost::move(*vp);
       }
+      BOOST_CATCH(...){
+         alloc_traits::destroy(this->a_, vp);
+         BOOST_RETHROW
+      }
+      BOOST_CATCH_END
+      alloc_traits::destroy(this->a_, vp);
    }
 };
 
@@ -327,115 +280,73 @@ namespace boost {
 namespace container {
 namespace container_detail {
 
-#define BOOST_PP_LOCAL_MACRO(n)                                                     \
-template        \
-struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_non_movable_emplace, n), arg)  \
-   :  public advanced_insert_aux_int                                      \
+#define BOOST_PP_LOCAL_MACRO(N)                                                     \
+template        \
+struct BOOST_PP_CAT(insert_non_movable_emplace_proxy_arg, N)                        \
 {                                                                                   \
    typedef boost::container::allocator_traits alloc_traits;                      \
-   typedef typename allocator_traits::size_type size_type;                       \
-   typedef typename allocator_traits::value_type value_type;                     \
-   typedef typename advanced_insert_aux_int::difference_type              \
-      difference_type;                                                              \
+   typedef typename alloc_traits::size_type size_type;                              \
+   typedef typename alloc_traits::value_type value_type;                            \
                                                                                     \
-   BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_non_movable_emplace, n), arg)      \
-      ( A &a BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _) )          \
+   BOOST_PP_CAT(insert_non_movable_emplace_proxy_arg, N)                            \
+      ( A &a BOOST_PP_ENUM_TRAILING(N, BOOST_CONTAINER_PP_PARAM_LIST, _) )          \
       : a_(a)                                                                       \
-      , used_(false)                                                                \
-      BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_INIT, _)                   \
-    {}                                                                              \
+      BOOST_PP_ENUM_TRAILING(N, BOOST_CONTAINER_PP_PARAM_INIT, _)                   \
+   {}                                                                               \
                                                                                     \
-   virtual void copy_remaining_to(Iterator)                                         \
-   {  BOOST_ASSERT(false);   }                                                      \
-                                                                                    \
-   virtual void uninitialized_copy_remaining_to(Iterator p)                         \
+   void uninitialized_copy_n_and_update(Iterator p, size_type n)                    \
    {                                                                                \
-      if(!this->used_){                                                             \
-         alloc_traits::construct                                                    \
-            ( this->a_                                                              \
-            , container_detail::to_raw_pointer(&*p)                                 \
-            BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _)         \
-            );                                                                      \
-         this->used_ = true;                                                        \
-      }                                                                             \
+      BOOST_ASSERT(n == 1); (void)n;                                                \
+      alloc_traits::construct                                                       \
+         ( this->a_                                                                 \
+         , container_detail::to_raw_pointer(&*p)                                    \
+         BOOST_PP_ENUM_TRAILING(N, BOOST_CONTAINER_PP_MEMBER_FORWARD, _)            \
+         );                                                                         \
    }                                                                                \
                                                                                     \
-   virtual void uninitialized_copy_some_and_update                                  \
-      (Iterator p, difference_type division_count, bool first_n)                    \
-   {                                                                                \
-      BOOST_ASSERT(division_count <=1);                                             \
-      if((first_n && division_count == 1) || (!first_n && division_count == 0)){    \
-         if(!this->used_){                                                          \
-            alloc_traits::construct                                                 \
-               ( this->a_                                                           \
-               , container_detail::to_raw_pointer(&*p)                              \
-               BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _)      \
-               );                                                                   \
-            this->used_ = true;                                                     \
-         }                                                                          \
-      }                                                                             \
-   }                                                                                \
-                                                                                    \
-   virtual void copy_some_and_update(Iterator, difference_type, bool)               \
+   void copy_n_and_update(Iterator, size_type)                                      \
    {  BOOST_ASSERT(false);   }                                                      \
                                                                                     \
+   protected:                                                                       \
    A &a_;                                                                           \
-   bool used_;                                                                      \
-   BOOST_PP_REPEAT(n, BOOST_CONTAINER_PP_PARAM_DEFINE, _)                           \
+   BOOST_PP_REPEAT(N, BOOST_CONTAINER_PP_PARAM_DEFINE, _)                           \
 };                                                                                  \
                                                                                     \
-template        \
-struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)              \
-   : BOOST_PP_CAT(BOOST_PP_CAT(                                                     \
-      advanced_insert_aux_non_movable_emplace, n), arg)                             \
-         < A, Iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P) >                        \
+template        \
+struct BOOST_PP_CAT(insert_emplace_proxy_arg, N)                                    \
+   : BOOST_PP_CAT(insert_non_movable_emplace_proxy_arg, N)                          \
+         < A, Iterator BOOST_PP_ENUM_TRAILING_PARAMS(N, P) >                        \
 {                                                                                   \
-   typedef BOOST_PP_CAT(BOOST_PP_CAT(                                               \
-      advanced_insert_aux_non_movable_emplace, n), arg)                             \
-          base_t;                 \
+   typedef BOOST_PP_CAT(insert_non_movable_emplace_proxy_arg, N)                    \
+          base_t;                 \
    typedef typename base_t::value_type       value_type;                            \
-   typedef typename base_t::difference_type  difference_type;                       \
+   typedef typename base_t::size_type  size_type;                                   \
    typedef boost::container::allocator_traits alloc_traits;                      \
                                                                                     \
-   BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)                  \
-      ( A &a BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _) )          \
-      : base_t(a BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) )   \
-    {}                                                                              \
+   BOOST_PP_CAT(insert_emplace_proxy_arg, N)                                        \
+      ( A &a BOOST_PP_ENUM_TRAILING(N, BOOST_CONTAINER_PP_PARAM_LIST, _) )          \
+      : base_t(a BOOST_PP_ENUM_TRAILING(N, BOOST_CONTAINER_PP_PARAM_FORWARD, _) )   \
+   {}                                                                               \
                                                                                     \
-   virtual void copy_remaining_to(Iterator p)                                       \
+   void copy_n_and_update(Iterator p, size_type n)                                  \
    {                                                                                \
-      if(!this->used_){                                                             \
-         aligned_storage::value> v;    \
-         value_type *vp = static_cast(static_cast(&v));       \
-         alloc_traits::construct(this->a_, vp                                       \
-            BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _));       \
-         scoped_destructor d(this->a_, vp);                                      \
+      BOOST_ASSERT(n == 1); (void)n;                                                \
+      aligned_storage::value> v;       \
+      value_type *vp = static_cast(static_cast(&v));          \
+      alloc_traits::construct(this->a_, vp                                          \
+         BOOST_PP_ENUM_TRAILING(N, BOOST_CONTAINER_PP_MEMBER_FORWARD, _));          \
+      BOOST_TRY{                                                                    \
          *p = ::boost::move(*vp);                                                   \
-         d.release();                                                               \
-         this->used_ = true;                                                        \
       }                                                                             \
-   }                                                                                \
-                                                                                    \
-   virtual void copy_some_and_update                                                \
-      (Iterator p, difference_type division_count, bool first_n)                    \
-   {                                                                                \
-      BOOST_ASSERT(division_count <=1);                                             \
-      if((first_n && division_count == 1) || (!first_n && division_count == 0)){    \
-         if(!this->used_){                                                          \
-            aligned_storage::value> v; \
-            value_type *vp = static_cast(static_cast(&v));    \
-            alloc_traits::construct(this->a_, vp                                    \
-               BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _));    \
-            scoped_destructor d(this->a_, vp);                                   \
-            *p = ::boost::move(*vp);                                                \
-            d.release();                                                            \
-            this->used_ = true;                                                     \
-         }                                                                          \
+      BOOST_CATCH(...){                                                             \
+         alloc_traits::destroy(this->a_, vp);                                       \
+         BOOST_RETHROW                                                              \
       }                                                                             \
+      BOOST_CATCH_END                                                               \
+      alloc_traits::destroy(this->a_, vp);                                          \
    }                                                                                \
 };                                                                                  \
 //!
-
 #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
 #include BOOST_PP_LOCAL_ITERATE()
 
diff --git a/include/boost/container/detail/allocator_version_traits.hpp b/include/boost/container/detail/allocator_version_traits.hpp
new file mode 100644
index 0000000..d69e61b
--- /dev/null
+++ b/include/boost/container/detail/allocator_version_traits.hpp
@@ -0,0 +1,163 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2012-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)
+//
+// See http://www.boost.org/libs/container for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_CONTAINER_DETAIL_ALLOCATOR_VERSION_TRAITS_HPP
+#define BOOST_CONTAINER_DETAIL_ALLOCATOR_VERSION_TRAITS_HPP
+
+#if (defined _MSC_VER) && (_MSC_VER >= 1200)
+#  pragma once
+#endif
+
+#include 
+#include 
+#include              //allocator_traits
+#include  //multiallocation_chain
+#include           //version_type
+#include        //allocation_type
+#include                    //integral_constant
+#include                //pointer_traits
+#include                                           //pair
+#include                                         //runtime_error
+#include            //BOOST_TRY
+
+namespace boost {
+namespace container {
+namespace container_detail {
+
+template::value>
+struct allocator_version_traits
+{
+   typedef ::boost::container::container_detail::integral_constant
+       alloc_version;
+
+   typedef typename Allocator::multiallocation_chain multiallocation_chain;
+
+   typedef typename boost::container::allocator_traits::pointer    pointer;
+   typedef typename boost::container::allocator_traits::size_type  size_type;
+
+   //Node allocation interface
+   static pointer allocate_one(Allocator &a)
+   {  return a.allocate_one();   }
+
+   static void deallocate_one(Allocator &a, const pointer &p)
+   {  a.deallocate_one(p);   }
+
+   static void allocate_individual(Allocator &a, size_type n, multiallocation_chain &m)
+   {  return a.allocate_individual(n, m);   }
+
+   static void deallocate_individual(Allocator &a, multiallocation_chain &holder)
+   {  a.deallocate_individual(holder);   }
+
+   static std::pair
+      allocation_command(Allocator &a, allocation_type command,
+                         size_type limit_size, size_type preferred_size,
+                         size_type &received_size, const pointer &reuse)
+   {
+      return a.allocation_command
+         (command, limit_size, preferred_size, received_size, reuse);
+   }
+};
+
+template
+struct allocator_version_traits
+{
+   typedef ::boost::container::container_detail::integral_constant
+       alloc_version;
+
+   typedef typename boost::container::allocator_traits::pointer    pointer;
+   typedef typename boost::container::allocator_traits::size_type  size_type;
+   typedef typename boost::container::allocator_traits::value_type value_type;
+
+   typedef typename boost::intrusive::pointer_traits::
+         template rebind_pointer::type                void_ptr;
+   typedef container_detail::basic_multiallocation_chain
+                                                  multialloc_cached_counted;
+   typedef boost::container::container_detail::
+      transform_multiallocation_chain
+         < multialloc_cached_counted, value_type>           multiallocation_chain;
+
+   //Node allocation interface
+   static pointer allocate_one(Allocator &a)
+   {  return a.allocate(1);   }
+
+   static void deallocate_one(Allocator &a, const pointer &p)
+   {  a.deallocate(p, 1);   }
+
+   static void deallocate_individual(Allocator &a, multiallocation_chain &holder)
+   {
+      while(!holder.empty()){
+         a.deallocate(holder.pop_front(), 1);
+      }
+   }
+
+   struct allocate_individual_rollback
+   {
+      allocate_individual_rollback(Allocator &a, multiallocation_chain &chain)
+         : mr_a(a), mp_chain(&chain)
+      {}
+
+      ~allocate_individual_rollback()
+      {
+         if(mp_chain)
+            allocator_version_traits::deallocate_individual(mr_a, *mp_chain);
+      }
+
+      void release()
+      {
+         mp_chain = 0;
+      }
+
+      Allocator &mr_a;
+      multiallocation_chain * mp_chain;
+   };
+
+   static void allocate_individual(Allocator &a, size_type n, multiallocation_chain &m)
+   {
+      allocate_individual_rollback rollback(a, m);
+      while(n--){
+         m.push_front(a.allocate(1));
+      }
+      rollback.release();
+   }
+
+   static std::pair
+      allocation_command(Allocator &a, allocation_type command,
+                         size_type, size_type preferred_size,
+                         size_type &received_size, const pointer &)
+   {
+      std::pair ret(pointer(), false);
+      if(!(command & allocate_new)){
+         if(!(command & nothrow_allocation)){
+            throw std::runtime_error("version 1 allocator without allocate_new flag");
+         }
+      }
+      else{
+         received_size = preferred_size;
+         BOOST_TRY{
+            ret.first = a.allocate(received_size);
+         }
+         BOOST_CATCH(...){
+            if(!(command & nothrow_allocation)){
+               BOOST_RETHROW
+            }
+         }
+         BOOST_CATCH_END
+      }
+      return ret;
+   }
+};
+
+}  //namespace container_detail {
+}  //namespace container {
+}  //namespace boost {
+
+#include 
+
+#endif // ! defined(BOOST_CONTAINER_DETAIL_ALLOCATOR_VERSION_TRAITS_HPP)
diff --git a/include/boost/container/detail/destroyers.hpp b/include/boost/container/detail/destroyers.hpp
index befae3f..f9bfd86 100644
--- a/include/boost/container/detail/destroyers.hpp
+++ b/include/boost/container/detail/destroyers.hpp
@@ -188,13 +188,17 @@ struct scoped_destructor_n
 
    void increment_size_backwards(size_type inc)
    {  m_n += inc;   m_p -= inc;  }
+
+   void shrink_forward(size_type inc)
+   {  m_n -= inc;   m_p += inc;  }
   
    ~scoped_destructor_n()
    {
       if(!m_p) return;
       value_type *raw_ptr = container_detail::to_raw_pointer(m_p);
-      for(size_type i = 0; i < m_n; ++i, ++raw_ptr)
+      while(m_n--){
          AllocTraits::destroy(m_a, raw_ptr);
+      }
    }
 
    private:
@@ -323,7 +327,7 @@ class allocator_destroyer_and_chain_builder
    void operator()(const typename A::pointer &p)
    {
       allocator_traits::destroy(a_, container_detail::to_raw_pointer(p));
-      c_.push_front(p);
+      c_.push_back(p);
    }
 };
 
@@ -348,8 +352,7 @@ class allocator_multialloc_chain_node_deallocator
 
    ~allocator_multialloc_chain_node_deallocator()
    {
-      if(!c_.empty())
-         a_.deallocate_individual(boost::move(c_));
+      a_.deallocate_individual(c_);
    }
 };
 
diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp
index 9146fd4..2af12d4 100644
--- a/include/boost/container/detail/flat_tree.hpp
+++ b/include/boost/container/detail/flat_tree.hpp
@@ -25,7 +25,7 @@
 #include 
 
 #include 
-#include 
+#include 
 
 #include 
 #include 
@@ -48,7 +48,7 @@ class flat_tree_value_compare
    typedef Value              first_argument_type;
    typedef Value              second_argument_type;
    typedef bool               return_type;
-   public:
+   public:    
    flat_tree_value_compare()
       : Compare()
    {}
@@ -65,7 +65,7 @@ class flat_tree_value_compare
 
    const Compare &get_comp() const
       {  return *this;  }
-
+  
    Compare &get_comp()
       {  return *this;  }
 };
@@ -238,7 +238,7 @@ class flat_tree
    flat_tree&  operator=(BOOST_RV_REF(flat_tree) mx)
    {  m_data = boost::move(mx.m_data); return *this;  }
 
-   public:
+   public:   
    // accessors:
    Compare key_comp() const
    { return this->m_data.get_comp(); }
@@ -441,17 +441,17 @@ class flat_tree
 
       //Prereserve all memory so that iterators are not invalidated
       this->reserve(this->size()+len);
-      const const_iterator beg(this->cbegin());
-      const_iterator pos(beg);
+      const const_iterator b(this->cbegin());
+      const_iterator pos(b);
       //Loop in burst sizes
       while(len){
          const size_type burst = len < BurstSize ? len : BurstSize;
-         const const_iterator cend_(this->cend());
+         const const_iterator ce(this->cend());
          len -= burst;
          for(size_type i = 0; i != burst; ++i){
             //Get the insertion position for each key
-            pos = const_cast(*this).priv_upper_bound(pos, cend_, KeyOfValue()(*first));
-            positions[i] = static_cast(pos - beg);
+            pos = const_cast(*this).priv_upper_bound(pos, ce, KeyOfValue()(*first));
+            positions[i] = static_cast(pos - b);
             ++first;
          }
          //Insert all in a single step in the precalculated positions
@@ -489,22 +489,22 @@ class flat_tree
 
       //Prereserve all memory so that iterators are not invalidated
       this->reserve(this->size()+len);
-      const const_iterator beg(this->cbegin());
-      const_iterator pos(beg);
+      const const_iterator b(this->cbegin());
+      const_iterator pos(b);
       const value_compare &value_comp = this->m_data;
       skips[0u] = 0u;
       //Loop in burst sizes
       while(len){
          const size_type burst = len < BurstSize ? len : BurstSize;
          size_type unique_burst = 0u;
-         const const_iterator cend_(this->cend());
+         const const_iterator ce(this->cend());
          while(unique_burst < burst && len > 0){
             //Get the insertion position for each key
             const value_type & val = *first++;
             --len;
-            pos = const_cast(*this).priv_lower_bound(pos, cend_, KeyOfValue()(val));
+            pos = const_cast(*this).priv_lower_bound(pos, ce, KeyOfValue()(val));
             //Check if already present
-            if(pos != cend_ && !value_comp(val, *pos)){
+            if(pos != ce && !value_comp(val, *pos)){
                if(unique_burst > 0){
                   ++skips[unique_burst-1];
                }
@@ -512,7 +512,7 @@ class flat_tree
             }
 
             //If not present, calculate position
-            positions[unique_burst] = static_cast(pos - beg);
+            positions[unique_burst] = static_cast(pos - b);
             skips[unique_burst++] = 0u;
          }
          if(unique_burst){
@@ -692,22 +692,22 @@ class flat_tree
    // set operations:
    iterator find(const key_type& k)
    {
-      const Compare &key_comp_ = this->m_data.get_comp();
+      const Compare &key_cmp = this->m_data.get_comp();
       iterator i = this->lower_bound(k);
 
-      if (i != this->end() && key_comp_(k, KeyOfValue()(*i))){
-         i = this->end();
+      if (i != this->end() && key_cmp(k, KeyOfValue()(*i))){ 
+         i = this->end(); 
       }
       return i;
    }
 
    const_iterator find(const key_type& k) const
    {
-      const Compare &key_comp_ = this->m_data.get_comp();
+      const Compare &key_cmp = this->m_data.get_comp();
       const_iterator i = this->lower_bound(k);
 
-      if (i != this->end() && key_comp_(k, KeyOfValue()(*i))){
-         i = this->end();
+      if (i != this->end() && key_cmp(k, KeyOfValue()(*i))){ 
+         i = this->end(); 
       }
       return i;
    }
@@ -737,11 +737,11 @@ class flat_tree
    std::pair equal_range(const key_type& k) const
    {  return this->priv_equal_range(this->begin(), this->end(), k);  }
 
-   size_type capacity() const
+   size_type capacity() const          
    { return this->m_data.m_vect.capacity(); }
 
-   void reserve(size_type count_)
-   { this->m_data.m_vect.reserve(count_);   }
+   void reserve(size_type cnt)      
+   { this->m_data.m_vect.reserve(cnt);   }
 
    private:
    struct insert_commit_data
@@ -780,13 +780,13 @@ class flat_tree
    }
 
    std::pair priv_insert_unique_prepare
-      (const_iterator beg, const_iterator end_, const value_type& val, insert_commit_data &commit_data)
+      (const_iterator b, const_iterator e, const value_type& val, insert_commit_data &commit_data)
    {
       const value_compare &value_comp  = this->m_data;
-      commit_data.position = this->priv_lower_bound(beg, end_, KeyOfValue()(val));
+      commit_data.position = this->priv_lower_bound(b, e, KeyOfValue()(val));
       return std::pair
          ( *reinterpret_cast(&commit_data.position)
-         , commit_data.position == end_ || value_comp(val, *commit_data.position));
+         , commit_data.position == e || value_comp(val, *commit_data.position));
    }
 
    std::pair priv_insert_unique_prepare
@@ -854,7 +854,7 @@ class flat_tree
    RanIt priv_lower_bound(RanIt first, RanIt last,
                           const key_type & key) const
    {
-      const Compare &key_comp_ = this->m_data.get_comp();
+      const Compare &key_cmp = this->m_data.get_comp();
       KeyOfValue key_extract;
       difference_type len = last - first, half;
       RanIt middle;
@@ -864,7 +864,7 @@ class flat_tree
          middle = first;
          middle += half;
 
-         if (key_comp_(key_extract(*middle), key)) {
+         if (key_cmp(key_extract(*middle), key)) {
             ++middle;
             first = middle;
             len = len - half - 1;
@@ -879,7 +879,7 @@ class flat_tree
    RanIt priv_upper_bound(RanIt first, RanIt last,
                           const key_type & key) const
    {
-      const Compare &key_comp_ = this->m_data.get_comp();
+      const Compare &key_cmp = this->m_data.get_comp();
       KeyOfValue key_extract;
       difference_type len = last - first, half;
       RanIt middle;
@@ -889,12 +889,12 @@ class flat_tree
          middle = first;
          middle += half;
 
-         if (key_comp_(key, key_extract(*middle))) {
+         if (key_cmp(key, key_extract(*middle))) {
             len = half;
          }
          else{
             first = ++middle;
-            len = len - half - 1;
+            len = len - half - 1; 
          }
       }
       return first;
@@ -904,7 +904,7 @@ class flat_tree
    std::pair
       priv_equal_range(RanIt first, RanIt last, const key_type& key) const
    {
-      const Compare &key_comp_ = this->m_data.get_comp();
+      const Compare &key_cmp = this->m_data.get_comp();
       KeyOfValue key_extract;
       difference_type len = last - first, half;
       RanIt middle, left, right;
@@ -914,12 +914,12 @@ class flat_tree
          middle = first;
          middle += half;
 
-         if (key_comp_(key_extract(*middle), key)){
+         if (key_cmp(key_extract(*middle), key)){
             first = middle;
             ++first;
             len = len - half - 1;
          }
-         else if (key_comp_(key, key_extract(*middle))){
+         else if (key_cmp(key, key_extract(*middle))){
             len = half;
          }
          else {
@@ -1033,7 +1033,7 @@ template 
 struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor_after_move::value && has_trivial_destructor_after_move::value;
 };
 */
 }  //namespace boost {
diff --git a/include/boost/container/detail/iterators.hpp b/include/boost/container/detail/iterators.hpp
index 3e77931..f58c4ce 100644
--- a/include/boost/container/detail/iterators.hpp
+++ b/include/boost/container/detail/iterators.hpp
@@ -20,7 +20,7 @@
 
 #include "config_begin.hpp"
 #include 
-#include 
+#include 
 #include 
 #include 
 
diff --git a/include/boost/container/detail/multiallocation_chain.hpp b/include/boost/container/detail/multiallocation_chain.hpp
index 5752083..2e29f9c 100644
--- a/include/boost/container/detail/multiallocation_chain.hpp
+++ b/include/boost/container/detail/multiallocation_chain.hpp
@@ -19,7 +19,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 namespace boost {
 namespace container {
@@ -50,41 +50,38 @@ class basic_multiallocation_chain
    typedef typename boost::intrusive::
       pointer_traits                              node_ptr_traits;
 
-   static node & build_node(const VoidPointer &p)
-   {
-      return *::new (static_cast(static_cast(container_detail::to_raw_pointer(p)))) node;
-   }
+   static node & to_node(const VoidPointer &p)
+   {  return *static_cast(static_cast(container_detail::to_raw_pointer(p)));  }
 
-   static VoidPointer destroy_node(node &n)
-   {
-      VoidPointer retptr = node_ptr_traits::pointer_to(n);
-      n.~node();
-      return retptr;
-   }
+   static VoidPointer from_node(node &n)
+   {  return node_ptr_traits::pointer_to(n);  }
 
-   static node_ptr to_node_ptr(VoidPointer p)
+   static node_ptr to_node_ptr(const VoidPointer &p)
    {  return node_ptr_traits::static_cast_from(p);   }
 
    BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_multiallocation_chain)
 
    public:
 
-   typedef VoidPointer  void_pointer;
-   typedef typename slist_impl_t::iterator iterator;
-   typedef typename slist_impl_t::size_type size_type;
+   typedef VoidPointer                       void_pointer;
+   typedef typename slist_impl_t::iterator   iterator;
+   typedef typename slist_impl_t::size_type  size_type;
 
    basic_multiallocation_chain()
       :  slist_impl_()
    {}
 
+   basic_multiallocation_chain(const void_pointer &b, const void_pointer &before_e, size_type n)
+      :  slist_impl_(to_node_ptr(b), to_node_ptr(before_e), n)
+   {}
+
    basic_multiallocation_chain(BOOST_RV_REF(basic_multiallocation_chain) other)
-      :  slist_impl_()
-   {  slist_impl_.swap(other.slist_impl_); }
+      :  slist_impl_(::boost::move(other.slist_impl_))
+   {}
 
    basic_multiallocation_chain& operator=(BOOST_RV_REF(basic_multiallocation_chain) other)
    {
-      basic_multiallocation_chain tmp(boost::move(other));
-      this->swap(tmp);
+      slist_impl_ = ::boost::move(other.slist_impl_);
       return *this;
    }
 
@@ -110,43 +107,54 @@ class basic_multiallocation_chain
    {  slist_impl_.clear(); }
 
    iterator insert_after(iterator it, void_pointer m)
-   {  return slist_impl_.insert_after(it, build_node(m));   }
+   {  return slist_impl_.insert_after(it, to_node(m));   }
 
-   void push_front(void_pointer m)
-   {  return slist_impl_.push_front(build_node(m));  }
+   void push_front(const void_pointer &m)
+   {  return slist_impl_.push_front(to_node(m));  }
 
-   void push_back(void_pointer m)
-   {  return slist_impl_.push_back(build_node(m));   }
+   void push_back(const void_pointer &m)
+   {  return slist_impl_.push_back(to_node(m));   }
 
    void_pointer pop_front()
    {
       node & n = slist_impl_.front();
-      void_pointer ret = destroy_node(n);
+      void_pointer ret = from_node(n);
       slist_impl_.pop_front();
       return ret;
    }
 
-   void splice_after(iterator after_this, basic_multiallocation_chain &x, iterator before_begin_, iterator before_end)
-   {  slist_impl_.splice_after(after_this, x.slist_impl_, before_begin_, before_end);   }
-
-   void splice_after(iterator after_this, basic_multiallocation_chain &x, iterator before_begin_, iterator before_end, size_type n)
-   {  slist_impl_.splice_after(after_this, x.slist_impl_, before_begin_, before_end, n);   }
+   void splice_after(iterator after_this, basic_multiallocation_chain &x, iterator before_b, iterator before_e, size_type n)
+   {  slist_impl_.splice_after(after_this, x.slist_impl_, before_b, before_e, n);   }
 
    void splice_after(iterator after_this, basic_multiallocation_chain &x)
    {  slist_impl_.splice_after(after_this, x.slist_impl_);   }
 
-   void incorporate_after(iterator after_this, void_pointer begin_ , iterator before_end)
+   void erase_after(iterator before_b, iterator e, size_type n)
+   {  slist_impl_.erase_after(before_b, e, n);   }
+
+   void_pointer incorporate_after(iterator after_this, const void_pointer &b, size_type unit_bytes, size_type num_units)
    {
-      slist_impl_.incorporate_after(after_this, to_node_ptr(begin_), to_node_ptr(before_end));
+      typedef typename boost::intrusive::pointer_traits char_pointer_traits;
+      char_ptr elem = char_pointer_traits::static_cast_from(b);
+      if(num_units){
+         char_ptr prev_elem = elem;
+         elem += unit_bytes;
+         for(size_type i = 0; i != num_units-1; ++i, elem += unit_bytes){
+            ::new (container_detail::to_raw_pointer(prev_elem)) void_pointer(elem);
+            prev_elem = elem;
+         }
+         slist_impl_.incorporate_after(after_this, to_node_ptr(b), to_node_ptr(prev_elem), num_units);
+      }
+      return elem;
    }
 
-   void incorporate_after(iterator after_this, void_pointer begin_, void_pointer before_end, size_type n)
-   {  slist_impl_.incorporate_after(after_this, to_node_ptr(begin_), to_node_ptr(before_end), n);   }
+   void incorporate_after(iterator after_this, void_pointer b, void_pointer before_e, size_type n)
+   {  slist_impl_.incorporate_after(after_this, to_node_ptr(b), to_node_ptr(before_e), n);   }
 
    void swap(basic_multiallocation_chain &x)
    {  slist_impl_.swap(x.slist_impl_);   }
 
-   static iterator iterator_to(void_pointer p)
+   static iterator iterator_to(const void_pointer &p)
    {  return slist_impl_t::s_iterator_to(to_node(p));   }
 
    std::pair extract_data()
@@ -170,11 +178,13 @@ struct cast_functor
 
 template
 class transform_multiallocation_chain
+   : public MultiallocationChain
 {
    private:
    BOOST_MOVABLE_BUT_NOT_COPYABLE(transform_multiallocation_chain)
+   //transform_multiallocation_chain(const transform_multiallocation_chain &);
+   //transform_multiallocation_chain & operator=(const transform_multiallocation_chain &);
 
-   MultiallocationChain   holder_;
    typedef typename MultiallocationChain::void_pointer   void_pointer;
    typedef typename boost::intrusive::pointer_traits
                                            void_pointer_traits;
@@ -193,39 +203,41 @@ class transform_multiallocation_chain
    typedef typename MultiallocationChain::size_type      size_type;
 
    transform_multiallocation_chain()
-      : holder_()
+      : MultiallocationChain()
    {}
 
    transform_multiallocation_chain(BOOST_RV_REF(transform_multiallocation_chain) other)
-      : holder_()
-   {  this->swap(other); }
+      : MultiallocationChain(::boost::move(static_cast(other)))
+   {}
 
    transform_multiallocation_chain(BOOST_RV_REF(MultiallocationChain) other)
-      : holder_(boost::move(other))
+      : MultiallocationChain(::boost::move(static_cast(other)))
    {}
 
    transform_multiallocation_chain& operator=(BOOST_RV_REF(transform_multiallocation_chain) other)
    {
-      transform_multiallocation_chain tmp(boost::move(other));
-      this->swap(tmp);
-      return *this;
+      return static_cast
+         (this->MultiallocationChain::operator=(::boost::move(static_cast(other))));
    }
-
-   void push_front(pointer mem)
+/*
+   void push_front(const pointer &mem)
    {  holder_.push_front(mem);  }
 
+   void push_back(const pointer &mem)
+   {  return holder_.push_back(mem);   }
+
    void swap(transform_multiallocation_chain &other_chain)
    {  holder_.swap(other_chain.holder_); }
 
-   void splice_after(iterator after_this, transform_multiallocation_chain &x, iterator before_begin_, iterator before_end, size_type n)
-   {  holder_.splice_after(after_this.base(), x.holder_, before_begin_.base(), before_end.base(), n);  }
-
-   void incorporate_after(iterator after_this, pointer begin_, pointer before_end, size_type n)
-   {  holder_.incorporate_after(after_this.base(), begin_, before_end, n);  }
+   void splice_after(iterator after_this, transform_multiallocation_chain &x, iterator before_b, iterator before_e, size_type n)
+   {  holder_.splice_after(after_this.base(), x.holder_, before_b.base(), before_e.base(), n);  }
 
+   void incorporate_after(iterator after_this, pointer b, pointer before_e, size_type n)
+   {  holder_.incorporate_after(after_this.base(), b, before_e, n);  }
+*/
    pointer pop_front()
-   {  return cast(holder_.pop_front());  }
-
+   {  return cast(this->MultiallocationChain::pop_front());  }
+/*
    bool empty() const
    {  return holder_.empty(); }
 
@@ -246,23 +258,21 @@ class transform_multiallocation_chain
 
    void clear()
    {  holder_.clear(); }
-
+*/
    iterator insert_after(iterator it, pointer m)
-   {  return iterator(holder_.insert_after(it.base(), m)); }
+   {  return iterator(this->MultiallocationChain::insert_after(it.base(), m)); }
 
-   static iterator iterator_to(pointer p)
+   static iterator iterator_to(const pointer &p)
    {  return iterator(MultiallocationChain::iterator_to(p));  }
 
    std::pair extract_data()
    {
-      std::pair data(holder_.extract_data());
+      std::pair data(this->MultiallocationChain::extract_data());
       return std::pair(cast(data.first), cast(data.second));
    }
-
-   MultiallocationChain extract_multiallocation_chain()
-   {
-      return MultiallocationChain(boost::move(holder_));
-   }
+/*
+   MultiallocationChain &extract_multiallocation_chain()
+   {  return holder_;  }*/
 };
 
 }}}
diff --git a/include/boost/container/detail/node_alloc_holder.hpp b/include/boost/container/detail/node_alloc_holder.hpp
index 68048bc..7d851c0 100644
--- a/include/boost/container/detail/node_alloc_holder.hpp
+++ b/include/boost/container/detail/node_alloc_holder.hpp
@@ -21,7 +21,7 @@
 #include 
 #include 
 
-#include 
+#include 
 #include 
 
 #include 
@@ -30,6 +30,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #ifndef BOOST_CONTAINER_PERFECT_FORWARDING
 #include 
@@ -89,6 +91,7 @@ struct node_alloc_holder
    typedef typename ICont::const_iterator             icont_citerator;
    typedef allocator_destroyer             Destroyer;
    typedef allocator_traits                NodeAllocTraits;
+   typedef allocator_version_traits        AllocVersionTraits;
 
    private:
    BOOST_COPYABLE_AND_MOVABLE(node_alloc_holder)
@@ -151,22 +154,10 @@ struct node_alloc_holder
    {  return allocator_traits_type::max_size(this->node_alloc());  }
 
    NodePtr allocate_one()
-   {  return this->allocate_one(alloc_version());   }
-
-   NodePtr allocate_one(allocator_v1)
-   {  return this->node_alloc().allocate(1);   }
-
-   NodePtr allocate_one(allocator_v2)
-   {  return this->node_alloc().allocate_one();   }
+   {  return AllocVersionTraits::allocate_one(this->node_alloc());   }
 
    void deallocate_one(const NodePtr &p)
-   {  return this->deallocate_one(p, alloc_version());   }
-
-   void deallocate_one(const NodePtr &p, allocator_v1)
-   {  this->node_alloc().deallocate(p, 1);   }
-
-   void deallocate_one(const NodePtr &p, allocator_v2)
-   {  this->node_alloc().deallocate_one(p);   }
+   {  AllocVersionTraits::deallocate_one(this->node_alloc(), p);  }
 
    #ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
@@ -235,40 +226,51 @@ struct node_alloc_holder
    }
 
    template
-   FwdIterator allocate_many_and_construct
+   void allocate_many_and_construct
       (FwdIterator beg, difference_type n, Inserter inserter)
    {
-      if(n){
-         typedef typename NodeAlloc::multiallocation_chain multiallocation_chain;
+      /*
+      NodePtr p = this->allocate_one();
+      Deallocator node_deallocator(p, this->node_alloc());
+      ::boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->m_data), it);
+      node_deallocator.release();
+      //This does not throw
+      typedef typename Node::hook_type hook_type;
+      ::new(static_cast(container_detail::to_raw_pointer(p))) hook_type;
+      return (p);
+      */
+      typedef typename NodeAlloc::multiallocation_chain multiallocation_chain;
 
-         //Try to allocate memory in a single block
-         multiallocation_chain mem(this->node_alloc().allocate_individual(n));
-         int constructed = 0;
-         Node *p = 0;
-         BOOST_TRY{
-               for(difference_type i = 0; i < n; ++i, ++beg, --constructed){
-               p = container_detail::to_raw_pointer(mem.pop_front());
-               //This can throw
-               constructed = 0;
-               boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->m_data), beg);
-               ++constructed;
-               //This does not throw
-               typedef typename Node::hook_type hook_type;
-               ::new(static_cast(container_detail::to_raw_pointer(p))) hook_type;
-               //This can throw in some containers (predicate might throw)
-               inserter(*p);
-            }
+      //Try to allocate memory in a single block
+      typedef typename multiallocation_chain::iterator multialloc_iterator;
+      multiallocation_chain mem;
+      this->node_alloc().allocate_individual(n, mem);
+      multialloc_iterator itbeg(mem.begin()), itlast(mem.last());
+      mem.clear();
+      Node *p = 0;
+      NodeAlloc &nalloc = this->node_alloc();
+      BOOST_TRY{
+         while(n--){
+            p = container_detail::to_raw_pointer(&*itbeg);
+            ++itbeg;
+            //This can throw
+            Deallocator node_deallocator(p, nalloc);
+            boost::container::construct_in_place(nalloc, container_detail::addressof(p->m_data), beg);
+            ++beg;
+            node_deallocator.release();
+            //This does not throw
+            typedef typename Node::hook_type hook_type;
+            ::new(static_cast(p)) hook_type;
+            //This can throw in some containers (predicate might throw)
+            inserter(*p);
          }
-         BOOST_CATCH(...){
-            if(constructed){
-               allocator_traits::destroy(this->node_alloc(), container_detail::to_raw_pointer(p));
-            }
-            this->node_alloc().deallocate_individual(boost::move(mem));
-            BOOST_RETHROW
-         }
-         BOOST_CATCH_END
       }
-      return beg;
+      BOOST_CATCH(...){
+         mem.incorporate_after(mem.last(), &*itbeg, &*itlast, n);
+         this->node_alloc().deallocate_individual(mem);
+         BOOST_RETHROW
+      }
+      BOOST_CATCH_END
    }
 
    void clear(allocator_v1)
@@ -281,7 +283,7 @@ struct node_alloc_holder
       this->icont().clear_and_dispose(builder);
       //BOOST_STATIC_ASSERT((::boost::has_move_emulation_enabled::value == true));
       if(!chain.empty())
-         this->node_alloc().deallocate_individual(boost::move(chain));
+         this->node_alloc().deallocate_individual(chain);
    }
 
    icont_iterator erase_range(const icont_iterator &first, const icont_iterator &last, allocator_v1)
@@ -289,8 +291,13 @@ struct node_alloc_holder
 
    icont_iterator erase_range(const icont_iterator &first, const icont_iterator &last, allocator_v2)
    {
-      allocator_multialloc_chain_node_deallocator chain_holder(this->node_alloc());
-      return this->icont().erase_and_dispose(first, last, chain_holder.get_chain_builder());
+      typedef typename NodeAlloc::multiallocation_chain multiallocation_chain;
+      NodeAlloc & nalloc = this->node_alloc();
+      multiallocation_chain chain;
+      allocator_destroyer_and_chain_builder chain_builder(nalloc, chain);
+      icont_iterator ret_it = this->icont().erase_and_dispose(first, last, chain_builder);
+      nalloc.deallocate_individual(chain);
+      return ret_it;
    }
 
    template
diff --git a/include/boost/container/detail/node_pool_impl.hpp b/include/boost/container/detail/node_pool_impl.hpp
index 63c1278..53e35ac 100644
--- a/include/boost/container/detail/node_pool_impl.hpp
+++ b/include/boost/container/detail/node_pool_impl.hpp
@@ -26,10 +26,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include    //std::unary_function
 
+
 namespace boost {
 namespace container {
 namespace container_detail {
@@ -85,19 +87,19 @@ class private_node_pool_impl
    {  return container_detail::to_raw_pointer(mp_segment_mngr_base);  }
 
    void *allocate_node()
-   {  return priv_alloc_node();  }
+   {  return this->priv_alloc_node();  }
   
    //!Deallocates an array pointed by ptr. Never throws
    void deallocate_node(void *ptr)
-   {  priv_dealloc_node(ptr); }
+   {  this->priv_dealloc_node(ptr); }
 
    //!Allocates a singly linked list of n nodes ending in null pointer.
-   multiallocation_chain allocate_nodes(const size_type n)
+   void allocate_nodes(const size_type n, multiallocation_chain &chain)
    {
       //Preallocate all needed blocks to fulfill the request
       size_type cur_nodes = m_freelist.size();
       if(cur_nodes < n){
-         priv_alloc_block(((n - cur_nodes) - 1)/m_nodes_per_block + 1);
+         this->priv_alloc_block(((n - cur_nodes) - 1)/m_nodes_per_block + 1);
       }
 
       //We just iterate the needed nodes to get the last we'll erase
@@ -118,20 +120,18 @@ class private_node_pool_impl
 
       //Now take the last erased node and just splice it in the end
       //of the intrusive list that will be traversed by the multialloc iterator.
-      multiallocation_chain chain;
       chain.incorporate_after(chain.before_begin(), &*first_node, &*last_node, n);
       m_allocated += n;
-      return boost::move(chain);
    }
 
-   void deallocate_nodes(multiallocation_chain chain)
+   void deallocate_nodes(multiallocation_chain &chain)
    {
       typedef typename multiallocation_chain::iterator iterator;
       iterator it(chain.begin()), itend(chain.end());
       while(it != itend){
          void *pElem = &*it;
          ++it;
-         priv_dealloc_node(pElem);
+         this->priv_dealloc_node(pElem);
       }
    }
 
@@ -275,7 +275,7 @@ class private_node_pool_impl
    {
       //If there are no free nodes we allocate a new block
       if (m_freelist.empty())
-         priv_alloc_block();
+         this->priv_alloc_block(1);
       //We take the first free node
       node_t *n = (node_t*)&m_freelist.front();
       m_freelist.pop_front();
@@ -295,14 +295,13 @@ class private_node_pool_impl
    }
 
    //!Allocates several blocks of nodes. Can throw
-   void priv_alloc_block(size_type num_blocks = 1)
+   void priv_alloc_block(size_type num_blocks)
    {
-      if(!num_blocks)
-         return;
+      BOOST_ASSERT(num_blocks > 0);
       size_type blocksize =
          get_rounded_size(m_real_node_size*m_nodes_per_block, (size_type)alignment_of::value);
 
-      try{
+      BOOST_TRY{
          for(size_type i = 0; i != num_blocks; ++i){
             //We allocate a new NodeBlock and put it as first
             //element in the free Node list
@@ -313,15 +312,16 @@ class private_node_pool_impl
 
             //We initialize all Nodes in Node Block to insert
             //them in the free Node list
-            for(size_type i = 0; i < m_nodes_per_block; ++i, pNode += m_real_node_size){
+            for(size_type j = 0; j < m_nodes_per_block; ++j, pNode += m_real_node_size){
                m_freelist.push_front(*new (pNode) node_t);
             }
          }
       }
-      catch(...){
+      BOOST_CATCH(...){
          //to-do: if possible, an efficient way to deallocate allocated blocks
-         throw;
+         BOOST_RETHROW
       }
+      BOOST_CATCH_END
    }
 
    //!Deprecated, use deallocate_free_blocks
diff --git a/include/boost/container/detail/pair.hpp b/include/boost/container/detail/pair.hpp
index d5cd65a..3fd63d4 100644
--- a/include/boost/container/detail/pair.hpp
+++ b/include/boost/container/detail/pair.hpp
@@ -27,7 +27,7 @@
 
 #include    //std::pair
 
-#include 
+#include 
 #include 
 
 #ifndef BOOST_CONTAINER_PERFECT_FORWARDING
diff --git a/include/boost/container/detail/pool_common.hpp b/include/boost/container/detail/pool_common.hpp
index 500b912..983d141 100644
--- a/include/boost/container/detail/pool_common.hpp
+++ b/include/boost/container/detail/pool_common.hpp
@@ -34,7 +34,7 @@ struct node_slist
    typedef slist_hook_t node_t;
 
    typedef typename bi::make_slist
-      , bi::base_hook >::type node_slist_t;
+      , bi::cache_last, bi::base_hook >::type node_slist_t;
 };
 
 template
diff --git a/include/boost/container/detail/preprocessor.hpp b/include/boost/container/detail/preprocessor.hpp
index 599215f..4e175a8 100644
--- a/include/boost/container/detail/preprocessor.hpp
+++ b/include/boost/container/detail/preprocessor.hpp
@@ -17,6 +17,7 @@
 
 #include 
 #include 
+#include 
 
 #ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 //#error "This file is not needed when perfect forwarding is available"
@@ -38,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS 10
 
@@ -97,7 +99,7 @@ const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \
          template
          struct ref_holder
          {
-            ref_holder(T &t)
+            explicit ref_holder(T &t)
                : t_(t)
             {}
             T &t_;
@@ -107,7 +109,7 @@ const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \
          template
          struct ref_holder
          {
-            ref_holder(const T &t)
+            explicit ref_holder(const T &t)
                : t_(t)
             {}
             const T &t_;
@@ -117,7 +119,7 @@ const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \
          template
          struct ref_holder
          {
-            ref_holder(const T &t)
+            explicit ref_holder(const T &t)
                : t_(t)
             {}
             const T &t_;
@@ -127,7 +129,7 @@ const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \
          template
          struct ref_holder
          {
-            ref_holder(T &&t)
+            explicit ref_holder(T &&t)
                : t_(t)
             {}
             T &t_;
@@ -137,10 +139,10 @@ const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \
          template
          struct ref_holder
          {
-            ref_holder(T &&t)
-               : t(t)
+            explicit ref_holder(T &&t)
+               : t_(t)
             {}
-            T &t;
+            T &t_;
             T && get()  { return ::boost::move(t_); }
          };
 
diff --git a/include/boost/container/detail/tree.hpp b/include/boost/container/detail/tree.hpp
index 12342a8..9cb3c9f 100644
--- a/include/boost/container/detail/tree.hpp
+++ b/include/boost/container/detail/tree.hpp
@@ -15,7 +15,7 @@
 #include 
 #include 
 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #ifndef BOOST_CONTAINER_PERFECT_FORWARDING
 #include 
 #endif
@@ -247,19 +248,20 @@ class rbtree
       {
          if(NodePtr p = m_icont.unlink_leftmost_without_rebalance()){
             //First recycle a node (this can't throw)
-            try{
+            BOOST_TRY{
                //This can throw
                p->do_assign(other.m_data);
                return p;
             }
-            catch(...){
+            BOOST_CATCH(...){
                //If there is an exception destroy the whole source
                m_holder.destroy_node(p);
                while((p = m_icont.unlink_leftmost_without_rebalance())){
                   m_holder.destroy_node(p);
                }
-               throw;
+               BOOST_RETHROW
             }
+            BOOST_CATCH_END
          }
          else{
             return m_holder.create_node(other.m_data);
@@ -284,19 +286,20 @@ class rbtree
       {
          if(NodePtr p = m_icont.unlink_leftmost_without_rebalance()){
             //First recycle a node (this can't throw)
-            try{
+            BOOST_TRY{
                //This can throw
                p->do_move_assign(const_cast(other).m_data);
                return p;
             }
-            catch(...){
+            BOOST_CATCH(...){
                //If there is an exception destroy the whole source
                m_holder.destroy_node(p);
                while((p = m_icont.unlink_leftmost_without_rebalance())){
                   m_holder.destroy_node(p);
                }
-               throw;
+               BOOST_RETHROW
             }
+            BOOST_CATCH_END
          }
          else{
             return m_holder.create_node(other.m_data);
@@ -1121,7 +1124,7 @@ class C, class A>
 struct has_trivial_destructor_after_move
     >
 {
-   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor_after_move::value && has_trivial_destructor_after_move::value;
 };
 */
 } //namespace boost  {
diff --git a/include/boost/container/detail/type_traits.hpp b/include/boost/container/detail/type_traits.hpp
index c1de447..5020ee9 100644
--- a/include/boost/container/detail/type_traits.hpp
+++ b/include/boost/container/detail/type_traits.hpp
@@ -21,7 +21,7 @@
 
 #include "config_begin.hpp"
 
-#include 
+#include 
 
 namespace boost {
 namespace container {
diff --git a/include/boost/container/detail/utilities.hpp b/include/boost/container/detail/utilities.hpp
index ece9a2e..5c294e1 100644
--- a/include/boost/container/detail/utilities.hpp
+++ b/include/boost/container/detail/utilities.hpp
@@ -18,11 +18,14 @@
 #include 
 #include 
 #include 
-#include 
+#include 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 
 namespace boost {
 namespace container {
@@ -123,16 +126,6 @@ struct ct_rounded_size
    enum { value = ((OrigSize-1)/RoundTo+1)*RoundTo };
 };
 
-template
-struct move_const_ref_type
-   : if_c
-//   < ::boost::is_fundamental::value || ::boost::is_pointer::value || ::boost::is_member_pointer::value || ::boost::is_enum::value
-   < !::boost::is_class::value
-   ,const T &
-   ,BOOST_CATCH_CONST_RLVALUE(T)
-   >
-{};
-
 }  //namespace container_detail {
 
 //////////////////////////////////////////////////////////////////////////////
@@ -154,13 +147,95 @@ template
     typename F> // F models ForwardIterator
 F uninitialized_move_alloc(A &a, I f, I l, F r)
 {
-   while (f != l) {
-      allocator_traits::construct(a, container_detail::to_raw_pointer(&*r), boost::move(*f));
-      ++f; ++r;
+   F back = r;
+   BOOST_TRY{
+      while (f != l) {
+         allocator_traits::construct(a, container_detail::to_raw_pointer(&*r), boost::move(*f));
+         ++f; ++r;
+      }
    }
+   BOOST_CATCH(...){
+	   for (; back != r; ++back){
+         allocator_traits::destroy(a, container_detail::to_raw_pointer(&*back));
+      }
+	   BOOST_RETHROW;
+   }
+   BOOST_CATCH_END
    return r;
 }
 
+//////////////////////////////////////////////////////////////////////////////
+//
+//                               uninitialized_move_alloc_n
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//! Effects:
+//!   \code
+//!   for (; n--; ++result, ++first)
+//!      allocator_traits::construct(a, &*result, boost::move(*first));
+//!   \endcode
+//!
+//! Returns: result
+template
+    // F models ForwardIterator
+F uninitialized_move_alloc_n(A &a, I f, typename std::iterator_traits::difference_type n, F r)
+{
+   F back = r;
+   BOOST_TRY{
+      while (n--) {
+         allocator_traits::construct(a, container_detail::to_raw_pointer(&*r), boost::move(*f));
+         ++f; ++r;
+      }
+   }
+   BOOST_CATCH(...){
+	   for (; back != r; ++back){
+         allocator_traits::destroy(a, container_detail::to_raw_pointer(&*back));
+      }
+	   BOOST_RETHROW;
+   }
+   BOOST_CATCH_END
+   return r;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//                               uninitialized_move_alloc_n_source
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//! Effects:
+//!   \code
+//!   for (; n--; ++result, ++first)
+//!      allocator_traits::construct(a, &*result, boost::move(*first));
+//!   \endcode
+//!
+//! Returns: first (after incremented)
+template
+    // F models ForwardIterator
+I uninitialized_move_alloc_n_source(A &a, I f, typename std::iterator_traits::difference_type n, F r)
+{
+   F back = r;
+   BOOST_TRY{
+      while (n--) {
+         allocator_traits::construct(a, container_detail::to_raw_pointer(&*r), boost::move(*f));
+         ++f; ++r;
+      }
+   }
+   BOOST_CATCH(...){
+	   for (; back != r; ++back){
+         allocator_traits::destroy(a, container_detail::to_raw_pointer(&*back));
+      }
+	   BOOST_RETHROW;
+   }
+   BOOST_CATCH_END
+   return f;
+}
+
 //////////////////////////////////////////////////////////////////////////////
 //
 //                               uninitialized_copy_alloc
@@ -180,13 +255,95 @@ template
     typename F> // F models ForwardIterator
 F uninitialized_copy_alloc(A &a, I f, I l, F r)
 {
-   while (f != l) {
-      allocator_traits::construct(a, container_detail::to_raw_pointer(&*r), *f);
-      ++f; ++r;
+   F back = r;
+   BOOST_TRY{
+      while (f != l) {
+         allocator_traits::construct(a, container_detail::to_raw_pointer(&*r), *f);
+         ++f; ++r;
+      }
    }
+   BOOST_CATCH(...){
+	   for (; back != r; ++back){
+         allocator_traits::destroy(a, container_detail::to_raw_pointer(&*back));
+      }
+	   BOOST_RETHROW;
+   }
+   BOOST_CATCH_END
    return r;
 }
 
+//////////////////////////////////////////////////////////////////////////////
+//
+//                               uninitialized_copy_alloc_n
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//! Effects:
+//!   \code
+//!   for (; n--; ++result, ++first)
+//!      allocator_traits::construct(a, &*result, *first);
+//!   \endcode
+//!
+//! Returns: result
+template
+    // F models ForwardIterator
+F uninitialized_copy_alloc_n(A &a, I f, typename std::iterator_traits::difference_type n, F r)
+{
+   F back = r;
+   BOOST_TRY{
+      while (n--) {
+         allocator_traits::construct(a, container_detail::to_raw_pointer(&*r), *f);
+         ++f; ++r;
+      }
+   }
+   BOOST_CATCH(...){
+	   for (; back != r; ++back){
+         allocator_traits::destroy(a, container_detail::to_raw_pointer(&*back));
+      }
+	   BOOST_RETHROW;
+   }
+   BOOST_CATCH_END
+   return r;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//                               uninitialized_copy_alloc_n_source
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//! Effects:
+//!   \code
+//!   for (; n--; ++result, ++first)
+//!      allocator_traits::construct(a, &*result, *first);
+//!   \endcode
+//!
+//! Returns: first (after incremented)
+template
+    // F models ForwardIterator
+I uninitialized_copy_alloc_n_source(A &a, I f, typename std::iterator_traits::difference_type n, F r)
+{
+   F back = r;
+   BOOST_TRY{
+      while (n--) {
+         allocator_traits::construct(a, container_detail::to_raw_pointer(&*r), *f);
+         ++f; ++r;
+      }
+   }
+   BOOST_CATCH(...){
+	   for (; back != r; ++back){
+         allocator_traits::destroy(a, container_detail::to_raw_pointer(&*back));
+      }
+	   BOOST_RETHROW;
+   }
+   BOOST_CATCH_END
+   return f;
+}
+
 //////////////////////////////////////////////////////////////////////////////
 //
 //                               uninitialized_copy_alloc
@@ -206,10 +363,20 @@ template
     typename T>
 void uninitialized_fill_alloc(A &a, F f, F l, const T &t)
 {
-   while (f != l) {
-      allocator_traits::construct(a, container_detail::to_raw_pointer(&*f), t);
-      ++f;
+   F back = f;
+   BOOST_TRY{
+      while (f != l) {
+         allocator_traits::construct(a, container_detail::to_raw_pointer(&*f), t);
+         ++f;
+      }
    }
+   BOOST_CATCH(...){
+	   for (; back != l; ++back){
+         allocator_traits::destroy(a, container_detail::to_raw_pointer(&*back));
+      }
+	   BOOST_RETHROW;
+   }
+   BOOST_CATCH_END
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -242,6 +409,168 @@ F uninitialized_copy_or_move_alloc
    return ::boost::container::uninitialized_copy_alloc(a, f, l, r);
 }
 
+//////////////////////////////////////////////////////////////////////////////
+//
+//                            uninitialized_copy_or_move_alloc_n
+//
+//////////////////////////////////////////////////////////////////////////////
+
+template
+   // F models ForwardIterator
+F uninitialized_copy_or_move_alloc_n
+   (A &a, I f, typename std::iterator_traits::difference_type n, F r
+   ,typename boost::container::container_detail::enable_if
+      < boost::move_detail::is_move_iterator >::type* = 0)
+{
+   return ::boost::container::uninitialized_move_alloc_n(a, f, n, r);
+}
+
+template
+   // F models ForwardIterator
+F uninitialized_copy_or_move_alloc_n
+   (A &a, I f, typename std::iterator_traits::difference_type n, F r
+   ,typename boost::container::container_detail::disable_if
+      < boost::move_detail::is_move_iterator >::type* = 0)
+{
+   return ::boost::container::uninitialized_copy_alloc_n(a, f, n, r);
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//                            uninitialized_copy_or_move_alloc_n_source
+//
+//////////////////////////////////////////////////////////////////////////////
+
+template
+   // F models ForwardIterator
+I uninitialized_copy_or_move_alloc_n_source
+   (A &a, I f, typename std::iterator_traits::difference_type n, F r
+   ,typename boost::container::container_detail::enable_if
+      < boost::move_detail::is_move_iterator >::type* = 0)
+{
+   return ::boost::container::uninitialized_move_alloc_n_source(a, f, n, r);
+}
+
+template
+   // F models ForwardIterator
+I uninitialized_copy_or_move_alloc_n_source
+   (A &a, I f, typename std::iterator_traits::difference_type n, F r
+   ,typename boost::container::container_detail::disable_if
+      < boost::move_detail::is_move_iterator >::type* = 0)
+{
+   return ::boost::container::uninitialized_copy_alloc_n_source(a, f, n, r);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//                         copy_or_move
+//
+//////////////////////////////////////////////////////////////////////////////
+
+template
+   // F models ForwardIterator
+inline F copy_or_move(I f, I l, F r
+   ,typename boost::container::container_detail::enable_if
+      < boost::move_detail::is_move_iterator >::type* = 0)
+{
+   while (f != l) {
+      *r = ::boost::move(*f);
+      ++f; ++r;
+   }
+   return r;
+}
+
+template
+   // F models ForwardIterator
+inline F copy_or_move(I f, I l, F r
+   ,typename boost::container::container_detail::disable_if
+      < boost::move_detail::is_move_iterator >::type* = 0)
+{
+   while (f != l) {
+      *r = *f;
+      ++f; ++r;
+   }
+   return r;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//                         copy_or_move_n
+//
+//////////////////////////////////////////////////////////////////////////////
+
+template
+   // F models ForwardIterator
+inline F copy_or_move_n(I f, typename std::iterator_traits::difference_type n, F r
+   ,typename boost::container::container_detail::enable_if
+      < boost::move_detail::is_move_iterator >::type* = 0)
+{
+   while (n--) {
+      *r = ::boost::move(*f);
+      ++f; ++r;
+   }
+   return r;
+}
+
+template
+   // F models ForwardIterator
+inline F copy_or_move_n(I f, typename std::iterator_traits::difference_type n, F r
+   ,typename boost::container::container_detail::disable_if
+      < boost::move_detail::is_move_iterator >::type* = 0)
+{
+   while (n--) {
+      *r = *f;
+      ++f; ++r;
+   }
+   return r;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//                         copy_or_move_n_source
+//
+//////////////////////////////////////////////////////////////////////////////
+
+template
+   // F models ForwardIterator
+inline I copy_or_move_n_source(I f, typename std::iterator_traits::difference_type n, F r
+   ,typename boost::container::container_detail::enable_if
+      < boost::move_detail::is_move_iterator >::type* = 0)
+{
+   while (n--) {
+      *r = ::boost::move(*f);
+      ++f; ++r;
+   }
+   return f;
+}
+
+template
+   // F models ForwardIterator
+inline I copy_or_move_n_source(I f, typename std::iterator_traits::difference_type n, F r
+   ,typename boost::container::container_detail::disable_if
+      < boost::move_detail::is_move_iterator >::type* = 0)
+{
+   while (n--) {
+      *r = *f;
+      ++f; ++r;
+   }
+   return f;
+}
 
 }  //namespace container {
 }  //namespace boost {
diff --git a/include/boost/container/detail/workaround.hpp b/include/boost/container/detail/workaround.hpp
index 317bbb2..a0820a1 100644
--- a/include/boost/container/detail/workaround.hpp
+++ b/include/boost/container/detail/workaround.hpp
@@ -18,8 +18,12 @@
    #define BOOST_CONTAINER_PERFECT_FORWARDING
 #endif
 
-#if defined(BOOST_NO_CXX11_NOEXCEPT)
-   #define BOOST_CONTAINER_NOEXCEPT
+#if defined(BOOST_NO_NOEXCEPT)
+   #if defined(BOOST_MSVC)
+      #define BOOST_CONTAINER_NOEXCEPT throw()
+   #else
+      #define BOOST_CONTAINER_NOEXCEPT
+   #endif
    #define BOOST_CONTAINER_NOEXCEPT_IF(x)
 #else
    #define BOOST_CONTAINER_NOEXCEPT    noexcept
diff --git a/include/boost/container/flat_map.hpp b/include/boost/container/flat_map.hpp
index 4fb9e07..2dd2210 100644
--- a/include/boost/container/flat_map.hpp
+++ b/include/boost/container/flat_map.hpp
@@ -27,8 +27,8 @@
 #include 
 #include 
 #include 
-#include 
-#include 
+#include 
+#include 
 
 namespace boost {
 namespace container {
@@ -251,7 +251,7 @@ class flat_map
    //!   was passed to the object's constructor.
    //!
    //! Complexity: Constant.
-   allocator_type get_allocator() const
+   allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.get_allocator()); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -261,7 +261,7 @@ class flat_map
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   stored_allocator_type &get_stored_allocator()
+   stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force(m_flat_tree.get_stored_allocator()); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -271,7 +271,7 @@ class flat_map
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   const stored_allocator_type &get_stored_allocator() const
+   const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force(m_flat_tree.get_stored_allocator()); }
 
    //////////////////////////////////////////////
@@ -285,7 +285,7 @@ class flat_map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator begin()
+   iterator begin() BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.begin()); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
@@ -293,7 +293,7 @@ class flat_map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator begin() const
+   const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.begin()); }
 
    //! Effects: Returns an iterator to the end of the container.
@@ -301,7 +301,7 @@ class flat_map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator end()
+   iterator end() BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.end()); }
 
    //! Effects: Returns a const_iterator to the end of the container.
@@ -309,7 +309,7 @@ class flat_map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator end() const
+   const_iterator end() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.end()); }
 
    //! Effects: Returns a reverse_iterator pointing to the beginning
@@ -318,7 +318,7 @@ class flat_map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reverse_iterator rbegin()
+   reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.rbegin()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
@@ -327,7 +327,7 @@ class flat_map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator rbegin() const
+   const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.rbegin()); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
@@ -336,7 +336,7 @@ class flat_map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reverse_iterator rend()
+   reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.rend()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
@@ -345,7 +345,7 @@ class flat_map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator rend() const
+   const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.rend()); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
@@ -353,7 +353,7 @@ class flat_map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator cbegin() const
+   const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.cbegin()); }
 
    //! Effects: Returns a const_iterator to the end of the container.
@@ -361,7 +361,7 @@ class flat_map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator cend() const
+   const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.cend()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
@@ -370,7 +370,7 @@ class flat_map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin() const
+   const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.crbegin()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
@@ -379,7 +379,7 @@ class flat_map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator crend() const
+   const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.crend()); }
 
    //////////////////////////////////////////////
@@ -393,7 +393,7 @@ class flat_map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   bool empty() const
+   bool empty() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.empty(); }
 
    //! Effects: Returns the number of the elements contained in the container.
@@ -401,7 +401,7 @@ class flat_map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type size() const
+   size_type size() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.size(); }
 
    //! Effects: Returns the largest possible size of the container.
@@ -409,7 +409,7 @@ class flat_map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type max_size() const
+   size_type max_size() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.max_size(); }
 
    //! Effects: Number of elements for which memory has been allocated.
@@ -418,7 +418,7 @@ class flat_map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type capacity() const
+   size_type capacity() const BOOST_CONTAINER_NOEXCEPT        
       { return m_flat_tree.capacity(); }
 
    //! Effects: If n is less than or equal to capacity(), this call has no
@@ -428,10 +428,10 @@ class flat_map
    //!
    //! Throws: If memory allocation allocation throws or T's copy constructor throws.
    //!
-   //! Note: If capacity() is less than "count", iterators and references to
+   //! Note: If capacity() is less than "cnt", iterators and references to
    //!   to values might be invalidated.
-   void reserve(size_type count_)
-      { m_flat_tree.reserve(count_);   }
+   void reserve(size_type cnt)      
+      { m_flat_tree.reserve(cnt);   }
 
    //! Effects: Tries to deallocate the excess of memory created
    //    with previous allocations. The size of the vector is unchanged
@@ -740,7 +740,7 @@ class flat_map
    //! Postcondition: size() == 0.
    //!
    //! Complexity: linear in size().
-   void clear()
+   void clear() BOOST_CONTAINER_NOEXCEPT
       { m_flat_tree.clear(); }
 
    //////////////////////////////////////////////
@@ -900,15 +900,15 @@ inline void swap(flat_map& x,
 /// @cond
 
 }  //namespace container {
-/*
+
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
 template 
 struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor_after_move::value && has_trivial_destructor_after_move::value;
 };
-*/
+
 namespace container {
 
 // Forward declaration of operators < and ==, needed for friend declaration.
@@ -1099,7 +1099,7 @@ class flat_multimap
    //!   was passed to the object's constructor.
    //!
    //! Complexity: Constant.
-   allocator_type get_allocator() const
+   allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.get_allocator()); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -1109,7 +1109,7 @@ class flat_multimap
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   stored_allocator_type &get_stored_allocator()
+   stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force(m_flat_tree.get_stored_allocator()); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -1119,7 +1119,7 @@ class flat_multimap
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   const stored_allocator_type &get_stored_allocator() const
+   const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force(m_flat_tree.get_stored_allocator()); }
 
    //////////////////////////////////////////////
@@ -1133,7 +1133,7 @@ class flat_multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator begin()
+   iterator begin() BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.begin()); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
@@ -1141,7 +1141,7 @@ class flat_multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator begin() const
+   const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.begin()); }
 
    //! Effects: Returns an iterator to the end of the container.
@@ -1149,7 +1149,7 @@ class flat_multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator end()
+   iterator end() BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.end()); }
 
    //! Effects: Returns a const_iterator to the end of the container.
@@ -1157,7 +1157,7 @@ class flat_multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator end() const
+   const_iterator end() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.end()); }
 
    //! Effects: Returns a reverse_iterator pointing to the beginning
@@ -1166,7 +1166,7 @@ class flat_multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reverse_iterator rbegin()
+   reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.rbegin()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
@@ -1175,7 +1175,7 @@ class flat_multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator rbegin() const
+   const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.rbegin()); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
@@ -1184,7 +1184,7 @@ class flat_multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reverse_iterator rend()
+   reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.rend()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
@@ -1193,7 +1193,7 @@ class flat_multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator rend() const
+   const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.rend()); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
@@ -1201,7 +1201,7 @@ class flat_multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator cbegin() const
+   const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.cbegin()); }
 
    //! Effects: Returns a const_iterator to the end of the container.
@@ -1209,7 +1209,7 @@ class flat_multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator cend() const
+   const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.cend()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
@@ -1218,7 +1218,7 @@ class flat_multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin() const
+   const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.crbegin()); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
@@ -1227,7 +1227,7 @@ class flat_multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator crend() const
+   const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
       { return container_detail::force_copy(m_flat_tree.crend()); }
 
    //////////////////////////////////////////////
@@ -1241,7 +1241,7 @@ class flat_multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   bool empty() const
+   bool empty() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.empty(); }
 
    //! Effects: Returns the number of the elements contained in the container.
@@ -1249,7 +1249,7 @@ class flat_multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type size() const
+   size_type size() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.size(); }
 
    //! Effects: Returns the largest possible size of the container.
@@ -1257,7 +1257,7 @@ class flat_multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type max_size() const
+   size_type max_size() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.max_size(); }
 
    //! Effects: Number of elements for which memory has been allocated.
@@ -1266,7 +1266,7 @@ class flat_multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type capacity() const
+   size_type capacity() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.capacity(); }
 
    //! Effects: If n is less than or equal to capacity(), this call has no
@@ -1276,10 +1276,10 @@ class flat_multimap
    //!
    //! Throws: If memory allocation allocation throws or T's copy constructor throws.
    //!
-   //! Note: If capacity() is less than "count", iterators and references to
+   //! Note: If capacity() is less than "cnt", iterators and references to
    //!   to values might be invalidated.
-   void reserve(size_type count_)
-      { m_flat_tree.reserve(count_);   }
+   void reserve(size_type cnt)      
+      { m_flat_tree.reserve(cnt);   }
 
    //! Effects: Tries to deallocate the excess of memory created
    //    with previous allocations. The size of the vector is unchanged
@@ -1516,7 +1516,7 @@ class flat_multimap
    //! Postcondition: size() == 0.
    //!
    //! Complexity: linear in size().
-   void clear()
+   void clear() BOOST_CONTAINER_NOEXCEPT
       { m_flat_tree.clear(); }
 
    //////////////////////////////////////////////
@@ -1655,15 +1655,15 @@ inline void swap(flat_multimap& x, flat_multimap == true_type
 //!specialization for optimizations
 template 
 struct has_trivial_destructor_after_move< boost::container::flat_multimap >
 {
-   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor_after_move::value && has_trivial_destructor_after_move::value;
 };
-*/
+
 }  //namespace boost {
 
 /// @endcond
diff --git a/include/boost/container/flat_set.hpp b/include/boost/container/flat_set.hpp
index b6266e6..82bdea8 100644
--- a/include/boost/container/flat_set.hpp
+++ b/include/boost/container/flat_set.hpp
@@ -25,8 +25,8 @@
 #include 
 #include 
 #include 
-#include 
-#include 
+#include 
+#include 
 
 namespace boost {
 namespace container {
@@ -197,7 +197,7 @@ class flat_set
    //!   was passed to the object's constructor.
    //!
    //! Complexity: Constant.
-   allocator_type get_allocator() const
+   allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.get_allocator(); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -207,7 +207,7 @@ class flat_set
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   stored_allocator_type &get_stored_allocator()
+   stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
    {  return m_flat_tree.get_stored_allocator(); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -217,7 +217,7 @@ class flat_set
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   const stored_allocator_type &get_stored_allocator() const
+   const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
    {  return m_flat_tree.get_stored_allocator(); }
 
    //////////////////////////////////////////////
@@ -231,7 +231,7 @@ class flat_set
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator begin()
+   iterator begin() BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.begin(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
@@ -239,7 +239,7 @@ class flat_set
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator begin() const
+   const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.begin(); }
 
    //! Effects: Returns an iterator to the end of the container.
@@ -247,7 +247,7 @@ class flat_set
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator end()
+   iterator end() BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.end(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
@@ -255,7 +255,7 @@ class flat_set
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator end() const
+   const_iterator end() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.end(); }
 
    //! Effects: Returns a reverse_iterator pointing to the beginning
@@ -264,7 +264,7 @@ class flat_set
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reverse_iterator rbegin()
+   reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.rbegin(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
@@ -273,7 +273,7 @@ class flat_set
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator rbegin() const
+   const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.rbegin(); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
@@ -282,7 +282,7 @@ class flat_set
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reverse_iterator rend()
+   reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.rend(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
@@ -291,7 +291,7 @@ class flat_set
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator rend() const
+   const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.rend(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
@@ -299,7 +299,7 @@ class flat_set
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator cbegin() const
+   const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.cbegin(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
@@ -307,7 +307,7 @@ class flat_set
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator cend() const
+   const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.cend(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
@@ -316,7 +316,7 @@ class flat_set
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin() const
+   const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.crbegin(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
@@ -325,7 +325,7 @@ class flat_set
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator crend() const
+   const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.crend(); }
 
 
@@ -340,7 +340,7 @@ class flat_set
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   bool empty() const
+   bool empty() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.empty(); }
 
    //! Effects: Returns the number of the elements contained in the container.
@@ -348,7 +348,7 @@ class flat_set
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type size() const
+   size_type size() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.size(); }
 
    //! Effects: Returns the largest possible size of the container.
@@ -356,7 +356,7 @@ class flat_set
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type max_size() const
+   size_type max_size() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.max_size(); }
 
    //! Effects: Number of elements for which memory has been allocated.
@@ -365,7 +365,7 @@ class flat_set
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type capacity() const
+   size_type capacity() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.capacity(); }
 
    //! Effects: If n is less than or equal to capacity(), this call has no
@@ -375,10 +375,10 @@ class flat_set
    //!
    //! Throws: If memory allocation allocation throws or Key's copy constructor throws.
    //!
-   //! Note: If capacity() is less than "count", iterators and references to
+   //! Note: If capacity() is less than "cnt", iterators and references to
    //!   to values might be invalidated.
-   void reserve(size_type count_)
-      { m_flat_tree.reserve(count_);   }
+   void reserve(size_type cnt)      
+      { m_flat_tree.reserve(cnt);   }
 
    //! Effects: Tries to deallocate the excess of memory created
    //    with previous allocations. The size of the vector is unchanged
@@ -582,7 +582,7 @@ class flat_set
    //! Postcondition: size() == 0.
    //!
    //! Complexity: linear in size().
-   void clear()
+   void clear() BOOST_CONTAINER_NOEXCEPT
       { m_flat_tree.clear(); }
 
    //////////////////////////////////////////////
@@ -726,15 +726,15 @@ inline void swap(flat_set& x, flat_set == true_type
 //!specialization for optimizations
 template 
 struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value &&has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor_after_move::value &&has_trivial_destructor_after_move::value;
 };
-*/
+
 namespace container {
 
 // Forward declaration of operators < and ==, needed for friend declaration.
@@ -884,7 +884,7 @@ class flat_multiset
    //!   was passed to the object's constructor.
    //!
    //! Complexity: Constant.
-   allocator_type get_allocator() const
+   allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
    { return m_flat_tree.get_allocator(); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -894,7 +894,7 @@ class flat_multiset
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   stored_allocator_type &get_stored_allocator()
+   stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
    { return m_flat_tree.get_stored_allocator(); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -904,7 +904,7 @@ class flat_multiset
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   const stored_allocator_type &get_stored_allocator() const
+   const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
    { return m_flat_tree.get_stored_allocator(); }
 
    //! Effects: Returns an iterator to the first element contained in the container.
@@ -912,7 +912,7 @@ class flat_multiset
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator begin()
+   iterator begin() BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.begin(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
@@ -928,7 +928,7 @@ class flat_multiset
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator cbegin() const
+   const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.cbegin(); }
 
    //! Effects: Returns an iterator to the end of the container.
@@ -936,7 +936,7 @@ class flat_multiset
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator end()
+   iterator end() BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.end(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
@@ -944,7 +944,7 @@ class flat_multiset
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator end() const
+   const_iterator end() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.end(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
@@ -952,7 +952,7 @@ class flat_multiset
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator cend() const
+   const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.cend(); }
 
    //! Effects: Returns a reverse_iterator pointing to the beginning
@@ -961,7 +961,7 @@ class flat_multiset
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reverse_iterator rbegin()
+   reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.rbegin(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
@@ -970,7 +970,7 @@ class flat_multiset
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator rbegin() const
+   const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.rbegin(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
@@ -979,7 +979,7 @@ class flat_multiset
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin() const
+   const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.crbegin(); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
@@ -988,7 +988,7 @@ class flat_multiset
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reverse_iterator rend()
+   reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.rend(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
@@ -997,7 +997,7 @@ class flat_multiset
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator rend() const
+   const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.rend(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
@@ -1006,7 +1006,7 @@ class flat_multiset
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator crend() const
+   const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.crend(); }
 
    //////////////////////////////////////////////
@@ -1020,7 +1020,7 @@ class flat_multiset
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   bool empty() const
+   bool empty() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.empty(); }
 
    //! Effects: Returns the number of the elements contained in the container.
@@ -1028,7 +1028,7 @@ class flat_multiset
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type size() const
+   size_type size() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.size(); }
 
    //! Effects: Returns the largest possible size of the container.
@@ -1036,7 +1036,7 @@ class flat_multiset
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type max_size() const
+   size_type max_size() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.max_size(); }
 
    //! Effects: Number of elements for which memory has been allocated.
@@ -1045,7 +1045,7 @@ class flat_multiset
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type capacity() const
+   size_type capacity() const BOOST_CONTAINER_NOEXCEPT
       { return m_flat_tree.capacity(); }
 
    //! Effects: If n is less than or equal to capacity(), this call has no
@@ -1055,10 +1055,10 @@ class flat_multiset
    //!
    //! Throws: If memory allocation allocation throws or Key's copy constructor throws.
    //!
-   //! Note: If capacity() is less than "count", iterators and references to
+   //! Note: If capacity() is less than "cnt", iterators and references to
    //!   to values might be invalidated.
-   void reserve(size_type count_)
-      { m_flat_tree.reserve(count_);   }
+   void reserve(size_type cnt)      
+      { m_flat_tree.reserve(cnt);   }
 
    //! Effects: Tries to deallocate the excess of memory created
    //    with previous allocations. The size of the vector is unchanged
@@ -1244,7 +1244,7 @@ class flat_multiset
    //! Postcondition: size() == 0.
    //!
    //! Complexity: linear in size().
-   void clear()
+   void clear() BOOST_CONTAINER_NOEXCEPT
       { m_flat_tree.clear(); }
 
    //////////////////////////////////////////////
@@ -1388,15 +1388,15 @@ inline void swap(flat_multiset& x, flat_multiset == true_type
 //!specialization for optimizations
 template 
 struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor_after_move::value && has_trivial_destructor_after_move::value;
 };
-*/
+
 namespace container {
 
 /// @endcond
diff --git a/include/boost/container/list.hpp b/include/boost/container/list.hpp
index 38f7c54..b4a3cf3 100644
--- a/include/boost/container/list.hpp
+++ b/include/boost/container/list.hpp
@@ -18,8 +18,9 @@
 #include 
 #include 
 #include 
-#include 
-#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -140,9 +141,6 @@ class list_const_iterator
    friend bool operator!= (const list_const_iterator& l, const list_const_iterator& r)
    {  return l.m_it != r.m_it;  }
 
-   IIterator &get()
-   {  return this->m_it;   }
-
    const IIterator &get() const
    {  return this->m_it;   }
 };
@@ -187,9 +185,6 @@ class list_iterator
    list_iterator operator--(int)
    {  IIterator tmp = this->m_it; --*this; return list_iterator(tmp); }
 
-   IIterator &get()
-   {  return this->m_it;   }
-
    const IIterator &get() const
    {  return this->m_it;   }
 };
@@ -303,10 +298,10 @@ class list
 
    //! Effects: Constructs a list taking the allocator as parameter.
    //!
-   //! Throws: If allocator_type's copy constructor throws.
+   //! Throws: Nothing
    //!
    //! Complexity: Constant.
-   explicit list(const allocator_type &a)
+   explicit list(const allocator_type &a) BOOST_CONTAINER_NOEXCEPT
       : AllocHolder(a)
    {}
 
@@ -398,7 +393,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Linear to the number of elements.
-   ~list()
+   ~list() BOOST_CONTAINER_NOEXCEPT
    {} //AllocHolder clears the list
 
    //! Effects: Makes *this contain the same elements as x.
@@ -498,7 +493,7 @@ class list
    //! Throws: If allocator's copy constructor throws.
    //!
    //! Complexity: Constant.
-   allocator_type get_allocator() const
+   allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
    {  return allocator_type(this->node_alloc()); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -508,7 +503,7 @@ class list
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   stored_allocator_type &get_stored_allocator()
+   stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
    {  return this->node_alloc(); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -518,7 +513,7 @@ class list
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   const stored_allocator_type &get_stored_allocator() const
+   const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
    {  return this->node_alloc(); }
 
    //////////////////////////////////////////////
@@ -532,7 +527,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator begin()
+   iterator begin() BOOST_CONTAINER_NOEXCEPT
    { return iterator(this->icont().begin()); }
 
    //! Effects: Returns a const_iterator to the first element contained in the list.
@@ -540,7 +535,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator begin() const
+   const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
    {  return this->cbegin();   }
 
    //! Effects: Returns an iterator to the end of the list.
@@ -548,7 +543,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator end()
+   iterator end() BOOST_CONTAINER_NOEXCEPT
    {  return iterator(this->icont().end());  }
 
    //! Effects: Returns a const_iterator to the end of the list.
@@ -556,7 +551,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator end() const
+   const_iterator end() const BOOST_CONTAINER_NOEXCEPT
    {  return this->cend();  }
 
    //! Effects: Returns a reverse_iterator pointing to the beginning
@@ -565,7 +560,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reverse_iterator rbegin()
+   reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT
    {  return reverse_iterator(end());  }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
@@ -574,7 +569,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator rbegin() const
+   const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
    {  return this->crbegin();  }
 
    //! Effects: Returns a reverse_iterator pointing to the end
@@ -583,7 +578,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reverse_iterator rend()
+   reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT
    {  return reverse_iterator(begin());   }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
@@ -592,7 +587,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator rend() const
+   const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT
    {  return this->crend();   }
 
    //! Effects: Returns a const_iterator to the first element contained in the list.
@@ -600,7 +595,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator cbegin() const
+   const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
    {  return const_iterator(this->non_const_icont().begin());   }
 
    //! Effects: Returns a const_iterator to the end of the list.
@@ -608,7 +603,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator cend() const
+   const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
    {  return const_iterator(this->non_const_icont().end());  }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
@@ -617,7 +612,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin() const
+   const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT
    {  return const_reverse_iterator(this->cend());  }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
@@ -626,7 +621,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator crend() const
+   const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
    {  return const_reverse_iterator(this->cbegin());   }
 
    //////////////////////////////////////////////
@@ -640,7 +635,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   bool empty() const
+   bool empty() const BOOST_CONTAINER_NOEXCEPT
    {  return !this->size();  }
 
    //! Effects: Returns the number of the elements contained in the list.
@@ -648,7 +643,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type size() const
+   size_type size() const BOOST_CONTAINER_NOEXCEPT
    {   return this->icont().size();   }
 
    //! Effects: Returns the largest possible size of the list.
@@ -656,7 +651,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type max_size() const
+   size_type max_size() const BOOST_CONTAINER_NOEXCEPT
    {  return AllocHolder::max_size();  }
 
    //! Effects: Inserts or erases elements at the end such that
@@ -700,7 +695,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reference front()            
+   reference front() BOOST_CONTAINER_NOEXCEPT
    { return *this->begin(); }
 
    //! Requires: !empty()
@@ -711,7 +706,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reference front() const
+   const_reference front() const BOOST_CONTAINER_NOEXCEPT
    { return *this->begin(); }
 
    //! Requires: !empty()
@@ -722,7 +717,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reference back()             
+   reference back() BOOST_CONTAINER_NOEXCEPT
    { return *(--this->end()); }
 
    //! Requires: !empty()
@@ -733,7 +728,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reference back()  const
+   const_reference back() const BOOST_CONTAINER_NOEXCEPT
    { return *(--this->end()); }
 
    //////////////////////////////////////////////
@@ -939,8 +934,10 @@ class list
    {
       //Optimized allocation and construction
       insertion_functor func(this->icont(), p.get());
+      iterator before_p(p.get());
+      --before_p;
       this->allocate_many_and_construct(first, std::distance(first, last), func);
-      return iterator(func.inserted_first());
+      return ++before_p;
    }
    #endif
 
@@ -949,7 +946,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Amortized constant time.
-   void pop_front()             
+   void pop_front() BOOST_CONTAINER_NOEXCEPT
    {  this->erase(this->cbegin());      }
 
    //! Effects: Removes the last element from the list.
@@ -957,7 +954,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Amortized constant time.
-   void pop_back()              
+   void pop_back() BOOST_CONTAINER_NOEXCEPT
    {  const_iterator tmp = this->cend(); this->erase(--tmp);  }
 
    //! Requires: p must be a valid iterator of *this.
@@ -967,7 +964,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Amortized constant time.
-   iterator erase(const_iterator p)
+   iterator erase(const_iterator p) BOOST_CONTAINER_NOEXCEPT
    {  return iterator(this->icont().erase_and_dispose(p.get(), Destroyer(this->node_alloc()))); }
 
    //! Requires: first and last must be valid iterator to elements in *this.
@@ -977,7 +974,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Linear to the distance between first and last.
-   iterator erase(const_iterator first, const_iterator last)
+   iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
    {  return iterator(AllocHolder::erase_range(first.get(), last.get(), alloc_version())); }
 
    //! Effects: Swaps the contents of *this and x.
@@ -993,7 +990,7 @@ class list
    //! Throws: Nothing.
    //!
    //! Complexity: Linear to the number of elements in the list.
-   void clear()
+   void clear() BOOST_CONTAINER_NOEXCEPT
    {  AllocHolder::clear(alloc_version());  }
 
    //////////////////////////////////////////////
@@ -1003,13 +1000,12 @@ class list
    //////////////////////////////////////////////
 
    //! Requires: p must point to an element contained
-   //!   by the list. x != *this
+   //!   by the list. x != *this. this' allocator and x's allocator shall compare equal
    //!
    //! Effects: Transfers all the elements of list x to this list, before the
    //!   the element pointed by p. No destructors or copy constructors are called.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Constant.
    //!
@@ -1017,19 +1013,18 @@ class list
    //!    this list. Iterators of this list and all the references are not invalidated.
    void splice(const_iterator p, list& x) BOOST_CONTAINER_NOEXCEPT
    {
-      BOOST_ASSERT(*this != x);
+      BOOST_ASSERT(this != &x);
       BOOST_ASSERT(this->node_alloc() == x.node_alloc());
       this->icont().splice(p.get(), x.icont());
    }
 
    //! Requires: p must point to an element contained
-   //!   by the list. x != *this
+   //!   by the list. x != *this. this' allocator and x's allocator shall compare equal
    //!
    //! Effects: Transfers all the elements of list x to this list, before the
    //!   the element pointed by p. No destructors or copy constructors are called.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Constant.
    //!
@@ -1040,13 +1035,13 @@ class list
 
    //! Requires: p must point to an element contained
    //!   by this list. i must point to an element contained in list x.
+   //!   this' allocator and x's allocator shall compare equal
    //!
    //! Effects: 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.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Constant.
    //!
@@ -1054,20 +1049,20 @@ class list
    //!   list. Iterators of this list and all the references are not invalidated.
    void splice(const_iterator p, list &x, const_iterator i) BOOST_CONTAINER_NOEXCEPT
    {
-      BOOST_ASSERT(*this != x);
+      //BOOST_ASSERT(this != &x);
       BOOST_ASSERT(this->node_alloc() == x.node_alloc());
       this->icont().splice(p.get(), x.icont(), i.get());
    }
 
    //! Requires: p must point to an element contained
    //!   by this list. i must point to an element contained in list x.
+   //!   this' allocator and x's allocator shall compare equal.
    //!
    //! Effects: 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.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Constant.
    //!
@@ -1078,12 +1073,12 @@ class list
 
    //! Requires: p must point to an element contained
    //!   by this list. first and last must point to elements contained in list x.
+   //!   this' allocator and x's allocator shall compare equal
    //!
    //! Effects: 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.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Linear to the number of elements transferred.
    //!
@@ -1091,19 +1086,18 @@ class list
    //!   list. Iterators of this list and all the references are not invalidated.
    void splice(const_iterator p, list &x, const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
    {
-      BOOST_ASSERT(*this != x);
       BOOST_ASSERT(this->node_alloc() == x.node_alloc());
       this->icont().splice(p.get(), x.icont(), first.get(), last.get());
    }
 
    //! Requires: p must point to an element contained
    //!   by this list. first and last must point to elements contained in list x.
+   //!   this' allocator and x's allocator shall compare equal.
    //!
    //! Effects: 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.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Linear to the number of elements transferred.
    //!
@@ -1114,13 +1108,12 @@ class list
 
    //! Requires: 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)
+   //!   n == std::distance(first, last). this' allocator and x's allocator shall compare equal
    //!
    //! Effects: 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.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws:  Nothing
    //!
    //! Complexity: Constant.
    //!
@@ -1130,20 +1123,18 @@ class list
    //! Note: Non-standard extension
    void splice(const_iterator p, list &x, const_iterator first, const_iterator last, size_type n) BOOST_CONTAINER_NOEXCEPT
    {
-      BOOST_ASSERT(*this != x);
       BOOST_ASSERT(this->node_alloc() == x.node_alloc());
       this->icont().splice(p.get(), x.icont(), first.get(), last.get(), n);
    }
 
    //! Requires: 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)
+   //!   n == std::distance(first, last). this' allocator and x's allocator shall compare equal
    //!
    //! Effects: 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.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Constant.
    //!
@@ -1156,7 +1147,7 @@ class list
 
    //! Effects: Removes all the elements that compare equal to value.
    //!
-   //! Throws: Nothing.
+   //! Throws: If comparison throws.
    //!
    //! Complexity: Linear time. It performs exactly size() comparisons for equality.
    //!
@@ -1184,9 +1175,9 @@ class list
    //! Effects: Removes adjacent duplicate elements or adjacent
    //!   elements that are equal from the list.
    //!
-   //! Throws: Nothing.
+   //! Throws: If comparison throws.
    //!
-   //! Complexity: Linear time (size()-1 comparisons calls to pred()).
+   //! Complexity: Linear time (size()-1 comparisons equality comparisons).
    //!
    //! Note: The relative order of elements that are not removed is unchanged,
    //!   and iterators to elements that are not removed remain valid.
@@ -1198,7 +1189,7 @@ class list
    //!
    //! Throws: If pred throws.
    //!
-   //! Complexity: Linear time (size()-1 comparisons equality comparisons).
+   //! Complexity: Linear time (size()-1 comparisons calls to pred()).
    //!
    //! Note: The relative order of elements that are not removed is unchanged,
    //!   and iterators to elements that are not removed remain valid.
@@ -1216,7 +1207,7 @@ class list
    //!   that is, if an element from *this is equivalent to one from x, then the element
    //!   from *this will precede the one from x.
    //!
-   //! Throws: Nothing.
+   //! Throws: If comparison throws.
    //!
    //! Complexity: This function is linear time: it performs at most
    //!   size() + x.size() - 1 comparisons.
@@ -1230,7 +1221,7 @@ class list
    //!   that is, if an element from *this is equivalent to one from x, then the element
    //!   from *this will precede the one from x.
    //!
-   //! Throws: Nothing.
+   //! Throws: If comparison throws.
    //!
    //! Complexity: This function is linear time: it performs at most
    //!   size() + x.size() - 1 comparisons.
@@ -1245,22 +1236,18 @@ class list
    //!   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.
    //!
-   //! Throws: Nothing.
+   //! Throws: If comp throws.
    //!
    //! Complexity: This function is linear time: it performs at most
    //!   size() + x.size() - 1 comparisons.
    //!
    //! Note: Iterators and references to *this are not invalidated.
    template 
-   void merge(list &x, StrictWeakOrdering comp)
+   void merge(list &x, const StrictWeakOrdering &comp)
    {
-      if((NodeAlloc&)*this == (NodeAlloc&)x){
-         this->icont().merge(x.icont(),
-            ValueCompareToNodeCompare(comp));
-      }
-      else{
-         throw std::runtime_error("list::merge called with unequal allocators");
-      }
+      BOOST_ASSERT(this->node_alloc() == x.node_alloc());
+      this->icont().merge(x.icont(),
+         ValueCompareToNodeCompare(comp));
    }
 
    //! Requires: p must be a comparison function that induces a strict weak
@@ -1271,7 +1258,7 @@ class list
    //!   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.
    //!
-   //! Throws: Nothing.
+   //! Throws: If comp throws.
    //!
    //! Complexity: This function is linear time: it performs at most
    //!   size() + x.size() - 1 comparisons.
@@ -1284,7 +1271,7 @@ class list
    //! Effects: This function sorts the list *this according to std::less.
    //!   The sort is stable, that is, the relative order of equivalent elements is preserved.
    //!
-   //! Throws: Nothing.
+   //! Throws: If comparison throws.
    //!
    //! Notes: Iterators and references are not invalidated.
    //!  
@@ -1296,7 +1283,7 @@ class list
    //! Effects: This function sorts the list *this according to std::less.
    //!   The sort is stable, that is, the relative order of equivalent elements is preserved.
    //!
-   //! Throws: Nothing.
+   //! Throws: If comp throws.
    //!
    //! Notes: Iterators and references are not invalidated.
    //!
@@ -1318,7 +1305,7 @@ class list
    //! Complexity: This function is linear time.
    //!
    //! Note: Iterators and references are not invalidated
-   void reverse()
+   void reverse() BOOST_CONTAINER_NOEXCEPT
    {  this->icont().reverse(); }   
 
    /// @cond
@@ -1382,31 +1369,18 @@ class list
    class insertion_functor
    {
       Icont &icont_;
-      typedef typename Icont::iterator       iiterator;
       typedef typename Icont::const_iterator iconst_iterator;
-
       const iconst_iterator pos_;
-      iiterator ret_;
-      bool first_;
 
       public:
       insertion_functor(Icont &icont, typename Icont::const_iterator pos)
-         :  icont_(icont), pos_(pos), ret_(pos.unconst()), first_(true)
+         :  icont_(icont), pos_(pos)
       {}
 
       void operator()(Node &n)
       {
-         if(first_){
-            ret_ = this->icont_.insert(pos_, n);
-            first_ = false;
-         }
-         else{
-            this->icont_.insert(pos_, n);
-         }
+         this->icont_.insert(pos_, n);
       }
-
-      iiterator inserted_first() const
-      {  return ret_;   }
    };
 
    //Functors for member algorithm defaults
@@ -1483,15 +1457,14 @@ inline void swap(list& x, list& y)
 /// @cond
 
 }  //namespace container {
-/*
+
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
 template 
 struct has_trivial_destructor_after_move >
-{
-   static const bool value = has_trivial_destructor::value;
-};
-*/
+   : public ::boost::has_trivial_destructor_after_move
+{};
+
 namespace container {
 
 /// @endcond
diff --git a/include/boost/container/map.hpp b/include/boost/container/map.hpp
index 92d499a..d4ab423 100644
--- a/include/boost/container/map.hpp
+++ b/include/boost/container/map.hpp
@@ -30,8 +30,8 @@
 #include 
 #include 
 #include 
-#include 
-#include 
+#include 
+#include 
 #include 
 #include 
 
@@ -229,7 +229,7 @@ class map
    //!   was passed to the object's constructor.
    //!
    //! Complexity: Constant.
-   allocator_type get_allocator() const
+   allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
    { return m_tree.get_allocator(); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -239,7 +239,7 @@ class map
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   stored_allocator_type &get_stored_allocator()
+   stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
    { return m_tree.get_stored_allocator(); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -249,7 +249,7 @@ class map
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   const stored_allocator_type &get_stored_allocator() const
+   const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
    { return m_tree.get_stored_allocator(); }
 
    //////////////////////////////////////////////
@@ -263,7 +263,7 @@ class map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator begin()
+   iterator begin() BOOST_CONTAINER_NOEXCEPT
    { return m_tree.begin(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
@@ -271,7 +271,7 @@ class map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator begin() const
+   const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
    { return this->cbegin(); }
 
    //! Effects: Returns an iterator to the end of the container.
@@ -279,7 +279,7 @@ class map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator end()
+   iterator end() BOOST_CONTAINER_NOEXCEPT
    { return m_tree.end(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
@@ -287,7 +287,7 @@ class map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator end() const
+   const_iterator end() const BOOST_CONTAINER_NOEXCEPT
    { return this->cend(); }
 
    //! Effects: Returns a reverse_iterator pointing to the beginning
@@ -296,7 +296,7 @@ class map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reverse_iterator rbegin()
+   reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT
    { return m_tree.rbegin(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
@@ -305,7 +305,7 @@ class map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator rbegin() const
+   const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
    { return this->crbegin(); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
@@ -314,7 +314,7 @@ class map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reverse_iterator rend()
+   reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT
    { return m_tree.rend(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
@@ -323,7 +323,7 @@ class map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator rend() const
+   const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT
    { return this->crend(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
@@ -331,7 +331,7 @@ class map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator cbegin() const
+   const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
    { return m_tree.begin(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
@@ -339,7 +339,7 @@ class map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator cend() const
+   const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
    { return m_tree.end(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
@@ -348,7 +348,7 @@ class map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin() const
+   const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT
    { return m_tree.rbegin(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
@@ -357,7 +357,7 @@ class map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator crend() const
+   const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
    { return m_tree.rend(); }
 
    //////////////////////////////////////////////
@@ -371,7 +371,7 @@ class map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   bool empty() const
+   bool empty() const BOOST_CONTAINER_NOEXCEPT
    { return m_tree.empty(); }
 
    //! Effects: Returns the number of the elements contained in the container.
@@ -379,7 +379,7 @@ class map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type size() const
+   size_type size() const BOOST_CONTAINER_NOEXCEPT
    { return m_tree.size(); }
 
    //! Effects: Returns the largest possible size of the container.
@@ -387,7 +387,7 @@ class map
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type max_size() const
+   size_type max_size() const BOOST_CONTAINER_NOEXCEPT
    { return m_tree.max_size(); }
 
    //////////////////////////////////////////////
@@ -621,7 +621,7 @@ class map
    //!   returns end().
    //!
    //! Complexity: Amortized constant time
-   iterator erase(const_iterator position)
+   iterator erase(const_iterator position) BOOST_CONTAINER_NOEXCEPT
    { return m_tree.erase(position); }
 
    //! Effects: Erases all elements in the container with key equivalent to x.
@@ -629,7 +629,7 @@ class map
    //! Returns: Returns the number of erased elements.
    //!
    //! Complexity: log(size()) + count(k)
-   size_type erase(const key_type& x)
+   size_type erase(const key_type& x) BOOST_CONTAINER_NOEXCEPT
    { return m_tree.erase(x); }
 
    //! Effects: Erases all the elements in the range [first, last).
@@ -637,7 +637,7 @@ class map
    //! Returns: Returns last.
    //!
    //! Complexity: log(size())+N where N is the distance from first to last.
-   iterator erase(const_iterator first, const_iterator last)
+   iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
    { return m_tree.erase(first, last); }
 
    //! Effects: Swaps the contents of *this and x.
@@ -653,7 +653,7 @@ class map
    //! Postcondition: size() == 0.
    //!
    //! Complexity: linear in size().
-   void clear()
+   void clear() BOOST_CONTAINER_NOEXCEPT
    { m_tree.clear(); }
 
    //////////////////////////////////////////////
@@ -827,15 +827,15 @@ inline bool operator<(const multimap& x,
                       const multimap& y);
 
 }  //namespace container {
-/*
+
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
 template 
 struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor_after_move::value && has_trivial_destructor_after_move::value;
 };
-*/
+
 namespace container {
 
 /// @endcond
@@ -951,9 +951,9 @@ class multimap
    //!
    //! Complexity: Linear in N.
    template 
-   multimap(ordered_range_t ordered_range_, InputIterator first, InputIterator last, const Compare& comp = Compare(),
+   multimap(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp = Compare(),
          const allocator_type& a = allocator_type())
-      : m_tree(ordered_range_, first, last, comp, a)
+      : m_tree(ordered_range, first, last, comp, a)
    {}
 
    //! Effects: Copy constructs a multimap.
@@ -1016,7 +1016,7 @@ class multimap
    //!   was passed to the object's constructor.
    //!
    //! Complexity: Constant.
-   allocator_type get_allocator() const
+   allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
    { return m_tree.get_allocator(); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -1026,7 +1026,7 @@ class multimap
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   stored_allocator_type &get_stored_allocator()
+   stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
    { return m_tree.get_stored_allocator(); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -1036,7 +1036,7 @@ class multimap
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   const stored_allocator_type &get_stored_allocator() const
+   const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
    { return m_tree.get_stored_allocator(); }
 
    //////////////////////////////////////////////
@@ -1050,7 +1050,7 @@ class multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator begin()
+   iterator begin() BOOST_CONTAINER_NOEXCEPT
    { return m_tree.begin(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
@@ -1058,7 +1058,7 @@ class multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator begin() const
+   const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
    { return this->cbegin(); }
 
    //! Effects: Returns an iterator to the end of the container.
@@ -1066,7 +1066,7 @@ class multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator end()
+   iterator end() BOOST_CONTAINER_NOEXCEPT
    { return m_tree.end(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
@@ -1074,7 +1074,7 @@ class multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator end() const
+   const_iterator end() const BOOST_CONTAINER_NOEXCEPT
    { return this->cend(); }
 
    //! Effects: Returns a reverse_iterator pointing to the beginning
@@ -1083,7 +1083,7 @@ class multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reverse_iterator rbegin()
+   reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT
    { return m_tree.rbegin(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
@@ -1092,7 +1092,7 @@ class multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator rbegin() const
+   const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
    { return this->crbegin(); }
 
    //! Effects: Returns a reverse_iterator pointing to the end
@@ -1101,7 +1101,7 @@ class multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reverse_iterator rend()
+   reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT
    { return m_tree.rend(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
@@ -1110,7 +1110,7 @@ class multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator rend() const
+   const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT
    { return this->crend(); }
 
    //! Effects: Returns a const_iterator to the first element contained in the container.
@@ -1118,7 +1118,7 @@ class multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator cbegin() const
+   const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
    { return m_tree.begin(); }
 
    //! Effects: Returns a const_iterator to the end of the container.
@@ -1126,7 +1126,7 @@ class multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator cend() const
+   const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
    { return m_tree.end(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
@@ -1135,7 +1135,7 @@ class multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin() const
+   const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT
    { return m_tree.rbegin(); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
@@ -1144,7 +1144,7 @@ class multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator crend() const
+   const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
    { return m_tree.rend(); }
 
    //////////////////////////////////////////////
@@ -1158,7 +1158,7 @@ class multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   bool empty() const
+   bool empty() const BOOST_CONTAINER_NOEXCEPT
    { return m_tree.empty(); }
 
    //! Effects: Returns the number of the elements contained in the container.
@@ -1166,7 +1166,7 @@ class multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type size() const
+   size_type size() const BOOST_CONTAINER_NOEXCEPT
    { return m_tree.size(); }
 
    //! Effects: Returns the largest possible size of the container.
@@ -1174,7 +1174,7 @@ class multimap
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type max_size() const
+   size_type max_size() const BOOST_CONTAINER_NOEXCEPT
    { return m_tree.max_size(); }
 
    //////////////////////////////////////////////
@@ -1317,7 +1317,7 @@ class multimap
    //!   returns end().
    //!
    //! Complexity: Amortized constant time
-   iterator erase(const_iterator position)
+   iterator erase(const_iterator position) BOOST_CONTAINER_NOEXCEPT
    { return m_tree.erase(position); }
 
    //! Effects: Erases all elements in the container with key equivalent to x.
@@ -1325,7 +1325,7 @@ class multimap
    //! Returns: Returns the number of erased elements.
    //!
    //! Complexity: log(size()) + count(k)
-   size_type erase(const key_type& x)
+   size_type erase(const key_type& x) BOOST_CONTAINER_NOEXCEPT
    { return m_tree.erase(x); }
 
    //! Effects: Erases all the elements in the range [first, last).
@@ -1333,7 +1333,7 @@ class multimap
    //! Returns: Returns last.
    //!
    //! Complexity: log(size())+N where N is the distance from first to last.
-   iterator erase(const_iterator first, const_iterator last)
+   iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
    { return m_tree.erase(first, last); }
 
    //! Effects: Swaps the contents of *this and x.
@@ -1349,7 +1349,7 @@ class multimap
    //! Postcondition: size() == 0.
    //!
    //! Complexity: linear in size().
-   void clear()
+   void clear() BOOST_CONTAINER_NOEXCEPT
    { m_tree.clear(); }
 
    //////////////////////////////////////////////
@@ -1486,15 +1486,15 @@ inline void swap(multimap& x, multimap == true_type
 //!specialization for optimizations
 template 
 struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor_after_move::value && has_trivial_destructor_after_move::value;
 };
-*/
+
 namespace container {
 
 /// @endcond
diff --git a/include/boost/container/scoped_allocator.hpp b/include/boost/container/scoped_allocator.hpp
index c49c3cf..39fd4da 100644
--- a/include/boost/container/scoped_allocator.hpp
+++ b/include/boost/container/scoped_allocator.hpp
@@ -30,8 +30,8 @@
 #include 
 #include 
 #include 
-#include 
-
+#include 
+#include 
 
 namespace boost { namespace container {
 
@@ -1338,52 +1338,56 @@ class scoped_allocator_adaptor
    void construct_pair(Pair* p)
    {
       this->construct(container_detail::addressof(p->first));
-      try {
+      BOOST_TRY{
          this->construct(container_detail::addressof(p->second));
       }
-      catch (...) {
+      BOOST_CATCH(...){
          this->destroy(container_detail::addressof(p->first));
-         throw;
+         BOOST_RETHROW
       }
+      BOOST_CATCH_END
    }
 
    template 
    void construct_pair(Pair* p, BOOST_FWD_REF(U) x, BOOST_FWD_REF(V) y)
    {
       this->construct(container_detail::addressof(p->first), ::boost::forward(x));
-      try {
+      BOOST_TRY{
          this->construct(container_detail::addressof(p->second), ::boost::forward(y));
       }
-      catch (...) {
+      BOOST_CATCH(...){
          this->destroy(container_detail::addressof(p->first));
-         throw;
+         BOOST_RETHROW
       }
+      BOOST_CATCH_END
    }
 
    template 
    void construct_pair(Pair* p, const Pair2& pr)
    {
       this->construct(container_detail::addressof(p->first), pr.first);
-      try {
+      BOOST_TRY{
          this->construct(container_detail::addressof(p->second), pr.second);
       }
-      catch (...) {
+      BOOST_CATCH(...){
          this->destroy(container_detail::addressof(p->first));
-         throw;
+         BOOST_RETHROW
       }
+      BOOST_CATCH_END
    }
 
    template 
    void construct_pair(Pair* p, BOOST_RV_REF(Pair2) pr)
    {
       this->construct(container_detail::addressof(p->first), ::boost::move(pr.first));
-      try {
+      BOOST_TRY{
          this->construct(container_detail::addressof(p->second), ::boost::move(pr.second));
       }
-      catch (...) {
+      BOOST_CATCH(...){
          this->destroy(container_detail::addressof(p->first));
-         throw;
+         BOOST_RETHROW
       }
+      BOOST_CATCH_END
    }
 
    //template 
diff --git a/include/boost/container/set.hpp b/include/boost/container/set.hpp
index 3c6fcd5..0b49376 100644
--- a/include/boost/container/set.hpp
+++ b/include/boost/container/set.hpp
@@ -23,11 +23,11 @@
 #include 
 #include 
 
-#include 
-#include 
+#include 
+#include 
 #include 
 #include 
-#include 
+#include 
 #ifndef BOOST_CONTAINER_PERFECT_FORWARDING
 #include 
 #endif
@@ -646,15 +646,15 @@ inline void swap(set& x, set& y)
 /// @cond
 
 }  //namespace container {
-/*
+
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
 template 
 struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor_after_move::value && has_trivial_destructor_after_move::value;
 };
-*/
+
 namespace container {
 
 // Forward declaration of operators < and ==, needed for friend declaration.
@@ -757,10 +757,10 @@ class multiset
    //!
    //! Complexity: Linear in N.
    template 
-   multiset( ordered_range_t ordered_range_, InputIterator first, InputIterator last
+   multiset( ordered_range_t, InputIterator first, InputIterator last
            , const Compare& comp = Compare()
            , const allocator_type& a = allocator_type())
-      : m_tree(ordered_range_, first, last, comp, a)
+      : m_tree(ordered_range, first, last, comp, a)
    {}
 
    //! Effects: Copy constructs a multiset.
@@ -1259,15 +1259,15 @@ inline void swap(multiset& x, multiset == true_type
 //!specialization for optimizations
 template 
 struct has_trivial_destructor_after_move >
 {
-   static const bool value = has_trivial_destructor::value && has_trivial_destructor::value;
+   static const bool value = has_trivial_destructor_after_move::value && has_trivial_destructor_after_move::value;
 };
-*/
+
 namespace container {
 
 /// @endcond
diff --git a/include/boost/container/slist.hpp b/include/boost/container/slist.hpp
index c65a9a2..84cccda 100644
--- a/include/boost/container/slist.hpp
+++ b/include/boost/container/slist.hpp
@@ -19,8 +19,8 @@
 #include 
 
 #include 
-#include 
-#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -140,9 +140,6 @@ class slist_const_iterator
    friend bool operator!= (const slist_const_iterator& l, const slist_const_iterator& r)
    {  return l.m_it != r.m_it;  }
 
-   IIterator &get()
-   {  return this->m_it;   }
-
    const IIterator &get() const
    {  return this->m_it;   }
 };
@@ -181,9 +178,6 @@ class slist_iterator
    slist_iterator operator++(int)
    { IIterator tmp = this->m_it; ++*this; return slist_iterator(tmp); }
 
-   IIterator &get()
-   {  return this->m_it;   }
-
    const IIterator &get() const
    {  return this->m_it;   }
 };
@@ -319,10 +313,10 @@ class slist
 
    //! Effects: Constructs a list taking the allocator as parameter.
    //!
-   //! Throws: If allocator_type's copy constructor throws.
+   //! Throws: Nothing
    //!
    //! Complexity: Constant.
-   explicit slist(const allocator_type& a)
+   explicit slist(const allocator_type& a) BOOST_CONTAINER_NOEXCEPT
       :  AllocHolder(a)
    {}
 
@@ -407,7 +401,7 @@ class slist
    //! Throws: Nothing.
    //!
    //! Complexity: Linear to the number of elements.
-   ~slist()
+   ~slist() BOOST_CONTAINER_NOEXCEPT
    {} //AllocHolder clears the slist
 
    //! Effects: Makes *this contain the same elements as x.
@@ -511,7 +505,7 @@ class slist
    //! Throws: If allocator's copy constructor throws.
    //!
    //! Complexity: Constant.
-   allocator_type get_allocator() const
+   allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
    {  return allocator_type(this->node_alloc()); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -521,7 +515,7 @@ class slist
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   stored_allocator_type &get_stored_allocator()
+   stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
    {  return this->node_alloc(); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -531,7 +525,7 @@ class slist
    //! Complexity: Constant.
    //!
    //! Note: Non-standard extension.
-   const stored_allocator_type &get_stored_allocator() const
+   const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
    {  return this->node_alloc(); }
 
    //////////////////////////////////////////////
@@ -547,7 +541,7 @@ class slist
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator before_begin()
+   iterator before_begin() BOOST_CONTAINER_NOEXCEPT
    {  return iterator(end());  }
 
    //! Effects: Returns a non-dereferenceable const_iterator
@@ -557,7 +551,7 @@ class slist
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator before_begin() const
+   const_iterator before_begin() const BOOST_CONTAINER_NOEXCEPT
    {  return this->cbefore_begin();  }
 
    //! Effects: Returns an iterator to the first element contained in the list.
@@ -565,7 +559,7 @@ class slist
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator begin()
+   iterator begin() BOOST_CONTAINER_NOEXCEPT
    { return iterator(this->icont().begin()); }
 
    //! Effects: Returns a const_iterator to the first element contained in the list.
@@ -573,7 +567,7 @@ class slist
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator begin() const
+   const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
    {  return this->cbegin();   }
 
    //! Effects: Returns an iterator to the end of the list.
@@ -581,7 +575,7 @@ class slist
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator end()
+   iterator end() BOOST_CONTAINER_NOEXCEPT
    { return iterator(this->icont().end()); }
 
    //! Effects: Returns a const_iterator to the end of the list.
@@ -589,7 +583,7 @@ class slist
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator end() const
+   const_iterator end() const BOOST_CONTAINER_NOEXCEPT
    {  return this->cend();   }
 
    //! Effects: Returns a non-dereferenceable const_iterator
@@ -599,7 +593,7 @@ class slist
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator cbefore_begin() const
+   const_iterator cbefore_begin() const BOOST_CONTAINER_NOEXCEPT
    {  return const_iterator(end());  }
 
    //! Effects: Returns a const_iterator to the first element contained in the list.
@@ -607,7 +601,7 @@ class slist
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator cbegin() const
+   const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
    {  return const_iterator(this->non_const_icont().begin());   }
 
    //! Effects: Returns a const_iterator to the end of the list.
@@ -615,7 +609,7 @@ class slist
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator cend() const
+   const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
    {  return const_iterator(this->non_const_icont().end());   }
 
    //! Returns: The iterator to the element before i in the sequence.
@@ -627,7 +621,7 @@ class slist
    //! Complexity: Linear to the number of elements before i.
    //!
    //! Note: Non-standard extension.
-   iterator previous(iterator p)
+   iterator previous(iterator p) BOOST_CONTAINER_NOEXCEPT
    {  return iterator(this->icont().previous(p.get())); }
 
    //! Returns: The const_iterator to the element before i in the sequence.
@@ -986,9 +980,9 @@ class slist
    //!
    //! Note: 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_pos, slist& x)
+   void splice_after(const_iterator prev_pos, slist& x) BOOST_CONTAINER_NOEXCEPT
    {
-      BOOST_ASSERT(*this != x);
+      BOOST_ASSERT(this != &x);
       BOOST_ASSERT(this->node_alloc() == x.node_alloc());
       this->icont().splice_after(prev_pos.get(), x.icont());
    }
@@ -1006,65 +1000,63 @@ class slist
    //!
    //! Note: 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_pos, BOOST_RV_REF(slist) x)
+   void splice_after(const_iterator prev_pos, BOOST_RV_REF(slist) x) BOOST_CONTAINER_NOEXCEPT
    {  this->splice_after(prev_pos, static_cast(x));  }
 
    //! Requires: prev_pos must be a valid iterator of this.
    //!   i must point to an element contained in list x.
+   //!   this' allocator and x's allocator shall compare equal.
    //!
    //! Effects: Transfers the value pointed by i, from list x to this list,
    //!   after the element pointed by prev_pos.
    //!   If prev_pos == prev or prev_pos == ++prev, this function is a null operation.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Constant.
    //!
    //! Note: 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_pos, slist& x, const_iterator prev)
+   void splice_after(const_iterator prev_pos, slist& x, const_iterator prev) BOOST_CONTAINER_NOEXCEPT
    {
-      BOOST_ASSERT(*this != x);
       BOOST_ASSERT(this->node_alloc() == x.node_alloc());
       this->icont().splice_after(prev_pos.get(), x.icont(), prev.get());
    }
 
    //! Requires: prev_pos must be a valid iterator of this.
    //!   i must point to an element contained in list x.
+   //!   this' allocator and x's allocator shall compare equal.
    //!
    //! Effects: Transfers the value pointed by i, from list x to this list,
    //!   after the element pointed by prev_pos.
    //!   If prev_pos == prev or prev_pos == ++prev, this function is a null operation.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Constant.
    //!
    //! Note: 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_pos, BOOST_RV_REF(slist) x, const_iterator prev)
+   void splice_after(const_iterator prev_pos, BOOST_RV_REF(slist) x, const_iterator prev) BOOST_CONTAINER_NOEXCEPT
    {  this->splice_after(prev_pos, static_cast(x), prev);  }
 
    //! Requires: prev_pos must be a valid iterator of this.
    //!   before_first and before_last must be valid iterators of x.
    //!   prev_pos must not be contained in [before_first, before_last) range.
+   //!   this' allocator and x's allocator shall compare equal.
    //!
    //! Effects: Transfers the range [before_first + 1, before_last + 1)
    //!   from list x to this list, after the element pointed by prev_pos.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Linear to the number of transferred elements.
    //!
    //! Note: 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_pos,      slist& x,
-      const_iterator before_first,  const_iterator before_last)
+      const_iterator before_first,  const_iterator before_last) BOOST_CONTAINER_NOEXCEPT
    {
-      BOOST_ASSERT(*this != x);
       BOOST_ASSERT(this->node_alloc() == x.node_alloc());
       this->icont().splice_after
          (prev_pos.get(), x.icont(), before_first.get(), before_last.get());
@@ -1073,31 +1065,31 @@ class slist
    //! Requires: prev_pos must be a valid iterator of this.
    //!   before_first and before_last must be valid iterators of x.
    //!   prev_pos must not be contained in [before_first, before_last) range.
+   //!   this' allocator and x's allocator shall compare equal.
    //!
    //! Effects: Transfers the range [before_first + 1, before_last + 1)
    //!   from list x to this list, after the element pointed by prev_pos.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Linear to the number of transferred elements.
    //!
    //! Note: 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_pos,      BOOST_RV_REF(slist) x,
-      const_iterator before_first,  const_iterator before_last)
+      const_iterator before_first,  const_iterator before_last) BOOST_CONTAINER_NOEXCEPT
    {  this->splice_after(prev_pos, static_cast(x), before_first, before_last);  }
 
    //! Requires: prev_pos must be a valid iterator of this.
    //!   before_first and before_last must be valid iterators of x.
    //!   prev_pos must not be contained in [before_first, before_last) range.
-   //!   n == std::distance(before_first, before_last)
+   //!   n == std::distance(before_first, before_last).
+   //!   this' allocator and x's allocator shall compare equal.
    //!
    //! Effects: Transfers the range [before_first + 1, before_last + 1)
    //!   from list x to this list, after the element pointed by prev_pos.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Constant.
    //!
@@ -1105,9 +1097,8 @@ class slist
    //!   list. Iterators of this list and all the references are not invalidated.
    void splice_after(const_iterator prev_pos,      slist& x,
                      const_iterator before_first,  const_iterator before_last,
-                     size_type n)
+                     size_type n) BOOST_CONTAINER_NOEXCEPT
    {
-      BOOST_ASSERT(*this != x);
       BOOST_ASSERT(this->node_alloc() == x.node_alloc());
       this->icont().splice_after
          (prev_pos.get(), x.icont(), before_first.get(), before_last.get(), n);
@@ -1116,13 +1107,13 @@ class slist
    //! Requires: prev_pos must be a valid iterator of this.
    //!   before_first and before_last must be valid iterators of x.
    //!   prev_pos must not be contained in [before_first, before_last) range.
-   //!   n == std::distance(before_first, before_last)
+   //!   n == std::distance(before_first, before_last).
+   //!   this' allocator and x's allocator shall compare equal.
    //!
    //! Effects: Transfers the range [before_first + 1, before_last + 1)
    //!   from list x to this list, after the element pointed by prev_pos.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Constant.
    //!
@@ -1130,7 +1121,7 @@ class slist
    //!   list. Iterators of this list and all the references are not invalidated.
    void splice_after(const_iterator prev_pos,      BOOST_RV_REF(slist) x,
                      const_iterator before_first,  const_iterator before_last,
-                     size_type n)
+                     size_type n) BOOST_CONTAINER_NOEXCEPT
    {  this->splice_after(prev_pos, static_cast(x), before_first, before_last, n);  }
 
    //! Effects: Removes all the elements that compare equal to value.
@@ -1163,9 +1154,9 @@ class slist
    //! Effects: Removes adjacent duplicate elements or adjacent
    //!   elements that are equal from the list.
    //!
-   //! Throws: Nothing.
+   //! Throws: If comparison throws.
    //!
-   //! Complexity: Linear time (size()-1 comparisons calls to pred()).
+   //! Complexity: Linear time (size()-1 comparisons equality comparisons).
    //!
    //! Note: The relative order of elements that are not removed is unchanged,
    //!   and iterators to elements that are not removed remain valid.
@@ -1177,7 +1168,7 @@ class slist
    //!
    //! Throws: If pred throws.
    //!
-   //! Complexity: Linear time (size()-1 comparisons equality comparisons).
+   //! Complexity: Linear time (size()-1 comparisons calls to pred()).
    //!
    //! Note: The relative order of elements that are not removed is unchanged,
    //!   and iterators to elements that are not removed remain valid.
@@ -1195,7 +1186,7 @@ class slist
    //!   that is, if an element from *this is equivalent to one from x, then the element
    //!   from *this will precede the one from x.
    //!
-   //! Throws: Nothing.
+   //! Throws: If comparison throws.
    //!
    //! Complexity: This function is linear time: it performs at most
    //!   size() + x.size() - 1 comparisons.
@@ -1209,7 +1200,7 @@ class slist
    //!   that is, if an element from *this is equivalent to one from x, then the element
    //!   from *this will precede the one from x.
    //!
-   //! Throws: Nothing.
+   //! Throws: If comparison throws.
    //!
    //! Complexity: This function is linear time: it performs at most
    //!   size() + x.size() - 1 comparisons.
@@ -1224,7 +1215,7 @@ class slist
    //!   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.
    //!
-   //! Throws: Nothing.
+   //! Throws: If comp throws.
    //!
    //! Complexity: This function is linear time: it performs at most
    //!   size() + x.size() - 1 comparisons.
@@ -1233,13 +1224,9 @@ class slist
    template 
    void merge(slist& x, StrictWeakOrdering comp)
    {
-      if((NodeAlloc&)*this == (NodeAlloc&)x){
-         this->icont().merge(x.icont(),
-            ValueCompareToNodeCompare(comp));
-      }
-      else{
-         throw std::runtime_error("list::merge called with unequal allocators");
-      }
+      BOOST_ASSERT(this->node_alloc() == x.node_alloc());
+      this->icont().merge(x.icont(),
+         ValueCompareToNodeCompare(comp));
    }
 
    //! Requires: p must be a comparison function that induces a strict weak
@@ -1250,7 +1237,7 @@ class slist
    //!   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.
    //!
-   //! Throws: Nothing.
+   //! Throws: If comp throws.
    //!
    //! Complexity: This function is linear time: it performs at most
    //!   size() + x.size() - 1 comparisons.
@@ -1263,7 +1250,7 @@ class slist
    //! Effects: This function sorts the list *this according to std::less.
    //!   The sort is stable, that is, the relative order of equivalent elements is preserved.
    //!
-   //! Throws: Nothing.
+   //! Throws: If comparison throws.
    //!
    //! Notes: Iterators and references are not invalidated.
    //!
@@ -1275,7 +1262,7 @@ class slist
    //! Effects: This function sorts the list *this according to std::less.
    //!   The sort is stable, that is, the relative order of equivalent elements is preserved.
    //!
-   //! Throws: Nothing.
+   //! Throws: If comp throws.
    //!
    //! Notes: Iterators and references are not invalidated.
    //!
@@ -1297,7 +1284,7 @@ class slist
    //! Complexity: This function is linear time.
    //!
    //! Note: Iterators and references are not invalidated
-   void reverse()
+   void reverse() BOOST_CONTAINER_NOEXCEPT
    {  this->icont().reverse();  }
 
    //////////////////////////////////////////////
@@ -1403,7 +1390,7 @@ class slist
    //! Throws: Nothing.
    //!
    //! Complexity: Linear to the number of elements before p.
-   iterator erase(const_iterator p)
+   iterator erase(const_iterator p) BOOST_CONTAINER_NOEXCEPT
    {  return iterator(this->erase_after(previous(p))); }
 
    //! Requires: first and last must be valid iterator to elements in *this.
@@ -1414,73 +1401,71 @@ class slist
    //!
    //! Complexity: Linear to the distance between first and last plus
    //!   linear to the elements before first.
-   iterator erase(const_iterator first, const_iterator last)
+   iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
    {  return iterator(this->erase_after(previous(first), last)); }
 
    //! Requires: p must point to an element contained
-   //!   by the list. x != *this
+   //!   by the list. x != *this. this' allocator and x's allocator shall compare equal
    //!
    //! Effects: Transfers all the elements of list x to this list, before the
    //!   the element pointed by p. No destructors or copy constructors are called.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Linear in distance(begin(), p), and linear in x.size().
    //!
    //! Note: 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)
+   void splice(const_iterator p, slist& x) BOOST_CONTAINER_NOEXCEPT
    {  this->splice_after(this->previous(p), x);  }
 
    //! Requires: p must point to an element contained
-   //!   by the list. x != *this
+   //!   by the list. x != *this. this' allocator and x's allocator shall compare equal
    //!
    //! Effects: Transfers all the elements of list x to this list, before the
    //!   the element pointed by p. No destructors or copy constructors are called.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Linear in distance(begin(), p), and linear in x.size().
    //!
    //! Note: 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)
+   void splice(const_iterator p, BOOST_RV_REF(slist) x) BOOST_CONTAINER_NOEXCEPT
    {  this->splice(p, static_cast(x));  }
 
    //! Requires: p must point to an element contained
    //!   by this list. i must point to an element contained in list x.
+   //!   this' allocator and x's allocator shall compare equal
    //!
    //! Effects: 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.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Linear in distance(begin(), p), and in distance(x.begin(), i).
    //!
    //! Note: 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)
+   void splice(const_iterator p, slist& x, const_iterator i) BOOST_CONTAINER_NOEXCEPT
    {  this->splice_after(this->previous(p), x, this->previous(i));  }
 
    //! Requires: p must point to an element contained
    //!   by this list. i must point to an element contained in list x.
+   //!   this' allocator and x's allocator shall compare equal.
    //!
    //! Effects: 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.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Linear in distance(begin(), p), and in distance(x.begin(), i).
    //!
    //! Note: 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)
+   void splice(const_iterator p, BOOST_RV_REF(slist) x, const_iterator i) BOOST_CONTAINER_NOEXCEPT
    {  this->splice(p, static_cast(x), i);  }
 
    //! Requires: p must point to an element contained
@@ -1488,33 +1473,33 @@ class slist
    //!
    //! Effects: 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.
+   //!   this' allocator and x's allocator shall compare equal.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Linear in distance(begin(), p), in distance(x.begin(), first),
    //!   and in distance(first, last).
    //!
    //! Note: 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)
+   void splice(const_iterator p, slist& x, const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
    {  this->splice_after(this->previous(p), x, this->previous(first), this->previous(last));  }
 
    //! Requires: p must point to an element contained
    //!   by this list. first and last must point to elements contained in list x.
+   //!   this' allocator and x's allocator shall compare equal
    //!
    //! Effects: 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.
    //!
-   //! Throws: std::runtime_error if this' allocator and x's allocator
-   //!   are not equal.
+   //! Throws: Nothing
    //!
    //! Complexity: Linear in distance(begin(), p), in distance(x.begin(), first),
    //!   and in distance(first, last).
    //!
    //! Note: 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)
+   void splice(const_iterator p, BOOST_RV_REF(slist) x, const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
    {  this->splice(p, static_cast(x), first, last);  }
 
    /// @cond
@@ -1658,15 +1643,14 @@ inline void swap(slist& x, slist& y)
 /// @cond
 
 namespace boost {
-/*
+
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
 template 
 struct has_trivial_destructor_after_move >
-{
-   static const bool value = has_trivial_destructor::value;
-};
-*/
+   : public ::boost::has_trivial_destructor_after_move
+{};
+
 namespace container {
 
 /// @endcond
diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp
index 8d23672..539b2da 100644
--- a/include/boost/container/stable_vector.hpp
+++ b/include/boost/container/stable_vector.hpp
@@ -1,4 +1,4 @@
-//////////////////////////////////////////////////////////////////////////////
+
 //
 // (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost
 // Software License, Version 1.0. (See accompanying file
@@ -29,15 +29,16 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include  //max
 #include 
 #include 
@@ -303,7 +304,7 @@ struct index_traits
    static const size_type ExtraPointers = 3;
    //Stable vector stores metadata at the end of the index (node_base_ptr vector) with additional 3 pointers:
    //    back() is this->index.back() - ExtraPointers;
-   //    end node index is    *(this->index.end() -3)
+   //    end node index is    *(this->index.end() - 3)
    //    Node cache first is  *(this->index.end() - 2);
    //    Node cache last is   this->index.back();
 
@@ -366,89 +367,6 @@ struct index_traits
    #endif   //STABLE_VECTOR_ENABLE_INVARIANT_CHECKING
 };
 
-template::value>
-struct allocator_version_wrapper
-{
-   typedef ::boost::container::container_detail::integral_constant
-       alloc_version;
-
-   typedef typename Allocator::multiallocation_chain multiallocation_chain;
-
-   typedef typename boost::container::allocator_traits::pointer    pointer;
-   typedef typename boost::container::allocator_traits::size_type  size_type;
-
-   static pointer allocate_one(Allocator &a)
-   {  return a.allocate_one();   }
-
-   static void deallocate_one(Allocator &a, const pointer &p)
-   {  a.deallocate_one(p);   }
-
-   static multiallocation_chain allocate_individual(Allocator &a, size_type n)
-   {  return a.allocate_individual(n);   }
-
-   static void deallocate_individual(Allocator &a, multiallocation_chain &holder)
-   {  a.deallocate_individual(::boost::move(holder));   }
-};
-
-template
-struct allocator_version_wrapper
-{
-   typedef ::boost::container::container_detail::integral_constant
-       alloc_version;
-
-   typedef typename boost::container::allocator_traits::pointer    pointer;
-   typedef typename boost::container::allocator_traits::size_type  size_type;
-   typedef typename boost::container::allocator_traits::value_type value_type;
-
-   typedef typename boost::intrusive::pointer_traits::
-         template rebind_pointer::type                void_ptr;
-   typedef container_detail::basic_multiallocation_chain
-                                                  multialloc_cached_counted;
-   typedef boost::container::container_detail::
-      transform_multiallocation_chain
-         < multialloc_cached_counted, value_type>           multiallocation_chain;
-
-   static pointer allocate_one(Allocator &a)
-   {  return a.allocate(1);   }
-
-   static void deallocate_one(Allocator &a, const pointer &p)
-   {  a.deallocate(p, 1);   }
-
-   static void deallocate_individual(Allocator &a, multiallocation_chain &holder)
-   {
-      while(!holder.empty()){
-         a.deallocate(holder.pop_front(), 1);
-      }
-   }
-
-   struct allocate_individual_rollback
-   {
-      allocate_individual_rollback(Allocator &a, multiallocation_chain &chain)
-         : mr_a(a), mr_chain(chain)
-      {}
-
-      ~allocate_individual_rollback()
-      {
-         allocator_version_wrapper::deallocate_individual(mr_a, mr_chain);
-      }
-
-      Allocator &mr_a;
-      multiallocation_chain &mr_chain;
-   };
-
-   static multiallocation_chain allocate_individual(Allocator &a, size_type n)
-   {
-      multiallocation_chain m;
-      multiallocation_chain m_ret;
-      allocate_individual_rollback rollback(a, m);
-      while(n--){
-         m.push_front(a.allocate(1));
-      }
-      m.swap(m_ret);
-      return ::boost::move(m_ret);
-   }
-};
-
 } //namespace stable_vector_detail
 
 #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -555,20 +473,21 @@ class stable_vector
       template portable_rebind_alloc
          ::type                            node_allocator_type;
 
-   typedef stable_vector_detail::allocator_version_wrapper allocator_version_wrapper_t;
-   typedef typename allocator_version_wrapper_t::multiallocation_chain multiallocation_chain;
+   typedef ::boost::container::container_detail::
+      allocator_version_traits                    allocator_version_traits_t;
+   typedef typename allocator_version_traits_t::multiallocation_chain  multiallocation_chain;
 
    node_ptr allocate_one()
-   {  return allocator_version_wrapper_t::allocate_one(this->priv_node_alloc());   }
+   {  return allocator_version_traits_t::allocate_one(this->priv_node_alloc());   }
 
    void deallocate_one(const node_ptr &p)
-   {  allocator_version_wrapper_t::deallocate_one(this->priv_node_alloc(), p);   }
+   {  allocator_version_traits_t::deallocate_one(this->priv_node_alloc(), p);   }
 
-   multiallocation_chain allocate_individual(typename allocator_traits_type::size_type n)
-   {  return allocator_version_wrapper_t::allocate_individual(this->priv_node_alloc(), n);   }
+   void allocate_individual(typename allocator_traits_type::size_type n, multiallocation_chain &m)
+   {  allocator_version_traits_t::allocate_individual(this->priv_node_alloc(), n, m);   }
 
    void deallocate_individual(multiallocation_chain &holder)
-   {  allocator_version_wrapper_t::deallocate_individual(this->priv_node_alloc(), holder);   }
+   {  allocator_version_traits_t::deallocate_individual(this->priv_node_alloc(), holder);   }
 
    friend class stable_vector_detail::clear_on_destroy;
    typedef stable_vector_detail::iterator
@@ -633,10 +552,10 @@ class stable_vector
 
    //! Effects: Constructs a stable_vector taking the allocator as parameter.
    //!
-   //! Throws: If allocator_type's copy constructor throws.
+   //! Throws: Nothing
    //!
    //! Complexity: Constant.
-   explicit stable_vector(const allocator_type& al)
+   explicit stable_vector(const allocator_type& al) BOOST_CONTAINER_NOEXCEPT
       : internal_data(al), index(al)
    {
       STABLE_VECTOR_CHECK_INVARIANT;
@@ -904,7 +823,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator  begin()
+   iterator  begin() BOOST_CONTAINER_NOEXCEPT
    {   return (this->index.empty()) ? this->end(): iterator(node_ptr_traits::static_cast_from(this->index.front())); }
 
    //! Effects: Returns a const_iterator to the first element contained in the stable_vector.
@@ -912,7 +831,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator  begin()const
+   const_iterator  begin() const BOOST_CONTAINER_NOEXCEPT
    {   return (this->index.empty()) ? this->cend() : const_iterator(node_ptr_traits::static_cast_from(this->index.front())) ;   }
 
    //! Effects: Returns an iterator to the end of the stable_vector.
@@ -920,7 +839,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   iterator        end()
+   iterator        end() BOOST_CONTAINER_NOEXCEPT
    {  return iterator(this->priv_get_end_node());  }
 
    //! Effects: Returns a const_iterator to the end of the stable_vector.
@@ -928,7 +847,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator  end() const
+   const_iterator  end() const BOOST_CONTAINER_NOEXCEPT
    {  return const_iterator(this->priv_get_end_node());  }
 
    //! Effects: Returns a reverse_iterator pointing to the beginning
@@ -937,7 +856,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reverse_iterator       rbegin()
+   reverse_iterator       rbegin() BOOST_CONTAINER_NOEXCEPT
    {  return reverse_iterator(this->end());  }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
@@ -946,7 +865,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator rbegin() const
+   const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
    {  return const_reverse_iterator(this->end());  }
 
    //! Effects: Returns a reverse_iterator pointing to the end
@@ -955,7 +874,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reverse_iterator       rend()
+   reverse_iterator       rend() BOOST_CONTAINER_NOEXCEPT
    {  return reverse_iterator(this->begin());   }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
@@ -964,7 +883,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator rend()const
+   const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT
    {  return const_reverse_iterator(this->begin());   }
 
    //! Effects: Returns a const_iterator to the first element contained in the stable_vector.
@@ -972,7 +891,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator         cbegin() const
+   const_iterator         cbegin() const BOOST_CONTAINER_NOEXCEPT
    {  return this->begin();   }
 
    //! Effects: Returns a const_iterator to the end of the stable_vector.
@@ -980,7 +899,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_iterator         cend()const
+   const_iterator         cend() const BOOST_CONTAINER_NOEXCEPT
    {  return this->end();  }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
@@ -989,7 +908,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator crbegin() const
+   const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT
    {  return this->rbegin();  }
 
    //! Effects: Returns a const_reverse_iterator pointing to the end
@@ -998,7 +917,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reverse_iterator crend()const
+   const_reverse_iterator crend()const BOOST_CONTAINER_NOEXCEPT
    {  return this->rend(); }
 
    //////////////////////////////////////////////
@@ -1012,7 +931,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   bool empty() const
+   bool empty() const BOOST_CONTAINER_NOEXCEPT
    {  return this->index.size() <= ExtraPointers;  }
 
    //! Effects: Returns the number of the elements contained in the stable_vector.
@@ -1020,7 +939,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type size() const
+   size_type size() const BOOST_CONTAINER_NOEXCEPT
    {
       const size_type index_size = this->index.size();
       return index_size ? (index_size - ExtraPointers) : 0;
@@ -1031,7 +950,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type max_size() const
+   size_type max_size() const BOOST_CONTAINER_NOEXCEPT
    {  return this->index.max_size() - ExtraPointers;  }
 
    //! Effects: Inserts or erases elements at the end such that
@@ -1071,7 +990,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type capacity() const
+   size_type capacity() const BOOST_CONTAINER_NOEXCEPT
    {
       const size_type index_size             = this->index.size();
       BOOST_ASSERT(!index_size || index_size >= ExtraPointers);
@@ -1094,7 +1013,7 @@ class stable_vector
       if(n > this->max_size())
          throw std::bad_alloc();
 
-      size_type size_        = this->size();  
+      size_type sz         = this->size();  
       size_type old_capacity = this->capacity();
       if(n > old_capacity){
          index_traits_type::initialize_end_node(this->index, this->internal_data.end_node, n);
@@ -1106,8 +1025,8 @@ class stable_vector
             index_traits_type::fix_up_pointers_from(this->index, this->index.begin());
          }
          //Now fill pool if data is not enough
-         if((n - size_) > this->internal_data.pool_size){
-            this->priv_increase_pool((n - size_) - this->internal_data.pool_size);
+         if((n - sz) > this->internal_data.pool_size){
+            this->priv_increase_pool((n - sz) - this->internal_data.pool_size);
          }
       }
    }
@@ -1156,7 +1075,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reference front()
+   reference front() BOOST_CONTAINER_NOEXCEPT
    {  return static_cast(*this->index.front()).value;  }
 
    //! Requires: !empty()
@@ -1167,7 +1086,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reference front() const
+   const_reference front() const BOOST_CONTAINER_NOEXCEPT
    {  return static_cast(*this->index.front()).value;  }
 
    //! Requires: !empty()
@@ -1178,7 +1097,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reference back()
+   reference back() BOOST_CONTAINER_NOEXCEPT
    {  return static_cast(*this->index[this->size() - ExtraPointers]).value;  }
 
    //! Requires: !empty()
@@ -1189,7 +1108,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reference back()const
+   const_reference back() const BOOST_CONTAINER_NOEXCEPT
    {  return static_cast(*this->index[this->size() - ExtraPointers]).value;  }
 
    //! Requires: size() > n.
@@ -1200,7 +1119,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reference operator[](size_type n)
+   reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT
    {  return static_cast(*this->index[n]).value;  }
 
    //! Requires: size() > n.
@@ -1211,7 +1130,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reference operator[](size_type n)const
+   const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT
    {  return static_cast(*this->index[n]).value;   }
 
    //! Requires: size() > n.
@@ -1400,7 +1319,7 @@ class stable_vector
    //!
    //! Complexity: Linear to std::distance [first, last).
    template 
-   iterator insert(const_iterator position,InputIterator first, InputIterator last
+   iterator insert(const_iterator position, InputIterator first, InputIterator last
       #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
       , typename container_detail::enable_if_c
          < !container_detail::is_convertible::value
@@ -1426,8 +1345,8 @@ class stable_vector
          >::type * = 0
       )
    {
-      const size_type num_new    = (size_type)std::distance(first,last);
-      const size_type pos        = static_cast(position - this->cbegin());
+      const size_type num_new = static_cast(std::distance(first, last));
+      const size_type pos     = static_cast(position - this->cbegin());
       if(num_new){
          //Fills the node pool and inserts num_new null pointers in pos.
          //If a new buffer was needed fixes up pointers up to pos so
@@ -1463,7 +1382,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant time.
-   void pop_back()
+   void pop_back() BOOST_CONTAINER_NOEXCEPT
    {  this->erase(--this->cend());   }
 
    //! Effects: Erases the element at position pos.
@@ -1472,15 +1391,15 @@ class stable_vector
    //!
    //! Complexity: Linear to the elements between pos and the
    //!   last element. Constant if pos is the last element.
-   iterator erase(const_iterator position)
+   iterator erase(const_iterator position) BOOST_CONTAINER_NOEXCEPT
    {
       STABLE_VECTOR_CHECK_INVARIANT;
-      difference_type d = position - this->cbegin();
-      index_iterator   it = this->index.begin() + d;
+      const size_type d = position - this->cbegin();
+      index_iterator it = this->index.begin() + d;
       this->priv_delete_node(position.node_pointer());
       it = this->index.erase(it);
       index_traits_type::fix_up_pointers_from(this->index, it);
-      return this->begin()+d;
+      return iterator(node_ptr_traits::static_cast_from(*it));
    }
 
    //! Effects: Erases the elements pointed by [first, last).
@@ -1489,19 +1408,30 @@ class stable_vector
    //!
    //! Complexity: Linear to the distance between first and last
    //!   plus linear to the elements between pos and the last element.
-   iterator erase(const_iterator first, const_iterator last)
+   iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
    {
       STABLE_VECTOR_CHECK_INVARIANT;
-      difference_type d1 = first - this->cbegin(), d2 = last - this->cbegin();
-      if(d1 != d2){
-         index_iterator it1(this->index.begin() + d1), it2(it1 + (d2 - d1));
-         for(index_iterator it = it1; it != it2; ++it){
-            this->priv_delete_node(node_ptr_traits::static_cast_from(*it));
+      const const_iterator cbeg(this->cbegin());
+      const size_type d1 = static_cast(first - cbeg),
+                      d2 = static_cast(last  - cbeg);
+      size_type d_dif = d2 - d1;
+      if(d_dif){
+         multiallocation_chain holder;
+         const index_iterator it1(this->index.begin() + d1);
+         const index_iterator it2(it1 + d_dif);
+         index_iterator it(it1);
+         while(d_dif--){
+            node_base_ptr &nb = *it;
+            ++it;
+            node_type &n = *node_ptr_traits::static_cast_from(nb);
+            this->priv_destroy_node(n);
+            holder.push_back(node_ptr_traits::pointer_to(n));
          }
+         this->priv_put_in_pool(holder);
          const index_iterator e = this->index.erase(it1, it2);
          index_traits_type::fix_up_pointers_from(this->index, e);
       }
-      return iterator(this->begin() + d1);
+      return iterator(last.node_pointer());
    }
 
    //! Effects: Swaps the contents of *this and x.
@@ -1524,7 +1454,7 @@ class stable_vector
    //! Throws: Nothing.
    //!
    //! Complexity: Linear to the number of elements in the stable_vector.
-   void clear()
+   void clear() BOOST_CONTAINER_NOEXCEPT
    {   this->erase(this->cbegin(),this->cend()); }
 
    /// @cond
@@ -1666,7 +1596,8 @@ class stable_vector
                               , node_ptr_traits::static_cast_from(pool_first_ref)
                               , node_ptr_traits::static_cast_from(pool_last_ref)
                               , internal_data.pool_size);
-      multiallocation_chain m (this->allocate_individual(n));
+      multiallocation_chain m;
+      this->allocate_individual(n, m);
       holder.splice_after(holder.before_begin(), m, m.before_begin(), m.last(), n);
       this->internal_data.pool_size += n;
       std::pair data(holder.extract_data());
@@ -1690,11 +1621,25 @@ class stable_vector
       pool_last_ref  = ret.second;
    }
 
+   void priv_put_in_pool(multiallocation_chain &ch)
+   {
+      node_base_ptr &pool_first_ref = *(this->index.end()-(ExtraPointers-1));
+      node_base_ptr &pool_last_ref  = this->index.back();
+      ch.incorporate_after( ch.before_begin()
+                          , node_ptr_traits::static_cast_from(pool_first_ref)
+                          , node_ptr_traits::static_cast_from(pool_last_ref)
+                          , internal_data.pool_size);
+      this->internal_data.pool_size = ch.size();
+      const std::pair ret(ch.extract_data());
+      pool_first_ref = ret.first;
+      pool_last_ref  = ret.second;
+   }
+
    node_ptr priv_get_from_pool()
    {
       //Precondition: index is not empty
       BOOST_ASSERT(!this->index.empty());
-      node_base_ptr &pool_first_ref = *(this->index.end() - 2);
+      node_base_ptr &pool_first_ref = *(this->index.end() - (ExtraPointers-1));
       node_base_ptr &pool_last_ref  = this->index.back();
       multiallocation_chain holder;
       holder.incorporate_after( holder.before_begin()
@@ -1707,9 +1652,9 @@ class stable_vector
          pool_first_ref = pool_last_ref = node_ptr();
       }
       else{
-         std::pair data(holder.extract_data());
+         const std::pair data(holder.extract_data());
          pool_first_ref = data.first;
-         pool_last_ref = data.second;
+         pool_last_ref  = data.second;
       }
       return ret;
    }
@@ -1720,11 +1665,16 @@ class stable_vector
          (static_cast(const_cast(this->internal_data.end_node)));
    }
 
-   void priv_delete_node(const node_ptr &n)
+   void priv_destroy_node(const node_type &n)
    {
       allocator_traits::
-         destroy(this->priv_node_alloc(), container_detail::addressof(n->value));
-      static_cast(container_detail::to_raw_pointer(n))->~node_base_type();
+         destroy(this->priv_node_alloc(), container_detail::addressof(n.value));
+      static_cast(&n)->~node_base_type();
+   }
+
+   void priv_delete_node(const node_ptr &n)
+   {
+      this->priv_destroy_node(*n);
       this->priv_put_in_pool(n);
    }
 
@@ -1776,7 +1726,7 @@ class stable_vector
       }
 
       size_type n = this->capacity() - this->size();
-      node_base_ptr &pool_first_ref = *(index_ref.end() - 2);
+      node_base_ptr &pool_first_ref = *(index_ref.end() - (ExtraPointers-1));
       node_base_ptr &pool_last_ref  = index_ref.back();
       multiallocation_chain holder;
       holder.incorporate_after( holder.before_begin()
@@ -1886,6 +1836,17 @@ void swap(stable_vector& x,stable_vector& y)
 
 /// @endcond
 
+/*
+
+//!has_trivial_destructor_after_move<> == true_type
+//!specialization for optimizations
+template 
+struct has_trivial_destructor_after_move >
+   : public has_trivial_destructor_after_move::value
+{};
+
+*/
+
 }}
 
 #include 
diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp
index 7cbd447..40b2397 100644
--- a/include/boost/container/string.hpp
+++ b/include/boost/container/string.hpp
@@ -44,11 +44,13 @@
 #include 
 #include 
 #include 
+#include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -81,8 +83,8 @@ namespace container_detail {
 // an exception-safe version of basic_string.  The constructor allocates,
 // but does not initialize, a block of memory.  The destructor
 // deallocates, but does not destroy elements within, a block of
-// memory.  The destructor assumes that the memory either is the internal buffer,
-// or else points to a block of memory that was allocated using _String_base's
+// memory. The destructor assumes that the memory either is the internal buffer,
+// or else points to a block of memory that was allocated using string_base's
 // allocator and whose size is this->m_storage.
 template 
 class basic_string_base
@@ -92,7 +94,6 @@ class basic_string_base
    typedef allocator_traits allocator_traits_type;
  public:
    typedef Allocator                                  allocator_type;
-   //! The stored allocator type
    typedef allocator_type                              stored_allocator_type;
    typedef typename allocator_traits_type::pointer     pointer;
    typedef typename allocator_traits_type::value_type  value_type;
@@ -284,36 +285,8 @@ class basic_string_base
          reuse = pointer();
          command &= ~(expand_fwd | expand_bwd);
       }
-      return this->allocation_command
-         (command, limit_size, preferred_size, received_size, reuse, alloc_version());
-   }
-
-   std::pair
-      allocation_command(allocation_type command,
-                         size_type limit_size,
-                         size_type preferred_size,
-                         size_type &received_size,
-                         const pointer &reuse,
-                         allocator_v1)
-   {
-      (void)limit_size;
-      (void)reuse;
-      if(!(command & allocate_new))
-         return std::pair(pointer(), false);
-      received_size = preferred_size;
-      return std::make_pair(this->alloc().allocate(received_size), false);
-   }
-
-   std::pair
-      allocation_command(allocation_type command,
-                         size_type limit_size,
-                         size_type preferred_size,
-                         size_type &received_size,
-                         pointer reuse,
-                         allocator_v2)
-   {
-      return this->alloc().allocation_command(command, limit_size, preferred_size,
-                                              received_size, reuse);
+      return container_detail::allocator_version_traits::allocation_command
+         (this->alloc(), command, limit_size, preferred_size, received_size, reuse);
    }
 
    size_type next_capacity(size_type additional_objects) const
@@ -336,11 +309,9 @@ class basic_string_base
 
    void destroy(pointer p, size_type n)
    {
-      for(; n--; ++p){
-         allocator_traits_type::destroy
-            ( this->alloc()
-            , container_detail::to_raw_pointer(p)
-            );
+      value_type *raw_p = container_detail::to_raw_pointer(p);
+      for(; n--; ++raw_p){
+         allocator_traits_type::destroy( this->alloc(), raw_p);
       }
    }
 
@@ -569,37 +540,26 @@ class basic_string
    /// @endcond
 
    public:
-
-   //! The allocator type
-   typedef Allocator                                       allocator_type;
-   //! The stored allocator type
-   typedef allocator_type                          stored_allocator_type;
-   //! The type of object, CharT, stored in the string
-   typedef CharT                                   value_type;
-   //! The second template parameter Traits
-   typedef Traits                                  traits_type;
-   //! Pointer to CharT
-   typedef typename allocator_traits_type::pointer pointer;
-   //! Const pointer to CharT
-   typedef typename allocator_traits_type::const_pointer               const_pointer;
-   //! Reference to CharT
-   typedef typename allocator_traits_type::reference                   reference;
-   //! Const reference to CharT
-   typedef typename allocator_traits_type::const_reference             const_reference;
-   //! An unsigned integral type
-   typedef typename allocator_traits_type::size_type                   size_type;
-   //! A signed integral type
-   typedef typename allocator_traits_type::difference_type             difference_type;
-   //! Iterator used to iterate through a string. It's a Random Access Iterator
-   typedef pointer                                 iterator;
-   //! Const iterator used to iterate through a string. It's a Random Access Iterator
-   typedef const_pointer                           const_iterator;
-   //! Iterator used to iterate backwards through a string
-   typedef std::reverse_iterator       reverse_iterator;
-   //! Const iterator used to iterate backwards through a string
-   typedef std::reverse_iterator const_reverse_iterator;
-   //! The largest possible value of type size_type. That is, size_type(-1).
-   static const size_type npos;
+   //////////////////////////////////////////////
+   //
+   //                    types
+   //
+   //////////////////////////////////////////////
+   typedef Traits                                                                      traits_type;
+   typedef CharT                                                                       value_type;
+   typedef typename ::boost::container::allocator_traits::pointer           pointer;
+   typedef typename ::boost::container::allocator_traits::const_pointer     const_pointer;
+   typedef typename ::boost::container::allocator_traits::reference         reference;
+   typedef typename ::boost::container::allocator_traits::const_reference   const_reference;
+   typedef typename ::boost::container::allocator_traits::size_type         size_type;
+   typedef typename ::boost::container::allocator_traits::difference_type   difference_type;
+   typedef Allocator                                                                   allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(allocator_type)                                      stored_allocator_type;
+   typedef BOOST_CONTAINER_IMPDEF(pointer)                                             iterator;
+   typedef BOOST_CONTAINER_IMPDEF(const_pointer)                                       const_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)                     reverse_iterator;
+   typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator)               const_reverse_iterator;
+   static const size_type npos = size_type(-1);
 
    /// @cond
    private:
@@ -611,6 +571,11 @@ class basic_string
    /// @endcond
 
    public:                         // Constructor, destructor, assignment.
+   //////////////////////////////////////////////
+   //
+   //          construct/copy/destroy
+   //
+   //////////////////////////////////////////////
    /// @cond
    struct reserve_t {};
 
@@ -634,8 +599,8 @@ class basic_string
 
    //! Effects: Constructs a basic_string taking the allocator as parameter.
    //!
-   //! Throws: If allocator_type's copy constructor throws.
-   explicit basic_string(const allocator_type& a)
+   //! Throws: Nothing
+   explicit basic_string(const allocator_type& a) BOOST_CONTAINER_NOEXCEPT
       : base_t(a)
    { this->priv_terminate_string(); }
 
@@ -653,10 +618,10 @@ class basic_string
 
    //! Effects: Move constructor. Moves s's resources to *this.
    //!
-   //! Throws: If allocator_type's copy constructor throws.
+   //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   basic_string(BOOST_RV_REF(basic_string) s)
+   basic_string(BOOST_RV_REF(basic_string) s) BOOST_CONTAINER_NOEXCEPT
       : base_t(boost::move((base_t&)s))
    {}
 
@@ -693,7 +658,7 @@ class basic_string
    //! Effects: Constructs a basic_string taking the allocator as parameter,
    //!   and is initialized by a specific number of characters of the s string.
    basic_string(const basic_string& s, size_type pos, size_type n = npos,
-               const allocator_type& a = allocator_type())
+                const allocator_type& a = allocator_type())
       : base_t(a)
    {
       this->priv_terminate_string();
@@ -706,8 +671,7 @@ class basic_string
 
    //! Effects: Constructs a basic_string taking the allocator as parameter,
    //!   and is initialized by a specific number of characters of the s c-string.
-   basic_string(const CharT* s, size_type n,
-               const allocator_type& a = allocator_type())
+   basic_string(const CharT* s, size_type n, const allocator_type& a = allocator_type())
       : base_t(a)
    {
       this->priv_terminate_string();
@@ -716,8 +680,7 @@ class basic_string
 
    //! Effects: Constructs a basic_string taking the allocator as parameter,
    //!   and is initialized by the null-terminated s c-string.
-   basic_string(const CharT* s,
-                const allocator_type& a = allocator_type())
+   basic_string(const CharT* s, const allocator_type& a = allocator_type())
       : base_t(a)
    {
       this->priv_terminate_string();
@@ -726,8 +689,7 @@ class basic_string
 
    //! Effects: Constructs a basic_string taking the allocator as parameter,
    //!   and is initialized by n copies of c.
-   basic_string(size_type n, CharT c,
-                const allocator_type& a = allocator_type())
+   basic_string(size_type n, CharT c, const allocator_type& a = allocator_type())
       : base_t(a)
    {
       this->priv_terminate_string();
@@ -737,8 +699,7 @@ class basic_string
    //! Effects: Constructs a basic_string taking the allocator as parameter,
    //!   and a range of iterators.
    template 
-   basic_string(InputIterator f, InputIterator l,
-               const allocator_type& a = allocator_type())
+   basic_string(InputIterator f, InputIterator l, const allocator_type& a = allocator_type())
       : base_t(a)
    {
       this->priv_terminate_string();
@@ -750,7 +711,7 @@ class basic_string
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   ~basic_string()
+   ~basic_string() BOOST_CONTAINER_NOEXCEPT
    {}
      
    //! Effects: Copy constructs a string.
@@ -784,7 +745,7 @@ class basic_string
    //! Throws: If allocator_type's copy constructor throws.
    //!
    //! Complexity: Constant.
-   basic_string& operator=(BOOST_RV_REF(basic_string) x)
+   basic_string& operator=(BOOST_RV_REF(basic_string) x) BOOST_CONTAINER_NOEXCEPT
    {
       if (&x != this){
          allocator_type &this_alloc = this->alloc();
@@ -815,114 +776,12 @@ class basic_string
    basic_string& operator=(CharT c)
    { return this->assign(static_cast(1), c); }
 
-   //! Effects: Returns an iterator to the first element contained in the vector.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   iterator begin()
-   { return this->priv_addr(); }
-
-   //! Effects: Returns a const_iterator to the first element contained in the vector.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_iterator begin() const
-   { return this->priv_addr(); }
-
-   //! Effects: Returns a const_iterator to the first element contained in the vector.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_iterator cbegin() const
-   { return this->priv_addr(); }
-
-   //! Effects: Returns an iterator to the end of the vector.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   iterator end()
-   { return this->priv_end_addr(); }
-
-   //! Effects: Returns a const_iterator to the end of the vector.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_iterator end() const
-   { return this->priv_end_addr(); }
-
-   //! Effects: Returns a const_iterator to the end of the vector.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_iterator cend() const
-   { return this->priv_end_addr(); }
-
-   //! Effects: Returns a reverse_iterator pointing to the beginning
-   //! of the reversed vector.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   reverse_iterator rbegin()            
-   { return reverse_iterator(this->priv_end_addr()); }
-
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning
-   //! of the reversed vector.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_reverse_iterator rbegin() const
-   { return this->crbegin(); }
-
-   //! Effects: Returns a const_reverse_iterator pointing to the beginning
-   //! of the reversed vector.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_reverse_iterator crbegin() const
-   { return const_reverse_iterator(this->priv_end_addr()); }
-
-   //! Effects: Returns a reverse_iterator pointing to the end
-   //! of the reversed vector.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   reverse_iterator rend()              
-   { return reverse_iterator(this->priv_addr()); }
-
-   //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed vector.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_reverse_iterator rend()   const
-   { return this->crend(); }
-
-   //! Effects: Returns a const_reverse_iterator pointing to the end
-   //! of the reversed vector.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   const_reverse_iterator crend()   const
-   { return const_reverse_iterator(this->priv_addr()); }
-
    //! Effects: Returns a copy of the internal allocator.
    //!
    //! Throws: If allocator's copy constructor throws.
    //!
    //! Complexity: Constant.
-   allocator_type get_allocator() const
+   allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
    { return this->alloc(); }
 
    //! Effects: Returns a reference to the internal allocator.
@@ -945,12 +804,134 @@ class basic_string
    const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
    {  return this->alloc(); }
 
+   //////////////////////////////////////////////
+   //
+   //                iterators
+   //
+   //////////////////////////////////////////////
+
+   //! Effects: Returns an iterator to the first element contained in the vector.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   iterator begin() BOOST_CONTAINER_NOEXCEPT
+   { return this->priv_addr(); }
+
+   //! Effects: Returns a const_iterator to the first element contained in the vector.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
+   { return this->priv_addr(); }
+
+   //! Effects: Returns an iterator to the end of the vector.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   iterator end() BOOST_CONTAINER_NOEXCEPT
+   { return this->priv_end_addr(); }
+
+   //! Effects: Returns a const_iterator to the end of the vector.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_iterator end() const BOOST_CONTAINER_NOEXCEPT
+   { return this->priv_end_addr(); }
+
+   //! Effects: Returns a reverse_iterator pointing to the beginning
+   //! of the reversed vector.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   reverse_iterator rbegin()  BOOST_CONTAINER_NOEXCEPT
+   { return reverse_iterator(this->priv_end_addr()); }
+
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed vector.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
+   { return this->crbegin(); }
+
+   //! Effects: Returns a reverse_iterator pointing to the end
+   //! of the reversed vector.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   reverse_iterator rend()  BOOST_CONTAINER_NOEXCEPT
+   { return reverse_iterator(this->priv_addr()); }
+
+   //! Effects: Returns a const_reverse_iterator pointing to the end
+   //! of the reversed vector.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT
+   { return this->crend(); }
+
+   //! Effects: Returns a const_iterator to the first element contained in the vector.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
+   { return this->priv_addr(); }
+
+   //! Effects: Returns a const_iterator to the end of the vector.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
+   { return this->priv_end_addr(); }
+
+   //! Effects: Returns a const_reverse_iterator pointing to the beginning
+   //! of the reversed vector.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT
+   { return const_reverse_iterator(this->priv_end_addr()); }
+
+   //! Effects: Returns a const_reverse_iterator pointing to the end
+   //! of the reversed vector.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
+   { return const_reverse_iterator(this->priv_addr()); }
+
+   //////////////////////////////////////////////
+   //
+   //                capacity
+   //
+   //////////////////////////////////////////////
+
+   //! Effects: Returns true if the vector contains no elements.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   bool empty() const BOOST_CONTAINER_NOEXCEPT
+   { return !this->priv_size(); }
+
    //! Effects: Returns the number of the elements contained in the vector.
    //!
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type size() const   
+   size_type size() const    BOOST_CONTAINER_NOEXCEPT
    { return this->priv_size(); }
 
    //! Effects: Returns the number of the elements contained in the vector.
@@ -958,7 +939,7 @@ class basic_string
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type length() const
+   size_type length() const BOOST_CONTAINER_NOEXCEPT
    { return this->size(); }
 
    //! Effects: Returns the largest possible size of the vector.
@@ -966,7 +947,7 @@ class basic_string
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   size_type max_size() const
+   size_type max_size() const BOOST_CONTAINER_NOEXCEPT
    { return base_t::max_size(); }
 
    //! Effects: Inserts or erases elements at the end such that
@@ -990,7 +971,16 @@ class basic_string
    //!
    //! Complexity: Linear to the difference between size() and new_size.
    void resize(size_type n)
-   { resize(n, CharT(0)); }
+   { resize(n, CharT()); }
+
+   //! Effects: Number of elements for which memory has been allocated.
+   //!   capacity() is always greater than or equal to size().
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Constant.
+   size_type capacity() const BOOST_CONTAINER_NOEXCEPT
+   { return this->priv_capacity(); }
 
    //! Effects: If n is less than or equal to capacity(), this call has no
    //!   effect. Otherwise, it is a request for allocation of additional memory.
@@ -1023,28 +1013,6 @@ class basic_string
       }
    }
 
-   //! Effects: Number of elements for which memory has been allocated.
-   //!   capacity() is always greater than or equal to size().
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   size_type capacity() const
-   { return this->priv_capacity(); }
-
-   //! Effects: Erases all the elements of the vector.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Linear to the number of elements in the vector.
-   void clear()
-   {
-      if (!this->empty()) {
-         Traits::assign(*this->priv_addr(), CharT(0));
-         this->priv_size(0);
-      }
-   }
-
    //! Effects: Tries to deallocate the excess of memory created
    //!   with previous allocations. The size of the string is unchanged
    //!
@@ -1076,13 +1044,11 @@ class basic_string
       }
    }
 
-   //! Effects: Returns true if the vector contains no elements.
-   //!
-   //! Throws: Nothing.
-   //!
-   //! Complexity: Constant.
-   bool empty() const
-   { return !this->priv_size(); }
+   //////////////////////////////////////////////
+   //
+   //               element access
+   //
+   //////////////////////////////////////////////
 
    //! Requires: size() > n.
    //!
@@ -1092,7 +1058,7 @@ class basic_string
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reference operator[](size_type n)
+   reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT
       { return *(this->priv_addr() + n); }
 
    //! Requires: size() > n.
@@ -1103,7 +1069,7 @@ class basic_string
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   const_reference operator[](size_type n) const
+   const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT
       { return *(this->priv_addr() + n); }
 
    //! Requires: size() > n.
@@ -1135,6 +1101,12 @@ class basic_string
       return *(this->priv_addr() + n);
    }
 
+   //////////////////////////////////////////////
+   //
+   //                modifiers
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Calls append(str.data, str.size()).
    //!
    //! Returns: *this
@@ -1240,7 +1212,7 @@ class basic_string
    //! Throws: Nothing
    //!
    //! Returns: *this
-   basic_string& assign(BOOST_RV_REF(basic_string) ms)
+   basic_string& assign(BOOST_RV_REF(basic_string) ms) BOOST_CONTAINER_NOEXCEPT
    {  return this->swap_data(ms), *this;  }
 
    //! Requires: pos <= str.size()
@@ -1322,10 +1294,10 @@ class basic_string
    //! Returns: *this
    basic_string& insert(size_type pos, const basic_string& s)
    {
-      const size_type size_ = this->size();
-      if (pos > size_)
+      const size_type sz = this->size();
+      if (pos > sz)
          this->throw_out_of_range();
-      if (size_ > this->max_size() - s.size())
+      if (sz > this->max_size() - s.size())
          this->throw_length_error();
       this->insert(this->priv_addr() + pos, s.begin(), s.end());
       return *this;
@@ -1341,12 +1313,12 @@ class basic_string
    //! Returns: *this
    basic_string& insert(size_type pos1, const basic_string& s, size_type pos2, size_type n)
    {
-      const size_type size_ = this->size();
+      const size_type sz = this->size();
       const size_type str_size = s.size();
-      if (pos1 > size_ || pos2 > str_size)
+      if (pos1 > sz || pos2 > str_size)
          this->throw_out_of_range();
       size_type len = container_detail::min_value(n, str_size - pos2);
-      if (size_ > this->max_size() - len)
+      if (sz > this->max_size() - len)
          this->throw_length_error();
       const CharT *beg_ptr = container_detail::to_raw_pointer(s.begin()) + pos2;
       const CharT *end_ptr = beg_ptr + len;
@@ -1591,7 +1563,7 @@ class basic_string
    //!
    //! Returns: An iterator which points to the element immediately following p prior to the element being
    //!    erased. If no such element exists, end() is returned.
-   iterator erase(const_iterator p)
+   iterator erase(const_iterator p) BOOST_CONTAINER_NOEXCEPT
    {
       // The move includes the terminating null.
       CharT * const ptr = const_cast(container_detail::to_raw_pointer(p));
@@ -1611,7 +1583,7 @@ class basic_string
    //!
    //! Returns: An iterator which points to the element pointed to by last prior to
    //!   the other elements being erased. If no such element exists, end() is returned.
-   iterator erase(const_iterator first, const_iterator last)
+   iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
    {
       CharT * f = const_cast(container_detail::to_raw_pointer(first));
       if (first != last) { // The move includes the terminating null.
@@ -1631,13 +1603,26 @@ class basic_string
    //! Throws: Nothing
    //!
    //! Effects: Equivalent to erase(size() - 1, 1).
-   void pop_back()
+   void pop_back() BOOST_CONTAINER_NOEXCEPT
    {
       const size_type old_size = this->priv_size();
       Traits::assign(this->priv_addr()[old_size-1], CharT(0));
       this->priv_size(old_size-1);;
    }
 
+   //! Effects: Erases all the elements of the vector.
+   //!
+   //! Throws: Nothing.
+   //!
+   //! Complexity: Linear to the number of elements in the vector.
+   void clear() BOOST_CONTAINER_NOEXCEPT
+   {
+      if (!this->empty()) {
+         Traits::assign(*this->priv_addr(), CharT(0));
+         this->priv_size(0);
+      }
+   }
+
    //! Requires: pos1 <= size().
    //!
    //! Effects: Calls replace(pos1, n1, str.data(), str.size()).
@@ -1890,12 +1875,18 @@ class basic_string
       container_detail::swap_alloc(this->alloc(), x.alloc(), flag);
    }
 
+   //////////////////////////////////////////////
+   //
+   //                 data access
+   //
+   //////////////////////////////////////////////
+
    //! Requires: The program shall not alter any of the values stored in the character array.
    //!
    //! Returns: Allocator pointer p such that p + i == &operator[](i) for each i in [0,size()].
    //!
    //! Complexity: constant time.
-   const CharT* c_str() const
+   const CharT* c_str() const BOOST_CONTAINER_NOEXCEPT
    {  return container_detail::to_raw_pointer(this->priv_addr()); }
 
    //! Requires: The program shall not alter any of the values stored in the character array.
@@ -1903,9 +1894,15 @@ class basic_string
    //! Returns: Allocator pointer p such that p + i == &operator[](i) for each i in [0,size()].
    //!
    //! Complexity: constant time.
-   const CharT* data()  const
+   const CharT* data()  const BOOST_CONTAINER_NOEXCEPT
    {  return container_detail::to_raw_pointer(this->priv_addr()); }
 
+   //////////////////////////////////////////////
+   //
+   //             string operations
+   //
+   //////////////////////////////////////////////
+
    //! Effects: Determines the lowest position xpos, if possible, such that both
    //!   of the following conditions obtain: 19 pos <= xpos and xpos + str.size() <= size();
    //!   2) traits::eq(at(xpos+I), str.at(I)) for all elements I of the string controlled by str.
@@ -1949,12 +1946,12 @@ class basic_string
    //! Returns: find(basic_string(1,c), pos).
    size_type find(CharT c, size_type pos = 0) const
    {
-      const size_type size_ = this->size();
-      if (pos >= size_)
+      const size_type sz = this->size();
+      if (pos >= sz)
          return npos;
       else {
-         const pointer addr = this->priv_addr();
-         pointer finish = addr + size_;
+         const pointer addr    = this->priv_addr();
+         pointer finish = addr + sz;
          const const_iterator result =
             std::find_if(addr + pos, finish,
                   std::bind2nd(Eq_traits(), c));
@@ -2039,12 +2036,12 @@ class basic_string
    //! Returns: find_first_of(basic_string(s, n), pos).
    size_type find_first_of(const CharT* s, size_type pos, size_type n) const
    {
-      const size_type size_ = this->size();
-      if (pos >= size_)
+      const size_type sz = this->size();
+      if (pos >= sz)
          return npos;
       else {
-         const pointer addr = this->priv_addr();
-         pointer finish = addr + size_;
+         const pointer addr    = this->priv_addr();
+         pointer finish = addr + sz;
          const_iterator result = std::find_first_of
             (addr + pos, finish, s, s + n, Eq_traits());
          return result != finish ? result - this->begin() : npos;
@@ -2282,8 +2279,8 @@ class basic_string
    //! Throws: out_of_range if pos1 > size() or pos2 > str.size()
    //!
    //! Returns: basic_string(*this, pos1, n1).compare(basic_string(str, pos2, n2)).
-   int compare(size_type pos1, size_type n1,
-               const basic_string& str, size_type pos2, size_type n2) const {
+   int compare(size_type pos1, size_type n1, const basic_string& str, size_type pos2, size_type n2) const
+   {
       if (pos1 > this->size() || pos2 > str.size())
          this->throw_out_of_range();
       const pointer addr     = this->priv_addr();
@@ -2309,8 +2306,7 @@ class basic_string
    //! Throws: out_of_range if pos1 > size()
    //!
    //! Returns: basic_string(*this, pos, n1).compare(basic_string(s, n2)).
-   int compare(size_type pos1, size_type n1,
-               const CharT* s, size_type n2) const
+   int compare(size_type pos1, size_type n1, const CharT* s, size_type n2) const
    {
       if (pos1 > this->size())
          this->throw_out_of_range();
@@ -2352,7 +2348,7 @@ class basic_string
       const size_type long_size    = this->priv_long_size();
       const size_type long_storage = this->priv_long_storage();
       //We can make this nothrow as chars are always NoThrowCopyables
-      try{
+      BOOST_TRY{
          const std::pair ret = this->allocation_command
                (allocate_new, long_size+1, long_size+1, real_cap, long_addr);
          //Copy and update
@@ -2364,9 +2360,10 @@ class basic_string
          //And release old buffer
          this->alloc().deallocate(long_addr, long_storage);
       }
-      catch(...){
+      BOOST_CATCH(...){
          return;
       }
+      BOOST_CATCH_END
    }
 
    template
@@ -2481,15 +2478,6 @@ typedef basic_string
    ,std::allocator >
 wstring;
 
-/// @cond
-
-template 
-const typename basic_string::size_type
-basic_string::npos
-  = (typename basic_string::size_type) -1;
-
-/// @endcond
-
 // ------------------------------------------------------------
 // Non-member functions.
 
@@ -2857,15 +2845,14 @@ inline std::size_t hash_value(basic_string, Allocator>
 /// @cond
 
 namespace boost {
-/*
+
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
 template 
 struct has_trivial_destructor_after_move >
-{
-   static const bool value = has_trivial_destructor::value;
-};
-*/
+   : public ::boost::has_trivial_destructor_after_move
+{};
+
 }
 
 /// @endcond
diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp
index 972db9e..3c4c9c5 100644
--- a/include/boost/container/vector.hpp
+++ b/include/boost/container/vector.hpp
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -39,9 +40,10 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -213,8 +215,7 @@ struct vector_value_traits
    typedef T value_type;
    typedef Allocator allocator_type;
    static const bool trivial_dctr = boost::has_trivial_destructor::value;
-   static const bool trivial_dctr_after_move = trivial_dctr;
-      //::boost::has_trivial_destructor_after_move::value || trivial_dctr;
+   static const bool trivial_dctr_after_move = ::boost::has_trivial_destructor_after_move::value;
    //static const bool trivial_copy = has_trivial_copy::value;
    //static const bool nothrow_copy = has_nothrow_copy::value;
    //static const bool trivial_assign = has_trivial_assign::value;
@@ -286,42 +287,17 @@ struct vector_alloc_holder
                          size_type preferred_size,
                          size_type &received_size, const pointer &reuse = 0)
    {
-      return allocation_command(command, limit_size, preferred_size,
-                               received_size, reuse, alloc_version());
-   }
-
-   std::pair
-      allocation_command(allocation_type command,
-                         size_type limit_size,
-                         size_type preferred_size,
-                         size_type &received_size,
-                         const pointer &reuse,
-                         allocator_v1)
-   {
-      (void)limit_size;
-      (void)reuse;
-      if(!(command & allocate_new))
-         return std::pair(pointer(0), false);
-      received_size = preferred_size;
-      return std::make_pair(this->alloc().allocate(received_size), false);
-   }
-
-   std::pair
-      allocation_command(allocation_type command,
-                         size_type limit_size,
-                         size_type preferred_size,
-                         size_type &received_size,
-                         const pointer &reuse,
-                         allocator_v2)
-   {
-      return this->alloc().allocation_command
-         (command, limit_size, preferred_size, received_size, reuse);
+      return allocator_version_traits::allocation_command
+         (this->alloc(), command, limit_size, preferred_size, received_size, reuse);
    }
 
    size_type next_capacity(size_type additional_objects) const
    {
+      std::size_t num_objects   = this->members_.m_size + additional_objects;
+      std::size_t next_cap = this->members_.m_capacity + this->members_.m_capacity/2;
+      return num_objects > next_cap ? num_objects : next_cap;/*
       return get_next_capacity( allocator_traits_type::max_size(this->alloc())
-                              , this->members_.m_capacity, additional_objects);
+                              , this->members_.m_capacity, additional_objects);*/
    }
 
    struct members_holder
@@ -435,7 +411,6 @@ class vector : private container_detail::vector_alloc_holder
    /// @cond
    private:
    BOOST_COPYABLE_AND_MOVABLE(vector)
-   typedef container_detail::advanced_insert_aux_int    advanced_insert_aux_int_t;
    typedef container_detail::vector_value_traits value_traits;
 
    typedef typename base_t::allocator_v1           allocator_v1;
@@ -443,8 +418,6 @@ class vector : private container_detail::vector_alloc_holder
    typedef typename base_t::alloc_version          alloc_version;
 
    typedef constant_iterator   cvalue_iterator;
-   typedef repeat_iterator     repeat_it;
-   typedef boost::move_iterator         repeat_move_it;
    /// @endcond
 
    public:
@@ -857,7 +830,7 @@ class vector : private container_detail::vector_alloc_holder
       else{
          const size_type n = new_size - this->size();
          this->reserve(new_size);
-         container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
+         container_detail::insert_default_constructed_n_proxy proxy(this->alloc());
          this->priv_forward_range_insert(this->cend().get_ptr(), n, proxy);
       }
    }
@@ -920,11 +893,10 @@ class vector : private container_detail::vector_alloc_holder
          //If there is no forward expansion, move objects
          else{
             //We will reuse insert code, so create a dummy input iterator
-            T *dummy_it(container_detail::to_raw_pointer(this->members_.m_start));
-            container_detail::advanced_insert_aux_proxy, T*>
-               proxy(this->alloc(), ::boost::make_move_iterator(dummy_it), ::boost::make_move_iterator(dummy_it));
+            container_detail::insert_range_proxy, T*>
+               proxy(this->alloc(), ::boost::make_move_iterator((T *)0));
             //Backwards (and possibly forward) expansion
-            if(ret.second){
+            if(alloc_version::value > 1 && ret.second){
                #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
                ++this->num_expand_bwd;
                #endif
@@ -1018,7 +990,7 @@ class vector : private container_detail::vector_alloc_holder
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   reference operator[](size_type n)        
+   reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT
    { return this->members_.m_start[n]; }
 
    //! Requires: size() > n.
@@ -1102,9 +1074,9 @@ class vector : private container_detail::vector_alloc_holder
          ++this->members_.m_size;
       }
       else{
-         typedef container_detail::advanced_insert_aux_emplace type;
-         type &&proxy = type(this->alloc(), ::boost::forward(args)...);
-         this->priv_forward_range_insert(back_pos, 1, proxy);
+         typedef container_detail::insert_emplace_proxy type;
+         this->priv_forward_range_insert
+            (back_pos, 1, type(this->alloc(), ::boost::forward(args)...));
       }
    }
 
@@ -1122,11 +1094,9 @@ class vector : private container_detail::vector_alloc_holder
    iterator emplace(const_iterator position, Args && ...args)
    {
       //Just call more general insert(pos, size, value) and return iterator
-      size_type pos_n = position - cbegin();
-      typedef container_detail::advanced_insert_aux_emplace type;
-      type &&proxy = type(this->alloc(), ::boost::forward(args)...);
-      this->priv_forward_range_insert(position.get_ptr(), 1, proxy);
-      return iterator(this->members_.m_start + pos_n);
+      typedef container_detail::insert_emplace_proxy type;
+      return this->priv_forward_range_insert
+         (position.get_ptr(), 1, type(this->alloc(), ::boost::forward(args)...));
    }
 
    #else
@@ -1143,8 +1113,8 @@ class vector : private container_detail::vector_alloc_holder
          ++this->members_.m_size;                                                               \
       }                                                                                         \
       else{                                                                                     \
-         container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)      \
-             proxy                                   \
+         container_detail::BOOST_PP_CAT(insert_emplace_proxy_arg, n)                            \
+             proxy                           \
             (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));     \
          this->priv_forward_range_insert(back_pos, 1, proxy);                                   \
       }                                                                                         \
@@ -1154,12 +1124,11 @@ class vector : private container_detail::vector_alloc_holder
    iterator emplace(const_iterator pos                                                          \
                     BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                \
    {                                                                                            \
-      size_type pos_n = pos - cbegin();                                                         \
-         container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)      \
-             proxy                                   \
+      container_detail::BOOST_PP_CAT(insert_emplace_proxy_arg, n)                               \
+          proxy                              \
             (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));     \
-      this->priv_forward_range_insert(container_detail::to_raw_pointer(pos.get_ptr()), 1,proxy);\
-      return iterator(this->members_.m_start + pos_n);                                          \
+      return this->priv_forward_range_insert                                                    \
+         (container_detail::to_raw_pointer(pos.get_ptr()), 1, proxy);                           \
    }                                                                                            \
    //!
    #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
@@ -1222,7 +1191,10 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Linear to n.
    iterator insert(const_iterator p, size_type n, const T& x)
-   {  return this->insert(p, cvalue_iterator(x, n), cvalue_iterator());  }
+   {
+      container_detail::insert_n_copies_proxy proxy(this->alloc(), x);
+      return this->priv_forward_range_insert(p.get_ptr(), n, proxy);
+   }
 
    //! Requires: p must be a valid iterator of *this.
    //!
@@ -1250,7 +1222,7 @@ class vector : private container_detail::vector_alloc_holder
          it = this->emplace(it, *first);
          ++it;
       }
-      return this->begin() + n_pos;
+      return iterator(this->members_.m_start + n_pos);
    }
 
    #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1262,11 +1234,8 @@ class vector : private container_detail::vector_alloc_holder
          >::type * = 0
       )
    {
-      const size_type n_pos = pos - this->cbegin();
-      const size_type n = std::distance(first, last);
-      container_detail::advanced_insert_aux_proxy proxy(this->alloc(), first, last);
-      this->priv_forward_range_insert(pos.get_ptr(), n, proxy);
-      return this->begin() + n_pos;
+      container_detail::insert_range_proxy proxy(this->alloc(), first);
+      return this->priv_forward_range_insert(pos.get_ptr(), std::distance(first, last), proxy);
    }
    #endif
 
@@ -1275,7 +1244,7 @@ class vector : private container_detail::vector_alloc_holder
    //! Throws: Nothing.
    //!
    //! Complexity: Constant time.
-   void pop_back()
+   void pop_back() BOOST_CONTAINER_NOEXCEPT
    {
       //Destroy last element
       --this->members_.m_size;
@@ -1290,8 +1259,8 @@ class vector : private container_detail::vector_alloc_holder
    //!   last element. Constant if pos is the last element.
    iterator erase(const_iterator position)
    {
-      T *pos = container_detail::to_raw_pointer(position.get_ptr());
-      T *beg = container_detail::to_raw_pointer(this->members_.m_start);
+      T *const pos = container_detail::to_raw_pointer(position.get_ptr());
+      T *const beg = container_detail::to_raw_pointer(this->members_.m_start);
       ::boost::move(pos + 1, beg + this->members_.m_size, pos);
       --this->members_.m_size;
       //Destroy last element
@@ -1307,14 +1276,14 @@ class vector : private container_detail::vector_alloc_holder
    //!   plus linear to the elements between pos and the last element.
    iterator erase(const_iterator first, const_iterator last)
    {
-      if (first != last){   // worth doing, copy down over hole
+      if (first != last){
          T* end_pos = container_detail::to_raw_pointer(this->members_.m_start) + this->members_.m_size;
          T* ptr = container_detail::to_raw_pointer(boost::move
             (container_detail::to_raw_pointer(last.get_ptr())
             ,end_pos
             ,container_detail::to_raw_pointer(first.get_ptr())
             ));
-         size_type destroyed = (end_pos - ptr);
+         const size_type destroyed = (end_pos - ptr);
          this->destroy_n(ptr, destroyed);
          this->members_.m_size -= destroyed;
       }
@@ -1361,26 +1330,15 @@ class vector : private container_detail::vector_alloc_holder
    }
 
    private:
-   iterator priv_insert(const_iterator position, const T &x)
+   template
+   iterator priv_insert(const const_iterator &p, BOOST_FWD_REF(U) x)
    {
-      //Just call more general insert(pos, size, value) and return iterator
-      size_type pos_n = position - cbegin();
-      this->insert(position, (size_type)1, x);
-      return iterator(this->members_.m_start + pos_n);
-   }
-
-   iterator priv_insert(const_iterator position, BOOST_RV_REF(T) x)
-   {
-      //Just call more general insert(pos, size, value) and return iterator
-      size_type pos_n = position - cbegin();
-      this->insert(position
-                  ,repeat_move_it(repeat_it(x, 1))
-                  ,repeat_move_it(repeat_it()));
-      return iterator(this->members_.m_start + pos_n);
+      return this->priv_forward_range_insert
+         (p.get_ptr(), 1, container_detail::get_insert_value_proxy(this->alloc(), ::boost::forward(x)));
    }
 
    template 
-   void priv_push_back(BOOST_MOVE_CATCH_FWD(U) x)
+   void priv_push_back(BOOST_FWD_REF(U) x)
    {
       if (this->members_.m_size < this->members_.m_capacity){
          //There is more memory, just construct a new object at the end
@@ -1391,7 +1349,7 @@ class vector : private container_detail::vector_alloc_holder
          ++this->members_.m_size;
       }
       else{
-         this->insert(this->cend(), ::boost::forward(x));
+         this->priv_insert(this->cend(), ::boost::forward(x));
       }
    }
 
@@ -1409,9 +1367,8 @@ class vector : private container_detail::vector_alloc_holder
                   (allocate_new, this->size(), this->size(), real_cap, this->members_.m_start);
             if(real_cap < this->capacity()){
                //We will reuse insert code, so create a dummy input iterator
-               T *dummy_it(container_detail::to_raw_pointer(this->members_.m_start));
-               container_detail::advanced_insert_aux_proxy, T*>
-                  proxy(this->alloc(), ::boost::make_move_iterator(dummy_it), ::boost::make_move_iterator(dummy_it));
+               container_detail::insert_range_proxy, T*>
+                  proxy(this->alloc(), ::boost::make_move_iterator((T *)0));
                #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
                ++this->num_alloc;
                #endif
@@ -1450,65 +1407,79 @@ class vector : private container_detail::vector_alloc_holder
       }
    }
 
-   void priv_forward_range_insert(pointer pos, const size_type n, advanced_insert_aux_int_t &interf)
+   template 
+   iterator priv_forward_range_insert
+      (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy)
    {
       //Check if we have enough memory or try to expand current memory
-      size_type remaining = this->members_.m_capacity - this->members_.m_size;
-      bool same_buffer_start;
-      std::pair ret;
-      size_type real_cap = this->members_.m_capacity;
+      const size_type remaining = this->members_.m_capacity - this->members_.m_size;
+      const size_type n_pos = pos - this->members_.m_start;
+      T *const raw_pos = container_detail::to_raw_pointer(pos);
 
       //Check if we already have room
-      if (n <= remaining){
-         same_buffer_start = true;
-      }
-      else{
-         //There is not enough memory, allocate a new
-         //buffer or expand the old one.
-         size_type new_cap = this->next_capacity(n);
-         ret = this->allocation_command
-               (allocate_new | expand_fwd | expand_bwd,
-                  this->members_.m_size + n, new_cap, real_cap, this->members_.m_start);
+      if(alloc_version::value > 1){   //Version 2 allocator, compile time check
+         bool same_buffer_start = n <= remaining;
+         if (!same_buffer_start){
+            size_type real_cap = 0;
+            //There is not enough memory, allocate a new
+            //buffer or expand the old one.
+            std::pair ret = (this->allocation_command
+                  (allocate_new | expand_fwd | expand_bwd,
+                     this->members_.m_size + n, this->next_capacity(n), real_cap, this->members_.m_start));
 
-         //Check for forward expansion
-         same_buffer_start = ret.second && this->members_.m_start == ret.first;
-         if(same_buffer_start){
-            this->members_.m_capacity  = real_cap;
+            //Buffer reallocated
+            if(ret.second){
+               //Forward expansion, delay insertion
+               if(this->members_.m_start == ret.first){
+                  #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
+                  ++this->num_expand_fwd;
+                  #endif
+                  this->members_.m_capacity = real_cap;
+                  //Expand forward
+                  this->priv_range_insert_expand_forward(raw_pos, n, insert_range_proxy);
+               }
+               //Backwards (and possibly forward) expansion
+               else{
+                  #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
+                  ++this->num_expand_bwd;
+                  #endif
+                  this->priv_range_insert_expand_backwards
+                     ( container_detail::to_raw_pointer(ret.first)
+                     , real_cap, raw_pos, n, insert_range_proxy);
+               }
+            }
+            //New buffer
+            else{
+               #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
+               ++this->num_alloc;
+               #endif
+               this->priv_range_insert_new_allocation
+                  ( container_detail::to_raw_pointer(ret.first)
+                  , real_cap, raw_pos, n, insert_range_proxy);
+            }
+         }
+         else{
+            //Expand forward
+            this->priv_range_insert_expand_forward
+               (raw_pos, n, insert_range_proxy);
          }
       }
-     
-      //If we had room or we have expanded forward
-      if (same_buffer_start){
-         #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
-         ++this->num_expand_fwd;
-         #endif
-         this->priv_range_insert_expand_forward
-            (container_detail::to_raw_pointer(pos), n, interf);
-      }
-      //Backwards (and possibly forward) expansion
-      else if(ret.second){
-         #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
-         ++this->num_expand_bwd;
-         #endif
-         this->priv_range_insert_expand_backwards
-            ( container_detail::to_raw_pointer(ret.first)
-            , real_cap
-            , container_detail::to_raw_pointer(pos)
-            , n
-            , interf);
-      }
-      //New buffer
-      else{
-         #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
-         ++this->num_alloc;
-         #endif
-         this->priv_range_insert_new_allocation
-            ( container_detail::to_raw_pointer(ret.first)
-            , real_cap
-            , container_detail::to_raw_pointer(pos)
-            , n
-            , interf);
+      else{ //Version 1 allocator
+         if (n <= remaining){
+            this->priv_range_insert_expand_forward
+               (raw_pos, n, insert_range_proxy);
+         }
+         else{
+            const size_type new_cap = this->next_capacity(n);
+            T * new_buf = container_detail::to_raw_pointer(this->alloc().allocate(new_cap));
+            #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
+            ++this->num_alloc;
+            #endif
+            this->priv_range_insert_new_allocation
+               ( new_buf, new_cap, raw_pos, n, insert_range_proxy);
+         }
       }
+      return iterator(this->members_.m_start + n_pos);
    }
 
    //Absolutely experimental. This function might change, disappear or simply crash!
@@ -1660,15 +1631,21 @@ class vector : private container_detail::vector_alloc_holder
    }
 
    private:
-   void priv_range_insert_expand_forward(T* pos, size_type n, advanced_insert_aux_int_t &interf)
+   template 
+   void priv_range_insert_expand_forward(T* const pos, const size_type n, InsertionProxy insert_range_proxy)
    {
       //n can't be 0, because there is nothing to do in that case
       if(!n) return;
       //There is enough memory
-      T* old_finish = container_detail::to_raw_pointer(this->members_.m_start) + this->members_.m_size;
+      T* const old_finish = container_detail::to_raw_pointer(this->members_.m_start) + this->members_.m_size;
       const size_type elems_after = old_finish - pos;
 
-      if (elems_after >= n){
+      if (!elems_after){
+         //Copy first new elements in pos
+         insert_range_proxy.uninitialized_copy_n_and_update(pos, n);
+         this->members_.m_size += n;
+      }
+      else if (elems_after >= n){
          //New elements can be just copied.
          //Move to uninitialized memory last objects
          ::boost::container::uninitialized_move_alloc
@@ -1677,24 +1654,31 @@ class vector : private container_detail::vector_alloc_holder
          //Copy previous to last objects to the initialized end
          boost::move_backward(pos, old_finish - n, old_finish);
          //Insert new objects in the pos
-         interf.copy_remaining_to(pos);
+         insert_range_proxy.copy_n_and_update(pos, n);
       }
       else {
-         //The new elements don't fit in the [pos, end()) range. Copy
-         //to the beginning of the unallocated zone the last new elements.
-         interf.uninitialized_copy_some_and_update(old_finish, elems_after, false);
-         this->members_.m_size += n - elems_after;
-         //Copy old [pos, end()) elements to the uninitialized memory
-         ::boost::container::uninitialized_move_alloc
-            (this->alloc(), pos, old_finish, container_detail::to_raw_pointer(this->members_.m_start) + this->members_.m_size);
-         this->members_.m_size += elems_after;
-         //Copy first new elements in pos
-         interf.copy_remaining_to(pos);
+         //The new elements don't fit in the [pos, end()) range.
+
+         //Copy old [pos, end()) elements to the uninitialized memory (a gap is created)
+         ::boost::container::uninitialized_move_alloc(this->alloc(), pos, old_finish, pos + n);
+         BOOST_TRY{
+            //Copy first new elements in pos (gap is still there)
+            insert_range_proxy.copy_n_and_update(pos, elems_after);
+            //Copy to the beginning of the unallocated zone the last new elements (the gap is closed).
+            insert_range_proxy.uninitialized_copy_n_and_update(old_finish, n - elems_after);
+            this->members_.m_size += n;
+         }
+         BOOST_CATCH(...){
+            this->destroy_n(pos + n, elems_after);
+            BOOST_RETHROW
+         }
+         BOOST_CATCH_END
       }
    }
 
+   template 
    void priv_range_insert_new_allocation
-      (T* new_start, size_type new_cap, T* pos, size_type n, advanced_insert_aux_int_t &interf)
+      (T* const new_start, size_type new_cap, T* const pos, const size_type n, InsertionProxy insert_range_proxy)
    {
       //n can be zero, if we want to reallocate!
       T *new_finish = new_start;
@@ -1712,7 +1696,7 @@ class vector : private container_detail::vector_alloc_holder
          constructed_values_destroyer.increment_size(new_finish - old_finish);
       }
       //Initialize new objects, starting from previous point
-      interf.uninitialized_copy_remaining_to(old_finish = new_finish);
+      insert_range_proxy.uninitialized_copy_n_and_update(old_finish = new_finish, n);
       new_finish += n;
       constructed_values_destroyer.increment_size(new_finish - old_finish);
       //Initialize from the rest of the old buffer,
@@ -1734,19 +1718,21 @@ class vector : private container_detail::vector_alloc_holder
       scoped_alloc.release();
    }
 
+   template 
    void priv_range_insert_expand_backwards
-         (T* new_start, size_type new_capacity,
-          T* pos, const size_type n, advanced_insert_aux_int_t &interf)
+         (T* const new_start, const size_type new_capacity,
+          T* const pos, const size_type n, InsertionProxy insert_range_proxy)
    {
       //n can be zero to just expand capacity
       //Backup old data
-      T* old_start  = container_detail::to_raw_pointer(this->members_.m_start);
-      T* old_finish = old_start + this->members_.m_size;
-      size_type old_size = this->members_.m_size;
+      T* const old_start  = container_detail::to_raw_pointer(this->members_.m_start);
+      T* const old_finish = old_start + this->members_.m_size;
+      const size_type old_size = this->members_.m_size;
 
       //We can have 8 possibilities:
-      const size_type elemsbefore   = (size_type)(pos - old_start);
-      const size_type s_before      = (size_type)(old_start - new_start);
+      const size_type elemsbefore = static_cast(pos - old_start);
+      const size_type s_before    = static_cast(old_start - new_start);
+      const size_type before_plus_new = elemsbefore + n;
 
       //Update the vector buffer information to a safe state
       this->members_.m_start      = new_start;
@@ -1757,15 +1743,16 @@ class vector : private container_detail::vector_alloc_holder
       //all the old objects to fulfill previous vector state
       typename value_traits::OldArrayDestructor old_values_destroyer(old_start, this->alloc(), old_size);
       //Check if s_before is big enough to hold the beginning of old data + new data
-      if(difference_type(s_before) >= difference_type(elemsbefore + n)){
+      if(s_before >= before_plus_new){
          //Copy first old values before pos, after that the new objects
-         ::boost::container::uninitialized_move_alloc(this->alloc(), old_start, pos, new_start);
+         T *const new_elem_pos = ::boost::container::uninitialized_move_alloc(this->alloc(), old_start, pos, new_start);
          this->members_.m_size = elemsbefore;
-         interf.uninitialized_copy_remaining_to(new_start + elemsbefore);
+         insert_range_proxy.uninitialized_copy_n_and_update(new_elem_pos, n);
          this->members_.m_size += n;
          //Check if s_before is so big that even copying the old data + new data
          //there is a gap between the new data and the old data
-         if(s_before >= (old_size + n)){
+         const size_type new_size = old_size + n;
+         if(s_before >= new_size){
             //Old situation:
             // _________________________________________________________
             //|            raw_mem                | old_begin | old_end |
@@ -1778,9 +1765,9 @@ class vector : private container_detail::vector_alloc_holder
             //
             //Now initialize the rest of memory with the last old values
             ::boost::container::uninitialized_move_alloc
-               (this->alloc(), pos, old_finish, new_start + elemsbefore + n);
+               (this->alloc(), pos, old_finish, new_start + before_plus_new);
             //All new elements correctly constructed, avoid new element destruction
-            this->members_.m_size = old_size + n;
+            this->members_.m_size = new_size;
             //Old values destroyed automatically with "old_values_destroyer"
             //when "old_values_destroyer" goes out of scope unless the have trivial
             //destructor after move.
@@ -1801,17 +1788,17 @@ class vector : private container_detail::vector_alloc_holder
             //
             //Now initialize the rest of memory with the last old values
             //All new elements correctly constructed, avoid new element destruction
-            size_type raw_gap = s_before - (elemsbefore + n);
+            const size_type raw_gap = s_before - before_plus_new;
             //Now initialize the rest of s_before memory with the
             //first of elements after new values
-            ::boost::container::uninitialized_move_alloc
-               (this->alloc(), pos, pos + raw_gap, new_start + elemsbefore + n);
+            ::boost::container::uninitialized_move_alloc_n
+               (this->alloc(), pos, raw_gap, new_start + before_plus_new);
             //Update size since we have a contiguous buffer
             this->members_.m_size = old_size + s_before;
             //All new elements correctly constructed, avoid old element destruction
             old_values_destroyer.release();
             //Now copy remaining last objects in the old buffer begin
-            T *to_destroy = ::boost::move(pos + raw_gap, old_finish, old_start);
+            T * const to_destroy = ::boost::move(pos + raw_gap, old_finish, old_start);
             //Now destroy redundant elements except if they were moved and
             //they have trivial destructor after move
             size_type n_destroy =  old_finish - to_destroy;
@@ -1840,7 +1827,7 @@ class vector : private container_detail::vector_alloc_holder
          //| old_begin + new + old_end  |  raw_mem           |
          //|____________________________|____________________|
          //
-         bool do_after    = n > s_before;
+         const bool do_after = n > s_before;
 
          //Now we can have two situations: the raw_mem of the
          //beginning divides the old_begin, or the new elements:
@@ -1869,28 +1856,26 @@ class vector : private container_detail::vector_alloc_holder
             //|___________|_____|_________|_____________________|
             //
             //Copy the first part of old_begin to raw_mem
-            T *start_n = old_start + difference_type(s_before);
-            ::boost::container::uninitialized_move_alloc
-               (this->alloc(), old_start, start_n, new_start);
+            ::boost::container::uninitialized_move_alloc_n
+               (this->alloc(), old_start, s_before, new_start);
             //The buffer is all constructed until old_end,
             //release destroyer and update size
             old_values_destroyer.release();
             this->members_.m_size = old_size + s_before;
-            //Now copy the second part of old_begin overwriting himself
-            T* next = ::boost::move(start_n, pos, old_start);
+            //Now copy the second part of old_begin overwriting itself
+            T *const next = ::boost::move(old_start + s_before, pos, old_start);
             if(do_after){
                //Now copy the new_beg elements
-               interf.copy_some_and_update(next, s_before, true);
+               insert_range_proxy.copy_n_and_update(next, s_before);
             }
             else{
                //Now copy the all the new elements
-               interf.copy_remaining_to(next);
-               T* move_start = next + n;
+               insert_range_proxy.copy_n_and_update(next, n);
                //Now displace old_end elements
-               T* move_end   = ::boost::move(pos, old_finish, move_start);
+               T* const move_end   = ::boost::move(pos, old_finish, next + n);
                //Destroy remaining moved elements from old_end except if
                //they have trivial destructor after being moved
-               difference_type n_destroy = s_before - n;
+               const size_type n_destroy = s_before - n;
                if(!value_traits::trivial_dctr_after_move)
                   this->destroy_n(move_end, n_destroy);
                this->members_.m_size -= n_destroy;
@@ -1923,30 +1908,30 @@ class vector : private container_detail::vector_alloc_holder
             //|___________|_____|_________|__________________________|
             //
             //First copy whole old_begin and part of new to raw_mem
-            ::boost::container::uninitialized_move_alloc
+            T * const new_pos = ::boost::container::uninitialized_move_alloc
                (this->alloc(), old_start, pos, new_start);
             this->members_.m_size = elemsbefore;
-
-            const size_type mid_n = difference_type(s_before) - elemsbefore;
-            interf.uninitialized_copy_some_and_update(new_start + elemsbefore, mid_n, true);
-            this->members_.m_size = old_size + s_before;
+            const size_type mid_n = s_before - elemsbefore;
+            insert_range_proxy.uninitialized_copy_n_and_update(new_pos, mid_n);
             //The buffer is all constructed until old_end,
-            //release destroyer and update size
+            //release destroyer
+            this->members_.m_size = old_size + s_before;
             old_values_destroyer.release();
 
             if(do_after){
                //Copy new_beg part
-               interf.copy_some_and_update(old_start, s_before - mid_n, true);
+               insert_range_proxy.copy_n_and_update(old_start, elemsbefore);
             }
             else{
                //Copy all new elements
-               interf.copy_remaining_to(old_start);
-               T* move_start = old_start + (n-mid_n);
+               const size_type rest_new = n - mid_n;
+               insert_range_proxy.copy_n_and_update(old_start, rest_new);
+               T* move_start = old_start + rest_new;
                //Displace old_end
                T* move_end = ::boost::move(pos, old_finish, move_start);
                //Destroy remaining moved elements from old_end except if they
                //have trivial destructor after being moved
-               difference_type n_destroy = s_before - n;
+               size_type n_destroy = s_before - n;
                if(!value_traits::trivial_dctr_after_move)
                   this->destroy_n(move_end, n_destroy);
                this->members_.m_size -= n_destroy;
@@ -1954,9 +1939,6 @@ class vector : private container_detail::vector_alloc_holder
          }
 
          //This is only executed if two phase construction is needed
-         //This can be executed without exception handling since we
-         //have to just copy and append in raw memory and
-         //old_values_destroyer has been released in phase 1.
          if(do_after){
             //The raw memory divides the new elements
             //
@@ -1975,11 +1957,11 @@ class vector : private container_detail::vector_alloc_holder
             //| old_begin      +       new            | old_end |raw |
             //|_______________________________________|_________|____|
             //
-            const size_type n_after  = n - s_before;
-            const difference_type elemsafter = old_size - elemsbefore;
+            const size_type n_after    = n - s_before;
+            const size_type elemsafter = old_size - elemsbefore;
 
             //We can have two situations:
-            if (elemsafter > difference_type(n_after)){
+            if (elemsafter >= n_after){
                //The raw_mem from end will divide displaced old_end
                //
                //Old situation:
@@ -1993,7 +1975,7 @@ class vector : private container_detail::vector_alloc_holder
                //|__________________________|_________|________|_________|
                //
                //First copy the part of old_end raw_mem
-               T* finish_n = old_finish - difference_type(n_after);
+               T* finish_n = old_finish - n_after;
                ::boost::container::uninitialized_move_alloc
                   (this->alloc(), finish_n, old_finish, old_finish);
                this->members_.m_size += n_after;
@@ -2001,7 +1983,7 @@ class vector : private container_detail::vector_alloc_holder
                boost::move_backward(pos, finish_n, old_finish);
                //Now overwrite with new_end
                //The new_end part is [first + (n - n_after), last)
-               interf.copy_remaining_to(pos);
+               insert_range_proxy.copy_n_and_update(pos, n_after);
             }
             else {
                //The raw_mem from end will divide new_end part
@@ -2016,16 +1998,38 @@ class vector : private container_detail::vector_alloc_holder
                //| old_begin   +   new_beg  |     new_end   |old_end | raw_mem |
                //|__________________________|_______________|________|_________|
                //
+
+               const size_type mid_last_dist = n_after - elemsafter;
+               //First initialize data in raw memory
+
+               //Copy to the old_end part to the uninitialized zone leaving a gap.
+               ::boost::container::uninitialized_move_alloc
+                  (this->alloc(), pos, old_finish, old_finish + mid_last_dist);
+
+               BOOST_TRY{
+                  //Copy the first part to the already constructed old_end zone
+                  insert_range_proxy.copy_n_and_update(pos, elemsafter);
+                  //Copy the rest to the uninitialized zone filling the gap
+                  insert_range_proxy.uninitialized_copy_n_and_update(old_finish, mid_last_dist);
+                  this->members_.m_size += n_after;
+               }
+               BOOST_CATCH(...){
+                  this->destroy_n(pos, mid_last_dist);
+                  BOOST_RETHROW
+               }
+               BOOST_CATCH_END
+/*
                size_type mid_last_dist = n_after - elemsafter;
                //First initialize data in raw memory
+
                //The new_end part is [first + (n - n_after), last)
-               interf.uninitialized_copy_some_and_update(old_finish, elemsafter, false);
+               insert_range_proxy.uninitialized_copy_last_and_update(old_finish, elemsafter);
                this->members_.m_size += mid_last_dist;
                ::boost::container::uninitialized_move_alloc
                   (this->alloc(), pos, old_finish, old_finish + mid_last_dist);
                this->members_.m_size += n_after - mid_last_dist;
                //Now copy the part of new_end over constructed elements
-               interf.copy_remaining_to(pos);
+               insert_range_proxy.copy_remaining_to(pos);*/
             }
          }
       }
@@ -2083,17 +2087,14 @@ inline void swap(vector& x, vector& y)
 
 namespace boost {
 
-/*
 
 //!has_trivial_destructor_after_move<> == true_type
 //!specialization for optimizations
 template 
 struct has_trivial_destructor_after_move >
-{
-   static const bool value = has_trivial_destructor::value;
-};
+   : public ::boost::has_trivial_destructor_after_move
+{};
 
-*/
 
 }
 

From 6d4af66addfdb4b4262f5acea09187d6d33f0db6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Sat, 24 Nov 2012 21:09:10 +0000
Subject: [PATCH 62/93] *  Improved `vector`'s insertion performance. * 
 Changed again experimental multiallocation interface for better performance
 (still experimental). *  Added no exception support for those willing to
 disable exceptions in their compilers. *  Fixed GCC -Wshadow warnings. * 
 Replaced deprecated BOOST_NO_XXXX with newer BOOST_NO_CXX11_XXX macros.

[SVN r81519]
---
 doc/container.qbk                      |  10 +
 example/doc_move_containers.cpp        |   2 +-
 proj/to-do.txt                         |  99 +---------
 proj/vc7ide/container.vcproj           |   3 +
 test/allocator_traits_test.cpp         |   2 +-
 test/deque_test.cpp                    |  12 +-
 test/dummy_test_allocator.hpp          |  12 +-
 test/emplace_test.hpp                  | 257 +++++++++++++++++--------
 test/expand_bwd_test_allocator.hpp     |   7 +-
 test/flat_tree_test.cpp                |  74 +++++++
 test/list_test.hpp                     |   3 +-
 test/map_test.hpp                      |  25 +--
 test/movable_int.hpp                   |   3 +-
 test/scoped_allocator_adaptor_test.cpp |   2 +-
 test/scoped_allocator_usage_test.cpp   |   2 +-
 test/set_test.hpp                      |  82 ++++----
 test/string_test.cpp                   |   3 -
 test/vector_test.cpp                   |   9 +-
 test/vector_test.hpp                   |   4 +-
 19 files changed, 355 insertions(+), 256 deletions(-)

diff --git a/doc/container.qbk b/doc/container.qbk
index 75f4a3f..6e7f9d2 100644
--- a/doc/container.qbk
+++ b/doc/container.qbk
@@ -614,6 +614,16 @@ use [*Boost.Container]? There are several reasons for that:
 
 [section:release_notes Release Notes]
 
+[section:release_notes_boost_1_53_00 Boost 1.53 Release]
+
+*  Improved `vector`'s insertion performance.
+*  Changed again experimental multiallocation interface for better performance (still experimental).
+*  Added no exception support for those willing to disable exceptions in their compilers.
+*  Fixed GCC -Wshadow warnings.
+*  Replaced deprecated BOOST_NO_XXXX with newer BOOST_NO_CXX11_XXX macros.
+
+[endsect]
+
 [section:release_notes_boost_1_52_00 Boost 1.52 Release]
 
 *  Improved `stable_vector`'s template code bloat and type safety.
diff --git a/example/doc_move_containers.cpp b/example/doc_move_containers.cpp
index c0fa618..867db0b 100644
--- a/example/doc_move_containers.cpp
+++ b/example/doc_move_containers.cpp
@@ -11,7 +11,7 @@
 #include 
 //[doc_move_containers
 #include 
-#include 
+#include 
 #include 
 
 //Non-copyable class
diff --git a/proj/to-do.txt b/proj/to-do.txt
index f0c9890..01d497a 100644
--- a/proj/to-do.txt
+++ b/proj/to-do.txt
@@ -5,6 +5,10 @@
 ->Align with C++11 [multi]map::insert(P &&p) overload.
 ->Unify all allocator version traits in one class (starting from stable_vector_detail::allocator_version_wrapper)
    maybe in allocator_traits?
+->Fix code marked with "//to-do: if possible, an efficient way to deallocate allocated blocks"
+->Add BOOST_CONTAINER_TRY, etc. macros to allow disabling exceptions only in this library (just like Boost.Intrusive)
+->Add macro to change the default allocator std::allocator to another one
+->Add front()/back() to string
 
 
 Review allocator traits
@@ -56,97 +60,4 @@ Add hash for containers
 
 Add std:: hashing support
 
-Fix trivial destructor after move and other optimizing traits
-
-Mark previous() in slist/and forward_list as non-standard
-
-Function order:
-
-----------type------------
-value_type;
-pointer;
-const_pointer;
-reference;
-const_reference;
-size_type;
-difference_type;
-allocator_type;
-stored_allocator_type;
-iterator;
-const_iterator;
-reverse_iterator;
-const_reverse_iterator;
-----------func------------
-container()
-container(allocator_type)
-container(size_type)
-container(size_type, value_type, allocator_type = ())
-container(InpIt, InpIt)
-container(const container &)
-container(container &&)
-container(const container &, allocator_type)
-container(container &&, allocator_type)
-container(initializer_list, allocator)
-~container()
-container operator=(const container &)
-container operator=(container &&)
-container operator=(initializer_list)
-assign(size_type, const T &)
-
-assign(InpIt, InptIt)
-assign(initializer_list)
-get_allocator()
-
-begin()
-begin() const
-end()
-end() const
-rbegin()
-rbegin() const
-rend()
-rend() const
-
-cbegin() const
-cend() const
-crbegin() const
-crend() const
-
-empty()
-size()
-max_size()
-resize(size_type)
-resize(size_type, cont T&)
-capacity()
-reserve(size_type)
-shrink_to_fit()
-
-front()
-front() const
-back()
-back() const
-operator[] ()
-operator[] ()const
-at()
-at() const
-
-
-data()
-data() const
-
-emplace_front()
-emplace_back()
-emplace()
-push_front(const T&)
-push_front(T&&)
-push_back(const T&)
-push_back(T&&)
-insert(iterator, const T &)
-insert(iterator, T &&)
-insert(size_type, const T &)
-insert(InpIt, InpIt)
-pop_front()
-pop_back()
-erase(const_iterator)
-erase(const_iterator, const_iterator)
-swap(container &)
-clear()
\ No newline at end of file
+Fix trivial destructor after move and other optimizing traits
\ No newline at end of file
diff --git a/proj/vc7ide/container.vcproj b/proj/vc7ide/container.vcproj
index ca5a3e3..5c89b16 100644
--- a/proj/vc7ide/container.vcproj
+++ b/proj/vc7ide/container.vcproj
@@ -242,6 +242,9 @@
 				
 				
+				
+				
 				
 				
diff --git a/test/allocator_traits_test.cpp b/test/allocator_traits_test.cpp
index 65ce8f3..3161884 100644
--- a/test/allocator_traits_test.cpp
+++ b/test/allocator_traits_test.cpp
@@ -14,7 +14,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 template
diff --git a/test/deque_test.cpp b/test/deque_test.cpp
index fbc4ab6..23a8e58 100644
--- a/test/deque_test.cpp
+++ b/test/deque_test.cpp
@@ -21,7 +21,8 @@
 #include "check_equal_containers.hpp"
 #include "dummy_test_allocator.hpp"
 #include "movable_int.hpp"
-#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -148,8 +149,7 @@ bool do_test()
       MyCntDeque *cntdeque = new MyCntDeque;
       MyStdDeque *stddeque = new MyStdDeque;
       //Compare several shared memory deque operations with std::deque
-      int i;
-      for(i = 0; i < max*100; ++i){
+      for(int i = 0; i < max*100; ++i){
          IntType move_me(i);
          cntdeque->insert(cntdeque->end(), boost::move(move_me));
          stddeque->insert(stddeque->end(), i);
@@ -159,7 +159,7 @@ bool do_test()
       cntdeque->clear();
       stddeque->clear();
 
-      for(i = 0; i < max*100; ++i){
+      for(int i = 0; i < max*100; ++i){
          IntType move_me(i);
          cntdeque->push_back(boost::move(move_me));
          stddeque->push_back(i);
@@ -169,7 +169,7 @@ bool do_test()
       cntdeque->clear();
       stddeque->clear();
 
-      for(i = 0; i < max*100; ++i){
+      for(int i = 0; i < max*100; ++i){
          IntType move_me(i);
          cntdeque->push_front(boost::move(move_me));
          stddeque->push_front(i);
@@ -239,7 +239,7 @@ bool do_test()
 
       if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
 
-      for(i = 0; i < max; ++i){
+      for(int i = 0; i < max; ++i){
          IntType move_me(i);
          cntdeque->insert(cntdeque->begin(), boost::move(move_me));
          stddeque->insert(stddeque->begin(), i);
diff --git a/test/dummy_test_allocator.hpp b/test/dummy_test_allocator.hpp
index 332892e..ef95836 100644
--- a/test/dummy_test_allocator.hpp
+++ b/test/dummy_test_allocator.hpp
@@ -26,7 +26,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -55,7 +55,7 @@ class simple_allocator
    {}
 
    T* allocate(std::size_t n)
-   {  return (T*)::new char[sizeof(T)*n];  }
+   { return (T*)::new char[sizeof(T)*n];  }
 
    void deallocate(T*p, std::size_t)
    { delete[] ((char*)p);}
@@ -168,8 +168,8 @@ class dummy_test_allocator
    //!preferred_elements. The number of actually allocated elements is
    //!will be assigned to received_size. Memory allocated with this function
    //!must be deallocated only with deallocate_one().
-   multiallocation_chain allocate_individual(size_type)
-   {  return multiallocation_chain(); }
+   void allocate_individual(size_type, multiallocation_chain &)
+   {}
 
    //!Allocates many elements of size == 1 in a contiguous block
    //!of memory. The minimum number to be allocated is min_elements,
@@ -177,7 +177,7 @@ class dummy_test_allocator
    //!preferred_elements. The number of actually allocated elements is
    //!will be assigned to received_size. Memory allocated with this function
    //!must be deallocated only with deallocate_one().
-   void deallocate_individual(multiallocation_chain)
+   void deallocate_individual(multiallocation_chain &)
    {}
 
    //!Allocates many elements of size elem_size in a contiguous block
@@ -186,7 +186,7 @@ class dummy_test_allocator
    //!preferred_elements. The number of actually allocated elements is
    //!will be assigned to received_size. The elements must be deallocated
    //!with deallocate(...)
-   void deallocate_many(multiallocation_chain)
+   void deallocate_many(multiallocation_chain &)
    {}
 };
 
diff --git a/test/emplace_test.hpp b/test/emplace_test.hpp
index ff93659..c772c9c 100644
--- a/test/emplace_test.hpp
+++ b/test/emplace_test.hpp
@@ -15,7 +15,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
@@ -98,14 +98,20 @@ enum EmplaceOptions{
 };
 
 template
-bool test_expected_container(const Container &ec, const EmplaceInt *Expected, unsigned int only_first_n)
+bool test_expected_container(const Container &ec, const EmplaceInt *Expected, unsigned int only_first_n, unsigned int cont_offset = 0)
 {
    typedef typename Container::const_iterator const_iterator;
    const_iterator itb(ec.begin()), ite(ec.end());
    unsigned int cur = 0;
-   if(only_first_n > ec.size()){
+   if(cont_offset > ec.size()){
       return false;
    }
+   if(only_first_n > (ec.size() - cont_offset)){
+      return false;
+   }
+   while(cont_offset--){
+      ++itb;
+   }
    for(; itb != ite && only_first_n--; ++itb, ++cur){
       const EmplaceInt & cr = *itb;
       if(cr != Expected[cur]){
@@ -163,33 +169,39 @@ bool test_emplace_back(container_detail::true_)
       << typeid(Container).name() << std::endl;
 
    {
-   new(&expected [0]) EmplaceInt();
-   new(&expected [1]) EmplaceInt(1);
-   new(&expected [2]) EmplaceInt(1, 2);
-   new(&expected [3]) EmplaceInt(1, 2, 3);
-   new(&expected [4]) EmplaceInt(1, 2, 3, 4);
-   new(&expected [5]) EmplaceInt(1, 2, 3, 4, 5);
-   Container c;
-   c.emplace_back();
-   if(!test_expected_container(c, &expected[0], 1))
-      return false;
-   c.emplace_back(1);
-   if(!test_expected_container(c, &expected[0], 2))
-      return false;
-   c.emplace_back(1, 2);
-   if(!test_expected_container(c, &expected[0], 3))
-      return false;
-   c.emplace_back(1, 2, 3);
-   if(!test_expected_container(c, &expected[0], 4))
-      return false;
-   c.emplace_back(1, 2, 3, 4);
-   if(!test_expected_container(c, &expected[0], 5))
-      return false;
-   c.emplace_back(1, 2, 3, 4, 5);
-   if(!test_expected_container(c, &expected[0], 6))
-      return false;
+      new(&expected [0]) EmplaceInt();
+      new(&expected [1]) EmplaceInt(1);
+      new(&expected [2]) EmplaceInt(1, 2);
+      new(&expected [3]) EmplaceInt(1, 2, 3);
+      new(&expected [4]) EmplaceInt(1, 2, 3, 4);
+      new(&expected [5]) EmplaceInt(1, 2, 3, 4, 5);
+      Container c;
+      c.emplace_back();
+      if(!test_expected_container(c, &expected[0], 1)){
+         return false;
+      }
+      c.emplace_back(1);
+      if(!test_expected_container(c, &expected[0], 2)){
+         return false;
+      }
+      c.emplace_back(1, 2);
+      if(!test_expected_container(c, &expected[0], 3)){
+         return false;
+      }
+      c.emplace_back(1, 2, 3);
+      if(!test_expected_container(c, &expected[0], 4)){
+         return false;
+      }
+      c.emplace_back(1, 2, 3, 4);
+      if(!test_expected_container(c, &expected[0], 5)){
+         return false;
+      }
+      c.emplace_back(1, 2, 3, 4, 5);
+      if(!test_expected_container(c, &expected[0], 6)){
+         return false;
+      }
    }
-
+   std::cout << "...OK" << std::endl;
    return true;
 }
 
@@ -212,24 +224,31 @@ bool test_emplace_front(container_detail::true_)
       new(&expected [5]) EmplaceInt();
       Container c;
       c.emplace_front();
-      if(!test_expected_container(c, &expected[0] + 5, 1))
+      if(!test_expected_container(c, &expected[0] + 5, 1)){
          return false;
-      c.emplace_front(1);/*
-      if(!test_expected_container(c, &expected[0] + 4, 2))
+      }
+      c.emplace_front(1);
+      if(!test_expected_container(c, &expected[0] + 4, 2)){
          return false;
+      }
       c.emplace_front(1, 2);
-      if(!test_expected_container(c, &expected[0] + 3, 3))
+      if(!test_expected_container(c, &expected[0] + 3, 3)){
          return false;
+      }
       c.emplace_front(1, 2, 3);
-      if(!test_expected_container(c, &expected[0] + 2, 4))
+      if(!test_expected_container(c, &expected[0] + 2, 4)){
          return false;
+      }
       c.emplace_front(1, 2, 3, 4);
-      if(!test_expected_container(c, &expected[0] + 1, 5))
+      if(!test_expected_container(c, &expected[0] + 1, 5)){
          return false;
+      }
       c.emplace_front(1, 2, 3, 4, 5);
-      if(!test_expected_container(c, &expected[0] + 0, 6))
-         return false;*/
+      if(!test_expected_container(c, &expected[0] + 0, 6)){
+         return false;
+      }
    }
+   std::cout << "...OK" << std::endl;
    return true;
 }
 
@@ -250,11 +269,13 @@ bool test_emplace_before(container_detail::true_)
       Container c;
       c.emplace(c.cend(), 1);
       c.emplace(c.cbegin());
-      if(!test_expected_container(c, &expected[0], 2))
+      if(!test_expected_container(c, &expected[0], 2)){
          return false;
+      }
       c.emplace(c.cend());
-      if(!test_expected_container(c, &expected[0], 3))
+      if(!test_expected_container(c, &expected[0], 3)){
          return false;
+      }
    }
    {
       new(&expected [0]) EmplaceInt();
@@ -271,39 +292,74 @@ bool test_emplace_before(container_detail::true_)
       c.emplace(c.cbegin(), 1, 2);
       c.emplace(c.cbegin(), 1);
       c.emplace(c.cbegin());
-      if(!test_expected_container(c, &expected[0], 6))
+      if(!test_expected_container(c, &expected[0], 6)){
          return false;
+      }
       c.clear();
       //emplace_back-like
       typename Container::const_iterator i = c.emplace(c.cend());
-      if(!test_expected_container(c, &expected[0], 1))
+      if(!test_expected_container(c, &expected[0], 1)){
          return false;
+      }
       i = c.emplace(++i, 1);
-      if(!test_expected_container(c, &expected[0], 2))
+      if(!test_expected_container(c, &expected[0], 2)){
          return false;
+      }
       i = c.emplace(++i, 1, 2);
-      if(!test_expected_container(c, &expected[0], 3))
+      if(!test_expected_container(c, &expected[0], 3)){
          return false;
+      }
       i = c.emplace(++i, 1, 2, 3);
-      if(!test_expected_container(c, &expected[0], 4))
+      if(!test_expected_container(c, &expected[0], 4)){
          return false;
+      }
       i = c.emplace(++i, 1, 2, 3, 4);
-      if(!test_expected_container(c, &expected[0], 5))
+      if(!test_expected_container(c, &expected[0], 5)){
          return false;
+      }
       i = c.emplace(++i, 1, 2, 3, 4, 5);
-      if(!test_expected_container(c, &expected[0], 6))
+      if(!test_expected_container(c, &expected[0], 6)){
          return false;
+      }
       c.clear();
       //emplace in the middle
       c.emplace(c.cbegin());
-      i = c.emplace(c.cend(), 1, 2, 3, 4, 5);
-      i = c.emplace(i, 1, 2, 3, 4);
-      i = c.emplace(i, 1, 2, 3);
-      i = c.emplace(i, 1, 2);
-      i = c.emplace(i, 1);
-
-      if(!test_expected_container(c, &expected[0], 6))
+      if(!test_expected_container(c, &expected[0], 1)){
          return false;
+      }
+      i = c.emplace(c.cend(), 1, 2, 3, 4, 5);
+      if(!test_expected_container(c, &expected[0], 1)){
+         return false;
+      }
+      if(!test_expected_container(c, &expected[5], 1, 1)){
+         return false;
+      }
+      i = c.emplace(i, 1, 2, 3, 4);
+      if(!test_expected_container(c, &expected[0], 1)){
+         return false;
+      }
+      if(!test_expected_container(c, &expected[4], 2, 1)){
+         return false;
+      }
+      i = c.emplace(i, 1, 2, 3);
+      if(!test_expected_container(c, &expected[0], 1)){
+         return false;
+      }
+      if(!test_expected_container(c, &expected[3], 3, 1)){
+         return false;
+      }
+      i = c.emplace(i, 1, 2);
+      if(!test_expected_container(c, &expected[0], 1)){
+         return false;
+      }
+      if(!test_expected_container(c, &expected[2], 4, 1)){
+         return false;
+      }
+      i = c.emplace(i, 1);
+      if(!test_expected_container(c, &expected[0], 6)){
+         return false;
+      }
+      std::cout << "...OK" << std::endl;
    }
    return true;
 }
@@ -324,11 +380,13 @@ bool test_emplace_after(container_detail::true_)
       Container c;
       typename Container::const_iterator i = c.emplace_after(c.cbefore_begin(), 1);
       c.emplace_after(c.cbefore_begin());
-      if(!test_expected_container(c, &expected[0], 2))
+      if(!test_expected_container(c, &expected[0], 2)){
          return false;
+      }
       c.emplace_after(i);
-      if(!test_expected_container(c, &expected[0], 3))
+      if(!test_expected_container(c, &expected[0], 3)){
          return false;
+      }
    }
    {
       new(&expected [0]) EmplaceInt();
@@ -345,28 +403,35 @@ bool test_emplace_after(container_detail::true_)
       c.emplace_after(c.cbefore_begin(), 1, 2);
       c.emplace_after(c.cbefore_begin(), 1);
       c.emplace_after(c.cbefore_begin());
-      if(!test_expected_container(c, &expected[0], 6))
+      if(!test_expected_container(c, &expected[0], 6)){
          return false;
+      }
       c.clear();
       //emplace_back-like
       typename Container::const_iterator i = c.emplace_after(c.cbefore_begin());
-      if(!test_expected_container(c, &expected[0], 1))
+      if(!test_expected_container(c, &expected[0], 1)){
          return false;
+      }
       i = c.emplace_after(i, 1);
-      if(!test_expected_container(c, &expected[0], 2))
+      if(!test_expected_container(c, &expected[0], 2)){
          return false;
+      }
       i = c.emplace_after(i, 1, 2);
-      if(!test_expected_container(c, &expected[0], 3))
+      if(!test_expected_container(c, &expected[0], 3)){
          return false;
+      }
       i = c.emplace_after(i, 1, 2, 3);
-      if(!test_expected_container(c, &expected[0], 4))
+      if(!test_expected_container(c, &expected[0], 4)){
          return false;
+      }
       i = c.emplace_after(i, 1, 2, 3, 4);
-      if(!test_expected_container(c, &expected[0], 5))
+      if(!test_expected_container(c, &expected[0], 5)){
          return false;
+      }
       i = c.emplace_after(i, 1, 2, 3, 4, 5);
-      if(!test_expected_container(c, &expected[0], 6))
+      if(!test_expected_container(c, &expected[0], 6)){
          return false;
+      }
       c.clear();
       //emplace_after in the middle
       i = c.emplace_after(c.cbefore_begin());
@@ -376,8 +441,10 @@ bool test_emplace_after(container_detail::true_)
       c.emplace_after(i, 1, 2);
       c.emplace_after(i, 1);
 
-      if(!test_expected_container(c, &expected[0], 6))
+      if(!test_expected_container(c, &expected[0], 6)){
          return false;
+      }
+      std::cout << "...OK" << std::endl;
    }
    return true;
 }
@@ -401,23 +468,30 @@ bool test_emplace_assoc(container_detail::true_)
    {
       Container c;
       c.emplace();
-      if(!test_expected_container(c, &expected[0], 1))
+      if(!test_expected_container(c, &expected[0], 1)){
          return false;
+      }
       c.emplace(1);
-      if(!test_expected_container(c, &expected[0], 2))
+      if(!test_expected_container(c, &expected[0], 2)){
          return false;
+      }
       c.emplace(1, 2);
-      if(!test_expected_container(c, &expected[0], 3))
+      if(!test_expected_container(c, &expected[0], 3)){
          return false;
+      }
       c.emplace(1, 2, 3);
-      if(!test_expected_container(c, &expected[0], 4))
+      if(!test_expected_container(c, &expected[0], 4)){
          return false;
+      }
       c.emplace(1, 2, 3, 4);
-      if(!test_expected_container(c, &expected[0], 5))
+      if(!test_expected_container(c, &expected[0], 5)){
          return false;
+      }
       c.emplace(1, 2, 3, 4, 5);
-      if(!test_expected_container(c, &expected[0], 6))
+      if(!test_expected_container(c, &expected[0], 6)){
          return false;
+      }
+      std::cout << "...OK" << std::endl;
    }
    return true;
 }
@@ -443,23 +517,30 @@ bool test_emplace_hint(container_detail::true_)
       Container c;
       typename Container::const_iterator it;
       it = c.emplace_hint(c.begin());
-      if(!test_expected_container(c, &expected[0], 1))
+      if(!test_expected_container(c, &expected[0], 1)){
          return false;
+      }
       it = c.emplace_hint(it, 1);
-      if(!test_expected_container(c, &expected[0], 2))
+      if(!test_expected_container(c, &expected[0], 2)){
          return false;
+      }
       it = c.emplace_hint(it, 1, 2);
-      if(!test_expected_container(c, &expected[0], 3))
+      if(!test_expected_container(c, &expected[0], 3)){
          return false;
+      }
       it = c.emplace_hint(it, 1, 2, 3);
-      if(!test_expected_container(c, &expected[0], 4))
+      if(!test_expected_container(c, &expected[0], 4)){
          return false;
+      }
       it = c.emplace_hint(it, 1, 2, 3, 4);
-      if(!test_expected_container(c, &expected[0], 5))
+      if(!test_expected_container(c, &expected[0], 5)){
          return false;
+      }
       it = c.emplace_hint(it, 1, 2, 3, 4, 5);
-      if(!test_expected_container(c, &expected[0], 6))
+      if(!test_expected_container(c, &expected[0], 6)){
          return false;
+      }
+      std::cout << "...OK" << std::endl;
    }
 
    return true;
@@ -498,6 +579,7 @@ bool test_emplace_assoc_pair(container_detail::true_)
          std::cout << "Error after c.emplace(2, 2);\n";
          return false;
       }
+      std::cout << "...OK" << std::endl;
    }
    return true;
 }
@@ -536,6 +618,7 @@ bool test_emplace_hint_pair(container_detail::true_)
          std::cout << "Error after c.emplace(it, 2, 2);\n";
          return false;
       }
+      std::cout << "...OK" << std::endl;
    }
    return true;
 }
@@ -555,22 +638,30 @@ struct emplace_active
 template
 bool test_emplace()
 {
-   if(!test_emplace_back(emplace_active()))
+   if(!test_emplace_back(emplace_active())){
       return false;
-   if(!test_emplace_front(emplace_active()))
+   }
+   if(!test_emplace_front(emplace_active())){
       return false;
-   if(!test_emplace_before(emplace_active()))
+   }
+   if(!test_emplace_before(emplace_active())){
       return false;
-   if(!test_emplace_after(emplace_active()))
+   }
+   if(!test_emplace_after(emplace_active())){
       return false;
-   if(!test_emplace_assoc(emplace_active()))
+   }
+   if(!test_emplace_assoc(emplace_active())){
       return false;
-   if(!test_emplace_hint(emplace_active()))
+   }
+   if(!test_emplace_hint(emplace_active())){
       return false;
-   if(!test_emplace_assoc_pair(emplace_active()))
+   }
+   if(!test_emplace_assoc_pair(emplace_active())){
       return false;
-   if(!test_emplace_hint_pair(emplace_active()))
+   }
+   if(!test_emplace_hint_pair(emplace_active())){
       return false;
+   }
    return true;
 }
 
diff --git a/test/expand_bwd_test_allocator.hpp b/test/expand_bwd_test_allocator.hpp
index fbab8c7..a39aaf1 100644
--- a/test/expand_bwd_test_allocator.hpp
+++ b/test/expand_bwd_test_allocator.hpp
@@ -65,13 +65,16 @@ class expand_bwd_test_allocator
 
    typedef boost::container::container_detail::version_type   version;
 
+   //Dummy multiallocation chain
+   struct multiallocation_chain{};
+
    template
    struct rebind
    {  typedef expand_bwd_test_allocator   other;   };
 
    //!Constructor from the segment manager. Never throws
-   expand_bwd_test_allocator(T *buffer, size_type size, difference_type offset)
-      : mp_buffer(buffer), m_size(size)
+   expand_bwd_test_allocator(T *buffer, size_type sz, difference_type offset)
+      : mp_buffer(buffer), m_size(sz)
       , m_offset(offset),  m_allocations(0){ }
 
    //!Constructor from other expand_bwd_test_allocator. Never throws
diff --git a/test/flat_tree_test.cpp b/test/flat_tree_test.cpp
index c6738e2..c476b13 100644
--- a/test/flat_tree_test.cpp
+++ b/test/flat_tree_test.cpp
@@ -627,3 +627,77 @@ int main()
 }
 
 #include 
+
+/*
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct Request 
+{ 
+    Request() {};
+    
+    //Move semantics...
+    Request(BOOST_RV_REF(Request) r) : rvals()  //Move constructor
+    {
+        rvals.swap(r.rvals);
+    };
+
+    Request& operator=(BOOST_RV_REF(Request) r) //Move assignment
+    {
+        if (this != &r){
+            rvals.swap(r.rvals);
+        }
+        return *this;
+    };
+
+    // Values I want to be moved, not copied.
+    boost::container::vector rvals;
+
+   private:
+    // Mark this class movable but not copyable
+    BOOST_MOVABLE_BUT_NOT_COPYABLE(Request)
+};
+
+typedef boost::container::flat_map Requests;
+//typedef boost::container::map Requests2;
+
+int
+main() {
+    Requests req;
+    std::pair ret = req.insert( Requests::value_type( 7, Request() ) );
+    std::cout << "Insert success for req: " << ret.second << std::endl;
+    
+    //Requests2 req2;
+    //std::pair ret2 = req2.insert( Requests2::value_type( 7, Request() ) );
+    //std::cout << "Insert success for req2: " << ret2.second << std::endl;
+
+    return 0;
+}
+*/
+/*
+#include 
+#include 
+#include 
+
+using namespace std;
+
+int main(int , char *[])
+{
+    double d[] = {0, 0.2, 0.8, 1, 2, 3, 4};
+    boost::container::flat_set set;
+
+    set.insert(0);
+    set.insert(set.end(), 1);
+    set.insert(set.end(), 3);
+    set.insert(boost::container::ordered_unique_range_t(), d, d + sizeof(d)/sizeof(*d));
+    boost::container::flat_set::iterator it(set.begin());
+    boost::container::flat_set::iterator const itend(set.end());
+    while(it != itend)
+        cout << *it++ << endl;
+
+    return 0;
+}
+*/
\ No newline at end of file
diff --git a/test/list_test.hpp b/test/list_test.hpp
index 85f1b73..e1f0ec6 100644
--- a/test/list_test.hpp
+++ b/test/list_test.hpp
@@ -19,7 +19,8 @@
 #include 
 #include "print_container.hpp"
 #include "input_from_forward_iterator.hpp"
-#include 
+#include 
+#include 
 #include 
 
 namespace boost{
diff --git a/test/map_test.hpp b/test/map_test.hpp
index 66dc800..96ea05d 100644
--- a/test/map_test.hpp
+++ b/test/map_test.hpp
@@ -19,6 +19,8 @@
 #include "print_container.hpp"
 #include 
 #include 
+#include 
+#include 
 #include 
 
 template
@@ -104,7 +106,6 @@ int map_test ()
          if(!CheckEqualContainers(boostmap2, stdmap2)) return 1;
          if(!CheckEqualContainers(boostmultimap2, stdmultimap2)) return 1;
 
-/*
          MyBoostMap *boostmap3 = new MyBoostMap
                ( ordered_unique_range
                , boost::make_move_iterator(&aux_vect[0])
@@ -124,12 +125,14 @@ int map_test ()
             std::cout << "Error in construct(MyBoostMultiMap3)" << std::endl;
             return 1;
          }
-*/
-         IntType i0(0);
-         boostmap2->erase(i0);
-         boostmultimap2->erase(i0);
-         stdmap2->erase(0);
-         stdmultimap2->erase(0);
+
+         {
+            IntType i0(0);
+            boostmap2->erase(i0);
+            boostmultimap2->erase(i0);
+            stdmap2->erase(0);
+            stdmultimap2->erase(0);
+         }
          {
             IntType i0(0);
             IntType i1(1);
@@ -146,10 +149,10 @@ int map_test ()
          delete boostmultimap2;
          delete stdmap2;
          delete stdmultimap2;
-         //delete boostmap3;
-         //delete boostmultimap3;
-         //delete stdmap3;
-         //delete stdmultimap3;
+         delete boostmap3;
+         delete boostmultimap3;
+         delete stdmap3;
+         delete stdmultimap3;
       }
       {
          //This is really nasty, but we have no other simple choice
diff --git a/test/movable_int.hpp b/test/movable_int.hpp
index d895845..65fa473 100644
--- a/test/movable_int.hpp
+++ b/test/movable_int.hpp
@@ -13,7 +13,8 @@
 
 #include 
 #include 
-#include 
+#include 
+#include 
 
 namespace boost {
 namespace container {
diff --git a/test/scoped_allocator_adaptor_test.cpp b/test/scoped_allocator_adaptor_test.cpp
index 66d86b0..1855127 100644
--- a/test/scoped_allocator_adaptor_test.cpp
+++ b/test/scoped_allocator_adaptor_test.cpp
@@ -11,7 +11,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
diff --git a/test/scoped_allocator_usage_test.cpp b/test/scoped_allocator_usage_test.cpp
index c0a4827..f8dafa4 100644
--- a/test/scoped_allocator_usage_test.cpp
+++ b/test/scoped_allocator_usage_test.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/test/set_test.hpp b/test/set_test.hpp
index 20554df..91397c9 100644
--- a/test/set_test.hpp
+++ b/test/set_test.hpp
@@ -17,7 +17,8 @@
 #include 
 #include 
 #include "print_container.hpp"
-#include 
+#include 
+#include 
 #include 
 
 namespace boost{
@@ -119,8 +120,7 @@ int set_test ()
       delete stdmultiset3;
    }
 
-   int i, j;
-   for(i = 0; i < max; ++i){
+   for(int i = 0; i < max; ++i){
       IntType move_me(i);
       boostset->insert(boost::move(move_me));
       stdset->insert(i);
@@ -301,7 +301,7 @@ int set_test ()
       }
    }
 
-   for(i = 0; i < max; ++i){
+   for(int i = 0; i < max; ++i){
       IntType move_me(i);
       boostset->insert(boost::move(move_me));
       stdset->insert(i);
@@ -319,37 +319,39 @@ int set_test ()
       return 1;
    }
 
-   for(i = 0; i < max; ++i){
-      IntType move_me(i);
-      boostset->insert(boostset->begin(), boost::move(move_me));
-      stdset->insert(stdset->begin(), i);
-      //PrintContainers(boostset, stdset);
-      IntType move_me2(i);
-      boostmultiset->insert(boostmultiset->begin(), boost::move(move_me2));
-      stdmultiset->insert(stdmultiset->begin(), i);
-      //PrintContainers(boostmultiset, stdmultiset);
-      if(!CheckEqualContainers(boostset, stdset)){
-         std::cout << "Error in boostset->insert(boostset->begin(), boost::move(move_me))" << std::endl;
-         return 1;
-      }
-      if(!CheckEqualContainers(boostmultiset, stdmultiset)){
-         std::cout << "Error in boostmultiset->insert(boostmultiset->begin(), boost::move(move_me2))" << std::endl;
-         return 1;
-      }
+   for(int i = 0; i < max; ++i){
+      {
+         IntType move_me(i);
+         boostset->insert(boostset->begin(), boost::move(move_me));
+         stdset->insert(stdset->begin(), i);
+         //PrintContainers(boostset, stdset);
+         IntType move_me2(i);
+         boostmultiset->insert(boostmultiset->begin(), boost::move(move_me2));
+         stdmultiset->insert(stdmultiset->begin(), i);
+         //PrintContainers(boostmultiset, stdmultiset);
+         if(!CheckEqualContainers(boostset, stdset)){
+            std::cout << "Error in boostset->insert(boostset->begin(), boost::move(move_me))" << std::endl;
+            return 1;
+         }
+         if(!CheckEqualContainers(boostmultiset, stdmultiset)){
+            std::cout << "Error in boostmultiset->insert(boostmultiset->begin(), boost::move(move_me2))" << std::endl;
+            return 1;
+         }
 
-      IntType move_me3(i);
-      boostset->insert(boostset->end(), boost::move(move_me3));
-      stdset->insert(stdset->end(), i);
-      IntType move_me4(i);
-      boostmultiset->insert(boostmultiset->end(), boost::move(move_me4));
-      stdmultiset->insert(stdmultiset->end(), i);
-      if(!CheckEqualContainers(boostset, stdset)){
-         std::cout << "Error in boostset->insert(boostset->end(), boost::move(move_me3))" << std::endl;
-         return 1;
-      }
-      if(!CheckEqualContainers(boostmultiset, stdmultiset)){
-         std::cout << "Error in boostmultiset->insert(boostmultiset->end(), boost::move(move_me4))" << std::endl;
-         return 1;
+         IntType move_me3(i);
+         boostset->insert(boostset->end(), boost::move(move_me3));
+         stdset->insert(stdset->end(), i);
+         IntType move_me4(i);
+         boostmultiset->insert(boostmultiset->end(), boost::move(move_me4));
+         stdmultiset->insert(stdmultiset->end(), i);
+         if(!CheckEqualContainers(boostset, stdset)){
+            std::cout << "Error in boostset->insert(boostset->end(), boost::move(move_me3))" << std::endl;
+            return 1;
+         }
+         if(!CheckEqualContainers(boostmultiset, stdmultiset)){
+            std::cout << "Error in boostmultiset->insert(boostmultiset->end(), boost::move(move_me4))" << std::endl;
+            return 1;
+         }
       }
       {
       IntType move_me(i);
@@ -372,10 +374,11 @@ int set_test ()
       }
       {
       IntType move_me(i);
+      IntType move_me2(i);
       boostset->insert(boostset->lower_bound(move_me), boost::move(move_me2));
       stdset->insert(stdset->lower_bound(i), i);
       //PrintContainers(boostset, stdset);
-      IntType move_me2(i);
+      move_me2 = i;
       boostmultiset->insert(boostmultiset->lower_bound(move_me2), boost::move(move_me2));
       stdmultiset->insert(stdmultiset->lower_bound(i), i);
       //PrintContainers(boostmultiset, stdmultiset);
@@ -391,7 +394,7 @@ int set_test ()
    }
 
    //Compare count with std containers
-   for(i = 0; i < max; ++i){
+   for(int i = 0; i < max; ++i){
       IntType count_me(i);
       if(boostset->count(count_me) != stdset->count(i)){
          return -1;
@@ -407,8 +410,8 @@ int set_test ()
    boostset->clear();
    boostmultiset->clear();
 
-   for(j = 0; j < 3; ++j)
-   for(i = 0; i < 100; ++i){
+   for(int j = 0; j < 3; ++j)
+   for(int i = 0; i < 100; ++i){
       IntType move_me(i);
       boostset->insert(boost::move(move_me));
       IntType move_me2(i);
@@ -448,8 +451,7 @@ int set_test_copyable ()
       MyBoostMultiSet *boostmultiset = new MyBoostMultiSet;
       MyStdMultiSet *stdmultiset = new MyStdMultiSet;
 
-      int i;
-      for(i = 0; i < max; ++i){
+      for(int i = 0; i < max; ++i){
          IntType move_me(i);
          boostset->insert(boost::move(move_me));
          stdset->insert(i);
diff --git a/test/string_test.cpp b/test/string_test.cpp
index 4b6ff25..f68482d 100644
--- a/test/string_test.cpp
+++ b/test/string_test.cpp
@@ -330,9 +330,6 @@ int string_test()
 
       //Check addition
       {
-         typedef std::basic_string StdString;
-         typedef basic_string BoostString;
-        
          BoostString bs2 = string_literals::String();
          StdString   ss2 = string_literals::String();
          BoostString bs3 = string_literals::Suffix();
diff --git a/test/vector_test.cpp b/test/vector_test.cpp
index afc03b8..a872315 100644
--- a/test/vector_test.cpp
+++ b/test/vector_test.cpp
@@ -15,7 +15,7 @@
 #include 
 
 #include 
-#include 
+#include 
 #include "check_equal_containers.hpp"
 #include "movable_int.hpp"
 #include "expand_bwd_test_allocator.hpp"
@@ -148,12 +148,13 @@ int main()
    v.push_back(Test());
 
    const test::EmplaceOptions Options = (test::EmplaceOptions)(test::EMPLACE_BACK | test::EMPLACE_BEFORE);
-   if(!boost::container::test::test_emplace
-      < vector, Options>())
+   if(!boost::container::test::test_emplace< vector, Options>()){
       return 1;
+   }
 
-   if(!boost::container::test::test_propagate_allocator())
+   if(!boost::container::test::test_propagate_allocator()){
       return 1;
+   }
 
    return 0;
 
diff --git a/test/vector_test.hpp b/test/vector_test.hpp
index 5c262b0..503ec59 100644
--- a/test/vector_test.hpp
+++ b/test/vector_test.hpp
@@ -19,7 +19,7 @@
 #include 
 #include 
 
-#include 
+#include 
 #include 
 #include "print_container.hpp"
 #include "check_equal_containers.hpp"
@@ -28,6 +28,8 @@
 #include 
 #include "emplace_test.hpp"
 #include "input_from_forward_iterator.hpp"
+#include 
+#include 
 
 namespace boost{
 namespace container {

From 9cfc51f19c0a208b33b207e7afd4065588b1bf4c Mon Sep 17 00:00:00 2001
From: Marshall Clow 
Date: Mon, 26 Nov 2012 18:56:20 +0000
Subject: [PATCH 63/93] Removed usage of deprecated macros in Boost.Container

[SVN r81572]
---
 include/boost/container/detail/workaround.hpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/boost/container/detail/workaround.hpp b/include/boost/container/detail/workaround.hpp
index a0820a1..06cb733 100644
--- a/include/boost/container/detail/workaround.hpp
+++ b/include/boost/container/detail/workaround.hpp
@@ -18,7 +18,7 @@
    #define BOOST_CONTAINER_PERFECT_FORWARDING
 #endif
 
-#if defined(BOOST_NO_NOEXCEPT)
+#if defined(BOOST_NO_CXX11_NOEXCEPT)
    #if defined(BOOST_MSVC)
       #define BOOST_CONTAINER_NOEXCEPT throw()
    #else

From 4ec3cec4b288ab6023c1ef6fda846756ea075556 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Tue, 18 Dec 2012 21:07:54 +0000
Subject: [PATCH 64/93] Bug #7650

[SVN r82085]
---
 doc/container.qbk                | 1 +
 include/boost/container/list.hpp | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/doc/container.qbk b/doc/container.qbk
index 6e7f9d2..7dbc319 100644
--- a/doc/container.qbk
+++ b/doc/container.qbk
@@ -616,6 +616,7 @@ use [*Boost.Container]? There are several reasons for that:
 
 [section:release_notes_boost_1_53_00 Boost 1.53 Release]
 
+*  Fixed bug [@https://svn.boost.org/trac/boost/ticket/7650 #7650].
 *  Improved `vector`'s insertion performance.
 *  Changed again experimental multiallocation interface for better performance (still experimental).
 *  Added no exception support for those willing to disable exceptions in their compilers.
diff --git a/include/boost/container/list.hpp b/include/boost/container/list.hpp
index b4a3cf3..571e63a 100644
--- a/include/boost/container/list.hpp
+++ b/include/boost/container/list.hpp
@@ -119,7 +119,7 @@ class list_const_iterator
    { return this->m_it->m_data;  }
 
    const_pointer   operator->() const
-   { return ::boost::intrusive::pointer_traits::to_pointer(this->m_it->m_data); }
+   { return ::boost::intrusive::pointer_traits::pointer_to(this->m_it->m_data); }
 
    //Increment / Decrement
    list_const_iterator& operator++()      

From 71e9c48f32e2999839f256486650e1cf687fa40f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Fri, 28 Dec 2012 23:53:43 +0000
Subject: [PATCH 65/93] Added missing  include for std::swap

[SVN r82252]
---
 include/boost/container/detail/pair.hpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/boost/container/detail/pair.hpp b/include/boost/container/detail/pair.hpp
index 3fd63d4..79753a8 100644
--- a/include/boost/container/detail/pair.hpp
+++ b/include/boost/container/detail/pair.hpp
@@ -26,6 +26,7 @@
 #include 
 
 #include    //std::pair
+#include  //std::swap
 
 #include 
 #include 

From 99c8d5d9d7a406816c9e15e6a233ce83af956298 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Thu, 10 Jan 2013 10:55:50 +0000
Subject: [PATCH 66/93] Fixes #7227

[SVN r82429]
---
 doc/container.qbk                             |  51 +++++++
 include/boost/container/deque.hpp             |   4 +-
 .../detail/adaptive_node_pool_impl.hpp        |   5 +-
 .../detail/allocator_version_traits.hpp       |   4 +-
 include/boost/container/flat_map.hpp          |   7 +-
 include/boost/container/list.hpp              |   3 +-
 include/boost/container/map.hpp               |   7 +-
 include/boost/container/slist.hpp             |   2 +-
 include/boost/container/stable_vector.hpp     |  22 +--
 include/boost/container/string.hpp            |  80 +++++------
 include/boost/container/throw_exception.hpp   | 110 ++++++++++++++
 include/boost/container/vector.hpp            |   7 +-
 proj/vc7ide/container.sln                     |   8 ++
 proj/vc7ide/container.vcproj                  |   9 ++
 proj/vc7ide/throw_exception_test.vcproj       | 134 ++++++++++++++++++
 proj/vc7ide/vector_test.vcproj                |   1 +
 test/deque_test.cpp                           |   8 +-
 test/dummy_test_allocator.hpp                 |   2 +-
 test/expand_bwd_test_allocator.hpp            |   6 +-
 test/expand_bwd_test_template.hpp             |  14 +-
 test/heap_allocator_v1.hpp                    |   1 -
 test/list_test.hpp                            |   7 +-
 test/map_test.hpp                             |  14 +-
 test/set_test.hpp                             |   7 +-
 test/throw_exception_test.cpp                 |  62 ++++++++
 test/vector_test.hpp                          |   8 +-
 26 files changed, 487 insertions(+), 96 deletions(-)
 create mode 100644 include/boost/container/throw_exception.hpp
 create mode 100644 proj/vc7ide/throw_exception_test.vcproj
 create mode 100644 test/throw_exception_test.cpp

diff --git a/doc/container.qbk b/doc/container.qbk
index 7dbc319..5b90af6 100644
--- a/doc/container.qbk
+++ b/doc/container.qbk
@@ -189,6 +189,49 @@ Finally, we can just compile, link, and run!
 
 [endsect]
 
+[section:exception_handling Boost.Container and C++ exceptions]
+
+In some environments, such as game development or embedded systems, C++ exceptions are disabled or a customized error handling is needed.
+According to document [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html N2271 EASTL -- Electronic Arts Standard Template Library]
+exceptions can be disabled for several reasons:
+
+*  ["['Exception handling incurs some kind of cost in all compiler implementations, including those that avoid
+   the cost during normal execution. However, in some cases this cost may arguably offset the cost of the code that it is replacing.]]
+*  ["['Exception handling is often agreed to be a superior solution for handling a large range of function return values. However,
+   avoiding the creation of functions that need large ranges of return values is superior to using exception handling to handle such values.]]
+*  ["['Using exception handling correctly can be difficult in the case of complex software.]]
+*  ["['The execution of throw and catch can be significantly expensive with some implementations.]]
+*  ["['Exception handling violates the don't-pay-for-what-you-don't-use design of C++, as it incurs overhead in any non-leaf function that
+   has destructible stack objects regardless of whether they use exception handling.]]
+*  ["['The approach that game software usually takes is to avoid the need for exception handling where possible; avoid the possibility
+   of circumstances that may lead to exceptions. For example, verify up front that there is enough memory for a subsystem to do its job
+   instead of trying to deal with the problem via exception handling or any other means after it occurs.]]
+*  ["['However, some game libraries may nevertheless benefit from the use of exception handling. It's best, however,
+   if such libraries keep the exception handling internal lest they force their usage of exception handling on the rest of the application.]]
+
+In order to support environments without C++ exception support or environments with special error handling needs,
+[*Boost.Container] changes error signalling behaviour when `BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS` or `BOOST_NO_EXCEPTIONS`
+is defined. The former shall be defined by the user and the latter can be either defined by the user or implicitly defined by [*Boost.Confg]
+when the compiler has been invoked with the appropriate flag (like `-fno-exceptions` in GCC).
+
+When dealing with user-defined classes, (e.g. when constructing user-defined classes):
+
+*  If `BOOST_NO_EXCEPTIONS` is defined, the library avoids using `try`/`catch`/`throw` statements. The class writer must handle and
+   propagate error situations internally as no error will be propagated through [*Boost.Container].
+*  If `BOOST_NO_EXCEPTIONS` is *not* defined, the library propagates exceptions offering the exception guarantees detailed in the documentation.
+
+When the library needs to throw an exception (such as `out_of_range` when an incorrect index is used in `vector::at`)], the library calls
+a throw callback declared in ``:
+
+*  If `BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS` is defined, then the programmer must provide its own definition for all
+   `throw_xxx` functions. Those functions can't return, they must throw an exception or call `std::exit` or `std::abort`.
+*  Else if `BOOST_NO_EXCEPTIONS` is defined, a `BOOST_ASSERT_MSG` assertion is triggered
+   (see [@http://www.boost.org/libs/utility/assert.html Boost.Assert] for more information). 
+   If this assertion returns, then `std::abort` is called.
+*  Else, an appropriate standard library exception is thrown (like `std::out_of_range`).
+
+[endsect]
+
 [section:non_standard_containers Non-standard containers]
 
 [section:stable_vector ['stable_vector]]
@@ -569,6 +612,8 @@ use [*Boost.Container]? There are several reasons for that:
    usually implies a no-throw guarantee (if predicate's or allocator's default constructor doesn't throw).
    * Small string optimization for [classref boost::container::basic_string basic_string].
 * New extensions beyond the standard based on user feedback to improve code performance.
+* You need a portable implementation that works when compiling without exceptions support or 
+  you need to customize the error handling when a container needs to signall an exceptional error.
 
 [endsect]
 
@@ -614,6 +659,12 @@ use [*Boost.Container]? There are several reasons for that:
 
 [section:release_notes Release Notes]
 
+[section:release_notes_boost_1_54_00 Boost 1.54 Release]
+
+*  Support for `BOOST_NO_EXCEPTIONS` [@https://svn.boost.org/trac/boost/ticket/7227 #7227].
+
+[endsect]
+
 [section:release_notes_boost_1_53_00 Boost 1.53 Release]
 
 *  Fixed bug [@https://svn.boost.org/trac/boost/ticket/7650 #7650].
diff --git a/include/boost/container/deque.hpp b/include/boost/container/deque.hpp
index 32fa480..0962f0b 100644
--- a/include/boost/container/deque.hpp
+++ b/include/boost/container/deque.hpp
@@ -46,12 +46,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -1575,7 +1575,7 @@ class deque : protected deque_base
    }
 
    void priv_range_check(size_type n) const
-      {  if (n >= this->size())  BOOST_RETHROW std::out_of_range("deque");   }
+      {  if (n >= this->size())  throw_out_of_range("deque::at out of range");   }
 
    template 
    iterator priv_insert(const_iterator position, BOOST_FWD_REF(U) x)
diff --git a/include/boost/container/detail/adaptive_node_pool_impl.hpp b/include/boost/container/detail/adaptive_node_pool_impl.hpp
index 42bdf43..8b673cf 100644
--- a/include/boost/container/detail/adaptive_node_pool_impl.hpp
+++ b/include/boost/container/detail/adaptive_node_pool_impl.hpp
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -780,7 +781,7 @@ class private_adaptive_node_pool_impl
             //In case of error, free memory deallocating all nodes (the new ones allocated
             //in this function plus previously stored nodes in chain).
             this->deallocate_nodes(chain);
-            throw std::bad_alloc();
+            throw_bad_alloc();
          }
          block_info_t &c_info = *new(mem_address)block_info_t();
          mem_address += HdrSize;
@@ -812,7 +813,7 @@ class private_adaptive_node_pool_impl
             //In case of error, free memory deallocating all nodes (the new ones allocated
             //in this function plus previously stored nodes in chain).
             this->deallocate_nodes(chain);
-            throw std::bad_alloc();
+            throw_bad_alloc();
          }
          //First initialize header information on the last subblock
          char *hdr_addr = mem_address + m_real_block_alignment*(m_num_subblocks-1);
diff --git a/include/boost/container/detail/allocator_version_traits.hpp b/include/boost/container/detail/allocator_version_traits.hpp
index d69e61b..4cef676 100644
--- a/include/boost/container/detail/allocator_version_traits.hpp
+++ b/include/boost/container/detail/allocator_version_traits.hpp
@@ -18,13 +18,13 @@
 #include 
 #include 
 #include              //allocator_traits
+#include 
 #include  //multiallocation_chain
 #include           //version_type
 #include        //allocation_type
 #include                    //integral_constant
 #include                //pointer_traits
 #include                                           //pair
-#include                                         //runtime_error
 #include            //BOOST_TRY
 
 namespace boost {
@@ -135,7 +135,7 @@ struct allocator_version_traits
       std::pair ret(pointer(), false);
       if(!(command & allocate_new)){
          if(!(command & nothrow_allocation)){
-            throw std::runtime_error("version 1 allocator without allocate_new flag");
+            throw_logic_error("version 1 allocator without allocate_new flag");
          }
       }
       else{
diff --git a/include/boost/container/flat_map.hpp b/include/boost/container/flat_map.hpp
index 2dd2210..8bb372f 100644
--- a/include/boost/container/flat_map.hpp
+++ b/include/boost/container/flat_map.hpp
@@ -22,13 +22,14 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 
 namespace boost {
 namespace container {
@@ -478,7 +479,7 @@ class flat_map
    {
       iterator i = this->find(k);
       if(i == this->end()){
-         throw std::out_of_range("key not found");
+         throw_out_of_range("flat_map::at key not found");
       }
       return i->second;
    }
@@ -492,7 +493,7 @@ class flat_map
    {
       const_iterator i = this->find(k);
       if(i == this->end()){
-         throw std::out_of_range("key not found");
+         throw_out_of_range("flat_map::at key not found");
       }
       return i->second;
    }
diff --git a/include/boost/container/list.hpp b/include/boost/container/list.hpp
index 571e63a..79f4a6b 100644
--- a/include/boost/container/list.hpp
+++ b/include/boost/container/list.hpp
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -36,13 +37,11 @@
 #include 
 #endif
 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 
 namespace boost {
 namespace container {
diff --git a/include/boost/container/map.hpp b/include/boost/container/map.hpp
index d4ab423..b1faf49 100644
--- a/include/boost/container/map.hpp
+++ b/include/boost/container/map.hpp
@@ -22,7 +22,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -30,10 +29,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 namespace boost {
 namespace container {
@@ -423,7 +424,7 @@ class map
    {
       iterator i = this->find(k);
       if(i == this->end()){
-         throw std::out_of_range("key not found");
+         throw_out_of_range("map::at key not found");
       }
       return i->second;
    }
@@ -435,7 +436,7 @@ class map
    {
       const_iterator i = this->find(k);
       if(i == this->end()){
-         throw std::out_of_range("key not found");
+         throw_out_of_range("map::at key not found");
       }
       return i->second;
    }
diff --git a/include/boost/container/slist.hpp b/include/boost/container/slist.hpp
index 84cccda..39bf0c2 100644
--- a/include/boost/container/slist.hpp
+++ b/include/boost/container/slist.hpp
@@ -19,6 +19,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -37,7 +38,6 @@
 #include 
 #endif
 
-#include 
 #include 
 #include 
 #include 
diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp
index 539b2da..759124c 100644
--- a/include/boost/container/stable_vector.hpp
+++ b/include/boost/container/stable_vector.hpp
@@ -1,4 +1,4 @@
-
+//////////////////////////////////////////////////////////////////////////////
 //
 // (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost
 // Software License, Version 1.0. (See accompanying file
@@ -29,18 +29,21 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include  //max
-#include 
+
 #include 
 #include  //placement new
 
@@ -1010,8 +1013,9 @@ class stable_vector
    void reserve(size_type n)
    {
       STABLE_VECTOR_CHECK_INVARIANT;
-      if(n > this->max_size())
-         throw std::bad_alloc();
+      if(n > this->max_size()){
+         throw_length_error("stable_vector::reserve max_size() exceeded");
+      }
 
       size_type sz         = this->size();  
       size_type old_capacity = this->capacity();
@@ -1143,8 +1147,9 @@ class stable_vector
    //! Complexity: Constant.
    reference at(size_type n)
    {
-      if(n>=this->size())
-         throw std::out_of_range("invalid subscript at stable_vector::at");
+      if(n >= this->size()){
+         throw_out_of_range("vector::at invalid subscript");
+      }
       return operator[](n);
    }
 
@@ -1158,8 +1163,9 @@ class stable_vector
    //! Complexity: Constant.
    const_reference at(size_type n)const
    {
-      if(n>=this->size())
-         throw std::out_of_range("invalid subscript at stable_vector::at");
+      if(n >= this->size()){
+         throw_out_of_range("vector::at invalid subscript");
+      }
       return operator[](n);
    }
 
diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp
index 40b2397..74dd051 100644
--- a/include/boost/container/string.hpp
+++ b/include/boost/container/string.hpp
@@ -38,6 +38,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -54,8 +55,7 @@
 
 #include 
 #include 
-#include      
-#include  
+#include 
 #include 
 #include 
 #include 
@@ -335,8 +335,9 @@ class basic_string_base
             this->priv_storage(new_cap);
          }
       }
-      else
-         throw_length_error();
+      else{
+         throw_length_error("basic_string::allocate_initial_block max_size() exceeded");
+      }
    }
 
    void deallocate_block()
@@ -345,13 +346,6 @@ class basic_string_base
    size_type max_size() const
    {  return allocator_traits_type::max_size(this->alloc()) - 1; }
 
-   // Helper functions for exception handling.
-   void throw_length_error() const
-   {  throw(std::length_error("basic_string"));  }
-
-   void throw_out_of_range() const
-   {  throw(std::out_of_range("basic_string"));  }
-
    protected:
    size_type priv_capacity() const
    { return this->priv_storage() - 1; }
@@ -663,7 +657,7 @@ class basic_string
    {
       this->priv_terminate_string();
       if (pos > s.size())
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::basic_string out of range position");
       else
          this->assign
             (s.begin() + pos, s.begin() + pos + container_detail::min_value(n, s.size() - pos));
@@ -991,7 +985,7 @@ class basic_string
    void reserve(size_type res_arg)
    {
       if (res_arg > this->max_size()){
-         this->throw_length_error();
+         throw_length_error("basic_string::reserve max_size() exceeded");
       }
 
       if (this->capacity() < res_arg){
@@ -1083,7 +1077,7 @@ class basic_string
    reference at(size_type n)
    {
       if (n >= this->size())
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::at invalid subscript");
       return *(this->priv_addr() + n);
    }
 
@@ -1097,7 +1091,7 @@ class basic_string
    //! Complexity: Constant.
    const_reference at(size_type n) const {
       if (n >= this->size())
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::at invalid subscript");
       return *(this->priv_addr() + n);
    }
 
@@ -1142,7 +1136,7 @@ class basic_string
    basic_string& append(const basic_string& s, size_type pos, size_type n)
    {
       if (pos > s.size())
-      this->throw_out_of_range();
+         throw_out_of_range("basic_string::append out of range position");
       return this->append(s.begin() + pos,
                           s.begin() + pos + container_detail::min_value(n, s.size() - pos));
    }
@@ -1226,7 +1220,7 @@ class basic_string
    basic_string& assign(const basic_string& s, size_type pos, size_type n)
    {
       if (pos > s.size())
-      this->throw_out_of_range();
+         throw_out_of_range("basic_string::assign out of range position");
       return this->assign(s.begin() + pos,
                           s.begin() + pos + container_detail::min_value(n, s.size() - pos));
    }
@@ -1296,9 +1290,9 @@ class basic_string
    {
       const size_type sz = this->size();
       if (pos > sz)
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::insert out of range position");
       if (sz > this->max_size() - s.size())
-         this->throw_length_error();
+         throw_length_error("basic_string::insert max_size() exceeded");
       this->insert(this->priv_addr() + pos, s.begin(), s.end());
       return *this;
    }
@@ -1316,10 +1310,10 @@ class basic_string
       const size_type sz = this->size();
       const size_type str_size = s.size();
       if (pos1 > sz || pos2 > str_size)
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::insert out of range position");
       size_type len = container_detail::min_value(n, str_size - pos2);
       if (sz > this->max_size() - len)
-         this->throw_length_error();
+         throw_length_error("basic_string::insert max_size() exceeded");
       const CharT *beg_ptr = container_detail::to_raw_pointer(s.begin()) + pos2;
       const CharT *end_ptr = beg_ptr + len;
       this->insert(this->priv_addr() + pos1, beg_ptr, end_ptr);
@@ -1340,9 +1334,9 @@ class basic_string
    basic_string& insert(size_type pos, const CharT* s, size_type n)
    {
       if (pos > this->size())
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::insert out of range position");
       if (this->size() > this->max_size() - n)
-         this->throw_length_error();
+         throw_length_error("basic_string::insert max_size() exceeded");
       this->insert(this->priv_addr() + pos, s, s + n);
       return *this;
    }
@@ -1358,10 +1352,10 @@ class basic_string
    basic_string& insert(size_type pos, const CharT* s)
    {
       if (pos > this->size())
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::insert out of range position");
       size_type len = Traits::length(s);
       if (this->size() > this->max_size() - len)
-         this->throw_length_error();
+         throw_length_error("basic_string::insert max_size() exceeded");
       this->insert(this->priv_addr() + pos, s, s + len);
       return *this;
    }
@@ -1375,9 +1369,9 @@ class basic_string
    basic_string& insert(size_type pos, size_type n, CharT c)
    {
       if (pos > this->size())
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::insert out of range position");
       if (this->size() > this->max_size() - n)
-         this->throw_length_error();
+         throw_length_error("basic_string::insert max_size() exceeded");
       this->insert(const_iterator(this->priv_addr() + pos), n, c);
       return *this;
    }
@@ -1551,7 +1545,7 @@ class basic_string
    basic_string& erase(size_type pos = 0, size_type n = npos)
    {
       if (pos > this->size())
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::erase out of range position");
       const pointer addr = this->priv_addr();
       erase(addr + pos, addr + pos + container_detail::min_value(n, this->size() - pos));
       return *this;
@@ -1633,10 +1627,10 @@ class basic_string
    basic_string& replace(size_type pos1, size_type n1, const basic_string& str)
    {
       if (pos1 > this->size())
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::replace out of range position");
       const size_type len = container_detail::min_value(n1, this->size() - pos1);
       if (this->size() - len >= this->max_size() - str.size())
-         this->throw_length_error();
+         throw_length_error("basic_string::replace max_size() exceeded");
       const pointer addr = this->priv_addr();
       return this->replace( const_iterator(addr + pos1)
                           , const_iterator(addr + pos1 + len)
@@ -1656,11 +1650,11 @@ class basic_string
                          const basic_string& str, size_type pos2, size_type n2)
    {
       if (pos1 > this->size() || pos2 > str.size())
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::replace out of range position");
       const size_type len1 = container_detail::min_value(n1, this->size() - pos1);
       const size_type len2 = container_detail::min_value(n2, str.size() - pos2);
       if (this->size() - len1 >= this->max_size() - len2)
-         this->throw_length_error();
+         throw_length_error("basic_string::replace max_size() exceeded");
       const pointer addr    = this->priv_addr();
       const pointer straddr = str.priv_addr();
       return this->replace(addr + pos1, addr + pos1 + len1,
@@ -1684,10 +1678,10 @@ class basic_string
    basic_string& replace(size_type pos1, size_type n1, const CharT* s, size_type n2)
    {
       if (pos1 > this->size())
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::replace out of range position");
       const size_type len = container_detail::min_value(n1, this->size() - pos1);
       if (n2 > this->max_size() || size() - len >= this->max_size() - n2)
-         this->throw_length_error();
+         throw_length_error("basic_string::replace max_size() exceeded");
       const pointer addr    = this->priv_addr();
       return this->replace(addr + pos1, addr + pos1 + len, s, s + n2);
    }
@@ -1709,11 +1703,11 @@ class basic_string
    basic_string& replace(size_type pos, size_type n1, const CharT* s)
    {
       if (pos > this->size())
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::replace out of range position");
       const size_type len = container_detail::min_value(n1, this->size() - pos);
       const size_type n2 = Traits::length(s);
       if (n2 > this->max_size() || this->size() - len >= this->max_size() - n2)
-         this->throw_length_error();
+         throw_length_error("basic_string::replace max_size() exceeded");
       const pointer addr    = this->priv_addr();
       return this->replace(addr + pos, addr + pos + len,
                      s, s + Traits::length(s));
@@ -1730,10 +1724,10 @@ class basic_string
    basic_string& replace(size_type pos1, size_type n1, size_type n2, CharT c)
    {
       if (pos1 > this->size())
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::replace out of range position");
       const size_type len = container_detail::min_value(n1, this->size() - pos1);
       if (n2 > this->max_size() || this->size() - len >= this->max_size() - n2)
-         this->throw_length_error();
+         throw_length_error("basic_string::replace max_size() exceeded");
       const pointer addr    = this->priv_addr();
       return this->replace(addr + pos1, addr + pos1 + len, n2, c);
    }
@@ -1858,7 +1852,7 @@ class basic_string
    size_type copy(CharT* s, size_type n, size_type pos = 0) const
    {
       if (pos > this->size())
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::copy out of range position");
       const size_type len = container_detail::min_value(n, this->size() - pos);
       Traits::copy(s, container_detail::to_raw_pointer(this->priv_addr() + pos), len);
       return len;
@@ -2230,7 +2224,7 @@ class basic_string
    basic_string substr(size_type pos = 0, size_type n = npos) const
    {
       if (pos > this->size())
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::substr out of range position");
       const pointer addr = this->priv_addr();
       return basic_string(addr + pos,
                           addr + pos + container_detail::min_value(n, size() - pos), this->alloc());
@@ -2263,7 +2257,7 @@ class basic_string
    int compare(size_type pos1, size_type n1, const basic_string& str) const
    {
       if (pos1 > this->size())
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::compare out of range position");
       const pointer addr    = this->priv_addr();
       const pointer str_addr = str.priv_addr();
       return s_compare(addr + pos1,
@@ -2282,7 +2276,7 @@ class basic_string
    int compare(size_type pos1, size_type n1, const basic_string& str, size_type pos2, size_type n2) const
    {
       if (pos1 > this->size() || pos2 > str.size())
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::compare out of range position");
       const pointer addr     = this->priv_addr();
       const pointer str_addr = str.priv_addr();
       return s_compare(addr + pos1,
@@ -2309,7 +2303,7 @@ class basic_string
    int compare(size_type pos1, size_type n1, const CharT* s, size_type n2) const
    {
       if (pos1 > this->size())
-         this->throw_out_of_range();
+         throw_out_of_range("basic_string::compare out of range position");
       const pointer addr = this->priv_addr();
       return s_compare( addr + pos1,
                         addr + pos1 + container_detail::min_value(n1, this->size() - pos1),
diff --git a/include/boost/container/throw_exception.hpp b/include/boost/container/throw_exception.hpp
new file mode 100644
index 0000000..e22d104
--- /dev/null
+++ b/include/boost/container/throw_exception.hpp
@@ -0,0 +1,110 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2012-2013. 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)
+//
+// See http://www.boost.org/libs/container for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_CONTAINER_THROW_EXCEPTION_HPP
+#define BOOST_CONTAINER_THROW_EXCEPTION_HPP
+
+#include 
+#include 
+
+#if (defined _MSC_VER) && (_MSC_VER >= 1200)
+#  pragma once
+#endif
+
+#ifndef BOOST_NO_EXCEPTIONS
+   #include  //for std exception types
+   #include        //for std::bad_alloc
+#else
+   #include 
+   #include    //for std::abort
+#endif
+
+namespace boost {
+namespace container {
+
+#if defined(BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS)
+   //The user must provide definitions for the following functions
+
+   void throw_bad_alloc();
+
+   void throw_out_of_range(const char* str);
+
+   void throw_length_error(const char* str);
+
+   void throw_logic_error(const char* str);
+
+   void throw_runtime_error(const char* str);
+
+#elif defined(BOOST_NO_EXCEPTIONS)
+
+   inline void throw_bad_alloc()
+   {
+      BOOST_ASSERT(!"boost::container bad_alloc thrown");
+      std::abort();
+   }
+
+   inline void throw_out_of_range(const char* str)
+   {
+      BOOST_ASSERT_MSG(!"boost::container out_of_range thrown", str);
+      std::abort();
+   }
+
+   inline void throw_length_error(const char* str)
+   {
+      BOOST_ASSERT_MSG(!"boost::container length_error thrown", str);
+      std::abort();
+   }
+
+   inline void throw_logic_error(const char* str)
+   {
+      BOOST_ASSERT_MSG(!"boost::container logic_error thrown", str);
+      std::abort();
+   }
+
+   inline void throw_runtime_error(const char* str)
+   {
+      BOOST_ASSERT_MSG(!"boost::container runtime_error thrown", str);
+      std::abort();
+   }
+
+#else //defined(BOOST_NO_EXCEPTIONS)
+
+   inline void throw_bad_alloc()
+   {
+      throw std::bad_alloc();
+   }
+
+   inline void throw_out_of_range(const char* str)
+   {
+      throw std::out_of_range(str);
+   }
+
+   inline void throw_length_error(const char* str)
+   {
+      throw std::length_error(str);
+   }
+
+   inline void throw_logic_error(const char* str)
+   {
+      throw std::logic_error(str);
+   }
+
+   inline void throw_runtime_error(const char* str)
+   {
+      throw std::runtime_error(str);
+   }
+
+#endif
+
+}}  //namespace boost { namespace container {
+
+#include 
+
+#endif //#ifndef BOOST_CONTAINER_THROW_EXCEPTION_HPP
diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp
index 3c4c9c5..2712cac 100644
--- a/include/boost/container/vector.hpp
+++ b/include/boost/container/vector.hpp
@@ -22,7 +22,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -41,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2038,8 +2038,9 @@ class vector : private container_detail::vector_alloc_holder
    void priv_check_range(size_type n) const
    {
       //If n is out of range, throw an out_of_range exception
-      if (n >= this->size())
-         throw std::out_of_range("vector::at");
+      if (n >= this->size()){
+         throw_out_of_range("vector::at out of range");
+      }
    }
 
    #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
diff --git a/proj/vc7ide/container.sln b/proj/vc7ide/container.sln
index 68beb93..584f8ab 100644
--- a/proj/vc7ide/container.sln
+++ b/proj/vc7ide/container.sln
@@ -55,6 +55,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hash_table_test", "hash_tab
 	ProjectSection(ProjectDependencies) = postProject
 	EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "throw_exception_test", "throw_exception_test.vcproj", "{5A8D91E0-FA57-284F-84FE-D3A6BA792002}"
+	ProjectSection(ProjectDependencies) = postProject
+	EndProjectSection
+EndProject
 Global
 	GlobalSection(SolutionConfiguration) = preSolution
 		Debug = Debug
@@ -119,6 +123,10 @@ Global
 		{58CCE183-6092-48FE-A4F7-BA0D3A792606}.Debug.Build.0 = Debug|Win32
 		{58CCE183-6092-48FE-A4F7-BA0D3A792606}.Release.ActiveCfg = Release|Win32
 		{58CCE183-6092-48FE-A4F7-BA0D3A792606}.Release.Build.0 = Release|Win32
+		{5A8D91E0-FA57-284F-84FE-D3A6BA792002}.Debug.ActiveCfg = Debug|Win32
+		{5A8D91E0-FA57-284F-84FE-D3A6BA792002}.Debug.Build.0 = Debug|Win32
+		{5A8D91E0-FA57-284F-84FE-D3A6BA792002}.Release.ActiveCfg = Release|Win32
+		{5A8D91E0-FA57-284F-84FE-D3A6BA792002}.Release.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 	EndGlobalSection
diff --git a/proj/vc7ide/container.vcproj b/proj/vc7ide/container.vcproj
index 5c89b16..5deba8d 100644
--- a/proj/vc7ide/container.vcproj
+++ b/proj/vc7ide/container.vcproj
@@ -185,6 +185,9 @@
 			
 			
+			
+			
 			
 			
@@ -221,6 +224,9 @@
 			
 			
+			
+			
 			
 			
@@ -260,6 +266,9 @@
 				
 				
+				
+				
 				
 				
diff --git a/proj/vc7ide/throw_exception_test.vcproj b/proj/vc7ide/throw_exception_test.vcproj
new file mode 100644
index 0000000..12b7bb8
--- /dev/null
+++ b/proj/vc7ide/throw_exception_test.vcproj
@@ -0,0 +1,134 @@
+
+
+	
+		
+	
+	
+		
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+		
+		
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+		
+	
+	
+	
+	
+		
+			
+			
+		
+	
+	
+	
+
diff --git a/proj/vc7ide/vector_test.vcproj b/proj/vc7ide/vector_test.vcproj
index 270f5cf..1076c97 100644
--- a/proj/vc7ide/vector_test.vcproj
+++ b/proj/vc7ide/vector_test.vcproj
@@ -22,6 +22,7 @@
 				AdditionalIncludeDirectories="../../../.."
 				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
 				MinimalRebuild="TRUE"
+				ExceptionHandling="TRUE"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
 				TreatWChar_tAsBuiltInType="TRUE"
diff --git a/test/deque_test.cpp b/test/deque_test.cpp
index 23a8e58..0ca9fef 100644
--- a/test/deque_test.cpp
+++ b/test/deque_test.cpp
@@ -29,6 +29,7 @@
 #include "emplace_test.hpp"
 #include "propagate_allocator_test.hpp"
 #include "vector_test.hpp"
+#include 
 
 using namespace boost::container;
 
@@ -143,7 +144,7 @@ bool do_test()
    typedef deque  MyCntDeque;
    typedef std::deque MyStdDeque;
    const int max = 100;
-   try{
+   BOOST_TRY{
       //Shared memory allocator must be always be initialized
       //since it has no default constructor
       MyCntDeque *cntdeque = new MyCntDeque;
@@ -268,10 +269,13 @@ bool do_test()
       delete cntdeque;
       delete stddeque;
    }
-   catch(std::exception &ex){
+   BOOST_CATCH(std::exception &ex){
+      #ifndef BOOST_NO_EXCEPTIONS
       std::cout << ex.what() << std::endl;
+      #endif
       return false;
    }
+   BOOST_CATCH_END
   
    std::cout << std::endl << "Test OK!" << std::endl;
    return true;
diff --git a/test/dummy_test_allocator.hpp b/test/dummy_test_allocator.hpp
index ef95836..993cccf 100644
--- a/test/dummy_test_allocator.hpp
+++ b/test/dummy_test_allocator.hpp
@@ -26,11 +26,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
 //!\file
diff --git a/test/expand_bwd_test_allocator.hpp b/test/expand_bwd_test_allocator.hpp
index a39aaf1..882552a 100644
--- a/test/expand_bwd_test_allocator.hpp
+++ b/test/expand_bwd_test_allocator.hpp
@@ -19,6 +19,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -26,7 +27,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 //!\file
@@ -146,8 +146,8 @@ class expand_bwd_test_allocator
          return std::pair(mp_buffer, true);
       }
       else{
-         assert(0);
-         throw std::bad_alloc();
+         throw_bad_alloc();
+         return std::pair(mp_buffer, true);
       }
    }
 
diff --git a/test/expand_bwd_test_template.hpp b/test/expand_bwd_test_template.hpp
index 0f06e23..c1f26e1 100644
--- a/test/expand_bwd_test_template.hpp
+++ b/test/expand_bwd_test_template.hpp
@@ -135,7 +135,7 @@ bool test_insert_with_expand_bwd()
    for(int iteration = 0; iteration < Iterations; ++iteration)
    {
       value_type *memory = new value_type[MemorySize];
-      try {
+      BOOST_TRY {
          std::vector initial_data;
          initial_data.resize(InitialSize[iteration]);
          for(int i = 0; i < InitialSize[iteration]; ++i){
@@ -165,10 +165,11 @@ bool test_insert_with_expand_bwd()
             return false;
          }
       }
-      catch(...){
+      BOOST_CATCH(...){
          delete [](const_cast(memory));
-         throw;
+         BOOST_RETHROW;
       }
+      BOOST_CATCH_END
       delete [](const_cast(memory));
    }
 
@@ -193,7 +194,7 @@ bool test_assign_with_expand_bwd()
    for(int iteration = 0; iteration  initial_data;
          initial_data.resize(InitialSize[iteration]);
@@ -227,10 +228,11 @@ bool test_assign_with_expand_bwd()
             return false;
          }
       }
-      catch(...){
+      BOOST_CATCH(...){
          delete [](const_cast::type*>(memory));
-         throw;
+         BOOST_RETHROW;
       }
+      BOOST_CATCH_END
       delete [](const_cast::type*>(memory));
    }
 
diff --git a/test/heap_allocator_v1.hpp b/test/heap_allocator_v1.hpp
index 56fc1a2..b7724d2 100644
--- a/test/heap_allocator_v1.hpp
+++ b/test/heap_allocator_v1.hpp
@@ -28,7 +28,6 @@
 #include 
 #include 
 #include 
-#include 
 
 //!\file
 //!Describes an heap_allocator_v1 that allocates portions of fixed size
diff --git a/test/list_test.hpp b/test/list_test.hpp
index e1f0ec6..0ce580b 100644
--- a/test/list_test.hpp
+++ b/test/list_test.hpp
@@ -148,7 +148,7 @@ int list_test (bool copied_allocators_equal = true)
    const int max = 100;
    typedef list_push_data_function push_data_t;
 
-   try{
+   BOOST_TRY{
       MyBoostList *boostlist = new MyBoostList;
       MyStdList *stdlist = new MyStdList;
 
@@ -338,9 +338,10 @@ int list_test (bool copied_allocators_equal = true)
       delete boostlist;
       delete stdlist;
    }
-   catch(...){
-      throw;
+   BOOST_CATCH(...){
+      BOOST_RETHROW;
    }
+   BOOST_CATCH_END
    return 0;
 }
 
diff --git a/test/map_test.hpp b/test/map_test.hpp
index 96ea05d..2357f57 100644
--- a/test/map_test.hpp
+++ b/test/map_test.hpp
@@ -44,7 +44,7 @@ int map_test ()
    typedef typename MyStdMap::value_type  StdPairType;
    const int max = 100;
 
-   try{
+   BOOST_TRY{
       MyBoostMap *boostmap = new MyBoostMap;
       MyStdMap *stdmap = new MyStdMap;
       MyBoostMultiMap *boostmultimap = new MyBoostMultiMap;
@@ -467,9 +467,10 @@ int map_test ()
       delete boostmultimap;
       delete stdmultimap;
    }
-   catch(...){
-      throw;
+   BOOST_CATCH(...){
+      BOOST_RETHROW;
    }
+   BOOST_CATCH_END
    return 0;
 }
 
@@ -485,7 +486,7 @@ int map_test_copyable ()
 
    const int max = 100;
 
-   try{
+   BOOST_TRY{
    MyBoostMap *boostmap = new MyBoostMap;
    MyStdMap *stdmap = new MyStdMap;
    MyBoostMultiMap *boostmultimap = new MyBoostMultiMap;
@@ -537,9 +538,10 @@ int map_test_copyable ()
          delete stdmultimap;
       }
    }
-   catch(...){
-      throw;
+   BOOST_CATCH(...){
+      BOOST_RETHROW;
    }
+   BOOST_CATCH_END
    return 0;
 }
 
diff --git a/test/set_test.hpp b/test/set_test.hpp
index 91397c9..7a2b844 100644
--- a/test/set_test.hpp
+++ b/test/set_test.hpp
@@ -443,7 +443,7 @@ int set_test_copyable ()
    typedef typename MyBoostSet::value_type IntType;
    const int max = 100;
 
-   try{
+   BOOST_TRY{
       //Shared memory allocator must be always be initialized
       //since it has no default constructor
       MyBoostSet *boostset = new MyBoostSet;
@@ -492,9 +492,10 @@ int set_test_copyable ()
       delete boostset;
       delete boostmultiset;
    }
-   catch(...){
-      throw;
+   BOOST_CATCH(...){
+      BOOST_RETHROW;
    }
+   BOOST_CATCH_END
    return 0;
 }
 
diff --git a/test/throw_exception_test.cpp b/test/throw_exception_test.cpp
new file mode 100644
index 0000000..2572dfe
--- /dev/null
+++ b/test/throw_exception_test.cpp
@@ -0,0 +1,62 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2012-2013. 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)
+//
+// See http://www.boost.org/libs/container for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+#define BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS
+
+#include 
+
+#include 
+#include 
+
+using namespace boost::container;
+
+static bool bad_alloc_called     = false;
+static bool out_of_range_called  = false;
+static bool length_error_called  = false;
+static bool logic_error_called   = false;
+static bool runtime_error_called = false;
+
+//User defined throw implementations
+namespace boost {
+namespace container {
+
+   void throw_bad_alloc()
+   {  bad_alloc_called = true;   }
+
+   void throw_out_of_range(const char* str)
+   {  (void)str; out_of_range_called = true;   }
+
+   void throw_length_error(const char* str)
+   {  (void)str; length_error_called = true;   }
+
+   void throw_logic_error(const char* str)
+   {  (void)str; logic_error_called = true; }
+
+   void throw_runtime_error(const char* str)
+   {  (void)str; runtime_error_called = true;  }
+
+}} //boost::container
+
+int main()
+{
+   //Check user-defined throw callbacks are called
+   throw_bad_alloc();
+   BOOST_TEST(bad_alloc_called == true);
+   throw_out_of_range("dummy");
+   BOOST_TEST(out_of_range_called == true);
+   throw_length_error("dummy");
+   BOOST_TEST(length_error_called == true);
+   throw_logic_error("dummy");
+   BOOST_TEST(logic_error_called == true);
+   throw_runtime_error("dummy");
+   BOOST_TEST(runtime_error_called == true);
+   return ::boost::report_errors();
+}
+
+#include 
diff --git a/test/vector_test.hpp b/test/vector_test.hpp
index 503ec59..318e339 100644
--- a/test/vector_test.hpp
+++ b/test/vector_test.hpp
@@ -30,6 +30,7 @@
 #include "input_from_forward_iterator.hpp"
 #include 
 #include 
+#include 
 
 namespace boost{
 namespace container {
@@ -91,7 +92,7 @@ int vector_test()
    const int max = 100;
 
    {
-      try{
+      BOOST_TRY{
          MyBoostVector *boostvector = new MyBoostVector;
          MyStdVector *stdvector = new MyStdVector;
          boostvector->resize(100);
@@ -292,10 +293,13 @@ int vector_test()
          delete stdvector;
          delete boostvector;
       }
-      catch(std::exception &ex){
+      BOOST_CATCH(std::exception &ex){
+         #ifndef BOOST_NO_EXCEPTIONS
          std::cout << ex.what() << std::endl;
+         #endif
          return 1;
       }
+      BOOST_CATCH_END
    }
    std::cout << std::endl << "Test OK!" << std::endl;
    return 0;

From 92183ce9aac950954d914048df26ca2a82167a1c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Thu, 10 Jan 2013 20:03:39 +0000
Subject: [PATCH 67/93] Removed unused variable warnings

[SVN r82433]
---
 include/boost/container/detail/node_pool_impl.hpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/boost/container/detail/node_pool_impl.hpp b/include/boost/container/detail/node_pool_impl.hpp
index 53e35ac..2103898 100644
--- a/include/boost/container/detail/node_pool_impl.hpp
+++ b/include/boost/container/detail/node_pool_impl.hpp
@@ -208,8 +208,6 @@ class private_node_pool_impl
       BOOST_ASSERT(m_allocated==0);
       size_type blocksize = get_rounded_size
          (m_real_node_size*m_nodes_per_block, (size_type)alignment_of::value);
-      typename blockslist_t::iterator
-         it(m_blocklist.begin()), itend(m_blocklist.end()), aux;
 
       //We iterate though the NodeBlock list to free the memory
       while(!m_blocklist.empty()){

From c72b23df5474ec1b29bdd63c3e98cfbc432c0a46 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Mon, 11 Feb 2013 09:47:06 +0000
Subject: [PATCH 68/93] Fixes #7921

[SVN r82812]
---
 include/boost/container/slist.hpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/boost/container/slist.hpp b/include/boost/container/slist.hpp
index 39bf0c2..a9a4f67 100644
--- a/include/boost/container/slist.hpp
+++ b/include/boost/container/slist.hpp
@@ -169,7 +169,7 @@ class slist_iterator
    {  return  this->m_it->m_data;  }
 
    pointer   operator->() const
-   { return ::boost::intrusive::pointer_traits::to_pointer(this->m_it->m_data); }
+   { return ::boost::intrusive::pointer_traits::pointer_to(this->m_it->m_data); }
 
    //Increment / Decrement
    slist_iterator& operator++() 

From 8bfd3f84b1e9c8673cca9b368faf469d8514da25 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Mon, 11 Feb 2013 09:48:24 +0000
Subject: [PATCH 69/93] Updated change log with bugfix 7921

[SVN r82813]
---
 doc/container.qbk | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/doc/container.qbk b/doc/container.qbk
index 5b90af6..55483bb 100644
--- a/doc/container.qbk
+++ b/doc/container.qbk
@@ -662,6 +662,8 @@ use [*Boost.Container]? There are several reasons for that:
 [section:release_notes_boost_1_54_00 Boost 1.54 Release]
 
 *  Support for `BOOST_NO_EXCEPTIONS` [@https://svn.boost.org/trac/boost/ticket/7227 #7227].
+*  Fixed bugs [@https://svn.boost.org/trac/boost/ticket/7921 #7921],
+              [@https://svn.boost.org/trac/boost/ticket/7969 #7969].
 
 [endsect]
 

From c0cb9ae2c7ace2f08d89f56fb607020d5e63b6ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Mon, 11 Feb 2013 11:31:02 +0000
Subject: [PATCH 70/93] Cleanup unnecessary variables in erase(const_iterator)

[SVN r82814]
---
 include/boost/container/vector.hpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp
index 2712cac..26a2dab 100644
--- a/include/boost/container/vector.hpp
+++ b/include/boost/container/vector.hpp
@@ -1261,10 +1261,9 @@ class vector : private container_detail::vector_alloc_holder
    {
       T *const pos = container_detail::to_raw_pointer(position.get_ptr());
       T *const beg = container_detail::to_raw_pointer(this->members_.m_start);
-      ::boost::move(pos + 1, beg + this->members_.m_size, pos);
+      //Move elements forward and destroy last
+      base_t::destroy(::boost::move(pos + 1, beg + this->members_.m_size, pos));
       --this->members_.m_size;
-      //Destroy last element
-      base_t::destroy(container_detail::to_raw_pointer(this->members_.m_start) + this->members_.m_size);
       return iterator(position.get_ptr());
    }
 

From f56ec3886b6fbbc2e291df17c1845e63228a8173 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Mon, 11 Feb 2013 11:31:59 +0000
Subject: [PATCH 71/93] Use explicit instantiation for iterators defined
 outside the class in order to detect compilation errors.

[SVN r82815]
---
 test/flat_tree_test.cpp     |  3 +++
 test/list_test.cpp          |  9 +++++++++
 test/slist_test.cpp         | 10 ++++++++++
 test/stable_vector_test.cpp |  7 +++++++
 test/vector_test.cpp        |  7 +++++++
 5 files changed, 36 insertions(+)

diff --git a/test/flat_tree_test.cpp b/test/flat_tree_test.cpp
index c476b13..5854b59 100644
--- a/test/flat_tree_test.cpp
+++ b/test/flat_tree_test.cpp
@@ -116,6 +116,9 @@ template class flat_multiset
    , std::allocator
    >;
 
+//As flat container iterators are typedefs for vector::[const_]iterator,
+//no need to explicit instantiate them
+
 }} //boost::container
 
 
diff --git a/test/list_test.cpp b/test/list_test.cpp
index 2abcdec..fca017f 100644
--- a/test/list_test.cpp
+++ b/test/list_test.cpp
@@ -32,6 +32,15 @@ template class boost::container::list >;
 
+namespace container_detail {
+
+template class list_const_iterator
+    >::container_type::iterator >;
+template class list_iterator
+    >::container_type::iterator>;
+
+}
+
 }}
 
 typedef list MyList;
diff --git a/test/slist_test.cpp b/test/slist_test.cpp
index 46d6851..808d25c 100644
--- a/test/slist_test.cpp
+++ b/test/slist_test.cpp
@@ -30,6 +30,16 @@ template class boost::container::slist >;
+
+namespace container_detail {
+
+template class slist_const_iterator
+    >::container_type::iterator >;
+template class slist_iterator
+    >::container_type::iterator>;
+
+}
+
 }}
 
 typedef slist MyList;
diff --git a/test/stable_vector_test.cpp b/test/stable_vector_test.cpp
index c69efe4..748886e 100644
--- a/test/stable_vector_test.cpp
+++ b/test/stable_vector_test.cpp
@@ -39,6 +39,13 @@ template class stable_vector >;
 
+namespace stable_vector_detail{
+
+template class iterator< int, int &, int *>;
+template class iterator< int, const int &, const int *>;
+
+}
+
 }}
 
 class recursive_vector
diff --git a/test/vector_test.cpp b/test/vector_test.cpp
index a872315..9833b0d 100644
--- a/test/vector_test.cpp
+++ b/test/vector_test.cpp
@@ -39,6 +39,13 @@ template class boost::container::vector >;
 
+namespace container_detail {
+
+template class vector_const_iterator;
+template class vector_iterator;
+
+}
+
 }}
 
 int test_expand_bwd()

From d3a350d56f65be5605e7eda67077fc820fd75621 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Tue, 12 Feb 2013 21:26:21 +0000
Subject: [PATCH 72/93] vector performance optimization: simplified allocator
 holder, constructors rewritten to avoid unnecessary initializations.

[SVN r82846]
---
 .../container/detail/advanced_insert_int.hpp  |  26 +
 include/boost/container/detail/utilities.hpp  |  56 ++
 include/boost/container/vector.hpp            | 700 ++++++++++--------
 3 files changed, 463 insertions(+), 319 deletions(-)

diff --git a/include/boost/container/detail/advanced_insert_int.hpp b/include/boost/container/detail/advanced_insert_int.hpp
index 4c4fef6..3cecc3f 100644
--- a/include/boost/container/detail/advanced_insert_int.hpp
+++ b/include/boost/container/detail/advanced_insert_int.hpp
@@ -27,6 +27,32 @@
 
 namespace boost { namespace container { namespace container_detail {
 
+template
+struct move_insert_range_proxy
+{
+   typedef typename allocator_traits::size_type size_type;
+   typedef typename allocator_traits::value_type value_type;
+
+   move_insert_range_proxy(A& a, FwdIt first)
+      :  a_(a), first_(first)
+   {}
+
+   void uninitialized_copy_n_and_update(Iterator pos, size_type n)
+   {
+      this->first_ = ::boost::container::uninitialized_move_alloc_n_source
+         (this->a_, this->first_, n, pos);
+   }
+
+   void copy_n_and_update(Iterator pos, size_type n)
+   {
+      this->first_ = ::boost::container::move_n_source(this->first_, n, pos);
+   }
+
+   A &a_;
+   FwdIt first_;
+};
+
+
 template
 struct insert_range_proxy
 {
diff --git a/include/boost/container/detail/utilities.hpp b/include/boost/container/detail/utilities.hpp
index 5c294e1..d9905ce 100644
--- a/include/boost/container/detail/utilities.hpp
+++ b/include/boost/container/detail/utilities.hpp
@@ -572,6 +572,62 @@ inline I copy_or_move_n_source(I f, typename std::iterator_traits::difference
    return f;
 }
 
+//////////////////////////////////////////////////////////////////////////////
+//
+//                         move
+//
+//////////////////////////////////////////////////////////////////////////////
+
+template
+   // F models ForwardIterator
+inline F move(I f, I l, F r)
+{
+   while (f != l) {
+      *r = ::boost::move(*f);
+      ++f; ++r;
+   }
+   return r;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//                         move_n
+//
+//////////////////////////////////////////////////////////////////////////////
+
+template
+   // F models ForwardIterator
+inline F move_n(I f, typename std::iterator_traits::difference_type n, F r)
+{
+   while (n--) {
+      *r = ::boost::move(*f);
+      ++f; ++r;
+   }
+   return r;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//                         move_n_source
+//
+//////////////////////////////////////////////////////////////////////////////
+
+template
+   // F models ForwardIterator
+inline I move_n_source(I f, typename std::iterator_traits::difference_type n, F r)
+{
+   while (n--) {
+      *r = ::boost::move(*f);
+      ++f; ++r;
+   }
+   return f;
+}
+
 }  //namespace container {
 }  //namespace boost {
 
diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp
index 26a2dab..37fdc2a 100644
--- a/include/boost/container/vector.hpp
+++ b/include/boost/container/vector.hpp
@@ -74,75 +74,81 @@ class vector_const_iterator
    Pointer m_ptr;
 
    public:
-   Pointer get_ptr() const    {  return   m_ptr;  }
-   explicit vector_const_iterator(Pointer ptr)  : m_ptr(ptr){}
+   Pointer get_ptr() const BOOST_CONTAINER_NOEXCEPT
+   {  return   m_ptr;  }
+
+   explicit vector_const_iterator(Pointer ptr) BOOST_CONTAINER_NOEXCEPT
+      : m_ptr(ptr)
+   {}
    /// @endcond
 
    public:
 
    //Constructors
-   vector_const_iterator() : m_ptr(0){}
+   vector_const_iterator() BOOST_CONTAINER_NOEXCEPT
+      : m_ptr()
+   {}
 
    //Pointer like operators
-   reference operator*()   const 
+   reference operator*()   const BOOST_CONTAINER_NOEXCEPT
    {  return *m_ptr;  }
 
-   const value_type * operator->()  const 
+   const value_type * operator->()  const BOOST_CONTAINER_NOEXCEPT
    {  return container_detail::to_raw_pointer(m_ptr);  }
 
-   reference operator[](difference_type off) const
+   reference operator[](difference_type off) const BOOST_CONTAINER_NOEXCEPT
    {  return m_ptr[off];   }
 
    //Increment / Decrement
-   vector_const_iterator& operator++()      
+   vector_const_iterator& operator++() BOOST_CONTAINER_NOEXCEPT
    { ++m_ptr;  return *this; }
 
-   vector_const_iterator operator++(int)     
+   vector_const_iterator operator++(int) BOOST_CONTAINER_NOEXCEPT
    {  Pointer tmp = m_ptr; ++*this; return vector_const_iterator(tmp);  }
 
-   vector_const_iterator& operator--()
+   vector_const_iterator& operator--() BOOST_CONTAINER_NOEXCEPT
    {  --m_ptr; return *this;  }
 
-   vector_const_iterator operator--(int)
+   vector_const_iterator operator--(int) BOOST_CONTAINER_NOEXCEPT
    {  Pointer tmp = m_ptr; --*this; return vector_const_iterator(tmp); }
 
    //Arithmetic
-   vector_const_iterator& operator+=(difference_type off)
+   vector_const_iterator& operator+=(difference_type off) BOOST_CONTAINER_NOEXCEPT
    {  m_ptr += off; return *this;   }
 
-   vector_const_iterator operator+(difference_type off) const
-   {  return vector_const_iterator(m_ptr+off);  }
-
-   friend vector_const_iterator operator+(difference_type off, const vector_const_iterator& right)
-   {  return vector_const_iterator(off + right.m_ptr); }
-
-   vector_const_iterator& operator-=(difference_type off)
+   vector_const_iterator& operator-=(difference_type off) BOOST_CONTAINER_NOEXCEPT
    {  m_ptr -= off; return *this;   }
 
-   vector_const_iterator operator-(difference_type off) const
-   {  return vector_const_iterator(m_ptr-off);  }
+   friend vector_const_iterator operator+(const vector_const_iterator &x, difference_type off) BOOST_CONTAINER_NOEXCEPT
+   {  return vector_const_iterator(x.m_ptr+off);  }
 
-   difference_type operator-(const vector_const_iterator& right) const
-   {  return m_ptr - right.m_ptr;   }
+   friend vector_const_iterator operator+(difference_type off, const vector_const_iterator& right) BOOST_CONTAINER_NOEXCEPT
+   {  return vector_const_iterator(off + right.m_ptr); }
+
+   friend vector_const_iterator operator-(const vector_const_iterator &x, difference_type off) BOOST_CONTAINER_NOEXCEPT
+   {  return vector_const_iterator(x.m_ptr-off);  }
+
+   friend difference_type operator-(const vector_const_iterator &left, const vector_const_iterator& right) BOOST_CONTAINER_NOEXCEPT
+   {  return left.m_ptr - right.m_ptr;   }
 
    //Comparison operators
-   bool operator==   (const vector_const_iterator& r)  const
-   {  return m_ptr == r.m_ptr;  }
+   friend bool operator==   (const vector_const_iterator& l, const vector_const_iterator& r) BOOST_CONTAINER_NOEXCEPT
+   {  return l.m_ptr == r.m_ptr;  }
 
-   bool operator!=   (const vector_const_iterator& r)  const
-   {  return m_ptr != r.m_ptr;  }
+   friend bool operator!=   (const vector_const_iterator& l, const vector_const_iterator& r) BOOST_CONTAINER_NOEXCEPT
+   {  return l.m_ptr != r.m_ptr;  }
 
-   bool operator<    (const vector_const_iterator& r)  const
-   {  return m_ptr < r.m_ptr;  }
+   friend bool operator<    (const vector_const_iterator& l, const vector_const_iterator& r) BOOST_CONTAINER_NOEXCEPT
+   {  return l.m_ptr < r.m_ptr;  }
 
-   bool operator<=   (const vector_const_iterator& r)  const
-   {  return m_ptr <= r.m_ptr;  }
+   friend bool operator<=   (const vector_const_iterator& l, const vector_const_iterator& r) BOOST_CONTAINER_NOEXCEPT
+   {  return l.m_ptr <= r.m_ptr;  }
 
-   bool operator>    (const vector_const_iterator& r)  const
-   {  return m_ptr > r.m_ptr;  }
+   friend bool operator>    (const vector_const_iterator& l, const vector_const_iterator& r) BOOST_CONTAINER_NOEXCEPT
+   {  return l.m_ptr > r.m_ptr;  }
 
-   bool operator>=   (const vector_const_iterator& r)  const
-   {  return m_ptr >= r.m_ptr;  }
+   friend bool operator>=   (const vector_const_iterator& l, const vector_const_iterator& r) BOOST_CONTAINER_NOEXCEPT
+   {  return l.m_ptr >= r.m_ptr;  }
 };
 
 //! Iterator used to iterate through a vector
@@ -151,7 +157,7 @@ class vector_iterator
    :  public vector_const_iterator
 {
    public:
-   explicit vector_iterator(Pointer ptr)
+   explicit vector_iterator(Pointer ptr) BOOST_CONTAINER_NOEXCEPT
       : vector_const_iterator(ptr)
    {}
 
@@ -163,50 +169,47 @@ class vector_iterator
    typedef value_type&                                                           reference;
 
    //Constructors
-   vector_iterator()
+   vector_iterator() BOOST_CONTAINER_NOEXCEPT
    {}
 
    //Pointer like operators
-   reference operator*()  const 
+   reference operator*()  const BOOST_CONTAINER_NOEXCEPT
    {  return *this->m_ptr;  }
 
-   value_type* operator->() const 
+   value_type* operator->() const BOOST_CONTAINER_NOEXCEPT
    {  return  container_detail::to_raw_pointer(this->m_ptr);  }
 
-   reference operator[](difference_type off) const
+   reference operator[](difference_type off) const BOOST_CONTAINER_NOEXCEPT
    {  return this->m_ptr[off];   }
 
    //Increment / Decrement
-   vector_iterator& operator++() 
+   vector_iterator& operator++()  BOOST_CONTAINER_NOEXCEPT
    {  ++this->m_ptr; return *this;  }
 
-   vector_iterator operator++(int)
+   vector_iterator operator++(int) BOOST_CONTAINER_NOEXCEPT
    {  pointer tmp = this->m_ptr; ++*this; return vector_iterator(tmp);  }
   
-   vector_iterator& operator--()
+   vector_iterator& operator--() BOOST_CONTAINER_NOEXCEPT
    {  --this->m_ptr; return *this;  }
 
-   vector_iterator operator--(int)
+   vector_iterator operator--(int) BOOST_CONTAINER_NOEXCEPT
    {  vector_iterator tmp = *this; --*this; return vector_iterator(tmp); }
 
    // Arithmetic
-   vector_iterator& operator+=(difference_type off)
+   vector_iterator& operator+=(difference_type off) BOOST_CONTAINER_NOEXCEPT
    {  this->m_ptr += off;  return *this;  }
 
-   vector_iterator operator+(difference_type off) const
-   {  return vector_iterator(this->m_ptr+off);  }
-
-   friend vector_iterator operator+(difference_type off, const vector_iterator& right)
-   {  return vector_iterator(off + right.m_ptr); }
-
-   vector_iterator& operator-=(difference_type off)
+   vector_iterator& operator-=(difference_type off) BOOST_CONTAINER_NOEXCEPT
    {  this->m_ptr -= off; return *this;   }
 
-   vector_iterator operator-(difference_type off) const
-   {  return vector_iterator(this->m_ptr-off);  }
+   friend vector_iterator operator+(const vector_iterator &x, difference_type off) BOOST_CONTAINER_NOEXCEPT
+   {  return vector_iterator(x.m_ptr+off);  }
 
-   difference_type operator-(const vector_const_iterator& right) const
-   {  return static_cast&>(*this) - right;   }
+   friend vector_iterator operator+(difference_type off, const vector_iterator& right) BOOST_CONTAINER_NOEXCEPT
+   {  return vector_iterator(off + right.m_ptr); }
+
+   friend vector_iterator operator-(const vector_iterator &x, difference_type off) BOOST_CONTAINER_NOEXCEPT
+   {  return vector_iterator(x.m_ptr-off);  }
 };
 
 template 
@@ -216,15 +219,10 @@ struct vector_value_traits
    typedef Allocator allocator_type;
    static const bool trivial_dctr = boost::has_trivial_destructor::value;
    static const bool trivial_dctr_after_move = ::boost::has_trivial_destructor_after_move::value;
-   //static const bool trivial_copy = has_trivial_copy::value;
-   //static const bool nothrow_copy = has_nothrow_copy::value;
-   //static const bool trivial_assign = has_trivial_assign::value;
-   //static const bool nothrow_assign = has_nothrow_assign::value;
-
    static const bool trivial_copy = has_trivial_copy::value;
-   static const bool nothrow_copy = has_nothrow_copy::value;
+   static const bool nothrow_copy = has_nothrow_copy::value || trivial_copy;
    static const bool trivial_assign = has_trivial_assign::value;
-   static const bool nothrow_assign = false;
+   static const bool nothrow_assign = has_nothrow_assign::value || trivial_assign;
 
    //This is the anti-exception array destructor
    //to deallocate values already constructed
@@ -251,41 +249,88 @@ struct vector_value_traits
 //!This struct deallocates and allocated memory
 template 
 struct vector_alloc_holder
+   : public Allocator
 {
+   private:
+   BOOST_MOVABLE_BUT_NOT_COPYABLE(vector_alloc_holder)
+
+   public:
    typedef boost::container::allocator_traits allocator_traits_type;
    typedef typename allocator_traits_type::pointer       pointer;
    typedef typename allocator_traits_type::size_type     size_type;
    typedef typename allocator_traits_type::value_type    value_type;
    typedef vector_value_traits    value_traits;
+   typedef container_detail::integral_constant      allocator_v1;
+   typedef container_detail::integral_constant      allocator_v2;
+   typedef container_detail::integral_constant::value> alloc_version;
 
    //Constructor, does not throw
    vector_alloc_holder()
       BOOST_CONTAINER_NOEXCEPT_IF(::boost::has_nothrow_default_constructor::value)
-      : members_()
+      :  Allocator(), m_start(), m_size(0), m_capacity(0)
    {}
 
    //Constructor, does not throw
    template
    explicit vector_alloc_holder(BOOST_FWD_REF(AllocConvertible) a) BOOST_CONTAINER_NOEXCEPT
-      : members_(boost::forward(a))
+      :  Allocator(boost::forward(a)), m_start(), m_size(0), m_capacity(0)
    {}
 
-   //Destructor
-   ~vector_alloc_holder()
+   //Constructor, does not throw
+   template
+   explicit vector_alloc_holder(BOOST_FWD_REF(AllocConvertible) a, size_type capacity)
+      :  Allocator(boost::forward(a)), m_start(), m_size(), m_capacity()
    {
-      this->prot_destroy_all();
-      this->prot_deallocate();
+      m_start = this->allocation_command
+            (allocate_new, capacity, capacity, m_capacity, m_start).first;
+   }
+
+   //Constructor, does not throw
+   explicit vector_alloc_holder(size_type capacity)
+      :  Allocator(), m_start(), m_size(), m_capacity()
+   {
+      m_start = this->allocation_command
+            (allocate_new, capacity, capacity, m_capacity, m_start).first;
+   }
+
+   vector_alloc_holder(BOOST_RV_REF(vector_alloc_holder) holder) BOOST_CONTAINER_NOEXCEPT
+      : Allocator(boost::move(static_cast(holder)))
+      , m_start(holder.m_start), m_size(holder.m_size), m_capacity(holder.m_capacity)
+   {
+      holder.m_start = pointer();
+      holder.m_size = holder.m_capacity = 0;
+   }
+
+   void first_allocation(size_type capacity)
+   {
+      m_start = this->allocation_command
+            (allocate_new, capacity, capacity, m_capacity, m_start).first;
+   }
+
+   template
+   void first_allocation_fill(Proxy proxy, size_type n)
+   {
+      //Copy first new elements in pos
+      proxy.uninitialized_copy_n_and_update
+         (container_detail::to_raw_pointer(this->m_start), n);
+      this->m_size = n;
+   }
+
+   //Destructor
+   ~vector_alloc_holder() BOOST_CONTAINER_NOEXCEPT
+   {
+      if(this->m_capacity){
+         this->destroy_n(container_detail::to_raw_pointer(this->m_start), this->m_size);
+         this->alloc().deallocate(this->m_start, this->m_capacity);
+      }
    }
 
-   typedef container_detail::integral_constant      allocator_v1;
-   typedef container_detail::integral_constant      allocator_v2;
-   typedef container_detail::integral_constant::value> alloc_version;
    std::pair
       allocation_command(allocation_type command,
                          size_type limit_size,
                          size_type preferred_size,
-                         size_type &received_size, const pointer &reuse = 0)
+                         size_type &received_size, const pointer &reuse = pointer())
    {
       return allocator_version_traits::allocation_command
          (this->alloc(), command, limit_size, preferred_size, received_size, reuse);
@@ -293,64 +338,56 @@ struct vector_alloc_holder
 
    size_type next_capacity(size_type additional_objects) const
    {
-      std::size_t num_objects   = this->members_.m_size + additional_objects;
-      std::size_t next_cap = this->members_.m_capacity + this->members_.m_capacity/2;
+      std::size_t num_objects   = this->m_size + additional_objects;
+      std::size_t next_cap = this->m_capacity + this->m_capacity/2;
       return num_objects > next_cap ? num_objects : next_cap;/*
-      return get_next_capacity( allocator_traits_type::max_size(this->alloc())
-                              , this->members_.m_capacity, additional_objects);*/
+      return get_next_capacity( allocator_traits_type::max_size(this->m_holder.alloc())
+                              , this->m_capacity, additional_objects);*/
    }
 
-   struct members_holder
-      : public Allocator
+   pointer     m_start;
+   size_type   m_size;
+   size_type   m_capacity;
+
+   void swap_members(vector_alloc_holder &x) BOOST_CONTAINER_NOEXCEPT
    {
-      private:
-      members_holder(const members_holder&);
-
-      public:
-      template
-      explicit members_holder(BOOST_FWD_REF(Alloc) alloc)
-         :  Allocator(boost::forward(alloc)), m_start(0), m_size(0), m_capacity(0)
-      {}
-
-      members_holder()
-         :  Allocator(), m_start(0), m_size(0), m_capacity(0)
-      {}
-
-      pointer     m_start;
-      size_type   m_size;
-      size_type   m_capacity;
-   } members_;
-
-   void swap_members(vector_alloc_holder &x)
-   {
-      container_detail::do_swap(this->members_.m_start, x.members_.m_start);
-      container_detail::do_swap(this->members_.m_size, x.members_.m_size);
-      container_detail::do_swap(this->members_.m_capacity, x.members_.m_capacity);
+      container_detail::do_swap(this->m_start, x.m_start);
+      container_detail::do_swap(this->m_size, x.m_size);
+      container_detail::do_swap(this->m_capacity, x.m_capacity);
    }
 
-   Allocator &alloc()
-   {  return members_;  }
-
-   const Allocator &alloc() const
-   {  return members_;  }
-
-   protected:
-   void prot_deallocate()
+   void move_from_empty(vector_alloc_holder &x) BOOST_CONTAINER_NOEXCEPT
    {
-      if(!this->members_.m_capacity)   return;
-      this->alloc().deallocate(this->members_.m_start, this->members_.m_capacity);
-      this->members_.m_start     = 0;
-      this->members_.m_size      = 0;
-      this->members_.m_capacity  = 0;
+      this->m_start     = x.m_start;
+      this->m_size      = x.m_size;
+      this->m_capacity  = x.m_capacity;
+      x.m_start = pointer();
+      x.m_size = x.m_capacity = 0;
    }
 
-   void destroy(value_type* p)
+   Allocator &alloc() BOOST_CONTAINER_NOEXCEPT
+   {  return *this;  }
+
+   const Allocator &alloc() const BOOST_CONTAINER_NOEXCEPT
+   {  return *this;  }
+
+   void deallocate() BOOST_CONTAINER_NOEXCEPT
+   {
+      if(this->m_capacity){
+         this->alloc().deallocate(this->m_start, this->m_capacity);
+         this->m_start     = pointer();
+         this->m_size      = 0;
+         this->m_capacity  = 0;
+      }
+   }
+
+   void destroy(value_type* p) BOOST_CONTAINER_NOEXCEPT
    {
       if(!value_traits::trivial_dctr)
          allocator_traits_type::destroy(this->alloc(), p);
    }
 
-   void destroy_n(value_type* p, size_type n)
+   void destroy_n(value_type* p, size_type n) BOOST_CONTAINER_NOEXCEPT
    {
       if(!value_traits::trivial_dctr){
          for(; n--; ++p){
@@ -359,10 +396,10 @@ struct vector_alloc_holder
       }
    }
 
-   void prot_destroy_all()
+   void destroy_all() BOOST_CONTAINER_NOEXCEPT
    {
-      this->destroy_n(container_detail::to_raw_pointer(this->members_.m_start), this->members_.m_size);
-      this->members_.m_size = 0;
+      this->destroy_n(container_detail::to_raw_pointer(this->m_start), this->m_size);
+      this->m_size = 0;
    }
 };
 
@@ -381,8 +418,9 @@ template  >
 #else
 template 
 #endif
-class vector : private container_detail::vector_alloc_holder
+class vector
 {
+   container_detail::vector_alloc_holder m_holder;
    /// @cond
    typedef container_detail::vector_alloc_holder base_t;
    typedef allocator_traits            allocator_traits_type;
@@ -434,7 +472,7 @@ class vector : private container_detail::vector_alloc_holder
    //! Complexity: Constant.
    vector()
       BOOST_CONTAINER_NOEXCEPT_IF(::boost::has_nothrow_default_constructor::value)
-      : base_t()
+      : m_holder()
    {}
 
    //! Effects: Constructs a vector taking the allocator as parameter.
@@ -443,7 +481,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    explicit vector(const Allocator& a) BOOST_CONTAINER_NOEXCEPT
-      : base_t(a)
+      : m_holder(a)
    {}
 
    //! Effects: Constructs a vector that will use a copy of allocator a
@@ -454,8 +492,11 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Linear to n.
    explicit vector(size_type n)
-      :  base_t()
-   {  this->resize(n);  }
+      :  m_holder(n)
+   {
+      this->m_holder.first_allocation_fill
+         (container_detail::insert_default_constructed_n_proxy (this->m_holder.alloc()), n);
+   }
 
    //! Effects: Constructs a vector that will use a copy of allocator a
    //!   and inserts n copies of value.
@@ -465,8 +506,11 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Linear to n.
    vector(size_type n, const T& value, const allocator_type& a = allocator_type())
-      :  base_t(a)
-   {  this->resize(n, value); }
+      :  m_holder(a, n)
+   {
+      this->m_holder.first_allocation_fill
+         (container_detail::insert_n_copies_proxy (this->m_holder.alloc(), value), n);
+   }
 
    //! Effects: Constructs a vector that will use a copy of allocator a
    //!   and inserts a copy of the range [first, last) in the vector.
@@ -477,8 +521,8 @@ class vector : private container_detail::vector_alloc_holder
    //! Complexity: Linear to the range [first, last).
    template 
    vector(InIt first, InIt last, const allocator_type& a = allocator_type())
-      :  base_t(a)
-   {  this->assign(first, last); }
+      :  m_holder(a)
+   {  this->insert(this->cend(), first, last); }
 
    //! Effects: Copy constructs a vector.
    //!
@@ -489,10 +533,11 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Linear to the elements x contains.
    vector(const vector &x)
-      :  base_t(allocator_traits_type::select_on_container_copy_construction(x.alloc()))
+      :  m_holder(allocator_traits_type::select_on_container_copy_construction(x.m_holder.alloc()), x.size())
    {
-      this->assign( container_detail::to_raw_pointer(x.members_.m_start)
-                  , container_detail::to_raw_pointer(x.members_.m_start + x.members_.m_size));
+      this->m_holder.first_allocation_fill
+         (container_detail::insert_range_proxy
+            (this->m_holder.alloc(), container_detail::to_raw_pointer(x.m_holder.m_start)), x.size());
    }
 
    //! Effects: Move constructor. Moves mx's resources to *this.
@@ -501,8 +546,8 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    vector(BOOST_RV_REF(vector) mx) BOOST_CONTAINER_NOEXCEPT
-      :  base_t(boost::move(mx.alloc()))
-   {  this->swap_members(mx);   }
+      :  m_holder(boost::move(mx.m_holder))
+   {}
 
    //! Effects: Copy constructs a vector using the specified allocator.
    //!
@@ -513,10 +558,11 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Linear to the elements x contains.
    vector(const vector &x, const allocator_type &a)
-      :  base_t(a)
+      :  m_holder(a, x.size())
    {
-      this->assign( container_detail::to_raw_pointer(x.members_.m_start)
-                  , container_detail::to_raw_pointer(x.members_.m_start + x.members_.m_size));
+      this->m_holder.first_allocation_fill
+         (container_detail::insert_range_proxy
+            (this->m_holder.alloc(), container_detail::to_raw_pointer(x.m_holder.m_start)), x.size());
    }
 
    //! Effects: Move constructor using the specified allocator.
@@ -527,14 +573,17 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant if a == mx.get_allocator(), linear otherwise.
    vector(BOOST_RV_REF(vector) mx, const allocator_type &a)
-      :  base_t(a)
+      :  m_holder(a)
    {
-      if(mx.alloc() == a){
-         this->swap_members(mx);
+      if(mx.m_holder.alloc() == a){
+         this->m_holder.move_from_empty(mx.m_holder);
       }
       else{
-         this->assign( container_detail::to_raw_pointer(mx.members_.m_start)
-                     , container_detail::to_raw_pointer(mx.members_.m_start) + mx.members_.m_size);
+         const size_type n = mx.size();
+         this->m_holder.first_allocation(n);
+         this->m_holder.first_allocation_fill
+            (container_detail::move_insert_range_proxy
+               (this->m_holder.alloc(), container_detail::to_raw_pointer(mx.m_holder.m_start)), n);
       }
    }
 
@@ -558,8 +607,8 @@ class vector : private container_detail::vector_alloc_holder
    vector& operator=(BOOST_COPY_ASSIGN_REF(vector) x)
    {
       if (&x != this){
-         allocator_type &this_alloc     = this->alloc();
-         const allocator_type &x_alloc  = x.alloc();
+         allocator_type &this_alloc     = this->m_holder.alloc();
+         const allocator_type &x_alloc  = x.m_holder.alloc();
          container_detail::bool_ flag;
          if(flag && this_alloc != x_alloc){
@@ -567,8 +616,8 @@ class vector : private container_detail::vector_alloc_holder
             this->shrink_to_fit();
          }
          container_detail::assign_alloc(this_alloc, x_alloc, flag);
-         this->assign( container_detail::to_raw_pointer(x.members_.m_start)
-                     , container_detail::to_raw_pointer(x.members_.m_start + x.members_.m_size));
+         this->assign( container_detail::to_raw_pointer(x.m_holder.m_start)
+                     , container_detail::to_raw_pointer(x.m_holder.m_start + x.m_holder.m_size));
       }
       return *this;
    }
@@ -586,13 +635,13 @@ class vector : private container_detail::vector_alloc_holder
       BOOST_CONTAINER_NOEXCEPT
    {
       if (&x != this){
-         allocator_type &this_alloc = this->alloc();
-         allocator_type &x_alloc    = x.alloc();
+         allocator_type &this_alloc = this->m_holder.alloc();
+         allocator_type &x_alloc    = x.m_holder.alloc();
          //If allocators are equal we can just swap pointers
          if(this_alloc == x_alloc){
             //Destroy objects but retain memory in case x reuses it in the future
             this->clear();
-            this->swap_members(x);
+            this->m_holder.swap_members(x.m_holder);
             //Move allocator if needed
             container_detail::bool_ flag;
@@ -600,8 +649,8 @@ class vector : private container_detail::vector_alloc_holder
          }
          //If unequal allocators, then do a one by one move
          else{
-            this->assign( boost::make_move_iterator(container_detail::to_raw_pointer(x.members_.m_start))
-                        , boost::make_move_iterator(container_detail::to_raw_pointer(x.members_.m_start + x.members_.m_size)));
+            this->assign( boost::make_move_iterator(container_detail::to_raw_pointer(x.m_holder.m_start))
+                        , boost::make_move_iterator(container_detail::to_raw_pointer(x.m_holder.m_start + x.m_holder.m_size)));
          }
       }
       return *this;
@@ -654,8 +703,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
-   { return this->alloc();  }
-
+   { return this->m_holder.alloc();  }
 
    //! Effects: Returns a reference to the internal allocator.
    //!
@@ -665,7 +713,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Note: Non-standard extension.
    stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
-   {  return this->alloc(); }
+   {  return this->m_holder.alloc(); }
 
    //! Effects: Returns a reference to the internal allocator.
    //!
@@ -675,7 +723,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Note: Non-standard extension.
    const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
-   {  return this->alloc(); }
+   {  return this->m_holder.alloc(); }
 
    //////////////////////////////////////////////
    //
@@ -689,7 +737,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    iterator begin() BOOST_CONTAINER_NOEXCEPT
-   { return iterator(this->members_.m_start); }
+   { return iterator(this->m_holder.m_start); }
 
    //! Effects: Returns a const_iterator to the first element contained in the vector.
    //!
@@ -697,7 +745,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
-   { return const_iterator(this->members_.m_start); }
+   { return const_iterator(this->m_holder.m_start); }
 
    //! Effects: Returns an iterator to the end of the vector.
    //!
@@ -705,7 +753,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    iterator end() BOOST_CONTAINER_NOEXCEPT
-   { return iterator(this->members_.m_start + this->members_.m_size); }
+   { return iterator(this->m_holder.m_start + this->m_holder.m_size); }
 
    //! Effects: Returns a const_iterator to the end of the vector.
    //!
@@ -757,7 +805,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
-   { return const_iterator(this->members_.m_start); }
+   { return const_iterator(this->m_holder.m_start); }
 
    //! Effects: Returns a const_iterator to the end of the vector.
    //!
@@ -765,7 +813,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
-   { return const_iterator(this->members_.m_start + this->members_.m_size); }
+   { return const_iterator(this->m_holder.m_start + this->m_holder.m_size); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
    //! of the reversed vector.
@@ -797,7 +845,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    bool empty() const BOOST_CONTAINER_NOEXCEPT
-   { return !this->members_.m_size; }
+   { return !this->m_holder.m_size; }
 
    //! Effects: Returns the number of the elements contained in the vector.
    //!
@@ -805,7 +853,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    size_type size() const BOOST_CONTAINER_NOEXCEPT
-   { return this->members_.m_size; }
+   { return this->m_holder.m_size; }
 
    //! Effects: Returns the largest possible size of the vector.
    //!
@@ -813,7 +861,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    size_type max_size() const BOOST_CONTAINER_NOEXCEPT
-   { return allocator_traits_type::max_size(this->alloc()); }
+   { return allocator_traits_type::max_size(this->m_holder.alloc()); }
 
    //! Effects: Inserts or erases elements at the end such that
    //!   the size becomes n. New elements are default constructed.
@@ -825,12 +873,12 @@ class vector : private container_detail::vector_alloc_holder
    {
       if (new_size < this->size()){
          //Destroy last elements
-         this->erase(const_iterator(this->members_.m_start + new_size), this->end());
+         this->erase(const_iterator(this->m_holder.m_start + new_size), this->end());
       }
       else{
          const size_type n = new_size - this->size();
          this->reserve(new_size);
-         container_detail::insert_default_constructed_n_proxy proxy(this->alloc());
+         container_detail::insert_default_constructed_n_proxy proxy(this->m_holder.alloc());
          this->priv_forward_range_insert(this->cend().get_ptr(), n, proxy);
       }
    }
@@ -843,10 +891,10 @@ class vector : private container_detail::vector_alloc_holder
    //! Complexity: Linear to the difference between size() and new_size.
    void resize(size_type new_size, const T& x)
    {
-      pointer finish = this->members_.m_start + this->members_.m_size;
+      pointer finish = this->m_holder.m_start + this->m_holder.m_size;
       if (new_size < size()){
          //Destroy last elements
-         this->erase(const_iterator(this->members_.m_start + new_size), this->end());
+         this->erase(const_iterator(this->m_holder.m_start + new_size), this->end());
       }
       else{
          //Insert new elements at the end
@@ -861,7 +909,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    size_type capacity() const BOOST_CONTAINER_NOEXCEPT
-   { return this->members_.m_capacity; }
+   { return this->m_holder.m_capacity; }
 
    //! Effects: If n is less than or equal to capacity(), this call has no
    //!   effect. Otherwise, it is a request for allocation of additional memory.
@@ -877,24 +925,24 @@ class vector : private container_detail::vector_alloc_holder
          bool same_buffer_start;
          size_type real_cap = 0;
          std::pair ret =
-            this->allocation_command
+            this->m_holder.allocation_command
                (allocate_new | expand_fwd | expand_bwd,
-                  new_cap, new_cap, real_cap, this->members_.m_start);
+                  new_cap, new_cap, real_cap, this->m_holder.m_start);
 
          //Check for forward expansion
-         same_buffer_start = ret.second && this->members_.m_start == ret.first;
+         same_buffer_start = ret.second && this->m_holder.m_start == ret.first;
          if(same_buffer_start){
             #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
             ++this->num_expand_fwd;
             #endif
-            this->members_.m_capacity  = real_cap;
+            this->m_holder.m_capacity  = real_cap;
          }
 
          //If there is no forward expansion, move objects
          else{
             //We will reuse insert code, so create a dummy input iterator
             container_detail::insert_range_proxy, T*>
-               proxy(this->alloc(), ::boost::make_move_iterator((T *)0));
+               proxy(this->m_holder.alloc(), ::boost::make_move_iterator((T *)0));
             //Backwards (and possibly forward) expansion
             if(alloc_version::value > 1 && ret.second){
                #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
@@ -903,7 +951,7 @@ class vector : private container_detail::vector_alloc_holder
                this->priv_range_insert_expand_backwards
                   ( container_detail::to_raw_pointer(ret.first)
                   , real_cap
-                  , container_detail::to_raw_pointer(this->members_.m_start)
+                  , container_detail::to_raw_pointer(this->m_holder.m_start)
                   , 0
                   , proxy);
             }
@@ -915,7 +963,7 @@ class vector : private container_detail::vector_alloc_holder
                this->priv_range_insert_new_allocation
                   ( container_detail::to_raw_pointer(ret.first)
                   , real_cap
-                  , container_detail::to_raw_pointer(this->members_.m_start)
+                  , container_detail::to_raw_pointer(this->m_holder.m_start)
                   , 0
                   , proxy);
             }
@@ -947,7 +995,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    reference         front() BOOST_CONTAINER_NOEXCEPT
-   { return *this->members_.m_start; }
+   { return *this->m_holder.m_start; }
 
    //! Requires: !empty()
    //!
@@ -958,7 +1006,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    const_reference   front() const BOOST_CONTAINER_NOEXCEPT
-   { return *this->members_.m_start; }
+   { return *this->m_holder.m_start; }
 
    //! Requires: !empty()
    //!
@@ -969,7 +1017,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    reference         back() BOOST_CONTAINER_NOEXCEPT
-   { return this->members_.m_start[this->members_.m_size - 1]; }
+   { return this->m_holder.m_start[this->m_holder.m_size - 1]; }
 
    //! Requires: !empty()
    //!
@@ -980,7 +1028,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    const_reference   back()  const BOOST_CONTAINER_NOEXCEPT
-   { return this->members_.m_start[this->members_.m_size - 1]; }
+   { return this->m_holder.m_start[this->m_holder.m_size - 1]; }
 
    //! Requires: size() > n.
    //!
@@ -991,7 +1039,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT
-   { return this->members_.m_start[n]; }
+   { return this->m_holder.m_start[n]; }
 
    //! Requires: size() > n.
    //!
@@ -1002,7 +1050,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT
-   { return this->members_.m_start[n]; }
+   { return this->m_holder.m_start[n]; }
 
    //! Requires: size() > n.
    //!
@@ -1013,7 +1061,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    reference at(size_type n)
-   { this->priv_check_range(n); return this->members_.m_start[n]; }
+   { this->priv_check_range(n); return this->m_holder.m_start[n]; }
 
    //! Requires: size() > n.
    //!
@@ -1024,7 +1072,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    const_reference at(size_type n) const
-   { this->priv_check_range(n); return this->members_.m_start[n]; }
+   { this->priv_check_range(n); return this->m_holder.m_start[n]; }
 
    //////////////////////////////////////////////
    //
@@ -1039,7 +1087,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    T* data() BOOST_CONTAINER_NOEXCEPT
-   { return container_detail::to_raw_pointer(this->members_.m_start); }
+   { return container_detail::to_raw_pointer(this->m_holder.m_start); }
 
    //! Returns: Allocator pointer such that [data(),data() + size()) is a valid range.
    //!   For a non-empty vector, data() == &front().
@@ -1048,7 +1096,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Constant.
    const T * data()  const BOOST_CONTAINER_NOEXCEPT
-   { return container_detail::to_raw_pointer(this->members_.m_start); }
+   { return container_detail::to_raw_pointer(this->m_holder.m_start); }
 
    //////////////////////////////////////////////
    //
@@ -1067,16 +1115,16 @@ class vector : private container_detail::vector_alloc_holder
    template
    void emplace_back(Args &&...args)
    {
-      T* back_pos = container_detail::to_raw_pointer(this->members_.m_start) + this->members_.m_size;
-      if (this->members_.m_size < this->members_.m_capacity){
+      T* back_pos = container_detail::to_raw_pointer(this->m_holder.m_start) + this->m_holder.m_size;
+      if (this->m_holder.m_size < this->m_holder.m_capacity){
          //There is more memory, just construct a new object at the end
-         allocator_traits_type::construct(this->alloc(), back_pos, ::boost::forward(args)...);
-         ++this->members_.m_size;
+         allocator_traits_type::construct(this->m_holder.alloc(), back_pos, ::boost::forward(args)...);
+         ++this->m_holder.m_size;
       }
       else{
          typedef container_detail::insert_emplace_proxy type;
          this->priv_forward_range_insert
-            (back_pos, 1, type(this->alloc(), ::boost::forward(args)...));
+            (back_pos, 1, type(this->m_holder.alloc(), ::boost::forward(args)...));
       }
    }
 
@@ -1096,40 +1144,40 @@ class vector : private container_detail::vector_alloc_holder
       //Just call more general insert(pos, size, value) and return iterator
       typedef container_detail::insert_emplace_proxy type;
       return this->priv_forward_range_insert
-         (position.get_ptr(), 1, type(this->alloc(), ::boost::forward(args)...));
+         (position.get_ptr(), 1, type(this->m_holder.alloc(), ::boost::forward(args)...));
    }
 
    #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, >)       \
-   void emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                        \
-   {                                                                                            \
-      T* back_pos = container_detail::to_raw_pointer                                            \
-         (this->members_.m_start) + this->members_.m_size;                                      \
-      if (this->members_.m_size < this->members_.m_capacity){                                   \
-         allocator_traits_type::construct (this->alloc()                                        \
-            , back_pos BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) );        \
-         ++this->members_.m_size;                                                               \
-      }                                                                                         \
-      else{                                                                                     \
-         container_detail::BOOST_PP_CAT(insert_emplace_proxy_arg, n)                            \
-             proxy                           \
-            (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));     \
-         this->priv_forward_range_insert(back_pos, 1, proxy);                                   \
-      }                                                                                         \
-   }                                                                                            \
-                                                                                                \
-   BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >)       \
-   iterator emplace(const_iterator pos                                                          \
-                    BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                \
-   {                                                                                            \
-      container_detail::BOOST_PP_CAT(insert_emplace_proxy_arg, n)                               \
-          proxy                              \
-            (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));     \
-      return this->priv_forward_range_insert                                                    \
-         (container_detail::to_raw_pointer(pos.get_ptr()), 1, proxy);                           \
-   }                                                                                            \
+   #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_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                              \
+   {                                                                                                  \
+      T* back_pos = container_detail::to_raw_pointer                                                  \
+         (this->m_holder.m_start) + this->m_holder.m_size;                                            \
+      if (this->m_holder.m_size < this->m_holder.m_capacity){                                         \
+         allocator_traits_type::construct (this->m_holder.alloc()                                     \
+            , back_pos BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) );              \
+         ++this->m_holder.m_size;                                                                     \
+      }                                                                                               \
+      else{                                                                                           \
+         container_detail::BOOST_PP_CAT(insert_emplace_proxy_arg, n)                                  \
+             proxy                                 \
+            (this->m_holder.alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));  \
+         this->priv_forward_range_insert(back_pos, 1, proxy);                                         \
+      }                                                                                               \
+   }                                                                                                  \
+                                                                                                      \
+   BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >)             \
+   iterator emplace(const_iterator pos                                                                \
+                    BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                      \
+   {                                                                                                  \
+      container_detail::BOOST_PP_CAT(insert_emplace_proxy_arg, n)                                     \
+          proxy                                    \
+            (this->m_holder.alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));  \
+      return this->priv_forward_range_insert                                                          \
+         (container_detail::to_raw_pointer(pos.get_ptr()), 1, proxy);                                 \
+   }                                                                                                  \
    //!
    #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
    #include BOOST_PP_LOCAL_ITERATE()
@@ -1192,7 +1240,7 @@ class vector : private container_detail::vector_alloc_holder
    //! Complexity: Linear to n.
    iterator insert(const_iterator p, size_type n, const T& x)
    {
-      container_detail::insert_n_copies_proxy proxy(this->alloc(), x);
+      container_detail::insert_n_copies_proxy proxy(this->m_holder.alloc(), x);
       return this->priv_forward_range_insert(p.get_ptr(), n, proxy);
    }
 
@@ -1222,7 +1270,7 @@ class vector : private container_detail::vector_alloc_holder
          it = this->emplace(it, *first);
          ++it;
       }
-      return iterator(this->members_.m_start + n_pos);
+      return iterator(this->m_holder.m_start + n_pos);
    }
 
    #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1234,7 +1282,7 @@ class vector : private container_detail::vector_alloc_holder
          >::type * = 0
       )
    {
-      container_detail::insert_range_proxy proxy(this->alloc(), first);
+      container_detail::insert_range_proxy proxy(this->m_holder.alloc(), first);
       return this->priv_forward_range_insert(pos.get_ptr(), std::distance(first, last), proxy);
    }
    #endif
@@ -1247,8 +1295,8 @@ class vector : private container_detail::vector_alloc_holder
    void pop_back() BOOST_CONTAINER_NOEXCEPT
    {
       //Destroy last element
-      --this->members_.m_size;
-      this->destroy(container_detail::to_raw_pointer(this->members_.m_start) + this->members_.m_size);
+      --this->m_holder.m_size;
+      this->m_holder.destroy(container_detail::to_raw_pointer(this->m_holder.m_start) + this->m_holder.m_size);
    }
 
    //! Effects: Erases the element at position pos.
@@ -1260,10 +1308,10 @@ class vector : private container_detail::vector_alloc_holder
    iterator erase(const_iterator position)
    {
       T *const pos = container_detail::to_raw_pointer(position.get_ptr());
-      T *const beg = container_detail::to_raw_pointer(this->members_.m_start);
+      T *const beg = container_detail::to_raw_pointer(this->m_holder.m_start);
       //Move elements forward and destroy last
-      base_t::destroy(::boost::move(pos + 1, beg + this->members_.m_size, pos));
-      --this->members_.m_size;
+      this->m_holder.destroy(::boost::move(pos + 1, beg + this->m_holder.m_size, pos));
+      --this->m_holder.m_size;
       return iterator(position.get_ptr());
    }
 
@@ -1276,15 +1324,15 @@ class vector : private container_detail::vector_alloc_holder
    iterator erase(const_iterator first, const_iterator last)
    {
       if (first != last){
-         T* end_pos = container_detail::to_raw_pointer(this->members_.m_start) + this->members_.m_size;
+         T* end_pos = container_detail::to_raw_pointer(this->m_holder.m_start) + this->m_holder.m_size;
          T* ptr = container_detail::to_raw_pointer(boost::move
             (container_detail::to_raw_pointer(last.get_ptr())
             ,end_pos
             ,container_detail::to_raw_pointer(first.get_ptr())
             ));
          const size_type destroyed = (end_pos - ptr);
-         this->destroy_n(ptr, destroyed);
-         this->members_.m_size -= destroyed;
+         this->m_holder.destroy_n(ptr, destroyed);
+         this->m_holder.m_size -= destroyed;
       }
       return iterator(first.get_ptr());
    }
@@ -1294,13 +1342,13 @@ class vector : private container_detail::vector_alloc_holder
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   void swap(vector& x)
+   void swap(vector& x) BOOST_CONTAINER_NOEXCEPT
    {
       //Just swap internals
-      this->swap_members(x);
+      this->m_holder.swap_members(x.m_holder);
       //And now the allocator
       container_detail::bool_ flag;
-      container_detail::swap_alloc(this->alloc(), x.alloc(), flag);
+      container_detail::swap_alloc(this->m_holder.alloc(), x.m_holder.alloc(), flag);
    }
 
    //! Effects: Erases all the elements of the vector.
@@ -1309,7 +1357,7 @@ class vector : private container_detail::vector_alloc_holder
    //!
    //! Complexity: Linear to the number of elements in the vector.
    void clear() BOOST_CONTAINER_NOEXCEPT
-   {  this->prot_destroy_all();  }
+   {  this->m_holder.destroy_all();  }
 
    /// @cond
 
@@ -1333,19 +1381,19 @@ class vector : private container_detail::vector_alloc_holder
    iterator priv_insert(const const_iterator &p, BOOST_FWD_REF(U) x)
    {
       return this->priv_forward_range_insert
-         (p.get_ptr(), 1, container_detail::get_insert_value_proxy(this->alloc(), ::boost::forward(x)));
+         (p.get_ptr(), 1, container_detail::get_insert_value_proxy(this->m_holder.alloc(), ::boost::forward(x)));
    }
 
    template 
    void priv_push_back(BOOST_FWD_REF(U) x)
    {
-      if (this->members_.m_size < this->members_.m_capacity){
+      if (this->m_holder.m_size < this->m_holder.m_capacity){
          //There is more memory, just construct a new object at the end
          allocator_traits_type::construct
-            ( this->alloc()
-            , container_detail::to_raw_pointer(this->members_.m_start + this->members_.m_size)
+            ( this->m_holder.alloc()
+            , container_detail::to_raw_pointer(this->m_holder.m_start + this->m_holder.m_size)
             , ::boost::forward(x) );
-         ++this->members_.m_size;
+         ++this->m_holder.m_size;
       }
       else{
          this->priv_insert(this->cend(), ::boost::forward(x));
@@ -1354,32 +1402,32 @@ class vector : private container_detail::vector_alloc_holder
 
    void priv_shrink_to_fit(allocator_v1)
    {
-      if(this->members_.m_capacity){
+      if(this->m_holder.m_capacity){
          if(!this->size()){
-            this->prot_deallocate();
+            this->m_holder.deallocate();
          }
          else{
             //Allocate a new buffer.
             size_type real_cap = 0;
             std::pair ret =
-               this->allocation_command
-                  (allocate_new, this->size(), this->size(), real_cap, this->members_.m_start);
+               this->m_holder.allocation_command
+                  (allocate_new, this->size(), this->size(), real_cap, this->m_holder.m_start);
             if(real_cap < this->capacity()){
                //We will reuse insert code, so create a dummy input iterator
                container_detail::insert_range_proxy, T*>
-                  proxy(this->alloc(), ::boost::make_move_iterator((T *)0));
+                  proxy(this->m_holder.alloc(), ::boost::make_move_iterator((T *)0));
                #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
                ++this->num_alloc;
                #endif
                this->priv_range_insert_new_allocation
                   ( container_detail::to_raw_pointer(ret.first)
                   , real_cap
-                  , container_detail::to_raw_pointer(this->members_.m_start)
+                  , container_detail::to_raw_pointer(this->m_holder.m_start)
                   , 0
                   , proxy);
             }
             else{
-               this->alloc().deallocate(ret.first, real_cap);
+               this->m_holder.alloc().deallocate(ret.first, real_cap);
             }
          }
       }
@@ -1387,17 +1435,17 @@ class vector : private container_detail::vector_alloc_holder
 
    void priv_shrink_to_fit(allocator_v2)
    {
-      if(this->members_.m_capacity){
+      if(this->m_holder.m_capacity){
          if(!size()){
-            this->prot_deallocate();
+            this->m_holder.deallocate();
          }
          else{
             size_type received_size;
-            if(this->allocation_command
+            if(this->m_holder.allocation_command
                ( shrink_in_place | nothrow_allocation
                , this->capacity(), this->size()
-               , received_size,   this->members_.m_start).first){
-               this->members_.m_capacity = received_size;
+               , received_size,   this->m_holder.m_start).first){
+               this->m_holder.m_capacity = received_size;
                #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
                ++this->num_shrink;
                #endif
@@ -1411,8 +1459,8 @@ class vector : private container_detail::vector_alloc_holder
       (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy)
    {
       //Check if we have enough memory or try to expand current memory
-      const size_type remaining = this->members_.m_capacity - this->members_.m_size;
-      const size_type n_pos = pos - this->members_.m_start;
+      const size_type remaining = this->m_holder.m_capacity - this->m_holder.m_size;
+      const size_type n_pos = pos - this->m_holder.m_start;
       T *const raw_pos = container_detail::to_raw_pointer(pos);
 
       //Check if we already have room
@@ -1422,18 +1470,18 @@ class vector : private container_detail::vector_alloc_holder
             size_type real_cap = 0;
             //There is not enough memory, allocate a new
             //buffer or expand the old one.
-            std::pair ret = (this->allocation_command
+            std::pair ret = (this->m_holder.allocation_command
                   (allocate_new | expand_fwd | expand_bwd,
-                     this->members_.m_size + n, this->next_capacity(n), real_cap, this->members_.m_start));
+                     this->m_holder.m_size + n, this->m_holder.next_capacity(n), real_cap, this->m_holder.m_start));
 
             //Buffer reallocated
             if(ret.second){
                //Forward expansion, delay insertion
-               if(this->members_.m_start == ret.first){
+               if(this->m_holder.m_start == ret.first){
                   #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
                   ++this->num_expand_fwd;
                   #endif
-                  this->members_.m_capacity = real_cap;
+                  this->m_holder.m_capacity = real_cap;
                   //Expand forward
                   this->priv_range_insert_expand_forward(raw_pos, n, insert_range_proxy);
                }
@@ -1469,8 +1517,8 @@ class vector : private container_detail::vector_alloc_holder
                (raw_pos, n, insert_range_proxy);
          }
          else{
-            const size_type new_cap = this->next_capacity(n);
-            T * new_buf = container_detail::to_raw_pointer(this->alloc().allocate(new_cap));
+            const size_type new_cap = this->m_holder.next_capacity(n);
+            T * new_buf = container_detail::to_raw_pointer(this->m_holder.alloc().allocate(new_cap));
             #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
             ++this->num_alloc;
             #endif
@@ -1478,7 +1526,7 @@ class vector : private container_detail::vector_alloc_holder
                ( new_buf, new_cap, raw_pos, n, insert_range_proxy);
          }
       }
-      return iterator(this->members_.m_start + n_pos);
+      return iterator(this->m_holder.m_start + n_pos);
    }
 
    //Absolutely experimental. This function might change, disappear or simply crash!
@@ -1488,7 +1536,7 @@ class vector : private container_detail::vector_alloc_holder
    {
       const size_type old_size_pos = this->size();
       this->reserve(old_size_pos + element_count);
-      T* const begin_ptr = container_detail::to_raw_pointer(this->members_.m_start);
+      T* const begin_ptr = container_detail::to_raw_pointer(this->m_holder.m_start);
       size_type insertions_left = element_count;
       size_type next_pos = old_size_pos;
       size_type hole_size = element_count;
@@ -1496,7 +1544,7 @@ class vector : private container_detail::vector_alloc_holder
       //Exception rollback. If any copy throws before the hole is filled, values
       //already inserted/copied at the end of the buffer will be destroyed.
       typename value_traits::ArrayDestructor past_hole_values_destroyer
-         (begin_ptr + old_size_pos + element_count, this->alloc(), size_type(0u));
+         (begin_ptr + old_size_pos + element_count, this->m_holder.alloc(), size_type(0u));
       //Loop for each insertion backwards, first moving the elements after the insertion point,
       //then inserting the element.
       while(insertions_left){
@@ -1517,12 +1565,12 @@ class vector : private container_detail::vector_alloc_holder
             //The hole was reduced by priv_insert_ordered_at_shift_range so expand exception rollback range backwards
             past_hole_values_destroyer.increment_size_backwards(next_pos - pos);
             //Insert the new value in the hole
-            allocator_traits_type::construct(this->alloc(), begin_ptr + pos + insertions_left - 1, *(--last_value_it));
+            allocator_traits_type::construct(this->m_holder.alloc(), begin_ptr + pos + insertions_left - 1, *(--last_value_it));
             --new_hole_size;
             if(new_hole_size == 0){
                //Hole was just filled, disable exception rollback and change vector size
                past_hole_values_destroyer.release();
-               this->members_.m_size += element_count;
+               this->m_holder.m_size += element_count;
             }
             else{
                //The hole was reduced by the new insertion by one
@@ -1533,7 +1581,7 @@ class vector : private container_detail::vector_alloc_holder
             if(hole_size){
                //Hole was just filled by priv_insert_ordered_at_shift_range, disable exception rollback and change vector size
                past_hole_values_destroyer.release();
-               this->members_.m_size += element_count;
+               this->m_holder.m_size += element_count;
             }
             //Insert the new value in the already constructed range
             begin_ptr[pos + insertions_left - 1] = *(--last_value_it);
@@ -1601,7 +1649,7 @@ class vector : private container_detail::vector_alloc_holder
       BOOST_ASSERT(first_pos <= last_pos);
       BOOST_ASSERT(last_pos <= limit_pos);
       //
-      T* const begin_ptr = container_detail::to_raw_pointer(this->members_.m_start);
+      T* const begin_ptr = container_detail::to_raw_pointer(this->m_holder.m_start);
       T* const first_ptr = begin_ptr + first_pos;
       T* const last_ptr  = begin_ptr + last_pos;
 
@@ -1614,7 +1662,7 @@ class vector : private container_detail::vector_alloc_holder
       //Case B:
       else if((first_pos + shift_count) >= limit_pos){
          //All uninitialized_moved
-         ::boost::container::uninitialized_move_alloc(this->alloc(), first_ptr, last_ptr, first_ptr + shift_count);
+         ::boost::container::uninitialized_move_alloc(this->m_holder.alloc(), first_ptr, last_ptr, first_ptr + shift_count);
          hole_size = last_pos + shift_count - limit_pos;
       }
       //Case C:
@@ -1622,7 +1670,7 @@ class vector : private container_detail::vector_alloc_holder
          //Some uninitialized_moved
          T* const limit_ptr    = begin_ptr + limit_pos;
          T* const boundary_ptr = limit_ptr - shift_count;
-         ::boost::container::uninitialized_move_alloc(this->alloc(), boundary_ptr, last_ptr, limit_ptr);
+         ::boost::container::uninitialized_move_alloc(this->m_holder.alloc(), boundary_ptr, last_ptr, limit_ptr);
          //The rest is move assigned
          boost::move_backward(first_ptr, boundary_ptr, limit_ptr);
       }
@@ -1636,20 +1684,20 @@ class vector : private container_detail::vector_alloc_holder
       //n can't be 0, because there is nothing to do in that case
       if(!n) return;
       //There is enough memory
-      T* const old_finish = container_detail::to_raw_pointer(this->members_.m_start) + this->members_.m_size;
+      T* const old_finish = container_detail::to_raw_pointer(this->m_holder.m_start) + this->m_holder.m_size;
       const size_type elems_after = old_finish - pos;
 
       if (!elems_after){
          //Copy first new elements in pos
          insert_range_proxy.uninitialized_copy_n_and_update(pos, n);
-         this->members_.m_size += n;
+         this->m_holder.m_size += n;
       }
       else if (elems_after >= n){
          //New elements can be just copied.
          //Move to uninitialized memory last objects
          ::boost::container::uninitialized_move_alloc
-            (this->alloc(), old_finish - n, old_finish, old_finish);
-         this->members_.m_size += n;
+            (this->m_holder.alloc(), old_finish - n, old_finish, old_finish);
+         this->m_holder.m_size += n;
          //Copy previous to last objects to the initialized end
          boost::move_backward(pos, old_finish - n, old_finish);
          //Insert new objects in the pos
@@ -1659,16 +1707,16 @@ class vector : private container_detail::vector_alloc_holder
          //The new elements don't fit in the [pos, end()) range.
 
          //Copy old [pos, end()) elements to the uninitialized memory (a gap is created)
-         ::boost::container::uninitialized_move_alloc(this->alloc(), pos, old_finish, pos + n);
+         ::boost::container::uninitialized_move_alloc(this->m_holder.alloc(), pos, old_finish, pos + n);
          BOOST_TRY{
             //Copy first new elements in pos (gap is still there)
             insert_range_proxy.copy_n_and_update(pos, elems_after);
             //Copy to the beginning of the unallocated zone the last new elements (the gap is closed).
             insert_range_proxy.uninitialized_copy_n_and_update(old_finish, n - elems_after);
-            this->members_.m_size += n;
+            this->m_holder.m_size += n;
          }
          BOOST_CATCH(...){
-            this->destroy_n(pos + n, elems_after);
+            this->m_holder.destroy_n(pos + n, elems_after);
             BOOST_RETHROW
          }
          BOOST_CATCH_END
@@ -1683,15 +1731,15 @@ class vector : private container_detail::vector_alloc_holder
       T *new_finish = new_start;
       T *old_finish;
       //Anti-exception rollbacks
-      typename value_traits::ArrayDeallocator scoped_alloc(new_start, this->alloc(), new_cap);
-      typename value_traits::ArrayDestructor constructed_values_destroyer(new_start, this->alloc(), 0u);
+      typename value_traits::ArrayDeallocator scoped_alloc(new_start, this->m_holder.alloc(), new_cap);
+      typename value_traits::ArrayDestructor constructed_values_destroyer(new_start, this->m_holder.alloc(), 0u);
 
       //Initialize with [begin(), pos) old buffer
       //the start of the new buffer
-      T *old_buffer = container_detail::to_raw_pointer(this->members_.m_start);
+      T *old_buffer = container_detail::to_raw_pointer(this->m_holder.m_start);
       if(old_buffer){
          new_finish = ::boost::container::uninitialized_move_alloc
-            (this->alloc(), container_detail::to_raw_pointer(this->members_.m_start), pos, old_finish = new_finish);
+            (this->m_holder.alloc(), container_detail::to_raw_pointer(this->m_holder.m_start), pos, old_finish = new_finish);
          constructed_values_destroyer.increment_size(new_finish - old_finish);
       }
       //Initialize new objects, starting from previous point
@@ -1702,16 +1750,16 @@ class vector : private container_detail::vector_alloc_holder
       //starting from previous point
       if(old_buffer){
          new_finish = ::boost::container::uninitialized_move_alloc
-            (this->alloc(), pos, old_buffer + this->members_.m_size, new_finish);
+            (this->m_holder.alloc(), pos, old_buffer + this->m_holder.m_size, new_finish);
          //Destroy and deallocate old elements
          //If there is allocated memory, destroy and deallocate
          if(!value_traits::trivial_dctr_after_move)
-            this->destroy_n(old_buffer, this->members_.m_size);
-         this->alloc().deallocate(this->members_.m_start, this->members_.m_capacity);
+            this->m_holder.destroy_n(old_buffer, this->m_holder.m_size);
+         this->m_holder.alloc().deallocate(this->m_holder.m_start, this->m_holder.m_capacity);
       }
-      this->members_.m_start     = new_start;
-      this->members_.m_size      = new_finish - new_start;
-      this->members_.m_capacity  = new_cap;
+      this->m_holder.m_start     = new_start;
+      this->m_holder.m_size      = new_finish - new_start;
+      this->m_holder.m_capacity  = new_cap;
       //All construction successful, disable rollbacks
       constructed_values_destroyer.release();
       scoped_alloc.release();
@@ -1724,9 +1772,9 @@ class vector : private container_detail::vector_alloc_holder
    {
       //n can be zero to just expand capacity
       //Backup old data
-      T* const old_start  = container_detail::to_raw_pointer(this->members_.m_start);
-      T* const old_finish = old_start + this->members_.m_size;
-      const size_type old_size = this->members_.m_size;
+      T* const old_start  = container_detail::to_raw_pointer(this->m_holder.m_start);
+      T* const old_finish = old_start + this->m_holder.m_size;
+      const size_type old_size = this->m_holder.m_size;
 
       //We can have 8 possibilities:
       const size_type elemsbefore = static_cast(pos - old_start);
@@ -1734,20 +1782,20 @@ class vector : private container_detail::vector_alloc_holder
       const size_type before_plus_new = elemsbefore + n;
 
       //Update the vector buffer information to a safe state
-      this->members_.m_start      = new_start;
-      this->members_.m_capacity   = new_capacity;
-      this->members_.m_size = 0;
+      this->m_holder.m_start      = new_start;
+      this->m_holder.m_capacity   = new_capacity;
+      this->m_holder.m_size = 0;
 
       //If anything goes wrong, this object will destroy
       //all the old objects to fulfill previous vector state
-      typename value_traits::OldArrayDestructor old_values_destroyer(old_start, this->alloc(), old_size);
+      typename value_traits::OldArrayDestructor old_values_destroyer(old_start, this->m_holder.alloc(), old_size);
       //Check if s_before is big enough to hold the beginning of old data + new data
       if(s_before >= before_plus_new){
          //Copy first old values before pos, after that the new objects
-         T *const new_elem_pos = ::boost::container::uninitialized_move_alloc(this->alloc(), old_start, pos, new_start);
-         this->members_.m_size = elemsbefore;
+         T *const new_elem_pos = ::boost::container::uninitialized_move_alloc(this->m_holder.alloc(), old_start, pos, new_start);
+         this->m_holder.m_size = elemsbefore;
          insert_range_proxy.uninitialized_copy_n_and_update(new_elem_pos, n);
-         this->members_.m_size += n;
+         this->m_holder.m_size += n;
          //Check if s_before is so big that even copying the old data + new data
          //there is a gap between the new data and the old data
          const size_type new_size = old_size + n;
@@ -1764,9 +1812,9 @@ class vector : private container_detail::vector_alloc_holder
             //
             //Now initialize the rest of memory with the last old values
             ::boost::container::uninitialized_move_alloc
-               (this->alloc(), pos, old_finish, new_start + before_plus_new);
+               (this->m_holder.alloc(), pos, old_finish, new_start + before_plus_new);
             //All new elements correctly constructed, avoid new element destruction
-            this->members_.m_size = new_size;
+            this->m_holder.m_size = new_size;
             //Old values destroyed automatically with "old_values_destroyer"
             //when "old_values_destroyer" goes out of scope unless the have trivial
             //destructor after move.
@@ -1791,9 +1839,9 @@ class vector : private container_detail::vector_alloc_holder
             //Now initialize the rest of s_before memory with the
             //first of elements after new values
             ::boost::container::uninitialized_move_alloc_n
-               (this->alloc(), pos, raw_gap, new_start + before_plus_new);
+               (this->m_holder.alloc(), pos, raw_gap, new_start + before_plus_new);
             //Update size since we have a contiguous buffer
-            this->members_.m_size = old_size + s_before;
+            this->m_holder.m_size = old_size + s_before;
             //All new elements correctly constructed, avoid old element destruction
             old_values_destroyer.release();
             //Now copy remaining last objects in the old buffer begin
@@ -1802,8 +1850,8 @@ class vector : private container_detail::vector_alloc_holder
             //they have trivial destructor after move
             size_type n_destroy =  old_finish - to_destroy;
             if(!value_traits::trivial_dctr_after_move)
-               this->destroy_n(to_destroy, n_destroy);
-            this->members_.m_size -= n_destroy;
+               this->m_holder.destroy_n(to_destroy, n_destroy);
+            this->m_holder.m_size -= n_destroy;
          }
       }
       else{
@@ -1856,11 +1904,11 @@ class vector : private container_detail::vector_alloc_holder
             //
             //Copy the first part of old_begin to raw_mem
             ::boost::container::uninitialized_move_alloc_n
-               (this->alloc(), old_start, s_before, new_start);
+               (this->m_holder.alloc(), old_start, s_before, new_start);
             //The buffer is all constructed until old_end,
             //release destroyer and update size
             old_values_destroyer.release();
-            this->members_.m_size = old_size + s_before;
+            this->m_holder.m_size = old_size + s_before;
             //Now copy the second part of old_begin overwriting itself
             T *const next = ::boost::move(old_start + s_before, pos, old_start);
             if(do_after){
@@ -1876,8 +1924,8 @@ class vector : private container_detail::vector_alloc_holder
                //they have trivial destructor after being moved
                const size_type n_destroy = s_before - n;
                if(!value_traits::trivial_dctr_after_move)
-                  this->destroy_n(move_end, n_destroy);
-               this->members_.m_size -= n_destroy;
+                  this->m_holder.destroy_n(move_end, n_destroy);
+               this->m_holder.m_size -= n_destroy;
             }
          }
          else {
@@ -1908,13 +1956,13 @@ class vector : private container_detail::vector_alloc_holder
             //
             //First copy whole old_begin and part of new to raw_mem
             T * const new_pos = ::boost::container::uninitialized_move_alloc
-               (this->alloc(), old_start, pos, new_start);
-            this->members_.m_size = elemsbefore;
+               (this->m_holder.alloc(), old_start, pos, new_start);
+            this->m_holder.m_size = elemsbefore;
             const size_type mid_n = s_before - elemsbefore;
             insert_range_proxy.uninitialized_copy_n_and_update(new_pos, mid_n);
             //The buffer is all constructed until old_end,
             //release destroyer
-            this->members_.m_size = old_size + s_before;
+            this->m_holder.m_size = old_size + s_before;
             old_values_destroyer.release();
 
             if(do_after){
@@ -1932,8 +1980,8 @@ class vector : private container_detail::vector_alloc_holder
                //have trivial destructor after being moved
                size_type n_destroy = s_before - n;
                if(!value_traits::trivial_dctr_after_move)
-                  this->destroy_n(move_end, n_destroy);
-               this->members_.m_size -= n_destroy;
+                  this->m_holder.destroy_n(move_end, n_destroy);
+               this->m_holder.m_size -= n_destroy;
             }
          }
 
@@ -1976,8 +2024,8 @@ class vector : private container_detail::vector_alloc_holder
                //First copy the part of old_end raw_mem
                T* finish_n = old_finish - n_after;
                ::boost::container::uninitialized_move_alloc
-                  (this->alloc(), finish_n, old_finish, old_finish);
-               this->members_.m_size += n_after;
+                  (this->m_holder.alloc(), finish_n, old_finish, old_finish);
+               this->m_holder.m_size += n_after;
                //Displace the rest of old_end to the new position
                boost::move_backward(pos, finish_n, old_finish);
                //Now overwrite with new_end
@@ -2003,17 +2051,17 @@ class vector : private container_detail::vector_alloc_holder
 
                //Copy to the old_end part to the uninitialized zone leaving a gap.
                ::boost::container::uninitialized_move_alloc
-                  (this->alloc(), pos, old_finish, old_finish + mid_last_dist);
+                  (this->m_holder.alloc(), pos, old_finish, old_finish + mid_last_dist);
 
                BOOST_TRY{
                   //Copy the first part to the already constructed old_end zone
                   insert_range_proxy.copy_n_and_update(pos, elemsafter);
                   //Copy the rest to the uninitialized zone filling the gap
                   insert_range_proxy.uninitialized_copy_n_and_update(old_finish, mid_last_dist);
-                  this->members_.m_size += n_after;
+                  this->m_holder.m_size += n_after;
                }
                BOOST_CATCH(...){
-                  this->destroy_n(pos, mid_last_dist);
+                  this->m_holder.destroy_n(pos, mid_last_dist);
                   BOOST_RETHROW
                }
                BOOST_CATCH_END
@@ -2023,10 +2071,10 @@ class vector : private container_detail::vector_alloc_holder
 
                //The new_end part is [first + (n - n_after), last)
                insert_range_proxy.uninitialized_copy_last_and_update(old_finish, elemsafter);
-               this->members_.m_size += mid_last_dist;
+               this->m_holder.m_size += mid_last_dist;
                ::boost::container::uninitialized_move_alloc
-                  (this->alloc(), pos, old_finish, old_finish + mid_last_dist);
-               this->members_.m_size += n_after - mid_last_dist;
+                  (this->m_holder.alloc(), pos, old_finish, old_finish + mid_last_dist);
+               this->m_holder.m_size += n_after - mid_last_dist;
                //Now copy the part of new_end over constructed elements
                insert_range_proxy.copy_remaining_to(pos);*/
             }
@@ -2098,6 +2146,20 @@ struct has_trivial_destructor_after_move
 
 }
 
+//#define BOOST_CONTAINER_PUT_SWAP_OVERLOAD_IN_NAMESPACE_STD
+
+#ifdef BOOST_CONTAINER_PUT_SWAP_OVERLOAD_IN_NAMESPACE_STD
+
+namespace std {
+
+template 
+inline void swap(boost::container::vector& x, boost::container::vector& y)
+{  x.swap(y);  }
+
+}  //namespace std {
+
+#endif
+
 /// @endcond
 
 #include 

From e93994fb7242a3a014a3a84fdc3bf2be91d759fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Thu, 14 Feb 2013 19:43:13 +0000
Subject: [PATCH 73/93] Added uninitialized_default_alloc as current code
 didn't use allocator_traits

[SVN r82889]
---
 .../container/detail/advanced_insert_int.hpp  |  35 ++----
 include/boost/container/detail/utilities.hpp  | 115 ++++++++++++++----
 2 files changed, 103 insertions(+), 47 deletions(-)

diff --git a/include/boost/container/detail/advanced_insert_int.hpp b/include/boost/container/detail/advanced_insert_int.hpp
index 3cecc3f..0b09fdd 100644
--- a/include/boost/container/detail/advanced_insert_int.hpp
+++ b/include/boost/container/detail/advanced_insert_int.hpp
@@ -37,15 +37,15 @@ struct move_insert_range_proxy
       :  a_(a), first_(first)
    {}
 
-   void uninitialized_copy_n_and_update(Iterator pos, size_type n)
+   void uninitialized_copy_n_and_update(Iterator p, size_type n)
    {
       this->first_ = ::boost::container::uninitialized_move_alloc_n_source
-         (this->a_, this->first_, n, pos);
+         (this->a_, this->first_, n, p);
    }
 
-   void copy_n_and_update(Iterator pos, size_type n)
+   void copy_n_and_update(Iterator p, size_type n)
    {
-      this->first_ = ::boost::container::move_n_source(this->first_, n, pos);
+      this->first_ = ::boost::container::move_n_source(this->first_, n, p);
    }
 
    A &a_;
@@ -63,15 +63,15 @@ struct insert_range_proxy
       :  a_(a), first_(first)
    {}
 
-   void uninitialized_copy_n_and_update(Iterator pos, size_type n)
+   void uninitialized_copy_n_and_update(Iterator p, size_type n)
    {
       this->first_ = ::boost::container::uninitialized_copy_or_move_alloc_n_source
-         (this->a_, this->first_, n, pos);
+         (this->a_, this->first_, n, p);
    }
 
-   void copy_n_and_update(Iterator pos, size_type n)
+   void copy_n_and_update(Iterator p, size_type n)
    {
-      this->first_ = ::boost::container::copy_or_move_n_source(this->first_, n, pos);
+      this->first_ = ::boost::container::copy_or_move_n_source(this->first_, n, p);
    }
 
    A &a_;
@@ -90,7 +90,7 @@ struct insert_n_copies_proxy
    {}
 
    void uninitialized_copy_n_and_update(Iterator p, size_type n)
-   {  std::uninitialized_fill_n(p, n, v_);   }
+   {  boost::container::uninitialized_fill_alloc_n(this->a_, v_, n, p);  }
 
    void copy_n_and_update(Iterator p, size_type n)
    {  std::fill_n(p, n, v_);  }
@@ -112,22 +112,7 @@ struct insert_default_constructed_n_proxy
    {}
 
    void uninitialized_copy_n_and_update(Iterator p, size_type n)
-   {
-      Iterator orig_p = p;
-      size_type n_left = n;
-      BOOST_TRY{
-         for(; n_left--; ++p){
-            alloc_traits::construct(this->a_, container_detail::to_raw_pointer(&*p));
-         }
-      }
-      BOOST_CATCH(...){
-         for(; orig_p != p; ++orig_p){
-            alloc_traits::destroy(this->a_, container_detail::to_raw_pointer(&*orig_p++));
-         }
-         BOOST_RETHROW
-      }
-      BOOST_CATCH_END
-   }
+   {  boost::container::uninitialized_default_alloc_n(this->a_, n, p);  }
 
    void copy_n_and_update(Iterator, size_type)
    {
diff --git a/include/boost/container/detail/utilities.hpp b/include/boost/container/detail/utilities.hpp
index d9905ce..23489db 100644
--- a/include/boost/container/detail/utilities.hpp
+++ b/include/boost/container/detail/utilities.hpp
@@ -136,11 +136,11 @@ struct ct_rounded_size
 
 //! Effects:
 //!   \code
-//!   for (; first != last; ++result, ++first)
-//!      allocator_traits::construct(a, &*result, boost::move(*first));
+//!   for (; f != l; ++r, ++f)
+//!      allocator_traits::construct(a, &*r, boost::move(*f));
 //!   \endcode
 //!
-//! Returns: result
+//! Returns: r
 template
    Effects:
 //!   \code
-//!   for (; n--; ++result, ++first)
-//!      allocator_traits::construct(a, &*result, boost::move(*first));
+//!   for (; n--; ++r, ++f)
+//!      allocator_traits::construct(a, &*r, boost::move(*f));
 //!   \endcode
 //!
-//! Returns: result
+//! Returns: r
 template
    ::differ
 
 //! Effects:
 //!   \code
-//!   for (; n--; ++result, ++first)
-//!      allocator_traits::construct(a, &*result, boost::move(*first));
+//!   for (; n--; ++r, ++f)
+//!      allocator_traits::construct(a, &*r, boost::move(*f));
 //!   \endcode
 //!
-//! Returns: first (after incremented)
+//! Returns: f (after incremented)
 template
    :
 
 //! Effects:
 //!   \code
-//!   for (; first != last; ++result, ++first)
-//!      allocator_traits::construct(a, &*result, *first);
+//!   for (; f != l; ++r, ++f)
+//!      allocator_traits::construct(a, &*r, *f);
 //!   \endcode
 //!
-//! Returns: result
+//! Returns: r
 template
    Effects:
 //!   \code
-//!   for (; n--; ++result, ++first)
-//!      allocator_traits::construct(a, &*result, *first);
+//!   for (; n--; ++r, ++f)
+//!      allocator_traits::construct(a, &*r, *f);
 //!   \endcode
 //!
-//! Returns: result
+//! Returns: r
 template
    ::differ
 
 //! Effects:
 //!   \code
-//!   for (; n--; ++result, ++first)
-//!      allocator_traits::construct(a, &*result, *first);
+//!   for (; n--; ++r, ++f)
+//!      allocator_traits::construct(a, &*r, *f);
 //!   \endcode
 //!
-//! Returns: first (after incremented)
+//! Returns: f (after incremented)
 template
    :
 
 //! Effects:
 //!   \code
-//!   for (; first != last; ++result, ++first)
-//!      allocator_traits::construct(a, &*result, *first);
+//!   for (; f != l; ++r, ++f)
+//!      allocator_traits::construct(a, &*r, *f);
 //!   \endcode
 //!
-//! Returns: result
+//! Returns: r
 template
    Effects:
+//!   \code
+//!   for (; n--; ++r, ++f)
+//!      allocator_traits::construct(a, &*r);
+//!   \endcode
+//!
+//! Returns: r
+template
+    // F models ForwardIterator
+F uninitialized_default_alloc_n(A &a, typename allocator_traits::difference_type n, F r)
+{
+   F back = r;
+   BOOST_TRY{
+      while (n--) {
+         allocator_traits::construct(a, container_detail::to_raw_pointer(&*r));
+         ++r;
+      }
+   }
+   BOOST_CATCH(...){
+	   for (; back != r; ++back){
+         allocator_traits::destroy(a, container_detail::to_raw_pointer(&*back));
+      }
+	   BOOST_RETHROW;
+   }
+   BOOST_CATCH_END
+   return r;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//                               uninitialized_fill_alloc_n
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//! Effects:
+//!   \code
+//!   for (; n--; ++r, ++f)
+//!      allocator_traits::construct(a, &*r, v);
+//!   \endcode
+//!
+//! Returns: r
+template
+    // F models ForwardIterator
+F uninitialized_fill_alloc_n(A &a, const T &v, typename allocator_traits::difference_type n, F r)
+{
+   F back = r;
+   BOOST_TRY{
+      while (n--) {
+         allocator_traits::construct(a, container_detail::to_raw_pointer(&*r), v);
+         ++r;
+      }
+   }
+   BOOST_CATCH(...){
+	   for (; back != r; ++back){
+         allocator_traits::destroy(a, container_detail::to_raw_pointer(&*back));
+      }
+	   BOOST_RETHROW;
+   }
+   BOOST_CATCH_END
+   return r;
+}
+
 //////////////////////////////////////////////////////////////////////////////
 //
 //                         copy_or_move
@@ -631,7 +703,6 @@ inline I move_n_source(I f, typename std::iterator_traits::difference_type n,
 }  //namespace container {
 }  //namespace boost {
 
-
 #include 
 
 #endif   //#ifndef BOOST_CONTAINER_DETAIL_UTILITIES_HPP

From f309f82a8f6fd1a3603f912fc62e7deb417dcfad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Tue, 19 Feb 2013 21:35:46 +0000
Subject: [PATCH 74/93] Added experimental static_vector first sketch

[SVN r83036]
---
 include/boost/container/detail/utilities.hpp |   53 +
 include/boost/container/static_vector.hpp    | 1040 ++++++++++++++++++
 include/boost/container/vector.hpp           |  834 +++++++++-----
 proj/vc7ide/static_vector_test.vcproj        |  139 +++
 test/movable.hpp                             |   92 ++
 test/static_vector_test.cpp                  |  803 ++++++++++++++
 test/static_vector_test.hpp                  |   99 ++
 7 files changed, 2805 insertions(+), 255 deletions(-)
 create mode 100644 include/boost/container/static_vector.hpp
 create mode 100644 proj/vc7ide/static_vector_test.vcproj
 create mode 100644 test/movable.hpp
 create mode 100644 test/static_vector_test.cpp
 create mode 100644 test/static_vector_test.hpp

diff --git a/include/boost/container/detail/utilities.hpp b/include/boost/container/detail/utilities.hpp
index 23489db..02141a4 100644
--- a/include/boost/container/detail/utilities.hpp
+++ b/include/boost/container/detail/utilities.hpp
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -700,6 +701,58 @@ inline I move_n_source(I f, typename std::iterator_traits::difference_type n,
    return f;
 }
 
+//////////////////////////////////////////////////////////////////////////////
+//
+//                         destroy_n
+//
+//////////////////////////////////////////////////////////////////////////////
+
+template
+     // I models InputIterator
+inline void destroy_alloc_n(A &a, I f, typename std::iterator_traits::difference_type n
+   ,typename boost::container::container_detail::enable_if_c
+      < !boost::has_trivial_destructor::value_type>::value >::type* = 0)
+{
+   while(n--){
+      allocator_traits::destroy(a, container_detail::addressof(*f++));
+   }
+}
+
+template
+     // I models InputIterator
+inline void destroy_alloc_n(A &, I, typename std::iterator_traits::difference_type
+   ,typename boost::container::container_detail::enable_if_c
+      < boost::has_trivial_destructor::value_type>::value >::type* = 0)
+{}
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//                         deep_swap_alloc_n
+//
+//////////////////////////////////////////////////////////////////////////////
+
+template
+     
+void deep_swap_alloc_n(A &a, F short_range_f, typename allocator_traits::size_type n_i
+                      , G large_range_f, typename allocator_traits::size_type n_j)
+{
+   typename allocator_traits::size_type n = 0;
+   typedef typename allocator_traits::value_type value_type;
+   for (; n != n_i ; ++short_range_f, ++large_range_f, ++n){
+      //boost::swap(*first_sm, *first_la);            // may throw
+      value_type temp(boost::move(*short_range_f));   // may throw
+      *short_range_f = boost::move(*large_range_f);   // may throw
+      *large_range_f = boost::move(temp);             // may throw
+   }
+   uninitialized_move_alloc_n(a, large_range_f, n_j - n, short_range_f);  // may throw
+   destroy_alloc_n(a, large_range_f, n_j - n);
+}
+
 }  //namespace container {
 }  //namespace boost {
 
diff --git a/include/boost/container/static_vector.hpp b/include/boost/container/static_vector.hpp
new file mode 100644
index 0000000..428c7de
--- /dev/null
+++ b/include/boost/container/static_vector.hpp
@@ -0,0 +1,1040 @@
+// Boost.Container static_vector
+//
+// Copyright (c) 2012-2013 Adam Wulkiewicz, Lodz, Poland.
+// Copyright (c) 2011-2013 Andrew Hundt.
+//
+// Use, modification and distribution is subject to 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)
+
+#ifndef BOOST_CONTAINER_STATIC_VECTOR_HPP
+#define BOOST_CONTAINER_STATIC_VECTOR_HPP
+
+#if (defined _MSC_VER) && (_MSC_VER >= 1200)
+#  pragma once
+#endif
+
+#include 
+
+#include 
+#include 
+
+namespace boost { namespace container {
+
+/**
+ * @defgroup static_vector_non_member static_vector non-member functions
+ */
+
+/**
+ * @brief A variable-size array container with fixed capacity.
+ *
+ * static_vector is a sequence container like boost::container::vector with contiguous storage that can
+ * change in size, along with the static allocation, low overhead, and fixed capacity of boost::array.
+ *
+ * A static_vector is a sequence that supports random access to elements, constant time insertion and
+ * removal of elements at the end, and linear time insertion and removal of elements at the beginning or 
+ * in the middle. The number of elements in a static_vector may vary dynamically up to a fixed capacity
+ * because elements are stored within the object itself similarly to an array. However, objects are 
+ * initialized as they are inserted into static_vector unlike C arrays or std::array which must construct
+ * all elements on instantiation. The behavior of static_vector enables the use of statically allocated
+ * elements in cases with complex object lifetime requirements that would otherwise not be trivially 
+ * possible.
+ *
+ * @par Error Handling
+ *  Insertion beyond the capacity and out of bounds errors results in calling throw_bad_alloc().
+ *  The reason for this is because unlike vectors, static_vector does not perform allocation.
+ *
+ * @tparam Value    The type of element that will be stored.
+ * @tparam Capacity The maximum number of elements static_vector can store, fixed at compile time.
+ */
+
+
+namespace container_detail {
+
+template
+class static_storage_allocator
+{
+   public:
+   typedef T value_type;
+
+   T* internal_storage() const
+   {  return const_cast(static_cast(static_cast(&storage)));  }
+
+   T* internal_storage()
+   {  return static_cast(static_cast(&storage));  }
+
+   static const std::size_t internal_capacity = N;
+
+   typedef boost::container::container_detail::version_type   version;
+
+   friend bool operator==(const static_storage_allocator &, const static_storage_allocator &)
+   {  return false;  }
+
+   friend bool operator!=(const static_storage_allocator &, const static_storage_allocator &)
+   {  return true;  }
+
+   private:
+   typename boost::aligned_storage
+      ::value>::type storage;
+};
+
+}  //namespace container_detail {
+
+
+template 
+class static_vector
+    : public vector >
+{
+    typedef vector > base_t;
+
+    BOOST_COPYABLE_AND_MOVABLE(static_vector)
+
+   template
+   friend class static_vector;
+
+public:
+    //! @brief The type of elements stored in the container.
+    typedef typename base_t::value_type value_type;
+    //! @brief The unsigned integral type used by the container.
+    typedef typename base_t::size_type size_type;
+    //! @brief The pointers difference type.
+    typedef typename base_t::difference_type difference_type;
+    //! @brief The pointer type.
+    typedef typename base_t::pointer pointer;
+    //! @brief The const pointer type.
+    typedef typename base_t::const_pointer const_pointer;
+    //! @brief The value reference type.
+    typedef typename base_t::reference reference;
+    //! @brief The value const reference type.
+    typedef typename base_t::const_reference const_reference;
+    //! @brief The iterator type.
+    typedef typename base_t::iterator iterator;
+    //! @brief The const iterator type.
+    typedef typename base_t::const_iterator const_iterator;
+    //! @brief The reverse iterator type.
+    typedef typename base_t::reverse_iterator reverse_iterator;
+    //! @brief The const reverse iterator.
+    typedef typename base_t::const_reverse_iterator const_reverse_iterator;
+
+    //! @brief Constructs an empty static_vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    static_vector()
+        : base_t()
+    {}
+
+    //! @pre count <= capacity()
+    //!
+    //! @brief Constructs a static_vector containing count default constructed Values.
+    //!
+    //! @param count    The number of values which will be contained in the container.
+    //!
+    //! @par Throws
+    //!   If Value's default constructor throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    explicit static_vector(size_type count)
+        : base_t(count)
+    {}
+
+    //! @pre count <= capacity()
+    //!
+    //! @brief Constructs a static_vector containing count copies of value.
+    //!
+    //! @param count    The number of copies of a values that will be contained in the container.
+    //! @param value    The value which will be used to copy construct values.
+    //!
+    //! @par Throws
+    //!   If Value's copy constructor throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    static_vector(size_type count, value_type const& value)
+        : base_t(count, value)
+    {}
+
+    //! @pre
+    //!  @li distance(first, last) <= capacity()
+    //!  @li Iterator must meet the \c ForwardTraversalIterator concept.
+    //!
+    //! @brief Constructs a static_vector containing copy of a range [first, last).
+    //!
+    //! @param first    The iterator to the first element in range.
+    //! @param last     The iterator to the one after the last element in range.
+    //!
+    //! @par Throws
+    //!   If Value's constructor taking a dereferenced Iterator throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    template 
+    static_vector(Iterator first, Iterator last)
+        : base_t(first, last)
+    {}
+
+    //! @brief Constructs a copy of other static_vector.
+    //!
+    //! @param other    The static_vector which content will be copied to this one.
+    //!
+    //! @par Throws
+    //!   If Value's copy constructor throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    static_vector(static_vector const& other)
+        : base_t(other)
+    {}
+
+    //! @pre other.size() <= capacity().
+    //!
+    //! @brief Constructs a copy of other static_vector.
+    //!
+    //! @param other    The static_vector which content will be copied to this one.
+    //!
+    //! @par Throws
+    //!   If Value's copy constructor throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    template 
+    static_vector(static_vector const& other) : base_t(other) {}
+
+    //! @brief Copy assigns Values stored in the other static_vector to this one.
+    //!
+    //! @param other    The static_vector which content will be copied to this one.
+    //!
+    //! @par Throws
+    //!   If Value's copy constructor or copy assignment throws.
+    //!
+    //! @par Complexity
+    //! Linear O(N).
+    static_vector & operator=(BOOST_COPY_ASSIGN_REF(static_vector) other)
+    {
+        base_t::operator=(static_cast(other));
+        return *this;
+    }
+
+    //! @pre other.size() <= capacity()
+    //!
+    //! @brief Copy assigns Values stored in the other static_vector to this one.
+    //!
+    //! @param other    The static_vector which content will be copied to this one.
+    //!
+    //! @par Throws
+    //!   If Value's copy constructor or copy assignment throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    template 
+// TEMPORARY WORKAROUND
+#if defined(BOOST_NO_RVALUE_REFERENCES)
+    static_vector & operator=(::boost::rv< static_vector > const& other)
+#else
+    static_vector & operator=(static_vector const& other)
+#endif
+    {
+        base_t::operator=(static_cast const&>(other));
+        return *this;
+    }
+
+    //! @brief Move constructor. Moves Values stored in the other static_vector to this one.
+    //!
+    //! @param other    The static_vector which content will be moved to this one.
+    //!
+    //! @par Throws
+    //!   @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor throws.
+    //!   @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    static_vector(BOOST_RV_REF(static_vector) other)
+        : base_t(boost::move(static_cast(other)))
+    {}
+
+    //! @pre other.size() <= capacity()
+    //!
+    //! @brief Move constructor. Moves Values stored in the other static_vector to this one.
+    //!
+    //! @param other    The static_vector which content will be moved to this one.
+    //!
+    //! @par Throws
+    //!   @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor throws.
+    //!   @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    template 
+    static_vector(BOOST_RV_REF_BEG static_vector BOOST_RV_REF_END other)
+        : base_t(boost::move(static_cast::base_t&>(other)))
+    {}
+
+    //! @brief Move assignment. Moves Values stored in the other static_vector to this one.
+    //!
+    //! @param other    The static_vector which content will be moved to this one.
+    //!
+    //! @par Throws
+    //!   @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor or move assignment throws.
+    //!   @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    static_vector & operator=(BOOST_RV_REF(static_vector) other)
+    {
+        base_t::operator=(boost::move(static_cast(other)));
+        return *this;
+    }
+
+    //! @pre other.size() <= capacity()
+    //!
+    //! @brief Move assignment. Moves Values stored in the other static_vector to this one.
+    //!
+    //! @param other    The static_vector which content will be moved to this one.
+    //!
+    //! @par Throws
+    //!   @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor or move assignment throws.
+    //!   @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    template 
+    static_vector & operator=(BOOST_RV_REF_BEG static_vector BOOST_RV_REF_END other)
+    {
+        base_t::operator=(boost::move(static_cast::base_t&>(other)));
+        return *this;
+    }
+
+#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
+
+    //! @brief Destructor. Destroys Values stored in this container.
+    //!
+    //! @par Throws
+    //!   Nothing
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    ~static_vector();
+
+    //! @brief Swaps contents of the other static_vector and this one.
+    //!
+    //! @param other    The static_vector which content will be swapped with this one's content.
+    //!
+    //! @par Throws
+    //!   @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor or move assignment throws,
+    //!   @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws,
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    void swap(static_vector & other);
+
+    //! @pre other.size() <= capacity() && size() <= other.capacity()
+    //!
+    //! @brief Swaps contents of the other static_vector and this one.
+    //!
+    //! @param other    The static_vector which content will be swapped with this one's content.
+    //!
+    //! @par Throws
+    //!   @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor or move assignment throws,
+    //!   @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws,
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    template 
+    void swap(static_vector & other);
+
+    //! @pre count <= capacity()
+    //!
+    //! @brief Inserts or erases elements at the end such that
+    //!   the size becomes count. New elements are default constructed.
+    //!
+    //! @param count    The number of elements which will be stored in the container.
+    //!
+    //! @par Throws
+    //!   If Value's default constructor throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    void resize(size_type count);
+
+    //! @pre count <= capacity()
+    //!
+    //! @brief Inserts or erases elements at the end such that
+    //!   the size becomes count. New elements are copy constructed from value.
+    //!
+    //! @param count    The number of elements which will be stored in the container.
+    //! @param value    The value used to copy construct the new element.
+    //!
+    //! @par Throws
+    //!   If Value's copy constructor throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    void resize(size_type count, value_type const& value);
+
+    //! @pre count <= capacity()
+    //!
+    //! @brief This call has no effect because the Capacity of this container is constant.
+    //!
+    //! @param count    The number of elements which the container should be able to contain.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    void reserve(size_type count);
+
+    //! @pre size() < capacity()
+    //!
+    //! @brief Adds a copy of value at the end.
+    //!
+    //! @param value    The value used to copy construct the new element.
+    //!
+    //! @par Throws
+    //!   If Value's copy constructor throws.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    void push_back(value_type const& value);
+
+    //! @pre size() < capacity()
+    //!
+    //! @brief Moves value to the end.
+    //!
+    //! @param value    The value to move construct the new element.
+    //!
+    //! @par Throws
+    //!   If Value's move constructor throws.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    void push_back(BOOST_RV_REF(value_type) value);
+
+    //! @pre !empty()
+    //!
+    //! @brief Destroys last value and decreases the size.
+    //!
+    //! @par Throws
+    //!   Nothing by default.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    void pop_back();
+
+    //! @pre
+    //!  @li \c position must be a valid iterator of \c *this in range [begin(), end()].
+    //!  @li size() < capacity()
+    //!
+    //! @brief Inserts a copy of element at position.
+    //!
+    //! @param position    The position at which the new value will be inserted.
+    //! @param value       The value used to copy construct the new element.
+    //!
+    //! @par Throws
+    //!   @li If Value's copy constructor or copy assignment throws
+    //!   @li If Value's move constructor or move assignment throws.
+    //!
+    //! @par Complexity
+    //!   Constant or linear.
+    iterator insert(iterator position, value_type const& value);
+
+    //! @pre
+    //!  @li \c position must be a valid iterator of \c *this in range [begin(), end()].
+    //!  @li size() < capacity()
+    //!
+    //! @brief Inserts a move-constructed element at position.
+    //!
+    //! @param position    The position at which the new value will be inserted.
+    //! @param value       The value used to move construct the new element.
+    //!
+    //! @par Throws
+    //!   If Value's move constructor or move assignment throws.
+    //!
+    //! @par Complexity
+    //!   Constant or linear.
+    iterator insert(iterator position, BOOST_RV_REF(value_type) value);
+
+    //! @pre
+    //!  @li \c position must be a valid iterator of \c *this in range [begin(), end()].
+    //!  @li size() + count <= capacity()
+    //!
+    //! @brief Inserts a count copies of value at position.
+    //!
+    //! @param position    The position at which new elements will be inserted.
+    //! @param count       The number of new elements which will be inserted.
+    //! @param value       The value used to copy construct new elements.
+    //!
+    //! @par Throws
+    //!   @li If Value's copy constructor or copy assignment throws.
+    //!   @li If Value's move constructor or move assignment throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    iterator insert(iterator position, size_type count, value_type const& value);
+
+    //! @pre
+    //!  @li \c position must be a valid iterator of \c *this in range [begin(), end()].
+    //!  @li distance(first, last) <= capacity()
+    //!  @li \c Iterator must meet the \c ForwardTraversalIterator concept.
+    //!
+    //! @brief Inserts a copy of a range [first, last) at position.
+    //!
+    //! @param position    The position at which new elements will be inserted.
+    //! @param first       The iterator to the first element of a range used to construct new elements.
+    //! @param last        The iterator to the one after the last element of a range used to construct new elements.
+    //!
+    //! @par Throws
+    //!   @li If Value's constructor and assignment taking a dereferenced \c Iterator.
+    //!   @li If Value's move constructor or move assignment throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    template 
+    iterator insert(iterator position, Iterator first, Iterator last);
+
+    //! @pre \c position must be a valid iterator of \c *this in range [begin(), end())
+    //!
+    //! @brief Erases Value from position.
+    //!
+    //! @param position    The position of the element which will be erased from the container.
+    //!
+    //! @par Throws
+    //!   If Value's move assignment throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    iterator erase(iterator position);
+
+    //! @pre
+    //!  @li \c first and \c last must define a valid range
+    //!  @li iterators must be in range [begin(), end()]
+    //!
+    //! @brief Erases Values from a range [first, last).
+    //!
+    //! @param first    The position of the first element of a range which will be erased from the container.
+    //! @param last     The position of the one after the last element of a range which will be erased from the container.
+    //!
+    //! @par Throws
+    //!   If Value's move assignment throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    iterator erase(iterator first, iterator last);
+
+    //! @pre distance(first, last) <= capacity()
+    //!
+    //! @brief Assigns a range [first, last) of Values to this container.
+    //!
+    //! @param first       The iterator to the first element of a range used to construct new content of this container.
+    //! @param last        The iterator to the one after the last element of a range used to construct new content of this container.
+    //!
+    //! @par Throws
+    //!   If Value's copy constructor or copy assignment throws,
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    template 
+    void assign(Iterator first, Iterator last);
+
+    //! @pre count <= capacity()
+    //!
+    //! @brief Assigns a count copies of value to this container.
+    //!
+    //! @param count       The new number of elements which will be container in the container.
+    //! @param value       The value which will be used to copy construct the new content.
+    //!
+    //! @par Throws
+    //!   If Value's copy constructor or copy assignment throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    void assign(size_type count, value_type const& value);
+
+    //! @pre size() < capacity()
+    //!
+    //! @brief Inserts a Value constructed with
+    //!   \c std::forward(args)... in the end of the container.
+    //!
+    //! @param args     The arguments of the constructor of the new element which will be created at the end of the container.
+    //!
+    //! @par Throws
+    //!   If in-place constructor throws or Value's move constructor throws.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    template
+    void emplace_back(Args &&...args);
+
+    //! @pre
+    //!  @li \c position must be a valid iterator of \c *this in range [begin(), end()]
+    //!  @li size() < capacity()
+    //!
+    //! @brief Inserts a Value constructed with
+    //!   \c std::forward(args)... before position
+    //!
+    //! @param position The position at which new elements will be inserted.
+    //! @param args     The arguments of the constructor of the new element.
+    //!
+    //! @par Throws
+    //!   If in-place constructor throws or if Value's move constructor or move assignment throws.
+    //!
+    //! @par Complexity
+    //!   Constant or linear.
+    template
+    iterator emplace(iterator position, Args &&...args);
+
+    //! @brief Removes all elements from the container.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    void clear();
+
+    //! @pre i < size()
+    //!
+    //! @brief Returns reference to the i-th element.
+    //!
+    //! @param i    The element's index.
+    //!
+    //! @return reference to the i-th element
+    //!   from the beginning of the container.
+    //!
+    //! @par Throws
+    //!   \c std::out_of_range exception by default.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    reference at(size_type i);
+
+    //! @pre i < size()
+    //!
+    //! @brief Returns const reference to the i-th element.
+    //!
+    //! @param i    The element's index.
+    //!
+    //! @return const reference to the i-th element
+    //!   from the beginning of the container.
+    //!
+    //! @par Throws
+    //!   \c std::out_of_range exception by default.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_reference at(size_type i) const;
+
+    //! @pre i < size()
+    //!
+    //! @brief Returns reference to the i-th element.
+    //!
+    //! @param i    The element's index.
+    //!
+    //! @return reference to the i-th element
+    //!   from the beginning of the container.
+    //!
+    //! @par Throws
+    //!   Nothing by default.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    reference operator[](size_type i);
+
+    //! @pre i < size()
+    //!
+    //! @brief Returns const reference to the i-th element.
+    //!
+    //! @param i    The element's index.
+    //!
+    //! @return const reference to the i-th element
+    //!   from the beginning of the container.
+    //!
+    //! @par Throws
+    //!   Nothing by default.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_reference operator[](size_type i) const;
+
+    //! @pre \c !empty()
+    //!
+    //! @brief Returns reference to the first element.
+    //!
+    //! @return reference to the first element
+    //!   from the beginning of the container.
+    //!
+    //! @par Throws
+    //!   Nothing by default.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    reference front();
+
+    //! @pre \c !empty()
+    //!
+    //! @brief Returns const reference to the first element.
+    //!
+    //! @return const reference to the first element
+    //!   from the beginning of the container.
+    //!
+    //! @par Throws
+    //!   Nothing by default.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_reference front() const;
+
+    //! @pre \c !empty()
+    //!
+    //! @brief Returns reference to the last element.
+    //!
+    //! @return reference to the last element
+    //!   from the beginning of the container.
+    //!
+    //! @par Throws
+    //!   Nothing by default.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    reference back();
+
+    //! @pre \c !empty()
+    //!
+    //! @brief Returns const reference to the first element.
+    //!
+    //! @return const reference to the last element
+    //!   from the beginning of the container.
+    //!
+    //! @par Throws
+    //!   Nothing by default.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_reference back() const;
+
+    //! @brief Pointer such that [data(), data() + size()) is a valid range.
+    //!   For a non-empty vector data() == &front().
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    Value * data();
+
+    //! @brief Const pointer such that [data(), data() + size()) is a valid range.
+    //!   For a non-empty vector data() == &front().
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const Value * data() const;
+
+    //! @brief Returns iterator to the first element.
+    //!
+    //! @return iterator to the first element contained in the vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    iterator begin();
+
+    //! @brief Returns const iterator to the first element.
+    //!
+    //! @return const_iterator to the first element contained in the vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_iterator begin() const;
+
+    //! @brief Returns const iterator to the first element.
+    //!
+    //! @return const_iterator to the first element contained in the vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_iterator cbegin() const;
+
+    //! @brief Returns iterator to the one after the last element.
+    //!
+    //! @return iterator pointing to the one after the last element contained in the vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    iterator end();
+
+    //! @brief Returns const iterator to the one after the last element.
+    //!
+    //! @return const_iterator pointing to the one after the last element contained in the vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_iterator end() const;
+
+    //! @brief Returns const iterator to the one after the last element.
+    //!
+    //! @return const_iterator pointing to the one after the last element contained in the vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_iterator cend() const;
+
+    //! @brief Returns reverse iterator to the first element of the reversed container.
+    //!
+    //! @return reverse_iterator pointing to the beginning
+    //! of the reversed static_vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    reverse_iterator rbegin();
+
+    //! @brief Returns const reverse iterator to the first element of the reversed container.
+    //!
+    //! @return const_reverse_iterator pointing to the beginning
+    //! of the reversed static_vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_reverse_iterator rbegin() const;
+
+    //! @brief Returns const reverse iterator to the first element of the reversed container.
+    //!
+    //! @return const_reverse_iterator pointing to the beginning
+    //! of the reversed static_vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_reverse_iterator crbegin() const;
+
+    //! @brief Returns reverse iterator to the one after the last element of the reversed container.
+    //!
+    //! @return reverse_iterator pointing to the one after the last element
+    //! of the reversed static_vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    reverse_iterator rend();
+
+    //! @brief Returns const reverse iterator to the one after the last element of the reversed container.
+    //!
+    //! @return const_reverse_iterator pointing to the one after the last element
+    //! of the reversed static_vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_reverse_iterator rend() const;
+
+    //! @brief Returns const reverse iterator to the one after the last element of the reversed container.
+    //!
+    //! @return const_reverse_iterator pointing to the one after the last element
+    //! of the reversed static_vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_reverse_iterator crend() const;
+
+    //! @brief Returns container's capacity.
+    //!
+    //! @return container's capacity.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    static size_type capacity();
+
+    //! @brief Returns container's capacity.
+    //!
+    //! @return container's capacity.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    static size_type max_size();
+
+    //! @brief Returns the number of stored elements.
+    //!
+    //! @return Number of elements contained in the container.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    size_type size() const;
+
+    //! @brief Queries if the container contains elements.
+    //!
+    //! @return true if the number of elements contained in the
+    //!   container is equal to 0.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    bool empty() const;
+
+#endif // BOOST_CONTAINER_DOXYGEN_INVOKED
+
+};
+
+#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
+
+//! @brief Checks if contents of two static_vectors are equal.
+//!
+//! @ingroup static_vector_non_member
+//!
+//! @param x    The first static_vector.
+//! @param y    The second static_vector.
+//!
+//! @return     \c true if containers have the same size and elements in both containers are equal.
+//!
+//! @par Complexity
+//!   Linear O(N).
+template
+bool operator== (static_vector const& x, static_vector const& y);
+
+//! @brief Checks if contents of two static_vectors are not equal.
+//!
+//! @ingroup static_vector_non_member
+//!
+//! @param x    The first static_vector.
+//! @param y    The second static_vector.
+//!
+//! @return     \c true if containers have different size or elements in both containers are not equal.
+//!
+//! @par Complexity
+//!   Linear O(N).
+template
+bool operator!= (static_vector const& x, static_vector const& y);
+
+//! @brief Lexicographically compares static_vectors.
+//!
+//! @ingroup static_vector_non_member
+//!
+//! @param x    The first static_vector.
+//! @param y    The second static_vector.
+//!
+//! @return     \c true if x compares lexicographically less than y.
+//!
+//! @par Complexity
+//!   Linear O(N).
+template
+bool operator< (static_vector const& x, static_vector const& y);
+
+//! @brief Lexicographically compares static_vectors.
+//!
+//! @ingroup static_vector_non_member
+//!
+//! @param x    The first static_vector.
+//! @param y    The second static_vector.
+//!
+//! @return     \c true if y compares lexicographically less than x.
+//!
+//! @par Complexity
+//!   Linear O(N).
+template
+bool operator> (static_vector const& x, static_vector const& y);
+
+//! @brief Lexicographically compares static_vectors.
+//!
+//! @ingroup static_vector_non_member
+//!
+//! @param x    The first static_vector.
+//! @param y    The second static_vector.
+//!
+//! @return     \c true if y don't compare lexicographically less than x.
+//!
+//! @par Complexity
+//!   Linear O(N).
+template
+bool operator<= (static_vector const& x, static_vector const& y);
+
+//! @brief Lexicographically compares static_vectors.
+//!
+//! @ingroup static_vector_non_member
+//!
+//! @param x    The first static_vector.
+//! @param y    The second static_vector.
+//!
+//! @return     \c true if x don't compare lexicographically less than y.
+//!
+//! @par Complexity
+//!   Linear O(N).
+template
+bool operator>= (static_vector const& x, static_vector const& y);
+
+//! @brief Swaps contents of two static_vectors.
+//!
+//! This function calls static_vector::swap().
+//!
+//! @ingroup static_vector_non_member
+//!
+//! @param x    The first static_vector.
+//! @param y    The second static_vector.
+//!
+//! @par Complexity
+//!   Linear O(N).
+template
+inline void swap(static_vector & x, static_vector & y);
+
+#else
+
+template
+inline void swap(static_vector & x, static_vector & y)
+{
+   x.swap(y);
+}
+
+#endif // BOOST_CONTAINER_DOXYGEN_INVOKED
+
+}} // namespace boost::container
+
+#include 
+
+#endif // BOOST_CONTAINER_STATIC_VECTOR_HPP
diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp
index 37fdc2a..859445c 100644
--- a/include/boost/container/vector.hpp
+++ b/include/boost/container/vector.hpp
@@ -74,7 +74,10 @@ class vector_const_iterator
    Pointer m_ptr;
 
    public:
-   Pointer get_ptr() const BOOST_CONTAINER_NOEXCEPT
+   const Pointer &get_ptr() const BOOST_CONTAINER_NOEXCEPT
+   {  return   m_ptr;  }
+
+   Pointer &get_ptr() BOOST_CONTAINER_NOEXCEPT
    {  return   m_ptr;  }
 
    explicit vector_const_iterator(Pointer ptr) BOOST_CONTAINER_NOEXCEPT
@@ -247,7 +250,12 @@ struct vector_value_traits
 };
 
 //!This struct deallocates and allocated memory
-template 
+template < class Allocator
+         , class AllocatorVersion = container_detail::integral_constant
+            < unsigned
+            , boost::container::container_detail::version::value
+            >
+         >
 struct vector_alloc_holder
    : public Allocator
 {
@@ -259,11 +267,6 @@ struct vector_alloc_holder
    typedef typename allocator_traits_type::pointer       pointer;
    typedef typename allocator_traits_type::size_type     size_type;
    typedef typename allocator_traits_type::value_type    value_type;
-   typedef vector_value_traits    value_traits;
-   typedef container_detail::integral_constant      allocator_v1;
-   typedef container_detail::integral_constant      allocator_v2;
-   typedef container_detail::integral_constant::value> alloc_version;
 
    //Constructor, does not throw
    vector_alloc_holder()
@@ -279,19 +282,19 @@ struct vector_alloc_holder
 
    //Constructor, does not throw
    template
-   explicit vector_alloc_holder(BOOST_FWD_REF(AllocConvertible) a, size_type capacity)
+   explicit vector_alloc_holder(BOOST_FWD_REF(AllocConvertible) a, size_type cap)
       :  Allocator(boost::forward(a)), m_start(), m_size(), m_capacity()
    {
       m_start = this->allocation_command
-            (allocate_new, capacity, capacity, m_capacity, m_start).first;
+            (allocate_new, cap, cap, m_capacity, m_start).first;
    }
 
    //Constructor, does not throw
-   explicit vector_alloc_holder(size_type capacity)
+   explicit vector_alloc_holder(size_type cap)
       :  Allocator(), m_start(), m_size(), m_capacity()
    {
       m_start = this->allocation_command
-            (allocate_new, capacity, capacity, m_capacity, m_start).first;
+            (allocate_new, cap, cap, m_capacity, m_start).first;
    }
 
    vector_alloc_holder(BOOST_RV_REF(vector_alloc_holder) holder) BOOST_CONTAINER_NOEXCEPT
@@ -302,26 +305,16 @@ struct vector_alloc_holder
       holder.m_size = holder.m_capacity = 0;
    }
 
-   void first_allocation(size_type capacity)
+   void first_allocation(size_type cap)
    {
       m_start = this->allocation_command
-            (allocate_new, capacity, capacity, m_capacity, m_start).first;
-   }
-
-   template
-   void first_allocation_fill(Proxy proxy, size_type n)
-   {
-      //Copy first new elements in pos
-      proxy.uninitialized_copy_n_and_update
-         (container_detail::to_raw_pointer(this->m_start), n);
-      this->m_size = n;
+            (allocate_new, cap, cap, m_capacity, m_start).first;
    }
 
    //Destructor
    ~vector_alloc_holder() BOOST_CONTAINER_NOEXCEPT
    {
       if(this->m_capacity){
-         this->destroy_n(container_detail::to_raw_pointer(this->m_start), this->m_size);
          this->alloc().deallocate(this->m_start, this->m_capacity);
       }
    }
@@ -349,7 +342,7 @@ struct vector_alloc_holder
    size_type   m_size;
    size_type   m_capacity;
 
-   void swap_members(vector_alloc_holder &x) BOOST_CONTAINER_NOEXCEPT
+   void swap(vector_alloc_holder &x) BOOST_CONTAINER_NOEXCEPT
    {
       container_detail::do_swap(this->m_start, x.m_start);
       container_detail::do_swap(this->m_size, x.m_size);
@@ -381,25 +374,142 @@ struct vector_alloc_holder
       }
    }
 
-   void destroy(value_type* p) BOOST_CONTAINER_NOEXCEPT
+   const pointer   &start() const     {  return m_start;  }
+   const size_type &capacity() const  {  return m_capacity;  }
+   void start(const pointer &p)       {  m_start = p;  }
+   void capacity(const size_type &c)  {  m_capacity = c;  }
+};
+
+//!This struct deallocates and allocated memory
+template 
+struct vector_alloc_holder >
+   : public Allocator
+{
+   private:
+   BOOST_MOVABLE_BUT_NOT_COPYABLE(vector_alloc_holder)
+
+   public:
+   typedef boost::container::allocator_traits allocator_traits_type;
+   typedef typename allocator_traits_type::pointer       pointer;
+   typedef typename allocator_traits_type::size_type     size_type;
+   typedef typename allocator_traits_type::value_type    value_type;
+
+   template 
+   friend struct vector_alloc_holder;
+
+   //Constructor, does not throw
+   vector_alloc_holder()
+      BOOST_CONTAINER_NOEXCEPT_IF(::boost::has_nothrow_default_constructor::value)
+      :  Allocator(), m_size(0)
+   {}
+
+   //Constructor, does not throw
+   template
+   explicit vector_alloc_holder(BOOST_FWD_REF(AllocConvertible) a) BOOST_CONTAINER_NOEXCEPT
+      :  Allocator(boost::forward(a)), m_size(0)
+   {}
+
+   //Constructor, does not throw
+   template
+   explicit vector_alloc_holder(BOOST_FWD_REF(AllocConvertible) a, size_type cap)
+      :  Allocator(boost::forward(a)), m_size()
    {
-      if(!value_traits::trivial_dctr)
-         allocator_traits_type::destroy(this->alloc(), p);
+      this->first_allocation(cap);
    }
 
-   void destroy_n(value_type* p, size_type n) BOOST_CONTAINER_NOEXCEPT
+   //Constructor, does not throw
+   explicit vector_alloc_holder(size_type cap)
+      :  Allocator(), m_size()
    {
-      if(!value_traits::trivial_dctr){
-         for(; n--; ++p){
-            allocator_traits_type::destroy(this->alloc(), p);
-         }
+      this->first_allocation(cap);
+   }
+
+   vector_alloc_holder(BOOST_RV_REF(vector_alloc_holder) holder)
+      : Allocator(boost::move(static_cast(holder)))
+      , m_size()
+   {
+      this->priv_move_construct_impl(holder);
+   }
+
+   template
+   vector_alloc_holder(BOOST_RV_REF_BEG vector_alloc_holder BOOST_RV_REF_END holder)
+      : Allocator()
+      , m_size()
+   {
+      this->priv_move_construct_impl(holder);
+   }
+
+   void first_allocation(size_type cap)
+   {
+      if(cap > Allocator::internal_capacity){
+         throw_bad_alloc();
       }
    }
 
-   void destroy_all() BOOST_CONTAINER_NOEXCEPT
+   //Destructor
+   ~vector_alloc_holder() BOOST_CONTAINER_NOEXCEPT
+   {}
+
+   void swap(vector_alloc_holder &x)
    {
-      this->destroy_n(container_detail::to_raw_pointer(this->m_start), this->m_size);
-      this->m_size = 0;
+      this->priv_swap_members_impl(x);
+   }
+
+   template
+   void swap(vector_alloc_holder &x)
+   {
+      if(this->m_size > x.capacity() || x.m_size > this->capacity()){
+         throw_bad_alloc();
+      }
+      this->priv_swap_members_impl(x);
+   }
+
+   void move_from_empty(vector_alloc_holder &x) BOOST_CONTAINER_NOEXCEPT
+   {  //Containers with version 0 allocators can't be moved without move elements one by one
+      throw_bad_alloc();
+   }
+
+   Allocator &alloc() BOOST_CONTAINER_NOEXCEPT
+   {  return *this;  }
+
+   const Allocator &alloc() const BOOST_CONTAINER_NOEXCEPT
+   {  return *this;  }
+
+   void deallocate() BOOST_CONTAINER_NOEXCEPT
+   {}
+
+   pointer start() const       {  return Allocator::internal_storage();  }
+   size_type  capacity() const {  return Allocator::internal_capacity;  }
+   size_type   m_size;
+
+   private:
+
+   template
+   void priv_move_construct_impl(vector_alloc_holder &holder)
+   {  //Containers with version 0 allocators can't be moved
+      const size_type n = holder.m_size;
+      this->first_allocation(n);
+      //Copy first new elements in pos
+      container_detail::move_insert_range_proxy proxy
+         (this->alloc(), container_detail::to_raw_pointer(holder.start()));
+      proxy.uninitialized_copy_n_and_update
+         (container_detail::to_raw_pointer(this->start()), n);
+      this->m_size = n;
+   }
+
+   template
+   void priv_swap_members_impl(vector_alloc_holder &x)
+   {
+      value_type *const first_this = container_detail::to_raw_pointer(this->start());
+      value_type *const first_x = container_detail::to_raw_pointer(x.start());
+
+      if(this->m_size < x.m_size){
+         deep_swap_alloc_n(this->alloc(), first_this, this->m_size, first_x, x.m_size);
+      }
+      else{
+         deep_swap_alloc_n(this->alloc(), first_x, x.m_size, first_this, this->m_size);
+      }
+      container_detail::do_swap(this->m_size, x.m_size);
    }
 };
 
@@ -424,6 +534,8 @@ class vector
    /// @cond
    typedef container_detail::vector_alloc_holder base_t;
    typedef allocator_traits            allocator_traits_type;
+   template 
+   friend class vector;
    /// @endcond
    public:
    //////////////////////////////////////////////
@@ -451,11 +563,14 @@ class vector
    BOOST_COPYABLE_AND_MOVABLE(vector)
    typedef container_detail::vector_value_traits value_traits;
 
-   typedef typename base_t::allocator_v1           allocator_v1;
-   typedef typename base_t::allocator_v2           allocator_v2;
-   typedef typename base_t::alloc_version          alloc_version;
+   typedef container_detail::integral_constant allocator_v0;
+   typedef container_detail::integral_constant allocator_v1;
+   typedef container_detail::integral_constant allocator_v2;
+   typedef container_detail::integral_constant
+      ::value >                               alloc_version;
 
-   typedef constant_iterator   cvalue_iterator;
+   typedef constant_iterator            cvalue_iterator;
    /// @endcond
 
    public:
@@ -494,24 +609,50 @@ class vector
    explicit vector(size_type n)
       :  m_holder(n)
    {
-      this->m_holder.first_allocation_fill
+      this->priv_first_allocation_fill
          (container_detail::insert_default_constructed_n_proxy (this->m_holder.alloc()), n);
    }
 
-   //! Effects: Constructs a vector that will use a copy of allocator a
+   //! Effects: Constructs a vector
    //!   and inserts n copies of value.
    //!
    //! Throws: If allocator_type's default constructor or allocation
    //!   throws or T's copy constructor throws.
    //!
    //! Complexity: Linear to n.
-   vector(size_type n, const T& value, const allocator_type& a = allocator_type())
-      :  m_holder(a, n)
+   vector(size_type n, const T& value)
+      :  m_holder(n)
    {
-      this->m_holder.first_allocation_fill
+      this->priv_first_allocation_fill
          (container_detail::insert_n_copies_proxy (this->m_holder.alloc(), value), n);
    }
 
+   //! Effects: Constructs a vector that will use a copy of allocator a
+   //!   and inserts n copies of value.
+   //!
+   //! Throws: If allocation
+   //!   throws or T's copy constructor throws.
+   //!
+   //! Complexity: Linear to n.
+   vector(size_type n, const T& value, const allocator_type& a)
+      :  m_holder(a, n)
+   {
+      this->priv_first_allocation_fill
+         (container_detail::insert_n_copies_proxy (this->m_holder.alloc(), value), n);
+   }
+
+   //! Effects: Constructs a vector
+   //!   and inserts a copy of the range [first, last) in the vector.
+   //!
+   //! Throws: If allocator_type's default constructor or allocation
+   //!   throws or T's constructor taking an dereferenced InIt throws.
+   //!
+   //! Complexity: Linear to the range [first, last).
+   template 
+   vector(InIt first, InIt last)
+      :  m_holder()
+   {  this->insert(this->cend(), first, last); }
+
    //! Effects: Constructs a vector that will use a copy of allocator a
    //!   and inserts a copy of the range [first, last) in the vector.
    //!
@@ -520,7 +661,7 @@ class vector
    //!
    //! Complexity: Linear to the range [first, last).
    template 
-   vector(InIt first, InIt last, const allocator_type& a = allocator_type())
+   vector(InIt first, InIt last, const allocator_type& a)
       :  m_holder(a)
    {  this->insert(this->cend(), first, last); }
 
@@ -535,9 +676,9 @@ class vector
    vector(const vector &x)
       :  m_holder(allocator_traits_type::select_on_container_copy_construction(x.m_holder.alloc()), x.size())
    {
-      this->m_holder.first_allocation_fill
+      this->priv_first_allocation_fill
          (container_detail::insert_range_proxy
-            (this->m_holder.alloc(), container_detail::to_raw_pointer(x.m_holder.m_start)), x.size());
+            (this->m_holder.alloc(), container_detail::to_raw_pointer(x.m_holder.start())), x.size());
    }
 
    //! Effects: Move constructor. Moves mx's resources to *this.
@@ -549,6 +690,22 @@ class vector
       :  m_holder(boost::move(mx.m_holder))
    {}
 
+   #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+   //! Effects: Move constructor. Moves mx's resources to *this.
+   //!
+   //! Throws: If T's move constructor or allocation throws
+   //!
+   //! Complexity: Linear.
+   //!
+   //! Note: Non-standard extension
+   template
+   vector(BOOST_RV_REF_BEG vector BOOST_RV_REF_END mx)
+      :  m_holder(boost::move(mx.m_holder))
+   {}
+
+   #endif   //!defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
    //! Effects: Copy constructs a vector using the specified allocator.
    //!
    //! Postcondition: x == *this.
@@ -560,9 +717,9 @@ class vector
    vector(const vector &x, const allocator_type &a)
       :  m_holder(a, x.size())
    {
-      this->m_holder.first_allocation_fill
+      this->priv_first_allocation_fill
          (container_detail::insert_range_proxy
-            (this->m_holder.alloc(), container_detail::to_raw_pointer(x.m_holder.m_start)), x.size());
+            (this->m_holder.alloc(), container_detail::to_raw_pointer(x.m_holder.start())), x.size());
    }
 
    //! Effects: Move constructor using the specified allocator.
@@ -581,9 +738,9 @@ class vector
       else{
          const size_type n = mx.size();
          this->m_holder.first_allocation(n);
-         this->m_holder.first_allocation_fill
+         this->priv_first_allocation_fill
             (container_detail::move_insert_range_proxy
-               (this->m_holder.alloc(), container_detail::to_raw_pointer(mx.m_holder.m_start)), n);
+               (this->m_holder.alloc(), container_detail::to_raw_pointer(mx.m_holder.start())), n);
       }
    }
 
@@ -594,7 +751,10 @@ class vector
    //!
    //! Complexity: Linear to the number of elements.
    ~vector() BOOST_CONTAINER_NOEXCEPT
-   {} //vector_alloc_holder clears the data
+   {
+      destroy_alloc_n(this->get_stored_allocator(), container_detail::to_raw_pointer(this->m_holder.start()), this->m_holder.m_size);
+      //vector_alloc_holder deallocates the data
+   } 
 
    //! Effects: Makes *this contain the same elements as x.
    //!
@@ -616,8 +776,8 @@ class vector
             this->shrink_to_fit();
          }
          container_detail::assign_alloc(this_alloc, x_alloc, flag);
-         this->assign( container_detail::to_raw_pointer(x.m_holder.m_start)
-                     , container_detail::to_raw_pointer(x.m_holder.m_start + x.m_holder.m_size));
+         this->assign( container_detail::to_raw_pointer(x.m_holder.start())
+                     , container_detail::to_raw_pointer(x.m_holder.start() + x.m_holder.m_size));
       }
       return *this;
    }
@@ -641,7 +801,7 @@ class vector
          if(this_alloc == x_alloc){
             //Destroy objects but retain memory in case x reuses it in the future
             this->clear();
-            this->m_holder.swap_members(x.m_holder);
+            this->m_holder.swap(x.m_holder);
             //Move allocator if needed
             container_detail::bool_ flag;
@@ -649,13 +809,33 @@ class vector
          }
          //If unequal allocators, then do a one by one move
          else{
-            this->assign( boost::make_move_iterator(container_detail::to_raw_pointer(x.m_holder.m_start))
-                        , boost::make_move_iterator(container_detail::to_raw_pointer(x.m_holder.m_start + x.m_holder.m_size)));
+            this->assign( boost::make_move_iterator(container_detail::to_raw_pointer(x.m_holder.start()))
+                        , boost::make_move_iterator(container_detail::to_raw_pointer(x.m_holder.start() + x.m_holder.m_size)));
          }
       }
       return *this;
    }
 
+   #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+   //! Effects: Move assignment. All mx's values are transferred to *this.
+   //!
+   //! Postcondition: x.empty(). *this contains a the elements x had
+   //!   before the function.
+   //!
+   //! Throws: If move constructor/assignment of T throws or allocation throws
+   //!
+   //! Complexity: Linear.
+   template
+   vector& operator=(BOOST_RV_REF_BEG vector BOOST_RV_REF_END x)
+   {
+      this->assign( boost::make_move_iterator(container_detail::to_raw_pointer(x.m_holder.start()))
+                  , boost::make_move_iterator(container_detail::to_raw_pointer(x.m_holder.start() + x.m_holder.m_size)));
+      return *this;
+   }
+
+   #endif
+
    //! Effects: Assigns the the range [first, last) to *this.
    //!
    //! Throws: If memory allocation throws or T's copy/move constructor/assignment or
@@ -680,7 +860,9 @@ class vector
 
       if (first == last){
          //There are no more elements in the sequence, erase remaining
-         this->erase(cur, this->cend());
+         T* const end_pos = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size;
+         size_type n = static_cast(end_pos - container_detail::to_raw_pointer(cur.get_ptr()));
+         this->priv_destroy_last_n(n);
       }
       else{
          //There are more elements in the range, insert the remaining ones
@@ -737,7 +919,7 @@ class vector
    //!
    //! Complexity: Constant.
    iterator begin() BOOST_CONTAINER_NOEXCEPT
-   { return iterator(this->m_holder.m_start); }
+   { return iterator(this->m_holder.start()); }
 
    //! Effects: Returns a const_iterator to the first element contained in the vector.
    //!
@@ -745,7 +927,7 @@ class vector
    //!
    //! Complexity: Constant.
    const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
-   { return const_iterator(this->m_holder.m_start); }
+   { return const_iterator(this->m_holder.start()); }
 
    //! Effects: Returns an iterator to the end of the vector.
    //!
@@ -753,7 +935,7 @@ class vector
    //!
    //! Complexity: Constant.
    iterator end() BOOST_CONTAINER_NOEXCEPT
-   { return iterator(this->m_holder.m_start + this->m_holder.m_size); }
+   { return iterator(this->m_holder.start() + this->m_holder.m_size); }
 
    //! Effects: Returns a const_iterator to the end of the vector.
    //!
@@ -805,7 +987,7 @@ class vector
    //!
    //! Complexity: Constant.
    const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
-   { return const_iterator(this->m_holder.m_start); }
+   { return const_iterator(this->m_holder.start()); }
 
    //! Effects: Returns a const_iterator to the end of the vector.
    //!
@@ -813,7 +995,7 @@ class vector
    //!
    //! Complexity: Constant.
    const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
-   { return const_iterator(this->m_holder.m_start + this->m_holder.m_size); }
+   { return const_iterator(this->m_holder.start() + this->m_holder.m_size); }
 
    //! Effects: Returns a const_reverse_iterator pointing to the beginning
    //! of the reversed vector.
@@ -871,15 +1053,15 @@ class vector
    //! Complexity: Linear to the difference between size() and new_size.
    void resize(size_type new_size)
    {
-      if (new_size < this->size()){
+      const size_type sz = this->size();
+      if (new_size < sz){
          //Destroy last elements
-         this->erase(const_iterator(this->m_holder.m_start + new_size), this->end());
+         this->priv_destroy_last_n(sz - new_size);
       }
       else{
          const size_type n = new_size - this->size();
-         this->reserve(new_size);
          container_detail::insert_default_constructed_n_proxy proxy(this->m_holder.alloc());
-         this->priv_forward_range_insert(this->cend().get_ptr(), n, proxy);
+         this->priv_forward_range_insert_at_end(n, proxy, alloc_version());
       }
    }
 
@@ -891,14 +1073,15 @@ class vector
    //! Complexity: Linear to the difference between size() and new_size.
    void resize(size_type new_size, const T& x)
    {
-      pointer finish = this->m_holder.m_start + this->m_holder.m_size;
-      if (new_size < size()){
+      const size_type sz = this->size();
+      if (new_size < sz){
          //Destroy last elements
-         this->erase(const_iterator(this->m_holder.m_start + new_size), this->end());
+         this->priv_destroy_last_n(sz - new_size);
       }
       else{
-         //Insert new elements at the end
-         this->insert(const_iterator(finish), new_size - this->size(), x);
+         const size_type n = new_size - this->size();
+         container_detail::insert_n_copies_proxy proxy(this->m_holder.alloc(), x);
+         this->priv_forward_range_insert_at_end(n, proxy, alloc_version());
       }
    }
 
@@ -909,7 +1092,7 @@ class vector
    //!
    //! Complexity: Constant.
    size_type capacity() const BOOST_CONTAINER_NOEXCEPT
-   { return this->m_holder.m_capacity; }
+   { return this->m_holder.capacity(); }
 
    //! Effects: If n is less than or equal to capacity(), this call has no
    //!   effect. Otherwise, it is a request for allocation of additional memory.
@@ -920,54 +1103,7 @@ class vector
    void reserve(size_type new_cap)
    {
       if (this->capacity() < new_cap){
-         //There is not enough memory, allocate a new
-         //buffer or expand the old one.
-         bool same_buffer_start;
-         size_type real_cap = 0;
-         std::pair ret =
-            this->m_holder.allocation_command
-               (allocate_new | expand_fwd | expand_bwd,
-                  new_cap, new_cap, real_cap, this->m_holder.m_start);
-
-         //Check for forward expansion
-         same_buffer_start = ret.second && this->m_holder.m_start == ret.first;
-         if(same_buffer_start){
-            #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
-            ++this->num_expand_fwd;
-            #endif
-            this->m_holder.m_capacity  = real_cap;
-         }
-
-         //If there is no forward expansion, move objects
-         else{
-            //We will reuse insert code, so create a dummy input iterator
-            container_detail::insert_range_proxy, T*>
-               proxy(this->m_holder.alloc(), ::boost::make_move_iterator((T *)0));
-            //Backwards (and possibly forward) expansion
-            if(alloc_version::value > 1 && ret.second){
-               #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
-               ++this->num_expand_bwd;
-               #endif
-               this->priv_range_insert_expand_backwards
-                  ( container_detail::to_raw_pointer(ret.first)
-                  , real_cap
-                  , container_detail::to_raw_pointer(this->m_holder.m_start)
-                  , 0
-                  , proxy);
-            }
-            //New buffer
-            else{
-               #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
-               ++this->num_alloc;
-               #endif
-               this->priv_range_insert_new_allocation
-                  ( container_detail::to_raw_pointer(ret.first)
-                  , real_cap
-                  , container_detail::to_raw_pointer(this->m_holder.m_start)
-                  , 0
-                  , proxy);
-            }
-         }
+         this->priv_reserve(new_cap, alloc_version());
       }
    }
 
@@ -995,7 +1131,7 @@ class vector
    //!
    //! Complexity: Constant.
    reference         front() BOOST_CONTAINER_NOEXCEPT
-   { return *this->m_holder.m_start; }
+   { return *this->m_holder.start(); }
 
    //! Requires: !empty()
    //!
@@ -1006,7 +1142,7 @@ class vector
    //!
    //! Complexity: Constant.
    const_reference   front() const BOOST_CONTAINER_NOEXCEPT
-   { return *this->m_holder.m_start; }
+   { return *this->m_holder.start(); }
 
    //! Requires: !empty()
    //!
@@ -1017,7 +1153,7 @@ class vector
    //!
    //! Complexity: Constant.
    reference         back() BOOST_CONTAINER_NOEXCEPT
-   { return this->m_holder.m_start[this->m_holder.m_size - 1]; }
+   { return this->m_holder.start()[this->m_holder.m_size - 1]; }
 
    //! Requires: !empty()
    //!
@@ -1028,7 +1164,7 @@ class vector
    //!
    //! Complexity: Constant.
    const_reference   back()  const BOOST_CONTAINER_NOEXCEPT
-   { return this->m_holder.m_start[this->m_holder.m_size - 1]; }
+   { return this->m_holder.start()[this->m_holder.m_size - 1]; }
 
    //! Requires: size() > n.
    //!
@@ -1039,7 +1175,7 @@ class vector
    //!
    //! Complexity: Constant.
    reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT
-   { return this->m_holder.m_start[n]; }
+   { return this->m_holder.start()[n]; }
 
    //! Requires: size() > n.
    //!
@@ -1050,7 +1186,7 @@ class vector
    //!
    //! Complexity: Constant.
    const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT
-   { return this->m_holder.m_start[n]; }
+   { return this->m_holder.start()[n]; }
 
    //! Requires: size() > n.
    //!
@@ -1061,7 +1197,7 @@ class vector
    //!
    //! Complexity: Constant.
    reference at(size_type n)
-   { this->priv_check_range(n); return this->m_holder.m_start[n]; }
+   { this->priv_check_range(n); return this->m_holder.start()[n]; }
 
    //! Requires: size() > n.
    //!
@@ -1072,7 +1208,7 @@ class vector
    //!
    //! Complexity: Constant.
    const_reference at(size_type n) const
-   { this->priv_check_range(n); return this->m_holder.m_start[n]; }
+   { this->priv_check_range(n); return this->m_holder.start()[n]; }
 
    //////////////////////////////////////////////
    //
@@ -1087,7 +1223,7 @@ class vector
    //!
    //! Complexity: Constant.
    T* data() BOOST_CONTAINER_NOEXCEPT
-   { return container_detail::to_raw_pointer(this->m_holder.m_start); }
+   { return container_detail::to_raw_pointer(this->m_holder.start()); }
 
    //! Returns: Allocator pointer such that [data(),data() + size()) is a valid range.
    //!   For a non-empty vector, data() == &front().
@@ -1096,7 +1232,7 @@ class vector
    //!
    //! Complexity: Constant.
    const T * data()  const BOOST_CONTAINER_NOEXCEPT
-   { return container_detail::to_raw_pointer(this->m_holder.m_start); }
+   { return container_detail::to_raw_pointer(this->m_holder.start()); }
 
    //////////////////////////////////////////////
    //
@@ -1115,16 +1251,16 @@ class vector
    template
    void emplace_back(Args &&...args)
    {
-      T* back_pos = container_detail::to_raw_pointer(this->m_holder.m_start) + this->m_holder.m_size;
-      if (this->m_holder.m_size < this->m_holder.m_capacity){
+      T* back_pos = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size;
+      if (this->m_holder.m_size < this->m_holder.capacity()){
          //There is more memory, just construct a new object at the end
          allocator_traits_type::construct(this->m_holder.alloc(), back_pos, ::boost::forward(args)...);
          ++this->m_holder.m_size;
       }
       else{
          typedef container_detail::insert_emplace_proxy type;
-         this->priv_forward_range_insert
-            (back_pos, 1, type(this->m_holder.alloc(), ::boost::forward(args)...));
+         this->priv_forward_range_insert_at_end
+            (1, type(this->m_holder.alloc(), ::boost::forward(args)...), alloc_version());
       }
    }
 
@@ -1143,8 +1279,8 @@ class vector
    {
       //Just call more general insert(pos, size, value) and return iterator
       typedef container_detail::insert_emplace_proxy type;
-      return this->priv_forward_range_insert
-         (position.get_ptr(), 1, type(this->m_holder.alloc(), ::boost::forward(args)...));
+      return this->priv_forward_range_insert( position.get_ptr(), 1, type(this->m_holder.alloc()
+                                            , ::boost::forward(args)...), alloc_version());
    }
 
    #else
@@ -1154,8 +1290,8 @@ class vector
    void emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                              \
    {                                                                                                  \
       T* back_pos = container_detail::to_raw_pointer                                                  \
-         (this->m_holder.m_start) + this->m_holder.m_size;                                            \
-      if (this->m_holder.m_size < this->m_holder.m_capacity){                                         \
+         (this->m_holder.start()) + this->m_holder.m_size;                                            \
+      if (this->m_holder.m_size < this->m_holder.capacity()){                                         \
          allocator_traits_type::construct (this->m_holder.alloc()                                     \
             , back_pos BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) );              \
          ++this->m_holder.m_size;                                                                     \
@@ -1164,7 +1300,7 @@ class vector
          container_detail::BOOST_PP_CAT(insert_emplace_proxy_arg, n)                                  \
              proxy                                 \
             (this->m_holder.alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));  \
-         this->priv_forward_range_insert(back_pos, 1, proxy);                                         \
+         this->priv_forward_range_insert_at_end(1, proxy, alloc_version());                           \
       }                                                                                               \
    }                                                                                                  \
                                                                                                       \
@@ -1176,7 +1312,7 @@ class vector
           proxy                                    \
             (this->m_holder.alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));  \
       return this->priv_forward_range_insert                                                          \
-         (container_detail::to_raw_pointer(pos.get_ptr()), 1, proxy);                                 \
+         (container_detail::to_raw_pointer(pos.get_ptr()), 1, proxy, alloc_version());                \
    }                                                                                                  \
    //!
    #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
@@ -1241,7 +1377,7 @@ class vector
    iterator insert(const_iterator p, size_type n, const T& x)
    {
       container_detail::insert_n_copies_proxy proxy(this->m_holder.alloc(), x);
-      return this->priv_forward_range_insert(p.get_ptr(), n, proxy);
+      return this->priv_forward_range_insert(p.get_ptr(), n, proxy, alloc_version());
    }
 
    //! Requires: p must be a valid iterator of *this.
@@ -1270,7 +1406,7 @@ class vector
          it = this->emplace(it, *first);
          ++it;
       }
-      return iterator(this->m_holder.m_start + n_pos);
+      return iterator(this->m_holder.start() + n_pos);
    }
 
    #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1283,7 +1419,7 @@ class vector
       )
    {
       container_detail::insert_range_proxy proxy(this->m_holder.alloc(), first);
-      return this->priv_forward_range_insert(pos.get_ptr(), std::distance(first, last), proxy);
+      return this->priv_forward_range_insert(pos.get_ptr(), std::distance(first, last), proxy, alloc_version());
    }
    #endif
 
@@ -1296,7 +1432,7 @@ class vector
    {
       //Destroy last element
       --this->m_holder.m_size;
-      this->m_holder.destroy(container_detail::to_raw_pointer(this->m_holder.m_start) + this->m_holder.m_size);
+      this->priv_destroy(container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size);
    }
 
    //! Effects: Erases the element at position pos.
@@ -1308,9 +1444,9 @@ class vector
    iterator erase(const_iterator position)
    {
       T *const pos = container_detail::to_raw_pointer(position.get_ptr());
-      T *const beg = container_detail::to_raw_pointer(this->m_holder.m_start);
+      T *const beg = container_detail::to_raw_pointer(this->m_holder.start());
       //Move elements forward and destroy last
-      this->m_holder.destroy(::boost::move(pos + 1, beg + this->m_holder.m_size, pos));
+      this->priv_destroy(::boost::move(pos + 1, beg + this->m_holder.m_size, pos));
       --this->m_holder.m_size;
       return iterator(position.get_ptr());
    }
@@ -1324,14 +1460,14 @@ class vector
    iterator erase(const_iterator first, const_iterator last)
    {
       if (first != last){
-         T* end_pos = container_detail::to_raw_pointer(this->m_holder.m_start) + this->m_holder.m_size;
-         T* ptr = container_detail::to_raw_pointer(boost::move
+         T* const end_pos = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size;
+         T* const ptr = container_detail::to_raw_pointer(boost::move
             (container_detail::to_raw_pointer(last.get_ptr())
             ,end_pos
             ,container_detail::to_raw_pointer(first.get_ptr())
             ));
          const size_type destroyed = (end_pos - ptr);
-         this->m_holder.destroy_n(ptr, destroyed);
+         destroy_alloc_n(this->get_stored_allocator(), ptr, destroyed);
          this->m_holder.m_size -= destroyed;
       }
       return iterator(first.get_ptr());
@@ -1342,22 +1478,39 @@ class vector
    //! Throws: Nothing.
    //!
    //! Complexity: Constant.
-   void swap(vector& x) BOOST_CONTAINER_NOEXCEPT
+   void swap(vector& x) BOOST_CONTAINER_NOEXCEPT_IF((!container_detail::is_same::value))
    {
-      //Just swap internals
-      this->m_holder.swap_members(x.m_holder);
+      //Just swap internals in case of !allocator_v0. Otherwise, deep swap
+      this->m_holder.swap(x.m_holder);
       //And now the allocator
       container_detail::bool_ flag;
       container_detail::swap_alloc(this->m_holder.alloc(), x.m_holder.alloc(), flag);
    }
 
+   #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
+
+   //! Effects: Swaps the contents of *this and x.
+   //!
+   //! Throws: If T's move constructor throws.
+   //!
+   //! Complexity: Linear
+   //!
+   //! Note: non-standard extension.
+   template
+   void swap(vector & x)
+   {
+      this->m_holder.swap(x.m_holder);
+   }
+
+   #endif   //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
+
    //! Effects: Erases all the elements of the vector.
    //!
    //! Throws: Nothing.
    //!
    //! Complexity: Linear to the number of elements in the vector.
    void clear() BOOST_CONTAINER_NOEXCEPT
-   {  this->m_holder.destroy_all();  }
+   {  this->priv_destroy_all();  }
 
    /// @cond
 
@@ -1377,21 +1530,128 @@ class vector
    }
 
    private:
+
+   void priv_reserve(size_type, allocator_v0)
+   {
+      throw_bad_alloc();
+   }
+
+   void priv_reserve(size_type new_cap, allocator_v1)
+   {
+      //There is not enough memory, allocate a new buffer
+      pointer p = this->m_holder.allocate(new_cap);
+
+      //We will reuse insert code, so create a dummy input iterator
+      container_detail::insert_range_proxy, T*>
+         proxy(this->m_holder.alloc(), ::boost::make_move_iterator((T *)0));
+      //Backwards (and possibly forward) expansion
+      #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
+      ++this->num_alloc;
+      #endif
+      this->priv_range_insert_new_allocation
+         ( container_detail::to_raw_pointer(p)
+         , new_cap
+         , container_detail::to_raw_pointer(this->m_holder.start())
+         , 0
+         , proxy);
+   }
+
+   void priv_reserve(size_type new_cap, allocator_v2)
+   {
+      //There is not enough memory, allocate a new
+      //buffer or expand the old one.
+      bool same_buffer_start;
+      size_type real_cap = 0;
+      std::pair ret =
+         this->m_holder.allocation_command
+            (allocate_new | expand_fwd | expand_bwd,
+               new_cap, new_cap, real_cap, this->m_holder.start());
+
+      //Check for forward expansion
+      same_buffer_start = ret.second && this->m_holder.start() == ret.first;
+      if(same_buffer_start){
+         #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
+         ++this->num_expand_fwd;
+         #endif
+         this->m_holder.capacity(real_cap);
+      }
+
+      //If there is no forward expansion, move objects
+      else{
+         //We will reuse insert code, so create a dummy input iterator
+         container_detail::insert_range_proxy, T*>
+            proxy(this->m_holder.alloc(), ::boost::make_move_iterator((T *)0));
+         //Backwards (and possibly forward) expansion
+         if(ret.second){
+            #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
+            ++this->num_expand_bwd;
+            #endif
+            this->priv_range_insert_expand_backwards
+               ( container_detail::to_raw_pointer(ret.first)
+               , real_cap
+               , container_detail::to_raw_pointer(this->m_holder.start())
+               , 0
+               , proxy);
+         }
+         //New buffer
+         else{
+            #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
+            ++this->num_alloc;
+            #endif
+            this->priv_range_insert_new_allocation
+               ( container_detail::to_raw_pointer(ret.first)
+               , real_cap
+               , container_detail::to_raw_pointer(this->m_holder.start())
+               , 0
+               , proxy);
+         }
+      }
+   }
+
+   template
+   void priv_first_allocation_fill(Proxy proxy, size_type n)
+   {
+      //Copy first new elements in pos
+      proxy.uninitialized_copy_n_and_update
+         (container_detail::to_raw_pointer(this->m_holder.start()), n);
+      this->m_holder.m_size = n;
+   }
+
+   void priv_destroy(value_type* p) BOOST_CONTAINER_NOEXCEPT
+   {
+      if(!value_traits::trivial_dctr)
+         allocator_traits_type::destroy(this->get_stored_allocator(), p);
+   }
+
+   void priv_destroy_last_n(size_type n) BOOST_CONTAINER_NOEXCEPT
+   {
+      T* const end_pos = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size;
+      destroy_alloc_n(this->get_stored_allocator(), end_pos-n, n);
+      this->m_holder.m_size -= n;
+   }
+
+   void priv_destroy_all() BOOST_CONTAINER_NOEXCEPT
+   {
+      destroy_alloc_n(this->get_stored_allocator(), container_detail::to_raw_pointer(this->m_holder.start()), this->m_holder.m_size);
+      this->m_holder.m_size = 0;
+   }
+
    template
    iterator priv_insert(const const_iterator &p, BOOST_FWD_REF(U) x)
    {
       return this->priv_forward_range_insert
-         (p.get_ptr(), 1, container_detail::get_insert_value_proxy(this->m_holder.alloc(), ::boost::forward(x)));
+         ( p.get_ptr(), 1, container_detail::get_insert_value_proxy(this->m_holder.alloc()
+         , ::boost::forward(x)), alloc_version());
    }
 
    template 
    void priv_push_back(BOOST_FWD_REF(U) x)
    {
-      if (this->m_holder.m_size < this->m_holder.m_capacity){
+      if (this->m_holder.m_size < this->m_holder.capacity()){
          //There is more memory, just construct a new object at the end
          allocator_traits_type::construct
             ( this->m_holder.alloc()
-            , container_detail::to_raw_pointer(this->m_holder.m_start + this->m_holder.m_size)
+            , container_detail::to_raw_pointer(this->m_holder.start() + this->m_holder.m_size)
             , ::boost::forward(x) );
          ++this->m_holder.m_size;
       }
@@ -1400,42 +1660,40 @@ class vector
       }
    }
 
+   void priv_shrink_to_fit(allocator_v0)
+   {}
+
    void priv_shrink_to_fit(allocator_v1)
    {
-      if(this->m_holder.m_capacity){
-         if(!this->size()){
+      const size_type cp = this->m_holder.capacity();
+      if(cp){
+         const size_type sz = this->size();
+         if(!sz){
             this->m_holder.deallocate();
          }
-         else{
+         else if(sz < cp){
             //Allocate a new buffer.
-            size_type real_cap = 0;
-            std::pair ret =
-               this->m_holder.allocation_command
-                  (allocate_new, this->size(), this->size(), real_cap, this->m_holder.m_start);
-            if(real_cap < this->capacity()){
-               //We will reuse insert code, so create a dummy input iterator
-               container_detail::insert_range_proxy, T*>
-                  proxy(this->m_holder.alloc(), ::boost::make_move_iterator((T *)0));
-               #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
-               ++this->num_alloc;
-               #endif
-               this->priv_range_insert_new_allocation
-                  ( container_detail::to_raw_pointer(ret.first)
-                  , real_cap
-                  , container_detail::to_raw_pointer(this->m_holder.m_start)
-                  , 0
-                  , proxy);
-            }
-            else{
-               this->m_holder.alloc().deallocate(ret.first, real_cap);
-            }
+            pointer p = this->m_holder.allocate(sz);
+
+            //We will reuse insert code, so create a dummy input iterator
+            container_detail::insert_range_proxy, T*>
+               proxy(this->m_holder.alloc(), ::boost::make_move_iterator((T *)0));
+            #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
+            ++this->num_alloc;
+            #endif
+            this->priv_range_insert_new_allocation
+               ( container_detail::to_raw_pointer(p)
+               , sz
+               , container_detail::to_raw_pointer(this->m_holder.start())
+               , 0
+               , proxy);
          }
       }
    }
 
    void priv_shrink_to_fit(allocator_v2)
    {
-      if(this->m_holder.m_capacity){
+      if(this->m_holder.capacity()){
          if(!size()){
             this->m_holder.deallocate();
          }
@@ -1444,8 +1702,8 @@ class vector
             if(this->m_holder.allocation_command
                ( shrink_in_place | nothrow_allocation
                , this->capacity(), this->size()
-               , received_size,   this->m_holder.m_start).first){
-               this->m_holder.m_capacity = received_size;
+               , received_size,   this->m_holder.start()).first){
+               this->m_holder.capacity(received_size);
                #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
                ++this->num_shrink;
                #endif
@@ -1456,77 +1714,136 @@ class vector
 
    template 
    iterator priv_forward_range_insert
-      (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy)
+      (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v0)
    {
       //Check if we have enough memory or try to expand current memory
-      const size_type remaining = this->m_holder.m_capacity - this->m_holder.m_size;
-      const size_type n_pos = pos - this->m_holder.m_start;
+      const size_type remaining = this->m_holder.capacity() - this->m_holder.m_size;
+      const size_type n_pos = pos - this->m_holder.start();
       T *const raw_pos = container_detail::to_raw_pointer(pos);
 
-      //Check if we already have room
-      if(alloc_version::value > 1){   //Version 2 allocator, compile time check
-         bool same_buffer_start = n <= remaining;
-         if (!same_buffer_start){
-            size_type real_cap = 0;
-            //There is not enough memory, allocate a new
-            //buffer or expand the old one.
-            std::pair ret = (this->m_holder.allocation_command
-                  (allocate_new | expand_fwd | expand_bwd,
-                     this->m_holder.m_size + n, this->m_holder.next_capacity(n), real_cap, this->m_holder.m_start));
+      if (n <= remaining){
+         this->priv_range_insert_expand_forward(raw_pos, n, insert_range_proxy);
+      }
+      else{
+         //This will trigger an error
+         throw_bad_alloc();
+      }
 
-            //Buffer reallocated
-            if(ret.second){
-               //Forward expansion, delay insertion
-               if(this->m_holder.m_start == ret.first){
-                  #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
-                  ++this->num_expand_fwd;
-                  #endif
-                  this->m_holder.m_capacity = real_cap;
-                  //Expand forward
-                  this->priv_range_insert_expand_forward(raw_pos, n, insert_range_proxy);
-               }
-               //Backwards (and possibly forward) expansion
-               else{
-                  #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
-                  ++this->num_expand_bwd;
-                  #endif
-                  this->priv_range_insert_expand_backwards
-                     ( container_detail::to_raw_pointer(ret.first)
-                     , real_cap, raw_pos, n, insert_range_proxy);
-               }
+      return iterator(this->m_holder.start() + n_pos);
+   }
+
+   template 
+   iterator priv_forward_range_insert_at_end
+      (const size_type n, const InsertionProxy insert_range_proxy, allocator_v0)
+   {
+      //Check if we have enough memory or try to expand current memory
+      const size_type remaining = this->m_holder.capacity() - this->m_holder.m_size;
+
+      if (n <= remaining){
+         this->priv_range_insert_at_end_expand_forward(n, insert_range_proxy);
+      }
+      else{
+         //This will trigger an error
+         throw_bad_alloc();
+      }
+
+      return this->end();
+   }
+
+   template 
+   iterator priv_forward_range_insert
+      (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v1)
+   {
+      //Check if we have enough memory or try to expand current memory
+      const size_type remaining = this->m_holder.capacity() - this->m_holder.m_size;
+      const size_type n_pos = pos - this->m_holder.start();
+      T *const raw_pos = container_detail::to_raw_pointer(pos);
+
+      if (n <= remaining){
+         this->priv_range_insert_expand_forward
+            (raw_pos, n, insert_range_proxy);
+      }
+      else{
+         const size_type new_cap = this->m_holder.next_capacity(n);
+         T * new_buf = container_detail::to_raw_pointer(this->m_holder.alloc().allocate(new_cap));
+         #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
+         ++this->num_alloc;
+         #endif
+         this->priv_range_insert_new_allocation
+            ( new_buf, new_cap, raw_pos, n, insert_range_proxy);
+      }
+      return iterator(this->m_holder.start() + n_pos);
+   }
+
+   template 
+   iterator priv_forward_range_insert_at_end
+      (const size_type n, const InsertionProxy insert_range_proxy, allocator_v1)
+   {
+      return this->priv_forward_range_insert(this->cend().get_ptr(), n, insert_range_proxy, allocator_v1());
+   }
+
+   template 
+   iterator priv_forward_range_insert
+      (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v2)
+   {
+      //Check if we have enough memory or try to expand current memory
+      const size_type remaining = this->m_holder.capacity() - this->m_holder.m_size;
+      const size_type n_pos = pos - this->m_holder.start();
+      T *const raw_pos = container_detail::to_raw_pointer(pos);
+
+      bool same_buffer_start = n <= remaining;
+      if (!same_buffer_start){
+         size_type real_cap = 0;
+         //There is not enough memory, allocate a new
+         //buffer or expand the old one.
+         std::pair ret = (this->m_holder.allocation_command
+               (allocate_new | expand_fwd | expand_bwd,
+                  this->m_holder.m_size + n, this->m_holder.next_capacity(n), real_cap, this->m_holder.start()));
+
+         //Buffer reallocated
+         if(ret.second){
+            //Forward expansion, delay insertion
+            if(this->m_holder.start() == ret.first){
+               #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
+               ++this->num_expand_fwd;
+               #endif
+               this->m_holder.capacity(real_cap);
+               //Expand forward
+               this->priv_range_insert_expand_forward(raw_pos, n, insert_range_proxy);
             }
-            //New buffer
+            //Backwards (and possibly forward) expansion
             else{
                #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
-               ++this->num_alloc;
+               ++this->num_expand_bwd;
                #endif
-               this->priv_range_insert_new_allocation
+               this->priv_range_insert_expand_backwards
                   ( container_detail::to_raw_pointer(ret.first)
                   , real_cap, raw_pos, n, insert_range_proxy);
             }
          }
+         //New buffer
          else{
-            //Expand forward
-            this->priv_range_insert_expand_forward
-               (raw_pos, n, insert_range_proxy);
-         }
-      }
-      else{ //Version 1 allocator
-         if (n <= remaining){
-            this->priv_range_insert_expand_forward
-               (raw_pos, n, insert_range_proxy);
-         }
-         else{
-            const size_type new_cap = this->m_holder.next_capacity(n);
-            T * new_buf = container_detail::to_raw_pointer(this->m_holder.alloc().allocate(new_cap));
             #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
             ++this->num_alloc;
             #endif
             this->priv_range_insert_new_allocation
-               ( new_buf, new_cap, raw_pos, n, insert_range_proxy);
+               ( container_detail::to_raw_pointer(ret.first)
+               , real_cap, raw_pos, n, insert_range_proxy);
          }
       }
-      return iterator(this->m_holder.m_start + n_pos);
+      else{
+         //Expand forward
+         this->priv_range_insert_expand_forward(raw_pos, n, insert_range_proxy);
+      }
+
+      return iterator(this->m_holder.start() + n_pos);
+   }
+
+   template 
+   iterator priv_forward_range_insert_at_end
+      (const size_type n, const InsertionProxy insert_range_proxy, allocator_v2)
+   {
+      return this->priv_forward_range_insert(this->cend().get_ptr(), n, insert_range_proxy, allocator_v2());
    }
 
    //Absolutely experimental. This function might change, disappear or simply crash!
@@ -1536,7 +1853,7 @@ class vector
    {
       const size_type old_size_pos = this->size();
       this->reserve(old_size_pos + element_count);
-      T* const begin_ptr = container_detail::to_raw_pointer(this->m_holder.m_start);
+      T* const begin_ptr = container_detail::to_raw_pointer(this->m_holder.start());
       size_type insertions_left = element_count;
       size_type next_pos = old_size_pos;
       size_type hole_size = element_count;
@@ -1649,7 +1966,7 @@ class vector
       BOOST_ASSERT(first_pos <= last_pos);
       BOOST_ASSERT(last_pos <= limit_pos);
       //
-      T* const begin_ptr = container_detail::to_raw_pointer(this->m_holder.m_start);
+      T* const begin_ptr = container_detail::to_raw_pointer(this->m_holder.start());
       T* const first_ptr = begin_ptr + first_pos;
       T* const last_ptr  = begin_ptr + last_pos;
 
@@ -1678,18 +1995,25 @@ class vector
    }
 
    private:
+   template 
+   void priv_range_insert_at_end_expand_forward(const size_type n, InsertionProxy insert_range_proxy)
+   {
+      T* const old_finish = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size;
+      insert_range_proxy.uninitialized_copy_n_and_update(old_finish, n);
+      this->m_holder.m_size += n;
+   }
+
    template 
    void priv_range_insert_expand_forward(T* const pos, const size_type n, InsertionProxy insert_range_proxy)
    {
       //n can't be 0, because there is nothing to do in that case
       if(!n) return;
       //There is enough memory
-      T* const old_finish = container_detail::to_raw_pointer(this->m_holder.m_start) + this->m_holder.m_size;
+      T* const old_finish = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size;
       const size_type elems_after = old_finish - pos;
 
       if (!elems_after){
-         //Copy first new elements in pos
-         insert_range_proxy.uninitialized_copy_n_and_update(pos, n);
+         insert_range_proxy.uninitialized_copy_n_and_update(old_finish, n);
          this->m_holder.m_size += n;
       }
       else if (elems_after >= n){
@@ -1716,7 +2040,7 @@ class vector
             this->m_holder.m_size += n;
          }
          BOOST_CATCH(...){
-            this->m_holder.destroy_n(pos + n, elems_after);
+            destroy_alloc_n(this->get_stored_allocator(), pos + n, elems_after);
             BOOST_RETHROW
          }
          BOOST_CATCH_END
@@ -1736,10 +2060,10 @@ class vector
 
       //Initialize with [begin(), pos) old buffer
       //the start of the new buffer
-      T *old_buffer = container_detail::to_raw_pointer(this->m_holder.m_start);
+      T *old_buffer = container_detail::to_raw_pointer(this->m_holder.start());
       if(old_buffer){
          new_finish = ::boost::container::uninitialized_move_alloc
-            (this->m_holder.alloc(), container_detail::to_raw_pointer(this->m_holder.m_start), pos, old_finish = new_finish);
+            (this->m_holder.alloc(), container_detail::to_raw_pointer(this->m_holder.start()), pos, old_finish = new_finish);
          constructed_values_destroyer.increment_size(new_finish - old_finish);
       }
       //Initialize new objects, starting from previous point
@@ -1754,12 +2078,12 @@ class vector
          //Destroy and deallocate old elements
          //If there is allocated memory, destroy and deallocate
          if(!value_traits::trivial_dctr_after_move)
-            this->m_holder.destroy_n(old_buffer, this->m_holder.m_size);
-         this->m_holder.alloc().deallocate(this->m_holder.m_start, this->m_holder.m_capacity);
+            destroy_alloc_n(this->get_stored_allocator(), old_buffer, this->m_holder.m_size);
+         this->m_holder.alloc().deallocate(this->m_holder.start(), this->m_holder.capacity());
       }
-      this->m_holder.m_start     = new_start;
-      this->m_holder.m_size      = new_finish - new_start;
-      this->m_holder.m_capacity  = new_cap;
+      this->m_holder.start(new_start);
+      this->m_holder.m_size = new_finish - new_start;
+      this->m_holder.capacity(new_cap);
       //All construction successful, disable rollbacks
       constructed_values_destroyer.release();
       scoped_alloc.release();
@@ -1772,7 +2096,7 @@ class vector
    {
       //n can be zero to just expand capacity
       //Backup old data
-      T* const old_start  = container_detail::to_raw_pointer(this->m_holder.m_start);
+      T* const old_start  = container_detail::to_raw_pointer(this->m_holder.start());
       T* const old_finish = old_start + this->m_holder.m_size;
       const size_type old_size = this->m_holder.m_size;
 
@@ -1782,8 +2106,8 @@ class vector
       const size_type before_plus_new = elemsbefore + n;
 
       //Update the vector buffer information to a safe state
-      this->m_holder.m_start      = new_start;
-      this->m_holder.m_capacity   = new_capacity;
+      this->m_holder.start(new_start);
+      this->m_holder.capacity(new_capacity);
       this->m_holder.m_size = 0;
 
       //If anything goes wrong, this object will destroy
@@ -1850,7 +2174,7 @@ class vector
             //they have trivial destructor after move
             size_type n_destroy =  old_finish - to_destroy;
             if(!value_traits::trivial_dctr_after_move)
-               this->m_holder.destroy_n(to_destroy, n_destroy);
+               destroy_alloc_n(this->get_stored_allocator(), to_destroy, n_destroy);
             this->m_holder.m_size -= n_destroy;
          }
       }
@@ -1924,7 +2248,7 @@ class vector
                //they have trivial destructor after being moved
                const size_type n_destroy = s_before - n;
                if(!value_traits::trivial_dctr_after_move)
-                  this->m_holder.destroy_n(move_end, n_destroy);
+                  destroy_alloc_n(this->get_stored_allocator(), move_end, n_destroy);
                this->m_holder.m_size -= n_destroy;
             }
          }
@@ -1980,7 +2304,7 @@ class vector
                //have trivial destructor after being moved
                size_type n_destroy = s_before - n;
                if(!value_traits::trivial_dctr_after_move)
-                  this->m_holder.destroy_n(move_end, n_destroy);
+                  destroy_alloc_n(this->get_stored_allocator(), move_end, n_destroy);
                this->m_holder.m_size -= n_destroy;
             }
          }
@@ -2061,7 +2385,7 @@ class vector
                   this->m_holder.m_size += n_after;
                }
                BOOST_CATCH(...){
-                  this->m_holder.destroy_n(pos, mid_last_dist);
+                  destroy_alloc_n(this->get_stored_allocator(), pos, mid_last_dist);
                   BOOST_RETHROW
                }
                BOOST_CATCH_END
diff --git a/proj/vc7ide/static_vector_test.vcproj b/proj/vc7ide/static_vector_test.vcproj
new file mode 100644
index 0000000..2ada060
--- /dev/null
+++ b/proj/vc7ide/static_vector_test.vcproj
@@ -0,0 +1,139 @@
+
+
+	
+		
+	
+	
+		
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+		
+		
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+		
+	
+	
+	
+	
+		
+			
+			
+		
+		
+		
+	
+	
+	
+
diff --git a/test/movable.hpp b/test/movable.hpp
new file mode 100644
index 0000000..3076865
--- /dev/null
+++ b/test/movable.hpp
@@ -0,0 +1,92 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2009.
+// 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)
+//
+// See http://www.boost.org/libs/move for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_MOVE_TEST_MOVABLE_HPP
+#define BOOST_MOVE_TEST_MOVABLE_HPP
+
+//[movable_definition 
+//header file "movable.hpp"
+#include 
+
+//A movable class
+class movable
+{
+    BOOST_MOVABLE_BUT_NOT_COPYABLE(movable)
+    int value_;
+    
+public:
+    movable() : value_(1){}
+    
+    //Move constructor and assignment
+    movable(BOOST_RV_REF(movable) m)
+    {  value_ = m.value_;   m.value_ = 0;  }
+    
+    movable & operator=(BOOST_RV_REF(movable) m)
+    {  value_ = m.value_;   m.value_ = 0;  return *this;  }
+    
+    bool moved() const //Observer
+    {  return value_ == 0; }
+};
+
+
+class copy_movable
+{
+    BOOST_COPYABLE_AND_MOVABLE(copy_movable)
+    int value_;
+    
+public:
+    copy_movable(int value = 1) : value_(value){}
+    
+    //Move constructor and assignment
+    copy_movable(BOOST_RV_REF(copy_movable) m)
+    {  value_ = m.value_;   m.value_ = 0;  }
+    
+    copy_movable(const copy_movable &m)
+    {  value_ = m.value_;   }
+    
+    copy_movable & operator=(BOOST_RV_REF(copy_movable) m)
+    {  value_ = m.value_;   m.value_ = 0;  return *this;  }
+    
+    copy_movable & operator=(BOOST_COPY_ASSIGN_REF(copy_movable) m)
+    {  value_ = m.value_;   return *this;  }
+    
+    bool moved() const //Observer
+    {  return value_ == 0; }
+    
+    bool operator==(const copy_movable& m) const
+    {  return value_ == m.value_; }
+};
+
+struct copy_movable_wrapper
+{
+   copy_movable cm;
+};
+
+copy_movable produce()
+{  return copy_movable();  }
+
+namespace boost{
+
+template<>
+struct has_nothrow_move
+{
+   static const bool value = true;
+};
+
+template<>
+struct has_nothrow_move
+{
+   static const bool value = true;
+};
+
+}  //namespace boost{
+//]
+
+#endif //BOOST_MOVE_TEST_MOVABLE_HPP
diff --git a/test/static_vector_test.cpp b/test/static_vector_test.cpp
new file mode 100644
index 0000000..f12e7e1
--- /dev/null
+++ b/test/static_vector_test.cpp
@@ -0,0 +1,803 @@
+// Boost.Container static_vector
+// Unit Test
+
+// Copyright (c) 2012-2013 Adam Wulkiewicz, Lodz, Poland.
+// Copyright (c) 2012-2013 Andrew Hundt.
+
+// Use, modification and distribution is subject to 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)
+#include 
+#include 
+#include 
+
+namespace boost  {
+namespace container {
+namespace test {
+
+//lightweight_test.hpp does not offer support to check if an operation throws
+//so write our own macro
+inline void throw_failed_impl(char const * excep, char const * file, int line, char const * function)
+{
+    BOOST_LIGHTWEIGHT_TEST_OSTREAM
+      << file << "(" << line << "): Exception '" << excep << "' not thrown in function '"
+      << function << "'" << std::endl;
+    ++boost::detail::test_errors();
+}
+
+}  //namespace detail {
+}  //namespace container {
+}  //namespace boost  {
+
+#define BOOST_TEST_THROW( S, E )                            \
+   try {                                                    \
+      S;                                                    \
+      ::boost::container::test::throw_failed_impl           \
+         (#E, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION);  \
+   }                                                        \
+   catch( E const&) {                                       \
+   }                                                        \
+//
+
+// TODO: Disable parts of the unit test that should not run when BOOST_NO_EXCEPTIONS
+// if exceptions are enabled there must be a user defined throw_exception function
+#ifdef BOOST_NO_EXCEPTIONS
+namespace boost {
+    void throw_exception(std::exception const & e){}; // user defined
+} // namespace boost
+#endif // BOOST_NO_EXCEPTIONS
+
+#include 
+#include 
+
+#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
+#include 
+#include 
+#endif
+
+#include "static_vector_test.hpp"
+
+namespace boost {
+namespace container {
+
+//Explicit instantiation to detect compilation errors
+template class boost::container::static_vector;
+
+}}
+
+
+template 
+void test_ctor_ndc()
+{
+    static_vector s;
+    BOOST_TEST_EQ(s.size() , 0u);
+    BOOST_TEST(s.capacity() == N);
+#ifndef BOOST_NO_EXCEPTIONS
+    BOOST_TEST_THROW( s.at(0u), std::out_of_range );
+#endif // BOOST_NO_EXCEPTIONS
+}
+
+template 
+void test_ctor_nc(size_t n)
+{
+    static_vector s(n);
+    BOOST_TEST(s.size() == n);
+    BOOST_TEST(s.capacity() == N);
+#ifndef BOOST_NO_EXCEPTIONS
+    BOOST_TEST_THROW( s.at(n), std::out_of_range );
+#endif // BOOST_NO_EXCEPTIONS
+    if ( 1 < n )
+    {
+        T val10(10);
+        s[0] = val10;
+        BOOST_TEST(T(10) == s[0]);
+        BOOST_TEST(T(10) == s.at(0));
+        T val20(20);
+        s.at(1) = val20;
+        BOOST_TEST(T(20) == s[1]);
+        BOOST_TEST(T(20) == s.at(1));
+    }
+}
+
+template 
+void test_ctor_nd(size_t n, T const& v)
+{
+    static_vector s(n, v);
+    BOOST_TEST(s.size() == n);
+    BOOST_TEST(s.capacity() == N);
+#ifndef BOOST_NO_EXCEPTIONS
+    BOOST_TEST_THROW( s.at(n), std::out_of_range );
+#endif // BOOST_NO_EXCEPTIONS
+    if ( 1 < n )
+    {
+        BOOST_TEST(v == s[0]);
+        BOOST_TEST(v == s.at(0));
+        BOOST_TEST(v == s[1]);
+        BOOST_TEST(v == s.at(1));
+        s[0] = T(10);
+        BOOST_TEST(T(10) == s[0]);
+        BOOST_TEST(T(10) == s.at(0));
+        s.at(1) = T(20);
+        BOOST_TEST(T(20) == s[1]);
+        BOOST_TEST(T(20) == s.at(1));
+    }
+}
+
+template 
+void test_resize_nc(size_t n)
+{
+    static_vector s;
+
+    s.resize(n);
+    BOOST_TEST(s.size() == n);
+    BOOST_TEST(s.capacity() == N);
+#ifndef BOOST_NO_EXCEPTIONS
+    BOOST_TEST_THROW( s.at(n), std::out_of_range );
+#endif // BOOST_NO_EXCEPTIONS
+    if ( 1 < n )
+    {
+        T val10(10);
+        s[0] = val10;
+        BOOST_TEST(T(10) == s[0]);
+        BOOST_TEST(T(10) == s.at(0));
+        T val20(20);
+        s.at(1) = val20;
+        BOOST_TEST(T(20) == s[1]);
+        BOOST_TEST(T(20) == s.at(1));
+    }
+}
+
+template 
+void test_resize_nd(size_t n, T const& v)
+{
+    static_vector s;
+
+    s.resize(n, v);
+    BOOST_TEST(s.size() == n);
+    BOOST_TEST(s.capacity() == N);
+#ifndef BOOST_NO_EXCEPTIONS
+    BOOST_TEST_THROW( s.at(n), std::out_of_range );
+#endif // BOOST_NO_EXCEPTIONS
+    if ( 1 < n )
+    {
+        BOOST_TEST(v == s[0]);
+        BOOST_TEST(v == s.at(0));
+        BOOST_TEST(v == s[1]);
+        BOOST_TEST(v == s.at(1));
+        s[0] = T(10);
+        BOOST_TEST(T(10) == s[0]);
+        BOOST_TEST(T(10) == s.at(0));
+        s.at(1) = T(20);
+        BOOST_TEST(T(20) == s[1]);
+        BOOST_TEST(T(20) == s.at(1));
+    }
+}
+
+template 
+void test_push_back_nd()
+{
+    static_vector s;
+
+    BOOST_TEST(s.size() == 0);
+#ifndef BOOST_NO_EXCEPTIONS
+    BOOST_TEST_THROW( s.at(0), std::out_of_range );
+#endif // BOOST_NO_EXCEPTIONS
+
+    for ( size_t i = 0 ; i < N ; ++i )
+    {
+        T t(i);
+        s.push_back(t);
+        BOOST_TEST(s.size() == i + 1);
+#ifndef BOOST_NO_EXCEPTIONS
+        BOOST_TEST_THROW( s.at(i + 1), std::out_of_range );
+#endif // BOOST_NO_EXCEPTIONS
+        BOOST_TEST(T(i) == s.at(i));
+        BOOST_TEST(T(i) == s[i]);
+        BOOST_TEST(T(i) == s.back());
+        BOOST_TEST(T(0) == s.front());
+        BOOST_TEST(T(i) == *(s.data() + i));
+    }
+}
+
+template 
+void test_pop_back_nd()
+{
+    static_vector s;
+
+    for ( size_t i = 0 ; i < N ; ++i )
+    {
+        T t(i);
+        s.push_back(t);
+    }
+
+    for ( size_t i = N ; i > 1 ; --i )
+    {
+        s.pop_back();
+        BOOST_TEST(s.size() == i - 1);
+#ifndef BOOST_NO_EXCEPTIONS
+        BOOST_TEST_THROW( s.at(i - 1), std::out_of_range );
+#endif // BOOST_NO_EXCEPTIONS
+        BOOST_TEST(T(i - 2) == s.at(i - 2));
+        BOOST_TEST(T(i - 2) == s[i - 2]);
+        BOOST_TEST(T(i - 2) == s.back());
+        BOOST_TEST(T(0) == s.front());
+    }
+}
+
+template 
+void test_compare_ranges(It1 first1, It1 last1, It2 first2, It2 last2)
+{
+    BOOST_TEST(std::distance(first1, last1) == std::distance(first2, last2));
+    for ( ; first1 != last1 && first2 != last2 ; ++first1, ++first2 )
+        BOOST_TEST(*first1 == *first2);
+}
+
+template 
+void test_copy_and_assign(C const& c)
+{
+    {
+        static_vector s(c.begin(), c.end());
+        BOOST_TEST(s.size() == c.size());
+        test_compare_ranges(s.begin(), s.end(), c.begin(), c.end());
+    }
+    {
+        static_vector s;
+        BOOST_TEST(0 == s.size());
+        s.assign(c.begin(), c.end());
+        BOOST_TEST(s.size() == c.size());
+        test_compare_ranges(s.begin(), s.end(), c.begin(), c.end());
+    }
+}
+
+template 
+void test_copy_and_assign_nd(T const& val)
+{
+    static_vector s;
+    std::vector v;
+    std::list l;
+
+    for ( size_t i = 0 ; i < N ; ++i )
+    {
+        T t(i);
+        s.push_back(t);
+        v.push_back(t);
+        l.push_back(t);
+    }
+    // copy ctor
+    {
+        static_vector s1(s);
+        BOOST_TEST(s.size() == s1.size());
+        test_compare_ranges(s.begin(), s.end(), s1.begin(), s1.end());
+    }
+    // copy assignment
+    {
+        static_vector s1;
+        BOOST_TEST(0 == s1.size());
+        s1 = s;
+        BOOST_TEST(s.size() == s1.size());
+        test_compare_ranges(s.begin(), s.end(), s1.begin(), s1.end());
+    }
+
+    // ctor(Iter, Iter) and assign(Iter, Iter)
+    test_copy_and_assign(s);
+    test_copy_and_assign(v);
+    test_copy_and_assign(l);
+
+    // assign(N, V)
+    {
+        static_vector s1(s);
+        test_compare_ranges(s.begin(), s.end(), s1.begin(), s1.end());
+        std::vector a(N, val);
+        s1.assign(N, val);
+        test_compare_ranges(a.begin(), a.end(), s1.begin(), s1.end());
+    }
+
+#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
+    stable_vector bsv(s.begin(), s.end());
+    vector bv(s.begin(), s.end());
+    test_copy_and_assign(bsv);
+    test_copy_and_assign(bv);
+#endif
+}
+
+template 
+void test_iterators_nd()
+{
+    static_vector s;
+    std::vector v;
+
+    for ( size_t i = 0 ; i < N ; ++i )
+    {
+        s.push_back(T(i));
+        v.push_back(T(i));
+    }
+
+    test_compare_ranges(s.begin(), s.end(), v.begin(), v.end());
+    test_compare_ranges(s.rbegin(), s.rend(), v.rbegin(), v.rend());
+
+    s.assign(v.rbegin(), v.rend());
+
+    test_compare_ranges(s.begin(), s.end(), v.rbegin(), v.rend());
+    test_compare_ranges(s.rbegin(), s.rend(), v.begin(), v.end());
+}
+
+template 
+void test_erase_nd()
+{
+    static_vector s;
+    typedef typename static_vector::iterator It;
+
+    for ( size_t i = 0 ; i < N ; ++i )
+        s.push_back(T(i));
+
+    // erase(pos)
+    {
+        for ( size_t i = 0 ; i < N ; ++i )
+        {
+            static_vector s1(s);
+            It it = s1.erase(s1.begin() + i);
+            BOOST_TEST(s1.begin() + i == it);
+            BOOST_TEST(s1.size() == N - 1);
+            for ( size_t j = 0 ; j < i ; ++j )
+                BOOST_TEST(s1[j] == T(j));
+            for ( size_t j = i+1 ; j < N ; ++j )
+                BOOST_TEST(s1[j-1] == T(j));
+        }
+    }
+    // erase(first, last)
+    {
+        size_t n = N/3;
+        for ( size_t i = 0 ; i <= N ; ++i )
+        {
+            static_vector s1(s);
+            size_t removed = i + n < N ? n : N - i;
+            It it = s1.erase(s1.begin() + i, s1.begin() + i + removed);
+            BOOST_TEST(s1.begin() + i == it);
+            BOOST_TEST(s1.size() == N - removed);
+            for ( size_t j = 0 ; j < i ; ++j )
+                BOOST_TEST(s1[j] == T(j));
+            for ( size_t j = i+n ; j < N ; ++j )
+                BOOST_TEST(s1[j-n] == T(j));
+        }
+    }
+}
+
+template 
+void test_insert(SV const& s, C const& c)
+{
+    size_t h = N/2;
+    size_t n = size_t(h/1.5f);
+
+    for ( size_t i = 0 ; i <= h ; ++i )
+    {
+        static_vector s1(s);
+
+        typename C::const_iterator it = c.begin();
+        std::advance(it, n);
+        typename static_vector::iterator
+            it1 = s1.insert(s1.begin() + i, c.begin(), it);
+
+        BOOST_TEST(s1.begin() + i == it1);
+        BOOST_TEST(s1.size() == h+n);
+        for ( size_t j = 0 ; j < i ; ++j )
+            BOOST_TEST(s1[j] == T(j));
+        for ( size_t j = 0 ; j < n ; ++j )
+            BOOST_TEST(s1[j+i] == T(100 + j));
+        for ( size_t j = 0 ; j < h-i ; ++j )
+            BOOST_TEST(s1[j+i+n] == T(j+i));
+    }
+}
+
+template 
+void test_insert_nd(T const& val)
+{
+    size_t h = N/2;
+
+    static_vector s, ss;
+    std::vector v;
+    std::list l;
+
+    typedef typename static_vector::iterator It;
+
+    for ( size_t i = 0 ; i < h ; ++i )
+    {
+        s.push_back(T(i));
+        ss.push_back(T(100 + i));
+        v.push_back(T(100 + i));
+        l.push_back(T(100 + i));
+    }
+
+    // insert(pos, val)
+    {
+        for ( size_t i = 0 ; i <= h ; ++i )
+        {
+            static_vector s1(s);
+            It it = s1.insert(s1.begin() + i, val);
+            BOOST_TEST(s1.begin() + i == it);
+            BOOST_TEST(s1.size() == h+1);
+            for ( size_t j = 0 ; j < i ; ++j )
+                BOOST_TEST(s1[j] == T(j));
+            BOOST_TEST(s1[i] == val);
+            for ( size_t j = 0 ; j < h-i ; ++j )
+                BOOST_TEST(s1[j+i+1] == T(j+i));
+        }
+    }
+    // insert(pos, n, val)
+    {
+        size_t n = size_t(h/1.5f);
+        for ( size_t i = 0 ; i <= h ; ++i )
+        {
+            static_vector s1(s);
+            It it = s1.insert(s1.begin() + i, n, val);
+            BOOST_TEST(s1.begin() + i == it);
+            BOOST_TEST(s1.size() == h+n);
+            for ( size_t j = 0 ; j < i ; ++j )
+                BOOST_TEST(s1[j] == T(j));
+            for ( size_t j = 0 ; j < n ; ++j )
+                BOOST_TEST(s1[j+i] == val);
+            for ( size_t j = 0 ; j < h-i ; ++j )
+                BOOST_TEST(s1[j+i+n] == T(j+i));
+        }
+    }
+    // insert(pos, first, last)
+    test_insert(s, ss);
+    test_insert(s, v);
+    test_insert(s, l);
+
+#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
+    stable_vector bsv(ss.begin(), ss.end());
+    vector bv(ss.begin(), ss.end());
+    test_insert(s, bv);
+    test_insert(s, bsv);
+#endif
+}
+
+template 
+void test_capacity_0_nd()
+{
+    static_vector v(5u, T(0));
+
+    static_vector s;
+    BOOST_TEST(s.size() == 0);
+    BOOST_TEST(s.capacity() == 0);
+#ifndef BOOST_NO_EXCEPTIONS
+    BOOST_TEST_THROW(s.at(0), std::out_of_range);
+    BOOST_TEST_THROW(s.resize(5u, T(0)), std::bad_alloc);
+    BOOST_TEST_THROW(s.push_back(T(0)), std::bad_alloc);
+    BOOST_TEST_THROW(s.insert(s.end(), T(0)), std::bad_alloc);
+    BOOST_TEST_THROW(s.insert(s.end(), 5u, T(0)), std::bad_alloc);
+    BOOST_TEST_THROW(s.insert(s.end(), v.begin(), v.end()), std::bad_alloc);
+    BOOST_TEST_THROW(s.assign(v.begin(), v.end()), std::bad_alloc);
+    BOOST_TEST_THROW(s.assign(5u, T(0)), std::bad_alloc);
+    try{
+        static_vector s2(v.begin(), v.end());
+        BOOST_TEST(false);
+    }catch(std::bad_alloc &){}
+    try{
+        static_vector s1(5u, T(0));
+        BOOST_TEST(false);
+    }catch(std::bad_alloc &){}
+#endif // BOOST_NO_EXCEPTIONS
+}
+
+template 
+void test_exceptions_nd()
+{
+    static_vector v(N, T(0));
+    static_vector s(N/2, T(0));
+
+#ifndef BOOST_NO_EXCEPTIONS
+    BOOST_TEST_THROW(s.resize(N, T(0)), std::bad_alloc);
+    BOOST_TEST_THROW(s.push_back(T(0)), std::bad_alloc);
+    BOOST_TEST_THROW(s.insert(s.end(), T(0)), std::bad_alloc);
+    BOOST_TEST_THROW(s.insert(s.end(), N, T(0)), std::bad_alloc);
+    BOOST_TEST_THROW(s.insert(s.end(), v.begin(), v.end()), std::bad_alloc);
+    BOOST_TEST_THROW(s.assign(v.begin(), v.end()), std::bad_alloc);
+    BOOST_TEST_THROW(s.assign(N, T(0)), std::bad_alloc);
+    try{
+        static_vector s2(v.begin(), v.end());
+        BOOST_TEST(false);
+    }catch(std::bad_alloc &){}
+    try{
+        static_vector s1(N, T(0));
+        BOOST_TEST(false);
+    }catch(std::bad_alloc &){}
+#endif // BOOST_NO_EXCEPTIONS
+}
+
+template 
+void test_swap_and_move_nd()
+{
+    {
+        static_vector v1, v2, v3, v4;
+        static_vector s1, s2;
+        static_vector s4;
+
+        for (size_t i = 0 ; i < N ; ++i )
+        {
+            v1.push_back(T(i));
+            v2.push_back(T(i));
+            v3.push_back(T(i));
+            v4.push_back(T(i));
+        }
+        for (size_t i = 0 ; i < N/2 ; ++i )
+        {
+            s1.push_back(T(100 + i));
+            s2.push_back(T(100 + i));
+            s4.push_back(T(100 + i));
+        }
+
+        s1.swap(v1);
+        s2 = boost::move(v2);
+        static_vector s3(boost::move(v3));
+        s4.swap(v4);
+
+        BOOST_TEST(v1.size() == N/2);
+        BOOST_TEST(s1.size() == N);
+        //iG moving does not imply emptying source
+        //BOOST_TEST(v2.size() == 0);
+        BOOST_TEST(s2.size() == N);
+        //iG moving does not imply emptying source
+        //BOOST_TEST(v3.size() == 0);
+        BOOST_TEST(s3.size() == N);
+        BOOST_TEST(v4.size() == N/2);
+        BOOST_TEST(s4.size() == N);
+        for (size_t i = 0 ; i < N/2 ; ++i )
+        {
+            BOOST_TEST(v1[i] == T(100 + i));
+            BOOST_TEST(v4[i] == T(100 + i));
+        }
+        for (size_t i = 0 ; i < N ; ++i )
+        {
+            BOOST_TEST(s1[i] == T(i));
+            BOOST_TEST(s2[i] == T(i));
+            BOOST_TEST(s3[i] == T(i));
+            BOOST_TEST(s4[i] == T(i));
+        }
+    }
+    {
+        static_vector v1, v2, v3;
+        static_vector s1, s2;
+
+        for (size_t i = 0 ; i < N/2 ; ++i )
+        {
+            v1.push_back(T(i));
+            v2.push_back(T(i));
+            v3.push_back(T(i));
+        }
+        for (size_t i = 0 ; i < N/3 ; ++i )
+        {
+            s1.push_back(T(100 + i));
+            s2.push_back(T(100 + i));
+        }
+
+        s1.swap(v1);
+        s2 = boost::move(v2);
+        static_vector s3(boost::move(v3));
+
+        BOOST_TEST(v1.size() == N/3);
+        BOOST_TEST(s1.size() == N/2);
+        //iG moving does not imply emptying source
+        //BOOST_TEST(v2.size() == 0);
+        BOOST_TEST(s2.size() == N/2);
+        //iG moving does not imply emptying source
+        //BOOST_TEST(v3.size() == 0);
+        BOOST_TEST(s3.size() == N/2);
+        for (size_t i = 0 ; i < N/3 ; ++i )
+            BOOST_TEST(v1[i] == T(100 + i));
+        for (size_t i = 0 ; i < N/2 ; ++i )
+        {
+            BOOST_TEST(s1[i] == T(i));
+            BOOST_TEST(s2[i] == T(i));
+            BOOST_TEST(s3[i] == T(i));
+        }
+    }
+    {
+        static_vector v(N, T(0));
+        static_vector s(N/2, T(1));
+#ifndef BOOST_NO_EXCEPTIONS
+        BOOST_TEST_THROW(s.swap(v), std::bad_alloc);
+        v.resize(N, T(0));
+        BOOST_TEST_THROW(s = boost::move(v), std::bad_alloc);
+        v.resize(N, T(0));
+        try {
+            static_vector s2(boost::move(v));
+            BOOST_TEST(false);
+        } catch (std::bad_alloc &) {}
+#endif // BOOST_NO_EXCEPTIONS
+    }
+}
+
+template 
+void test_emplace_0p()
+{
+    //emplace_back()
+    {
+        static_vector v;
+
+        for (int i = 0 ; i < int(N) ; ++i )
+            v.emplace_back();
+        BOOST_TEST(v.size() == N);
+#ifndef BOOST_NO_EXCEPTIONS
+        BOOST_TEST_THROW(v.emplace_back(), std::bad_alloc);
+#endif
+    }
+}
+
+template 
+void test_emplace_2p()
+{
+    //emplace_back(pos, int, int)
+    {
+        static_vector v;
+
+        for (int i = 0 ; i < int(N) ; ++i )
+            v.emplace_back(i, 100 + i);
+        BOOST_TEST(v.size() == N);
+#ifndef BOOST_NO_EXCEPTIONS
+        BOOST_TEST_THROW(v.emplace_back(N, 100 + N), std::bad_alloc);
+#endif
+        BOOST_TEST(v.size() == N);
+        for (int i = 0 ; i < int(N) ; ++i )
+            BOOST_TEST(v[i] == T(i, 100 + i));
+    }
+
+    // emplace(pos, int, int)
+    {
+        typedef typename static_vector::iterator It;
+
+        int h = N / 2;
+
+        static_vector v;
+        for ( int i = 0 ; i < h ; ++i )
+            v.emplace_back(i, 100 + i);
+
+        for ( int i = 0 ; i <= h ; ++i )
+        {
+            static_vector vv(v);
+            It it = vv.emplace(vv.begin() + i, i+100, i+200);
+            BOOST_TEST(vv.begin() + i == it);
+            BOOST_TEST(vv.size() == size_t(h+1));
+            for ( int j = 0 ; j < i ; ++j )
+                BOOST_TEST(vv[j] == T(j, j+100));
+            BOOST_TEST(vv[i] == T(i+100, i+200));
+            for ( int j = 0 ; j < h-i ; ++j )
+                BOOST_TEST(vv[j+i+1] == T(j+i, j+i+100));
+        }
+    }
+}
+
+template 
+void test_sv_elem(T const& t)
+{
+    typedef static_vector V;
+
+    static_vector v;
+
+    v.push_back(V(N/2, t));
+    V vvv(N/2, t);
+    v.push_back(boost::move(vvv));
+    v.insert(v.begin(), V(N/2, t));
+    v.insert(v.end(), V(N/2, t));
+    v.emplace_back(N/2, t);
+}
+
+int main(int, char* [])
+{
+    BOOST_TEST(counting_value::count() == 0);
+
+    test_ctor_ndc();
+    test_ctor_ndc();
+    test_ctor_ndc();
+    BOOST_TEST(counting_value::count() == 0);
+    test_ctor_ndc();
+    test_ctor_ndc();
+
+    test_ctor_nc(5);
+    test_ctor_nc(5);
+    test_ctor_nc(5);
+    BOOST_TEST(counting_value::count() == 0);
+    test_ctor_nc(5);
+    test_ctor_nc(5);
+
+    test_ctor_nd(5, 1);
+    test_ctor_nd(5, value_nd(1));
+    test_ctor_nd(5, counting_value(1));
+    BOOST_TEST(counting_value::count() == 0);
+    test_ctor_nd(5, shptr_value(1));
+    test_ctor_nd(5, produce());
+
+    test_resize_nc(5);
+    test_resize_nc(5);
+    test_resize_nc(5);
+    BOOST_TEST(counting_value::count() == 0);
+    test_resize_nc(5);
+    test_resize_nc(5);
+
+    test_resize_nd(5, 1);
+    test_resize_nd(5, value_nd(1));
+    test_resize_nd(5, counting_value(1));
+    BOOST_TEST(counting_value::count() == 0);
+    test_resize_nd(5, shptr_value(1));
+    test_resize_nd(5, produce());
+
+    test_push_back_nd();
+    test_push_back_nd();
+    test_push_back_nd();
+    BOOST_TEST(counting_value::count() == 0);
+    test_push_back_nd();
+    test_push_back_nd();
+
+    test_pop_back_nd();
+    test_pop_back_nd();
+    test_pop_back_nd();
+    BOOST_TEST(counting_value::count() == 0);
+    test_pop_back_nd();
+    test_pop_back_nd();
+
+    test_copy_and_assign_nd(1);
+    test_copy_and_assign_nd(value_nd(1));
+    test_copy_and_assign_nd(counting_value(1));
+    BOOST_TEST(counting_value::count() == 0);
+    test_copy_and_assign_nd(shptr_value(1));
+    test_copy_and_assign_nd(produce());
+
+    test_iterators_nd();
+    test_iterators_nd();
+    test_iterators_nd();
+    BOOST_TEST(counting_value::count() == 0);
+    test_iterators_nd();
+    test_iterators_nd();
+
+    test_erase_nd();
+    test_erase_nd();
+    test_erase_nd();
+    BOOST_TEST(counting_value::count() == 0);
+    test_erase_nd();
+    test_erase_nd();
+
+    test_insert_nd(50);
+    test_insert_nd(value_nd(50));
+    test_insert_nd(counting_value(50));
+    BOOST_TEST(counting_value::count() == 0);
+    test_insert_nd(shptr_value(50));
+    test_insert_nd(produce());
+
+    test_capacity_0_nd();
+    test_capacity_0_nd();
+    test_capacity_0_nd();
+    BOOST_TEST(counting_value::count() == 0);
+    test_capacity_0_nd();
+    test_capacity_0_nd();
+
+    test_exceptions_nd();
+    test_exceptions_nd();
+    test_exceptions_nd();
+    BOOST_TEST(counting_value::count() == 0);
+    test_exceptions_nd();
+    test_exceptions_nd();
+
+    test_swap_and_move_nd();
+    test_swap_and_move_nd();
+    test_swap_and_move_nd();
+    BOOST_TEST(counting_value::count() == 0);
+    test_swap_and_move_nd();
+    test_swap_and_move_nd();
+
+    test_emplace_0p();
+    BOOST_TEST(counting_value::count() == 0);
+
+    test_emplace_2p();
+    BOOST_TEST(counting_value::count() == 0);
+
+    test_sv_elem(50);
+    test_sv_elem(value_nd(50));
+    test_sv_elem(counting_value(50));
+    BOOST_TEST(counting_value::count() == 0);
+    test_sv_elem(shptr_value(50));
+    test_sv_elem(copy_movable(50));
+
+    return boost::report_errors();
+}
+
+#include 
diff --git a/test/static_vector_test.hpp b/test/static_vector_test.hpp
new file mode 100644
index 0000000..3dfe697
--- /dev/null
+++ b/test/static_vector_test.hpp
@@ -0,0 +1,99 @@
+// Boost.Container static_vector
+// Unit Test
+
+// Copyright (c) 2012-2013 Adam Wulkiewicz, Lodz, Poland.
+// Copyright (c) 2012-2013 Andrew Hundt.
+
+// Use, modification and distribution is subject to 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)
+
+#ifndef BOOST_CONTAINER_TEST_STATIC_VECTOR_TEST_HPP
+#define BOOST_CONTAINER_TEST_STATIC_VECTOR_TEST_HPP
+
+#include 
+
+#include 
+#include "movable.hpp"
+
+using namespace boost::container;
+
+class value_ndc
+{
+public:
+    explicit value_ndc(int a) : aa(a) {}
+    ~value_ndc() {}
+    bool operator==(value_ndc const& v) const { return aa == v.aa; }
+    bool operator<(value_ndc const& v) const { return aa < v.aa; }
+private:
+    value_ndc(value_ndc const&) {}
+    value_ndc & operator=(value_ndc const&) { return *this; }
+    int aa;
+};
+
+class value_nd
+{
+public:
+    explicit value_nd(int a) : aa(a) {}
+    ~value_nd() {}
+    bool operator==(value_nd const& v) const { return aa == v.aa; }
+    bool operator<(value_nd const& v) const { return aa < v.aa; }
+private:
+    int aa;
+};
+
+class value_nc
+{
+public:
+    explicit value_nc(int a = 0) : aa(a) {}
+    ~value_nc() {}
+    bool operator==(value_nc const& v) const { return aa == v.aa; }
+    bool operator<(value_nc const& v) const { return aa < v.aa; }
+private:
+    value_nc(value_nc const&) {}
+    value_nc & operator=(value_ndc const&) { return *this; }
+    int aa;
+};
+
+class counting_value
+{
+    BOOST_COPYABLE_AND_MOVABLE(counting_value)
+
+public:
+    explicit counting_value(int a = 0, int b = 0) : aa(a), bb(b) { ++c(); }
+    counting_value(counting_value const& v) : aa(v.aa), bb(v.bb) { ++c(); }
+    counting_value(BOOST_RV_REF(counting_value) p) : aa(p.aa), bb(p.bb) { p.aa = 0; p.bb = 0; ++c(); }                      // Move constructor
+    counting_value& operator=(BOOST_RV_REF(counting_value) p) { aa = p.aa; p.aa = 0; bb = p.bb; p.bb = 0; return *this; }   // Move assignment
+    counting_value& operator=(BOOST_COPY_ASSIGN_REF(counting_value) p) { aa = p.aa; bb = p.bb; return *this; }              // Copy assignment
+    ~counting_value() { --c(); }
+    bool operator==(counting_value const& v) const { return aa == v.aa && bb == v.bb; }
+    bool operator<(counting_value const& v) const { return aa < v.aa || ( aa == v.aa && bb < v.bb ); }
+    static size_t count() { return c(); }
+
+private:
+    static size_t & c() { static size_t co = 0; return co; }
+    int aa, bb;
+};
+
+namespace boost {
+
+template <>
+struct has_nothrow_move
+{
+    static const bool value = true;
+};
+
+}
+
+class shptr_value
+{
+    typedef boost::shared_ptr Ptr;
+public:
+    explicit shptr_value(int a = 0) : m_ptr(new int(a)) {}
+    bool operator==(shptr_value const& v) const { return *m_ptr == *(v.m_ptr); }
+    bool operator<(shptr_value const& v) const { return *m_ptr < *(v.m_ptr); }
+private:
+    boost::shared_ptr m_ptr;
+};
+
+#endif // BOOST_CONTAINER_TEST_STATIC_VECTOR_TEST_HPP

From aa74aab3d274f29fa0aa78ebb7c3f2494ce6dc0f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Wed, 20 Feb 2013 08:27:49 +0000
Subject: [PATCH 75/93] Fixes #8118

[SVN r83044]
---
 include/boost/container/stable_vector.hpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp
index 759124c..189840b 100644
--- a/include/boost/container/stable_vector.hpp
+++ b/include/boost/container/stable_vector.hpp
@@ -945,7 +945,7 @@ class stable_vector
    size_type size() const BOOST_CONTAINER_NOEXCEPT
    {
       const size_type index_size = this->index.size();
-      return index_size ? (index_size - ExtraPointers) : 0;
+      return (index_size - ExtraPointers) & (std::size_t(0u) -std::size_t(index_size != 0));
    }
 
    //! Effects: Returns the largest possible size of the stable_vector.
@@ -1001,7 +1001,9 @@ class stable_vector
       const size_type node_extra_capacity   = this->internal_data.pool_size;
       const size_type extra_capacity        = (bucket_extra_capacity < node_extra_capacity)
          ? bucket_extra_capacity : node_extra_capacity;
-      return (index_size ? (index_size - ExtraPointers + extra_capacity) : index_size);
+      const size_type index_offset =
+         (ExtraPointers + extra_capacity) & (size_type(0u) - size_type(index_size != 0));
+      return index_size - index_offset;
    }
 
    //! Effects: If n is less than or equal to capacity(), this call has no
@@ -1102,7 +1104,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    reference back() BOOST_CONTAINER_NOEXCEPT
-   {  return static_cast(*this->index[this->size() - ExtraPointers]).value;  }
+   {  return static_cast(*this->index[this->size()-1u]).value;  }
 
    //! Requires: !empty()
    //!
@@ -1113,7 +1115,7 @@ class stable_vector
    //!
    //! Complexity: Constant.
    const_reference back() const BOOST_CONTAINER_NOEXCEPT
-   {  return static_cast(*this->index[this->size() - ExtraPointers]).value;  }
+   {  return static_cast(*this->index[this->size()-1u]).value;  }
 
    //! Requires: size() > n.
    //!

From b3d5f6480b7982ea74ba99edf25b5a8316cd6c5d Mon Sep 17 00:00:00 2001
From: John Maddock 
Date: Wed, 20 Feb 2013 18:29:30 +0000
Subject: [PATCH 76/93] Fix broken links in doc build. Move some xsl:param's
 into individual library's Jamfiles. Refs #7899.

[SVN r83050]
---
 doc/Jamfile.v2 | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2
index f0d1056..5c470ce 100644
--- a/doc/Jamfile.v2
+++ b/doc/Jamfile.v2
@@ -48,8 +48,8 @@ boostbook standalone
    :
       container
    :
-        boost.root=../../../..
-        boost.libraries=../../../../libs/libraries.htm
+        html:boost.root=../../../..
+        html:boost.libraries=../../../../libs/libraries.htm
         generate.section.toc.level=3
         chunk.first.sections=1
         pdf:img.src.path=$(images_location)/
@@ -71,6 +71,7 @@ boostbook standalone
        
         # Choose indexing method for html:
         html:on
+        docbook:on
        
         # Set the name of the script file to use (index.idx is popular):
         $(here)/index.idx
@@ -89,3 +90,5 @@ boostbook standalone
 
 install pdfinstall : standalone/pdf : PDF . container.pdf ;
 explicit pdfinstall ;
+
+

From 0896d04ddff022766a35b029e5e70d58812354f9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= 
Date: Sun, 24 Feb 2013 13:13:36 +0000
Subject: [PATCH 77/93] Additional vector speed improvements, added basic
 benchmark against varray

[SVN r83126]
---
 bench/Jamfile.v2                              |   34 +
 bench/bench_static_vector.cpp                 |  147 ++
 bench/detail/varray.hpp                       | 2274 +++++++++++++++++
 bench/detail/varray_concept.hpp               |   60 +
 bench/detail/varray_util.hpp                  |  712 ++++++
 bench/varray.hpp                              |  994 +++++++
 doc/container.qbk                             |    3 +-
 include/boost/container/allocator_traits.hpp  |   16 +-
 .../container/detail/advanced_insert_int.hpp  |   16 +-
 include/boost/container/static_vector.hpp     |   68 +-
 include/boost/container/vector.hpp            |  539 ++--
 proj/vc7ide/container.sln                     |   16 +
 proj/vc7ide/container.vcproj                  |   26 +
 test/Jamfile.v2                               |    2 +-
 test/movable.hpp                              |   92 -
 test/movable_int.hpp                          |   97 +-
 test/static_vector_test.cpp                   | 1115 ++++----
 test/static_vector_test.hpp                   |    2 +-
 test/vector_test.hpp                          |    7 +-
 19 files changed, 5296 insertions(+), 924 deletions(-)
 create mode 100644 bench/Jamfile.v2
 create mode 100644 bench/bench_static_vector.cpp
 create mode 100644 bench/detail/varray.hpp
 create mode 100644 bench/detail/varray_concept.hpp
 create mode 100644 bench/detail/varray_util.hpp
 create mode 100644 bench/varray.hpp
 delete mode 100644 test/movable.hpp

diff --git a/bench/Jamfile.v2 b/bench/Jamfile.v2
new file mode 100644
index 0000000..25add18
--- /dev/null
+++ b/bench/Jamfile.v2
@@ -0,0 +1,34 @@
+# Boost Container Library Test Jamfile
+
+#  (C) Copyright Ion Gaztanaga 2009.
+# Use, modification and distribution are subject to 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)
+
+# Adapted from John Maddock's TR1 Jamfile.v2
+# Copyright John Maddock 2005.
+# Use, modification and distribution are subject to 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)
+
+# this rule enumerates through all the sources and invokes
+# the run rule for each source, the result is a list of all
+# the run rules, which we can pass on to the test_suite rule:
+
+rule test_all
+{
+   local all_rules = ;
+
+   for local fileb in [ glob *.cpp ]
+   {
+      all_rules += [ run $(fileb) /boost/timer//boost_timer /boost/system//boost_system /boost/thread//boost_thread
+      :  # additional args
+      :  # test-files
+      :  # requirements
+      ] ;
+   }
+
+   return $(all_rules) ;
+}
+
+test-suite container_test : [ test_all r ] ;
diff --git a/bench/bench_static_vector.cpp b/bench/bench_static_vector.cpp
new file mode 100644
index 0000000..bbcaed1
--- /dev/null
+++ b/bench/bench_static_vector.cpp
@@ -0,0 +1,147 @@
+// benchmark based on: http://cpp-next.com/archive/2010/10/howards-stl-move-semantics-benchmark/
+//
+//  @file   bench_static_vector.cpp
+//  @date   Aug 14, 2011
+//  @author Andrew Hundt 
+//
+//  (C) 2011-2012 Andrew Hundt 
+//  (C) 2013 Ion Gaztanaga
+//
+//  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)
+//
+//  @brief  varray_benchmark.cpp compares the performance of boost::container::varray to boost::container::vector
+
+#include "varray.hpp"
+#include "boost/container/vector.hpp"
+#include "boost/container/static_vector.hpp"
+#include "../test/movable_int.hpp"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+using boost::timer::cpu_timer;
+using boost::timer::cpu_times;
+using boost::timer::nanosecond_type;
+
+#ifdef NDEBUG
+static const std::size_t N = 1000;
+#else
+static const std::size_t N = 100;
+#endif
+
+#define BENCH_SIMPLE_CONSTRUCTION
+//#define BENCH_TRIVIAL_TYPE
+
+#ifdef BENCH_TRIVIAL_TYPE
+typedef std::size_t basic_type_t;
+#else
+typedef boost::container::test::copyable_int basic_type_t;
+#endif
+
+template
+T &get_set(std::size_t)
+{
+   #ifdef BENCH_SIMPLE_CONSTRUCTION
+   T &t = *new T(N);
+   for (std::size_t i = 0; i < N; ++i)
+      t[i] = basic_type_t(std::rand());
+   #else
+   T &t = *new T;
+   t.reserve(N);
+   for (std::size_t i = 0; i < N; ++i)
+      t.push_back(basic_type_t(std::rand()));
+   #endif
+   return t;
+}
+
+template
+T &generate()
+{
+   T &v = *new T;
+   v.reserve(N);
+
+   for (std::size_t i = 0; i < N; ++i){
+      typename T::reference r = get_set(i);
+      v.push_back(boost::move(r));
+      delete &r;
+   }
+   return v;
+}
+
+template
+cpu_times time_it()
+{
+   cpu_timer sortTime,rotateTime,destructionTime;
+   sortTime.stop();rotateTime.stop();destructionTime.stop();
+   cpu_timer totalTime, constructTime;
+   std::srand (0);
+   for(std::size_t i = 0; i< N; ++i){
+
+     constructTime.resume();
+     {
+      T &v = generate();
+      constructTime.stop();
+      sortTime.resume();
+      std::sort(v.begin(), v.end());
+      sortTime.stop();
+      rotateTime.resume();
+      std::rotate(v.begin(), v.begin() + v.size()/2, v.end());
+      rotateTime.stop();
+
+      destructionTime.resume();
+      delete &v;
+     }
+     destructionTime.stop();
+   }
+   totalTime.stop();
+   std::cout << "  construction took " << boost::timer::format(constructTime.elapsed());
+   std::cout << "  sort took       " << boost::timer::format(sortTime.elapsed());
+   std::cout << "  rotate took      " << boost::timer::format(rotateTime.elapsed());
+   std::cout << "  destruction took  " << boost::timer::format(destructionTime.elapsed());
+   std::cout << "  Total time =     " << boost::timer::format(totalTime.elapsed()) << std::endl;
+   return totalTime.elapsed();
+}
+
+void compare_times(cpu_times time_numerator, cpu_times time_denominator){
+   std::cout
+   << "\n  wall        = " << ((double)time_numerator.wall/(double)time_denominator.wall)
+   << "\n  user        = " << ((double)time_numerator.user/(double)time_denominator.user)
+   << "\n  system      = " << ((double)time_numerator.system/(double)time_denominator.system)
+   << "\n  (user+system) = " << ((double)(time_numerator.system+time_numerator.user)/(double)(time_denominator.system+time_denominator.user)) << "\n\n";
+}
+
+int main()
+{
+   try {
+      std::cout << "N = " << N << "\n\n";
+
+      std::cout << "varray benchmark:\n";
+      cpu_times time_varray = time_it,N > >();
+
+      std::cout << "boost::container::static_vector benchmark\n";
+      cpu_times time_boost_static_vector = time_it,N > >();
+
+      std::cout << "boost::container::vector benchmark\n";
+      cpu_times time_boost_vector = time_it > >();
+
+      std::cout << "std::vector benchmark\n";
+      cpu_times time_standard_vector = time_it > >();
+
+      std::cout << "varray/boost::container::vector total time comparison:";
+      compare_times(time_varray, time_boost_vector);
+
+      std::cout << "varray/boost::container::static_vector total time comparison:";
+      compare_times(time_varray, time_boost_static_vector);
+
+      std::cout << "varray/std::vector total time comparison:";
+      compare_times(time_varray,time_standard_vector);
+   }catch(std::exception e){
+      std::cout << e.what();
+   }
+   return 1;
+}
diff --git a/bench/detail/varray.hpp b/bench/detail/varray.hpp
new file mode 100644
index 0000000..e28eb47
--- /dev/null
+++ b/bench/detail/varray.hpp
@@ -0,0 +1,2274 @@
+// Boost.Container varray
+//
+// Copyright (c) 2012-2013 Adam Wulkiewicz, Lodz, Poland.
+// Copyright (c) 2011-2013 Andrew Hundt.
+//
+// Use, modification and distribution is subject to 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)
+
+#ifndef BOOST_CONTAINER_DETAIL_VARRAY_HPP
+#define BOOST_CONTAINER_DETAIL_VARRAY_HPP
+
+#if (defined _MSC_VER) && (_MSC_VER >= 1200)
+#  pragma once
+#endif
+
+#include 
+#include 
+#include 
+
+#include "varray_util.hpp"
+#include "varray_concept.hpp"
+#include 
+
+#ifndef BOOST_NO_EXCEPTIONS
+#include 
+#endif // BOOST_NO_EXCEPTIONS
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+// TODO - use std::reverse_iterator and std::iterator_traits
+// instead Boost.Iterator to remove dependency?
+// or boost/detail/iterator.hpp ?
+#include 
+
+/**
+ * @defgroup varray_non_member varray non-member functions
+ */
+
+namespace boost { namespace container { namespace container_detail {
+
+// Forward declaration
+template 
+class varray;
+
+namespace strategy {
+    
+// TODO: Improve error messages
+//       possibly include N in the strategy, and provide size as an optoinal allocate_failed parameter?
+//       Example of current error with reserve(4) when capacity is 3:
+//          "boost/container/varray.hpp(66): size can't exceed the capacity"
+//       Could say
+//          "cannot reserve(4) due to fixed capacity of 3 elements"    
+
+//! @brief The default strategy.
+//!
+//! @tparam Value Type of element stored in the container.
+template 
+struct def
+{
+    typedef Value value_type;
+    typedef std::size_t size_type;
+    typedef std::ptrdiff_t difference_type;
+    typedef Value* pointer;
+    typedef const Value* const_pointer;
+    typedef Value& reference;
+    typedef const Value& const_reference;
+
+    static void allocate_failed()
+    {
+        BOOST_ASSERT_MSG(false, "size can't exceed the capacity");
+    }
+};
+
+//! @brief The strategy adapting info from passed Allocator.
+//!
+//! This strategy defines the same types that are defined in the Allocator.
+//!
+//! @tparam Allocator The Allocator which will be adapted.
+template 
+struct allocator_adaptor
+{
+    typedef typename Allocator::value_type value_type;
+    typedef typename Allocator::size_type size_type;
+    typedef typename Allocator::difference_type difference_type;
+    typedef typename Allocator::pointer pointer;
+    typedef typename Allocator::const_pointer const_pointer;
+    typedef typename Allocator::reference reference;
+    typedef typename Allocator::const_reference const_reference;
+
+    static void allocate_failed()
+    {
+        BOOST_ASSERT_MSG(false, "size can't exceed the capacity");
+    }
+};
+
+} // namespace strategy
+
+struct varray_error_handler
+{
+    template 
+    static void check_capacity(varray const&, std::size_t s)
+    {
+        if ( Capacity < s )
+            S::allocate_failed();
+    }
+
+    template 
+    static void check_at(varray const& v,
+                         typename varray::size_type i)
+    {
+        (void)v;
+        (void)i;
+// TODO - use BOOST_THROW_EXCEPTION here?
+#ifndef BOOST_NO_EXCEPTIONS
+        if ( v.size() <= i )
+            throw std::out_of_range("index out of bounds");
+#else // BOOST_NO_EXCEPTIONS
+        BOOST_ASSERT_MSG(i < v.size(), "index out of bounds");
+#endif // BOOST_NO_EXCEPTIONS
+    }
+
+    template 
+    static void check_operator_brackets(varray const& v,
+                                        typename varray::size_type i)
+    {
+        (void)v;
+        (void)i;
+        BOOST_ASSERT_MSG(i < v.size(), "index out of bounds");
+    }
+
+    template 
+    static void check_empty(varray const& v)
+    {
+        (void)v;
+        BOOST_ASSERT_MSG(0 < v.size(), "the container is empty");
+    }
+
+    template 
+    static void check_iterator_end_neq(varray const& v,
+                                       typename varray::const_iterator position)
+    {
+        (void)v;
+        (void)position;
+        BOOST_ASSERT_MSG(v.begin() <= position && position < v.end(), "iterator out of bounds");
+    }
+
+    template 
+    static void check_iterator_end_eq(varray const& v,
+                                      typename varray::const_iterator position)
+    {
+        (void)v;
+        (void)position;
+        BOOST_ASSERT_MSG(v.begin() <= position && position <= v.end(), "iterator out of bounds");
+    }
+};
+
+template 
+struct varray_traits
+{
+    typedef typename Strategy::value_type value_type;
+    typedef typename Strategy::size_type size_type;
+    typedef typename Strategy::difference_type difference_type;
+    typedef typename Strategy::pointer pointer;
+    typedef typename Strategy::const_pointer const_pointer;
+    typedef typename Strategy::reference reference;
+    typedef typename Strategy::const_reference const_reference;
+
+    typedef varray_error_handler error_handler;
+
+    typedef boost::false_type use_memop_in_swap_and_move;
+    typedef boost::false_type use_optimized_swap;
+    typedef boost::false_type disable_trivial_init;
+};
+
+/**
+ * @brief A variable-size array container with fixed capacity.
+ *
+ * varray is a sequence container like boost::container::vector with contiguous storage that can
+ * change in size, along with the static allocation, low overhead, and fixed capacity of boost::array.
+ *
+ * A varray is a sequence that supports random access to elements, constant time insertion and
+ * removal of elements at the end, and linear time insertion and removal of elements at the beginning or 
+ * in the middle. The number of elements in a varray may vary dynamically up to a fixed capacity
+ * because elements are stored within the object itself similarly to an array. However, objects are 
+ * initialized as they are inserted into varray unlike C arrays or std::array which must construct
+ * all elements on instantiation. The behavior of varray enables the use of statically allocated
+ * elements in cases with complex object lifetime requirements that would otherwise not be trivially 
+ * possible.
+ *
+ * @par Error Handling
+ *  Insertion beyond the capacity and out of bounds errors result in undefined behavior unless
+ *  otherwise specified. In this respect if size() == capacity(), then varray::push_back()
+ *  behaves like std::vector pop_front() if size() == empty(). The reason for this difference
+ *  is because unlike vectors, varray does not perform allocation.
+ *
+ * @par Advanced Usage
+ *  Error handling behavior can be modified to more closely match std::vector exception behavior
+ *  when exceeding bounds by providing an alternate Strategy and varray_traits instantiation.
+ *
+ * @tparam Value    The type of element that will be stored.
+ * @tparam Capacity The maximum number of elements varray can store, fixed at compile time.
+ * @tparam Strategy Defines the public typedefs and error handlers,
+ *         implements StaticVectorStrategy and has some similarities
+ *         to an Allocator.
+ */
+template  >
+class varray
+{
+    typedef container_detail::varray_traits<
+        Value, Capacity, Strategy
+    > vt;
+    
+    typedef typename vt::error_handler errh;
+
+    BOOST_MPL_ASSERT_MSG(
+        ( boost::is_unsigned::value &&
+          sizeof(typename boost::uint_value_t::least) <= sizeof(typename vt::size_type) ),
+        SIZE_TYPE_IS_TOO_SMALL_FOR_SPECIFIED_CAPACITY,
+        (varray)
+    );
+
+    BOOST_CONCEPT_ASSERT((concept::VArrayStrategy));
+
+    typedef boost::aligned_storage<
+        sizeof(Value[Capacity]),
+        boost::alignment_of::value
+    > aligned_storage_type;
+
+    template 
+    friend class varray;
+
+    BOOST_COPYABLE_AND_MOVABLE(varray)
+
+#ifdef BOOST_NO_RVALUE_REFERENCES
+public:
+    template 
+    varray & operator=(varray & sv)
+    {
+        typedef varray other;
+        this->operator=(static_cast &>(const_cast(sv)));
+        return *this;
+    }
+#endif
+
+public:
+    //! @brief The type of elements stored in the container.
+    typedef typename vt::value_type value_type;
+    //! @brief The unsigned integral type used by the container.
+    typedef typename vt::size_type size_type;
+    //! @brief The pointers difference type.
+    typedef typename vt::difference_type difference_type;
+    //! @brief The pointer type.
+    typedef typename vt::pointer pointer;
+    //! @brief The const pointer type.
+    typedef typename vt::const_pointer const_pointer;
+    //! @brief The value reference type.
+    typedef typename vt::reference reference;
+    //! @brief The value const reference type.
+    typedef typename vt::const_reference const_reference;
+
+    //! @brief The iterator type.
+    typedef pointer iterator;
+    //! @brief The const iterator type.
+    typedef const_pointer const_iterator;
+    //! @brief The reverse iterator type.
+    typedef boost::reverse_iterator reverse_iterator;
+    //! @brief The const reverse iterator.
+    typedef boost::reverse_iterator const_reverse_iterator;
+
+    //! @brief The type of a strategy used by the varray.
+    typedef Strategy strategy_type;
+
+    //! @brief Constructs an empty varray.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    varray()
+        : m_size(0)
+    {}
+
+    //! @pre count <= capacity()
+    //!
+    //! @brief Constructs a varray containing count default constructed Values.
+    //!
+    //! @param count    The number of values which will be contained in the container.
+    //!
+    //! @par Throws
+    //!   If Value's default constructor throws.
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    explicit varray(size_type count)
+        : m_size(0)
+    {
+        this->resize(count);                                                        // may throw
+    }
+
+    //! @pre count <= capacity()
+    //!
+    //! @brief Constructs a varray containing count copies of value.
+    //!
+    //! @param count    The number of copies of a values that will be contained in the container.
+    //! @param value    The value which will be used to copy construct values.
+    //!
+    //! @par Throws
+    //!   If Value's copy constructor throws.
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    varray(size_type count, value_type const& value)
+        : m_size(0)
+    {
+        this->resize(count, value);                                                 // may throw
+    }
+
+    //! @pre
+    //!  @li distance(first, last) <= capacity()
+    //!  @li Iterator must meet the \c ForwardTraversalIterator concept.
+    //!
+    //! @brief Constructs a varray containing copy of a range [first, last).
+    //!
+    //! @param first    The iterator to the first element in range.
+    //! @param last     The iterator to the one after the last element in range.
+    //!
+    //! @par Throws
+    //!   If Value's constructor taking a dereferenced Iterator throws.
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    template 
+    varray(Iterator first, Iterator last)
+        : m_size(0)
+    {
+        BOOST_CONCEPT_ASSERT((boost_concepts::ForwardTraversal)); // Make sure you passed a ForwardIterator
+        
+        this->assign(first, last);                                                    // may throw
+    }
+
+    //! @brief Constructs a copy of other varray.
+    //!
+    //! @param other    The varray which content will be copied to this one.
+    //!
+    //! @par Throws
+    //!   If Value's copy constructor throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    varray(varray const& other)
+        : m_size(other.size())
+    {
+        namespace sv = varray_detail;
+        sv::uninitialized_copy(other.begin(), other.end(), this->begin());          // may throw
+    }
+
+    //! @pre other.size() <= capacity().
+    //!
+    //! @brief Constructs a copy of other varray.
+    //!
+    //! @param other    The varray which content will be copied to this one.
+    //!
+    //! @par Throws
+    //!   If Value's copy constructor throws.
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    template 
+    varray(varray const& other)
+        : m_size(other.size())
+    {
+        errh::check_capacity(*this, other.size());                                  // may throw
+        
+        namespace sv = varray_detail;
+        sv::uninitialized_copy(other.begin(), other.end(), this->begin());          // may throw
+    }
+
+    //! @brief Copy assigns Values stored in the other varray to this one.
+    //!
+    //! @param other    The varray which content will be copied to this one.
+    //!
+    //! @par Throws
+    //!   If Value's copy constructor or copy assignment throws.
+    //!
+    //! @par Complexity
+    //! Linear O(N).
+    varray & operator=(BOOST_COPY_ASSIGN_REF(varray) other)
+    {
+        this->assign(other.begin(), other.end());                                     // may throw
+
+        return *this;
+    }
+
+    //! @pre other.size() <= capacity()
+    //!
+    //! @brief Copy assigns Values stored in the other varray to this one.
+    //!
+    //! @param other    The varray which content will be copied to this one.
+    //!
+    //! @par Throws
+    //!   If Value's copy constructor or copy assignment throws.
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    template 
+// TEMPORARY WORKAROUND
+#if defined(BOOST_NO_RVALUE_REFERENCES)
+    varray & operator=(::boost::rv< varray > const& other)
+#else
+    varray & operator=(varray const& other)
+#endif
+    {
+        this->assign(other.begin(), other.end());                                     // may throw
+
+        return *this;
+    }
+
+    //! @brief Move constructor. Moves Values stored in the other varray to this one.
+    //!
+    //! @param other    The varray which content will be moved to this one.
+    //!
+    //! @par Throws
+    //!   @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor throws.
+    //!   @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor throws.
+    //! @internal
+    //!   @li It throws only if \c use_memop_in_swap_and_move is \c false_type - default.
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    varray(BOOST_RV_REF(varray) other)
+    {
+        typedef typename
+        vt::use_memop_in_swap_and_move use_memop_in_swap_and_move;
+
+        this->move_ctor_dispatch(other, use_memop_in_swap_and_move());
+    }
+
+    //! @pre other.size() <= capacity()
+    //!
+    //! @brief Move constructor. Moves Values stored in the other varray to this one.
+    //!
+    //! @param other    The varray which content will be moved to this one.
+    //!
+    //! @par Throws
+    //!   @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor throws.
+    //!   @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor throws.
+    //! @internal
+    //!   @li It throws only if \c use_memop_in_swap_and_move is false_type - default.
+    //! @endinternal
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    template 
+    varray(BOOST_RV_REF_3_TEMPL_ARGS(varray, value_type, C, S) other)
+        : m_size(other.m_size)
+    {
+        errh::check_capacity(*this, other.size());                                  // may throw
+
+        typedef typename
+        vt::use_memop_in_swap_and_move use_memop_in_swap_and_move;
+
+        this->move_ctor_dispatch(other, use_memop_in_swap_and_move());
+    }
+
+    //! @brief Move assignment. Moves Values stored in the other varray to this one.
+    //!
+    //! @param other    The varray which content will be moved to this one.
+    //!
+    //! @par Throws
+    //!   @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor or move assignment throws.
+    //!   @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws.
+    //! @internal
+    //!   @li It throws only if \c use_memop_in_swap_and_move is \c false_type - default.
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    varray & operator=(BOOST_RV_REF(varray) other)
+    {
+        if ( &other == this )
+            return *this;
+
+        typedef typename
+        vt::use_memop_in_swap_and_move use_memop_in_swap_and_move;
+
+        this->move_assign_dispatch(other, use_memop_in_swap_and_move());
+
+        return *this;
+    }
+
+    //! @pre other.size() <= capacity()
+    //!
+    //! @brief Move assignment. Moves Values stored in the other varray to this one.
+    //!
+    //! @param other    The varray which content will be moved to this one.
+    //!
+    //! @par Throws
+    //!   @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor or move assignment throws.
+    //!   @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws.
+    //! @internal
+    //!   @li It throws only if \c use_memop_in_swap_and_move is \c false_type - default.
+    //! @endinternal
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    template 
+    varray & operator=(BOOST_RV_REF_3_TEMPL_ARGS(varray, value_type, C, S) other)
+    {
+        errh::check_capacity(*this, other.size());                                  // may throw
+
+        typedef typename
+        vt::use_memop_in_swap_and_move use_memop_in_swap_and_move;
+
+        this->move_assign_dispatch(other, use_memop_in_swap_and_move());
+
+        return *this;
+    }
+
+    //! @brief Destructor. Destroys Values stored in this container.
+    //!
+    //! @par Throws
+    //!   Nothing
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    ~varray()
+    {
+        namespace sv = varray_detail;
+        sv::destroy(this->begin(), this->end());
+    }
+
+    //! @brief Swaps contents of the other varray and this one.
+    //!
+    //! @param other    The varray which content will be swapped with this one's content.
+    //!
+    //! @par Throws
+    //!   @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor or move assignment throws,
+    //!   @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws,
+    //! @internal
+    //!   @li It throws only if \c use_memop_in_swap_and_move and \c use_optimized_swap are \c false_type - default.
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    void swap(varray & other)
+    {
+        typedef typename
+        vt::use_optimized_swap use_optimized_swap;
+
+        this->swap_dispatch(other, use_optimized_swap());
+    }
+
+    //! @pre other.size() <= capacity() && size() <= other.capacity()
+    //!
+    //! @brief Swaps contents of the other varray and this one.
+    //!
+    //! @param other    The varray which content will be swapped with this one's content.
+    //!
+    //! @par Throws
+    //!   @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor or move assignment throws,
+    //!   @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws,
+    //! @internal
+    //!   @li It throws only if \c use_memop_in_swap_and_move and \c use_optimized_swap are \c false_type - default.
+    //! @endinternal
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    template 
+    void swap(varray & other)
+    {
+        errh::check_capacity(*this, other.size());
+        errh::check_capacity(other, this->size());
+
+        typedef typename
+        vt::use_optimized_swap use_optimized_swap;
+
+        this->swap_dispatch(other, use_optimized_swap()); 
+    }
+
+    //! @pre count <= capacity()
+    //!
+    //! @brief Inserts or erases elements at the end such that
+    //!   the size becomes count. New elements are default constructed.
+    //!
+    //! @param count    The number of elements which will be stored in the container.
+    //!
+    //! @par Throws
+    //!   If Value's default constructor throws.
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    void resize(size_type count)
+    {
+        namespace sv = varray_detail;
+        typedef typename vt::disable_trivial_init dti;
+
+        if ( count < m_size )
+        {
+            sv::destroy(this->begin() + count, this->end());
+        }
+        else
+        {
+            errh::check_capacity(*this, count);                                     // may throw
+
+            sv::uninitialized_fill(this->end(), this->begin() + count, dti()); // may throw
+        }
+        m_size = count; // update end
+    }
+
+    //! @pre count <= capacity()
+    //!
+    //! @brief Inserts or erases elements at the end such that
+    //!   the size becomes count. New elements are copy constructed from value.
+    //!
+    //! @param count    The number of elements which will be stored in the container.
+    //! @param value    The value used to copy construct the new element.
+    //!
+    //! @par Throws
+    //!   If Value's copy constructor throws.
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    void resize(size_type count, value_type const& value)
+    {
+        if ( count < m_size )
+        {
+            namespace sv = varray_detail;
+            sv::destroy(this->begin() + count, this->end());
+        }
+        else
+        {
+            errh::check_capacity(*this, count);                                     // may throw
+            
+            std::uninitialized_fill(this->end(), this->begin() + count, value);     // may throw
+        }
+        m_size = count; // update end
+    }
+
+    //! @pre count <= capacity()
+    //!
+    //! @brief This call has no effect because the Capacity of this container is constant.
+    //!
+    //! @param count    The number of elements which the container should be able to contain.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    void reserve(size_type count)
+    {
+        errh::check_capacity(*this, count);                                         // may throw
+    }
+
+    //! @pre size() < capacity()
+    //!
+    //! @brief Adds a copy of value at the end.
+    //!
+    //! @param value    The value used to copy construct the new element.
+    //!
+    //! @par Throws
+    //!   If Value's copy constructor throws.
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    void push_back(value_type const& value)
+    {
+        typedef typename vt::disable_trivial_init dti;
+
+        errh::check_capacity(*this, m_size + 1);                                    // may throw
+        
+        namespace sv = varray_detail;
+        sv::construct(dti(), this->end(), value);                                          // may throw
+        ++m_size; // update end
+    }
+
+    //! @pre size() < capacity()
+    //!
+    //! @brief Moves value to the end.
+    //!
+    //! @param value    The value to move construct the new element.
+    //!
+    //! @par Throws
+    //!   If Value's move constructor throws.
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    void push_back(BOOST_RV_REF(value_type) value)
+    {
+        typedef typename vt::disable_trivial_init dti;
+
+        errh::check_capacity(*this, m_size + 1);                                    // may throw
+
+        namespace sv = varray_detail;
+        sv::construct(dti(), this->end(), ::boost::move(value));                                          // may throw
+        ++m_size; // update end
+    }
+
+    //! @pre !empty()
+    //!
+    //! @brief Destroys last value and decreases the size.
+    //!
+    //! @par Throws
+    //!   Nothing by default.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    void pop_back()
+    {
+        errh::check_empty(*this);
+
+        namespace sv = varray_detail;
+        sv::destroy(this->end() - 1);
+        --m_size; // update end
+    }
+
+    //! @pre
+    //!  @li \c position must be a valid iterator of \c *this in range [begin(), end()].
+    //!  @li size() < capacity()
+    //!
+    //! @brief Inserts a copy of element at position.
+    //!
+    //! @param position    The position at which the new value will be inserted.
+    //! @param value       The value used to copy construct the new element.
+    //!
+    //! @par Throws
+    //!   @li If Value's copy constructor or copy assignment throws
+    //!   @li If Value's move constructor or move assignment throws.
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Constant or linear.
+    iterator insert(iterator position, value_type const& value)
+    {
+        return this->priv_insert(position, value);
+    }
+
+    //! @pre
+    //!  @li \c position must be a valid iterator of \c *this in range [begin(), end()].
+    //!  @li size() < capacity()
+    //!
+    //! @brief Inserts a move-constructed element at position.
+    //!
+    //! @param position    The position at which the new value will be inserted.
+    //! @param value       The value used to move construct the new element.
+    //!
+    //! @par Throws
+    //!   If Value's move constructor or move assignment throws.
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Constant or linear.
+    iterator insert(iterator position, BOOST_RV_REF(value_type) value)
+    {
+        return this->priv_insert(position, boost::move(value));
+    }
+
+    //! @pre
+    //!  @li \c position must be a valid iterator of \c *this in range [begin(), end()].
+    //!  @li size() + count <= capacity()
+    //!
+    //! @brief Inserts a count copies of value at position.
+    //!
+    //! @param position    The position at which new elements will be inserted.
+    //! @param count       The number of new elements which will be inserted.
+    //! @param value       The value used to copy construct new elements.
+    //!
+    //! @par Throws
+    //!   @li If Value's copy constructor or copy assignment throws.
+    //!   @li If Value's move constructor or move assignment throws.
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    iterator insert(iterator position, size_type count, value_type const& value)
+    {
+        errh::check_iterator_end_eq(*this, position);
+        errh::check_capacity(*this, m_size + count);                                // may throw
+
+        if ( position == this->end() )
+        {
+            std::uninitialized_fill(position, position + count, value);             // may throw
+            m_size += count; // update end
+        }
+        else
+        {
+            namespace sv = varray_detail;
+
+            difference_type to_move = std::distance(position, this->end());
+            
+            // TODO - should following lines check for exception and revert to the old size?
+
+            if ( count < static_cast(to_move) )
+            {
+                sv::uninitialized_move(this->end() - count, this->end(), this->end());          // may throw
+                m_size += count; // update end
+                sv::move_backward(position, position + to_move - count, this->end() - count);   // may throw
+                std::fill_n(position, count, value);                                            // may throw
+            }
+            else
+            {
+                std::uninitialized_fill(this->end(), position + count, value);                  // may throw
+                m_size += count - to_move; // update end
+                sv::uninitialized_move(position, position + to_move, position + count);         // may throw
+                m_size += to_move; // update end
+                std::fill_n(position, to_move, value);                                          // may throw
+            }
+        }
+
+        return position;
+    }
+
+    //! @pre
+    //!  @li \c position must be a valid iterator of \c *this in range [begin(), end()].
+    //!  @li distance(first, last) <= capacity()
+    //!  @li \c Iterator must meet the \c ForwardTraversalIterator concept.
+    //!
+    //! @brief Inserts a copy of a range [first, last) at position.
+    //!
+    //! @param position    The position at which new elements will be inserted.
+    //! @param first       The iterator to the first element of a range used to construct new elements.
+    //! @param last        The iterator to the one after the last element of a range used to construct new elements.
+    //!
+    //! @par Throws
+    //!   @li If Value's constructor and assignment taking a dereferenced \c Iterator.
+    //!   @li If Value's move constructor or move assignment throws.
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    template 
+    iterator insert(iterator position, Iterator first, Iterator last)
+    {
+        BOOST_CONCEPT_ASSERT((boost_concepts::ForwardTraversal)); // Make sure you passed a ForwardIterator
+
+        typedef typename boost::iterator_traversal::type traversal;
+        this->insert_dispatch(position, first, last, traversal());
+
+        return position;
+    }
+
+    //! @pre \c position must be a valid iterator of \c *this in range [begin(), end())
+    //!
+    //! @brief Erases Value from position.
+    //!
+    //! @param position    The position of the element which will be erased from the container.
+    //!
+    //! @par Throws
+    //!   If Value's move assignment throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    iterator erase(iterator position)
+    {
+        namespace sv = varray_detail;
+
+        errh::check_iterator_end_neq(*this, position);
+
+        //TODO - add empty check?
+        //errh::check_empty(*this);
+
+        sv::move(position + 1, this->end(), position);                              // may throw
+        sv::destroy(this->end() - 1);
+        --m_size;
+
+        return position;
+    }
+
+    //! @pre
+    //!  @li \c first and \c last must define a valid range
+    //!  @li iterators must be in range [begin(), end()]
+    //!
+    //! @brief Erases Values from a range [first, last).
+    //!
+    //! @param first    The position of the first element of a range which will be erased from the container.
+    //! @param last     The position of the one after the last element of a range which will be erased from the container.
+    //!
+    //! @par Throws
+    //!   If Value's move assignment throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    iterator erase(iterator first, iterator last)
+    {
+        namespace sv = varray_detail;
+
+        errh::check_iterator_end_eq(*this, first);
+        errh::check_iterator_end_eq(*this, last);
+        
+        difference_type n = std::distance(first, last);
+        
+        //TODO - add invalid range check?
+        //BOOST_ASSERT_MSG(0 <= n, "invalid range");
+        //TODO - add this->size() check?
+        //BOOST_ASSERT_MSG(n <= this->size(), "invalid range");
+
+        sv::move(last, this->end(), first);                                         // may throw
+        sv::destroy(this->end() - n, this->end());
+        m_size -= n;
+
+        return first;
+    }
+
+    //! @pre distance(first, last) <= capacity()
+    //!
+    //! @brief Assigns a range [first, last) of Values to this container.
+    //!
+    //! @param first       The iterator to the first element of a range used to construct new content of this container.
+    //! @param last        The iterator to the one after the last element of a range used to construct new content of this container.
+    //!
+    //! @par Throws
+    //!   If Value's copy constructor or copy assignment throws,
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    template 
+    void assign(Iterator first, Iterator last)
+    {
+        BOOST_CONCEPT_ASSERT((boost_concepts::ForwardTraversal)); // Make sure you passed a ForwardIterator
+
+        typedef typename boost::iterator_traversal::type traversal;
+        this->assign_dispatch(first, last, traversal());                            // may throw
+    }
+
+    //! @pre count <= capacity()
+    //!
+    //! @brief Assigns a count copies of value to this container.
+    //!
+    //! @param count       The new number of elements which will be container in the container.
+    //! @param value       The value which will be used to copy construct the new content.
+    //!
+    //! @par Throws
+    //!   If Value's copy constructor or copy assignment throws.
+    //!
+    //! @par Complexity
+    //!   Linear O(N).
+    void assign(size_type count, value_type const& value)
+    {
+        if ( count < m_size )
+        {
+            namespace sv = varray_detail;
+
+            std::fill_n(this->begin(), count, value);                               // may throw
+            sv::destroy(this->begin() + count, this->end());
+        }
+        else
+        {
+            errh::check_capacity(*this, count);                                     // may throw
+
+            std::fill_n(this->begin(), m_size, value);                              // may throw
+            std::uninitialized_fill(this->end(), this->begin() + count, value);     // may throw
+        }
+        m_size = count; // update end
+    }
+
+#if !defined(BOOST_CONTAINER_VARRAY_DISABLE_EMPLACE)
+#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+    //! @pre size() < capacity()
+    //!
+    //! @brief Inserts a Value constructed with
+    //!   \c std::forward(args)... in the end of the container.
+    //!
+    //! @param args     The arguments of the constructor of the new element which will be created at the end of the container.
+    //!
+    //! @par Throws
+    //!   If in-place constructor throws or Value's move constructor throws.
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    template
+    void emplace_back(BOOST_FWD_REF(Args) ...args)
+    {
+        typedef typename vt::disable_trivial_init dti;
+
+        errh::check_capacity(*this, m_size + 1);                                    // may throw
+
+        namespace sv = varray_detail;
+        sv::construct(dti(), this->end(), ::boost::forward(args)...);                // may throw
+        ++m_size; // update end
+    }
+
+    //! @pre
+    //!  @li \c position must be a valid iterator of \c *this in range [begin(), end()]
+    //!  @li size() < capacity()
+    //!
+    //! @brief Inserts a Value constructed with
+    //!   \c std::forward(args)... before position
+    //!
+    //! @param position The position at which new elements will be inserted.
+    //! @param args     The arguments of the constructor of the new element.
+    //!
+    //! @par Throws
+    //!   If in-place constructor throws or if Value's move constructor or move assignment throws.
+    //! @internal
+    //!   @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
+    //! @endinternal
+    //!
+    //! @par Complexity
+    //!   Constant or linear.
+    template
+    iterator emplace(iterator position, BOOST_FWD_REF(Args) ...args)
+    {
+        typedef typename vt::disable_trivial_init dti;
+
+        namespace sv = varray_detail;
+
+        errh::check_iterator_end_eq(*this, position);
+        errh::check_capacity(*this, m_size + 1);                                    // may throw
+
+        if ( position == this->end() )
+        {
+            sv::construct(dti(), position, ::boost::forward(args)...);               // may throw
+            ++m_size; // update end
+        }
+        else
+        {
+            // TODO - should following lines check for exception and revert to the old size?
+
+            // TODO - should move be used only if it's nonthrowing?
+            value_type & r = *(this->end() - 1);
+            sv::construct(dti(), this->end(), boost::move(r));                             // may throw
+            ++m_size; // update end
+            sv::move_backward(position, this->end() - 2, this->end() - 1);          // may throw
+
+            aligned_storage::value> temp_storage;
+            value_type * val_p = static_cast(temp_storage.address());
+            sv::construct(dti(), val_p, ::boost::forward(args)...);                  // may throw
+            sv::scoped_destructor d(val_p);
+            sv::assign(position, ::boost::move(*val_p));                            // may throw
+        }
+
+        return position;
+    }
+
+#else // BOOST_CONTAINER_PERFECT_FORWARDING || BOOST_CONTAINER_DOXYGEN_INVOKED
+
+    #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_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _))                        \
+    {                                                                                            \
+        typedef typename vt::disable_trivial_init dti;                                           \
+                                                                                                 \
+        errh::check_capacity(*this, m_size + 1);                                    /*may throw*/\
+                                                                                                 \
+        namespace sv = varray_detail;                                                     \
+        sv::construct(dti(), this->end() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); /*may throw*/\
+        ++m_size; /*update end*/                                                                 \
+    }                                                                                            \
+    //
+    #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
+    #include BOOST_PP_LOCAL_ITERATE()
+
+    #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(iterator position BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+    {                                                                                               \
+        typedef typename vt::disable_trivial_init dti;                                              \
+        namespace sv = varray_detail;                                                               \
+                                                                                                    \
+        errh::check_iterator_end_eq(*this, position);                                               \
+        errh::check_capacity(*this, m_size + 1);                                       /*may throw*/\
+                                                                                                    \
+        if ( position == this->end() )                                                              \
+        {                                                                                           \
+            sv::construct(dti(), position BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); /*may throw*/\
+            ++m_size; /*update end*/                                                                \
+        }                                                                                           \
+        else                                                                                        \
+        {                                                                                           \
+            /* TODO - should following lines check for exception and revert to the old size? */     \
+            /* TODO - should move be used only if it's nonthrowing? */                              \
+                                                                                                    \
+            value_type & r = *(this->end() - 1);                                                    \
+            sv::construct(dti(), this->end(), boost::move(r));                                /*may throw*/\
+            ++m_size; /*update end*/                                                                \
+            sv::move_backward(position, this->end() - 2, this->end() - 1);             /*may throw*/\
+                                                                                                    \
+            aligned_storage::value> temp_storage;      \
+            value_type * val_p = static_cast(temp_storage.address());                 \
+            sv::construct(dti(), val_p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); /*may throw*/\
+            sv::scoped_destructor d(val_p);                                             \
+            sv::assign(position, ::boost::move(*val_p));                               /*may throw*/\
+        }                                                                                           \
+                                                                                                    \
+        return position;                                                                            \
+    }                                                                                               \
+    //
+    #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
+    #include BOOST_PP_LOCAL_ITERATE()
+
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING || BOOST_CONTAINER_DOXYGEN_INVOKED
+#endif // !BOOST_CONTAINER_VARRAY_DISABLE_EMPLACE
+
+    //! @brief Removes all elements from the container.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    void clear()
+    {
+        namespace sv = varray_detail;
+        sv::destroy(this->begin(), this->end());
+        m_size = 0; // update end
+    }
+
+    //! @pre i < size()
+    //!
+    //! @brief Returns reference to the i-th element.
+    //!
+    //! @param i    The element's index.
+    //!
+    //! @return reference to the i-th element
+    //!   from the beginning of the container.
+    //!
+    //! @par Throws
+    //!   \c std::out_of_range exception by default.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    reference at(size_type i)
+    {
+        errh::check_at(*this, i);                                   // may throw
+        return *(this->begin() + i);
+    }
+
+    //! @pre i < size()
+    //!
+    //! @brief Returns const reference to the i-th element.
+    //!
+    //! @param i    The element's index.
+    //!
+    //! @return const reference to the i-th element
+    //!   from the beginning of the container.
+    //!
+    //! @par Throws
+    //!   \c std::out_of_range exception by default.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_reference at(size_type i) const
+    {
+        errh::check_at(*this, i);                                   // may throw
+        return *(this->begin() + i);
+    }
+
+    //! @pre i < size()
+    //!
+    //! @brief Returns reference to the i-th element.
+    //!
+    //! @param i    The element's index.
+    //!
+    //! @return reference to the i-th element
+    //!   from the beginning of the container.
+    //!
+    //! @par Throws
+    //!   Nothing by default.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    reference operator[](size_type i)
+    {
+        // TODO: Remove bounds check? std::vector and std::array operator[] don't check.
+        errh::check_operator_brackets(*this, i);
+        return *(this->begin() + i);
+    }
+
+    //! @pre i < size()
+    //!
+    //! @brief Returns const reference to the i-th element.
+    //!
+    //! @param i    The element's index.
+    //!
+    //! @return const reference to the i-th element
+    //!   from the beginning of the container.
+    //!
+    //! @par Throws
+    //!   Nothing by default.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_reference operator[](size_type i) const
+    {
+        errh::check_operator_brackets(*this, i);
+        return *(this->begin() + i);
+    }
+
+    //! @pre \c !empty()
+    //!
+    //! @brief Returns reference to the first element.
+    //!
+    //! @return reference to the first element
+    //!   from the beginning of the container.
+    //!
+    //! @par Throws
+    //!   Nothing by default.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    reference front()
+    {
+        errh::check_empty(*this);
+        return *(this->begin());
+    }
+
+    //! @pre \c !empty()
+    //!
+    //! @brief Returns const reference to the first element.
+    //!
+    //! @return const reference to the first element
+    //!   from the beginning of the container.
+    //!
+    //! @par Throws
+    //!   Nothing by default.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_reference front() const
+    {
+        errh::check_empty(*this);
+        return *(this->begin());
+    }
+
+    //! @pre \c !empty()
+    //!
+    //! @brief Returns reference to the last element.
+    //!
+    //! @return reference to the last element
+    //!   from the beginning of the container.
+    //!
+    //! @par Throws
+    //!   Nothing by default.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    reference back()
+    {
+        errh::check_empty(*this);
+        return *(this->end() - 1);
+    }
+
+    //! @pre \c !empty()
+    //!
+    //! @brief Returns const reference to the first element.
+    //!
+    //! @return const reference to the last element
+    //!   from the beginning of the container.
+    //!
+    //! @par Throws
+    //!   Nothing by default.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_reference back() const
+    {
+        errh::check_empty(*this);
+        return *(this->end() - 1);
+    }
+
+    //! @brief Pointer such that [data(), data() + size()) is a valid range.
+    //!   For a non-empty vector data() == &front().
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    Value * data()
+    {
+        return boost::addressof(*(this->ptr()));
+    }
+
+    //! @brief Const pointer such that [data(), data() + size()) is a valid range.
+    //!   For a non-empty vector data() == &front().
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const Value * data() const
+    {
+        return boost::addressof(*(this->ptr()));
+    }
+
+    
+    //! @brief Returns iterator to the first element.
+    //!
+    //! @return iterator to the first element contained in the vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    iterator begin() { return this->ptr(); }
+
+    //! @brief Returns const iterator to the first element.
+    //!
+    //! @return const_iterator to the first element contained in the vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_iterator begin() const { return this->ptr(); }
+
+    //! @brief Returns const iterator to the first element.
+    //!
+    //! @return const_iterator to the first element contained in the vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_iterator cbegin() const { return this->ptr(); }
+
+    //! @brief Returns iterator to the one after the last element.
+    //!
+    //! @return iterator pointing to the one after the last element contained in the vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    iterator end() { return this->begin() + m_size; }
+
+    //! @brief Returns const iterator to the one after the last element.
+    //!
+    //! @return const_iterator pointing to the one after the last element contained in the vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_iterator end() const { return this->begin() + m_size; }
+
+    //! @brief Returns const iterator to the one after the last element.
+    //!
+    //! @return const_iterator pointing to the one after the last element contained in the vector.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_iterator cend() const { return this->cbegin() + m_size; }
+
+    //! @brief Returns reverse iterator to the first element of the reversed container.
+    //!
+    //! @return reverse_iterator pointing to the beginning
+    //! of the reversed varray.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    reverse_iterator rbegin() { return reverse_iterator(this->end()); }
+
+    //! @brief Returns const reverse iterator to the first element of the reversed container.
+    //!
+    //! @return const_reverse_iterator pointing to the beginning
+    //! of the reversed varray.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_reverse_iterator rbegin() const { return reverse_iterator(this->end()); }
+
+    //! @brief Returns const reverse iterator to the first element of the reversed container.
+    //!
+    //! @return const_reverse_iterator pointing to the beginning
+    //! of the reversed varray.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_reverse_iterator crbegin() const { return reverse_iterator(this->end()); }
+
+    //! @brief Returns reverse iterator to the one after the last element of the reversed container.
+    //!
+    //! @return reverse_iterator pointing to the one after the last element
+    //! of the reversed varray.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    reverse_iterator rend() { return reverse_iterator(this->begin()); }
+
+    //! @brief Returns const reverse iterator to the one after the last element of the reversed container.
+    //!
+    //! @return const_reverse_iterator pointing to the one after the last element
+    //! of the reversed varray.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_reverse_iterator rend() const { return reverse_iterator(this->begin()); }
+
+    //! @brief Returns const reverse iterator to the one after the last element of the reversed container.
+    //!
+    //! @return const_reverse_iterator pointing to the one after the last element
+    //! of the reversed varray.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    const_reverse_iterator crend() const { return reverse_iterator(this->begin()); }
+
+    //! @brief Returns container's capacity.
+    //!
+    //! @return container's capacity.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    static size_type capacity() { return Capacity; }
+
+    //! @brief Returns container's capacity.
+    //!
+    //! @return container's capacity.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    static size_type max_size() { return Capacity; }
+
+    //! @brief Returns the number of stored elements.
+    //!
+    //! @return Number of elements contained in the container.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    size_type size() const { return m_size; }
+
+    //! @brief Queries if the container contains elements.
+    //!
+    //! @return true if the number of elements contained in the
+    //!   container is equal to 0.
+    //!
+    //! @par Throws
+    //!   Nothing.
+    //!
+    //! @par Complexity
+    //!   Constant O(1).
+    bool empty() const { return 0 == m_size; }
+
+private:
+
+    // @par Throws
+    //   Nothing.
+    // @par Complexity
+    //   Linear O(N).
+    template 
+    void move_ctor_dispatch(varray & other, boost::true_type /*use_memop*/)
+    {
+        ::memcpy(this->data(), other.data(), sizeof(Value) * other.m_size);
+        m_size = other.m_size;
+    }
+
+    // @par Throws
+    //   @li If boost::has_nothrow_move::value is true and Value's move constructor throws
+    //   @li If boost::has_nothrow_move::value is false and Value's copy constructor throws.
+    // @par Complexity
+    //   Linear O(N).
+    template 
+    void move_ctor_dispatch(varray & other, boost::false_type /*use_memop*/)
+    {
+        namespace sv = varray_detail;
+        sv::uninitialized_move_if_noexcept(other.begin(), other.end(), this->begin());                  // may throw
+        m_size = other.m_size;
+    }
+
+    // @par Throws
+    //   Nothing.
+    // @par Complexity
+    //   Linear O(N).
+    template 
+    void move_assign_dispatch(varray & other, boost::true_type /*use_memop*/)
+    {
+        this->clear();
+
+        ::memcpy(this->data(), other.data(), sizeof(Value) * other.m_size);
+        boost::swap(m_size, other.m_size);
+    }
+
+    // @par Throws
+    //   @li If boost::has_nothrow_move::value is true and Value's move constructor or move assignment throws
+    //   @li If boost::has_nothrow_move::value is false and Value's copy constructor or move assignment throws.
+    // @par Complexity
+    //   Linear O(N).
+    template 
+    void move_assign_dispatch(varray & other, boost::false_type /*use_memop*/)
+    {
+        namespace sv = varray_detail;
+        if ( m_size <= static_cast(other.size()) )
+        {
+            sv::move_if_noexcept(other.begin(), other.begin() + m_size, this->begin());             // may throw
+            // TODO - perform uninitialized_copy first?
+            sv::uninitialized_move_if_noexcept(other.begin() + m_size, other.end(), this->end());   // may throw
+        }
+        else
+        {
+            sv::move_if_noexcept(other.begin(), other.end(), this->begin());                        // may throw
+            sv::destroy(this->begin() + other.size(), this->end());
+        }
+        m_size = other.size(); // update end
+    }
+
+    // @par Throws
+    //   Nothing.
+    // @par Complexity
+    //   Linear O(N).
+    template 
+    void swap_dispatch(varray & other, boost::true_type const& /*use_optimized_swap*/)
+    {
+        typedef typename
+        boost::mpl::if_c<
+            Capacity < C,
+            aligned_storage_type,
+            typename varray::aligned_storage_type
+        >::type
+        storage_type;
+        
+        storage_type temp;
+        Value * temp_ptr = reinterpret_cast(temp.address());
+
+        ::memcpy(temp_ptr, this->data(), sizeof(Value) * this->size());
+        ::memcpy(this->data(), other.data(), sizeof(Value) * other.size());
+        ::memcpy(other.data(), temp_ptr, sizeof(Value) * this->size());
+
+        boost::swap(m_size, other.m_size);
+    }
+
+    // @par Throws
+    //   If Value's move constructor or move assignment throws
+    //   but only if use_memop_in_swap_and_move is false_type - default.
+    // @par Complexity
+    //   Linear O(N).
+    template 
+    void swap_dispatch(varray & other, boost::false_type const& /*use_optimized_swap*/)
+    {
+        namespace sv = varray_detail;
+
+        typedef typename
+        vt::use_memop_in_swap_and_move use_memop_in_swap_and_move;
+
+        if ( this->size() < other.size() )
+            swap_dispatch_impl(this->begin(), this->end(), other.begin(), other.end(), use_memop_in_swap_and_move()); // may throw
+        else
+            swap_dispatch_impl(other.begin(), other.end(), this->begin(), this->end(), use_memop_in_swap_and_move()); // may throw
+        boost::swap(m_size, other.m_size);
+    }
+
+    // @par Throws
+    //   Nothing.
+    // @par Complexity
+    //   Linear O(N).
+    void swap_dispatch_impl(iterator first_sm, iterator last_sm, iterator first_la, iterator last_la, boost::true_type const& /*use_memop*/)
+    {
+        //BOOST_ASSERT_MSG(std::distance(first_sm, last_sm) <= std::distance(first_la, last_la));
+
+        namespace sv = varray_detail;
+        for (; first_sm != last_sm ; ++first_sm, ++first_la)
+        {
+            boost::aligned_storage<
+                sizeof(value_type),
+                boost::alignment_of::value
+            > temp_storage;
+            value_type * temp_ptr = reinterpret_cast(temp_storage.address());
+
+            ::memcpy(temp_ptr, boost::addressof(*first_sm), sizeof(value_type));
+            ::memcpy(boost::addressof(*first_sm), boost::addressof(*first_la), sizeof(value_type));
+            ::memcpy(boost::addressof(*first_la), temp_ptr, sizeof(value_type));
+        }
+
+        ::memcpy(first_sm, first_la, sizeof(value_type) * std::distance(first_la, last_la));
+    }
+
+    // @par Throws
+    //   If Value's move constructor or move assignment throws.
+    // @par Complexity
+    //   Linear O(N).
+    void swap_dispatch_impl(iterator first_sm, iterator last_sm, iterator first_la, iterator last_la, boost::false_type const& /*use_memop*/)
+    {
+        //BOOST_ASSERT_MSG(std::distance(first_sm, last_sm) <= std::distance(first_la, last_la));
+
+        namespace sv = varray_detail;
+        for (; first_sm != last_sm ; ++first_sm, ++first_la)
+        {
+            //boost::swap(*first_sm, *first_la);                                    // may throw
+            value_type temp(boost::move(*first_sm));                                // may throw
+            *first_sm = boost::move(*first_la);                                     // may throw
+            *first_la = boost::move(temp);                                          // may throw
+        }
+        sv::uninitialized_move(first_la, last_la, first_sm);                        // may throw
+        sv::destroy(first_la, last_la);
+    }
+
+    // insert
+
+    // @par Throws
+    //   If Value's move constructor or move assignment throws
+    //   or if Value's copy assignment throws.
+    // @par Complexity
+    //   Linear O(N).
+    template 
+    iterator priv_insert(iterator position, V & value)
+    {
+        typedef typename vt::disable_trivial_init dti;
+        namespace sv = varray_detail;
+
+        errh::check_iterator_end_eq(*this, position);
+        errh::check_capacity(*this, m_size + 1);                                    // may throw
+
+        if ( position == this->end() )
+        {
+            sv::construct(dti(), position, value);                                         // may throw
+            ++m_size; // update end
+        }
+        else
+        {
+            // TODO - should following lines check for exception and revert to the old size?
+
+            // TODO - should move be used only if it's nonthrowing?
+            value_type & r = *(this->end() - 1);
+            sv::construct(dti(), this->end(), boost::move(r));                             // may throw
+            ++m_size; // update end
+            sv::move_backward(position, this->end() - 2, this->end() - 1);          // may throw
+            sv::assign(position, value);                                            // may throw
+        }
+
+        return position;
+    }
+
+    // insert
+
+    // @par Throws
+    //   If Value's move constructor, move assignment throws
+    //   or if Value's copy constructor or copy assignment throws.
+    // @par Complexity
+    //   Linear O(N).
+    template 
+    void insert_dispatch(iterator position, Iterator first, Iterator last, boost::random_access_traversal_tag const&)
+    {
+        BOOST_CONCEPT_ASSERT((boost_concepts::RandomAccessTraversal)); // Make sure you passed a RandomAccessIterator
+        
+        errh::check_iterator_end_eq(*this, position);
+        
+        typename boost::iterator_difference::type
+            count = std::distance(first, last);
+
+        errh::check_capacity(*this, m_size + count);                                             // may throw
+
+        if ( position == this->end() )
+        {
+            namespace sv = varray_detail;
+
+            sv::uninitialized_copy(first, last, position);                                      // may throw
+            m_size += count; // update end
+        }
+        else
+        {
+            this->insert_in_the_middle(position, first, last, count);                           // may throw
+        }
+    }
+
+    // @par Throws
+    //   If Value's move constructor, move assignment throws
+    //   or if Value's copy constructor or copy assignment throws.
+    // @par Complexity
+    //   Linear O(N).
+    template 
+    void insert_dispatch(iterator position, Iterator first, Iterator last, Traversal const& /*not_random_access*/)
+    {
+        errh::check_iterator_end_eq(*this, position);
+
+        if ( position == this->end() )
+        {
+            namespace sv = varray_detail;
+
+            std::ptrdiff_t d = std::distance(position, this->begin() + Capacity);
+            std::size_t count = sv::uninitialized_copy_s(first, last, position, d);                     // may throw
+            
+            errh::check_capacity(*this, count <= static_cast(d) ? m_size + count : Capacity + 1);  // may throw
+
+            m_size += count;
+        }
+        else
+        {
+            typename boost::iterator_difference::type
+                count = std::distance(first, last);
+            
+            errh::check_capacity(*this, m_size + count);                                                // may throw
+
+            this->insert_in_the_middle(position, first, last, count);                                   // may throw
+        }
+    }
+
+    // @par Throws
+    //   If Value's move constructor, move assignment throws
+    //   or if Value's copy constructor or copy assignment throws.
+    // @par Complexity
+    //   Linear O(N).
+    template 
+    void insert_in_the_middle(iterator position, Iterator first, Iterator last, difference_type count)
+    {
+        namespace sv = varray_detail;
+
+        difference_type to_move = std::distance(position, this->end());
+
+        // TODO - should following lines check for exception and revert to the old size?
+
+        if ( count < to_move )
+        {
+            sv::uninitialized_move(this->end() - count, this->end(), this->end());              // may throw
+            m_size += count; // update end
+            sv::move_backward(position, position + to_move - count, this->end() - count);       // may throw
+            sv::copy(first, last, position);                                                    // may throw
+        }
+        else
+        {
+            Iterator middle_iter = first;
+            std::advance(middle_iter, to_move);
+
+            sv::uninitialized_copy(middle_iter, last, this->end());                             // may throw
+            m_size += count - to_move; // update end
+            sv::uninitialized_move(position, position + to_move, position + count);             // may throw
+            m_size += to_move; // update end
+            sv::copy(first, middle_iter, position);                                             // may throw
+        }
+    }
+
+    // assign
+
+    // @par Throws
+    //   If Value's constructor or assignment taking dereferenced Iterator throws.
+    // @par Complexity
+    //   Linear O(N).
+    template 
+    void assign_dispatch(Iterator first, Iterator last, boost::random_access_traversal_tag const& /*not_random_access*/)
+    {
+        namespace sv = varray_detail;
+
+        typename boost::iterator_difference::type
+            s = std::distance(first, last);
+
+        errh::check_capacity(*this, s);                                     // may throw
+
+        if ( m_size <= static_cast(s) )
+        {
+            sv::copy(first, first + m_size, this->begin());                 // may throw
+            // TODO - perform uninitialized_copy first?
+            sv::uninitialized_copy(first + m_size, last, this->end());      // may throw
+        }
+        else
+        {
+            sv::copy(first, last, this->begin());                           // may throw
+            sv::destroy(this->begin() + s, this->end());
+        }
+        m_size = s; // update end
+    }
+
+    // @par Throws
+    //   If Value's constructor or assignment taking dereferenced Iterator throws.
+    // @par Complexity
+    //   Linear O(N).
+    template 
+    void assign_dispatch(Iterator first, Iterator last, Traversal const& /*not_random_access*/)
+    {
+        namespace sv = varray_detail;
+
+        size_type s = 0;
+        iterator it = this->begin();
+
+        for ( ; it != this->end() && first != last ; ++it, ++first, ++s )
+            *it = *first;                                                                                   // may throw
+
+        sv::destroy(it, this->end());
+
+        std::ptrdiff_t d = std::distance(it, this->begin() + Capacity);
+        std::size_t count = sv::uninitialized_copy_s(first, last, it, d);                                   // may throw
+        s += count;
+
+        errh::check_capacity(*this, count <= static_cast(d) ? s : Capacity + 1);               // may throw
+
+        m_size = s; // update end
+    }
+
+    pointer ptr()
+    {
+        return pointer(static_cast(m_storage.address()));
+    }
+
+    const_pointer ptr() const
+    {
+        return const_pointer(static_cast(m_storage.address()));
+    }
+
+    size_type m_size;
+    aligned_storage_type m_storage;
+};
+
+#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+template
+class varray
+{
+    typedef varray_traits<
+        Value, 0, Strategy
+    > vt;
+
+    typedef typename vt::size_type stored_size_type;
+    typedef typename vt::error_handler errh;
+
+public:
+    typedef typename vt::value_type value_type;
+    typedef stored_size_type size_type;
+    typedef typename vt::difference_type difference_type;
+    typedef typename vt::pointer pointer;
+    typedef typename vt::const_pointer const_pointer;
+    typedef typename vt::reference reference;
+    typedef typename vt::const_reference const_reference;
+
+    typedef pointer iterator;
+    typedef const_pointer const_iterator;
+    typedef boost::reverse_iterator reverse_iterator;
+    typedef boost::reverse_iterator const_reverse_iterator;
+
+    // nothrow
+    varray() {}
+
+    // strong
+    explicit varray(size_type count)
+    {
+        errh::check_capacity(*this, count);                                         // may throw
+    }
+
+    // strong
+    varray(size_type count, value_type const&)
+    {
+        errh::check_capacity(*this, count);                                         // may throw
+    }
+
+    // strong
+    varray(varray const& other)
+    {
+        //errh::check_capacity(*this, count);
+    }
+
+    // strong
+    template 
+    varray(varray const& other)
+    {
+        errh::check_capacity(*this, other.size());                                  // may throw
+    }
+
+    // strong
+    template 
+    varray(Iterator first, Iterator last)
+    {
+        errh::check_capacity(*this, std::distance(first, last));                    // may throw
+    }
+
+    // basic
+    varray & operator=(varray const& other)
+    {
+        //errh::check_capacity(*this, other.size());
+        return *this;
+    }
+
+    // basic
+    template 
+    varray & operator=(varray const& other)
+    {
+        errh::check_capacity(*this, other.size());                                  // may throw
+        return *this;
+    }
+
+    // nothrow
+    ~varray() {}
+
+    // strong
+    void resize(size_type count)
+    {
+        errh::check_capacity(*this, count);                                         // may throw
+    }
+
+    // strong
+    void resize(size_type count, value_type const&)
+    {
+        errh::check_capacity(*this, count);                                         // may throw
+    }
+
+    
+    // nothrow
+    void reserve(size_type count)
+    {
+        errh::check_capacity(*this, count);                                         // may throw
+    }
+
+    // strong
+    void push_back(value_type const&)
+    {
+        errh::check_capacity(*this, 1);                                             // may throw
+    }
+
+    // nothrow
+    void pop_back()
+    {
+        errh::check_empty(*this);
+    }
+
+    // basic
+    void insert(iterator position, value_type const&)
+    {
+        errh::check_iterator_end_eq(*this, position);
+        errh::check_capacity(*this, 1);                                             // may throw
+    }
+
+    // basic
+    void insert(iterator position, size_type count, value_type const&)
+    {
+        errh::check_iterator_end_eq(*this, position);
+        errh::check_capacity(*this, count);                                         // may throw
+    }
+
+    // basic
+    template 
+    void insert(iterator, Iterator first, Iterator last)
+    {
+        // TODO - add MPL_ASSERT, check if Iterator is really an iterator
+        typedef typename boost::iterator_traversal::type traversal;
+        errh::check_capacity(*this, std::distance(first, last));                    // may throw
+    }
+
+    // basic
+    void erase(iterator position)
+    {
+        errh::check_iterator_end_neq(*this, position);
+    }
+
+    // basic
+    void erase(iterator first, iterator last)
+    {
+        errh::check_iterator_end_eq(*this, first);
+        errh::check_iterator_end_eq(*this, last);
+
+        //BOOST_ASSERT_MSG(0 <= n, "invalid range");
+    }
+
+    // basic
+    template 
+    void assign(Iterator first, Iterator last)
+    {
+        // TODO - add MPL_ASSERT, check if Iterator is really an iterator
+        typedef typename boost::iterator_traversal::type traversal;
+        errh::check_capacity(*this, std::distance(first, last));                    // may throw
+    }
+
+    // basic
+    void assign(size_type count, value_type const&)
+    {
+        errh::check_capacity(*this, count);                                     // may throw
+    }
+
+    // nothrow
+    void clear() {}
+
+    // strong
+    reference at(size_type i)
+    {
+        errh::check_at(*this, i);                                   // may throw
+        return *(this->begin() + i);
+    }
+
+    // strong
+    const_reference at(size_type i) const
+    {
+        errh::check_at(*this, i);                                   // may throw
+        return *(this->begin() + i);
+    }
+
+    // nothrow
+    reference operator[](size_type i)
+    {
+        errh::check_operator_brackets(*this, i);
+        return *(this->begin() + i);
+    }
+
+    // nothrow
+    const_reference operator[](size_type i) const
+    {
+        errh::check_operator_brackets(*this, i);
+        return *(this->begin() + i);
+    }
+
+    // nothrow
+    reference front()
+    {
+        errh::check_empty(*this);
+        return *(this->begin());
+    }
+
+    // nothrow
+    const_reference front() const
+    {
+        errh::check_empty(*this);
+        return *(this->begin());
+    }
+
+    // nothrow
+    reference back()
+    {
+        errh::check_empty(*this);
+        return *(this->end() - 1);
+    }
+
+    // nothrow
+    const_reference back() const
+    {
+        errh::check_empty(*this);
+        return *(this->end() - 1);
+    }
+
+    // nothrow
+    Value * data() { return boost::addressof(*(this->ptr())); }
+    const Value * data() const { return boost::addressof(*(this->ptr())); }
+
+    // nothrow
+    iterator begin() { return this->ptr(); }
+    const_iterator begin() const { return this->ptr(); }
+    const_iterator cbegin() const { return this->ptr(); }
+    iterator end() { return this->begin(); }
+    const_iterator end() const { return this->begin(); }
+    const_iterator cend() const { return this->cbegin(); }
+    // nothrow
+    reverse_iterator rbegin() { return reverse_iterator(this->end()); }
+    const_reverse_iterator rbegin() const { return reverse_iterator(this->end()); }
+    const_reverse_iterator crbegin() const { return reverse_iterator(this->end()); }
+    reverse_iterator rend() { return reverse_iterator(this->begin()); }
+    const_reverse_iterator rend() const { return reverse_iterator(this->begin()); }
+    const_reverse_iterator crend() const { return reverse_iterator(this->begin()); }
+
+    // nothrow
+    size_type capacity() const { return 0; }
+    size_type max_size() const { return 0; }
+    size_type size() const { return 0; }
+    bool empty() const { return true; }
+
+private:
+
+    pointer ptr()
+    {
+        return pointer(reinterpret_cast(this));
+    }
+
+    const_pointer ptr() const
+    {
+        return const_pointer(reinterpret_cast(this));
+    }
+};
+
+#endif // !BOOST_CONTAINER_DOXYGEN_INVOKED
+
+//! @brief Checks if contents of two varrays are equal.
+//!
+//! @ingroup varray_non_member
+//!
+//! @param x    The first varray.
+//! @param y    The second varray.
+//!
+//! @return     \c true if containers have the same size and elements in both containers are equal.
+//!
+//! @par Complexity
+//!   Linear O(N).
+template
+bool operator== (varray const& x, varray const& y)
+{
+    return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin());
+}
+
+//! @brief Checks if contents of two varrays are not equal.
+//!
+//! @ingroup varray_non_member
+//!
+//! @param x    The first varray.
+//! @param y    The second varray.
+//!
+//! @return     \c true if containers have different size or elements in both containers are not equal.
+//!
+//! @par Complexity
+//!   Linear O(N).
+template
+bool operator!= (varray const& x, varray const& y)
+{
+    return !(x==y);
+}
+
+//! @brief Lexicographically compares varrays.
+//!
+//! @ingroup varray_non_member
+//!
+//! @param x    The first varray.
+//! @param y    The second varray.
+//!
+//! @return     \c true if x compares lexicographically less than y.
+//!
+//! @par Complexity
+//!   Linear O(N).
+template
+bool operator< (varray const& x, varray const& y)
+{
+    return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
+}
+
+//! @brief Lexicographically compares varrays.
+//!
+//! @ingroup varray_non_member
+//!
+//! @param x    The first varray.
+//! @param y    The second varray.
+//!
+//! @return     \c true if y compares lexicographically less than x.
+//!
+//! @par Complexity
+//!   Linear O(N).
+template
+bool operator> (varray const& x, varray const& y)
+{
+    return y
+bool operator<= (varray const& x, varray const& y)
+{
+    return !(y
+bool operator>= (varray const& x, varray const& y)
+{
+    return !(x
+inline void swap(varray & x, varray & y)
+{
+    x.swap(y);
+}
+
+}}} // namespace boost::container::container_detail
+
+#include 
+
+#endif // BOOST_CONTAINER_DETAIL_VARRAY_HPP
diff --git a/bench/detail/varray_concept.hpp b/bench/detail/varray_concept.hpp
new file mode 100644
index 0000000..ba31aae
--- /dev/null
+++ b/bench/detail/varray_concept.hpp
@@ -0,0 +1,60 @@
+// Boost.Container varray
+//
+// Copyright (c) 2012-2013 Andrew Hundt.
+// Copyright (c) 2012-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// Use, modification and distribution is subject to 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)
+
+#ifndef BOOST_CONTAINER_VARRAY_CONCEPT_HPP
+#define BOOST_CONTAINER_VARRAY_CONCEPT_HPP
+
+#include 
+
+namespace boost { namespace container { namespace container_detail { namespace concept {
+  
+/**
+ * VArrayStrategyConcept
+ *
+ *  \brief Checks strategy for varray, which has similarities to std::Allocator
+ *  \ingroup varray
+ */
+template
+struct VArrayStrategy {
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+
+    // typedefs are the same as in std::Allocator
+    typedef typename Strategy::value_type      value_type;
+    typedef typename Strategy::size_type       size_type;
+    typedef typename Strategy::difference_type difference_type;
+    typedef typename Strategy::pointer         pointer;
+    typedef typename Strategy::const_pointer   const_pointer;
+    typedef typename Strategy::reference       reference;
+    typedef typename Strategy::const_reference const_reference;
+
+    struct check_methods
+    {
+        static void apply()
+        {
+            Strategy const* str = 0;
+
+            // must implement allocate_failed
+            str->allocate_failed();
+            
+            boost::ignore_unused_variable_warning(str);
+        }
+    };
+
+public :
+    BOOST_CONCEPT_USAGE(VArrayStrategy)
+    {
+        check_methods::apply();
+    }
+
+#endif
+};
+
+}}}} // namespace boost::container::container_detail::concept
+
+#endif //BOOST_CONTAINER_VARRAY_CONCEPT_HPP
diff --git a/bench/detail/varray_util.hpp b/bench/detail/varray_util.hpp
new file mode 100644
index 0000000..23f0d24
--- /dev/null
+++ b/bench/detail/varray_util.hpp
@@ -0,0 +1,712 @@
+// Boost.Container
+//
+// varray details
+//
+// Copyright (c) 2012-2013 Adam Wulkiewicz, Lodz, Poland.
+// Copyright (c) 2011-2013 Andrew Hundt.
+//
+// Use, modification and distribution is subject to 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)
+
+#ifndef BOOST_CONTAINER_DETAIL_VARRAY_UTIL_HPP
+#define BOOST_CONTAINER_DETAIL_VARRAY_UTIL_HPP
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+//#include 
+//#include 
+//#include 
+//#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// TODO - move vectors iterators optimization to the other, optional file instead of checking defines?
+
+#if defined(BOOST_CONTAINER_VARRAY_ENABLE_VECTORS_OPTIMIZATION) && !defined(BOOST_NO_EXCEPTIONS)
+#include 
+#include 
+#endif // BOOST_CONTAINER_VARRAY_ENABLE_ITERATORS_OPTIMIZATION && !BOOST_NO_EXCEPTIONS
+
+namespace boost { namespace container { namespace varray_detail {
+
+template 
+struct are_elements_contiguous : boost::is_pointer
+{};
+    
+#if defined(BOOST_CONTAINER_VARRAY_ENABLE_VECTORS_OPTIMIZATION) && !defined(BOOST_NO_EXCEPTIONS)
+    
+template 
+struct are_elements_contiguous<
+    boost::container::container_detail::vector_const_iterator
+> : boost::true_type
+{};
+
+template 
+struct are_elements_contiguous<
+    boost::container::container_detail::vector_iterator
+> : boost::true_type
+{};
+
+#if defined(BOOST_DINKUMWARE_STDLIB)
+    
+template 
+struct are_elements_contiguous<
+    std::_Vector_const_iterator
+> : boost::true_type
+{};
+
+template 
+struct are_elements_contiguous<
+    std::_Vector_iterator
+> : boost::true_type
+{};
+
+#elif defined(BOOST_GNU_STDLIB)
+
+template 
+struct are_elements_contiguous<
+    __gnu_cxx::__normal_iterator >
+> : boost::true_type
+{};
+
+#elif defined(_LIBCPP_VERSION)
+
+// TODO - test it first
+//template 
+//struct are_elements_contiguous<
+//    __wrap_iter

+//> : boost::true_type +//{}; + +#else // OTHER_STDLIB + +// TODO - add other iterators implementations + +#endif // STDLIB + +#endif // BOOST_CONTAINER_VARRAY_ENABLE_VECTORS_OPTIMIZATION && !BOOST_NO_EXCEPTIONS + +}}} // namespace boost::container::varray_detail + +namespace boost { namespace container { namespace varray_detail { + +template +struct are_corresponding : + ::boost::mpl::and_< + ::boost::is_same< + ::boost::remove_const< + typename ::boost::iterator_value::type + >, + ::boost::remove_const< + typename ::boost::iterator_value::type + > + >, + are_elements_contiguous, + are_elements_contiguous + > +{}; + +template +struct is_corresponding_value : + ::boost::is_same< + ::boost::remove_const< + typename ::boost::iterator_value::type + >, + ::boost::remove_const + > +{}; + +// destroy(I, I) + +template +void destroy_dispatch(I /*first*/, I /*last*/, + boost::true_type const& /*has_trivial_destructor*/) +{} + +template +void destroy_dispatch(I first, I last, + boost::false_type const& /*has_trivial_destructor*/) +{ + typedef typename boost::iterator_value::type value_type; + for ( ; first != last ; ++first ) + first->~value_type(); +} + +template +void destroy(I first, I last) +{ + typedef typename boost::iterator_value::type value_type; + destroy_dispatch(first, last, has_trivial_destructor()); +} + +// destroy(I) + +template +void destroy_dispatch(I /*pos*/, + boost::true_type const& /*has_trivial_destructor*/) +{} + +template +void destroy_dispatch(I pos, + boost::false_type const& /*has_trivial_destructor*/) +{ + typedef typename boost::iterator_value::type value_type; + pos->~value_type(); +} + +template +void destroy(I pos) +{ + typedef typename boost::iterator_value::type value_type; + destroy_dispatch(pos, has_trivial_destructor()); +} + +// copy(I, I, O) + +template +inline O copy_dispatch(I first, I last, O dst, + boost::mpl::bool_ const& /*use_memmove*/) +{ + typedef typename boost::iterator_value::type value_type; + typename boost::iterator_difference::type d = std::distance(first, last); + + ::memmove(boost::addressof(*dst), boost::addressof(*first), sizeof(value_type) * d); + return dst + d; +} + +template +inline O copy_dispatch(I first, I last, O dst, + boost::mpl::bool_ const& /*use_memmove*/) +{ + return std::copy(first, last, dst); // may throw +} + +template +inline O copy(I first, I last, O dst) +{ + typedef typename + ::boost::mpl::and_< + are_corresponding, + ::boost::has_trivial_assign< + typename ::boost::iterator_value::type + > + >::type + use_memmove; + + return copy_dispatch(first, last, dst, use_memmove()); // may throw +} + +// uninitialized_copy(I, I, O) + +template +inline +O uninitialized_copy_dispatch(I first, I last, O dst, + boost::mpl::bool_ const& /*use_memcpy*/) +{ + typedef typename boost::iterator_value::type value_type; + typename boost::iterator_difference::type d = std::distance(first, last); + + ::memcpy(boost::addressof(*dst), boost::addressof(*first), sizeof(value_type) * d); + return dst + d; +} + +template +inline +F uninitialized_copy_dispatch(I first, I last, F dst, + boost::mpl::bool_ const& /*use_memcpy*/) +{ + return std::uninitialized_copy(first, last, dst); // may throw +} + +template +inline +F uninitialized_copy(I first, I last, F dst) +{ + typedef typename + ::boost::mpl::and_< + are_corresponding, + ::boost::has_trivial_copy< + typename ::boost::iterator_value::type + > + >::type + use_memcpy; + + return uninitialized_copy_dispatch(first, last, dst, use_memcpy()); // may throw +} + +// uninitialized_move(I, I, O) + +template +inline +O uninitialized_move_dispatch(I first, I last, O dst, + boost::mpl::bool_ const& /*use_memcpy*/) +{ + typedef typename boost::iterator_value::type value_type; + typename boost::iterator_difference::type d = std::distance(first, last); + + ::memcpy(boost::addressof(*dst), boost::addressof(*first), sizeof(value_type) * d); + return dst + d; +} + +template +inline +O uninitialized_move_dispatch(I first, I last, O dst, + boost::mpl::bool_ const& /*use_memcpy*/) +{ + //return boost::uninitialized_move(first, last, dst); // may throw + + O o = dst; + + BOOST_TRY + { + typedef typename std::iterator_traits::value_type value_type; + for (; first != last; ++first, ++o ) + new (boost::addressof(*o)) value_type(boost::move(*first)); + } + BOOST_CATCH(...) + { + destroy(dst, o); + BOOST_RETHROW; + } + BOOST_CATCH_END + + return dst; +} + +template +inline +O uninitialized_move(I first, I last, O dst) +{ + typedef typename + ::boost::mpl::and_< + are_corresponding, + ::boost::has_trivial_copy< + typename ::boost::iterator_value::type + > + >::type + use_memcpy; + + return uninitialized_move_dispatch(first, last, dst, use_memcpy()); // may throw +} + +// TODO - move uses memmove - implement 2nd version using memcpy? + +// move(I, I, O) + +template +inline +O move_dispatch(I first, I last, O dst, + boost::mpl::bool_ const& /*use_memmove*/) +{ + typedef typename boost::iterator_value::type value_type; + typename boost::iterator_difference::type d = std::distance(first, last); + + ::memmove(boost::addressof(*dst), boost::addressof(*first), sizeof(value_type) * d); + return dst + d; +} + +template +inline +O move_dispatch(I first, I last, O dst, + boost::mpl::bool_ const& /*use_memmove*/) +{ + return boost::move(first, last, dst); // may throw +} + +template +inline +O move(I first, I last, O dst) +{ + typedef typename + ::boost::mpl::and_< + are_corresponding, + ::boost::has_trivial_assign< + typename ::boost::iterator_value::type + > + >::type + use_memmove; + + return move_dispatch(first, last, dst, use_memmove()); // may throw +} + +// move_backward(BDI, BDI, BDO) + +template +inline +BDO move_backward_dispatch(BDI first, BDI last, BDO dst, + boost::mpl::bool_ const& /*use_memmove*/) +{ + typedef typename boost::iterator_value::type value_type; + typename boost::iterator_difference::type d = std::distance(first, last); + + BDO foo(dst - d); + ::memmove(boost::addressof(*foo), boost::addressof(*first), sizeof(value_type) * d); + return foo; +} + +template +inline +BDO move_backward_dispatch(BDI first, BDI last, BDO dst, + boost::mpl::bool_ const& /*use_memmove*/) +{ + return boost::move_backward(first, last, dst); // may throw +} + +template +inline +BDO move_backward(BDI first, BDI last, BDO dst) +{ + typedef typename + ::boost::mpl::and_< + are_corresponding, + ::boost::has_trivial_assign< + typename ::boost::iterator_value::type + > + >::type + use_memmove; + + return move_backward_dispatch(first, last, dst, use_memmove()); // may throw +} + +template +struct has_nothrow_move : public + ::boost::mpl::or_< + boost::mpl::bool_< + ::boost::has_nothrow_move< + typename ::boost::remove_const::type + >::value + >, + boost::mpl::bool_< + ::boost::has_nothrow_move::value + > + > +{}; + +// uninitialized_move_if_noexcept(I, I, O) + +template +inline +O uninitialized_move_if_noexcept_dispatch(I first, I last, O dst, boost::mpl::bool_ const& /*use_move*/) +{ return uninitialized_move(first, last, dst); } + +template +inline +O uninitialized_move_if_noexcept_dispatch(I first, I last, O dst, boost::mpl::bool_ const& /*use_move*/) +{ return uninitialized_copy(first, last, dst); } + +template +inline +O uninitialized_move_if_noexcept(I first, I last, O dst) +{ + typedef typename has_nothrow_move< + typename ::boost::iterator_value::type + >::type use_move; + + return uninitialized_move_if_noexcept_dispatch(first, last, dst, use_move()); // may throw +} + +// move_if_noexcept(I, I, O) + +template +inline +O move_if_noexcept_dispatch(I first, I last, O dst, boost::mpl::bool_ const& /*use_move*/) +{ return move(first, last, dst); } + +template +inline +O move_if_noexcept_dispatch(I first, I last, O dst, boost::mpl::bool_ const& /*use_move*/) +{ return copy(first, last, dst); } + +template +inline +O move_if_noexcept(I first, I last, O dst) +{ + typedef typename has_nothrow_move< + typename ::boost::iterator_value::type + >::type use_move; + + return move_if_noexcept_dispatch(first, last, dst, use_move()); // may throw +} + +// uninitialized_fill(I, I) + +template +inline +void uninitialized_fill_dispatch(I first, I last, + boost::true_type const& /*has_trivial_constructor*/, + boost::true_type const& /*disable_trivial_init*/) +{} + +template +inline +void uninitialized_fill_dispatch(I first, I last, + boost::true_type const& /*has_trivial_constructor*/, + boost::false_type const& /*disable_trivial_init*/) +{ + typedef typename boost::iterator_value::type value_type; + for ( ; first != last ; ++first ) + new (boost::addressof(*first)) value_type(); +} + +template +inline +void uninitialized_fill_dispatch(I first, I last, + boost::false_type const& /*has_trivial_constructor*/, + DisableTrivialInit const& /*not_used*/) +{ + typedef typename boost::iterator_value::type value_type; + I it = first; + + BOOST_TRY + { + for ( ; it != last ; ++it ) + new (boost::addressof(*it)) value_type(); // may throw + } + BOOST_CATCH(...) + { + destroy(first, it); + BOOST_RETHROW; + } + BOOST_CATCH_END +} + +template +inline +void uninitialized_fill(I first, I last, DisableTrivialInit const& disable_trivial_init) +{ + typedef typename boost::iterator_value::type value_type; + uninitialized_fill_dispatch(first, last, boost::has_trivial_constructor(), disable_trivial_init); // may throw +} + +// construct(I) + +template +inline +void construct_dispatch(boost::mpl::bool_ const& /*dont_init*/, I pos) +{} + +template +inline +void construct_dispatch(boost::mpl::bool_ const& /*dont_init*/, I pos) +{ + typedef typename ::boost::iterator_value::type value_type; + new (static_cast(::boost::addressof(*pos))) value_type(); // may throw +} + +template +inline +void construct(DisableTrivialInit const&, I pos) +{ + typedef typename ::boost::iterator_value::type value_type; + typedef typename ::boost::mpl::and_< + boost::has_trivial_constructor, + DisableTrivialInit + >::type dont_init; + + construct_dispatch(dont_init(), pos); // may throw +} + +// construct(I, V) + +template +inline +void construct_dispatch(I pos, V const& v, + boost::mpl::bool_ const& /*use_memcpy*/) +{ + ::memcpy(boost::addressof(*pos), boost::addressof(v), sizeof(V)); +} + +template +inline +void construct_dispatch(I pos, P const& p, + boost::mpl::bool_ const& /*use_memcpy*/) +{ + typedef typename boost::iterator_value::type V; + new (static_cast(boost::addressof(*pos))) V(p); // may throw +} + +template +inline +void construct(DisableTrivialInit const&, + I pos, P const& p) +{ + typedef typename + ::boost::mpl::and_< + is_corresponding_value, + ::boost::has_trivial_copy

+ >::type + use_memcpy; + + construct_dispatch(pos, p, use_memcpy()); // may throw +} + +// Needed by push_back(V &&) + +template +inline +void construct(DisableTrivialInit const&, I pos, BOOST_RV_REF(P) p) +{ + typedef typename + ::boost::mpl::and_< + is_corresponding_value, + ::boost::has_trivial_copy

+ >::type + use_memcpy; + + typedef typename boost::iterator_value::type V; + new (static_cast(boost::addressof(*pos))) V(::boost::move(p)); // may throw +} + +// Needed by emplace_back() and emplace() + +#if !defined(BOOST_CONTAINER_VARRAY_DISABLE_EMPLACE) +#if !defined(BOOST_NO_VARIADIC_TEMPLATES) + +template +inline +void construct(DisableTrivialInit const&, + I pos, + BOOST_FWD_REF(Args) ...args) +{ + typedef typename boost::iterator_value::type V; + new (static_cast(boost::addressof(*pos))) V(::boost::forward(args)...); // may throw +} + +#else // !BOOST_NO_VARIADIC_TEMPLATES + +// BOOST_NO_RVALUE_REFERENCES -> P0 const& p0 +// !BOOST_NO_RVALUE_REFERENCES -> P0 && p0 +// which means that version with one parameter may take V const& v + +#define BOOST_PP_LOCAL_MACRO(n) \ +template \ +inline \ +void construct(DisableTrivialInit const&, \ + I pos, \ + BOOST_CONTAINER_PP_PARAM(P, p) \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ +{ \ + typedef typename boost::iterator_value::type V; \ + new \ + (static_cast(boost::addressof(*pos))) \ + V(p, BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); /*may throw*/ \ +} \ +// +#define BOOST_PP_LOCAL_LIMITS (1, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) +#include BOOST_PP_LOCAL_ITERATE() + +#endif // !BOOST_NO_VARIADIC_TEMPLATES +#endif // !BOOST_CONTAINER_VARRAY_DISABLE_EMPLACE + +// assign(I, V) + +template +inline +void assign_dispatch(I pos, V const& v, + boost::mpl::bool_ const& /*use_memcpy*/) +{ + ::memcpy(boost::addressof(*pos), boost::addressof(v), sizeof(V)); +} + +template +inline +void assign_dispatch(I pos, V const& v, + boost::mpl::bool_ const& /*use_memcpy*/) +{ + *pos = v; // may throw +} + +template +inline +void assign(I pos, V const& v) +{ + typedef typename + ::boost::mpl::and_< + is_corresponding_value, + ::boost::has_trivial_assign + >::type + use_memcpy; + + assign_dispatch(pos, v, use_memcpy()); // may throw +} + +template +inline +void assign(I pos, BOOST_RV_REF(V) v) +{ + *pos = boost::move(v); // may throw +} + + +// uninitialized_copy_s + +template +inline std::size_t uninitialized_copy_s(I first, I last, F dest, std::size_t max_count) +{ + std::size_t count = 0; + F it = dest; + + BOOST_TRY + { + for ( ; first != last ; ++it, ++first, ++count ) + { + if ( max_count <= count ) + return (std::numeric_limits::max)(); + + // dummy 0 as DisableTrivialInit + construct(0, it, *first); // may throw + } + } + BOOST_CATCH(...) + { + destroy(dest, it); + BOOST_RETHROW; + } + BOOST_CATCH_END + + return count; +} + +// scoped_destructor + +template +class scoped_destructor +{ +public: + scoped_destructor(T * ptr) : m_ptr(ptr) {} + + ~scoped_destructor() + { + if(m_ptr) + destroy(m_ptr); + } + + void release() { m_ptr = 0; } + +private: + T * m_ptr; +}; + +}}} // namespace boost::container::varray_detail + +#endif // BOOST_CONTAINER_DETAIL_VARRAY_UTIL_HPP diff --git a/bench/varray.hpp b/bench/varray.hpp new file mode 100644 index 0000000..8e911cb --- /dev/null +++ b/bench/varray.hpp @@ -0,0 +1,994 @@ +// Boost.Container varray +// +// Copyright (c) 2012-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2013 Andrew Hundt. +// +// Use, modification and distribution is subject to 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) + +#ifndef BOOST_CONTAINER_VARRAY_HPP +#define BOOST_CONTAINER_VARRAY_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include + +#include "detail/varray.hpp" + +namespace boost { namespace container { + +/** + * @defgroup varray_non_member varray non-member functions + */ + +/** + * @brief A variable-size array container with fixed capacity. + * + * varray is a sequence container like boost::container::vector with contiguous storage that can + * change in size, along with the static allocation, low overhead, and fixed capacity of boost::array. + * + * A varray is a sequence that supports random access to elements, constant time insertion and + * removal of elements at the end, and linear time insertion and removal of elements at the beginning or + * in the middle. The number of elements in a varray may vary dynamically up to a fixed capacity + * because elements are stored within the object itself similarly to an array. However, objects are + * initialized as they are inserted into varray unlike C arrays or std::array which must construct + * all elements on instantiation. The behavior of varray enables the use of statically allocated + * elements in cases with complex object lifetime requirements that would otherwise not be trivially + * possible. + * + * @par Error Handling + * Insertion beyond the capacity and out of bounds errors result in undefined behavior. + * The reason for this is because unlike vectors, varray does not perform allocation. + * + * @tparam Value The type of element that will be stored. + * @tparam Capacity The maximum number of elements varray can store, fixed at compile time. + */ +template +class varray + : public container_detail::varray +{ + typedef container_detail::varray base_t; + + BOOST_COPYABLE_AND_MOVABLE(varray) + +public: + //! @brief The type of elements stored in the container. + typedef typename base_t::value_type value_type; + //! @brief The unsigned integral type used by the container. + typedef typename base_t::size_type size_type; + //! @brief The pointers difference type. + typedef typename base_t::difference_type difference_type; + //! @brief The pointer type. + typedef typename base_t::pointer pointer; + //! @brief The const pointer type. + typedef typename base_t::const_pointer const_pointer; + //! @brief The value reference type. + typedef typename base_t::reference reference; + //! @brief The value const reference type. + typedef typename base_t::const_reference const_reference; + //! @brief The iterator type. + typedef typename base_t::iterator iterator; + //! @brief The const iterator type. + typedef typename base_t::const_iterator const_iterator; + //! @brief The reverse iterator type. + typedef typename base_t::reverse_iterator reverse_iterator; + //! @brief The const reverse iterator. + typedef typename base_t::const_reverse_iterator const_reverse_iterator; + + //! @brief Constructs an empty varray. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + varray() + : base_t() + {} + + //! @pre count <= capacity() + //! + //! @brief Constructs a varray containing count default constructed Values. + //! + //! @param count The number of values which will be contained in the container. + //! + //! @par Throws + //! If Value's default constructor throws. + //! + //! @par Complexity + //! Linear O(N). + explicit varray(size_type count) + : base_t(count) + {} + + //! @pre count <= capacity() + //! + //! @brief Constructs a varray containing count copies of value. + //! + //! @param count The number of copies of a values that will be contained in the container. + //! @param value The value which will be used to copy construct values. + //! + //! @par Throws + //! If Value's copy constructor throws. + //! + //! @par Complexity + //! Linear O(N). + varray(size_type count, value_type const& value) + : base_t(count, value) + {} + + //! @pre + //! @li distance(first, last) <= capacity() + //! @li Iterator must meet the \c ForwardTraversalIterator concept. + //! + //! @brief Constructs a varray containing copy of a range [first, last). + //! + //! @param first The iterator to the first element in range. + //! @param last The iterator to the one after the last element in range. + //! + //! @par Throws + //! If Value's constructor taking a dereferenced Iterator throws. + //! + //! @par Complexity + //! Linear O(N). + template + varray(Iterator first, Iterator last) + : base_t(first, last) + {} + + //! @brief Constructs a copy of other varray. + //! + //! @param other The varray which content will be copied to this one. + //! + //! @par Throws + //! If Value's copy constructor throws. + //! + //! @par Complexity + //! Linear O(N). + varray(varray const& other) + : base_t(other) + {} + + //! @pre other.size() <= capacity(). + //! + //! @brief Constructs a copy of other varray. + //! + //! @param other The varray which content will be copied to this one. + //! + //! @par Throws + //! If Value's copy constructor throws. + //! + //! @par Complexity + //! Linear O(N). + template + varray(varray const& other) : base_t(other) {} + + //! @brief Copy assigns Values stored in the other varray to this one. + //! + //! @param other The varray which content will be copied to this one. + //! + //! @par Throws + //! If Value's copy constructor or copy assignment throws. + //! + //! @par Complexity + //! Linear O(N). + varray & operator=(BOOST_COPY_ASSIGN_REF(varray) other) + { + base_t::operator=(static_cast(other)); + return *this; + } + + //! @pre other.size() <= capacity() + //! + //! @brief Copy assigns Values stored in the other varray to this one. + //! + //! @param other The varray which content will be copied to this one. + //! + //! @par Throws + //! If Value's copy constructor or copy assignment throws. + //! + //! @par Complexity + //! Linear O(N). + template +// TEMPORARY WORKAROUND +#if defined(BOOST_NO_RVALUE_REFERENCES) + varray & operator=(::boost::rv< varray > const& other) +#else + varray & operator=(varray const& other) +#endif + { + base_t::operator=(static_cast const&>(other)); + return *this; + } + + //! @brief Move constructor. Moves Values stored in the other varray to this one. + //! + //! @param other The varray which content will be moved to this one. + //! + //! @par Throws + //! @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor throws. + //! @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor throws. + //! + //! @par Complexity + //! Linear O(N). + varray(BOOST_RV_REF(varray) other) + : base_t(boost::move(static_cast(other))) + {} + + //! @pre other.size() <= capacity() + //! + //! @brief Move constructor. Moves Values stored in the other varray to this one. + //! + //! @param other The varray which content will be moved to this one. + //! + //! @par Throws + //! @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor throws. + //! @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor throws. + //! + //! @par Complexity + //! Linear O(N). + template + varray(BOOST_RV_REF_2_TEMPL_ARGS(varray, value_type, C) other) + : base_t(boost::move(static_cast&>(other))) + {} + + //! @brief Move assignment. Moves Values stored in the other varray to this one. + //! + //! @param other The varray which content will be moved to this one. + //! + //! @par Throws + //! @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor or move assignment throws. + //! @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws. + //! + //! @par Complexity + //! Linear O(N). + varray & operator=(BOOST_RV_REF(varray) other) + { + base_t::operator=(boost::move(static_cast(other))); + return *this; + } + + //! @pre other.size() <= capacity() + //! + //! @brief Move assignment. Moves Values stored in the other varray to this one. + //! + //! @param other The varray which content will be moved to this one. + //! + //! @par Throws + //! @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor or move assignment throws. + //! @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws. + //! + //! @par Complexity + //! Linear O(N). + template + varray & operator=(BOOST_RV_REF_2_TEMPL_ARGS(varray, value_type, C) other) + { + base_t::operator=(boost::move(static_cast&>(other))); + return *this; + } + +#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED + + //! @brief Destructor. Destroys Values stored in this container. + //! + //! @par Throws + //! Nothing + //! + //! @par Complexity + //! Linear O(N). + ~varray(); + + //! @brief Swaps contents of the other varray and this one. + //! + //! @param other The varray which content will be swapped with this one's content. + //! + //! @par Throws + //! @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor or move assignment throws, + //! @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws, + //! + //! @par Complexity + //! Linear O(N). + void swap(varray & other); + + //! @pre other.size() <= capacity() && size() <= other.capacity() + //! + //! @brief Swaps contents of the other varray and this one. + //! + //! @param other The varray which content will be swapped with this one's content. + //! + //! @par Throws + //! @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor or move assignment throws, + //! @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws, + //! + //! @par Complexity + //! Linear O(N). + template + void swap(varray & other); + + //! @pre count <= capacity() + //! + //! @brief Inserts or erases elements at the end such that + //! the size becomes count. New elements are default constructed. + //! + //! @param count The number of elements which will be stored in the container. + //! + //! @par Throws + //! If Value's default constructor throws. + //! + //! @par Complexity + //! Linear O(N). + void resize(size_type count); + + //! @pre count <= capacity() + //! + //! @brief Inserts or erases elements at the end such that + //! the size becomes count. New elements are copy constructed from value. + //! + //! @param count The number of elements which will be stored in the container. + //! @param value The value used to copy construct the new element. + //! + //! @par Throws + //! If Value's copy constructor throws. + //! + //! @par Complexity + //! Linear O(N). + void resize(size_type count, value_type const& value); + + //! @pre count <= capacity() + //! + //! @brief This call has no effect because the Capacity of this container is constant. + //! + //! @param count The number of elements which the container should be able to contain. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Linear O(N). + void reserve(size_type count); + + //! @pre size() < capacity() + //! + //! @brief Adds a copy of value at the end. + //! + //! @param value The value used to copy construct the new element. + //! + //! @par Throws + //! If Value's copy constructor throws. + //! + //! @par Complexity + //! Constant O(1). + void push_back(value_type const& value); + + //! @pre size() < capacity() + //! + //! @brief Moves value to the end. + //! + //! @param value The value to move construct the new element. + //! + //! @par Throws + //! If Value's move constructor throws. + //! + //! @par Complexity + //! Constant O(1). + void push_back(BOOST_RV_REF(value_type) value); + + //! @pre !empty() + //! + //! @brief Destroys last value and decreases the size. + //! + //! @par Throws + //! Nothing by default. + //! + //! @par Complexity + //! Constant O(1). + void pop_back(); + + //! @pre + //! @li \c position must be a valid iterator of \c *this in range [begin(), end()]. + //! @li size() < capacity() + //! + //! @brief Inserts a copy of element at position. + //! + //! @param position The position at which the new value will be inserted. + //! @param value The value used to copy construct the new element. + //! + //! @par Throws + //! @li If Value's copy constructor or copy assignment throws + //! @li If Value's move constructor or move assignment throws. + //! + //! @par Complexity + //! Constant or linear. + iterator insert(iterator position, value_type const& value); + + //! @pre + //! @li \c position must be a valid iterator of \c *this in range [begin(), end()]. + //! @li size() < capacity() + //! + //! @brief Inserts a move-constructed element at position. + //! + //! @param position The position at which the new value will be inserted. + //! @param value The value used to move construct the new element. + //! + //! @par Throws + //! If Value's move constructor or move assignment throws. + //! + //! @par Complexity + //! Constant or linear. + iterator insert(iterator position, BOOST_RV_REF(value_type) value); + + //! @pre + //! @li \c position must be a valid iterator of \c *this in range [begin(), end()]. + //! @li size() + count <= capacity() + //! + //! @brief Inserts a count copies of value at position. + //! + //! @param position The position at which new elements will be inserted. + //! @param count The number of new elements which will be inserted. + //! @param value The value used to copy construct new elements. + //! + //! @par Throws + //! @li If Value's copy constructor or copy assignment throws. + //! @li If Value's move constructor or move assignment throws. + //! + //! @par Complexity + //! Linear O(N). + iterator insert(iterator position, size_type count, value_type const& value); + + //! @pre + //! @li \c position must be a valid iterator of \c *this in range [begin(), end()]. + //! @li distance(first, last) <= capacity() + //! @li \c Iterator must meet the \c ForwardTraversalIterator concept. + //! + //! @brief Inserts a copy of a range [first, last) at position. + //! + //! @param position The position at which new elements will be inserted. + //! @param first The iterator to the first element of a range used to construct new elements. + //! @param last The iterator to the one after the last element of a range used to construct new elements. + //! + //! @par Throws + //! @li If Value's constructor and assignment taking a dereferenced \c Iterator. + //! @li If Value's move constructor or move assignment throws. + //! + //! @par Complexity + //! Linear O(N). + template + iterator insert(iterator position, Iterator first, Iterator last); + + //! @pre \c position must be a valid iterator of \c *this in range [begin(), end()) + //! + //! @brief Erases Value from position. + //! + //! @param position The position of the element which will be erased from the container. + //! + //! @par Throws + //! If Value's move assignment throws. + //! + //! @par Complexity + //! Linear O(N). + iterator erase(iterator position); + + //! @pre + //! @li \c first and \c last must define a valid range + //! @li iterators must be in range [begin(), end()] + //! + //! @brief Erases Values from a range [first, last). + //! + //! @param first The position of the first element of a range which will be erased from the container. + //! @param last The position of the one after the last element of a range which will be erased from the container. + //! + //! @par Throws + //! If Value's move assignment throws. + //! + //! @par Complexity + //! Linear O(N). + iterator erase(iterator first, iterator last); + + //! @pre distance(first, last) <= capacity() + //! + //! @brief Assigns a range [first, last) of Values to this container. + //! + //! @param first The iterator to the first element of a range used to construct new content of this container. + //! @param last The iterator to the one after the last element of a range used to construct new content of this container. + //! + //! @par Throws + //! If Value's copy constructor or copy assignment throws, + //! + //! @par Complexity + //! Linear O(N). + template + void assign(Iterator first, Iterator last); + + //! @pre count <= capacity() + //! + //! @brief Assigns a count copies of value to this container. + //! + //! @param count The new number of elements which will be container in the container. + //! @param value The value which will be used to copy construct the new content. + //! + //! @par Throws + //! If Value's copy constructor or copy assignment throws. + //! + //! @par Complexity + //! Linear O(N). + void assign(size_type count, value_type const& value); + + //! @pre size() < capacity() + //! + //! @brief Inserts a Value constructed with + //! \c std::forward(args)... in the end of the container. + //! + //! @param args The arguments of the constructor of the new element which will be created at the end of the container. + //! + //! @par Throws + //! If in-place constructor throws or Value's move constructor throws. + //! + //! @par Complexity + //! Constant O(1). + template + void emplace_back(Args &&...args); + + //! @pre + //! @li \c position must be a valid iterator of \c *this in range [begin(), end()] + //! @li size() < capacity() + //! + //! @brief Inserts a Value constructed with + //! \c std::forward(args)... before position + //! + //! @param position The position at which new elements will be inserted. + //! @param args The arguments of the constructor of the new element. + //! + //! @par Throws + //! If in-place constructor throws or if Value's move constructor or move assignment throws. + //! + //! @par Complexity + //! Constant or linear. + template + iterator emplace(iterator position, Args &&...args); + + //! @brief Removes all elements from the container. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + void clear(); + + //! @pre i < size() + //! + //! @brief Returns reference to the i-th element. + //! + //! @param i The element's index. + //! + //! @return reference to the i-th element + //! from the beginning of the container. + //! + //! @par Throws + //! \c std::out_of_range exception by default. + //! + //! @par Complexity + //! Constant O(1). + reference at(size_type i); + + //! @pre i < size() + //! + //! @brief Returns const reference to the i-th element. + //! + //! @param i The element's index. + //! + //! @return const reference to the i-th element + //! from the beginning of the container. + //! + //! @par Throws + //! \c std::out_of_range exception by default. + //! + //! @par Complexity + //! Constant O(1). + const_reference at(size_type i) const; + + //! @pre i < size() + //! + //! @brief Returns reference to the i-th element. + //! + //! @param i The element's index. + //! + //! @return reference to the i-th element + //! from the beginning of the container. + //! + //! @par Throws + //! Nothing by default. + //! + //! @par Complexity + //! Constant O(1). + reference operator[](size_type i); + + //! @pre i < size() + //! + //! @brief Returns const reference to the i-th element. + //! + //! @param i The element's index. + //! + //! @return const reference to the i-th element + //! from the beginning of the container. + //! + //! @par Throws + //! Nothing by default. + //! + //! @par Complexity + //! Constant O(1). + const_reference operator[](size_type i) const; + + //! @pre \c !empty() + //! + //! @brief Returns reference to the first element. + //! + //! @return reference to the first element + //! from the beginning of the container. + //! + //! @par Throws + //! Nothing by default. + //! + //! @par Complexity + //! Constant O(1). + reference front(); + + //! @pre \c !empty() + //! + //! @brief Returns const reference to the first element. + //! + //! @return const reference to the first element + //! from the beginning of the container. + //! + //! @par Throws + //! Nothing by default. + //! + //! @par Complexity + //! Constant O(1). + const_reference front() const; + + //! @pre \c !empty() + //! + //! @brief Returns reference to the last element. + //! + //! @return reference to the last element + //! from the beginning of the container. + //! + //! @par Throws + //! Nothing by default. + //! + //! @par Complexity + //! Constant O(1). + reference back(); + + //! @pre \c !empty() + //! + //! @brief Returns const reference to the first element. + //! + //! @return const reference to the last element + //! from the beginning of the container. + //! + //! @par Throws + //! Nothing by default. + //! + //! @par Complexity + //! Constant O(1). + const_reference back() const; + + //! @brief Pointer such that [data(), data() + size()) is a valid range. + //! For a non-empty vector data() == &front(). + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + Value * data(); + + //! @brief Const pointer such that [data(), data() + size()) is a valid range. + //! For a non-empty vector data() == &front(). + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + const Value * data() const; + + //! @brief Returns iterator to the first element. + //! + //! @return iterator to the first element contained in the vector. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + iterator begin(); + + //! @brief Returns const iterator to the first element. + //! + //! @return const_iterator to the first element contained in the vector. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + const_iterator begin() const; + + //! @brief Returns const iterator to the first element. + //! + //! @return const_iterator to the first element contained in the vector. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + const_iterator cbegin() const; + + //! @brief Returns iterator to the one after the last element. + //! + //! @return iterator pointing to the one after the last element contained in the vector. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + iterator end(); + + //! @brief Returns const iterator to the one after the last element. + //! + //! @return const_iterator pointing to the one after the last element contained in the vector. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + const_iterator end() const; + + //! @brief Returns const iterator to the one after the last element. + //! + //! @return const_iterator pointing to the one after the last element contained in the vector. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + const_iterator cend() const; + + //! @brief Returns reverse iterator to the first element of the reversed container. + //! + //! @return reverse_iterator pointing to the beginning + //! of the reversed varray. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + reverse_iterator rbegin(); + + //! @brief Returns const reverse iterator to the first element of the reversed container. + //! + //! @return const_reverse_iterator pointing to the beginning + //! of the reversed varray. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + const_reverse_iterator rbegin() const; + + //! @brief Returns const reverse iterator to the first element of the reversed container. + //! + //! @return const_reverse_iterator pointing to the beginning + //! of the reversed varray. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + const_reverse_iterator crbegin() const; + + //! @brief Returns reverse iterator to the one after the last element of the reversed container. + //! + //! @return reverse_iterator pointing to the one after the last element + //! of the reversed varray. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + reverse_iterator rend(); + + //! @brief Returns const reverse iterator to the one after the last element of the reversed container. + //! + //! @return const_reverse_iterator pointing to the one after the last element + //! of the reversed varray. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + const_reverse_iterator rend() const; + + //! @brief Returns const reverse iterator to the one after the last element of the reversed container. + //! + //! @return const_reverse_iterator pointing to the one after the last element + //! of the reversed varray. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + const_reverse_iterator crend() const; + + //! @brief Returns container's capacity. + //! + //! @return container's capacity. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + static size_type capacity(); + + //! @brief Returns container's capacity. + //! + //! @return container's capacity. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + static size_type max_size(); + + //! @brief Returns the number of stored elements. + //! + //! @return Number of elements contained in the container. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + size_type size() const; + + //! @brief Queries if the container contains elements. + //! + //! @return true if the number of elements contained in the + //! container is equal to 0. + //! + //! @par Throws + //! Nothing. + //! + //! @par Complexity + //! Constant O(1). + bool empty() const; + +#endif // BOOST_CONTAINER_DOXYGEN_INVOKED + +}; + +#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED + +//! @brief Checks if contents of two varrays are equal. +//! +//! @ingroup varray_non_member +//! +//! @param x The first varray. +//! @param y The second varray. +//! +//! @return \c true if containers have the same size and elements in both containers are equal. +//! +//! @par Complexity +//! Linear O(N). +template +bool operator== (varray const& x, varray const& y); + +//! @brief Checks if contents of two varrays are not equal. +//! +//! @ingroup varray_non_member +//! +//! @param x The first varray. +//! @param y The second varray. +//! +//! @return \c true if containers have different size or elements in both containers are not equal. +//! +//! @par Complexity +//! Linear O(N). +template +bool operator!= (varray const& x, varray const& y); + +//! @brief Lexicographically compares varrays. +//! +//! @ingroup varray_non_member +//! +//! @param x The first varray. +//! @param y The second varray. +//! +//! @return \c true if x compares lexicographically less than y. +//! +//! @par Complexity +//! Linear O(N). +template +bool operator< (varray const& x, varray const& y); + +//! @brief Lexicographically compares varrays. +//! +//! @ingroup varray_non_member +//! +//! @param x The first varray. +//! @param y The second varray. +//! +//! @return \c true if y compares lexicographically less than x. +//! +//! @par Complexity +//! Linear O(N). +template +bool operator> (varray const& x, varray const& y); + +//! @brief Lexicographically compares varrays. +//! +//! @ingroup varray_non_member +//! +//! @param x The first varray. +//! @param y The second varray. +//! +//! @return \c true if y don't compare lexicographically less than x. +//! +//! @par Complexity +//! Linear O(N). +template +bool operator<= (varray const& x, varray const& y); + +//! @brief Lexicographically compares varrays. +//! +//! @ingroup varray_non_member +//! +//! @param x The first varray. +//! @param y The second varray. +//! +//! @return \c true if x don't compare lexicographically less than y. +//! +//! @par Complexity +//! Linear O(N). +template +bool operator>= (varray const& x, varray const& y); + +//! @brief Swaps contents of two varrays. +//! +//! This function calls varray::swap(). +//! +//! @ingroup varray_non_member +//! +//! @param x The first varray. +//! @param y The second varray. +//! +//! @par Complexity +//! Linear O(N). +template +inline void swap(varray & x, varray & y); + +#endif // BOOST_CONTAINER_DOXYGEN_INVOKED + +}} // namespace boost::container + +#include + +#endif // BOOST_CONTAINER_VARRAY_HPP diff --git a/doc/container.qbk b/doc/container.qbk index 55483bb..152ae74 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -663,7 +663,8 @@ use [*Boost.Container]? There are several reasons for that: * Support for `BOOST_NO_EXCEPTIONS` [@https://svn.boost.org/trac/boost/ticket/7227 #7227]. * Fixed bugs [@https://svn.boost.org/trac/boost/ticket/7921 #7921], - [@https://svn.boost.org/trac/boost/ticket/7969 #7969]. + [@https://svn.boost.org/trac/boost/ticket/7969 #7969], + [@https://svn.boost.org/trac/boost/ticket/8118 #8118]. [endsect] diff --git a/include/boost/container/allocator_traits.hpp b/include/boost/container/allocator_traits.hpp index 828d664..3e9ce0f 100644 --- a/include/boost/container/allocator_traits.hpp +++ b/include/boost/container/allocator_traits.hpp @@ -250,7 +250,19 @@ struct allocator_traits //! Returns: `a.select_on_container_copy_construction()` if that expression is well-formed; //! otherwise, a. - static Alloc select_on_container_copy_construction(const Alloc &a) + static + #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + typename container_detail::if_c + < boost::container::container_detail:: + has_member_function_callable_with_select_on_container_copy_construction + ::value + , Alloc + , const Alloc & + >::type + #else + Alloc + #endif + select_on_container_copy_construction(const Alloc &a) { const bool value = boost::container::container_detail:: has_member_function_callable_with_select_on_container_copy_construction @@ -295,7 +307,7 @@ struct allocator_traits static Alloc priv_select_on_container_copy_construction(boost::true_type, const Alloc &a) { return a.select_on_container_copy_construction(); } - static Alloc priv_select_on_container_copy_construction(boost::false_type, const Alloc &a) + static const Alloc &priv_select_on_container_copy_construction(boost::false_type, const Alloc &a) { return a; } #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) diff --git a/include/boost/container/detail/advanced_insert_int.hpp b/include/boost/container/detail/advanced_insert_int.hpp index 0b09fdd..2abf805 100644 --- a/include/boost/container/detail/advanced_insert_int.hpp +++ b/include/boost/container/detail/advanced_insert_int.hpp @@ -89,10 +89,10 @@ struct insert_n_copies_proxy : a_(a), v_(v) {} - void uninitialized_copy_n_and_update(Iterator p, size_type n) + void uninitialized_copy_n_and_update(Iterator p, size_type n) const { boost::container::uninitialized_fill_alloc_n(this->a_, v_, n, p); } - void copy_n_and_update(Iterator p, size_type n) + void copy_n_and_update(Iterator p, size_type n) const { std::fill_n(p, n, v_); } A &a_; @@ -111,10 +111,10 @@ struct insert_default_constructed_n_proxy : a_(a) {} - void uninitialized_copy_n_and_update(Iterator p, size_type n) + void uninitialized_copy_n_and_update(Iterator p, size_type n) const { boost::container::uninitialized_default_alloc_n(this->a_, n, p); } - void copy_n_and_update(Iterator, size_type) + void copy_n_and_update(Iterator, size_type) const { BOOST_ASSERT(false); } @@ -134,7 +134,7 @@ struct insert_copy_proxy : a_(a), v_(v) {} - void uninitialized_copy_n_and_update(Iterator p, size_type n) + void uninitialized_copy_n_and_update(Iterator p, size_type n) const { BOOST_ASSERT(n == 1); (void)n; alloc_traits::construct( this->a_ @@ -143,7 +143,7 @@ struct insert_copy_proxy ); } - void copy_n_and_update(Iterator p, size_type n) + void copy_n_and_update(Iterator p, size_type n) const { BOOST_ASSERT(n == 1); (void)n; *p =v_; @@ -165,7 +165,7 @@ struct insert_move_proxy : a_(a), v_(v) {} - void uninitialized_copy_n_and_update(Iterator p, size_type n) + void uninitialized_copy_n_and_update(Iterator p, size_type n) const { BOOST_ASSERT(n == 1); (void)n; alloc_traits::construct( this->a_ @@ -174,7 +174,7 @@ struct insert_move_proxy ); } - void copy_n_and_update(Iterator p, size_type n) + void copy_n_and_update(Iterator p, size_type n) const { BOOST_ASSERT(n == 1); (void)n; *p = ::boost::move(v_); diff --git a/include/boost/container/static_vector.hpp b/include/boost/container/static_vector.hpp index 428c7de..020a208 100644 --- a/include/boost/container/static_vector.hpp +++ b/include/boost/container/static_vector.hpp @@ -57,20 +57,29 @@ class static_storage_allocator public: typedef T value_type; - T* internal_storage() const + static_storage_allocator() BOOST_CONTAINER_NOEXCEPT + {} + + static_storage_allocator(const static_storage_allocator &) BOOST_CONTAINER_NOEXCEPT + {} + + static_storage_allocator & operator=(const static_storage_allocator &) BOOST_CONTAINER_NOEXCEPT + {} + + T* internal_storage() const BOOST_CONTAINER_NOEXCEPT { return const_cast(static_cast(static_cast(&storage))); } - T* internal_storage() + T* internal_storage() BOOST_CONTAINER_NOEXCEPT { return static_cast(static_cast(&storage)); } static const std::size_t internal_capacity = N; typedef boost::container::container_detail::version_type version; - friend bool operator==(const static_storage_allocator &, const static_storage_allocator &) + friend bool operator==(const static_storage_allocator &, const static_storage_allocator &) BOOST_CONTAINER_NOEXCEPT { return false; } - friend bool operator!=(const static_storage_allocator &, const static_storage_allocator &) + friend bool operator!=(const static_storage_allocator &, const static_storage_allocator &) BOOST_CONTAINER_NOEXCEPT { return true; } private: @@ -123,7 +132,7 @@ public: //! //! @par Complexity //! Constant O(1). - static_vector() + static_vector() BOOST_CONTAINER_NOEXCEPT : base_t() {} @@ -386,7 +395,7 @@ public: //! //! @par Complexity //! Linear O(N). - void reserve(size_type count); + void reserve(size_type count) BOOST_CONTAINER_NOEXCEPT; //! @pre size() < capacity() //! @@ -594,7 +603,7 @@ public: //! //! @par Complexity //! Constant O(1). - void clear(); + void clear() BOOST_CONTAINER_NOEXCEPT; //! @pre i < size() //! @@ -724,7 +733,7 @@ public: //! //! @par Complexity //! Constant O(1). - Value * data(); + Value * data() BOOST_CONTAINER_NOEXCEPT; //! @brief Const pointer such that [data(), data() + size()) is a valid range. //! For a non-empty vector data() == &front(). @@ -734,7 +743,7 @@ public: //! //! @par Complexity //! Constant O(1). - const Value * data() const; + const Value * data() const BOOST_CONTAINER_NOEXCEPT; //! @brief Returns iterator to the first element. //! @@ -745,7 +754,7 @@ public: //! //! @par Complexity //! Constant O(1). - iterator begin(); + iterator begin() BOOST_CONTAINER_NOEXCEPT; //! @brief Returns const iterator to the first element. //! @@ -756,7 +765,7 @@ public: //! //! @par Complexity //! Constant O(1). - const_iterator begin() const; + const_iterator begin() const BOOST_CONTAINER_NOEXCEPT; //! @brief Returns const iterator to the first element. //! @@ -767,7 +776,7 @@ public: //! //! @par Complexity //! Constant O(1). - const_iterator cbegin() const; + const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT; //! @brief Returns iterator to the one after the last element. //! @@ -778,7 +787,7 @@ public: //! //! @par Complexity //! Constant O(1). - iterator end(); + iterator end() BOOST_CONTAINER_NOEXCEPT; //! @brief Returns const iterator to the one after the last element. //! @@ -789,7 +798,7 @@ public: //! //! @par Complexity //! Constant O(1). - const_iterator end() const; + const_iterator end() const BOOST_CONTAINER_NOEXCEPT; //! @brief Returns const iterator to the one after the last element. //! @@ -800,7 +809,7 @@ public: //! //! @par Complexity //! Constant O(1). - const_iterator cend() const; + const_iterator cend() const BOOST_CONTAINER_NOEXCEPT; //! @brief Returns reverse iterator to the first element of the reversed container. //! @@ -812,7 +821,7 @@ public: //! //! @par Complexity //! Constant O(1). - reverse_iterator rbegin(); + reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT; //! @brief Returns const reverse iterator to the first element of the reversed container. //! @@ -824,7 +833,7 @@ public: //! //! @par Complexity //! Constant O(1). - const_reverse_iterator rbegin() const; + const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT; //! @brief Returns const reverse iterator to the first element of the reversed container. //! @@ -836,7 +845,7 @@ public: //! //! @par Complexity //! Constant O(1). - const_reverse_iterator crbegin() const; + const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT; //! @brief Returns reverse iterator to the one after the last element of the reversed container. //! @@ -848,7 +857,7 @@ public: //! //! @par Complexity //! Constant O(1). - reverse_iterator rend(); + reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT; //! @brief Returns const reverse iterator to the one after the last element of the reversed container. //! @@ -860,7 +869,7 @@ public: //! //! @par Complexity //! Constant O(1). - const_reverse_iterator rend() const; + const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT; //! @brief Returns const reverse iterator to the one after the last element of the reversed container. //! @@ -872,7 +881,7 @@ public: //! //! @par Complexity //! Constant O(1). - const_reverse_iterator crend() const; + const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT; //! @brief Returns container's capacity. //! @@ -883,7 +892,7 @@ public: //! //! @par Complexity //! Constant O(1). - static size_type capacity(); + static size_type capacity() BOOST_CONTAINER_NOEXCEPT; //! @brief Returns container's capacity. //! @@ -894,7 +903,7 @@ public: //! //! @par Complexity //! Constant O(1). - static size_type max_size(); + static size_type max_size() BOOST_CONTAINER_NOEXCEPT; //! @brief Returns the number of stored elements. //! @@ -905,7 +914,7 @@ public: //! //! @par Complexity //! Constant O(1). - size_type size() const; + size_type size() const BOOST_CONTAINER_NOEXCEPT; //! @brief Queries if the container contains elements. //! @@ -917,7 +926,13 @@ public: //! //! @par Complexity //! Constant O(1). - bool empty() const; + bool empty() const BOOST_CONTAINER_NOEXCEPT; +#else + + friend void swap(static_vector &x, static_vector &y) + { + x.swap(y); + } #endif // BOOST_CONTAINER_DOXYGEN_INVOKED @@ -1026,7 +1041,8 @@ inline void swap(static_vector & x, static_vector & y); #else template -inline void swap(static_vector & x, static_vector & y) +inline void swap(static_vector & x, static_vector & y + , typename container_detail::enable_if_c< C1 != C2>::type * = 0) { x.swap(y); } diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp index 859445c..3137cec 100644 --- a/include/boost/container/vector.hpp +++ b/include/boost/container/vector.hpp @@ -89,7 +89,11 @@ class vector_const_iterator //Constructors vector_const_iterator() BOOST_CONTAINER_NOEXCEPT + #ifndef NDEBUG : m_ptr() + #else + // No value initialization of m_ptr() to speed up things a bit: + #endif {} //Pointer like operators @@ -107,13 +111,13 @@ class vector_const_iterator { ++m_ptr; return *this; } vector_const_iterator operator++(int) BOOST_CONTAINER_NOEXCEPT - { Pointer tmp = m_ptr; ++*this; return vector_const_iterator(tmp); } + { return vector_const_iterator(m_ptr++); } vector_const_iterator& operator--() BOOST_CONTAINER_NOEXCEPT { --m_ptr; return *this; } vector_const_iterator operator--(int) BOOST_CONTAINER_NOEXCEPT - { Pointer tmp = m_ptr; --*this; return vector_const_iterator(tmp); } + { return vector_const_iterator(m_ptr--); } //Arithmetic vector_const_iterator& operator+=(difference_type off) BOOST_CONTAINER_NOEXCEPT @@ -125,11 +129,11 @@ class vector_const_iterator friend vector_const_iterator operator+(const vector_const_iterator &x, difference_type off) BOOST_CONTAINER_NOEXCEPT { return vector_const_iterator(x.m_ptr+off); } - friend vector_const_iterator operator+(difference_type off, const vector_const_iterator& right) BOOST_CONTAINER_NOEXCEPT - { return vector_const_iterator(off + right.m_ptr); } + friend vector_const_iterator operator+(difference_type off, vector_const_iterator right) BOOST_CONTAINER_NOEXCEPT + { right.m_ptr += off; return right; } - friend vector_const_iterator operator-(const vector_const_iterator &x, difference_type off) BOOST_CONTAINER_NOEXCEPT - { return vector_const_iterator(x.m_ptr-off); } + friend vector_const_iterator operator-(vector_const_iterator left, difference_type off) BOOST_CONTAINER_NOEXCEPT + { left.m_ptr += off; return left; } friend difference_type operator-(const vector_const_iterator &left, const vector_const_iterator& right) BOOST_CONTAINER_NOEXCEPT { return left.m_ptr - right.m_ptr; } @@ -159,9 +163,10 @@ template class vector_iterator : public vector_const_iterator { + typedef vector_const_iterator base_t; public: explicit vector_iterator(Pointer ptr) BOOST_CONTAINER_NOEXCEPT - : vector_const_iterator(ptr) + : base_t(ptr) {} public: @@ -173,6 +178,7 @@ class vector_iterator //Constructors vector_iterator() BOOST_CONTAINER_NOEXCEPT + : base_t() {} //Pointer like operators @@ -180,7 +186,7 @@ class vector_iterator { return *this->m_ptr; } value_type* operator->() const BOOST_CONTAINER_NOEXCEPT - { return container_detail::to_raw_pointer(this->m_ptr); } + { return container_detail::to_raw_pointer(this->m_ptr); } reference operator[](difference_type off) const BOOST_CONTAINER_NOEXCEPT { return this->m_ptr[off]; } @@ -190,13 +196,13 @@ class vector_iterator { ++this->m_ptr; return *this; } vector_iterator operator++(int) BOOST_CONTAINER_NOEXCEPT - { pointer tmp = this->m_ptr; ++*this; return vector_iterator(tmp); } + { return vector_iterator(this->m_ptr++); } vector_iterator& operator--() BOOST_CONTAINER_NOEXCEPT { --this->m_ptr; return *this; } vector_iterator operator--(int) BOOST_CONTAINER_NOEXCEPT - { vector_iterator tmp = *this; --*this; return vector_iterator(tmp); } + { return vector_iterator(this->m_ptr--); } // Arithmetic vector_iterator& operator+=(difference_type off) BOOST_CONTAINER_NOEXCEPT @@ -205,14 +211,14 @@ class vector_iterator vector_iterator& operator-=(difference_type off) BOOST_CONTAINER_NOEXCEPT { this->m_ptr -= off; return *this; } - friend vector_iterator operator+(const vector_iterator &x, difference_type off) BOOST_CONTAINER_NOEXCEPT - { return vector_iterator(x.m_ptr+off); } + friend vector_iterator operator+(vector_iterator left, difference_type off) BOOST_CONTAINER_NOEXCEPT + { left.m_ptr += off; return left; } - friend vector_iterator operator+(difference_type off, const vector_iterator& right) BOOST_CONTAINER_NOEXCEPT - { return vector_iterator(off + right.m_ptr); } + friend vector_iterator operator+(difference_type off, vector_iterator right) BOOST_CONTAINER_NOEXCEPT + { right.m_ptr += off; return right; } - friend vector_iterator operator-(const vector_iterator &x, difference_type off) BOOST_CONTAINER_NOEXCEPT - { return vector_iterator(x.m_ptr-off); } + friend vector_iterator operator-(vector_iterator left, difference_type off) BOOST_CONTAINER_NOEXCEPT + { left.m_ptr -= off; return left; } }; template @@ -271,35 +277,38 @@ struct vector_alloc_holder //Constructor, does not throw vector_alloc_holder() BOOST_CONTAINER_NOEXCEPT_IF(::boost::has_nothrow_default_constructor::value) - : Allocator(), m_start(), m_size(0), m_capacity(0) + : Allocator(), m_start(), m_size(), m_capacity() {} //Constructor, does not throw template explicit vector_alloc_holder(BOOST_FWD_REF(AllocConvertible) a) BOOST_CONTAINER_NOEXCEPT - : Allocator(boost::forward(a)), m_start(), m_size(0), m_capacity(0) + : Allocator(boost::forward(a)), m_start(), m_size(), m_capacity() {} //Constructor, does not throw template - explicit vector_alloc_holder(BOOST_FWD_REF(AllocConvertible) a, size_type cap) - : Allocator(boost::forward(a)), m_start(), m_size(), m_capacity() + explicit vector_alloc_holder(BOOST_FWD_REF(AllocConvertible) a, size_type initial_size) + : Allocator(boost::forward(a)) + , m_size(initial_size) //Size is initialized here so vector should only call uninitialized_xxx after this { - m_start = this->allocation_command - (allocate_new, cap, cap, m_capacity, m_start).first; + m_start = this->allocation_command(allocate_new, initial_size, initial_size, m_capacity, m_start).first; } //Constructor, does not throw - explicit vector_alloc_holder(size_type cap) - : Allocator(), m_start(), m_size(), m_capacity() + explicit vector_alloc_holder(size_type initial_size) + : Allocator() + , m_size(initial_size) //Size is initialized here so vector should only call uninitialized_xxx after this { m_start = this->allocation_command - (allocate_new, cap, cap, m_capacity, m_start).first; + (allocate_new, initial_size, initial_size, m_capacity, m_start).first; } vector_alloc_holder(BOOST_RV_REF(vector_alloc_holder) holder) BOOST_CONTAINER_NOEXCEPT : Allocator(boost::move(static_cast(holder))) - , m_start(holder.m_start), m_size(holder.m_size), m_capacity(holder.m_capacity) + , m_start(holder.m_start) + , m_size(holder.m_size) + , m_capacity(holder.m_capacity) { holder.m_start = pointer(); holder.m_size = holder.m_capacity = 0; @@ -311,6 +320,9 @@ struct vector_alloc_holder (allocate_new, cap, cap, m_capacity, m_start).first; } + void first_allocation_same_allocator_type(size_type cap) + { this->first_allocation(cap); } + //Destructor ~vector_alloc_holder() BOOST_CONTAINER_NOEXCEPT { @@ -347,6 +359,9 @@ struct vector_alloc_holder container_detail::do_swap(this->m_start, x.m_start); container_detail::do_swap(this->m_size, x.m_size); container_detail::do_swap(this->m_capacity, x.m_capacity); + //And now the allocator + container_detail::bool_ flag; + container_detail::swap_alloc(this->alloc(), x.alloc(), flag); } void move_from_empty(vector_alloc_holder &x) BOOST_CONTAINER_NOEXCEPT @@ -400,43 +415,50 @@ struct vector_alloc_holder::value) - : Allocator(), m_size(0) + : Allocator(), m_size() {} //Constructor, does not throw template explicit vector_alloc_holder(BOOST_FWD_REF(AllocConvertible) a) BOOST_CONTAINER_NOEXCEPT - : Allocator(boost::forward(a)), m_size(0) + : Allocator(boost::forward(a)), m_size() {} //Constructor, does not throw template - explicit vector_alloc_holder(BOOST_FWD_REF(AllocConvertible) a, size_type cap) - : Allocator(boost::forward(a)), m_size() + explicit vector_alloc_holder(BOOST_FWD_REF(AllocConvertible) a, size_type initial_size) + : Allocator(boost::forward(a)) + , m_size(initial_size) //Size is initialized here so vector should only call uninitialized_xxx after this { - this->first_allocation(cap); + this->first_allocation(initial_size); } //Constructor, does not throw - explicit vector_alloc_holder(size_type cap) - : Allocator(), m_size() + explicit vector_alloc_holder(size_type initial_size) + : Allocator() + , m_size(initial_size) //Size is initialized here so vector should only call uninitialized_xxx after this { - this->first_allocation(cap); + this->first_allocation(initial_size); } vector_alloc_holder(BOOST_RV_REF(vector_alloc_holder) holder) : Allocator(boost::move(static_cast(holder))) - , m_size() + , m_size(holder.m_size) //Size is initialized here so vector should only call uninitialized_xxx after this { - this->priv_move_construct_impl(holder); + ::boost::container::uninitialized_move_alloc_n + (this->alloc(), container_detail::to_raw_pointer(holder.start()), m_size, this->start()); } template vector_alloc_holder(BOOST_RV_REF_BEG vector_alloc_holder BOOST_RV_REF_END holder) : Allocator() - , m_size() + , m_size(holder.m_size) //Initialize it to m_size as first_allocation can only succeed or abort { - this->priv_move_construct_impl(holder); + //Different allocator type so we must check we have enough storage + const size_type n = holder.m_size; + this->first_allocation(n); + ::boost::container::uninitialized_move_alloc_n + (this->alloc(), container_detail::to_raw_pointer(holder.start()), n, this->start()); } void first_allocation(size_type cap) @@ -446,6 +468,9 @@ struct vector_alloc_holder void swap(vector_alloc_holder &x) { - if(this->m_size > x.capacity() || x.m_size > this->capacity()){ + if(this->m_size > OtherAllocator::internal_capacity || x.m_size > Allocator::internal_capacity){ throw_bad_alloc(); } this->priv_swap_members_impl(x); @@ -484,19 +509,6 @@ struct vector_alloc_holder - void priv_move_construct_impl(vector_alloc_holder &holder) - { //Containers with version 0 allocators can't be moved - const size_type n = holder.m_size; - this->first_allocation(n); - //Copy first new elements in pos - container_detail::move_insert_range_proxy proxy - (this->alloc(), container_detail::to_raw_pointer(holder.start())); - proxy.uninitialized_copy_n_and_update - (container_detail::to_raw_pointer(this->start()), n); - this->m_size = n; - } - template void priv_swap_members_impl(vector_alloc_holder &x) { @@ -530,7 +542,10 @@ template #endif class vector { - container_detail::vector_alloc_holder m_holder; + typedef container_detail::integral_constant + ::value > alloc_version; + boost::container::container_detail::vector_alloc_holder m_holder; /// @cond typedef container_detail::vector_alloc_holder base_t; typedef allocator_traits allocator_traits_type; @@ -566,9 +581,6 @@ class vector typedef container_detail::integral_constant allocator_v0; typedef container_detail::integral_constant allocator_v1; typedef container_detail::integral_constant allocator_v2; - typedef container_detail::integral_constant - ::value > alloc_version; typedef constant_iterator cvalue_iterator; /// @endcond @@ -609,8 +621,7 @@ class vector explicit vector(size_type n) : m_holder(n) { - this->priv_first_allocation_fill - (container_detail::insert_default_constructed_n_proxy (this->m_holder.alloc()), n); + boost::container::uninitialized_default_alloc_n(this->m_holder.alloc(), n, container_detail::to_raw_pointer(this->m_holder.start())); } //! Effects: Constructs a vector @@ -623,8 +634,8 @@ class vector vector(size_type n, const T& value) : m_holder(n) { - this->priv_first_allocation_fill - (container_detail::insert_n_copies_proxy (this->m_holder.alloc(), value), n); + boost::container::uninitialized_fill_alloc_n + (this->m_holder.alloc(), value, n, container_detail::to_raw_pointer(this->m_holder.start())); } //! Effects: Constructs a vector that will use a copy of allocator a @@ -637,8 +648,8 @@ class vector vector(size_type n, const T& value, const allocator_type& a) : m_holder(a, n) { - this->priv_first_allocation_fill - (container_detail::insert_n_copies_proxy (this->m_holder.alloc(), value), n); + boost::container::uninitialized_fill_alloc_n + (this->m_holder.alloc(), value, n, container_detail::to_raw_pointer(this->m_holder.start())); } //! Effects: Constructs a vector @@ -676,9 +687,9 @@ class vector vector(const vector &x) : m_holder(allocator_traits_type::select_on_container_copy_construction(x.m_holder.alloc()), x.size()) { - this->priv_first_allocation_fill - (container_detail::insert_range_proxy - (this->m_holder.alloc(), container_detail::to_raw_pointer(x.m_holder.start())), x.size()); + ::boost::container::uninitialized_copy_or_move_alloc_n_source + ( this->m_holder.alloc(), container_detail::to_raw_pointer(x.m_holder.start()) + , x.size(), container_detail::to_raw_pointer(this->m_holder.start())); } //! Effects: Move constructor. Moves mx's resources to *this. @@ -717,9 +728,9 @@ class vector vector(const vector &x, const allocator_type &a) : m_holder(a, x.size()) { - this->priv_first_allocation_fill - (container_detail::insert_range_proxy - (this->m_holder.alloc(), container_detail::to_raw_pointer(x.m_holder.start())), x.size()); + ::boost::container::uninitialized_copy_or_move_alloc_n_source + ( this->m_holder.alloc(), container_detail::to_raw_pointer(x.m_holder.start()) + , x.size(), container_detail::to_raw_pointer(this->m_holder.start())); } //! Effects: Move constructor using the specified allocator. @@ -737,10 +748,11 @@ class vector } else{ const size_type n = mx.size(); - this->m_holder.first_allocation(n); - this->priv_first_allocation_fill - (container_detail::move_insert_range_proxy - (this->m_holder.alloc(), container_detail::to_raw_pointer(mx.m_holder.start())), n); + this->m_holder.first_allocation_same_allocator_type(n); + ::boost::container::uninitialized_move_alloc_n_source + ( this->m_holder.alloc(), container_detail::to_raw_pointer(mx.m_holder.start()) + , n, container_detail::to_raw_pointer(this->m_holder.start())); + this->m_holder.m_size = n; } } @@ -767,17 +779,7 @@ class vector vector& operator=(BOOST_COPY_ASSIGN_REF(vector) x) { if (&x != this){ - allocator_type &this_alloc = this->m_holder.alloc(); - const allocator_type &x_alloc = x.m_holder.alloc(); - container_detail::bool_ flag; - if(flag && this_alloc != x_alloc){ - this->clear(); - this->shrink_to_fit(); - } - container_detail::assign_alloc(this_alloc, x_alloc, flag); - this->assign( container_detail::to_raw_pointer(x.m_holder.start()) - , container_detail::to_raw_pointer(x.m_holder.start() + x.m_holder.m_size)); + this->priv_copy_assign(boost::move(x), alloc_version()); } return *this; } @@ -794,25 +796,7 @@ class vector //iG BOOST_CONTAINER_NOEXCEPT_IF(!allocator_type::propagate_on_container_move_assignment::value || is_nothrow_move_assignable::value);) BOOST_CONTAINER_NOEXCEPT { - if (&x != this){ - allocator_type &this_alloc = this->m_holder.alloc(); - allocator_type &x_alloc = x.m_holder.alloc(); - //If allocators are equal we can just swap pointers - if(this_alloc == x_alloc){ - //Destroy objects but retain memory in case x reuses it in the future - this->clear(); - this->m_holder.swap(x.m_holder); - //Move allocator if needed - container_detail::bool_ flag; - container_detail::move_alloc(this_alloc, x_alloc, flag); - } - //If unequal allocators, then do a one by one move - else{ - this->assign( boost::make_move_iterator(container_detail::to_raw_pointer(x.m_holder.start())) - , boost::make_move_iterator(container_detail::to_raw_pointer(x.m_holder.start() + x.m_holder.m_size))); - } - } + this->priv_move_assign(boost::move(x), alloc_version()); return *this; } @@ -829,8 +813,7 @@ class vector template vector& operator=(BOOST_RV_REF_BEG vector BOOST_RV_REF_END x) { - this->assign( boost::make_move_iterator(container_detail::to_raw_pointer(x.m_holder.start())) - , boost::make_move_iterator(container_detail::to_raw_pointer(x.m_holder.start() + x.m_holder.m_size))); + this->priv_move_assign(boost::move(x), alloc_version()); return *this; } @@ -1259,8 +1242,8 @@ class vector } else{ typedef container_detail::insert_emplace_proxy type; - this->priv_forward_range_insert_at_end - (1, type(this->m_holder.alloc(), ::boost::forward(args)...), alloc_version()); + this->priv_forward_range_insert_no_capacity + (this->cend().get_ptr(), 1, type(this->m_holder.alloc(), ::boost::forward(args)...), alloc_version()); } } @@ -1300,7 +1283,8 @@ class vector container_detail::BOOST_PP_CAT(insert_emplace_proxy_arg, n) \ proxy \ (this->m_holder.alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ - this->priv_forward_range_insert_at_end(1, proxy, alloc_version()); \ + this->priv_forward_range_insert_no_capacity \ + (this->cend().get_ptr(), 1, proxy, alloc_version()); \ } \ } \ \ @@ -1482,9 +1466,6 @@ class vector { //Just swap internals in case of !allocator_v0. Otherwise, deep swap this->m_holder.swap(x.m_holder); - //And now the allocator - container_detail::bool_ flag; - container_detail::swap_alloc(this->m_holder.alloc(), x.m_holder.alloc(), flag); } #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED @@ -1531,6 +1512,125 @@ class vector private: + template + void priv_move_assign(BOOST_RV_REF_BEG vector BOOST_RV_REF_END x + , AllocVersion + , typename container_detail::enable_if_c + < container_detail::is_same::value && + !container_detail::is_same::value + >::type * = 0) + { + if(this->capacity() < x.size()){ + throw_bad_alloc(); + } + this->priv_move_assign_impl(boost::move(x), AllocVersion()); + } + + template + void priv_move_assign(BOOST_RV_REF_BEG vector BOOST_RV_REF_END x + , AllocVersion + , typename container_detail::enable_if_c + < !container_detail::is_same::value || + container_detail::is_same::value + >::type * = 0) + { + this->priv_move_assign_impl(boost::move(x), AllocVersion()); + } + + template + void priv_move_assign_impl(BOOST_RV_REF_BEG vector BOOST_RV_REF_END x + , AllocVersion + , typename container_detail::enable_if_c + < container_detail::is_same::value + >::type * = 0) + { + T* const this_start = container_detail::to_raw_pointer(m_holder.start()); + T* const other_start = container_detail::to_raw_pointer(x.m_holder.start()); + const size_type this_sz = m_holder.m_size; + const size_type other_sz = static_cast(x.m_holder.m_size); + if (this_sz < other_sz){ + move_n(other_start, this_sz, this_start); // may throw + uninitialized_move_alloc_n( this->m_holder.alloc(), other_start + this_sz + , other_sz - this_sz, this_start + this_sz); // may throw + } + else + { + move_n(other_start, other_sz, this_start); + destroy_alloc_n(this->m_holder.alloc(), this_start + other_sz, this_sz - other_sz); + } + this->m_holder.m_size = other_sz; + } + + template + void priv_move_assign_impl(BOOST_RV_REF_BEG vector BOOST_RV_REF_END x + , AllocVersion + , typename container_detail::enable_if_c + < !container_detail::is_same::value + >::type * = 0) + { + //for move constructor, no aliasing (&x != this) is assummed. + allocator_type &this_alloc = this->m_holder.alloc(); + allocator_type &x_alloc = x.m_holder.alloc(); + //If allocators are equal we can just swap pointers + if(this_alloc == x_alloc){ + //Destroy objects but retain memory in case x reuses it in the future + this->clear(); + this->m_holder.swap(x.m_holder); + //Move allocator if needed + container_detail::bool_ flag; + container_detail::move_alloc(this_alloc, x_alloc, flag); + } + //If unequal allocators, then do a one by one move + else{ + //TO-DO: optimize this + this->assign( boost::make_move_iterator(container_detail::to_raw_pointer(x.m_holder.start())) + , boost::make_move_iterator(container_detail::to_raw_pointer(x.m_holder.start() + x.m_holder.m_size))); + } + } + + template + void priv_copy_assign(const vector &x, AllocVersion + , typename container_detail::enable_if_c + < container_detail::is_same::value + >::type * = 0) + { + T* const this_start = container_detail::to_raw_pointer(m_holder.start()); + T* const other_start = container_detail::to_raw_pointer(x.m_holder.start()); + const size_type this_sz = m_holder.m_size; + const size_type other_sz = static_cast(x.m_holder.m_size); + if (this_sz < other_sz){ + copy_or_move_n(other_start, this_sz, this_start); // may throw + uninitialized_copy_or_move_alloc_n( this->m_holder.alloc(), other_start + this_sz + , other_sz - this_sz, this_start + this_sz); // may throw + } + else + { + copy_or_move_n(other_start, other_sz, this_start); + destroy_alloc_n(this->m_holder.alloc(), this_start + other_sz, this_sz - other_sz); + } + this->m_holder.m_size = other_sz; + } + + template + void priv_copy_assign(const vector &x, AllocVersion + , typename container_detail::enable_if_c + < !container_detail::is_same::value + >::type * = 0) + { + allocator_type &this_alloc = this->m_holder.alloc(); + const allocator_type &x_alloc = x.m_holder.alloc(); + container_detail::bool_ flag; + if(flag && this_alloc != x_alloc){ + this->clear(); + this->shrink_to_fit(); + } + container_detail::assign_alloc(this_alloc, x_alloc, flag); + this->assign( container_detail::to_raw_pointer(x.m_holder.start()) + , container_detail::to_raw_pointer(x.m_holder.start() + x.m_holder.m_size)); + } + void priv_reserve(size_type, allocator_v0) { throw_bad_alloc(); @@ -1540,20 +1640,17 @@ class vector { //There is not enough memory, allocate a new buffer pointer p = this->m_holder.allocate(new_cap); - - //We will reuse insert code, so create a dummy input iterator - container_detail::insert_range_proxy, T*> - proxy(this->m_holder.alloc(), ::boost::make_move_iterator((T *)0)); //Backwards (and possibly forward) expansion #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS ++this->num_alloc; #endif - this->priv_range_insert_new_allocation - ( container_detail::to_raw_pointer(p) - , new_cap - , container_detail::to_raw_pointer(this->m_holder.start()) - , 0 - , proxy); + T * const raw_beg = container_detail::to_raw_pointer(this->m_holder.start()); + const size_type sz = m_holder.m_size; + ::boost::container::uninitialized_move_alloc_n_source + ( this->m_holder.alloc(), raw_beg, sz, container_detail::to_raw_pointer(p) ); + destroy_alloc_n(this->m_holder.alloc(), raw_beg, sz); + this->m_holder.start(p); + this->m_holder.capacity(new_cap); } void priv_reserve(size_type new_cap, allocator_v2) @@ -1575,14 +1672,13 @@ class vector #endif this->m_holder.capacity(real_cap); } - //If there is no forward expansion, move objects else{ - //We will reuse insert code, so create a dummy input iterator - container_detail::insert_range_proxy, T*> - proxy(this->m_holder.alloc(), ::boost::make_move_iterator((T *)0)); //Backwards (and possibly forward) expansion if(ret.second){ + //We will reuse insert code, so create a dummy input iterator + container_detail::insert_range_proxy, T*> + proxy(this->m_holder.alloc(), ::boost::make_move_iterator((T *)0)); #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS ++this->num_expand_bwd; #endif @@ -1595,26 +1691,28 @@ class vector } //New buffer else{ + //Backwards (and possibly forward) expansion #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS ++this->num_alloc; #endif - this->priv_range_insert_new_allocation - ( container_detail::to_raw_pointer(ret.first) - , real_cap - , container_detail::to_raw_pointer(this->m_holder.start()) - , 0 - , proxy); + T * const raw_beg = container_detail::to_raw_pointer(this->m_holder.start()); + const size_type sz = m_holder.m_size; + ::boost::container::uninitialized_move_alloc_n_source + ( this->m_holder.alloc(), raw_beg, sz, container_detail::to_raw_pointer(ret.first) ); + destroy_alloc_n(this->m_holder.alloc(), raw_beg, sz); + this->m_holder.start(ret.first); + this->m_holder.capacity(real_cap); } } } template - void priv_first_allocation_fill(Proxy proxy, size_type n) + void priv_uninitialized_fill(Proxy proxy, size_type n) const { //Copy first new elements in pos proxy.uninitialized_copy_n_and_update (container_detail::to_raw_pointer(this->m_holder.start()), n); - this->m_holder.m_size = n; + //m_holder.size was already initialized to n in vector_alloc_holder's constructor } void priv_destroy(value_type* p) BOOST_CONTAINER_NOEXCEPT @@ -1644,19 +1742,35 @@ class vector , ::boost::forward(x)), alloc_version()); } - template - void priv_push_back(BOOST_FWD_REF(U) x) + void priv_push_back(const T &x) { if (this->m_holder.m_size < this->m_holder.capacity()){ //There is more memory, just construct a new object at the end allocator_traits_type::construct ( this->m_holder.alloc() , container_detail::to_raw_pointer(this->m_holder.start() + this->m_holder.m_size) - , ::boost::forward(x) ); + , x ); ++this->m_holder.m_size; } else{ - this->priv_insert(this->cend(), ::boost::forward(x)); + container_detail::insert_copy_proxy proxy(this->m_holder.alloc(), x); + this->priv_forward_range_insert_no_capacity(this->cend().get_ptr(), 1, proxy, alloc_version()); + } + } + + void priv_push_back(BOOST_RV_REF(T) x) + { + if (this->m_holder.m_size < this->m_holder.capacity()){ + //There is more memory, just construct a new object at the end + allocator_traits_type::construct + ( this->m_holder.alloc() + , container_detail::to_raw_pointer(this->m_holder.start() + this->m_holder.m_size) + , ::boost::move(x) ); + ++this->m_holder.m_size; + } + else{ + container_detail::insert_move_proxy proxy(this->m_holder.alloc(), x); + this->priv_forward_range_insert_no_capacity(this->cend().get_ptr(), 1, proxy, alloc_version()); } } @@ -1712,23 +1826,28 @@ class vector } } + template + iterator priv_forward_range_insert_no_capacity + (const pointer &pos, const size_type, const InsertionProxy , allocator_v0) + { + throw_bad_alloc(); + return iterator(pos); + } + template iterator priv_forward_range_insert (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v0) { //Check if we have enough memory or try to expand current memory const size_type remaining = this->m_holder.capacity() - this->m_holder.m_size; - const size_type n_pos = pos - this->m_holder.start(); - T *const raw_pos = container_detail::to_raw_pointer(pos); - if (n <= remaining){ - this->priv_range_insert_expand_forward(raw_pos, n, insert_range_proxy); - } - else{ + if (n > remaining){ //This will trigger an error throw_bad_alloc(); } - + const size_type n_pos = pos - this->m_holder.start(); + T *const raw_pos = container_detail::to_raw_pointer(pos); + this->priv_range_insert_expand_forward(raw_pos, n, insert_range_proxy); return iterator(this->m_holder.start() + n_pos); } @@ -1739,40 +1858,49 @@ class vector //Check if we have enough memory or try to expand current memory const size_type remaining = this->m_holder.capacity() - this->m_holder.m_size; - if (n <= remaining){ - this->priv_range_insert_at_end_expand_forward(n, insert_range_proxy); - } - else{ + if (n > remaining){ //This will trigger an error throw_bad_alloc(); } - + this->priv_range_insert_at_end_expand_forward(n, insert_range_proxy); return this->end(); } + template + iterator priv_forward_range_insert_no_capacity + (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v1) + { + //Check if we have enough memory or try to expand current memory + const size_type n_pos = pos - this->m_holder.start(); + T *const raw_pos = container_detail::to_raw_pointer(pos); + + const size_type new_cap = this->m_holder.next_capacity(n); + T * new_buf = container_detail::to_raw_pointer(this->m_holder.alloc().allocate(new_cap)); + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + ++this->num_alloc; + #endif + this->priv_range_insert_new_allocation + ( new_buf, new_cap, raw_pos, n, insert_range_proxy); + return iterator(this->m_holder.start() + n_pos); + } + template iterator priv_forward_range_insert (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v1) { //Check if we have enough memory or try to expand current memory const size_type remaining = this->m_holder.capacity() - this->m_holder.m_size; - const size_type n_pos = pos - this->m_holder.start(); T *const raw_pos = container_detail::to_raw_pointer(pos); if (n <= remaining){ + const size_type n_pos = pos - this->m_holder.start(); this->priv_range_insert_expand_forward (raw_pos, n, insert_range_proxy); + return iterator(this->m_holder.start() + n_pos); } else{ - const size_type new_cap = this->m_holder.next_capacity(n); - T * new_buf = container_detail::to_raw_pointer(this->m_holder.alloc().allocate(new_cap)); - #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS - ++this->num_alloc; - #endif - this->priv_range_insert_new_allocation - ( new_buf, new_cap, raw_pos, n, insert_range_proxy); + return this->priv_forward_range_insert_no_capacity(pos, n, insert_range_proxy, alloc_version()); } - return iterator(this->m_holder.start() + n_pos); } template @@ -1782,61 +1910,73 @@ class vector return this->priv_forward_range_insert(this->cend().get_ptr(), n, insert_range_proxy, allocator_v1()); } + template + iterator priv_forward_range_insert_no_capacity + (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v2) + { + //Check if we have enough memory or try to expand current memory + const size_type n_pos = pos - this->m_holder.start(); + T *const raw_pos = container_detail::to_raw_pointer(pos); + + size_type real_cap = 0; + //There is not enough memory, allocate a new + //buffer or expand the old one. + std::pair ret = (this->m_holder.allocation_command + (allocate_new | expand_fwd | expand_bwd, + this->m_holder.m_size + n, this->m_holder.next_capacity(n), real_cap, this->m_holder.start())); + + //Buffer reallocated + if(ret.second){ + //Forward expansion, delay insertion + if(this->m_holder.start() == ret.first){ + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + ++this->num_expand_fwd; + #endif + this->m_holder.capacity(real_cap); + //Expand forward + this->priv_range_insert_expand_forward(raw_pos, n, insert_range_proxy); + } + //Backwards (and possibly forward) expansion + else{ + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + ++this->num_expand_bwd; + #endif + this->priv_range_insert_expand_backwards + ( container_detail::to_raw_pointer(ret.first) + , real_cap, raw_pos, n, insert_range_proxy); + } + } + //New buffer + else{ + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + ++this->num_alloc; + #endif + this->priv_range_insert_new_allocation + ( container_detail::to_raw_pointer(ret.first) + , real_cap, raw_pos, n, insert_range_proxy); + } + + return iterator(this->m_holder.start() + n_pos); + } + template iterator priv_forward_range_insert (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v2) { //Check if we have enough memory or try to expand current memory const size_type remaining = this->m_holder.capacity() - this->m_holder.m_size; - const size_type n_pos = pos - this->m_holder.start(); - T *const raw_pos = container_detail::to_raw_pointer(pos); bool same_buffer_start = n <= remaining; if (!same_buffer_start){ - size_type real_cap = 0; - //There is not enough memory, allocate a new - //buffer or expand the old one. - std::pair ret = (this->m_holder.allocation_command - (allocate_new | expand_fwd | expand_bwd, - this->m_holder.m_size + n, this->m_holder.next_capacity(n), real_cap, this->m_holder.start())); - - //Buffer reallocated - if(ret.second){ - //Forward expansion, delay insertion - if(this->m_holder.start() == ret.first){ - #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS - ++this->num_expand_fwd; - #endif - this->m_holder.capacity(real_cap); - //Expand forward - this->priv_range_insert_expand_forward(raw_pos, n, insert_range_proxy); - } - //Backwards (and possibly forward) expansion - else{ - #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS - ++this->num_expand_bwd; - #endif - this->priv_range_insert_expand_backwards - ( container_detail::to_raw_pointer(ret.first) - , real_cap, raw_pos, n, insert_range_proxy); - } - } - //New buffer - else{ - #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS - ++this->num_alloc; - #endif - this->priv_range_insert_new_allocation - ( container_detail::to_raw_pointer(ret.first) - , real_cap, raw_pos, n, insert_range_proxy); - } + return priv_forward_range_insert_no_capacity(pos, n, insert_range_proxy, alloc_version()); } else{ //Expand forward + const size_type n_pos = pos - this->m_holder.start(); + T *const raw_pos = container_detail::to_raw_pointer(pos); this->priv_range_insert_expand_forward(raw_pos, n, insert_range_proxy); + return iterator(this->m_holder.start() + n_pos); } - - return iterator(this->m_holder.start() + n_pos); } template @@ -1979,7 +2119,8 @@ class vector //Case B: else if((first_pos + shift_count) >= limit_pos){ //All uninitialized_moved - ::boost::container::uninitialized_move_alloc(this->m_holder.alloc(), first_ptr, last_ptr, first_ptr + shift_count); + ::boost::container::uninitialized_move_alloc + (this->m_holder.alloc(), first_ptr, last_ptr, first_ptr + shift_count); hole_size = last_pos + shift_count - limit_pos; } //Case C: diff --git a/proj/vc7ide/container.sln b/proj/vc7ide/container.sln index 584f8ab..082bf1d 100644 --- a/proj/vc7ide/container.sln +++ b/proj/vc7ide/container.sln @@ -59,6 +59,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "throw_exception_test", "thr ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "static_vector_test", "static_vector_test.vcproj", "{58E1C1C3-096A-84FE-4FA2-D6BA79201C02}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bench_static_vector", "bench_static_vector.vcproj", "{58E1C1C3-096A-84FE-4FA2-D6BA79201C02}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug @@ -127,6 +135,14 @@ Global {5A8D91E0-FA57-284F-84FE-D3A6BA792002}.Debug.Build.0 = Debug|Win32 {5A8D91E0-FA57-284F-84FE-D3A6BA792002}.Release.ActiveCfg = Release|Win32 {5A8D91E0-FA57-284F-84FE-D3A6BA792002}.Release.Build.0 = Release|Win32 + {58E1C1C3-096A-84FE-4FA2-D6BA79201C02}.Debug.ActiveCfg = Debug|Win32 + {58E1C1C3-096A-84FE-4FA2-D6BA79201C02}.Debug.Build.0 = Debug|Win32 + {58E1C1C3-096A-84F0-4FA2-D6BA79201C02}.Release.ActiveCfg = Release|Win32 + {58E1C1C3-096A-84F0-4FA2-D6BA79201C02}.Release.Build.0 = Release|Win32 + {58E1C1C3-096A-84F1-4FA2-D6BA79201C02}.Debug.ActiveCfg = Debug|Win32 + {58E1C1C3-096A-84F1-4FA2-D6BA79201C02}.Debug.Build.0 = Debug|Win32 + {58E1C1C3-096A-84F2-4FA2-D6BA79201C02}.Release.ActiveCfg = Release|Win32 + {58E1C1C3-096A-84F2-4FA2-D6BA79201C02}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection diff --git a/proj/vc7ide/container.vcproj b/proj/vc7ide/container.vcproj index 5deba8d..9f42b17 100644 --- a/proj/vc7ide/container.vcproj +++ b/proj/vc7ide/container.vcproj @@ -172,6 +172,9 @@ + + @@ -221,6 +224,9 @@ + + @@ -325,6 +331,26 @@ + + + + + + + + + + + + diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index af84010..25add18 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -21,7 +21,7 @@ rule test_all for local fileb in [ glob *.cpp ] { - all_rules += [ run $(fileb) + all_rules += [ run $(fileb) /boost/timer//boost_timer /boost/system//boost_system /boost/thread//boost_thread : # additional args : # test-files : # requirements diff --git a/test/movable.hpp b/test/movable.hpp deleted file mode 100644 index 3076865..0000000 --- a/test/movable.hpp +++ /dev/null @@ -1,92 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2009. -// 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) -// -// See http://www.boost.org/libs/move for documentation. -// -////////////////////////////////////////////////////////////////////////////// -#ifndef BOOST_MOVE_TEST_MOVABLE_HPP -#define BOOST_MOVE_TEST_MOVABLE_HPP - -//[movable_definition -//header file "movable.hpp" -#include - -//A movable class -class movable -{ - BOOST_MOVABLE_BUT_NOT_COPYABLE(movable) - int value_; - -public: - movable() : value_(1){} - - //Move constructor and assignment - movable(BOOST_RV_REF(movable) m) - { value_ = m.value_; m.value_ = 0; } - - movable & operator=(BOOST_RV_REF(movable) m) - { value_ = m.value_; m.value_ = 0; return *this; } - - bool moved() const //Observer - { return value_ == 0; } -}; - - -class copy_movable -{ - BOOST_COPYABLE_AND_MOVABLE(copy_movable) - int value_; - -public: - copy_movable(int value = 1) : value_(value){} - - //Move constructor and assignment - copy_movable(BOOST_RV_REF(copy_movable) m) - { value_ = m.value_; m.value_ = 0; } - - copy_movable(const copy_movable &m) - { value_ = m.value_; } - - copy_movable & operator=(BOOST_RV_REF(copy_movable) m) - { value_ = m.value_; m.value_ = 0; return *this; } - - copy_movable & operator=(BOOST_COPY_ASSIGN_REF(copy_movable) m) - { value_ = m.value_; return *this; } - - bool moved() const //Observer - { return value_ == 0; } - - bool operator==(const copy_movable& m) const - { return value_ == m.value_; } -}; - -struct copy_movable_wrapper -{ - copy_movable cm; -}; - -copy_movable produce() -{ return copy_movable(); } - -namespace boost{ - -template<> -struct has_nothrow_move -{ - static const bool value = true; -}; - -template<> -struct has_nothrow_move -{ - static const bool value = true; -}; - -} //namespace boost{ -//] - -#endif //BOOST_MOVE_TEST_MOVABLE_HPP diff --git a/test/movable_int.hpp b/test/movable_int.hpp index 65fa473..1daf02a 100644 --- a/test/movable_int.hpp +++ b/test/movable_int.hpp @@ -53,23 +53,26 @@ class movable_int movable_int & operator= (int i) { this->m_int = i; return *this; } - bool operator ==(const movable_int &mi) const - { return this->m_int == mi.m_int; } + ~movable_int() + { this->m_int = 0; } - bool operator !=(const movable_int &mi) const - { return this->m_int != mi.m_int; } + friend bool operator ==(const movable_int &l, const movable_int &r) + { return l.m_int == r.m_int; } - bool operator <(const movable_int &mi) const - { return this->m_int < mi.m_int; } + friend bool operator !=(const movable_int &l, const movable_int &r) + { return l.m_int != r.m_int; } - bool operator <=(const movable_int &mi) const - { return this->m_int <= mi.m_int; } + friend bool operator <(const movable_int &l, const movable_int &r) + { return l.m_int < r.m_int; } - bool operator >=(const movable_int &mi) const - { return this->m_int >= mi.m_int; } + friend bool operator <=(const movable_int &l, const movable_int &r) + { return l.m_int <= r.m_int; } - bool operator >(const movable_int &mi) const - { return this->m_int > mi.m_int; } + friend bool operator >=(const movable_int &l, const movable_int &r) + { return l.m_int >= r.m_int; } + + friend bool operator >(const movable_int &l, const movable_int &r) + { return l.m_int > r.m_int; } int get_int() const { return m_int; } @@ -84,6 +87,9 @@ class movable_int int m_int; }; +inline movable_int produce_movable_int() +{ return movable_int(); } + template std::basic_ostream & operator<< (std::basic_ostream & os, movable_int const & p) @@ -93,7 +99,6 @@ std::basic_ostream & operator<< return os; } - template<> struct is_copyable { @@ -121,6 +126,9 @@ class movable_and_copyable_int : m_int(mmi.m_int) { mmi.m_int = 0; } + ~movable_and_copyable_int() + { this->m_int = 0; } + movable_and_copyable_int &operator= (BOOST_COPY_ASSIGN_REF(movable_and_copyable_int) mi) { this->m_int = mi.m_int; return *this; } @@ -130,23 +138,23 @@ class movable_and_copyable_int movable_and_copyable_int & operator= (int i) { this->m_int = i; return *this; } - bool operator ==(const movable_and_copyable_int &mi) const - { return this->m_int == mi.m_int; } + friend bool operator ==(const movable_and_copyable_int &l, const movable_and_copyable_int &r) + { return l.m_int == r.m_int; } - bool operator !=(const movable_and_copyable_int &mi) const - { return this->m_int != mi.m_int; } + friend bool operator !=(const movable_and_copyable_int &l, const movable_and_copyable_int &r) + { return l.m_int != r.m_int; } - bool operator <(const movable_and_copyable_int &mi) const - { return this->m_int < mi.m_int; } + friend bool operator <(const movable_and_copyable_int &l, const movable_and_copyable_int &r) + { return l.m_int < r.m_int; } - bool operator <=(const movable_and_copyable_int &mi) const - { return this->m_int <= mi.m_int; } + friend bool operator <=(const movable_and_copyable_int &l, const movable_and_copyable_int &r) + { return l.m_int <= r.m_int; } - bool operator >=(const movable_and_copyable_int &mi) const - { return this->m_int >= mi.m_int; } + friend bool operator >=(const movable_and_copyable_int &l, const movable_and_copyable_int &r) + { return l.m_int >= r.m_int; } - bool operator >(const movable_and_copyable_int &mi) const - { return this->m_int > mi.m_int; } + friend bool operator >(const movable_and_copyable_int &l, const movable_and_copyable_int &r) + { return l.m_int > r.m_int; } int get_int() const { return m_int; } @@ -161,6 +169,9 @@ class movable_and_copyable_int int m_int; }; +inline movable_and_copyable_int produce_movable_and_copyable_int() +{ return movable_and_copyable_int(); } + template std::basic_ostream & operator<< (std::basic_ostream & os, movable_and_copyable_int const & p) @@ -194,23 +205,29 @@ class copyable_int copyable_int & operator= (int i) { this->m_int = i; return *this; } - bool operator ==(const copyable_int &mi) const - { return this->m_int == mi.m_int; } + copyable_int & operator= (const copyable_int &ci) + { this->m_int = ci.m_int; return *this; } - bool operator !=(const copyable_int &mi) const - { return this->m_int != mi.m_int; } + ~copyable_int() + { this->m_int = 0; } - bool operator <(const copyable_int &mi) const - { return this->m_int < mi.m_int; } + friend bool operator ==(const copyable_int &l, const copyable_int &r) + { return l.m_int == r.m_int; } - bool operator <=(const copyable_int &mi) const - { return this->m_int <= mi.m_int; } + friend bool operator !=(const copyable_int &l, const copyable_int &r) + { return l.m_int != r.m_int; } - bool operator >=(const copyable_int &mi) const - { return this->m_int >= mi.m_int; } + friend bool operator <(const copyable_int &l, const copyable_int &r) + { return l.m_int < r.m_int; } - bool operator >(const copyable_int &mi) const - { return this->m_int > mi.m_int; } + friend bool operator <=(const copyable_int &l, const copyable_int &r) + { return l.m_int <= r.m_int; } + + friend bool operator >=(const copyable_int &l, const copyable_int &r) + { return l.m_int >= r.m_int; } + + friend bool operator >(const copyable_int &l, const copyable_int &r) + { return l.m_int > r.m_int; } int get_int() const { return m_int; } @@ -225,6 +242,9 @@ class copyable_int int m_int; }; +inline copyable_int produce_copyable_int() +{ return copyable_int(); } + template std::basic_ostream & operator<< (std::basic_ostream & os, copyable_int const & p) @@ -254,6 +274,9 @@ class non_copymovable_int : m_int(a) {} + ~non_copymovable_int() + { m_int = 0; } + bool operator ==(const non_copymovable_int &mi) const { return this->m_int == mi.m_int; } diff --git a/test/static_vector_test.cpp b/test/static_vector_test.cpp index f12e7e1..f616174 100644 --- a/test/static_vector_test.cpp +++ b/test/static_vector_test.cpp @@ -19,31 +19,35 @@ namespace test { //so write our own macro inline void throw_failed_impl(char const * excep, char const * file, int line, char const * function) { - BOOST_LIGHTWEIGHT_TEST_OSTREAM - << file << "(" << line << "): Exception '" << excep << "' not thrown in function '" - << function << "'" << std::endl; - ++boost::detail::test_errors(); + BOOST_LIGHTWEIGHT_TEST_OSTREAM + << file << "(" << line << "): Exception '" << excep << "' not thrown in function '" + << function << "'" << std::endl; + ++boost::detail::test_errors(); } } //namespace detail { } //namespace container { } //namespace boost { -#define BOOST_TEST_THROW( S, E ) \ - try { \ - S; \ - ::boost::container::test::throw_failed_impl \ - (#E, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \ - } \ - catch( E const&) { \ - } \ +#define BOOST_TEST_THROW( S, E ) \ + try { \ + S; \ + ::boost::container::test::throw_failed_impl \ + (#E, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \ + } \ + catch(E const&) { \ + } \ + catch(...) { \ + ::boost::container::test::throw_failed_impl \ + (#E, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \ + } \ // // TODO: Disable parts of the unit test that should not run when BOOST_NO_EXCEPTIONS // if exceptions are enabled there must be a user defined throw_exception function #ifdef BOOST_NO_EXCEPTIONS namespace boost { - void throw_exception(std::exception const & e){}; // user defined + void throw_exception(std::exception const & e){}; // user defined } // namespace boost #endif // BOOST_NO_EXCEPTIONS @@ -69,735 +73,734 @@ template class boost::container::static_vector; template void test_ctor_ndc() { - static_vector s; - BOOST_TEST_EQ(s.size() , 0u); - BOOST_TEST(s.capacity() == N); + static_vector s; + BOOST_TEST_EQ(s.size() , 0u); + BOOST_TEST(s.capacity() == N); #ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW( s.at(0u), std::out_of_range ); + BOOST_TEST_THROW( s.at(0u), std::out_of_range ); #endif // BOOST_NO_EXCEPTIONS } template void test_ctor_nc(size_t n) { - static_vector s(n); - BOOST_TEST(s.size() == n); - BOOST_TEST(s.capacity() == N); + static_vector s(n); + BOOST_TEST(s.size() == n); + BOOST_TEST(s.capacity() == N); #ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW( s.at(n), std::out_of_range ); + BOOST_TEST_THROW( s.at(n), std::out_of_range ); #endif // BOOST_NO_EXCEPTIONS - if ( 1 < n ) - { - T val10(10); - s[0] = val10; - BOOST_TEST(T(10) == s[0]); - BOOST_TEST(T(10) == s.at(0)); - T val20(20); - s.at(1) = val20; - BOOST_TEST(T(20) == s[1]); - BOOST_TEST(T(20) == s.at(1)); - } + if ( 1 < n ) + { + T val10(10); + s[0] = val10; + BOOST_TEST(T(10) == s[0]); + BOOST_TEST(T(10) == s.at(0)); + T val20(20); + s.at(1) = val20; + BOOST_TEST(T(20) == s[1]); + BOOST_TEST(T(20) == s.at(1)); + } } template void test_ctor_nd(size_t n, T const& v) { - static_vector s(n, v); - BOOST_TEST(s.size() == n); - BOOST_TEST(s.capacity() == N); + static_vector s(n, v); + BOOST_TEST(s.size() == n); + BOOST_TEST(s.capacity() == N); #ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW( s.at(n), std::out_of_range ); + BOOST_TEST_THROW( s.at(n), std::out_of_range ); #endif // BOOST_NO_EXCEPTIONS - if ( 1 < n ) - { - BOOST_TEST(v == s[0]); - BOOST_TEST(v == s.at(0)); - BOOST_TEST(v == s[1]); - BOOST_TEST(v == s.at(1)); - s[0] = T(10); - BOOST_TEST(T(10) == s[0]); - BOOST_TEST(T(10) == s.at(0)); - s.at(1) = T(20); - BOOST_TEST(T(20) == s[1]); - BOOST_TEST(T(20) == s.at(1)); - } + if ( 1 < n ) + { + BOOST_TEST(v == s[0]); + BOOST_TEST(v == s.at(0)); + BOOST_TEST(v == s[1]); + BOOST_TEST(v == s.at(1)); + s[0] = T(10); + BOOST_TEST(T(10) == s[0]); + BOOST_TEST(T(10) == s.at(0)); + s.at(1) = T(20); + BOOST_TEST(T(20) == s[1]); + BOOST_TEST(T(20) == s.at(1)); + } } template void test_resize_nc(size_t n) { - static_vector s; + static_vector s; - s.resize(n); - BOOST_TEST(s.size() == n); - BOOST_TEST(s.capacity() == N); + s.resize(n); + BOOST_TEST(s.size() == n); + BOOST_TEST(s.capacity() == N); #ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW( s.at(n), std::out_of_range ); + BOOST_TEST_THROW( s.at(n), std::out_of_range ); #endif // BOOST_NO_EXCEPTIONS - if ( 1 < n ) - { - T val10(10); - s[0] = val10; - BOOST_TEST(T(10) == s[0]); - BOOST_TEST(T(10) == s.at(0)); - T val20(20); - s.at(1) = val20; - BOOST_TEST(T(20) == s[1]); - BOOST_TEST(T(20) == s.at(1)); - } + if ( 1 < n ) + { + T val10(10); + s[0] = val10; + BOOST_TEST(T(10) == s[0]); + BOOST_TEST(T(10) == s.at(0)); + T val20(20); + s.at(1) = val20; + BOOST_TEST(T(20) == s[1]); + BOOST_TEST(T(20) == s.at(1)); + } } template void test_resize_nd(size_t n, T const& v) { - static_vector s; + static_vector s; - s.resize(n, v); - BOOST_TEST(s.size() == n); - BOOST_TEST(s.capacity() == N); + s.resize(n, v); + BOOST_TEST(s.size() == n); + BOOST_TEST(s.capacity() == N); #ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW( s.at(n), std::out_of_range ); + BOOST_TEST_THROW( s.at(n), std::out_of_range ); #endif // BOOST_NO_EXCEPTIONS - if ( 1 < n ) - { - BOOST_TEST(v == s[0]); - BOOST_TEST(v == s.at(0)); - BOOST_TEST(v == s[1]); - BOOST_TEST(v == s.at(1)); - s[0] = T(10); - BOOST_TEST(T(10) == s[0]); - BOOST_TEST(T(10) == s.at(0)); - s.at(1) = T(20); - BOOST_TEST(T(20) == s[1]); - BOOST_TEST(T(20) == s.at(1)); - } + if ( 1 < n ) + { + BOOST_TEST(v == s[0]); + BOOST_TEST(v == s.at(0)); + BOOST_TEST(v == s[1]); + BOOST_TEST(v == s.at(1)); + s[0] = T(10); + BOOST_TEST(T(10) == s[0]); + BOOST_TEST(T(10) == s.at(0)); + s.at(1) = T(20); + BOOST_TEST(T(20) == s[1]); + BOOST_TEST(T(20) == s.at(1)); + } } template void test_push_back_nd() { - static_vector s; + static_vector s; - BOOST_TEST(s.size() == 0); + BOOST_TEST(s.size() == 0); #ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW( s.at(0), std::out_of_range ); + BOOST_TEST_THROW( s.at(0), std::out_of_range ); #endif // BOOST_NO_EXCEPTIONS - for ( size_t i = 0 ; i < N ; ++i ) - { - T t(i); - s.push_back(t); - BOOST_TEST(s.size() == i + 1); + for ( size_t i = 0 ; i < N ; ++i ) + { + T t(i); + s.push_back(t); + BOOST_TEST(s.size() == i + 1); #ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW( s.at(i + 1), std::out_of_range ); + BOOST_TEST_THROW( s.at(i + 1), std::out_of_range ); #endif // BOOST_NO_EXCEPTIONS - BOOST_TEST(T(i) == s.at(i)); - BOOST_TEST(T(i) == s[i]); - BOOST_TEST(T(i) == s.back()); - BOOST_TEST(T(0) == s.front()); - BOOST_TEST(T(i) == *(s.data() + i)); - } + BOOST_TEST(T(i) == s.at(i)); + BOOST_TEST(T(i) == s[i]); + BOOST_TEST(T(i) == s.back()); + BOOST_TEST(T(0) == s.front()); + BOOST_TEST(T(i) == *(s.data() + i)); + } } template void test_pop_back_nd() { - static_vector s; + static_vector s; - for ( size_t i = 0 ; i < N ; ++i ) - { - T t(i); - s.push_back(t); - } + for ( size_t i = 0 ; i < N ; ++i ) + { + T t(i); + s.push_back(t); + } - for ( size_t i = N ; i > 1 ; --i ) - { - s.pop_back(); - BOOST_TEST(s.size() == i - 1); + for ( size_t i = N ; i > 1 ; --i ) + { + s.pop_back(); + BOOST_TEST(s.size() == i - 1); #ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW( s.at(i - 1), std::out_of_range ); + BOOST_TEST_THROW( s.at(i - 1), std::out_of_range ); #endif // BOOST_NO_EXCEPTIONS - BOOST_TEST(T(i - 2) == s.at(i - 2)); - BOOST_TEST(T(i - 2) == s[i - 2]); - BOOST_TEST(T(i - 2) == s.back()); - BOOST_TEST(T(0) == s.front()); - } + BOOST_TEST(T(i - 2) == s.at(i - 2)); + BOOST_TEST(T(i - 2) == s[i - 2]); + BOOST_TEST(T(i - 2) == s.back()); + BOOST_TEST(T(0) == s.front()); + } } template void test_compare_ranges(It1 first1, It1 last1, It2 first2, It2 last2) { - BOOST_TEST(std::distance(first1, last1) == std::distance(first2, last2)); - for ( ; first1 != last1 && first2 != last2 ; ++first1, ++first2 ) - BOOST_TEST(*first1 == *first2); + BOOST_TEST(std::distance(first1, last1) == std::distance(first2, last2)); + for ( ; first1 != last1 && first2 != last2 ; ++first1, ++first2 ) + BOOST_TEST(*first1 == *first2); } template void test_copy_and_assign(C const& c) { - { - static_vector s(c.begin(), c.end()); - BOOST_TEST(s.size() == c.size()); - test_compare_ranges(s.begin(), s.end(), c.begin(), c.end()); - } - { - static_vector s; - BOOST_TEST(0 == s.size()); - s.assign(c.begin(), c.end()); - BOOST_TEST(s.size() == c.size()); - test_compare_ranges(s.begin(), s.end(), c.begin(), c.end()); - } + { + static_vector s(c.begin(), c.end()); + BOOST_TEST(s.size() == c.size()); + test_compare_ranges(s.begin(), s.end(), c.begin(), c.end()); + } + { + static_vector s; + BOOST_TEST(0 == s.size()); + s.assign(c.begin(), c.end()); + BOOST_TEST(s.size() == c.size()); + test_compare_ranges(s.begin(), s.end(), c.begin(), c.end()); + } } template void test_copy_and_assign_nd(T const& val) { - static_vector s; - std::vector v; - std::list l; + static_vector s; + std::vector v; + std::list l; - for ( size_t i = 0 ; i < N ; ++i ) - { - T t(i); - s.push_back(t); - v.push_back(t); - l.push_back(t); - } - // copy ctor - { - static_vector s1(s); - BOOST_TEST(s.size() == s1.size()); - test_compare_ranges(s.begin(), s.end(), s1.begin(), s1.end()); - } - // copy assignment - { - static_vector s1; - BOOST_TEST(0 == s1.size()); - s1 = s; - BOOST_TEST(s.size() == s1.size()); - test_compare_ranges(s.begin(), s.end(), s1.begin(), s1.end()); - } + for ( size_t i = 0 ; i < N ; ++i ) + { + T t(i); + s.push_back(t); + v.push_back(t); + l.push_back(t); + } + // copy ctor + { + static_vector s1(s); + BOOST_TEST(s.size() == s1.size()); + test_compare_ranges(s.begin(), s.end(), s1.begin(), s1.end()); + } + // copy assignment + { + static_vector s1; + BOOST_TEST(0 == s1.size()); + s1 = s; + BOOST_TEST(s.size() == s1.size()); + test_compare_ranges(s.begin(), s.end(), s1.begin(), s1.end()); + } - // ctor(Iter, Iter) and assign(Iter, Iter) - test_copy_and_assign(s); - test_copy_and_assign(v); - test_copy_and_assign(l); + // ctor(Iter, Iter) and assign(Iter, Iter) + test_copy_and_assign(s); + test_copy_and_assign(v); + test_copy_and_assign(l); - // assign(N, V) - { - static_vector s1(s); - test_compare_ranges(s.begin(), s.end(), s1.begin(), s1.end()); - std::vector a(N, val); - s1.assign(N, val); - test_compare_ranges(a.begin(), a.end(), s1.begin(), s1.end()); - } + // assign(N, V) + { + static_vector s1(s); + test_compare_ranges(s.begin(), s.end(), s1.begin(), s1.end()); + std::vector a(N, val); + s1.assign(N, val); + test_compare_ranges(a.begin(), a.end(), s1.begin(), s1.end()); + } #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - stable_vector bsv(s.begin(), s.end()); - vector bv(s.begin(), s.end()); - test_copy_and_assign(bsv); - test_copy_and_assign(bv); + stable_vector bsv(s.begin(), s.end()); + vector bv(s.begin(), s.end()); + test_copy_and_assign(bsv); + test_copy_and_assign(bv); #endif } template void test_iterators_nd() { - static_vector s; - std::vector v; + static_vector s; + std::vector v; - for ( size_t i = 0 ; i < N ; ++i ) - { - s.push_back(T(i)); - v.push_back(T(i)); - } + for ( size_t i = 0 ; i < N ; ++i ) + { + s.push_back(T(i)); + v.push_back(T(i)); + } - test_compare_ranges(s.begin(), s.end(), v.begin(), v.end()); - test_compare_ranges(s.rbegin(), s.rend(), v.rbegin(), v.rend()); + test_compare_ranges(s.begin(), s.end(), v.begin(), v.end()); + test_compare_ranges(s.rbegin(), s.rend(), v.rbegin(), v.rend()); - s.assign(v.rbegin(), v.rend()); + s.assign(v.rbegin(), v.rend()); - test_compare_ranges(s.begin(), s.end(), v.rbegin(), v.rend()); - test_compare_ranges(s.rbegin(), s.rend(), v.begin(), v.end()); + test_compare_ranges(s.begin(), s.end(), v.rbegin(), v.rend()); + test_compare_ranges(s.rbegin(), s.rend(), v.begin(), v.end()); } template void test_erase_nd() { - static_vector s; - typedef typename static_vector::iterator It; + static_vector s; + typedef typename static_vector::iterator It; - for ( size_t i = 0 ; i < N ; ++i ) - s.push_back(T(i)); + for ( size_t i = 0 ; i < N ; ++i ) + s.push_back(T(i)); - // erase(pos) - { - for ( size_t i = 0 ; i < N ; ++i ) - { - static_vector s1(s); - It it = s1.erase(s1.begin() + i); - BOOST_TEST(s1.begin() + i == it); - BOOST_TEST(s1.size() == N - 1); - for ( size_t j = 0 ; j < i ; ++j ) - BOOST_TEST(s1[j] == T(j)); - for ( size_t j = i+1 ; j < N ; ++j ) - BOOST_TEST(s1[j-1] == T(j)); - } - } - // erase(first, last) - { - size_t n = N/3; - for ( size_t i = 0 ; i <= N ; ++i ) - { - static_vector s1(s); - size_t removed = i + n < N ? n : N - i; - It it = s1.erase(s1.begin() + i, s1.begin() + i + removed); - BOOST_TEST(s1.begin() + i == it); - BOOST_TEST(s1.size() == N - removed); - for ( size_t j = 0 ; j < i ; ++j ) - BOOST_TEST(s1[j] == T(j)); - for ( size_t j = i+n ; j < N ; ++j ) - BOOST_TEST(s1[j-n] == T(j)); - } - } + // erase(pos) + { + for ( size_t i = 0 ; i < N ; ++i ) + { + static_vector s1(s); + It it = s1.erase(s1.begin() + i); + BOOST_TEST(s1.begin() + i == it); + BOOST_TEST(s1.size() == N - 1); + for ( size_t j = 0 ; j < i ; ++j ) + BOOST_TEST(s1[j] == T(j)); + for ( size_t j = i+1 ; j < N ; ++j ) + BOOST_TEST(s1[j-1] == T(j)); + } + } + // erase(first, last) + { + size_t n = N/3; + for ( size_t i = 0 ; i <= N ; ++i ) + { + static_vector s1(s); + size_t removed = i + n < N ? n : N - i; + It it = s1.erase(s1.begin() + i, s1.begin() + i + removed); + BOOST_TEST(s1.begin() + i == it); + BOOST_TEST(s1.size() == N - removed); + for ( size_t j = 0 ; j < i ; ++j ) + BOOST_TEST(s1[j] == T(j)); + for ( size_t j = i+n ; j < N ; ++j ) + BOOST_TEST(s1[j-n] == T(j)); + } + } } template void test_insert(SV const& s, C const& c) { - size_t h = N/2; - size_t n = size_t(h/1.5f); + size_t h = N/2; + size_t n = size_t(h/1.5f); - for ( size_t i = 0 ; i <= h ; ++i ) - { - static_vector s1(s); + for ( size_t i = 0 ; i <= h ; ++i ) + { + static_vector s1(s); - typename C::const_iterator it = c.begin(); - std::advance(it, n); - typename static_vector::iterator - it1 = s1.insert(s1.begin() + i, c.begin(), it); + typename C::const_iterator it = c.begin(); + std::advance(it, n); + typename static_vector::iterator + it1 = s1.insert(s1.begin() + i, c.begin(), it); - BOOST_TEST(s1.begin() + i == it1); - BOOST_TEST(s1.size() == h+n); - for ( size_t j = 0 ; j < i ; ++j ) - BOOST_TEST(s1[j] == T(j)); - for ( size_t j = 0 ; j < n ; ++j ) - BOOST_TEST(s1[j+i] == T(100 + j)); - for ( size_t j = 0 ; j < h-i ; ++j ) - BOOST_TEST(s1[j+i+n] == T(j+i)); - } + BOOST_TEST(s1.begin() + i == it1); + BOOST_TEST(s1.size() == h+n); + for ( size_t j = 0 ; j < i ; ++j ) + BOOST_TEST(s1[j] == T(j)); + for ( size_t j = 0 ; j < n ; ++j ) + BOOST_TEST(s1[j+i] == T(100 + j)); + for ( size_t j = 0 ; j < h-i ; ++j ) + BOOST_TEST(s1[j+i+n] == T(j+i)); + } } template void test_insert_nd(T const& val) { - size_t h = N/2; + size_t h = N/2; - static_vector s, ss; - std::vector v; - std::list l; + static_vector s, ss; + std::vector v; + std::list l; - typedef typename static_vector::iterator It; + typedef typename static_vector::iterator It; - for ( size_t i = 0 ; i < h ; ++i ) - { - s.push_back(T(i)); - ss.push_back(T(100 + i)); - v.push_back(T(100 + i)); - l.push_back(T(100 + i)); - } + for ( size_t i = 0 ; i < h ; ++i ) + { + s.push_back(T(i)); + ss.push_back(T(100 + i)); + v.push_back(T(100 + i)); + l.push_back(T(100 + i)); + } - // insert(pos, val) - { - for ( size_t i = 0 ; i <= h ; ++i ) - { - static_vector s1(s); - It it = s1.insert(s1.begin() + i, val); - BOOST_TEST(s1.begin() + i == it); - BOOST_TEST(s1.size() == h+1); - for ( size_t j = 0 ; j < i ; ++j ) - BOOST_TEST(s1[j] == T(j)); - BOOST_TEST(s1[i] == val); - for ( size_t j = 0 ; j < h-i ; ++j ) - BOOST_TEST(s1[j+i+1] == T(j+i)); - } - } - // insert(pos, n, val) - { - size_t n = size_t(h/1.5f); - for ( size_t i = 0 ; i <= h ; ++i ) - { - static_vector s1(s); - It it = s1.insert(s1.begin() + i, n, val); - BOOST_TEST(s1.begin() + i == it); - BOOST_TEST(s1.size() == h+n); - for ( size_t j = 0 ; j < i ; ++j ) - BOOST_TEST(s1[j] == T(j)); - for ( size_t j = 0 ; j < n ; ++j ) - BOOST_TEST(s1[j+i] == val); - for ( size_t j = 0 ; j < h-i ; ++j ) - BOOST_TEST(s1[j+i+n] == T(j+i)); - } - } - // insert(pos, first, last) - test_insert(s, ss); - test_insert(s, v); - test_insert(s, l); + // insert(pos, val) + { + for ( size_t i = 0 ; i <= h ; ++i ) + { + static_vector s1(s); + It it = s1.insert(s1.begin() + i, val); + BOOST_TEST(s1.begin() + i == it); + BOOST_TEST(s1.size() == h+1); + for ( size_t j = 0 ; j < i ; ++j ) + BOOST_TEST(s1[j] == T(j)); + BOOST_TEST(s1[i] == val); + for ( size_t j = 0 ; j < h-i ; ++j ) + BOOST_TEST(s1[j+i+1] == T(j+i)); + } + } + // insert(pos, n, val) + { + size_t n = size_t(h/1.5f); + for ( size_t i = 0 ; i <= h ; ++i ) + { + static_vector s1(s); + It it = s1.insert(s1.begin() + i, n, val); + BOOST_TEST(s1.begin() + i == it); + BOOST_TEST(s1.size() == h+n); + for ( size_t j = 0 ; j < i ; ++j ) + BOOST_TEST(s1[j] == T(j)); + for ( size_t j = 0 ; j < n ; ++j ) + BOOST_TEST(s1[j+i] == val); + for ( size_t j = 0 ; j < h-i ; ++j ) + BOOST_TEST(s1[j+i+n] == T(j+i)); + } + } + // insert(pos, first, last) + test_insert(s, ss); + test_insert(s, v); + test_insert(s, l); #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - stable_vector bsv(ss.begin(), ss.end()); - vector bv(ss.begin(), ss.end()); - test_insert(s, bv); - test_insert(s, bsv); + stable_vector bsv(ss.begin(), ss.end()); + vector bv(ss.begin(), ss.end()); + test_insert(s, bv); + test_insert(s, bsv); #endif } template void test_capacity_0_nd() { - static_vector v(5u, T(0)); + static_vector v(5u, T(0)); - static_vector s; - BOOST_TEST(s.size() == 0); - BOOST_TEST(s.capacity() == 0); + static_vector s; + BOOST_TEST(s.size() == 0); + BOOST_TEST(s.capacity() == 0); #ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW(s.at(0), std::out_of_range); - BOOST_TEST_THROW(s.resize(5u, T(0)), std::bad_alloc); - BOOST_TEST_THROW(s.push_back(T(0)), std::bad_alloc); - BOOST_TEST_THROW(s.insert(s.end(), T(0)), std::bad_alloc); - BOOST_TEST_THROW(s.insert(s.end(), 5u, T(0)), std::bad_alloc); - BOOST_TEST_THROW(s.insert(s.end(), v.begin(), v.end()), std::bad_alloc); - BOOST_TEST_THROW(s.assign(v.begin(), v.end()), std::bad_alloc); - BOOST_TEST_THROW(s.assign(5u, T(0)), std::bad_alloc); - try{ - static_vector s2(v.begin(), v.end()); - BOOST_TEST(false); - }catch(std::bad_alloc &){} - try{ - static_vector s1(5u, T(0)); - BOOST_TEST(false); - }catch(std::bad_alloc &){} + BOOST_TEST_THROW(s.at(0), std::out_of_range); + BOOST_TEST_THROW(s.resize(5u, T(0)), std::bad_alloc); + BOOST_TEST_THROW(s.push_back(T(0)), std::bad_alloc); + BOOST_TEST_THROW(s.insert(s.end(), T(0)), std::bad_alloc); + BOOST_TEST_THROW(s.insert(s.end(), 5u, T(0)), std::bad_alloc); + BOOST_TEST_THROW(s.insert(s.end(), v.begin(), v.end()), std::bad_alloc); + BOOST_TEST_THROW(s.assign(v.begin(), v.end()), std::bad_alloc); + BOOST_TEST_THROW(s.assign(5u, T(0)), std::bad_alloc); + try{ + static_vector s2(v.begin(), v.end()); + BOOST_TEST(false); + }catch(std::bad_alloc &){} + try{ + static_vector s1(5u, T(0)); + BOOST_TEST(false); + }catch(std::bad_alloc &){} #endif // BOOST_NO_EXCEPTIONS } template void test_exceptions_nd() { - static_vector v(N, T(0)); - static_vector s(N/2, T(0)); + static_vector v(N, T(0)); + static_vector s(N/2, T(0)); #ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW(s.resize(N, T(0)), std::bad_alloc); - BOOST_TEST_THROW(s.push_back(T(0)), std::bad_alloc); - BOOST_TEST_THROW(s.insert(s.end(), T(0)), std::bad_alloc); - BOOST_TEST_THROW(s.insert(s.end(), N, T(0)), std::bad_alloc); - BOOST_TEST_THROW(s.insert(s.end(), v.begin(), v.end()), std::bad_alloc); - BOOST_TEST_THROW(s.assign(v.begin(), v.end()), std::bad_alloc); - BOOST_TEST_THROW(s.assign(N, T(0)), std::bad_alloc); - try{ - static_vector s2(v.begin(), v.end()); - BOOST_TEST(false); - }catch(std::bad_alloc &){} - try{ - static_vector s1(N, T(0)); - BOOST_TEST(false); - }catch(std::bad_alloc &){} + BOOST_TEST_THROW(s.resize(N, T(0)), std::bad_alloc); + BOOST_TEST_THROW(s.push_back(T(0)), std::bad_alloc); + BOOST_TEST_THROW(s.insert(s.end(), T(0)), std::bad_alloc); + BOOST_TEST_THROW(s.insert(s.end(), N, T(0)), std::bad_alloc); + BOOST_TEST_THROW(s.insert(s.end(), v.begin(), v.end()), std::bad_alloc); + BOOST_TEST_THROW(s.assign(v.begin(), v.end()), std::bad_alloc); + BOOST_TEST_THROW(s.assign(N, T(0)), std::bad_alloc); + try{ + static_vector s2(v.begin(), v.end()); + BOOST_TEST(false); + }catch(std::bad_alloc &){} + try{ + static_vector s1(N, T(0)); + BOOST_TEST(false); + }catch(std::bad_alloc &){} #endif // BOOST_NO_EXCEPTIONS } template void test_swap_and_move_nd() { - { - static_vector v1, v2, v3, v4; - static_vector s1, s2; - static_vector s4; + { + static_vector v1, v2, v3, v4; + static_vector s1, s2; + static_vector s4; - for (size_t i = 0 ; i < N ; ++i ) - { - v1.push_back(T(i)); - v2.push_back(T(i)); - v3.push_back(T(i)); - v4.push_back(T(i)); - } - for (size_t i = 0 ; i < N/2 ; ++i ) - { - s1.push_back(T(100 + i)); - s2.push_back(T(100 + i)); - s4.push_back(T(100 + i)); - } + for (size_t i = 0 ; i < N ; ++i ) + { + v1.push_back(T(i)); + v2.push_back(T(i)); + v3.push_back(T(i)); + v4.push_back(T(i)); + } + for (size_t i = 0 ; i < N/2 ; ++i ) + { + s1.push_back(T(100 + i)); + s2.push_back(T(100 + i)); + s4.push_back(T(100 + i)); + } - s1.swap(v1); - s2 = boost::move(v2); - static_vector s3(boost::move(v3)); - s4.swap(v4); + s1.swap(v1); + s2 = boost::move(v2); + static_vector s3(boost::move(v3)); + s4.swap(v4); - BOOST_TEST(v1.size() == N/2); - BOOST_TEST(s1.size() == N); - //iG moving does not imply emptying source - //BOOST_TEST(v2.size() == 0); - BOOST_TEST(s2.size() == N); - //iG moving does not imply emptying source - //BOOST_TEST(v3.size() == 0); - BOOST_TEST(s3.size() == N); - BOOST_TEST(v4.size() == N/2); - BOOST_TEST(s4.size() == N); - for (size_t i = 0 ; i < N/2 ; ++i ) - { - BOOST_TEST(v1[i] == T(100 + i)); - BOOST_TEST(v4[i] == T(100 + i)); - } - for (size_t i = 0 ; i < N ; ++i ) - { - BOOST_TEST(s1[i] == T(i)); - BOOST_TEST(s2[i] == T(i)); - BOOST_TEST(s3[i] == T(i)); - BOOST_TEST(s4[i] == T(i)); - } - } - { - static_vector v1, v2, v3; - static_vector s1, s2; + BOOST_TEST(v1.size() == N/2); + BOOST_TEST(s1.size() == N); + //iG moving does not imply emptying source + //BOOST_TEST(v2.size() == 0); + BOOST_TEST(s2.size() == N); + //iG moving does not imply emptying source + //BOOST_TEST(v3.size() == 0); + BOOST_TEST(s3.size() == N); + BOOST_TEST(v4.size() == N/2); + BOOST_TEST(s4.size() == N); + for (size_t i = 0 ; i < N/2 ; ++i ) + { + BOOST_TEST(v1[i] == T(100 + i)); + BOOST_TEST(v4[i] == T(100 + i)); + } + for (size_t i = 0 ; i < N ; ++i ) + { + BOOST_TEST(s1[i] == T(i)); + BOOST_TEST(s2[i] == T(i)); + BOOST_TEST(s3[i] == T(i)); + BOOST_TEST(s4[i] == T(i)); + } + } + { + static_vector v1, v2, v3; + static_vector s1, s2; - for (size_t i = 0 ; i < N/2 ; ++i ) - { - v1.push_back(T(i)); - v2.push_back(T(i)); - v3.push_back(T(i)); - } - for (size_t i = 0 ; i < N/3 ; ++i ) - { - s1.push_back(T(100 + i)); - s2.push_back(T(100 + i)); - } + for (size_t i = 0 ; i < N/2 ; ++i ) + { + v1.push_back(T(i)); + v2.push_back(T(i)); + v3.push_back(T(i)); + } + for (size_t i = 0 ; i < N/3 ; ++i ) + { + s1.push_back(T(100 + i)); + s2.push_back(T(100 + i)); + } - s1.swap(v1); - s2 = boost::move(v2); - static_vector s3(boost::move(v3)); + s1.swap(v1); + s2 = boost::move(v2); + static_vector s3(boost::move(v3)); - BOOST_TEST(v1.size() == N/3); - BOOST_TEST(s1.size() == N/2); - //iG moving does not imply emptying source - //BOOST_TEST(v2.size() == 0); - BOOST_TEST(s2.size() == N/2); - //iG moving does not imply emptying source - //BOOST_TEST(v3.size() == 0); - BOOST_TEST(s3.size() == N/2); - for (size_t i = 0 ; i < N/3 ; ++i ) - BOOST_TEST(v1[i] == T(100 + i)); - for (size_t i = 0 ; i < N/2 ; ++i ) - { - BOOST_TEST(s1[i] == T(i)); - BOOST_TEST(s2[i] == T(i)); - BOOST_TEST(s3[i] == T(i)); - } - } - { - static_vector v(N, T(0)); - static_vector s(N/2, T(1)); + BOOST_TEST(v1.size() == N/3); + BOOST_TEST(s1.size() == N/2); + //iG moving does not imply emptying source + //BOOST_TEST(v2.size() == 0); + BOOST_TEST(s2.size() == N/2); + //iG moving does not imply emptying source + //BOOST_TEST(v3.size() == 0); + BOOST_TEST(s3.size() == N/2); + for (size_t i = 0 ; i < N/3 ; ++i ) + BOOST_TEST(v1[i] == T(100 + i)); + for (size_t i = 0 ; i < N/2 ; ++i ) + { + BOOST_TEST(s1[i] == T(i)); + BOOST_TEST(s2[i] == T(i)); + BOOST_TEST(s3[i] == T(i)); + } + } + { + typedef static_vector small_vector_t; + static_vector v(N, T(0)); + small_vector_t s(N/2, T(1)); #ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW(s.swap(v), std::bad_alloc); - v.resize(N, T(0)); - BOOST_TEST_THROW(s = boost::move(v), std::bad_alloc); - v.resize(N, T(0)); - try { - static_vector s2(boost::move(v)); - BOOST_TEST(false); - } catch (std::bad_alloc &) {} + BOOST_TEST_THROW(s.swap(v), std::bad_alloc); + v.resize(N, T(0)); + BOOST_TEST_THROW(s = boost::move(v), std::bad_alloc); + v.resize(N, T(0)); + BOOST_TEST_THROW(small_vector_t s2(boost::move(v)), std::bad_alloc); #endif // BOOST_NO_EXCEPTIONS - } + } } template void test_emplace_0p() { - //emplace_back() - { - static_vector v; + //emplace_back() + { + static_vector v; - for (int i = 0 ; i < int(N) ; ++i ) - v.emplace_back(); - BOOST_TEST(v.size() == N); + for (int i = 0 ; i < int(N) ; ++i ) + v.emplace_back(); + BOOST_TEST(v.size() == N); #ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW(v.emplace_back(), std::bad_alloc); + BOOST_TEST_THROW(v.emplace_back(), std::bad_alloc); #endif - } + } } template void test_emplace_2p() { - //emplace_back(pos, int, int) - { - static_vector v; + //emplace_back(pos, int, int) + { + static_vector v; - for (int i = 0 ; i < int(N) ; ++i ) - v.emplace_back(i, 100 + i); - BOOST_TEST(v.size() == N); + for (int i = 0 ; i < int(N) ; ++i ) + v.emplace_back(i, 100 + i); + BOOST_TEST(v.size() == N); #ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW(v.emplace_back(N, 100 + N), std::bad_alloc); + BOOST_TEST_THROW(v.emplace_back(N, 100 + N), std::bad_alloc); #endif - BOOST_TEST(v.size() == N); - for (int i = 0 ; i < int(N) ; ++i ) - BOOST_TEST(v[i] == T(i, 100 + i)); - } + BOOST_TEST(v.size() == N); + for (int i = 0 ; i < int(N) ; ++i ) + BOOST_TEST(v[i] == T(i, 100 + i)); + } - // emplace(pos, int, int) - { - typedef typename static_vector::iterator It; + // emplace(pos, int, int) + { + typedef typename static_vector::iterator It; - int h = N / 2; + int h = N / 2; - static_vector v; - for ( int i = 0 ; i < h ; ++i ) - v.emplace_back(i, 100 + i); + static_vector v; + for ( int i = 0 ; i < h ; ++i ) + v.emplace_back(i, 100 + i); - for ( int i = 0 ; i <= h ; ++i ) - { - static_vector vv(v); - It it = vv.emplace(vv.begin() + i, i+100, i+200); - BOOST_TEST(vv.begin() + i == it); - BOOST_TEST(vv.size() == size_t(h+1)); - for ( int j = 0 ; j < i ; ++j ) - BOOST_TEST(vv[j] == T(j, j+100)); - BOOST_TEST(vv[i] == T(i+100, i+200)); - for ( int j = 0 ; j < h-i ; ++j ) - BOOST_TEST(vv[j+i+1] == T(j+i, j+i+100)); - } - } + for ( int i = 0 ; i <= h ; ++i ) + { + static_vector vv(v); + It it = vv.emplace(vv.begin() + i, i+100, i+200); + BOOST_TEST(vv.begin() + i == it); + BOOST_TEST(vv.size() == size_t(h+1)); + for ( int j = 0 ; j < i ; ++j ) + BOOST_TEST(vv[j] == T(j, j+100)); + BOOST_TEST(vv[i] == T(i+100, i+200)); + for ( int j = 0 ; j < h-i ; ++j ) + BOOST_TEST(vv[j+i+1] == T(j+i, j+i+100)); + } + } } template void test_sv_elem(T const& t) { - typedef static_vector V; + typedef static_vector V; - static_vector v; + static_vector v; - v.push_back(V(N/2, t)); - V vvv(N/2, t); - v.push_back(boost::move(vvv)); - v.insert(v.begin(), V(N/2, t)); - v.insert(v.end(), V(N/2, t)); - v.emplace_back(N/2, t); + v.push_back(V(N/2, t)); + V vvv(N/2, t); + v.push_back(boost::move(vvv)); + v.insert(v.begin(), V(N/2, t)); + v.insert(v.end(), V(N/2, t)); + v.emplace_back(N/2, t); } int main(int, char* []) { - BOOST_TEST(counting_value::count() == 0); + using boost::container::test::movable_and_copyable_int; + using boost::container::test::produce_movable_and_copyable_int; + BOOST_TEST(counting_value::count() == 0); - test_ctor_ndc(); - test_ctor_ndc(); - test_ctor_ndc(); - BOOST_TEST(counting_value::count() == 0); - test_ctor_ndc(); - test_ctor_ndc(); + test_ctor_ndc(); + test_ctor_ndc(); + test_ctor_ndc(); + BOOST_TEST(counting_value::count() == 0); + test_ctor_ndc(); + test_ctor_ndc(); - test_ctor_nc(5); - test_ctor_nc(5); - test_ctor_nc(5); - BOOST_TEST(counting_value::count() == 0); - test_ctor_nc(5); - test_ctor_nc(5); + test_ctor_nc(5); + test_ctor_nc(5); + test_ctor_nc(5); + BOOST_TEST(counting_value::count() == 0); + test_ctor_nc(5); + test_ctor_nc(5); - test_ctor_nd(5, 1); - test_ctor_nd(5, value_nd(1)); - test_ctor_nd(5, counting_value(1)); - BOOST_TEST(counting_value::count() == 0); - test_ctor_nd(5, shptr_value(1)); - test_ctor_nd(5, produce()); + test_ctor_nd(5, 1); + test_ctor_nd(5, value_nd(1)); + test_ctor_nd(5, counting_value(1)); + BOOST_TEST(counting_value::count() == 0); + test_ctor_nd(5, shptr_value(1)); + test_ctor_nd(5, produce_movable_and_copyable_int()); - test_resize_nc(5); - test_resize_nc(5); - test_resize_nc(5); - BOOST_TEST(counting_value::count() == 0); - test_resize_nc(5); - test_resize_nc(5); + test_resize_nc(5); + test_resize_nc(5); + test_resize_nc(5); + BOOST_TEST(counting_value::count() == 0); + test_resize_nc(5); + test_resize_nc(5); - test_resize_nd(5, 1); - test_resize_nd(5, value_nd(1)); - test_resize_nd(5, counting_value(1)); - BOOST_TEST(counting_value::count() == 0); - test_resize_nd(5, shptr_value(1)); - test_resize_nd(5, produce()); + test_resize_nd(5, 1); + test_resize_nd(5, value_nd(1)); + test_resize_nd(5, counting_value(1)); + BOOST_TEST(counting_value::count() == 0); + test_resize_nd(5, shptr_value(1)); + test_resize_nd(5, produce_movable_and_copyable_int()); - test_push_back_nd(); - test_push_back_nd(); - test_push_back_nd(); - BOOST_TEST(counting_value::count() == 0); - test_push_back_nd(); - test_push_back_nd(); + test_push_back_nd(); + test_push_back_nd(); + test_push_back_nd(); + BOOST_TEST(counting_value::count() == 0); + test_push_back_nd(); + test_push_back_nd(); - test_pop_back_nd(); - test_pop_back_nd(); - test_pop_back_nd(); - BOOST_TEST(counting_value::count() == 0); - test_pop_back_nd(); - test_pop_back_nd(); + test_pop_back_nd(); + test_pop_back_nd(); + test_pop_back_nd(); + BOOST_TEST(counting_value::count() == 0); + test_pop_back_nd(); + test_pop_back_nd(); - test_copy_and_assign_nd(1); - test_copy_and_assign_nd(value_nd(1)); - test_copy_and_assign_nd(counting_value(1)); - BOOST_TEST(counting_value::count() == 0); - test_copy_and_assign_nd(shptr_value(1)); - test_copy_and_assign_nd(produce()); + test_copy_and_assign_nd(1); + test_copy_and_assign_nd(value_nd(1)); + test_copy_and_assign_nd(counting_value(1)); + BOOST_TEST(counting_value::count() == 0); + test_copy_and_assign_nd(shptr_value(1)); + test_copy_and_assign_nd(produce_movable_and_copyable_int()); - test_iterators_nd(); - test_iterators_nd(); - test_iterators_nd(); - BOOST_TEST(counting_value::count() == 0); - test_iterators_nd(); - test_iterators_nd(); + test_iterators_nd(); + test_iterators_nd(); + test_iterators_nd(); + BOOST_TEST(counting_value::count() == 0); + test_iterators_nd(); + test_iterators_nd(); - test_erase_nd(); - test_erase_nd(); - test_erase_nd(); - BOOST_TEST(counting_value::count() == 0); - test_erase_nd(); - test_erase_nd(); + test_erase_nd(); + test_erase_nd(); + test_erase_nd(); + BOOST_TEST(counting_value::count() == 0); + test_erase_nd(); + test_erase_nd(); - test_insert_nd(50); - test_insert_nd(value_nd(50)); - test_insert_nd(counting_value(50)); - BOOST_TEST(counting_value::count() == 0); - test_insert_nd(shptr_value(50)); - test_insert_nd(produce()); + test_insert_nd(50); + test_insert_nd(value_nd(50)); + test_insert_nd(counting_value(50)); + BOOST_TEST(counting_value::count() == 0); + test_insert_nd(shptr_value(50)); + test_insert_nd(produce_movable_and_copyable_int()); - test_capacity_0_nd(); - test_capacity_0_nd(); - test_capacity_0_nd(); - BOOST_TEST(counting_value::count() == 0); - test_capacity_0_nd(); - test_capacity_0_nd(); + test_capacity_0_nd(); + test_capacity_0_nd(); + test_capacity_0_nd(); + BOOST_TEST(counting_value::count() == 0); + test_capacity_0_nd(); + test_capacity_0_nd(); - test_exceptions_nd(); - test_exceptions_nd(); - test_exceptions_nd(); - BOOST_TEST(counting_value::count() == 0); - test_exceptions_nd(); - test_exceptions_nd(); + test_exceptions_nd(); + test_exceptions_nd(); + test_exceptions_nd(); + BOOST_TEST(counting_value::count() == 0); + test_exceptions_nd(); + test_exceptions_nd(); - test_swap_and_move_nd(); - test_swap_and_move_nd(); - test_swap_and_move_nd(); - BOOST_TEST(counting_value::count() == 0); - test_swap_and_move_nd(); - test_swap_and_move_nd(); + test_swap_and_move_nd(); + test_swap_and_move_nd(); + test_swap_and_move_nd(); + BOOST_TEST(counting_value::count() == 0); + test_swap_and_move_nd(); + test_swap_and_move_nd(); - test_emplace_0p(); - BOOST_TEST(counting_value::count() == 0); + test_emplace_0p(); + BOOST_TEST(counting_value::count() == 0); - test_emplace_2p(); - BOOST_TEST(counting_value::count() == 0); + test_emplace_2p(); + BOOST_TEST(counting_value::count() == 0); - test_sv_elem(50); - test_sv_elem(value_nd(50)); - test_sv_elem(counting_value(50)); - BOOST_TEST(counting_value::count() == 0); - test_sv_elem(shptr_value(50)); - test_sv_elem(copy_movable(50)); - - return boost::report_errors(); + test_sv_elem(50); + test_sv_elem(value_nd(50)); + test_sv_elem(counting_value(50)); + BOOST_TEST(counting_value::count() == 0); + test_sv_elem(shptr_value(50)); + test_sv_elem(movable_and_copyable_int(50)); + return boost::report_errors(); } #include diff --git a/test/static_vector_test.hpp b/test/static_vector_test.hpp index 3dfe697..f2b3a65 100644 --- a/test/static_vector_test.hpp +++ b/test/static_vector_test.hpp @@ -14,7 +14,7 @@ #include #include -#include "movable.hpp" +#include "movable_int.hpp" using namespace boost::container; diff --git a/test/vector_test.hpp b/test/vector_test.hpp index 318e339..3771eaf 100644 --- a/test/vector_test.hpp +++ b/test/vector_test.hpp @@ -216,7 +216,12 @@ int vector_test() stdvector->push_back(int(1)); if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; } - { //push_back with enough capacity + + { //test back() + const IntType test_this(1); + if(test_this != boostvector->back()) return 1; + } + { //pop_back with enough capacity boostvector->pop_back(); boostvector->pop_back(); stdvector->pop_back(); From 3948f040b99ee5e1250b9386b4d2652e4a3610ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 24 Feb 2013 13:16:40 +0000 Subject: [PATCH 78/93] Rolled back to standard construction in benchmark [SVN r83127] --- bench/bench_static_vector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bench/bench_static_vector.cpp b/bench/bench_static_vector.cpp index bbcaed1..7e87f06 100644 --- a/bench/bench_static_vector.cpp +++ b/bench/bench_static_vector.cpp @@ -34,7 +34,7 @@ static const std::size_t N = 1000; static const std::size_t N = 100; #endif -#define BENCH_SIMPLE_CONSTRUCTION +//#define BENCH_SIMPLE_CONSTRUCTION //#define BENCH_TRIVIAL_TYPE #ifdef BENCH_TRIVIAL_TYPE From 9b0a73fc32d363fff1905b74d2516837cdfb7ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 24 Feb 2013 20:34:15 +0000 Subject: [PATCH 79/93] Add experimental option to define "vector::iterator" as "pointer" [SVN r83140] --- include/boost/container/detail/flat_tree.hpp | 18 ++- include/boost/container/stable_vector.hpp | 3 +- include/boost/container/vector.hpp | 121 ++++++++++++----- proj/vc7ide/bench_static_vector.vcproj | 134 +++++++++++++++++++ test/map_test.hpp | 10 +- test/set_test.hpp | 14 +- test/vector_test.cpp | 4 + 7 files changed, 257 insertions(+), 47 deletions(-) create mode 100644 proj/vc7ide/bench_static_vector.vcproj diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp index 2af12d4..ac35981 100644 --- a/include/boost/container/detail/flat_tree.hpp +++ b/include/boost/container/detail/flat_tree.hpp @@ -33,6 +33,9 @@ #include #include #include +#ifdef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER +#include +#endif #include namespace boost { @@ -73,10 +76,19 @@ class flat_tree_value_compare template struct get_flat_tree_iterators { + #ifdef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER + typedef Pointer iterator; + typedef typename boost::intrusive:: + pointer_traits::element_type iterator_element_type; + typedef typename boost::intrusive:: + pointer_traits:: template + rebind_pointer::type const_iterator; + #else //BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER typedef typename container_detail:: vector_iterator iterator; typedef typename container_detail:: vector_const_iterator const_iterator; + #endif //BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; }; @@ -785,7 +797,7 @@ class flat_tree const value_compare &value_comp = this->m_data; commit_data.position = this->priv_lower_bound(b, e, KeyOfValue()(val)); return std::pair - ( *reinterpret_cast(&commit_data.position) + ( iterator(vector_iterator_get_ptr(commit_data.position)) , commit_data.position == e || value_comp(val, *commit_data.position)); } @@ -813,10 +825,10 @@ class flat_tree if(pos != this->cbegin() && !value_comp(val, pos[-1])){ if(value_comp(pos[-1], val)){ commit_data.position = pos; - return std::pair(*reinterpret_cast(&pos), true); + return std::pair(iterator(vector_iterator_get_ptr(pos)), true); } else{ - return std::pair(*reinterpret_cast(&pos), false); + return std::pair(iterator(vector_iterator_get_ptr(pos)), false); } } return this->priv_insert_unique_prepare(this->cbegin(), pos, val, commit_data); diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp index 189840b..40f9de7 100644 --- a/include/boost/container/stable_vector.hpp +++ b/include/boost/container/stable_vector.hpp @@ -333,7 +333,8 @@ struct index_traits static void readjust_end_node(index_type &index, node_base_type &end_node) { if(!index.empty()){ - node_base_ptr &end_node_idx_ref = *(--index_traits::get_fix_up_end(index)); + index_iterator end_node_it(index_traits::get_fix_up_end(index)); + node_base_ptr &end_node_idx_ref = *(--end_node_it); end_node_idx_ref = node_base_ptr_traits::pointer_to(end_node); end_node.up = node_base_ptr_ptr_traits::pointer_to(end_node_idx_ref); } diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp index 3137cec..092114d 100644 --- a/include/boost/container/vector.hpp +++ b/include/boost/container/vector.hpp @@ -55,8 +55,12 @@ namespace container { /// @cond +//#define BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER + namespace container_detail { +#ifndef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER + //! Const vector_iterator used to iterate through a vector. template class vector_const_iterator @@ -221,6 +225,57 @@ class vector_iterator { left.m_ptr -= off; return left; } }; +} //namespace container_detail { + +template +const Pointer &vector_iterator_get_ptr(const container_detail::vector_const_iterator &it) BOOST_CONTAINER_NOEXCEPT +{ return it.get_ptr(); } + +template +Pointer &get_ptr(container_detail::vector_const_iterator &it) BOOST_CONTAINER_NOEXCEPT +{ return it.get_ptr(); } + +namespace container_detail { + +#else //ifndef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER + +template< class MaybeConstPointer + , bool ElementTypeIsConst + = is_const< typename boost::intrusive::pointer_traits::element_type>::value > +struct vector_get_ptr_pointer_to_non_const +{ + typedef MaybeConstPointer const_pointer; + typedef boost::intrusive::pointer_traits pointer_traits_t; + typedef typename pointer_traits_t::element_type element_type; + typedef typename remove_const::type non_const_element_type; + typedef typename pointer_traits_t + ::template rebind_pointer::type return_type; + + static return_type get_ptr(const const_pointer &ptr) + { return boost::intrusive::pointer_traits::const_cast_from(ptr); } +}; + +template +struct vector_get_ptr_pointer_to_non_const +{ + typedef const Pointer & return_type; + static return_type get_ptr(const Pointer &ptr) + { return ptr; } +}; + +} //namespace container_detail { + +template +typename container_detail::vector_get_ptr_pointer_to_non_const::return_type + vector_iterator_get_ptr(const MaybeConstPointer &ptr) BOOST_CONTAINER_NOEXCEPT +{ + return container_detail::vector_get_ptr_pointer_to_non_const::get_ptr(ptr); +} + +namespace container_detail { + +#endif //#ifndef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER + template struct vector_value_traits { @@ -323,7 +378,6 @@ struct vector_alloc_holder void first_allocation_same_allocator_type(size_type cap) { this->first_allocation(cap); } - //Destructor ~vector_alloc_holder() BOOST_CONTAINER_NOEXCEPT { if(this->m_capacity){ @@ -359,9 +413,6 @@ struct vector_alloc_holder container_detail::do_swap(this->m_start, x.m_start); container_detail::do_swap(this->m_size, x.m_size); container_detail::do_swap(this->m_capacity, x.m_capacity); - //And now the allocator - container_detail::bool_ flag; - container_detail::swap_alloc(this->alloc(), x.alloc(), flag); } void move_from_empty(vector_alloc_holder &x) BOOST_CONTAINER_NOEXCEPT @@ -389,10 +440,10 @@ struct vector_alloc_holder } } - const pointer &start() const { return m_start; } - const size_type &capacity() const { return m_capacity; } - void start(const pointer &p) { m_start = p; } - void capacity(const size_type &c) { m_capacity = c; } + const pointer &start() const BOOST_CONTAINER_NOEXCEPT { return m_start; } + const size_type &capacity() const BOOST_CONTAINER_NOEXCEPT { return m_capacity; } + void start(const pointer &p) BOOST_CONTAINER_NOEXCEPT { m_start = p; } + void capacity(const size_type &c) BOOST_CONTAINER_NOEXCEPT { m_capacity = c; } }; //!This struct deallocates and allocated memory @@ -468,7 +519,7 @@ struct vector_alloc_holderpriv_swap_members_impl(x); } - void move_from_empty(vector_alloc_holder &x) BOOST_CONTAINER_NOEXCEPT + void move_from_empty(vector_alloc_holder &x) { //Containers with version 0 allocators can't be moved without move elements one by one throw_bad_alloc(); } @@ -503,8 +554,8 @@ struct vector_alloc_holder #endif class vector { + /// @cond typedef container_detail::integral_constant ::value > alloc_version; boost::container::container_detail::vector_alloc_holder m_holder; - /// @cond typedef container_detail::vector_alloc_holder base_t; typedef allocator_traits allocator_traits_type; template @@ -568,8 +619,13 @@ class vector typedef typename ::boost::container::allocator_traits::difference_type difference_type; typedef Allocator allocator_type; typedef Allocator stored_allocator_type; + #if defined BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + typedef BOOST_CONTAINER_IMPDEF(pointer) iterator; + typedef BOOST_CONTAINER_IMPDEF(const_pointer) const_iterator; + #else typedef BOOST_CONTAINER_IMPDEF(container_detail::vector_iterator) iterator; typedef BOOST_CONTAINER_IMPDEF(container_detail::vector_const_iterator) const_iterator; + #endif typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator) reverse_iterator; typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator) const_reverse_iterator; @@ -844,7 +900,7 @@ class vector if (first == last){ //There are no more elements in the sequence, erase remaining T* const end_pos = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size; - size_type n = static_cast(end_pos - container_detail::to_raw_pointer(cur.get_ptr())); + size_type n = static_cast(end_pos - container_detail::to_raw_pointer(vector_iterator_get_ptr(cur))); this->priv_destroy_last_n(n); } else{ @@ -1243,7 +1299,7 @@ class vector else{ typedef container_detail::insert_emplace_proxy type; this->priv_forward_range_insert_no_capacity - (this->cend().get_ptr(), 1, type(this->m_holder.alloc(), ::boost::forward(args)...), alloc_version()); + (vector_iterator_get_ptr(this->cend()), 1, type(this->m_holder.alloc(), ::boost::forward(args)...), alloc_version()); } } @@ -1262,7 +1318,7 @@ class vector { //Just call more general insert(pos, size, value) and return iterator typedef container_detail::insert_emplace_proxy type; - return this->priv_forward_range_insert( position.get_ptr(), 1, type(this->m_holder.alloc() + return this->priv_forward_range_insert( vector_iterator_get_ptr(position), 1, type(this->m_holder.alloc() , ::boost::forward(args)...), alloc_version()); } @@ -1284,7 +1340,7 @@ class vector proxy \ (this->m_holder.alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ this->priv_forward_range_insert_no_capacity \ - (this->cend().get_ptr(), 1, proxy, alloc_version()); \ + (vector_iterator_get_ptr(this->cend()), 1, proxy, alloc_version()); \ } \ } \ \ @@ -1296,7 +1352,7 @@ class vector proxy \ (this->m_holder.alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ return this->priv_forward_range_insert \ - (container_detail::to_raw_pointer(pos.get_ptr()), 1, proxy, alloc_version()); \ + (container_detail::to_raw_pointer(vector_iterator_get_ptr(pos)), 1, proxy, alloc_version()); \ } \ //! #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) @@ -1361,7 +1417,7 @@ class vector iterator insert(const_iterator p, size_type n, const T& x) { container_detail::insert_n_copies_proxy proxy(this->m_holder.alloc(), x); - return this->priv_forward_range_insert(p.get_ptr(), n, proxy, alloc_version()); + return this->priv_forward_range_insert(vector_iterator_get_ptr(p), n, proxy, alloc_version()); } //! Requires: p must be a valid iterator of *this. @@ -1385,7 +1441,7 @@ class vector ) { const size_type n_pos = pos - this->cbegin(); - iterator it(pos.get_ptr()); + iterator it(vector_iterator_get_ptr(pos)); for(;first != last; ++first){ it = this->emplace(it, *first); ++it; @@ -1403,7 +1459,7 @@ class vector ) { container_detail::insert_range_proxy proxy(this->m_holder.alloc(), first); - return this->priv_forward_range_insert(pos.get_ptr(), std::distance(first, last), proxy, alloc_version()); + return this->priv_forward_range_insert(vector_iterator_get_ptr(pos), std::distance(first, last), proxy, alloc_version()); } #endif @@ -1427,12 +1483,12 @@ class vector //! last element. Constant if pos is the last element. iterator erase(const_iterator position) { - T *const pos = container_detail::to_raw_pointer(position.get_ptr()); + T *const pos = container_detail::to_raw_pointer(vector_iterator_get_ptr(position)); T *const beg = container_detail::to_raw_pointer(this->m_holder.start()); //Move elements forward and destroy last this->priv_destroy(::boost::move(pos + 1, beg + this->m_holder.m_size, pos)); --this->m_holder.m_size; - return iterator(position.get_ptr()); + return iterator(vector_iterator_get_ptr(position)); } //! Effects: Erases the elements pointed by [first, last). @@ -1446,15 +1502,15 @@ class vector if (first != last){ T* const end_pos = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size; T* const ptr = container_detail::to_raw_pointer(boost::move - (container_detail::to_raw_pointer(last.get_ptr()) + (container_detail::to_raw_pointer(vector_iterator_get_ptr(last)) ,end_pos - ,container_detail::to_raw_pointer(first.get_ptr()) + ,container_detail::to_raw_pointer(vector_iterator_get_ptr(first)) )); const size_type destroyed = (end_pos - ptr); destroy_alloc_n(this->get_stored_allocator(), ptr, destroyed); this->m_holder.m_size -= destroyed; } - return iterator(first.get_ptr()); + return iterator(vector_iterator_get_ptr(first)); } //! Effects: Swaps the contents of *this and x. @@ -1466,6 +1522,9 @@ class vector { //Just swap internals in case of !allocator_v0. Otherwise, deep swap this->m_holder.swap(x.m_holder); + //And now the allocator + container_detail::bool_ flag; + container_detail::swap_alloc(this->m_holder.alloc(), x.m_holder.alloc(), flag); } #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED @@ -1738,7 +1797,7 @@ class vector iterator priv_insert(const const_iterator &p, BOOST_FWD_REF(U) x) { return this->priv_forward_range_insert - ( p.get_ptr(), 1, container_detail::get_insert_value_proxy(this->m_holder.alloc() + ( vector_iterator_get_ptr(p), 1, container_detail::get_insert_value_proxy(this->m_holder.alloc() , ::boost::forward(x)), alloc_version()); } @@ -1754,7 +1813,7 @@ class vector } else{ container_detail::insert_copy_proxy proxy(this->m_holder.alloc(), x); - this->priv_forward_range_insert_no_capacity(this->cend().get_ptr(), 1, proxy, alloc_version()); + this->priv_forward_range_insert_no_capacity(vector_iterator_get_ptr(this->cend()), 1, proxy, alloc_version()); } } @@ -1770,7 +1829,7 @@ class vector } else{ container_detail::insert_move_proxy proxy(this->m_holder.alloc(), x); - this->priv_forward_range_insert_no_capacity(this->cend().get_ptr(), 1, proxy, alloc_version()); + this->priv_forward_range_insert_no_capacity(vector_iterator_get_ptr(this->cend()), 1, proxy, alloc_version()); } } @@ -1907,7 +1966,7 @@ class vector iterator priv_forward_range_insert_at_end (const size_type n, const InsertionProxy insert_range_proxy, allocator_v1) { - return this->priv_forward_range_insert(this->cend().get_ptr(), n, insert_range_proxy, allocator_v1()); + return this->priv_forward_range_insert(vector_iterator_get_ptr(this->cend()), n, insert_range_proxy, allocator_v1()); } template @@ -1983,7 +2042,7 @@ class vector iterator priv_forward_range_insert_at_end (const size_type n, const InsertionProxy insert_range_proxy, allocator_v2) { - return this->priv_forward_range_insert(this->cend().get_ptr(), n, insert_range_proxy, allocator_v2()); + return this->priv_forward_range_insert(vector_iterator_get_ptr(this->cend()), n, insert_range_proxy, allocator_v2()); } //Absolutely experimental. This function might change, disappear or simply crash! diff --git a/proj/vc7ide/bench_static_vector.vcproj b/proj/vc7ide/bench_static_vector.vcproj new file mode 100644 index 0000000..a518d54 --- /dev/null +++ b/proj/vc7ide/bench_static_vector.vcproj @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/map_test.hpp b/test/map_test.hpp index 2357f57..523eb37 100644 --- a/test/map_test.hpp +++ b/test/map_test.hpp @@ -179,14 +179,14 @@ int map_test () if(!CheckEqualPairContainers(boostmap, stdmap)) return 1; if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; - typename MyBoostMap::iterator it; + typename MyBoostMap::iterator it = boostmap->begin(); typename MyBoostMap::const_iterator cit = it; (void)cit; - boostmap->erase(boostmap->begin()++); - stdmap->erase(stdmap->begin()++); - boostmultimap->erase(boostmultimap->begin()++); - stdmultimap->erase(stdmultimap->begin()++); + boostmap->erase(boostmap->begin()); + stdmap->erase(stdmap->begin()); + boostmultimap->erase(boostmultimap->begin()); + stdmultimap->erase(stdmultimap->begin()); if(!CheckEqualPairContainers(boostmap, stdmap)) return 1; if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; diff --git a/test/set_test.hpp b/test/set_test.hpp index 7a2b844..a0a56e8 100644 --- a/test/set_test.hpp +++ b/test/set_test.hpp @@ -143,20 +143,20 @@ int set_test () return 1; } - typename MyBoostSet::iterator it; + typename MyBoostSet::iterator it = boostset->begin(); typename MyBoostSet::const_iterator cit = it; (void)cit; - boostset->erase(boostset->begin()++); - stdset->erase(stdset->begin()++); - boostmultiset->erase(boostmultiset->begin()++); - stdmultiset->erase(stdmultiset->begin()++); + boostset->erase(boostset->begin()); + stdset->erase(stdset->begin()); + boostmultiset->erase(boostmultiset->begin()); + stdmultiset->erase(stdmultiset->begin()); if(!CheckEqualContainers(boostset, stdset)){ - std::cout << "Error in boostset->erase(boostset->begin()++)" << std::endl; + std::cout << "Error in boostset->erase(boostset->begin())" << std::endl; return 1; } if(!CheckEqualContainers(boostmultiset, stdmultiset)){ - std::cout << "Error in boostmultiset->erase(boostmultiset->begin()++)" << std::endl; + std::cout << "Error in boostmultiset->erase(boostmultiset->begin())" << std::endl; return 1; } diff --git a/test/vector_test.cpp b/test/vector_test.cpp index 9833b0d..5ea8a05 100644 --- a/test/vector_test.cpp +++ b/test/vector_test.cpp @@ -41,9 +41,13 @@ template class boost::container::vector; template class vector_iterator; +#endif //BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER + } }} From 6acbbb6f9b5d613bff2034dad4303d31ec334c59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 3 Mar 2013 12:26:48 +0000 Subject: [PATCH 80/93] Vector performance improvements: dispatching to memcpy when possible. [SVN r83271] --- bench/bench_static_vector.cpp | 9 +- doc/container.qbk | 1 + include/boost/container/allocator_traits.hpp | 3 + include/boost/container/deque.hpp | 10 +- .../container/detail/advanced_insert_int.hpp | 5 +- include/boost/container/detail/flat_tree.hpp | 2 +- .../boost/container/detail/memory_util.hpp | 6 + include/boost/container/detail/utilities.hpp | 741 +++++++++++++----- include/boost/container/scoped_allocator.hpp | 6 +- include/boost/container/stable_vector.hpp | 2 +- include/boost/container/string.hpp | 4 +- include/boost/container/vector.hpp | 247 +++--- proj/vc7ide/container.vcproj | 174 ++-- test/Jamfile.v2 | 2 +- test/dummy_test_allocator.hpp | 19 +- test/expand_bwd_test_allocator.hpp | 6 +- test/heap_allocator_v1.hpp | 2 +- test/vector_test.hpp | 6 + 18 files changed, 781 insertions(+), 464 deletions(-) diff --git a/bench/bench_static_vector.cpp b/bench/bench_static_vector.cpp index 7e87f06..f36e145 100644 --- a/bench/bench_static_vector.cpp +++ b/bench/bench_static_vector.cpp @@ -92,7 +92,6 @@ cpu_times time_it() rotateTime.resume(); std::rotate(v.begin(), v.begin() + v.size()/2, v.end()); rotateTime.stop(); - destructionTime.resume(); delete &v; } @@ -120,16 +119,16 @@ int main() try { std::cout << "N = " << N << "\n\n"; - std::cout << "varray benchmark:\n"; + std::cout << "varray benchmark:" << std::endl; cpu_times time_varray = time_it,N > >(); - std::cout << "boost::container::static_vector benchmark\n"; + std::cout << "boost::container::static_vector benchmark" << std::endl; cpu_times time_boost_static_vector = time_it,N > >(); - std::cout << "boost::container::vector benchmark\n"; + std::cout << "boost::container::vector benchmark" << std::endl; cpu_times time_boost_vector = time_it > >(); - std::cout << "std::vector benchmark\n"; + std::cout << "std::vector benchmark" << std::endl; cpu_times time_standard_vector = time_it > >(); std::cout << "varray/boost::container::vector total time comparison:"; diff --git a/doc/container.qbk b/doc/container.qbk index 152ae74..e38288b 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -661,6 +661,7 @@ use [*Boost.Container]? There are several reasons for that: [section:release_notes_boost_1_54_00 Boost 1.54 Release] +* Speed improvements in `vector` constructors/copy/move/swap, dispatching to memcpy when possible. * Support for `BOOST_NO_EXCEPTIONS` [@https://svn.boost.org/trac/boost/ticket/7227 #7227]. * Fixed bugs [@https://svn.boost.org/trac/boost/ticket/7921 #7921], [@https://svn.boost.org/trac/boost/ticket/7969 #7969], diff --git a/include/boost/container/allocator_traits.hpp b/include/boost/container/allocator_traits.hpp index 3e9ce0f..964025f 100644 --- a/include/boost/container/allocator_traits.hpp +++ b/include/boost/container/allocator_traits.hpp @@ -32,7 +32,10 @@ #include //numeric_limits<>::max() #include //placement new #include //std::allocator + +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #include +#endif ///@cond diff --git a/include/boost/container/deque.hpp b/include/boost/container/deque.hpp index 0962f0b..d8dc2a4 100644 --- a/include/boost/container/deque.hpp +++ b/include/boost/container/deque.hpp @@ -830,11 +830,11 @@ class deque : protected deque_base if (len > size()) { FwdIt mid = first; std::advance(mid, this->size()); - boost::copy_or_move(first, mid, begin()); + boost::container::copy(first, mid, begin()); this->insert(this->cend(), mid, last); } else{ - this->erase(boost::copy_or_move(first, last, this->begin()), cend()); + this->erase(boost::container::copy(first, last, this->begin()), cend()); } } #endif @@ -1840,12 +1840,10 @@ class deque : protected deque_base ++cur_node) { FwdIt mid = first; std::advance(mid, this->s_buffer_size()); - ::boost::container::uninitialized_copy_or_move_alloc - (this->alloc(), first, mid, *cur_node); + ::boost::container::uninitialized_copy_alloc(this->alloc(), first, mid, *cur_node); first = mid; } - ::boost::container::uninitialized_copy_or_move_alloc - (this->alloc(), first, last, this->members_.m_finish.m_first); + ::boost::container::uninitialized_copy_alloc(this->alloc(), first, last, this->members_.m_finish.m_first); } BOOST_CATCH(...){ this->priv_destroy_range(this->members_.m_start, iterator(*cur_node, cur_node)); diff --git a/include/boost/container/detail/advanced_insert_int.hpp b/include/boost/container/detail/advanced_insert_int.hpp index 2abf805..86e2628 100644 --- a/include/boost/container/detail/advanced_insert_int.hpp +++ b/include/boost/container/detail/advanced_insert_int.hpp @@ -65,13 +65,12 @@ struct insert_range_proxy void uninitialized_copy_n_and_update(Iterator p, size_type n) { - this->first_ = ::boost::container::uninitialized_copy_or_move_alloc_n_source - (this->a_, this->first_, n, p); + this->first_ = ::boost::container::uninitialized_copy_alloc_n_source(this->a_, this->first_, n, p); } void copy_n_and_update(Iterator p, size_type n) { - this->first_ = ::boost::container::copy_or_move_n_source(this->first_, n, p); + this->first_ = ::boost::container::copy_n_source(this->first_, n, p); } A &a_; diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp index ac35981..90f0352 100644 --- a/include/boost/container/detail/flat_tree.hpp +++ b/include/boost/container/detail/flat_tree.hpp @@ -157,7 +157,7 @@ class flat_tree void swap(Data &d) { value_compare& mycomp = *this, & othercomp = d; - container_detail::do_swap(mycomp, othercomp); + boost::container::swap_dispatch(mycomp, othercomp); this->m_vect.swap(d.m_vect); } diff --git a/include/boost/container/detail/memory_util.hpp b/include/boost/container/detail/memory_util.hpp index c00172c..ac9a899 100644 --- a/include/boost/container/detail/memory_util.hpp +++ b/include/boost/container/detail/memory_util.hpp @@ -51,6 +51,12 @@ #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS+1, )) #include BOOST_PP_ITERATE() +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME swap +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 1, )) +#include BOOST_PP_ITERATE() + namespace boost { namespace container { namespace container_detail { diff --git a/include/boost/container/detail/utilities.hpp b/include/boost/container/detail/utilities.hpp index 02141a4..f56c3bf 100644 --- a/include/boost/container/detail/utilities.hpp +++ b/include/boost/container/detail/utilities.hpp @@ -19,17 +19,74 @@ #include #include #include +#include #include #include #include #include #include #include +#include +#include +#include +#include #include #include +#include //std::distance namespace boost { namespace container { + +////////////////////////////////////////////////////////////////////////////// +// +// swap +// +////////////////////////////////////////////////////////////////////////////// + +namespace container_swap { + +template::value > +struct has_member_swap +{ + static const bool value = boost::container::container_detail:: + has_member_function_callable_with_swap::value; +}; + +template +struct has_member_swap +{ + static const bool value = false; +}; + +} //namespace container_swap { + +template inline +typename container_detail::enable_if_c + ::value, void>::type +swap_dispatch(T &left, T &right) //swap using member swap +{ + left.swap(right); // may throw +} + +template inline +typename container_detail::enable_if_c + ::value && boost::has_move_emulation_enabled::value, void>::type + swap_dispatch(T &left, T &right) +{ + T temp(boost::move(left)); // may throw + left = boost::move(right); // may throw + right = boost::move(temp); // may throw +} + +template inline +typename container_detail::enable_if_c + ::value && !boost::has_move_emulation_enabled::value, void>::type + swap_dispatch(T &left, T &right) +{ + using std::swap; + swap(left, right); // may throw +} + namespace container_detail { template @@ -79,13 +136,6 @@ inline typename Pointer::element_type* to_raw_pointer(const Pointer &p) { return boost::container::container_detail::to_raw_pointer(p.operator->()); } -//!To avoid ADL problems with swap -template -inline void do_swap(T& x, T& y) -{ - using std::swap; - swap(x, y); -} template inline void swap_alloc(AllocatorType &, AllocatorType &, container_detail::false_type) @@ -94,7 +144,7 @@ inline void swap_alloc(AllocatorType &, AllocatorType &, container_detail::false template inline void swap_alloc(AllocatorType &l, AllocatorType &r, container_detail::true_type) -{ container_detail::do_swap(l, r); } +{ boost::container::swap_dispatch(l, r); } template inline void assign_alloc(AllocatorType &, const AllocatorType &, container_detail::false_type) @@ -127,14 +177,121 @@ struct ct_rounded_size enum { value = ((OrigSize-1)/RoundTo+1)*RoundTo }; }; +template +struct are_elements_contiguous +{ + static const bool value = false; +}; + +template +struct are_elements_contiguous +{ + static const bool value = true; +}; + +template +struct are_contiguous_and_same +{ + static const bool is_same_io = + is_same< typename remove_const< typename ::std::iterator_traits::value_type >::type + , typename ::std::iterator_traits::value_type + >::value; + static const bool value = is_same_io && + are_elements_contiguous::value && + are_elements_contiguous::value; +}; + +template +struct is_memcpy_copy_assignable +{ + static const bool value = are_contiguous_and_same::value && + boost::has_trivial_assign< typename ::std::iterator_traits::value_type >::value; +}; + +template +struct is_memcpy_copy_constructible +{ + static const bool value = are_contiguous_and_same::value && + boost::has_trivial_copy< typename ::std::iterator_traits::value_type >::value; +}; + +template +struct enable_if_memcpy_copy_constructible + : public enable_if_c::value, R> +{}; + +template +struct disable_if_memcpy_copy_constructible + : public enable_if_c::value, R> +{}; + +template +struct enable_if_memcpy_copy_assignable + : public enable_if_c::value, R> +{}; + +template +struct disable_if_memcpy_copy_assignable + : public enable_if_c::value, R> +{}; + +template + // F models ForwardIterator +inline F memcpy(I f, I l, F r) BOOST_CONTAINER_NOEXCEPT +{ + typedef typename std::iterator_traits::value_type value_type; + typename std::iterator_traits::difference_type n = std::distance(f, l); + ::memcpy(container_detail::addressof(*r), container_detail::addressof(*f), sizeof(value_type)*n); + std::advance(r, n); + return r; +} + +template + // F models ForwardIterator +F memcpy_n(I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT +{ + typedef typename std::iterator_traits::value_type value_type; + ::memcpy(container_detail::addressof(*r), container_detail::addressof(*f), sizeof(value_type)*n); + std::advance(r, n); + return r; +} + +template + // F models ForwardIterator +I memcpy_n_source(I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT +{ + typedef typename std::iterator_traits::value_type value_type; + ::memcpy(container_detail::addressof(*r), container_detail::addressof(*f), sizeof(value_type)*n); + std::advance(f, n); + return f; +} + +template + // F models ForwardIterator +I memcpy_n_source_dest(I f, typename std::iterator_traits::difference_type n, F &r) BOOST_CONTAINER_NOEXCEPT +{ + typedef typename std::iterator_traits::value_type value_type; + ::memcpy(container_detail::addressof(*r), container_detail::addressof(*f), sizeof(value_type)*n); + std::advance(f, n); + std::advance(r, n); + return f; +} + + } //namespace container_detail { + ////////////////////////////////////////////////////////////////////////////// // // uninitialized_move_alloc // ////////////////////////////////////////////////////////////////////////////// + //! Effects: //! \code //! for (; f != l; ++r, ++f) @@ -146,7 +303,8 @@ template // F models ForwardIterator -F uninitialized_move_alloc(A &a, I f, I l, F r) +inline typename container_detail::disable_if_memcpy_copy_constructible::type + uninitialized_move_alloc(A &a, I f, I l, F r) { F back = r; BOOST_TRY{ @@ -165,6 +323,14 @@ F uninitialized_move_alloc(A &a, I f, I l, F r) return r; } +template + // F models ForwardIterator +inline typename container_detail::enable_if_memcpy_copy_constructible::type + uninitialized_move_alloc(A &, I f, I l, F r) BOOST_CONTAINER_NOEXCEPT +{ return container_detail::memcpy(f, l, r); } + ////////////////////////////////////////////////////////////////////////////// // // uninitialized_move_alloc_n @@ -182,7 +348,8 @@ template // F models ForwardIterator -F uninitialized_move_alloc_n(A &a, I f, typename std::iterator_traits::difference_type n, F r) +inline typename container_detail::disable_if_memcpy_copy_constructible::type + uninitialized_move_alloc_n(A &a, I f, typename std::iterator_traits::difference_type n, F r) { F back = r; BOOST_TRY{ @@ -201,6 +368,14 @@ F uninitialized_move_alloc_n(A &a, I f, typename std::iterator_traits::differ return r; } +template + // F models ForwardIterator +inline typename container_detail::enable_if_memcpy_copy_constructible::type + uninitialized_move_alloc_n(A &, I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT +{ return container_detail::memcpy_n(f, n, r); } + ////////////////////////////////////////////////////////////////////////////// // // uninitialized_move_alloc_n_source @@ -218,7 +393,8 @@ template // F models ForwardIterator -I uninitialized_move_alloc_n_source(A &a, I f, typename std::iterator_traits::difference_type n, F r) +inline typename container_detail::disable_if_memcpy_copy_constructible::type + uninitialized_move_alloc_n_source(A &a, I f, typename std::iterator_traits::difference_type n, F r) { F back = r; BOOST_TRY{ @@ -237,6 +413,14 @@ I uninitialized_move_alloc_n_source(A &a, I f, typename std::iterator_traits: return f; } +template + // F models ForwardIterator +inline typename container_detail::enable_if_memcpy_copy_constructible::type + uninitialized_move_alloc_n_source(A &, I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT +{ return container_detail::memcpy_n_source(f, n, r); } + ////////////////////////////////////////////////////////////////////////////// // // uninitialized_copy_alloc @@ -254,7 +438,8 @@ template // F models ForwardIterator -F uninitialized_copy_alloc(A &a, I f, I l, F r) +inline typename container_detail::disable_if_memcpy_copy_constructible::type + uninitialized_copy_alloc(A &a, I f, I l, F r) { F back = r; BOOST_TRY{ @@ -273,6 +458,14 @@ F uninitialized_copy_alloc(A &a, I f, I l, F r) return r; } +template + // F models ForwardIterator +inline typename container_detail::enable_if_memcpy_copy_constructible::type + uninitialized_copy_alloc(A &, I f, I l, F r) BOOST_CONTAINER_NOEXCEPT +{ return container_detail::memcpy(f, l, r); } + ////////////////////////////////////////////////////////////////////////////// // // uninitialized_copy_alloc_n @@ -290,7 +483,8 @@ template // F models ForwardIterator -F uninitialized_copy_alloc_n(A &a, I f, typename std::iterator_traits::difference_type n, F r) +inline typename container_detail::disable_if_memcpy_copy_constructible::type + uninitialized_copy_alloc_n(A &a, I f, typename std::iterator_traits::difference_type n, F r) { F back = r; BOOST_TRY{ @@ -309,6 +503,14 @@ F uninitialized_copy_alloc_n(A &a, I f, typename std::iterator_traits::differ return r; } +template + // F models ForwardIterator +inline typename container_detail::enable_if_memcpy_copy_constructible::type + uninitialized_copy_alloc_n(A &, I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT +{ return container_detail::memcpy_n(f, n, r); } + ////////////////////////////////////////////////////////////////////////////// // // uninitialized_copy_alloc_n_source @@ -326,7 +528,8 @@ template // F models ForwardIterator -I uninitialized_copy_alloc_n_source(A &a, I f, typename std::iterator_traits::difference_type n, F r) +inline typename container_detail::disable_if_memcpy_copy_constructible::type + uninitialized_copy_alloc_n_source(A &a, I f, typename std::iterator_traits::difference_type n, F r) { F back = r; BOOST_TRY{ @@ -345,131 +548,13 @@ I uninitialized_copy_alloc_n_source(A &a, I f, typename std::iterator_traits: return f; } -////////////////////////////////////////////////////////////////////////////// -// -// uninitialized_copy_alloc -// -////////////////////////////////////////////////////////////////////////////// - -//! Effects: -//! \code -//! for (; f != l; ++r, ++f) -//! allocator_traits::construct(a, &*r, *f); -//! \endcode -//! -//! Returns: r template -void uninitialized_fill_alloc(A &a, F f, F l, const T &t) -{ - F back = f; - BOOST_TRY{ - while (f != l) { - allocator_traits::construct(a, container_detail::to_raw_pointer(&*f), t); - ++f; - } - } - BOOST_CATCH(...){ - for (; back != l; ++back){ - allocator_traits::destroy(a, container_detail::to_raw_pointer(&*back)); - } - BOOST_RETHROW; - } - BOOST_CATCH_END -} - -////////////////////////////////////////////////////////////////////////////// -// -// uninitialized_copy_or_move_alloc -// -////////////////////////////////////////////////////////////////////////////// - -template - // F models ForwardIterator -F uninitialized_copy_or_move_alloc - (A &a, I f, I l, F r - ,typename boost::container::container_detail::enable_if - < boost::move_detail::is_move_iterator >::type* = 0) -{ - return ::boost::container::uninitialized_move_alloc(a, f, l, r); -} - -template - // F models ForwardIterator -F uninitialized_copy_or_move_alloc - (A &a, I f, I l, F r - ,typename boost::container::container_detail::disable_if - < boost::move_detail::is_move_iterator >::type* = 0) -{ - return ::boost::container::uninitialized_copy_alloc(a, f, l, r); -} - -////////////////////////////////////////////////////////////////////////////// -// -// uninitialized_copy_or_move_alloc_n -// -////////////////////////////////////////////////////////////////////////////// - -template - // F models ForwardIterator -F uninitialized_copy_or_move_alloc_n - (A &a, I f, typename std::iterator_traits::difference_type n, F r - ,typename boost::container::container_detail::enable_if - < boost::move_detail::is_move_iterator >::type* = 0) -{ - return ::boost::container::uninitialized_move_alloc_n(a, f, n, r); -} - -template - // F models ForwardIterator -F uninitialized_copy_or_move_alloc_n - (A &a, I f, typename std::iterator_traits::difference_type n, F r - ,typename boost::container::container_detail::disable_if - < boost::move_detail::is_move_iterator >::type* = 0) -{ - return ::boost::container::uninitialized_copy_alloc_n(a, f, n, r); -} - - -////////////////////////////////////////////////////////////////////////////// -// -// uninitialized_copy_or_move_alloc_n_source -// -////////////////////////////////////////////////////////////////////////////// - -template - // F models ForwardIterator -I uninitialized_copy_or_move_alloc_n_source - (A &a, I f, typename std::iterator_traits::difference_type n, F r - ,typename boost::container::container_detail::enable_if - < boost::move_detail::is_move_iterator >::type* = 0) -{ - return ::boost::container::uninitialized_move_alloc_n_source(a, f, n, r); -} - -template - // F models ForwardIterator -I uninitialized_copy_or_move_alloc_n_source - (A &a, I f, typename std::iterator_traits::difference_type n, F r - ,typename boost::container::container_detail::disable_if - < boost::move_detail::is_move_iterator >::type* = 0) -{ - return ::boost::container::uninitialized_copy_alloc_n_source(a, f, n, r); -} + typename I, // I models InputIterator + typename F> // F models ForwardIterator +inline typename container_detail::enable_if_memcpy_copy_constructible::type + uninitialized_copy_alloc_n_source(A &, I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT +{ return container_detail::memcpy_n_source(f, n, r); } ////////////////////////////////////////////////////////////////////////////// // @@ -487,7 +572,7 @@ I uninitialized_copy_or_move_alloc_n_source template // F models ForwardIterator -F uninitialized_default_alloc_n(A &a, typename allocator_traits::difference_type n, F r) +inline F uninitialized_default_alloc_n(A &a, typename allocator_traits::difference_type n, F r) { F back = r; BOOST_TRY{ @@ -506,6 +591,41 @@ F uninitialized_default_alloc_n(A &a, typename allocator_traits::difference_t return r; } +////////////////////////////////////////////////////////////////////////////// +// +// uninitialized_fill_alloc +// +////////////////////////////////////////////////////////////////////////////// + +//! Effects: +//! \code +//! for (; f != l; ++r, ++f) +//! allocator_traits::construct(a, &*r, *f); +//! \endcode +//! +//! Returns: r +template + +inline void uninitialized_fill_alloc(A &a, F f, F l, const T &t) +{ + F back = f; + BOOST_TRY{ + while (f != l) { + allocator_traits::construct(a, container_detail::to_raw_pointer(&*f), t); + ++f; + } + } + BOOST_CATCH(...){ + for (; back != l; ++back){ + allocator_traits::destroy(a, container_detail::to_raw_pointer(&*back)); + } + BOOST_RETHROW; + } + BOOST_CATCH_END +} + ////////////////////////////////////////////////////////////////////////////// // @@ -524,7 +644,7 @@ template // F models ForwardIterator -F uninitialized_fill_alloc_n(A &a, const T &v, typename allocator_traits::difference_type n, F r) +inline F uninitialized_fill_alloc_n(A &a, const T &v, typename allocator_traits::difference_type n, F r) { F back = r; BOOST_TRY{ @@ -545,30 +665,15 @@ F uninitialized_fill_alloc_n(A &a, const T &v, typename allocator_traits::dif ////////////////////////////////////////////////////////////////////////////// // -// copy_or_move +// copy // ////////////////////////////////////////////////////////////////////////////// template // F models ForwardIterator -inline F copy_or_move(I f, I l, F r - ,typename boost::container::container_detail::enable_if - < boost::move_detail::is_move_iterator >::type* = 0) -{ - while (f != l) { - *r = ::boost::move(*f); - ++f; ++r; - } - return r; -} - -template - // F models ForwardIterator -inline F copy_or_move(I f, I l, F r - ,typename boost::container::container_detail::disable_if - < boost::move_detail::is_move_iterator >::type* = 0) +typename F> // F models ForwardIterator +inline typename container_detail::disable_if_memcpy_copy_assignable::type + copy(I f, I l, F r) { while (f != l) { *r = *f; @@ -577,32 +682,24 @@ inline F copy_or_move(I f, I l, F r return r; } +template + // F models ForwardIterator +inline typename container_detail::enable_if_memcpy_copy_assignable::type + copy(I f, I l, F r) BOOST_CONTAINER_NOEXCEPT +{ return container_detail::memcpy(f, l, r); } + ////////////////////////////////////////////////////////////////////////////// // -// copy_or_move_n +// copy_n // ////////////////////////////////////////////////////////////////////////////// template // F models ForwardIterator -inline F copy_or_move_n(I f, typename std::iterator_traits::difference_type n, F r - ,typename boost::container::container_detail::enable_if - < boost::move_detail::is_move_iterator >::type* = 0) -{ - while (n--) { - *r = ::boost::move(*f); - ++f; ++r; - } - return r; -} - -template - // F models ForwardIterator -inline F copy_or_move_n(I f, typename std::iterator_traits::difference_type n, F r - ,typename boost::container::container_detail::disable_if - < boost::move_detail::is_move_iterator >::type* = 0) +inline typename container_detail::disable_if_memcpy_copy_assignable::type + copy_n(I f, typename std::iterator_traits::difference_type n, F r) { while (n--) { *r = *f; @@ -611,32 +708,24 @@ inline F copy_or_move_n(I f, typename std::iterator_traits::difference_type n return r; } +template + // F models ForwardIterator +inline typename container_detail::enable_if_memcpy_copy_assignable::type + copy_n(I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT +{ return container_detail::memcpy_n(f, n, r); } + ////////////////////////////////////////////////////////////////////////////// // -// copy_or_move_n_source +// copy_n_source // ////////////////////////////////////////////////////////////////////////////// template // F models ForwardIterator -inline I copy_or_move_n_source(I f, typename std::iterator_traits::difference_type n, F r - ,typename boost::container::container_detail::enable_if - < boost::move_detail::is_move_iterator >::type* = 0) -{ - while (n--) { - *r = ::boost::move(*f); - ++f; ++r; - } - return f; -} - -template - // F models ForwardIterator -inline I copy_or_move_n_source(I f, typename std::iterator_traits::difference_type n, F r - ,typename boost::container::container_detail::disable_if - < boost::move_detail::is_move_iterator >::type* = 0) +inline typename container_detail::disable_if_memcpy_copy_assignable::type + copy_n_source(I f, typename std::iterator_traits::difference_type n, F r) { while (n--) { *r = *f; @@ -645,6 +734,39 @@ inline I copy_or_move_n_source(I f, typename std::iterator_traits::difference return f; } +template + // F models ForwardIterator +inline typename container_detail::enable_if_memcpy_copy_assignable::type + copy_n_source(I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT +{ return container_detail::memcpy_n_source(f, n, r); } + +////////////////////////////////////////////////////////////////////////////// +// +// copy_n_source_dest +// +////////////////////////////////////////////////////////////////////////////// + +template + // F models ForwardIterator +inline typename container_detail::disable_if_memcpy_copy_assignable::type + copy_n_source_dest(I f, typename std::iterator_traits::difference_type n, F &r) +{ + while (n--) { + *r = *f; + ++f; ++r; + } + return f; +} + +template + // F models ForwardIterator +inline typename container_detail::enable_if_memcpy_copy_assignable::type + copy_n_source_dest(I f, typename std::iterator_traits::difference_type n, F &r) BOOST_CONTAINER_NOEXCEPT +{ return container_detail::memcpy_n_source_dest(f, n, r); } + ////////////////////////////////////////////////////////////////////////////// // // move @@ -654,7 +776,8 @@ inline I copy_or_move_n_source(I f, typename std::iterator_traits::difference template // F models ForwardIterator -inline F move(I f, I l, F r) +inline typename container_detail::disable_if_memcpy_copy_assignable::type + move(I f, I l, F r) { while (f != l) { *r = ::boost::move(*f); @@ -663,6 +786,12 @@ inline F move(I f, I l, F r) return r; } +template + // F models ForwardIterator +inline typename container_detail::enable_if_memcpy_copy_assignable::type + move(I f, I l, F r) BOOST_CONTAINER_NOEXCEPT +{ return container_detail::memcpy(f, l, r); } ////////////////////////////////////////////////////////////////////////////// // @@ -673,7 +802,8 @@ inline F move(I f, I l, F r) template // F models ForwardIterator -inline F move_n(I f, typename std::iterator_traits::difference_type n, F r) +inline typename container_detail::disable_if_memcpy_copy_assignable::type + move_n(I f, typename std::iterator_traits::difference_type n, F r) { while (n--) { *r = ::boost::move(*f); @@ -682,6 +812,12 @@ inline F move_n(I f, typename std::iterator_traits::difference_type n, F r) return r; } +template + // F models ForwardIterator +inline typename container_detail::enable_if_memcpy_copy_assignable::type + move_n(I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT +{ return container_detail::memcpy_n(f, n, r); } ////////////////////////////////////////////////////////////////////////////// // @@ -690,9 +826,10 @@ inline F move_n(I f, typename std::iterator_traits::difference_type n, F r) ////////////////////////////////////////////////////////////////////////////// template - // F models ForwardIterator -inline I move_n_source(I f, typename std::iterator_traits::difference_type n, F r) + // F models ForwardIterator +inline typename container_detail::disable_if_memcpy_copy_assignable::type + move_n_source(I f, typename std::iterator_traits::difference_type n, F r) { while (n--) { *r = ::boost::move(*f); @@ -701,9 +838,42 @@ inline I move_n_source(I f, typename std::iterator_traits::difference_type n, return f; } +template + // F models ForwardIterator +inline typename container_detail::enable_if_memcpy_copy_assignable::type + move_n_source(I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT +{ return container_detail::memcpy_n_source(f, n, r); } + ////////////////////////////////////////////////////////////////////////////// // -// destroy_n +// move_n_source_dest +// +////////////////////////////////////////////////////////////////////////////// + +template + // F models ForwardIterator +inline typename container_detail::disable_if_memcpy_copy_assignable::type + move_n_source_dest(I f, typename std::iterator_traits::difference_type n, F &r) +{ + while (n--) { + *r = ::boost::move(*f); + ++f; ++r; + } + return f; +} + +template + // F models ForwardIterator +inline typename container_detail::enable_if_memcpy_copy_assignable::type + move_n_source_dest(I f, typename std::iterator_traits::difference_type n, F &r) BOOST_CONTAINER_NOEXCEPT +{ return container_detail::memcpy_n_source_dest(f, n, r); } + +////////////////////////////////////////////////////////////////////////////// +// +// destroy_n // ////////////////////////////////////////////////////////////////////////////// @@ -734,23 +904,170 @@ inline void destroy_alloc_n(A &, I, typename std::iterator_traits::difference ////////////////////////////////////////////////////////////////////////////// template - -void deep_swap_alloc_n(A &a, F short_range_f, typename allocator_traits::size_type n_i - , G large_range_f, typename allocator_traits::size_type n_j) + > +inline typename container_detail::disable_if_memcpy_copy_assignable::type + deep_swap_alloc_n( A &a, F short_range_f, typename allocator_traits::size_type n_i + , G large_range_f, typename allocator_traits::size_type n_j) { typename allocator_traits::size_type n = 0; - typedef typename allocator_traits::value_type value_type; for (; n != n_i ; ++short_range_f, ++large_range_f, ++n){ - //boost::swap(*first_sm, *first_la); // may throw - value_type temp(boost::move(*short_range_f)); // may throw - *short_range_f = boost::move(*large_range_f); // may throw - *large_range_f = boost::move(temp); // may throw + boost::container::swap_dispatch(*short_range_f, *large_range_f); + } + boost::container::uninitialized_move_alloc_n(a, large_range_f, n_j - n_i, short_range_f); // may throw + boost::container::destroy_alloc_n(a, large_range_f, n_j - n_i); +} + +static const std::size_t DeepSwapAllocNMaxStorage = std::size_t(1) << std::size_t(11); //2K bytes + +template + +inline typename container_detail::enable_if_c + < container_detail::is_memcpy_copy_assignable::value && (MaxTmpBytes <= DeepSwapAllocNMaxStorage) && false + , void>::type + deep_swap_alloc_n( A &a, F short_range_f, typename allocator_traits::size_type n_i + , G large_range_f, typename allocator_traits::size_type n_j) +{ + typedef typename allocator_traits::value_type value_type; + typedef typename boost::aligned_storage + ::value>::type storage_type; + storage_type storage; + + const std::size_t n_i_bytes = sizeof(value_type)*n_i; + unsigned char *const large_ptr = static_cast(static_cast(container_detail::addressof(*large_range_f))); + unsigned char *const short_ptr = static_cast(static_cast(container_detail::addressof(*short_range_f))); + unsigned char *const stora_ptr = static_cast(static_cast(container_detail::addressof(storage))); + ::memcpy(stora_ptr, large_ptr, n_i_bytes); + ::memcpy(large_ptr, short_ptr, n_i_bytes); + ::memcpy(short_ptr, stora_ptr, n_i_bytes); + std::advance(large_range_f, n_i); + std::advance(short_range_f, n_i); + boost::container::uninitialized_move_alloc_n(a, large_range_f, n_j - n_i, short_range_f); // may throw + boost::container::destroy_alloc_n(a, large_range_f, n_j - n_i); +} + +template + +inline typename container_detail::enable_if_c + < container_detail::is_memcpy_copy_assignable::value && true//(MaxTmpBytes > DeepSwapAllocNMaxStorage) + , void>::type + deep_swap_alloc_n( A &a, F short_range_f, typename allocator_traits::size_type n_i + , G large_range_f, typename allocator_traits::size_type n_j) +{ + typedef typename allocator_traits::value_type value_type; + typedef typename boost::aligned_storage + ::value>::type storage_type; + storage_type storage; + const std::size_t sizeof_storage = sizeof(storage); + + std::size_t n_i_bytes = sizeof(value_type)*n_i; + char *large_ptr = static_cast(static_cast(container_detail::addressof(*large_range_f))); + char *short_ptr = static_cast(static_cast(container_detail::addressof(*short_range_f))); + char *stora_ptr = static_cast(static_cast(container_detail::addressof(storage))); + + std::size_t szt_times = n_i_bytes/sizeof_storage; + const std::size_t szt_rem = n_i_bytes%sizeof_storage; + + //Loop unrolling using Duff's device, as it seems it helps on some architectures + const std::size_t Unroll = 4; + std::size_t n = (szt_times + (Unroll-1))/Unroll; + const std::size_t branch_number = ((!szt_times)*Unroll) + (szt_times % Unroll); + switch(branch_number){ + case 4: + break; + case 0: do{ + ::memcpy(stora_ptr, large_ptr, sizeof_storage); + ::memcpy(large_ptr, short_ptr, sizeof_storage); + ::memcpy(short_ptr, stora_ptr, sizeof_storage); + large_ptr += sizeof_storage; + short_ptr += sizeof_storage; + case 3: + ::memcpy(stora_ptr, large_ptr, sizeof_storage); + ::memcpy(large_ptr, short_ptr, sizeof_storage); + ::memcpy(short_ptr, stora_ptr, sizeof_storage); + large_ptr += sizeof_storage; + short_ptr += sizeof_storage; + case 2: + ::memcpy(stora_ptr, large_ptr, sizeof_storage); + ::memcpy(large_ptr, short_ptr, sizeof_storage); + ::memcpy(short_ptr, stora_ptr, sizeof_storage); + large_ptr += sizeof_storage; + short_ptr += sizeof_storage; + case 1: + ::memcpy(stora_ptr, large_ptr, sizeof_storage); + ::memcpy(large_ptr, short_ptr, sizeof_storage); + ::memcpy(short_ptr, stora_ptr, sizeof_storage); + large_ptr += sizeof_storage; + short_ptr += sizeof_storage; + } while(--n); + } + ::memcpy(stora_ptr, large_ptr, szt_rem); + ::memcpy(large_ptr, short_ptr, szt_rem); + ::memcpy(short_ptr, stora_ptr, szt_rem); + std::advance(large_range_f, n_i); + std::advance(short_range_f, n_i); + boost::container::uninitialized_move_alloc_n(a, large_range_f, n_j - n_i, short_range_f); // may throw + boost::container::destroy_alloc_n(a, large_range_f, n_j - n_i); +} + + +////////////////////////////////////////////////////////////////////////////// +// +// copy_assign_range_alloc_n +// +////////////////////////////////////////////////////////////////////////////// + +template + +void copy_assign_range_alloc_n( A &a, I inp_start, typename allocator_traits::size_type n_i + , O out_start, typename allocator_traits::size_type n_o ) +{ + if (n_o < n_i){ + inp_start = boost::container::copy_n_source_dest(inp_start, n_o, out_start); // may throw + boost::container::uninitialized_copy_alloc_n(a, inp_start, n_i - n_o, out_start);// may throw + } + else{ + out_start = boost::container::copy_n(inp_start, n_i, out_start); // may throw + boost::container::destroy_alloc_n(a, out_start, n_o - n_i); + } +} + +////////////////////////////////////////////////////////////////////////////// +// +// move_assign_range_alloc_n +// +////////////////////////////////////////////////////////////////////////////// + +template + +void move_assign_range_alloc_n( A &a, I inp_start, typename allocator_traits::size_type n_i + , O out_start, typename allocator_traits::size_type n_o ) +{ + if (n_o < n_i){ + inp_start = boost::container::move_n_source_dest(inp_start, n_o, out_start); // may throw + boost::container::uninitialized_move_alloc_n(a, inp_start, n_i - n_o, out_start); // may throw + } + else{ + out_start = boost::container::move_n(inp_start, n_i, out_start); // may throw + boost::container::destroy_alloc_n(a, out_start, n_o - n_i); } - uninitialized_move_alloc_n(a, large_range_f, n_j - n, short_range_f); // may throw - destroy_alloc_n(a, large_range_f, n_j - n); } } //namespace container { diff --git a/include/boost/container/scoped_allocator.hpp b/include/boost/container/scoped_allocator.hpp index 39fd4da..022c73e 100644 --- a/include/boost/container/scoped_allocator.hpp +++ b/include/boost/container/scoped_allocator.hpp @@ -584,6 +584,7 @@ class scoped_allocator_adaptor_base typedef OuterAlloc outer_allocator_type; typedef scoped_allocator_adaptor inner_allocator_type; + typedef allocator_traits inner_traits_type; typedef boost::integral_constant< bool, outer_traits_type::propagate_on_container_copy_assignment::value || @@ -723,6 +724,7 @@ class scoped_allocator_adaptor_base inner_allocator_type; \ + typedef allocator_traits inner_traits_type; \ typedef boost::integral_constant< \ bool, \ outer_traits_type::propagate_on_container_copy_assignment::value || \ @@ -860,6 +862,7 @@ class scoped_allocator_adaptor_base typedef OuterAlloc outer_allocator_type; typedef allocator_traits outer_traits_type; typedef scoped_allocator_adaptor inner_allocator_type; + typedef allocator_traits inner_traits_type; typedef typename outer_traits_type:: propagate_on_container_copy_assignment propagate_on_container_copy_assignment; typedef typename outer_traits_type:: @@ -1029,6 +1032,7 @@ class scoped_allocator_adaptor //! Type: `scoped_allocator_adaptor` if `sizeof...(InnerAllocs)` is zero; otherwise, //! `scoped_allocator_adaptor`. typedef typename base_type::inner_allocator_type inner_allocator_type; + typedef allocator_traits inner_traits_type; typedef typename outer_traits_type::value_type value_type; typedef typename outer_traits_type::size_type size_type; typedef typename outer_traits_type::difference_type difference_type; @@ -1220,7 +1224,7 @@ class scoped_allocator_adaptor return scoped_allocator_adaptor (internal_type_t() ,outer_traits_type::select_on_container_copy_construction(this->outer_allocator()) - ,outer_traits_type::select_on_container_copy_construction(this->inner_allocator()) + ,inner_traits_type::select_on_container_copy_construction(this->inner_allocator()) ); } /// @cond diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp index 40f9de7..2de4ae1 100644 --- a/include/boost/container/stable_vector.hpp +++ b/include/boost/container/stable_vector.hpp @@ -1714,7 +1714,7 @@ class stable_vector void priv_swap_members(stable_vector &x) { - container_detail::do_swap(this->internal_data.pool_size, x.internal_data.pool_size); + boost::container::swap_dispatch(this->internal_data.pool_size, x.internal_data.pool_size); index_traits_type::readjust_end_node(this->index, this->internal_data.end_node); index_traits_type::readjust_end_node(x.index, x.internal_data.end_node); } diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp index 74dd051..4aa6ce7 100644 --- a/include/boost/container/string.hpp +++ b/include/boost/container/string.hpp @@ -426,7 +426,7 @@ class basic_string_base { if(this->is_short()){ if(other.is_short()){ - container_detail::do_swap(this->members_.m_repr, other.members_.m_repr); + boost::container::swap_dispatch(this->members_.m_repr, other.members_.m_repr); } else{ short_t short_backup(this->members_.m_repr.short_repr()); @@ -447,7 +447,7 @@ class basic_string_base this->members_.m_repr.short_repr() = short_backup; } else{ - container_detail::do_swap(this->members_.m_repr.long_repr(), other.members_.m_repr.long_repr()); + boost::container::swap_dispatch(this->members_.m_repr.long_repr(), other.members_.m_repr.long_repr()); } } } diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp index 092114d..4319e6b 100644 --- a/include/boost/container/vector.hpp +++ b/include/boost/container/vector.hpp @@ -410,9 +410,9 @@ struct vector_alloc_holder void swap(vector_alloc_holder &x) BOOST_CONTAINER_NOEXCEPT { - container_detail::do_swap(this->m_start, x.m_start); - container_detail::do_swap(this->m_size, x.m_size); - container_detail::do_swap(this->m_capacity, x.m_capacity); + boost::container::swap_dispatch(this->m_start, x.m_start); + boost::container::swap_dispatch(this->m_size, x.m_size); + boost::container::swap_dispatch(this->m_capacity, x.m_capacity); } void move_from_empty(vector_alloc_holder &x) BOOST_CONTAINER_NOEXCEPT @@ -430,16 +430,6 @@ struct vector_alloc_holder const Allocator &alloc() const BOOST_CONTAINER_NOEXCEPT { return *this; } - void deallocate() BOOST_CONTAINER_NOEXCEPT - { - if(this->m_capacity){ - this->alloc().deallocate(this->m_start, this->m_capacity); - this->m_start = pointer(); - this->m_size = 0; - this->m_capacity = 0; - } - } - const pointer &start() const BOOST_CONTAINER_NOEXCEPT { return m_start; } const size_type &capacity() const BOOST_CONTAINER_NOEXCEPT { return m_capacity; } void start(const pointer &p) BOOST_CONTAINER_NOEXCEPT { m_start = p; } @@ -497,7 +487,7 @@ struct vector_alloc_holderalloc(), container_detail::to_raw_pointer(holder.start()), m_size, this->start()); + (this->alloc(), container_detail::to_raw_pointer(holder.start()), m_size, container_detail::to_raw_pointer(this->start())); } template @@ -509,7 +499,7 @@ struct vector_alloc_holderfirst_allocation(n); ::boost::container::uninitialized_move_alloc_n - (this->alloc(), container_detail::to_raw_pointer(holder.start()), n, this->start()); + (this->alloc(), container_detail::to_raw_pointer(holder.start()), n, container_detail::to_raw_pointer(this->start())); } void first_allocation(size_type cap) @@ -551,9 +541,6 @@ struct vector_alloc_holder void priv_swap_members_impl(vector_alloc_holder &x) { + const std::size_t MaxTmpStorage = sizeof(value_type)*Allocator::internal_capacity; value_type *const first_this = container_detail::to_raw_pointer(this->start()); value_type *const first_x = container_detail::to_raw_pointer(x.start()); if(this->m_size < x.m_size){ - deep_swap_alloc_n(this->alloc(), first_this, this->m_size, first_x, x.m_size); + boost::container::deep_swap_alloc_n(this->alloc(), first_this, this->m_size, first_x, x.m_size); } else{ - deep_swap_alloc_n(this->alloc(), first_x, x.m_size, first_this, this->m_size); + boost::container::deep_swap_alloc_n(this->alloc(), first_x, x.m_size, first_this, this->m_size); } - container_detail::do_swap(this->m_size, x.m_size); + boost::container::swap_dispatch(this->m_size, x.m_size); } }; @@ -743,7 +731,7 @@ class vector vector(const vector &x) : m_holder(allocator_traits_type::select_on_container_copy_construction(x.m_holder.alloc()), x.size()) { - ::boost::container::uninitialized_copy_or_move_alloc_n_source + ::boost::container::uninitialized_copy_alloc_n ( this->m_holder.alloc(), container_detail::to_raw_pointer(x.m_holder.start()) , x.size(), container_detail::to_raw_pointer(this->m_holder.start())); } @@ -784,7 +772,7 @@ class vector vector(const vector &x, const allocator_type &a) : m_holder(a, x.size()) { - ::boost::container::uninitialized_copy_or_move_alloc_n_source + ::boost::container::uninitialized_copy_alloc_n_source ( this->m_holder.alloc(), container_detail::to_raw_pointer(x.m_holder.start()) , x.size(), container_detail::to_raw_pointer(this->m_holder.start())); } @@ -820,7 +808,8 @@ class vector //! Complexity: Linear to the number of elements. ~vector() BOOST_CONTAINER_NOEXCEPT { - destroy_alloc_n(this->get_stored_allocator(), container_detail::to_raw_pointer(this->m_holder.start()), this->m_holder.m_size); + boost::container::destroy_alloc_n + (this->get_stored_allocator(), container_detail::to_raw_pointer(this->m_holder.start()), this->m_holder.m_size); //vector_alloc_holder deallocates the data } @@ -893,7 +882,8 @@ class vector { //Overwrite all elements we can from [first, last) iterator cur = this->begin(); - for ( ; first != last && cur != end(); ++cur, ++first){ + const iterator end_it = this->end(); + for ( ; first != last && cur != end_it; ++cur, ++first){ *cur = *first; } @@ -1507,7 +1497,7 @@ class vector ,container_detail::to_raw_pointer(vector_iterator_get_ptr(first)) )); const size_type destroyed = (end_pos - ptr); - destroy_alloc_n(this->get_stored_allocator(), ptr, destroyed); + boost::container::destroy_alloc_n(this->get_stored_allocator(), ptr, destroyed); this->m_holder.m_size -= destroyed; } return iterator(vector_iterator_get_ptr(first)); @@ -1607,16 +1597,7 @@ class vector T* const other_start = container_detail::to_raw_pointer(x.m_holder.start()); const size_type this_sz = m_holder.m_size; const size_type other_sz = static_cast(x.m_holder.m_size); - if (this_sz < other_sz){ - move_n(other_start, this_sz, this_start); // may throw - uninitialized_move_alloc_n( this->m_holder.alloc(), other_start + this_sz - , other_sz - this_sz, this_start + this_sz); // may throw - } - else - { - move_n(other_start, other_sz, this_start); - destroy_alloc_n(this->m_holder.alloc(), this_start + other_sz, this_sz - other_sz); - } + boost::container::move_assign_range_alloc_n(this->m_holder.alloc(), other_start, other_sz, this_start, this_sz); this->m_holder.m_size = other_sz; } @@ -1658,16 +1639,7 @@ class vector T* const other_start = container_detail::to_raw_pointer(x.m_holder.start()); const size_type this_sz = m_holder.m_size; const size_type other_sz = static_cast(x.m_holder.m_size); - if (this_sz < other_sz){ - copy_or_move_n(other_start, this_sz, this_start); // may throw - uninitialized_copy_or_move_alloc_n( this->m_holder.alloc(), other_start + this_sz - , other_sz - this_sz, this_start + this_sz); // may throw - } - else - { - copy_or_move_n(other_start, other_sz, this_start); - destroy_alloc_n(this->m_holder.alloc(), this_start + other_sz, this_sz - other_sz); - } + boost::container::copy_assign_range_alloc_n(this->m_holder.alloc(), other_start, other_sz, this_start, this_sz); this->m_holder.m_size = other_sz; } @@ -1707,7 +1679,7 @@ class vector const size_type sz = m_holder.m_size; ::boost::container::uninitialized_move_alloc_n_source ( this->m_holder.alloc(), raw_beg, sz, container_detail::to_raw_pointer(p) ); - destroy_alloc_n(this->m_holder.alloc(), raw_beg, sz); + boost::container::destroy_alloc_n(this->m_holder.alloc(), raw_beg, sz); this->m_holder.start(p); this->m_holder.capacity(new_cap); } @@ -1741,7 +1713,7 @@ class vector #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS ++this->num_expand_bwd; #endif - this->priv_range_insert_expand_backwards + this->priv_forward_range_insert_expand_backwards ( container_detail::to_raw_pointer(ret.first) , real_cap , container_detail::to_raw_pointer(this->m_holder.start()) @@ -1758,7 +1730,7 @@ class vector const size_type sz = m_holder.m_size; ::boost::container::uninitialized_move_alloc_n_source ( this->m_holder.alloc(), raw_beg, sz, container_detail::to_raw_pointer(ret.first) ); - destroy_alloc_n(this->m_holder.alloc(), raw_beg, sz); + boost::container::destroy_alloc_n(this->m_holder.alloc(), raw_beg, sz); this->m_holder.start(ret.first); this->m_holder.capacity(real_cap); } @@ -1783,13 +1755,14 @@ class vector void priv_destroy_last_n(size_type n) BOOST_CONTAINER_NOEXCEPT { T* const end_pos = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size; - destroy_alloc_n(this->get_stored_allocator(), end_pos-n, n); + boost::container::destroy_alloc_n(this->get_stored_allocator(), end_pos-n, n); this->m_holder.m_size -= n; } void priv_destroy_all() BOOST_CONTAINER_NOEXCEPT { - destroy_alloc_n(this->get_stored_allocator(), container_detail::to_raw_pointer(this->m_holder.start()), this->m_holder.m_size); + boost::container::destroy_alloc_n + (this->get_stored_allocator(), container_detail::to_raw_pointer(this->m_holder.start()), this->m_holder.m_size); this->m_holder.m_size = 0; } @@ -1833,7 +1806,7 @@ class vector } } - void priv_shrink_to_fit(allocator_v0) + void priv_shrink_to_fit(allocator_v0) BOOST_CONTAINER_NOEXCEPT {} void priv_shrink_to_fit(allocator_v1) @@ -1842,7 +1815,9 @@ class vector if(cp){ const size_type sz = this->size(); if(!sz){ - this->m_holder.deallocate(); + this->m_holder.alloc().deallocate(this->m_holder.m_start, cp); + this->m_holder.m_start = pointer(); + this->m_holder.m_capacity = 0; } else if(sz < cp){ //Allocate a new buffer. @@ -1854,7 +1829,7 @@ class vector #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS ++this->num_alloc; #endif - this->priv_range_insert_new_allocation + this->priv_forward_range_insert_new_allocation ( container_detail::to_raw_pointer(p) , sz , container_detail::to_raw_pointer(this->m_holder.start()) @@ -1864,18 +1839,21 @@ class vector } } - void priv_shrink_to_fit(allocator_v2) + void priv_shrink_to_fit(allocator_v2) BOOST_CONTAINER_NOEXCEPT { - if(this->m_holder.capacity()){ - if(!size()){ - this->m_holder.deallocate(); + const size_type cp = this->m_holder.capacity(); + if(cp){ + const size_type sz = this->size(); + if(!sz){ + this->m_holder.alloc().deallocate(this->m_holder.m_start, cp); + this->m_holder.m_start = pointer(); + this->m_holder.m_capacity = 0; } else{ size_type received_size; if(this->m_holder.allocation_command ( shrink_in_place | nothrow_allocation - , this->capacity(), this->size() - , received_size, this->m_holder.start()).first){ + , cp, sz, received_size, this->m_holder.start()).first){ this->m_holder.capacity(received_size); #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS ++this->num_shrink; @@ -1893,38 +1871,6 @@ class vector return iterator(pos); } - template - iterator priv_forward_range_insert - (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v0) - { - //Check if we have enough memory or try to expand current memory - const size_type remaining = this->m_holder.capacity() - this->m_holder.m_size; - - if (n > remaining){ - //This will trigger an error - throw_bad_alloc(); - } - const size_type n_pos = pos - this->m_holder.start(); - T *const raw_pos = container_detail::to_raw_pointer(pos); - this->priv_range_insert_expand_forward(raw_pos, n, insert_range_proxy); - return iterator(this->m_holder.start() + n_pos); - } - - template - iterator priv_forward_range_insert_at_end - (const size_type n, const InsertionProxy insert_range_proxy, allocator_v0) - { - //Check if we have enough memory or try to expand current memory - const size_type remaining = this->m_holder.capacity() - this->m_holder.m_size; - - if (n > remaining){ - //This will trigger an error - throw_bad_alloc(); - } - this->priv_range_insert_at_end_expand_forward(n, insert_range_proxy); - return this->end(); - } - template iterator priv_forward_range_insert_no_capacity (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v1) @@ -1938,44 +1884,19 @@ class vector #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS ++this->num_alloc; #endif - this->priv_range_insert_new_allocation + this->priv_forward_range_insert_new_allocation ( new_buf, new_cap, raw_pos, n, insert_range_proxy); return iterator(this->m_holder.start() + n_pos); } - template - iterator priv_forward_range_insert - (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v1) - { - //Check if we have enough memory or try to expand current memory - const size_type remaining = this->m_holder.capacity() - this->m_holder.m_size; - T *const raw_pos = container_detail::to_raw_pointer(pos); - - if (n <= remaining){ - const size_type n_pos = pos - this->m_holder.start(); - this->priv_range_insert_expand_forward - (raw_pos, n, insert_range_proxy); - return iterator(this->m_holder.start() + n_pos); - } - else{ - return this->priv_forward_range_insert_no_capacity(pos, n, insert_range_proxy, alloc_version()); - } - } - - template - iterator priv_forward_range_insert_at_end - (const size_type n, const InsertionProxy insert_range_proxy, allocator_v1) - { - return this->priv_forward_range_insert(vector_iterator_get_ptr(this->cend()), n, insert_range_proxy, allocator_v1()); - } template iterator priv_forward_range_insert_no_capacity (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v2) { //Check if we have enough memory or try to expand current memory - const size_type n_pos = pos - this->m_holder.start(); T *const raw_pos = container_detail::to_raw_pointer(pos); + const size_type n_pos = raw_pos - container_detail::to_raw_pointer(this->m_holder.start()); size_type real_cap = 0; //There is not enough memory, allocate a new @@ -1993,14 +1914,14 @@ class vector #endif this->m_holder.capacity(real_cap); //Expand forward - this->priv_range_insert_expand_forward(raw_pos, n, insert_range_proxy); + this->priv_forward_range_insert_expand_forward(raw_pos, n, insert_range_proxy); } //Backwards (and possibly forward) expansion else{ #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS ++this->num_expand_bwd; #endif - this->priv_range_insert_expand_backwards + this->priv_forward_range_insert_expand_backwards ( container_detail::to_raw_pointer(ret.first) , real_cap, raw_pos, n, insert_range_proxy); } @@ -2010,7 +1931,7 @@ class vector #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS ++this->num_alloc; #endif - this->priv_range_insert_new_allocation + this->priv_forward_range_insert_new_allocation ( container_detail::to_raw_pointer(ret.first) , real_cap, raw_pos, n, insert_range_proxy); } @@ -2018,6 +1939,42 @@ class vector return iterator(this->m_holder.start() + n_pos); } + template + iterator priv_forward_range_insert + (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v0) + { + //Check if we have enough memory or try to expand current memory + const size_type remaining = this->m_holder.capacity() - this->m_holder.m_size; + + if (n > remaining){ + //This will trigger an error + throw_bad_alloc(); + } + const size_type n_pos = pos - this->m_holder.start(); + T *const raw_pos = container_detail::to_raw_pointer(pos); + this->priv_forward_range_insert_expand_forward(raw_pos, n, insert_range_proxy); + return iterator(this->m_holder.start() + n_pos); + } + + template + iterator priv_forward_range_insert + (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v1) + { + //Check if we have enough memory or try to expand current memory + const size_type remaining = this->m_holder.capacity() - this->m_holder.m_size; + T *const raw_pos = container_detail::to_raw_pointer(pos); + + if (n <= remaining){ + const size_type n_pos = raw_pos - container_detail::to_raw_pointer(this->m_holder.start()); + this->priv_forward_range_insert_expand_forward + (raw_pos, n, insert_range_proxy); + return iterator(this->m_holder.start() + n_pos); + } + else{ + return this->priv_forward_range_insert_no_capacity(pos, n, insert_range_proxy, alloc_version()); + } + } + template iterator priv_forward_range_insert (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v2) @@ -2031,13 +1988,35 @@ class vector } else{ //Expand forward - const size_type n_pos = pos - this->m_holder.start(); T *const raw_pos = container_detail::to_raw_pointer(pos); - this->priv_range_insert_expand_forward(raw_pos, n, insert_range_proxy); + const size_type n_pos = raw_pos - container_detail::to_raw_pointer(this->m_holder.start()); + this->priv_forward_range_insert_expand_forward(raw_pos, n, insert_range_proxy); return iterator(this->m_holder.start() + n_pos); } } + template + iterator priv_forward_range_insert_at_end + (const size_type n, const InsertionProxy insert_range_proxy, allocator_v0) + { + //Check if we have enough memory or try to expand current memory + const size_type remaining = this->m_holder.capacity() - this->m_holder.m_size; + + if (n > remaining){ + //This will trigger an error + throw_bad_alloc(); + } + this->priv_forward_range_insert_at_end_expand_forward(n, insert_range_proxy); + return this->end(); + } + + template + iterator priv_forward_range_insert_at_end + (const size_type n, const InsertionProxy insert_range_proxy, allocator_v1) + { + return this->priv_forward_range_insert(vector_iterator_get_ptr(this->cend()), n, insert_range_proxy, allocator_v1()); + } + template iterator priv_forward_range_insert_at_end (const size_type n, const InsertionProxy insert_range_proxy, allocator_v2) @@ -2196,7 +2175,7 @@ class vector private: template - void priv_range_insert_at_end_expand_forward(const size_type n, InsertionProxy insert_range_proxy) + void priv_forward_range_insert_at_end_expand_forward(const size_type n, InsertionProxy insert_range_proxy) { T* const old_finish = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size; insert_range_proxy.uninitialized_copy_n_and_update(old_finish, n); @@ -2204,7 +2183,7 @@ class vector } template - void priv_range_insert_expand_forward(T* const pos, const size_type n, InsertionProxy insert_range_proxy) + void priv_forward_range_insert_expand_forward(T* const pos, const size_type n, InsertionProxy insert_range_proxy) { //n can't be 0, because there is nothing to do in that case if(!n) return; @@ -2240,7 +2219,7 @@ class vector this->m_holder.m_size += n; } BOOST_CATCH(...){ - destroy_alloc_n(this->get_stored_allocator(), pos + n, elems_after); + boost::container::destroy_alloc_n(this->get_stored_allocator(), pos + n, elems_after); BOOST_RETHROW } BOOST_CATCH_END @@ -2248,7 +2227,7 @@ class vector } template - void priv_range_insert_new_allocation + void priv_forward_range_insert_new_allocation (T* const new_start, size_type new_cap, T* const pos, const size_type n, InsertionProxy insert_range_proxy) { //n can be zero, if we want to reallocate! @@ -2278,7 +2257,7 @@ class vector //Destroy and deallocate old elements //If there is allocated memory, destroy and deallocate if(!value_traits::trivial_dctr_after_move) - destroy_alloc_n(this->get_stored_allocator(), old_buffer, this->m_holder.m_size); + boost::container::destroy_alloc_n(this->get_stored_allocator(), old_buffer, this->m_holder.m_size); this->m_holder.alloc().deallocate(this->m_holder.start(), this->m_holder.capacity()); } this->m_holder.start(new_start); @@ -2290,7 +2269,7 @@ class vector } template - void priv_range_insert_expand_backwards + void priv_forward_range_insert_expand_backwards (T* const new_start, const size_type new_capacity, T* const pos, const size_type n, InsertionProxy insert_range_proxy) { @@ -2374,7 +2353,7 @@ class vector //they have trivial destructor after move size_type n_destroy = old_finish - to_destroy; if(!value_traits::trivial_dctr_after_move) - destroy_alloc_n(this->get_stored_allocator(), to_destroy, n_destroy); + boost::container::destroy_alloc_n(this->get_stored_allocator(), to_destroy, n_destroy); this->m_holder.m_size -= n_destroy; } } @@ -2448,7 +2427,7 @@ class vector //they have trivial destructor after being moved const size_type n_destroy = s_before - n; if(!value_traits::trivial_dctr_after_move) - destroy_alloc_n(this->get_stored_allocator(), move_end, n_destroy); + boost::container::destroy_alloc_n(this->get_stored_allocator(), move_end, n_destroy); this->m_holder.m_size -= n_destroy; } } @@ -2504,7 +2483,7 @@ class vector //have trivial destructor after being moved size_type n_destroy = s_before - n; if(!value_traits::trivial_dctr_after_move) - destroy_alloc_n(this->get_stored_allocator(), move_end, n_destroy); + boost::container::destroy_alloc_n(this->get_stored_allocator(), move_end, n_destroy); this->m_holder.m_size -= n_destroy; } } @@ -2585,7 +2564,7 @@ class vector this->m_holder.m_size += n_after; } BOOST_CATCH(...){ - destroy_alloc_n(this->get_stored_allocator(), pos, mid_last_dist); + boost::container::destroy_alloc_n(this->get_stored_allocator(), pos, mid_last_dist); BOOST_RETHROW } BOOST_CATCH_END diff --git a/proj/vc7ide/container.vcproj b/proj/vc7ide/container.vcproj index 9f42b17..21e2815 100644 --- a/proj/vc7ide/container.vcproj +++ b/proj/vc7ide/container.vcproj @@ -95,93 +95,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -331,6 +244,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 25add18..af84010 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -21,7 +21,7 @@ rule test_all for local fileb in [ glob *.cpp ] { - all_rules += [ run $(fileb) /boost/timer//boost_timer /boost/system//boost_system /boost/thread//boost_thread + all_rules += [ run $(fileb) : # additional args : # test-files : # requirements diff --git a/test/dummy_test_allocator.hpp b/test/dummy_test_allocator.hpp index 993cccf..afdd042 100644 --- a/test/dummy_test_allocator.hpp +++ b/test/dummy_test_allocator.hpp @@ -314,15 +314,20 @@ class propagation_test_allocator friend bool operator!=(const propagation_test_allocator &, const propagation_test_allocator &) { return false; } + void swap(propagation_test_allocator &r) + { + ++this->swaps_; ++r.swaps_; + boost::container::swap_dispatch(this->id_, r.id_); + boost::container::swap_dispatch(this->ctr_copies_, r.ctr_copies_); + boost::container::swap_dispatch(this->ctr_moves_, r.ctr_moves_); + boost::container::swap_dispatch(this->assign_copies_, r.assign_copies_); + boost::container::swap_dispatch(this->assign_moves_, r.assign_moves_); + boost::container::swap_dispatch(this->swaps_, r.swaps_); + } + friend void swap(propagation_test_allocator &l, propagation_test_allocator &r) { - ++l.swaps_; ++r.swaps_; - container_detail::do_swap(l.id_, r.id_); - container_detail::do_swap(l.ctr_copies_, r.ctr_copies_); - container_detail::do_swap(l.ctr_moves_, r.ctr_moves_); - container_detail::do_swap(l.assign_copies_, r.assign_copies_); - container_detail::do_swap(l.assign_moves_, r.assign_moves_); - container_detail::do_swap(l.swaps_, r.swaps_); + l.swap(r); } unsigned int id_; diff --git a/test/expand_bwd_test_allocator.hpp b/test/expand_bwd_test_allocator.hpp index 882552a..81bf016 100644 --- a/test/expand_bwd_test_allocator.hpp +++ b/test/expand_bwd_test_allocator.hpp @@ -112,9 +112,9 @@ class expand_bwd_test_allocator friend void swap(self_t &alloc1, self_t &alloc2) { - container_detail::do_swap(alloc1.mp_buffer, alloc2.mp_buffer); - container_detail::do_swap(alloc1.m_size, alloc2.m_size); - container_detail::do_swap(alloc1.m_offset, alloc2.m_offset); + boost::container::swap_dispatch(alloc1.mp_buffer, alloc2.mp_buffer); + boost::container::swap_dispatch(alloc1.m_size, alloc2.m_size); + boost::container::swap_dispatch(alloc1.m_offset, alloc2.m_offset); } //Experimental version 2 expand_bwd_test_allocator functions diff --git a/test/heap_allocator_v1.hpp b/test/heap_allocator_v1.hpp index b7724d2..43603f7 100644 --- a/test/heap_allocator_v1.hpp +++ b/test/heap_allocator_v1.hpp @@ -133,7 +133,7 @@ class heap_allocator_v1 //!Swap segment manager. Does not throw. If each heap_allocator_v1 is placed in //!different memory segments, the result is undefined. friend void swap(self_t &alloc1, self_t &alloc2) - { detail::do_swap(alloc1.mp_mngr, alloc2.mp_mngr); } + { boost::container::boost::container::swap_dispatch(alloc1.mp_mngr, alloc2.mp_mngr); } }; //!Equality test for same type of heap_allocator_v1 diff --git a/test/vector_test.hpp b/test/vector_test.hpp index 3771eaf..aba9ee4 100644 --- a/test/vector_test.hpp +++ b/test/vector_test.hpp @@ -80,6 +80,12 @@ bool vector_copyable_only(V1 *boostvector, V2 *stdvector, boost::container::cont stdvector->push_back(int(3)); if(!test::CheckEqualContainers(boostvector, stdvector)) return false; } + { + V1 *pv1 = new V1(*boostvector); + V2 *pv2 = new V2(*stdvector); + delete pv1; + delete pv2; + } return true; } From ff57d9287e89c11c71e92dcaa689c5a443061e8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Wed, 13 Mar 2013 16:14:17 +0000 Subject: [PATCH 81/93] Marked vector iterator and boost::interprocess::offset_ptr as contiguous storage iterators to speed up insertion in vector with trivially copyable types. [SVN r83416] --- include/boost/container/detail/utilities.hpp | 62 ++++++++++++++++++++ test/vector_test.hpp | 5 ++ 2 files changed, 67 insertions(+) diff --git a/include/boost/container/detail/utilities.hpp b/include/boost/container/detail/utilities.hpp index f56c3bf..b1abc48 100644 --- a/include/boost/container/detail/utilities.hpp +++ b/include/boost/container/detail/utilities.hpp @@ -183,12 +183,74 @@ struct are_elements_contiguous static const bool value = false; }; +///////////////////////// +// raw pointers +///////////////////////// + template struct are_elements_contiguous { static const bool value = true; }; +///////////////////////// +// predeclarations +///////////////////////// + +#ifndef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER + +template +class vector_iterator; + +template +class vector_const_iterator; + +#endif //BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER + +} //namespace container_detail { +} //namespace container { + +namespace interprocess { + +template +class offset_ptr; + +} //namespace interprocess { + +namespace container { + +namespace container_detail { + +///////////////////////// +//vector_[const_]iterator +///////////////////////// + +#ifndef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER + +template +struct are_elements_contiguous > +{ + static const bool value = true; +}; + +template +struct are_elements_contiguous > +{ + static const bool value = true; +}; + +#endif //BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER + +///////////////////////// +// offset_ptr +///////////////////////// + +template +struct are_elements_contiguous< ::boost::interprocess::offset_ptr > +{ + static const bool value = true; +}; + template struct are_contiguous_and_same { diff --git a/test/vector_test.hpp b/test/vector_test.hpp index aba9ee4..bbcffb1 100644 --- a/test/vector_test.hpp +++ b/test/vector_test.hpp @@ -83,6 +83,11 @@ bool vector_copyable_only(V1 *boostvector, V2 *stdvector, boost::container::cont { V1 *pv1 = new V1(*boostvector); V2 *pv2 = new V2(*stdvector); + boostvector->clear(); + stdvector->clear(); + boostvector->assign(pv1->begin(), pv1->end()); + stdvector->assign(pv2->begin(), pv2->end()); + if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; delete pv1; delete pv2; } From 43b3b7112b1d625f1d97a5c5b30c28f8be167195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Thu, 14 Mar 2013 23:09:54 +0000 Subject: [PATCH 82/93] Adapted test to new BOOST_TEST_THROWS utility [SVN r83434] --- test/static_vector_test.cpp | 145 +++++++++--------------------------- 1 file changed, 36 insertions(+), 109 deletions(-) diff --git a/test/static_vector_test.cpp b/test/static_vector_test.cpp index f616174..21efeb7 100644 --- a/test/static_vector_test.cpp +++ b/test/static_vector_test.cpp @@ -11,53 +11,19 @@ #include #include -namespace boost { -namespace container { -namespace test { - -//lightweight_test.hpp does not offer support to check if an operation throws -//so write our own macro -inline void throw_failed_impl(char const * excep, char const * file, int line, char const * function) -{ - BOOST_LIGHTWEIGHT_TEST_OSTREAM - << file << "(" << line << "): Exception '" << excep << "' not thrown in function '" - << function << "'" << std::endl; - ++boost::detail::test_errors(); -} - -} //namespace detail { -} //namespace container { -} //namespace boost { - -#define BOOST_TEST_THROW( S, E ) \ - try { \ - S; \ - ::boost::container::test::throw_failed_impl \ - (#E, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \ - } \ - catch(E const&) { \ - } \ - catch(...) { \ - ::boost::container::test::throw_failed_impl \ - (#E, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \ - } \ -// - // TODO: Disable parts of the unit test that should not run when BOOST_NO_EXCEPTIONS // if exceptions are enabled there must be a user defined throw_exception function #ifdef BOOST_NO_EXCEPTIONS namespace boost { - void throw_exception(std::exception const & e){}; // user defined + void throw_exception(std::exception const &){}; // user defined } // namespace boost #endif // BOOST_NO_EXCEPTIONS #include #include -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) #include #include -#endif #include "static_vector_test.hpp" @@ -76,9 +42,7 @@ void test_ctor_ndc() static_vector s; BOOST_TEST_EQ(s.size() , 0u); BOOST_TEST(s.capacity() == N); -#ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW( s.at(0u), std::out_of_range ); -#endif // BOOST_NO_EXCEPTIONS + BOOST_TEST_THROWS( s.at(0u), std::out_of_range ); } template @@ -87,9 +51,7 @@ void test_ctor_nc(size_t n) static_vector s(n); BOOST_TEST(s.size() == n); BOOST_TEST(s.capacity() == N); -#ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW( s.at(n), std::out_of_range ); -#endif // BOOST_NO_EXCEPTIONS + BOOST_TEST_THROWS( s.at(n), std::out_of_range ); if ( 1 < n ) { T val10(10); @@ -109,9 +71,7 @@ void test_ctor_nd(size_t n, T const& v) static_vector s(n, v); BOOST_TEST(s.size() == n); BOOST_TEST(s.capacity() == N); -#ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW( s.at(n), std::out_of_range ); -#endif // BOOST_NO_EXCEPTIONS + BOOST_TEST_THROWS( s.at(n), std::out_of_range ); if ( 1 < n ) { BOOST_TEST(v == s[0]); @@ -135,9 +95,7 @@ void test_resize_nc(size_t n) s.resize(n); BOOST_TEST(s.size() == n); BOOST_TEST(s.capacity() == N); -#ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW( s.at(n), std::out_of_range ); -#endif // BOOST_NO_EXCEPTIONS + BOOST_TEST_THROWS( s.at(n), std::out_of_range ); if ( 1 < n ) { T val10(10); @@ -159,9 +117,7 @@ void test_resize_nd(size_t n, T const& v) s.resize(n, v); BOOST_TEST(s.size() == n); BOOST_TEST(s.capacity() == N); -#ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW( s.at(n), std::out_of_range ); -#endif // BOOST_NO_EXCEPTIONS + BOOST_TEST_THROWS( s.at(n), std::out_of_range ); if ( 1 < n ) { BOOST_TEST(v == s[0]); @@ -183,18 +139,14 @@ void test_push_back_nd() static_vector s; BOOST_TEST(s.size() == 0); -#ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW( s.at(0), std::out_of_range ); -#endif // BOOST_NO_EXCEPTIONS + BOOST_TEST_THROWS( s.at(0), std::out_of_range ); for ( size_t i = 0 ; i < N ; ++i ) { T t(i); s.push_back(t); BOOST_TEST(s.size() == i + 1); -#ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW( s.at(i + 1), std::out_of_range ); -#endif // BOOST_NO_EXCEPTIONS + BOOST_TEST_THROWS( s.at(i + 1), std::out_of_range ); BOOST_TEST(T(i) == s.at(i)); BOOST_TEST(T(i) == s[i]); BOOST_TEST(T(i) == s.back()); @@ -218,9 +170,7 @@ void test_pop_back_nd() { s.pop_back(); BOOST_TEST(s.size() == i - 1); -#ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW( s.at(i - 1), std::out_of_range ); -#endif // BOOST_NO_EXCEPTIONS + BOOST_TEST_THROWS( s.at(i - 1), std::out_of_range ); BOOST_TEST(T(i - 2) == s.at(i - 2)); BOOST_TEST(T(i - 2) == s[i - 2]); BOOST_TEST(T(i - 2) == s.back()); @@ -296,12 +246,10 @@ void test_copy_and_assign_nd(T const& val) test_compare_ranges(a.begin(), a.end(), s1.begin(), s1.end()); } -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) stable_vector bsv(s.begin(), s.end()); vector bv(s.begin(), s.end()); test_copy_and_assign(bsv); test_copy_and_assign(bv); -#endif } template @@ -448,12 +396,10 @@ void test_insert_nd(T const& val) test_insert(s, v); test_insert(s, l); -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) stable_vector bsv(ss.begin(), ss.end()); vector bv(ss.begin(), ss.end()); test_insert(s, bv); test_insert(s, bsv); -#endif } template @@ -464,24 +410,18 @@ void test_capacity_0_nd() static_vector s; BOOST_TEST(s.size() == 0); BOOST_TEST(s.capacity() == 0); -#ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW(s.at(0), std::out_of_range); - BOOST_TEST_THROW(s.resize(5u, T(0)), std::bad_alloc); - BOOST_TEST_THROW(s.push_back(T(0)), std::bad_alloc); - BOOST_TEST_THROW(s.insert(s.end(), T(0)), std::bad_alloc); - BOOST_TEST_THROW(s.insert(s.end(), 5u, T(0)), std::bad_alloc); - BOOST_TEST_THROW(s.insert(s.end(), v.begin(), v.end()), std::bad_alloc); - BOOST_TEST_THROW(s.assign(v.begin(), v.end()), std::bad_alloc); - BOOST_TEST_THROW(s.assign(5u, T(0)), std::bad_alloc); - try{ - static_vector s2(v.begin(), v.end()); - BOOST_TEST(false); - }catch(std::bad_alloc &){} - try{ - static_vector s1(5u, T(0)); - BOOST_TEST(false); - }catch(std::bad_alloc &){} -#endif // BOOST_NO_EXCEPTIONS + BOOST_TEST_THROWS(s.at(0), std::out_of_range); + BOOST_TEST_THROWS(s.resize(5u, T(0)), std::bad_alloc); + BOOST_TEST_THROWS(s.push_back(T(0)), std::bad_alloc); + BOOST_TEST_THROWS(s.insert(s.end(), T(0)), std::bad_alloc); + BOOST_TEST_THROWS(s.insert(s.end(), 5u, T(0)), std::bad_alloc); + BOOST_TEST_THROWS(s.insert(s.end(), v.begin(), v.end()), std::bad_alloc); + BOOST_TEST_THROWS(s.assign(v.begin(), v.end()), std::bad_alloc); + BOOST_TEST_THROWS(s.assign(5u, T(0)), std::bad_alloc); + BOOST_TEST_THROWS(s.assign(5u, T(0)), std::bad_alloc); + typedef static_vector static_vector_0_t; + BOOST_TEST_THROWS(static_vector_0_t s2(v.begin(), v.end()), std::bad_alloc); + BOOST_TEST_THROWS(static_vector_0_t s1(5u, T(0)), std::bad_alloc); } template @@ -490,23 +430,16 @@ void test_exceptions_nd() static_vector v(N, T(0)); static_vector s(N/2, T(0)); -#ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW(s.resize(N, T(0)), std::bad_alloc); - BOOST_TEST_THROW(s.push_back(T(0)), std::bad_alloc); - BOOST_TEST_THROW(s.insert(s.end(), T(0)), std::bad_alloc); - BOOST_TEST_THROW(s.insert(s.end(), N, T(0)), std::bad_alloc); - BOOST_TEST_THROW(s.insert(s.end(), v.begin(), v.end()), std::bad_alloc); - BOOST_TEST_THROW(s.assign(v.begin(), v.end()), std::bad_alloc); - BOOST_TEST_THROW(s.assign(N, T(0)), std::bad_alloc); - try{ - static_vector s2(v.begin(), v.end()); - BOOST_TEST(false); - }catch(std::bad_alloc &){} - try{ - static_vector s1(N, T(0)); - BOOST_TEST(false); - }catch(std::bad_alloc &){} -#endif // BOOST_NO_EXCEPTIONS + BOOST_TEST_THROWS(s.resize(N, T(0)), std::bad_alloc); + BOOST_TEST_THROWS(s.push_back(T(0)), std::bad_alloc); + BOOST_TEST_THROWS(s.insert(s.end(), T(0)), std::bad_alloc); + BOOST_TEST_THROWS(s.insert(s.end(), N, T(0)), std::bad_alloc); + BOOST_TEST_THROWS(s.insert(s.end(), v.begin(), v.end()), std::bad_alloc); + BOOST_TEST_THROWS(s.assign(v.begin(), v.end()), std::bad_alloc); + BOOST_TEST_THROWS(s.assign(N, T(0)), std::bad_alloc); + typedef static_vector static_vector_n_half_t; + BOOST_TEST_THROWS(static_vector_n_half_t s2(v.begin(), v.end()), std::bad_alloc); + BOOST_TEST_THROWS(static_vector_n_half_t s1(N, T(0)), std::bad_alloc); } template @@ -600,13 +533,11 @@ void test_swap_and_move_nd() typedef static_vector small_vector_t; static_vector v(N, T(0)); small_vector_t s(N/2, T(1)); -#ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW(s.swap(v), std::bad_alloc); + BOOST_TEST_THROWS(s.swap(v), std::bad_alloc); v.resize(N, T(0)); - BOOST_TEST_THROW(s = boost::move(v), std::bad_alloc); + BOOST_TEST_THROWS(s = boost::move(v), std::bad_alloc); v.resize(N, T(0)); - BOOST_TEST_THROW(small_vector_t s2(boost::move(v)), std::bad_alloc); -#endif // BOOST_NO_EXCEPTIONS + BOOST_TEST_THROWS(small_vector_t s2(boost::move(v)), std::bad_alloc); } } @@ -620,9 +551,7 @@ void test_emplace_0p() for (int i = 0 ; i < int(N) ; ++i ) v.emplace_back(); BOOST_TEST(v.size() == N); -#ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW(v.emplace_back(), std::bad_alloc); -#endif + BOOST_TEST_THROWS(v.emplace_back(), std::bad_alloc); } } @@ -636,9 +565,7 @@ void test_emplace_2p() for (int i = 0 ; i < int(N) ; ++i ) v.emplace_back(i, 100 + i); BOOST_TEST(v.size() == N); -#ifndef BOOST_NO_EXCEPTIONS - BOOST_TEST_THROW(v.emplace_back(N, 100 + N), std::bad_alloc); -#endif + BOOST_TEST_THROWS(v.emplace_back(N, 100 + N), std::bad_alloc); BOOST_TEST(v.size() == N); for (int i = 0 ; i < int(N) ; ++i ) BOOST_TEST(v[i] == T(i, 100 + i)); From 9f25104101e5153a09d7fee5cc13bc677017133a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 16 Mar 2013 14:22:59 +0000 Subject: [PATCH 83/93] Added missing for ::memcpy [SVN r83460] --- include/boost/container/detail/utilities.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/boost/container/detail/utilities.hpp b/include/boost/container/detail/utilities.hpp index b1abc48..81e0ed8 100644 --- a/include/boost/container/detail/utilities.hpp +++ b/include/boost/container/detail/utilities.hpp @@ -13,6 +13,7 @@ #include "config_begin.hpp" #include +#include //for ::memcpy #include #include #include From f1a4d7f82eb735b661acc7289a133511ad76332a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 16 Mar 2013 16:19:08 +0000 Subject: [PATCH 84/93] Fixes #8294 [SVN r83467] --- include/boost/container/deque.hpp | 20 ++++++-------------- test/deque_test.cpp | 14 ++++++++++++++ test/vector_test.hpp | 20 ++++++++++---------- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/include/boost/container/deque.hpp b/include/boost/container/deque.hpp index d8dc2a4..5ff423d 100644 --- a/include/boost/container/deque.hpp +++ b/include/boost/container/deque.hpp @@ -1721,11 +1721,11 @@ class deque : protected deque_base this->members_.m_finish = new_finish; } else{ - pos = this->members_.m_finish - elemsafter; + pos = old_finish - elemsafter; if (elemsafter >= n) { - iterator finish_n = this->members_.m_finish - difference_type(n); + iterator finish_n = old_finish - difference_type(n); ::boost::container::uninitialized_move_alloc - (this->alloc(), finish_n, this->members_.m_finish, this->members_.m_finish); + (this->alloc(), finish_n, old_finish, old_finish); this->members_.m_finish = new_finish; boost::move_backward(pos, finish_n, old_finish); interf.copy_n_and_update(pos, n); @@ -1733,25 +1733,17 @@ class deque : protected deque_base else { const size_type raw_gap = n - elemsafter; ::boost::container::uninitialized_move_alloc - (this->alloc(), pos, old_finish, this->members_.m_finish + raw_gap); + (this->alloc(), pos, old_finish, old_finish + raw_gap); BOOST_TRY{ + interf.copy_n_and_update(pos, elemsafter); interf.uninitialized_copy_n_and_update(old_finish, raw_gap); } BOOST_CATCH(...){ - this->priv_destroy_range(this->members_.m_finish, this->members_.m_finish + (old_finish - pos)); + this->priv_destroy_range(old_finish, old_finish + elemsafter); BOOST_RETHROW } BOOST_CATCH_END this->members_.m_finish = new_finish; - interf.copy_n_and_update(pos, elemsafter); - /* - interf.uninitialized_copy_some_and_update(old_finish, elemsafter, false); - this->members_.m_finish += n-elemsafter; - ::boost::container::uninitialized_move_alloc - (this->alloc(), pos, old_finish, this->members_.m_finish); - this->members_.m_finish = new_finish; - interf.copy_remaining_to(pos); - */ } } } diff --git a/test/deque_test.cpp b/test/deque_test.cpp index 0ca9fef..2889423 100644 --- a/test/deque_test.cpp +++ b/test/deque_test.cpp @@ -207,6 +207,20 @@ bool do_test() stddeque->insert(stddeque->end(), aux_vect2, aux_vect2 + 50); if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; + for(int i = 0; i < 50; ++i){ + IntType move_me (i); + aux_vect[i] = boost::move(move_me); + } + for(int i = 0; i < 50; ++i){ + aux_vect2[i] = i; + } + + cntdeque->insert(cntdeque->begin()+cntdeque->size() + ,boost::make_move_iterator(&aux_vect[0]) + ,boost::make_move_iterator(aux_vect + 50)); + stddeque->insert(stddeque->begin()+stddeque->size(), aux_vect2, aux_vect2 + 50); + if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; + for(int i = 0, j = static_cast(cntdeque->size()); i < j; ++i){ cntdeque->erase(cntdeque->begin()); stddeque->erase(stddeque->begin()); diff --git a/test/vector_test.hpp b/test/vector_test.hpp index bbcffb1..e21b9ba 100644 --- a/test/vector_test.hpp +++ b/test/vector_test.hpp @@ -172,38 +172,38 @@ int vector_test() IntType aux_vect[50]; for(int i = 0; i < 50; ++i){ - IntType new_int(-2); + IntType new_int(-i); aux_vect[i] = boost::move(new_int); } int aux_vect2[50]; for(int i = 0; i < 50; ++i){ - aux_vect2[i] = -2; + aux_vect2[i] = -i; } typename MyBoostVector::size_type old_size = boostvector->size(); typename MyBoostVector::iterator insert_it = - boostvector->insert(boostvector->begin() + old_size + boostvector->insert(boostvector->begin() + old_size/2 ,boost::make_move_iterator(&aux_vect[0]) ,boost::make_move_iterator(aux_vect + 50)); - if(boostvector->begin() + old_size != insert_it) return 1; - stdvector->insert(stdvector->begin() + old_size, aux_vect2, aux_vect2 + 50); + if(boostvector->begin() + old_size/2 != insert_it) return 1; + stdvector->insert(stdvector->begin() + old_size/2, aux_vect2, aux_vect2 + 50); if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; for(int i = 0; i < 50; ++i){ - IntType new_int(-3); + IntType new_int(-i); aux_vect[i] = boost::move(new_int); } for(int i = 0; i < 50; ++i){ - aux_vect2[i] = -3; + aux_vect2[i] = -i; } old_size = boostvector->size(); //Now try with input iterators instead - insert_it = boostvector->insert(boostvector->begin() + old_size + insert_it = boostvector->insert(boostvector->begin() + old_size/2 ,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0])) ,boost::make_move_iterator(make_input_from_forward_iterator(aux_vect + 50)) ); - if(boostvector->begin() + old_size != insert_it) return 1; - stdvector->insert(stdvector->begin() + old_size, aux_vect2, aux_vect2 + 50); + if(boostvector->begin() + old_size/2 != insert_it) return 1; + stdvector->insert(stdvector->begin() + old_size/2, aux_vect2, aux_vect2 + 50); if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; } /* //deque has no reserve From 6c13bd4918dab8724af6442c2ccf6075b99308b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 16 Mar 2013 19:30:19 +0000 Subject: [PATCH 85/93] Fixed error with repr swap [SVN r83468] --- include/boost/container/string.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp index 4aa6ce7..e97f789 100644 --- a/include/boost/container/string.hpp +++ b/include/boost/container/string.hpp @@ -426,7 +426,7 @@ class basic_string_base { if(this->is_short()){ if(other.is_short()){ - boost::container::swap_dispatch(this->members_.m_repr, other.members_.m_repr); + std::swap(this->members_.m_repr, other.members_.m_repr); } else{ short_t short_backup(this->members_.m_repr.short_repr()); From 7634deec5cc983d4eba9ec2204d9d4988cb25d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 16 Mar 2013 19:31:32 +0000 Subject: [PATCH 86/93] Added insertion test to vector-like containers [SVN r83469] --- doc/container.qbk | 4 ++-- proj/vc7ide/container.vcproj | 3 +++ test/vector_test.hpp | 7 ++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/container.qbk b/doc/container.qbk index e38288b..285e5fd 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -665,8 +665,8 @@ use [*Boost.Container]? There are several reasons for that: * Support for `BOOST_NO_EXCEPTIONS` [@https://svn.boost.org/trac/boost/ticket/7227 #7227]. * Fixed bugs [@https://svn.boost.org/trac/boost/ticket/7921 #7921], [@https://svn.boost.org/trac/boost/ticket/7969 #7969], - [@https://svn.boost.org/trac/boost/ticket/8118 #8118]. - + [@https://svn.boost.org/trac/boost/ticket/8118 #8118], + [@https://svn.boost.org/trac/boost/ticket/8294 #8294]. [endsect] [section:release_notes_boost_1_53_00 Boost 1.53 Release] diff --git a/proj/vc7ide/container.vcproj b/proj/vc7ide/container.vcproj index 21e2815..185a5c0 100644 --- a/proj/vc7ide/container.vcproj +++ b/proj/vc7ide/container.vcproj @@ -300,6 +300,9 @@ + + diff --git a/test/vector_test.hpp b/test/vector_test.hpp index e21b9ba..b1a4fb5 100644 --- a/test/vector_test.hpp +++ b/test/vector_test.hpp @@ -31,6 +31,7 @@ #include #include #include +#include "insert_test.hpp" namespace boost{ namespace container { @@ -102,6 +103,10 @@ int vector_test() typedef typename MyBoostVector::value_type IntType; const int max = 100; + if(!test_range_insertion()){ + return 1; + } + { BOOST_TRY{ MyBoostVector *boostvector = new MyBoostVector; @@ -317,6 +322,7 @@ int vector_test() } BOOST_CATCH_END } + std::cout << std::endl << "Test OK!" << std::endl; return 0; } @@ -328,4 +334,3 @@ int vector_test() #include #endif //BOOST_CONTAINER_TEST_VECTOR_TEST_HEADER - From 754736c83f2516b7adeb9a12863d1923eba210a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Mon, 25 Mar 2013 22:35:27 +0000 Subject: [PATCH 87/93] Added missing test file. [SVN r83571] --- test/insert_test.hpp | 74 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 test/insert_test.hpp diff --git a/test/insert_test.hpp b/test/insert_test.hpp new file mode 100644 index 0000000..1d589f1 --- /dev/null +++ b/test/insert_test.hpp @@ -0,0 +1,74 @@ +#ifndef BOOST_CONTAINER_TEST_INSERT_TEST_HPP +#define BOOST_CONTAINER_TEST_INSERT_TEST_HPP + +// Copyright (C) 2013 Cromwell D. Enage +// 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) + +#include +#include +#include "check_equal_containers.hpp" + +namespace boost { +namespace container { +namespace test { + +template +void + test_insert_range( + std::deque &std_deque + , SeqContainer &seq_container + , std::deque const& input_deque + , std::size_t index + ) +{ + BOOST_TEST(CheckEqualContainers(&std_deque, &seq_container)); + + std_deque.insert( + std_deque.begin() + index + , input_deque.begin() + , input_deque.end() + ); + + seq_container.insert( + seq_container.begin() + index + , input_deque.begin() + , input_deque.end() + ); + BOOST_TEST(CheckEqualContainers(&std_deque, &seq_container)); +} + +template +bool test_range_insertion() +{ + int err_count = boost::report_errors(); + typedef typename SeqContainer::value_type value_type; + std::deque input_deque; + for (int element = -10; element < 10; ++element) + { + input_deque.push_back(element + 20); + } + + for (std::size_t i = 0; i <= input_deque.size(); ++i) + { + std::deque std_deque; + SeqContainer seq_container; + + for (int element = -10; element < 10; ++element) + { + std_deque.push_back(element); + seq_container.push_back(value_type(element)); + } + test_insert_range(std_deque, seq_container, input_deque, i); + } + + return err_count == boost::report_errors(); +} + + +} //namespace test { +} //namespace container { +} //namespace boost { + +#endif //#ifndef BOOST_CONTAINER_TEST_INSERT_TEST_HPP From e6828a448aead64d04ffd0adf12761f6c5d9a664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Tue, 2 Apr 2013 22:42:58 +0000 Subject: [PATCH 88/93] Removed unused images from documentation and fixed some qbk [endsect] tags. [SVN r83727] --- doc/Jamfile.v2 | 2 ++ doc/container.qbk | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 5c470ce..fe7f054 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -50,6 +50,8 @@ boostbook standalone : html:boost.root=../../../.. html:boost.libraries=../../../../libs/libraries.htm + html:img.src.path=../../../../doc/html/ + xhtml:img.src.path=../../../../doc/html/ generate.section.toc.level=3 chunk.first.sections=1 pdf:img.src.path=$(images_location)/ diff --git a/doc/container.qbk b/doc/container.qbk index 285e5fd..daec5ce 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -253,7 +253,7 @@ can a stable design approach the behavior of `vector` (random access iterators, insertion/deletion, minimal memory overhead, etc.)? The following image describes the layout of a possible data structure upon which to base the design of a stable vector: -[$images/stable_vector.png [width 50%] [align center] ] +[$../../libs/container/doc/html/images/stable_vector.png [width 50%] [align center] ] Each element is stored in its own separate node. All the nodes are referenced from a contiguous array of pointers, but also every node contains an "up" pointer referring back to the associated array cell. This up pointer is the key element @@ -667,6 +667,7 @@ use [*Boost.Container]? There are several reasons for that: [@https://svn.boost.org/trac/boost/ticket/7969 #7969], [@https://svn.boost.org/trac/boost/ticket/8118 #8118], [@https://svn.boost.org/trac/boost/ticket/8294 #8294]. + [endsect] [section:release_notes_boost_1_53_00 Boost 1.53 Release] From 409b3fa27b6943335d65fb318303676720085e0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Tue, 2 Apr 2013 22:44:23 +0000 Subject: [PATCH 89/93] Removed unused images from documentation and fixed some qbk [endsect] tags. [SVN r83728] --- doc/html/boostbook.css | 537 ---------------------------------- doc/html/images/blank.png | Bin 374 -> 0 bytes doc/html/images/caution.png | Bin 1250 -> 0 bytes doc/html/images/draft.png | Bin 17454 -> 0 bytes doc/html/images/home.png | Bin 358 -> 0 bytes doc/html/images/important.png | Bin 722 -> 0 bytes doc/html/images/next.png | Bin 336 -> 0 bytes doc/html/images/note.png | Bin 490 -> 0 bytes doc/html/images/prev.png | Bin 334 -> 0 bytes doc/html/images/tip.png | Bin 449 -> 0 bytes doc/html/images/toc-blank.png | Bin 318 -> 0 bytes doc/html/images/toc-minus.png | Bin 259 -> 0 bytes doc/html/images/toc-plus.png | Bin 264 -> 0 bytes doc/html/images/up.png | Bin 370 -> 0 bytes doc/html/images/warning.png | Bin 1241 -> 0 bytes doc/html/reference.css | 12 - 16 files changed, 549 deletions(-) delete mode 100644 doc/html/boostbook.css delete mode 100644 doc/html/images/blank.png delete mode 100644 doc/html/images/caution.png delete mode 100644 doc/html/images/draft.png delete mode 100644 doc/html/images/home.png delete mode 100644 doc/html/images/important.png delete mode 100644 doc/html/images/next.png delete mode 100644 doc/html/images/note.png delete mode 100644 doc/html/images/prev.png delete mode 100644 doc/html/images/tip.png delete mode 100644 doc/html/images/toc-blank.png delete mode 100644 doc/html/images/toc-minus.png delete mode 100644 doc/html/images/toc-plus.png delete mode 100644 doc/html/images/up.png delete mode 100644 doc/html/images/warning.png delete mode 100644 doc/html/reference.css diff --git a/doc/html/boostbook.css b/doc/html/boostbook.css deleted file mode 100644 index 2146334..0000000 --- a/doc/html/boostbook.css +++ /dev/null @@ -1,537 +0,0 @@ -/*============================================================================= - Copyright (c) 2004 Joel de Guzman - - Use, modification and distribution is subject to 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) -=============================================================================*/ - -/*============================================================================= - Body defaults -=============================================================================*/ - - body - { - margin: 1em; - font-family: sans-serif; - } - -/*============================================================================= - Paragraphs -=============================================================================*/ - - p - { - text-align: left; - font-size: 10pt; - line-height: 1.15; - } - -/*============================================================================= - Program listings -=============================================================================*/ - - /* Code on paragraphs */ - p tt.computeroutput - { - font-size: 10pt; - } - - pre.synopsis - { - font-size: 10pt; - margin: 1pc 4% 0pc 4%; - padding: 0.5pc 0.5pc 0.5pc 0.5pc; - } - - .programlisting, - .screen - { - font-size: 10pt; - display: block; - margin: 1pc 4% 0pc 4%; - padding: 0.5pc 0.5pc 0.5pc 0.5pc; - } - -/*============================================================================= - Headings -=============================================================================*/ - - h1, h2, h3, h4, h5, h6 - { - text-align: left; - margin: 1em 0em 0.5em 0em; - font-weight: bold; - } - - h1 { font: 140% } - h2 { font: bold 140% } - h3 { font: bold 130% } - h4 { font: bold 120% } - h5 { font: italic 110% } - h6 { font: italic 100% } - - /* Top page titles */ - title, - h1.title, - h2.title - h3.title, - h4.title, - h5.title, - h6.title, - .refentrytitle - { - font-weight: bold; - margin-bottom: 1pc; - } - - h1.title { font-size: 140% } - h2.title { font-size: 140% } - h3.title { font-size: 130% } - h4.title { font-size: 120% } - h5.title { font-size: 110% } - h6.title { font-size: 100% } - - .section h1 - { - margin: 0em 0em 0.5em 0em; - font-size: 140%; - } - - .section h2 { font-size: 140% } - .section h3 { font-size: 130% } - .section h4 { font-size: 120% } - .section h5 { font-size: 110% } - .section h6 { font-size: 100% } - - /* Code on titles */ - h1 tt.computeroutput { font-size: 140% } - h2 tt.computeroutput { font-size: 140% } - h3 tt.computeroutput { font-size: 130% } - h4 tt.computeroutput { font-size: 120% } - h5 tt.computeroutput { font-size: 110% } - h6 tt.computeroutput { font-size: 100% } - -/*============================================================================= - Author -=============================================================================*/ - - h3.author - { - font-size: 100% - } - -/*============================================================================= - Lists -=============================================================================*/ - - li - { - font-size: 10pt; - line-height: 1.3; - } - - /* Unordered lists */ - ul - { - text-align: left; - } - - /* Ordered lists */ - ol - { - text-align: left; - } - -/*============================================================================= - Links -=============================================================================*/ - - a - { - text-decoration: none; /* no underline */ - } - - a:hover - { - text-decoration: underline; - } - -/*============================================================================= - Spirit style navigation -=============================================================================*/ - - .spirit-nav - { - text-align: right; - } - - .spirit-nav a - { - color: white; - padding-left: 0.5em; - } - - .spirit-nav img - { - border-width: 0px; - } - -/*============================================================================= - Table of contents -=============================================================================*/ - - .toc - { - margin: 1pc 4% 0pc 4%; - padding: 0.1pc 1pc 0.1pc 1pc; - font-size: 10pt; - line-height: 1.15; - } - - .toc-main - { - width: 600; - text-align: center; - margin: 1pc 1pc 1pc 10%; - padding: 2pc 1pc 3pc 1pc; - line-height: 0.1; - } - - .boost-toc - { - float: right; - padding: 0.5pc; - } - -/*============================================================================= - Tables -=============================================================================*/ - - .table-title, - div.table p.title - { - margin-left: 4%; - padding-right: 0.5em; - padding-left: 0.5em; - } - - .informaltable table, - .table table - { - width: 92%; - margin-left: 4%; - margin-right: 4%; - } - - div.informaltable table, - div.table table - { - padding: 4px; - } - - /* Table Cells */ - div.informaltable table tr td, - div.table table tr td - { - padding: 0.5em; - text-align: left; - } - - div.informaltable table tr th, - div.table table tr th - { - padding: 0.5em 0.5em 0.5em 0.5em; - border: 1pt solid white; - font-size: 120%; - } - -/*============================================================================= - Blurbs -=============================================================================*/ - - div.note, - div.tip, - div.important, - div.caution, - div.warning, - p.blurb - { - font-size: 10pt; - line-height: 1.2; - display: block; - margin: 1pc 4% 0pc 4%; - padding: 0.5pc 0.5pc 0.5pc 0.5pc; - } - - p.blurb img - { - padding: 1pt; - } - -/*============================================================================= - Variable Lists -=============================================================================*/ - - span.term - { - font-weight: bold; - font-size: 10pt; - } - - div.variablelist table tbody tr td - { - text-align: left; - vertical-align: top; - padding: 0em 2em 0em 0em; - font-size: 10pt; - } - - div.variablelist table tbody tr td p - { - margin: 0em 0em 0.5em 0em; - } - - /* Make the terms in definition lists bold */ - div.variablelist dl dt - { - font-weight: bold; - font-size: 10pt; - } - - div.variablelist dl dd - { - margin: 1em 0em 1em 2em; - font-size: 10pt; - } - -/*============================================================================= - Misc -=============================================================================*/ - - /* Title of books and articles in bibliographies */ - span.title - { - font-style: italic; - } - - span.underline - { - text-decoration: underline; - } - - span.strikethrough - { - text-decoration: line-through; - } - - /* Copyright, Legal Notice */ - div div.legalnotice p - { - font-size: 8pt; - text-align: left - } - -/*============================================================================= - Colors -=============================================================================*/ - - @media screen - { - /* Links */ - a - { - color: #0C7445; - } - - a:visited - { - color: #663974; - } - - h1 a, h2 a, h3 a, h4 a, h5 a, h6 a, - h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover, - h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited - { - text-decoration: none; /* no underline */ - color: #000000; - } - - /* Syntax Highlighting */ - .keyword { color: #0000AA; } - .identifier { color: #000000; } - .special { color: #707070; } - .preprocessor { color: #402080; } - .char { color: teal; } - .comment { color: #800000; } - .string { color: teal; } - .number { color: teal; } - .white_bkd { background-color: #E8FBE9; } - .dk_grey_bkd { background-color: #A0DAAC; } - - /* Copyright, Legal Notice */ - .copyright - { - color: #666666; - font-size: small; - } - - div div.legalnotice p - { - color: #666666; - } - - /* Program listing */ - pre.synopsis - { - border: 1px solid #DCDCDC; - border-bottom: 3px solid #9D9D9D; - border-right: 3px solid #9D9D9D; - background-color: #FAFFFB; - } - - .programlisting, - .screen - { - border: 1px solid #DCDCDC; - border-bottom: 3px solid #9D9D9D; - border-right: 3px solid #9D9D9D; - background-color: #FAFFFB; - } - - /* Blurbs */ - div.note, - div.tip, - div.important, - div.caution, - div.warning, - p.blurb - { - border: 1px solid #DCDCDC; - border-bottom: 3px solid #9D9D9D; - border-right: 3px solid #9D9D9D; - background-color: #FAFFFB; - } - - /* Table of contents */ - .toc - { - border: 1px solid #DCDCDC; - border-bottom: 3px solid #9D9D9D; - border-right: 3px solid #9D9D9D; - background-color: #FAFFFB; - } - - /* Table of contents */ - .toc-main - { - border: 1px solid #DCDCDC; - border-bottom: 3px solid #9D9D9D; - border-right: 3px solid #9D9D9D; - background-color: #FAFFFB; - } - - - /* Tables */ - div.informaltable table tr td, - div.table table tr td - { - border: 1px solid #DCDCDC; - background-color: #FAFFFB; - } - - div.informaltable table tr th, - div.table table tr th - { - background-color: #E3F9E4; - border: 1px solid #DCDCDC; - } - - /* Misc */ - span.highlight - { - color: #00A000; - } - } - - @media print - { - /* Links */ - a - { - color: black; - } - - a:visited - { - color: black; - } - - .spirit-nav - { - display: none; - } - - /* Program listing */ - pre.synopsis - { - border: 1px solid gray; - background-color: #FAFFFB; - } - - .programlisting, - .screen - { - border: 1px solid gray; - background-color: #FAFFFB; - } - - /* Table of contents */ - .toc - { - border: 1px solid #DCDCDC; - border-bottom: 3px solid #9D9D9D; - border-right: 3px solid #9D9D9D; - background-color: #FAFFFB; - } - - /* Table of contents */ - .toc-main - { - border: 1px solid #DCDCDC; - border-bottom: 3px solid #9D9D9D; - border-right: 3px solid #9D9D9D; - background-color: #FAFFFB; - } - - .informaltable table, - .table table - { - border: 1px solid #DCDCDC; - border-bottom: 3px solid #9D9D9D; - border-right: 3px solid #9D9D9D; - border-collapse: collapse; - background-color: #FAFFFB; - } - - /* Tables */ - div.informaltable table tr td, - div.table table tr td - { - border: 1px solid #DCDCDC; - background-color: #FAFFFB; - } - - div.informaltable table tr th, - div.table table tr th - { - border: 1px solid #DCDCDC; - background-color: #FAFFFB; - } - - /* Misc */ - span.highlight - { - font-weight: bold; - } - } diff --git a/doc/html/images/blank.png b/doc/html/images/blank.png deleted file mode 100644 index 764bf4f0c3bb4a09960b04b6fa9c9024bca703bc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 374 zcmeAS@N?(olHy`uVBq!ia0y~yU}ykg4kiW$2A`O3a~K#HSkfJR9T^xl_H+M9WMyDr z)b(_645^s&_M)R8g96V1g9H1Y`?|@Qa8+HmHda4(nQ?zM!!?FAj1kNm*b;aTNHv%; cj9>w=gf!;AOne?`3=9kmp00i_>zopr0Be8NW(e>Jab;j&;NV~o5MYpy zU{F+KFf?Rva$<;zVn|MA$j)XcE@r5%W@u?)XlW_#>0#*UDemd%nKFf8%9P?MQ>y38 zVVEwkZjIWyHF@jSt$X(}?A@Du?i|Cp zbLXyIW4Lzh+_h`h?%iX!chB(NJdh*`E$$X&!4}4&+z{J`|sZwzJC|^ z{$1kxcf;@BzyJTw@c+NS|Nj#IN5NBISn~R-X--a%afBxQ|J!3zMjr_SU zk_iHr)f*lf{$5^Qz}I)@3FlWvw(w~u=1P@VsTP+$RNGvxbHL-(%M6nc6`{zlU zjGQJeveps+!&Jb&mD)L@hA} z1_tL6*NBqf{Irtt#G+IN2MuLS&)mfHRNut(%;anZ6Fnn63k6F{eFF=914D)6qRirw zN{8Ia;*!i{z0_j8l+uFyyb`_S{M?DV6n8K%Fld2|%S_KpEGaEYWk@zRFt#waFg8d` zG)YZPF-fe)lBATd3a!N{b-$VA&f+n^|#(~yCI Ofx*+&&t;ucLK6T%G-N*j diff --git a/doc/html/images/draft.png b/doc/html/images/draft.png deleted file mode 100644 index 0084708c9b8287c51efa6b40b8d492854191455e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17454 zcmeAS@N?(olHy`uVBq!ia0y~yVCrFDVA{sP#K6Gdy&=krfq{V~-O<;Pfnj4m_n$;o z1_lKNPZ!6KiaBrZ-Y&bnV_It>gUxBbUGDq;8-IJzl^bZYNdFq&_HF%>I2sgw)Q7JN zaWX7AvyxSZ;a1dY28NFFCccr=a%;t-jiT=}Ffh!2v1?uK?S1dJ@0+Om6fE+-G`4(a z%(Bc`&m%QMr#-z^zJ*sSlffZoT1%K$@8gP{F?`Yf!JfU_`BK`3qL>MOAHOUUuyq5 zICVEaF;V1YxN#ua^vhOdFq+Vq?0GvRL+{f#=!FFy#0R*{}(!^yB1~4a?5`E z?UbRy5=I8a2^aW5^u37}`W2TjGSp4Hz^}Z7kwI?ag=~RK3=HueFQ#&2GBk+W3Eh$? zp3@Tc#)6IEL!;C!PA4gb2RHuzz5oC0=QrPGvHN5kEih*|u(tl+&-RwG)(LD37Kd%N zMDvt0Gu%m#yJe}B$j<_p{S z`X{h4{5g~DB<(Cw+xMN7;RAF1+$5DR-z%~i818?Zav?Qx(gpiRcNrOKI$Q3EVZQOhM844`yo-LdjblF7I)zQiNNHizIaZud+@W@y?<=U^W zU$0(1+TS^Wt%3QYA%E@JsNbJHIr;5&@?bs?_+v)A#4c^Nc6ly95Le=X|V>0PXf zybQayPnY^7_4SKxh75Ba^6n_@{HPUk^XF*WT5G`GDR} zzl@(#4J>tQQ=WWrZ!uwb)8F56Eo#5_i>KF5zFaGCiD85BJfU4Wr~5hg{<*(vUH2k| z<;;rfD> zIkUqavo}xovDT*S1F2Yf!)>R%t6w$93_Zu zpICRx(n*S8(T49WVo$b2x0o>G==Xw{ASF3EOF>L+kf`R~7O{gxzs}FM=X`GRdI@8K z@k+HXON4d-uB#!zHuxn?JubPWH|r@+J5E7(AvLs-6G5EOX1X zb$Sw&PTbd0Z5u2z8Ezaf@qKKuEq8a(tTKJhy$kOD*8BZq8IwcOCY{rt_pEzu`f%6o zmar?A%NI>zYdE`R9&m{<5EfJPbifU%&LGel$9@_j^m&oAXs3>`;Jd=DGM=uP)OzW1{Ci|pLnzvRAeyY}zj-|G0s_gYLCT%N4{`7-6% z!u^5@%dg&hwp{p+1sj8O)K1Hj%m3bU_sCcpa@pid^?p!dIJaltzEdi%Pc7NGZaM!X zkfXC(Oc-`3F8AMcD&*wLb+0$+So=9~7gafWFgGw?f9|~d)XU0w%QH`H(mCn3@%_Zh zO%vD}wyqP7+Hoo~d+qAOo66efgteG3todTN@aV;7lWG-~^P9IYG4Rz+z2LR7a$f4i z&F_0WCH{h(Y4c)si`bJdRg*67OMklfY^IYGgWShtkY#(9Wv*If_3YohGoH)`?&kTt zVEuggb?eOeb#--mr!T$szSHU@#qjR)r%y%UPTH?B#SfkF-@k9)x7zn#Ro{UM8(Fz| zdsLQR=Qg&N4Fy$A1*@mNb$#-s%E(@JLBGzVIca`U40(@MF-By^PE-ASIa?;ZZkCr6 zL*26tU#~}b+wQ$o_zYAP{y4}yH|hTD=an+Y3uPov*W7R{nl*u~;r)*r&z!R7KChhj zy#4O<+nvf^CW6Y$_)ilrteIK1I`{Uv*Uu`y{nCm)3#x_>Jok7J%duJhW*FGhHBBw| zCNg}!9QE3_2o#wW{Vn$vt6WbF^khCzuduLO>ttQNRwl!b?bZJ0cCd2F1|@wpnQFrD zr~C8Q3tcUIdK*h4LoP8a5LtXD({tIpWs}$#;;pAmxDXBD6qH=Ku+nP*NW36po{-h~ zVxg*H&M(!$p3D|{Sud1tl-l~L@`6hB<{MxCm`pWkP)@S_a`DX;unvng?RE?1p7R&J z#L(9o`0ntnWKiJowY1pnxck&Zk@tayN5+c1V3t4xf3NFhlhDw&N}!N>`FYFh^m)&H zFHg8o9diAv9w?k9Sky1Rqw;0l)l%92JIob%6;l7X?eu)Xa>U-=*Mr$ZZ1J5RfloeP zZZT;v`DtA{sm0Id%;(EF+*}Hd^UD4%Y4f}BwCLq7y=}G5E0-`XId*y7e3g=0kJf-} z^IRCr!{2QHV!m7u%%gpD8psrv4RTU`E?etn9W!LmOqe2_=X%NAO_ev{yGMqF_(_lp z67G9sR0uhPJXO}y(iT4ZJjkoxx?0>AZohl)`&gnOHp$lqo=ZMel1xbk(B=F^q;cWZR5TGh4aLR7FPbB8QvFGuC79rjxdll*1g4j5jAv&H1Ob zP*jmu!Aa$d)MXRP`tKhWw-^7K-4f=tk%ikK#^Z(Qu|k=)M2WUSnc2&3{wnKx+E^NS zUww2a^?lbJYJZ-^LpVrEj2ZA(&dL=YxUcw z-=7LLo^$=;JC*Z(NIXpD)IITXZAA8a-;ASHnG6pnUdZ-vnt%TJ@qatMOx##!wTE2@ z6q+1o+?}%5b}zEP@J9sd2G`7SYzN+!v`m%}dS*|&rn`9 zf8KM~K$ZV&@1zuY59rsMmRvSD$$sWk+`IfIm2sh=p`qv2^R&Ns$M!&Q@ty37wF^C8 z#4eb`_JDiwo$LT-XTeJhHkGxtrSmR$Y2N($*@E-!s_D@Y*`6Dz9m1`%Nz)MR(UO| z+V?`{thl(iXO-W+3q^mtuIc9VUPO`ifNHW&>~+_`375Ywnl3Fbc!@#g^roIU`@}hW z{RJ;E+)-Zs-pT1Ps2bLvHmB_NqCb92mb&TD6EFM#X%;{Ea+A)a`-Ab4{KtVa$1u@%i$V3l(R+{V!vbxv=n6W>$txkC)Vew7vlU-?ulq*u9u= zA#?F0whc3%eE&Y}>jk^44542NE0!?k=v=L;l6+eBZ$|2r-xgqjlRqIS2 z;Wzn0LF)uIf!36wSuJhOXFQoZPS~8!z5TAdZdOZMbc;#DjyLAZQ@4t8^0rI7V-pZh z_PK1bTl#yP-+YyY4+Ru?6|8oj&h+117nSY#qFH$fjr`SP(D_xIP|pM6=yq$YWXw8ND{XZ+89u6e)1oU@mKBa>lc z_lEwQmmPDn$YXh}TwPapZqu8~|6i9* z*{ySW*SfoLV!J`bpm|eo_5OYP>V8=s2zH9jPMtEl<(PHIC5AG$S1$e;PhDRj3@Jrjj46FUjNE`?vZgv^@>W$tzV$rmCzOD{28+Vb;P zrjXR@Ku>0mYi(amIC<4MG8r^)r`!(^l3FKli9tx*V!3CA#gREC4PRR4%s=;ePD`71 z$R!3o#T&cU?0dgF^V2UO3qB{Q1A#3kUsleGkBd8zY2oO>Y%#&$@4Y7`F&D4hTKk@n zp=s9how?EXKVLpJBYuBfYUH!`suOIqG8x(r?=b(?G=Z(a<%vmIV1OsI-Jp=GLUkU#gXzK>f|f_c}zTnlKo=>-7)>RrHp< z8iJP`VvZGlsbyl>=j5kscE*!gu(G!H?eBd$-j?qIG@t%9;iwTwtBcD1`}=$Tv*jOc zouoQiRla9SMWnp*j79FDfVxq_DtOw03p;eRnk zjK{K8 zU$StE$p*%D&bzPsbiA)w}59Y=epBMg~ zA;A&Wj(*BKPEs6+pIhR%UfY~c)fds+WWHzV-o^K&83isil+RZGV!f$&rpUF*dD>jB z-2?p(n>$H;(B9S}=AEc(J^g9rxoHpj6_-C0RphM@Nq5@+dEExJRqsW0md~F*KlKUo zaYqm4eQ%T&uJ??-c`2st_QcB{S|+gVkvRVG?c3a0%hu*U$vZYf=k%&or#AIG+XRws zoWQnc!?jcAlB{_x*KT#$YSN-T>vW!j-(gE9sSl|#$EQ!9zW0B}Nj;5A@ovR8`%h%< zaP?r`=X3eWw%qHboGi0@s?B|sn;&xi>HVX)98|zmTq(VK`}XbR`mpR+5my_@{IyeC zrtJ-Q!Tg`ik~f?q^T6WFS?8XAHsIm^6PcYGd%bdAyqTDx`Yw%5B7C5{zN`Fm*2{a1%mcw(XsX6o%$v$W-DzJ9bK z>UI47x`~%Pm6kB>U$ZsH$G)aDet(^A>8h45$xC;J2YvT0o_TH7frtSAWL_t!4|y`j zL8kvX{@JF!s%qE0?U9Riz222MOGzhsdh@mnJ>kSxnMGEfEhZ1s~L)`X6`V!uA}_x(^=`>ZJG;mNW{i*_xl9Uwhxarghb-dGqG&`?demi}$;q3`98(648`&wRG|^Yz8tU!}EG#|@7k zNPX8l=U6XCrosep`EjhUW=Dt4=}nol-fun|r7h2ql3Ciqy4t2Vg&~IP_3NGAlqbyj zcK5xn-}1%@Y)lj1)Kp9lD72dUYS+G}<$aGWe1ltdPvxxqB;vZ!{pq0Iwr6k zimX4e<=U^GKYt#3yH{mis$7WGfyG%&@h9}2ZpwOXF}o+o|FKw$iNKUKN2`AH>sL>> zYwe=bz3Td#m5;6(vFQcB_gbmk(>VF^4?#s<7E_+XKWpNGebOVp{rU69;b`XCsq>6H zTQj)BlFw|)(*9}q!N79ulwW^;n_KR62N}BcTa8_L?Dl6|sgZW}_V&{@oo4u9bN;b~ zU5#|y$zso02bM0heR#;~%%3ev%fEL{U~8IG`Dps|>84XBU;9;JH8u5TfvL`RMc)S( z-L{_iZ1eM((W}gw)(LD*lbx4^uj|)39ptyM<_Fg$7qh;{Hs_yzj{JK!%f#a$e!ceWZ9Rtj>;Hcf z^xNd-UFO(XrvAZoT53>4dgL^RkoJ==ZO*6a&fh=%Kvhi-liB3wKMi=a)0h3;H~n0C zc)9A6o3YoouDLSFu3)?V!wF|r#_LVrwN73a0?<;ik2-^(WFH=l{{{wiP0B3A!)7yq66yVmHOUNXDU$f~ZzWP@bq z-p@bx7RC|eqn$e5GcWf4$-BDvs|n}c>=u&^ zdkbaaV6`-@O#PjAz0@_3 zCGYdUwj5qv<99(3$7Qa5wmGfwHz;Cys^mk7AHA*a^sd-o?l z?-8kgZJy8R+;?=!+W@6IJKy}Sn$_aRHq}IcH9I#n^svF2m8M&-70Pkwa;m3?KCRTd zJ+eDmGEJ!h+%)AB|ysgBk+6IADhWgjs!{(JGOVD!iGX_`yd zY!$i`8tNG;dy=<)&GKGDQ1|`hf=O&iilVoFO_-*-#zE#k3R-HMlAxKpK6zE zou=%Ta%|VS?8pcEzSiztzg+UEAOBPnfr**3Zf$$JD=#(XYH6+2+?cyl^Nrr=-kw%z z>v&V~CG+{uF|!_T`&*&-^^1uwXfV4|aY^G2i^%TOp317Ku7y{2&ov4EUVFbZ_Dty3 z2`4in*QmCB-FCKW)6`vGcH~w_7xX>MQ_xF|)HB}7KlwoS^3yNHjIL`}cjwjW+fOzR z^QxC*p8oRH+OS+t{i+Azt_(H7jXOMimwjCosF(frXU(*&*ZJO`-Cij3^v7x0+HC># z=6>?W1NlBqc^j}I15^bbam|jMwselh)@Mpynkzqi6RJ3DaN@`-x#tg__)c39H|und zVdcE{?~K_O9hzezAp4SeSB#$a`e2cxpFe-r6H2HvIb5-O-1(Vnwg@#`J#UtIO zcqlXTx#^ZSk2g;5d|Ns1=@h}p^`W7nt)_Oas=P@IMS3k^|_p3cGJE564v1ZGmFpf-xvi$t~*z0Tec+7jg{Bq{)w{vS% zN&-dhZ$Em{>{;&ZQzjc$Pv>(m(^>s`mhaB~p7*u_)|v9rH-%J>EAHO4l$~YuLi>Ma zmcl-LHzx7A#oTQU|FqJ{uk+qT1BN?FOB!!j-mH%{_e2#|o!7?_RrgV!yJNcI3S0DqkiFUUGN?s`A&oZ=H5{R@WkqKNrgP$^E+5BKB$f zx&Mq@!<v^32&Rz^S#YKa7TWxrgfrGm0vfJq-?^~KV=zqUq1yRC_nXh)~wXKR`^Yh5y zaFV*wUODgny?fWpbzcn$QOSewzjHvhA zaJglln)8>Sh;~V4^@Sfb|CusWD@nVp+u0P-^^eQtIp^A~d~+^%t<*W4@_YL7<;xjv zcTTwQgKMhE26adk72jQIHTQ`Hd$_rp(29lkCpxR7a*If^mD{oTIX#wMGnwt%5sBc? zt51s}iv>OBR?fToj(e^f@86GdQ-UhzonE!Ja$YLWovYt+RZRA|doWig^%PE8Q+r?B z^`XI%%d5fW^%|Z(f8IO&=BeD%9vOc?o>;bO)xP)F^@XL{4u<;WZ`Cia2#PrE^m&oS zG+8(K9alEJPS2@#cWIr#R(32(+dXfMWZ~7Q(~Nzu&Dr9!UYLsS6w7teej_k2rJH6$ZidT*PrTL5u@e>Qf)%SW&Kb`vYMaiedckWMq?;0BF@9)3-@=Bf4 z(f8U@=*5pz9Ap!_VwGhZJ(?nr=3*1-0%ADpztr{$PnGouNHmt_pN^Ot8=%( z9o{$n*P{A7=Pk?h_0+xV-~ZOm&8dD$>P(#tVO}SfJ$;|X=#g=!+e_-k>TS8#-wS1d zipgE(%ROI2>pU+z^I7Nef8Wan{JpyaJehZ=tkvyuy2iA2XJ1Hld2hw!3+7Sh)=j&5 zH8j+7<=(HgiT)g!3DcLPYM$Qo)!KV|u6FOK?SImQe#M=Z*s;~@>VD-v594_@gh##p z+U|Ese!pQ!?HkQ75!XYUdncGRt$ok*`>?%K!u>fiRyRxU_U}J_dEI>9%M;=bg#Wnd zaOF+?tzTt}Ca2DPQ@3@J&#b!7(jFNJ!e=~{m4p~JtvL~8eSY&CN0sPoU0L%_t=FRJ zX73LcFL>i`c2Ue9!GmjekD=|23msudAtrtFa4_BynEeg&?I*Gem^H>>7=RzcKP{j*RGYuUjO>_xU7)W4Y8>vO_L<#+8oU)BNjy^eQhk5 zy7N`#y!ONizB^Jk-?i@buDn$L%TPsr75_p4yc2Ir@|1wIomdIG&X2{z6g}5>rj?Ocp&~dw+fWp4ZK1g2F?m z#`&H9{O8xNT|alUE@)%Bws=xo^0iyra)0mZUp}wez3TMxOfP-=9>dVkqXL&yOdhb< z+ZVX~IusWl|8&alwfWDjKihcEp8CdS*Vnf@L=H0*3P}~TKFr&pc)Rn+1?95oI;Z`X zPc}^ZoKUrcFAlSDpGEe?%g9nkpx6#i8?} z@1|urac951eLGr8@$K&8vjg)EnAdG7n7=Jo*e}EI{O8lBPp^x9=n@)Qv}7v3iirS& zee8~AovpWi={ZgK`Eu{|%Td|>w)f6BGbesvZi}9K{`u*ro4&@fC@oJbjotow&b6rD z7Va+DXKhRb*zA*ccs^*EmV03Reh&X{-|tob-t}b5VeU(sY%NDLBYs5AXql#Ca_q$A z`0U)Cjn~e7&gq%?ymFS>+OIa}4~8-HKepg$-k*7w0n~EIew#ME?%Be|100!u4rDt; zXRG#X)|t#O;s2g{-OhFWI^B~3Gb}TLKHV-)*q)o+v-0(=*Q+b0KCg_N7JGf|{wddH zwXiuUE%_+Bo>SK|=6dP8=bNs7S?*uo`7qTqFi<2Y)O)6O=G&KiM-6x)r@h@iZ(7o> z_rJg9PuaTd{qNZN6vl6@i?u$g)^o1iI&H1lCY|aXey$~w`+o0>xBn0jdi7-q*Usk}1t~2icF*+}KJ8I^X%+W>&2+;L``-WFC*O83zT(gI z`oGuf&d-^){Y8zP_0P)xUteFZJ1*K#o47-I{)Dd=@|e#@%}$MsoR%7y7WwSeqti2X z`s7$kUiteaG-XEla?vF`u{*NlU;mD);RCC!^71<&er~mcdheZe)(ld(Toe% zPinOf|5`lzf$tod8c!3aL~kp%o9maz^`d{tys{aWgJ!+AS~9&h`C7b} z-KGhb8}eIB?(`R(zEco;{r0-ZQ=8UgO0|nmY4zDH_tET_MWufVzr{_qyuVi&YFa1Q zSv@x`0ZruP%)9XFy<;!m@4c!s%VK?2@4qbIr&qc&M#!R6x1JX<`+Pj`> zGJP=NmrZx#Za;nC$qOI#>9@M(SiD?yHrkIbwqBD#-u0J9tNpp}Py33e{GPSND>d?2 zN*KQp;# zzhc+EW96~@M);gLJv(F68|O@W`sVfe#apNG1`AjCH{5vh;3k(kA81x4xo5J^q@|at z=T8e;cl-F9`MF#Uf|uAGomTIkowRQM!zqhatkP1?-neAOva`|!dFK8RHa#tI7CX~9 zUz)U)Jw3szE^qy;Qtr56?{?OXP+91g?9H>cPnJ%S{4y;zV@}9{Pajj?-(JQPc=PFEvF#RD<|UaI8R^bFkf!!N zCGy#m&E23n#^4dJ#g^;Kb@x4A+}2m)zfpSa`S8pxKh3VLMFl(dR$edF+-rGY+qb_5 zjxLvY`mfC}E!FRInwqBQB9dg<%+%npK=Iu#e@Z&XXV`z+FC%eB(j-M4P1NU+`7!>E3#@>5gGzKf@7uGa6| zHQ!@LR&BV~#mBrmCS5uF{e;I0>9e2rsM)9Nu-<4Cl@j?Z<-6h1DO2LA8q;5`wC^*U`T?H(KbI zUeT#1v$SOr|6F^xT)^r?!_-SPV)Bl+x8>fp+LQ2!Q#bX?tO?VM7YEhWw-_$d;0mAb zx@%psuGj{*Q~k4BCSK@|wEwlM?(n7`p0^jQUj4P!f42FD4O8ZySZOu?yvi5mHCwgY z7BJumR7>`ZbJyJbx~nqw;K_{I*Y9lCyI^C4&^3yL%!1YD|j zP;Y37OTL+!+H=wuJW7TpG^Ec15_1!z0Sz@RD=KZ-OStHYV53e+L+b8fL5}s zx&LmJ&S~bpQf|;x!McCHw5#7VGFzScTou2ht!%~x&iVX*dlMzDxjV&Pch8pGt+x7{ z%)I!QPm+ZTWZ0`x-naG#z6&|u{?F}t>GRK(PhCIRlnyrowRc>JW^$!s%!KTD?f>8mW6os4(hIq<*xVJZLAF2~6_@~yJ6 zfL~tbdyr8RyLF<=OHCDW*{jOj`=oAlE{)82DznP)S%7uv{}rpW!YyqLZc;B|jJh|}w?=OZ4ws@jGSGs23HR;vaUsjataO;QV%^7cgz1)_x`P#Y9H7mSa z|D9TQPSPG-=zOXUr~TK}xSdvu$QOnpK*sHw@LxRJ0y7MW0*0r`)s&su->)qoyzQ~L6@Fx?@>QK z=O%cj;*M!vq1D`=zv3J}+&uC%ef(Ct%%7Ae9Hkk09n>AWc5t7r=*}aXUAA8N;yuA# z=tj|ut3PY@J-w)C`_SEPAxlK(!*{wTAMaR~y>!a;Iez(fZdW>KFP*df=KZ|NSjpt+ z{+vOlPCt9N$?*BtNO9?VuipOe5|TU0cxb_-d-JYb&b?h_TcNPDFkhZic5P}x&CBEo zcP~7#->$VufBNa~-M@o>eP_$*n9#@c`SNz_5U2f{OIDvO52!lv*=D+Fa!^V;=NoV% z*8DS*=eZ3G4-N0gwi-OX$N8oD{O3QPJ{8?Co-%D$q}$Qy|B9DR+0w1QHeKlUKcn3m zT{h?K|GF*t7%9-fGPT5I#q#~-Po#dizgJszdef9^#*w|c+&g61wr#n-ci+B!w;j^< z|KHVM5$NgOQuRw(<;(YV%n?!>uHIMrT~#~X@R;Z8nJoJa(`GGuYNcZGKxS%5Nz>KK z)=|>M9|GS^U8fxBw_wuyf14C%RhevPPpqh{oVeaI;{dypm0M4B{N`)>_Us98w%&Lq z=(NEOpIGnLHr-Re>rDDo=*^^g9w=|vtq zoV*oI9>=?@X0`BTM&4IlspD>U`o@nBY$=AIdmGB)Qo^W2Wx?yeghbXvSb zUpp%!fxG3)ITg!yvdgANPZK?<7-%#Jzu(?3K+~9$ zq^eebeEzyKckNdLp3gSkMcPYKa_s+YEChF6_f}V*$*kv``~2tU&zo0I%-x>C6XUmJ z!o!bCRdo-^Zt%=dU~4Ji`Zo3QJRz&on{3YeFAok0{4UCwliZ`@DStfhlGUWM0iGEO zLMtvr+v1S^z7H(#QcA$M}~r2ONrH^^O^ppC4nNYfgzz= zFSpdCzvPLJI-g=!J!=_5y`zv+2bbbpk;-M|vDd%vy)Isr;M=#nMelUbts|E_UX-hB z*m})KZr_%9y3%WR{EeP`!6Ap^<&`6m{*y2G#k_AwTl@BRT-TeWKjJ>yO}OCD!ts)& zb>;H>`elxPs9m2Pp)I7fNPF?@^=@w9POJnK2`c0EB%+oo2 z=1Itwr6=~q-QRlU=BwLEvs>5}xvI`xBk?Lzs7m;K+NM^PZNDz)`8hEgDlZA%mg_h9 z!o&&lKdP=;8e4Odx3`5Y$<0GOZ?&C~kd@!{wdt?k3nr?V2;E_0otQ0joPIeR zda@;2#iT)5c}ah2yrr)bvxSAzuYzxrE~}U@2wZX(srQ?Ffnfp1%fnrk%RMs~1X{in z9-Rr2)ZuvP+^q`|+u`ORe|OU5qJ0nB%AK5;4_K$YmOk)JW%=t}(Gk!$ zq}RFcS-Um%y6(pq(3*zIdHPqkweO#xfAH1IZMjdMZqoVuU5jCZdwWEas^|xczH7HY zi$6EA4>gX`_|0seIM1Z~v6E zdn#0!cL5Sz&y4P)qFLwF423ytpzk0cA zopSy>u9=rz1K%X|Ff#1%QeTpK_sY+jX{w>o_s`wka?LdmylP|1eBBe73>=yh+aDP4 z)ZXuZyyK0-ChJR;c0A6J(<c z{a-AnKL6NWMwx5p=2dN~z45f@gPR*06 zyml*5LT`F^j(nNPXPbDv>6x=qW`?QorXDPs^?4J6%!Ryp<)3X%>!}|1$@sc`iCmkb z)UDUM`ckINs>^5ikRs2&yK>&`ZBuJ*{fgVBUOnmj=NhZIJ%)xnwfdI2i)H`Cy{NG> z_g#Ddrv%dS%m|<<{ zWs^;ds$N$IcFkd9SiXqwWhQ7@UdQwICj*K@LsKL3YW2NXW9)UGr%t@gASCvlxvyp4 zL?7np?6q4Bb(ZiM+ppca?7pA|jPkw&>L7}Lmh(}?3TQ1b=W>4ID?NYFA{E7Lqo?EV(6IO5jcg3o# z&+GE9r7|9b&%uZeJ`c&(@_dOcJ^7tn1@+`s>m=Qxf8Wep+3y}QQIkJ-c1#ed7TT>a_Y?^~`#g@=ZM^4$Ar z;`gVfzc;GRoVx0D)Ux*J2g=Idmrrona!t(D(U19nU#`84_MU4Og06UJnfn&o-h9(9 zayj<8XVhw4zdh$Rtp#@IGr|nG~w|6pk=33w!4&GFKs+r zG;7(u_o}=40{l1YaXTb!tDo@G@5LgGQ=6u+9(ma8C3Sh$vWb^hKap5HVX^q>iMQEL zX1dBtHnimY5&3*qQ*E~Uu??xqc(zF=r(7vNd5(c^#^o!Q87^&js(hy02{axgA$)S@ zX{T8ySFf^~fBv!wt99Au2FtU*G8s5;tSLMb?*mxtpUh;~E&L+$srACEV$xH8 zB=kh`weU^2TzlW!O-^O``RAWsmIOU9X_(9LamA-87ouJ-(ok6#tYke!)b(L?>m;jt zm62a2GTsn>e_qpn@13HOBS9rF-VgMa_*nH8%Rre0nLTHR=7 z_G#@zf6IOGtJh^qvfqo@Q0wQnJUCF~iAlqZ${MGis~7f9xbW(|&h8$uALlYHdo0`L z@R_|k`^Ti=$ImL8$|(N5G85i>+cc4T+GQizcV9#E1dWzIeednZ+%b82y71yV=S+P! z=lDE(sk&zC^wX|pj-S5>ZRf81x249{kGW&QZ+2nMx1OP)LR#~RqOxtz7hf-pdc8@f zcF&Q$--X}Ac>ipg!zLho++S7bmi9@%^_I3g%{ldA&Pf;F^FDYGV>ij;1q0KQlIx|% zB-WPlJfC9lj`zWdIkx>CFA{2=Z;7!v|5?H*>hImHZu`>iNFP|Z!?Lfbh0iDI&fnC| zt>3`>z`;7=E0(`;{?0 z+VypbRp#2-Ifo7V9vkpf&O3hDQEgh)uGd!b*SB9Y^Ig2PFZY1_0mnPv&wMT4Cd&EN z<+91Vdv5E~tJegIxJFK!_v+=c%u}0E)<_=+dsp$RLh9+XE=_r5u(s~%+W{`)lB6G;|FKLzs@&uU>4=$!AZw4PJ;_Mv$u9)7?KA9}hjBte-x+<(pTwZvK0l^LhJgFPro}-Z5qE#z;^rlVQ=PSk<>66?_gw zw<-;FPj9>vcX@65>r5djhn#&pne}_`sFWChM~W@azufm;_;hBrE+?;o)BN@=*W>bp ztTyagclTTJ`Oh}K!CQ5k^lQJi$ZQ7)B_ub5=kB#RPZ+~K9 zYSJ)cFMsBxG!Uh%9=$*QhJ1^eV`Wsd*o z&itC|7wpX3ac95ttjZT#EYH8poTZd6A6+x+vWiK=kH6YWcCTC9<~RG=E*s3^ z?TIs%oxIArw`w{_LF|dCL9y3=z7U!0yTtQFg~k2m9ErBdd2{tYeoDFd+{JGFgbNIh zrkBS)&s^-jbJ^Bun=2k)G&yVH%Xj|Xi{EyqH*xge`4JK*Qnb4IX9DAc2R;3<_Tsho zf4>ktemLdm#KS(lpC`P`PlkH=k0Vm$EfPxg(;bL^&oC#6>BAMdN$!U0 zVfo&3^^eOytxTD1=GOKC!VC-Uy|s8|y}Uh9VY#y6>$bTuUSdAhJ4F~C-1@B-|LW!A zf*m=ajYBm*QZ)On&zbjpW|fr?pL3N2Th$)M13S-OKW+4`mSvOboYh++YRnlA?9?~k zs<6EOfW+kIJ14()y8m702ouBheYY#Se!hIN^VSWQ?A*0aqd6J!{%){U`FuI^a@6z6 zcPYAJw)Yqw+&N!u5$wNQ_k3~knP1=U|9kpm9RtIwX%oV(TwbYt`qIgX(w9v>`m!*z z=hd2AcAsY8`QmH-Kb!M1-dqfPcLVJwUS2ur+s3cgXFi{qB*h@JD}Tb|IewE2)lP4k z>bhZT*}U|wOooCN?`C=wS=nB@wMZk(&-=8N&e3&h3=hsJpHD5aGK|Vj?pb~Hl3yMt z!vZ<(%%i*3h@?ht`^P(fS?9w%hJvRb1^uq2E_Lyn5mzs}FP`DSg;kjz$M#NMxOJN2 z`>EF-p7CNR$aw2KbB^D!UtY6hk24(5W&iCn@p5Lw{coz9FV-w)I3UWdxc0=$kTp8X zQde$SJ)4nX2WO_M-~0K7$4>IytLbMrAes(R@Hcwr%H^xSUSnW*XtYGsa&P+U-Mceo zm>IUqv~N*bUVb`Cn|tH6m=@Ith6fXVPY8SCzAakYJF#sy;{jcL#kDv3bLL;$KVQX! z!QzSb649?;_|~p(=FDU$IFan3{pw}x#LEk=@0sbBwv~~Ad%xn^7s|K!v)`UFUh`xM zpOX|r%tyIPU32bnu51pEJ0fw|oQWZZQ}B{jh~H-Qr&5nC*3~o5om0-qAkgR(#rjft zcZ}YY!v2XjUwoaqWpXzIgUgNyVP7V?`rO+)Rs7`VJ15`WXJ8QgHSyGr@|Kv|HIe%_ zYA`&w#nyj?!Sd{m?|Xmko4+jctmu|&mGgG*l4oeRrLsiy@4bnU`+s=pO?qxAe2L+~ zg|z0$J=Mn-zyCc|_|mngU%MC&?9@#cIQ*r0@@3G*wWki-e_3CP6=|Iu&BV~rd%K1S zDzo$b@2TPw_a2)O&%m&K+xw$S=iQs2^5vJgJ7`B7$mDC^6xaT_e)-9leZ27R(i_KE7-~9R9Q5*IzxMs_ubUZ5Ljpy%lrcB(3$|`i zTFyLa>&4f!T=8ot789}R7X+<4lI54?Fe*Kdz{MVwgbFY{BnaQnuJ!=|B z?LClM_NdpNf4+ILUWYw6$c?$dexrTj$;|ENo_{{I*+k4W@Ji|1CqWDi{zpOaSGGJi zI-GNEYGmy7oNK%cac>oth+4iqWWaOSz#>vY_jsm6@{8AO4C}uMUh0|?moCw^?|p1( zN%q>=%M#6`7;0``E}k~0uIJCyUF(WV4=&5hc*WMh@J-}W*PObJ+bw#hC$+FO7?g=! z>YB6f^3x*A`RCW&uBuXIU|>EAIu~HwvaNbuO>=iKD)jsX1ycSqvxQTGLPIwOn=`O% zK0P7q$rs*V`^slu0Iic_5V#cQ95wOseW|vC4{f#tostL^VU@khAaH5l{GCs}EN@HP z5u>+GEJkx_k6~)$wA7P_G8i~A?}K8Ae_Bh~4%r!o%Rpm43{1CcJ+%K@-YvZwS9B}b z$==?6@&yKgI4;GtHqW2JRT6F6 za__2b*&4>St9wyFsV~C;W+9%;(iwB6Nmb2K+itoAv;uhI1%?efO`M}-6_(rf7HKb? zH*emJf5Hq&3+CECTKsAM|KI!n>8%6pFIo5c!|c>a7Z?gyPKI4lI{EeTKcQWjvo`76 zjT2`0u;GYv6szR-yxV3Gpz*3zt8UDdW>_?-4&+^3-D`|Rx5}M1Kj30mRMasc%=5{X z{Vmgk*JV6sYq+6u&*EF(bvq-=!kw8?^0g`ZvNMFF7?et;ctyS0GEZ$G7tXF&lWN=T<3UM zf7539%yu@0J%{IfslSm`7o}7)OHD|MVZ(w+|M+KLxg6v?`2s^jImgTIOwUag-(hH2 zZ*b@DPJ_qyE}Klez|gQ>;8OgjxtAlSMP|Qz%EnOBI^kd6^*PhZyd}Cf;o02#20>cCer(fy2Ph<*7F&NV8P0kFUn@;L4th^6Y4IsfkVns;8Oo>70{rM z1)o#Z)B|9_g#wqdSx>**q~n>vU?JjktC7Jnc3Ns^sEP@L4A=4m%g68c=(z18K5z(2g*)X6Y`6qgsjegp75QS zp+jC#_S|yIy((L-S^d#vWJq%JVE?KI^1}ghj+YmvfwkX%yy8^uo_+f!U0`T<|JOc2 YsPxZ;53A2HFfcH9y85}Sb4q9e0Fi|iga7~l diff --git a/doc/html/images/home.png b/doc/html/images/home.png deleted file mode 100644 index 5584aacb097a80e66a5320312b6e4eb017af1a06..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 358 zcmeAS@N?(olHy`uVBq!ia0y~yU=Rjj7G?$phK4%r{|pQa%*9TgAsieWw;%dHU|?WS z3GfMV6&Dfg?(A@OuseF>a6(*+nzF*onKLh6zO-%YmOy{sw6wJU|Nk%gvq74Hfq|za z$S?Rm0x$^OKX;CSfq}EYBeIx*fm;ZK886+f`@_J%pjzS@Q4*Y=R#Ki=l*-_nm|T>f zo0^iDsNj}alvU8YOY t9}F9JU6`43jMG5vNQA&8NcoN_f;wr$vARr(hAt9lu zscC6x>EvV>6{VS+EaBwj6ciMco$ZvI98_E!l$@NLot<4>UER|o(bHqOcQ41TYc{y!?kM?_wFg)yJvXsp5^oB z9Pi&Vyniq7|3Ab3{~Z7S3p{_W`TV)z`}cpO z$(;G%_wGG* z?AW<;=dNA5cJJQ3=g*(NfB*jb_wWDz|6hCQ@I3|w2F4_BcNgdM3%p4T42R|DNig) zWpL0?*7VFxOi%SqOwUZtRxr^s(z8&owA44S&^IttNG{4OE~#|Ltt>9dOx8;+)=McZ z$j>X$OU}=oxJz*d0|SE=*tpE}yu^~yqEv=t diff --git a/doc/html/images/next.png b/doc/html/images/next.png deleted file mode 100644 index 59800b4e87f60c0e3383ede2b384b9be0f5ffe8d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 336 zcmeAS@N?(olHy`uVBq!ia0y~yU=Rjj7G?$phK4%r{|pQa%*9TgAsieWw;%dHU|?WS z3GfMV6&Dfg?(8r&Hr}>%OQ656nzF)*4nJa0`Jj)#l9-t%+}PK^d+g590~2^trx_V+aGYt)W#Kgko@Q{~>i6>w}LxPb)_bi1gN;4a>^d{wcuv&t)U99M06BF~bt=lC3t1z!y3OU-_; z>3=1k>J3(3i_72APIz-IDqpqc+E%+vGv;(%KfZ!%@4A+C&xmZ75-RagX8L}A{%x+r zX<~gz))PX{awr=ezabJ<%O$qq%HpE?3}IarYhrI#g}e)4`)(-lYr?KO{@fm?UzpsD z&F7x?_G;CcbIZ>^o0GCAMe@{JfwtZgS9s0dn=t$|`IrrC3yU6#%a-U6G$wZz0 z>m`@($9HNPdGJ4#pEvb;3eT@>Ck6%v=MvY5lHmNblJdl&R0anPWlhiA#Pn3(#PrPM zYy}fNBRvZROG|wN3w;Aah2)~l;*v^-+{)sT%w)aPV!f2og8aM^z2yAdiMtecFfcG^ zfsM;d&r2*RElOoDPD(L1F;6y4H8Hg?FgGwTOER!DNJ%kHHBU4$OExhPxjgw70|Nse jNLN5&dMbmFNrjP#wt==mQ8cF^C=xwg{an^LB{Ts5w*0vf diff --git a/doc/html/images/prev.png b/doc/html/images/prev.png deleted file mode 100644 index d88a40f923e3c554125f01cd366707c60cfcad04..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 334 zcmeAS@N?(olHy`uVBq!ia0y~yU=Rjj7G?$phK4%r{|pQa%*9TgAsieWw;%dHU|?WS z3GfMV6&DdqOG`60Hr}>%%ZlYo1O0u~loc*tzSP~>;p||S5Et|R|Noh1c$yg)73T~N2spa`a*~JRJ5eh~I1}5!gYtAz;Fo=OPI2WZRmSpDVDTHL^rZN~B=o=X8 z8<-ql-^0nkz!2u?;uumfC;0|1OPoRyGxLNShYX~Tl_Wf9G1_imu)%RA9}mw<0X2^e zQioc&m}WXSvRw^OFi2qFa&lm1W^U?K=~^Ook|m{hVvche^Q6-g?(V)Vn8U=toEqFE UkjD9gfq{X+)78&qol`;+00?PtqyPW_ diff --git a/doc/html/images/tip.png b/doc/html/images/tip.png deleted file mode 100644 index 5c4aab3bb3543191c360387c4af9a3cbaa051345..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 449 zcmeAS@N?(olHy`uVBq!ia0y~yV31^BV36QoU|?X-y2mNSz`($iDJ87yAgr${wU6ATeb^ycE^w7cIp z?_W?xU6%d(bb~@Shbi-aG=ETBbm~(ogOmrW&bwBIxdt+K+A3yD;V_t}R>0LF5GN)x zed{W(mq$!1ciVpPy1}W+9bm)Xrgda~bSbG?a3DdjluYV+O9SdLnMpASqX+9EZY3c7C@7#N&OTq83NAIrA4U>si~GJ7Ut&0mS)MRMrP)TsYwQg=9VeOrfC+2Nk)mu rLdL(;85kJ&K)M1F(^DCYOe>5`v<1B4~iR4S3j3^P6tl1hi%%HopDWWCg4y_C{| z{JavqiARt`YJFJnVhX)qGzOMplv!L->5yAl zT#}irms+fsQd*FoSE84kpF44v;tmD|1}(60ndy0nC8b5F42emG<`xDZ$;L?r7Ky3J=GDKJX@I;2(iM=Hp2}coT4AYeplx7Y_5oxZgQu&X%Q~lo FCIGT9P(J_w diff --git a/doc/html/images/up.png b/doc/html/images/up.png deleted file mode 100644 index 17d9c3ec491ae1ba22188ce85985623c92ffa9be..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 370 zcmeAS@N?(olHy`uVBq!ia0y~yU=Rjj7G?$phK4%r{|pQa%*9TgAsieWw;%dHU|?X- z3h)VW6&DdqOG|Thu-mqE%ZlYoyE{8BU%nLR@2jS)FmvY2qel)W#Kk;%^zi@x|I?Un z*fKCM@RbDl1^-6|46X<6oM2#J;4JWnEM{Qf76M_$OLy!3FfcHvmbgZg1m~xflqVLY zGWaGY7v<-srer26xMdclmgg5`7c2NiC>R+Sn6#IzInThrAO_OlT$Gwvl9`{U5R#dj z%3x@qZ(yu%U~+tY4<`cyLy@P8V@SoEspmFwHW&!FJyeg_(XezvV9WvAI|r@_>dZZG zPW6aiOT!J--9O?NG0%AP;}ge|4lDQN4=-}8`?JGwx}?mMnO)OdyQdu$nQCjPRV}jm z$u!Qa8E-cQ-r3Nz>Y(YPTd#BPEH+&8GWqfD!}4*53%dA!%#3$cIv;a~fq{X+)78&q Iol`;+0POUaApigX diff --git a/doc/html/images/warning.png b/doc/html/images/warning.png deleted file mode 100644 index 1c33db8f34a8b42b373179b46a2d8d8a10e061a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1241 zcmeAS@N?(olHy`uVBq!ia0y~yV2}V|4rT@hhU+WOo?>8NW(e>JaphoO5CF?5GB9W| zFc>m0I59AIF)#!%FhnshWHT@nGcZ&$Ftji*^e`|?VPKe2T|Fl#Xiikroa*YO3=B&x zEth(EEp2I8I%UezrAyZ`FswB+TsvjTRtAQxnwndCdbZA)vvujxty{P5WnkF5cJ1D+ zTaPg?91{>YCLwX`*s*gA4Ce#{&Phm|)6~4iz;I1d^V+p*_ZS%N-Mjakf#JEL;`8Uv z-!m}0=iqq%{{43bhVS3M|7T$MKMF=efJz}yVEuRs0|NtNlDE4HLkFv@2Ll7c3r`ov zkcwNmlWOyu3izvS7ejxP>R-!INP5f(XN|IS^C^Iyp?`SUk1vQO?s(K&l| zi|Nkt0@~*ymDp65*E-HED6u(s{Mfrxmah{JrgAMTIq)Du?nC5nnYTRgThA|azEdIl zD^uvV>~q(b?>`Fd;xnAbe7so1I$-&keKN}|vNNOCvX<~g{)wp7{&hR__v^cBU*Gq* zV3YS!cBPWsl#eNWc|~nAXWMOB8tQWBuXo=4>}cytyX_5F^Az{bVJ>7~U~n#RjVKAu zPb(=;EJ|f?&`{R&%uP&B^-WCAOwLv?(KFJsP_VSrH?Yt*FjPn`$}BFabjYnNF3C*R zOD)z*DJ{s)E742N&z-nSaR&nfgBIAh%=Em(lG377hGY|?B=Z!b6jL*k#Ka_13kwTN zLrZf@a|7cv1EVApQ-8txlNlHo_&~Y>64O%|j7%zwOtcNO4T_>U4H+017(8A5T-G@y GGywozG)2h( diff --git a/doc/html/reference.css b/doc/html/reference.css deleted file mode 100644 index 1bf6b68..0000000 --- a/doc/html/reference.css +++ /dev/null @@ -1,12 +0,0 @@ -/*============================================================================= - Copyright (c) 2004 Joel de Guzman - - Use, modification and distribution is subject to 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) -=============================================================================*/ -PRE.synopsis { - background-color: #e0ffff; - border: thin solid blue; - padding: 1em -} From 3e8acdcb8c28e9691f83fb24ea4fefff1f8984af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 7 Apr 2013 19:11:22 +0000 Subject: [PATCH 90/93] Added bounds checking via BOOST_ASSERT to operator[] [SVN r83797] --- include/boost/container/stable_vector.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp index 2de4ae1..3da8c64 100644 --- a/include/boost/container/stable_vector.hpp +++ b/include/boost/container/stable_vector.hpp @@ -1127,7 +1127,10 @@ class stable_vector //! //! Complexity: Constant. reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT - { return static_cast(*this->index[n]).value; } + { + BOOST_ASSERT(n < this->size()); + return static_cast(*this->index[n]).value; + } //! Requires: size() > n. //! @@ -1138,7 +1141,10 @@ class stable_vector //! //! Complexity: Constant. const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT - { return static_cast(*this->index[n]).value; } + { + BOOST_ASSERT(n < this->size()); + return static_cast(*this->index[n]).value; + } //! Requires: size() > n. //! From 9c97e11949e3d78d8b63b9b8029ebeaaa580d2ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Thu, 18 Apr 2013 20:04:04 +0000 Subject: [PATCH 91/93] Fixes operator- bug. [SVN r83960] --- include/boost/container/vector.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp index 4319e6b..06d2c3f 100644 --- a/include/boost/container/vector.hpp +++ b/include/boost/container/vector.hpp @@ -137,7 +137,7 @@ class vector_const_iterator { right.m_ptr += off; return right; } friend vector_const_iterator operator-(vector_const_iterator left, difference_type off) BOOST_CONTAINER_NOEXCEPT - { left.m_ptr += off; return left; } + { left.m_ptr -= off; return left; } friend difference_type operator-(const vector_const_iterator &left, const vector_const_iterator& right) BOOST_CONTAINER_NOEXCEPT { return left.m_ptr - right.m_ptr; } From a40fd4d49de294fd1618fbe8c6b314b74400ec08 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Sat, 20 Apr 2013 14:04:00 +0000 Subject: [PATCH 92/93] Container: fix minor warning. [SVN r83984] --- include/boost/container/detail/iterators.hpp | 4 ++-- include/boost/container/vector.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/container/detail/iterators.hpp b/include/boost/container/detail/iterators.hpp index f58c4ce..bba7205 100644 --- a/include/boost/container/detail/iterators.hpp +++ b/include/boost/container/detail/iterators.hpp @@ -114,7 +114,7 @@ class constant_iterator const T& operator*() const { return dereference(); } - const T& operator[] (Difference n) const + const T& operator[] (Difference ) const { return dereference(); } const T* operator->() const @@ -335,7 +335,7 @@ class repeat_iterator T& operator*() const { return dereference(); } - T& operator[] (Difference n) const + T& operator[] (Difference ) const { return dereference(); } T *operator->() const diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp index 06d2c3f..dac536a 100644 --- a/include/boost/container/vector.hpp +++ b/include/boost/container/vector.hpp @@ -530,7 +530,7 @@ struct vector_alloc_holderpriv_swap_members_impl(x); } - void move_from_empty(vector_alloc_holder &x) + void move_from_empty(vector_alloc_holder &) { //Containers with version 0 allocators can't be moved without move elements one by one throw_bad_alloc(); } From 1253e6b3127895b98e867c67652ec2432d8fca28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Fri, 26 Apr 2013 19:46:47 +0000 Subject: [PATCH 93/93] Fixes #8500 [SVN r84054] --- include/boost/container/allocator_traits.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/container/allocator_traits.hpp b/include/boost/container/allocator_traits.hpp index 964025f..64e4352 100644 --- a/include/boost/container/allocator_traits.hpp +++ b/include/boost/container/allocator_traits.hpp @@ -214,7 +214,7 @@ struct allocator_traits //! //! Throws: Nothing static void deallocate(Alloc &a, pointer p, size_type n) - { return a.deallocate(p, n); } + { a.deallocate(p, n); } //! Effects: calls `a.allocate(n, p)` if that call is well-formed; //! otherwise, invokes `a.allocate(n)`