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] 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());