From 40451e4bf70b5813b4990adfdffe31f9ae0fc419 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Mon, 8 May 2017 12:39:06 -0700 Subject: [PATCH 1/2] Add variant of map constructors to avoid useless extra allocator copy when using initializer list Many existing constructors have this form: map(std::initializer_list il, const Compare& comp = Compare(), const allocator_type& a = allocator_type()) The issue is that a temporary allocator_type is constructed, and passed to the base class where it is used to copy-constructed the rebound allocator. This temporary allocator_type here is always destroyed at the end of the map() constructor. For stateful allocators this is not desirable. The solution is to adopt what libc++ is doing and have to constructors: map(std::initializer_list il, const Compare& comp = Compare(), const allocator_type& a) and map(std::initializer_list il, const Compare& comp = Compare()) This way, unless an allocator is provided by the client, no extra temporary creation/destruction occurs. --- include/boost/container/detail/tree.hpp | 4 +- include/boost/container/map.hpp | 159 ++++++++++++++++++++++-- 2 files changed, 149 insertions(+), 14 deletions(-) diff --git a/include/boost/container/detail/tree.hpp b/include/boost/container/detail/tree.hpp index 7b29467..2524eed 100644 --- a/include/boost/container/detail/tree.hpp +++ b/include/boost/container/detail/tree.hpp @@ -519,7 +519,7 @@ class tree template tree(bool unique_insertion, InputIterator first, InputIterator last, const key_compare& comp, - const allocator_type& a + const allocator_type& a = allocator_type() #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) , typename container_detail::enable_if_or < void @@ -548,7 +548,7 @@ class tree template tree(bool unique_insertion, InputIterator first, InputIterator last, const key_compare& comp, - const allocator_type& a + const allocator_type& a = allocator_type() #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) , typename container_detail::disable_if_or < void diff --git a/include/boost/container/map.hpp b/include/boost/container/map.hpp index 56aefa4..fa095c4 100644 --- a/include/boost/container/map.hpp +++ b/include/boost/container/map.hpp @@ -153,13 +153,24 @@ class map //! //! Complexity: Constant. BOOST_CONTAINER_FORCEINLINE - explicit map(const Compare& comp, const allocator_type& a = allocator_type()) + explicit map(const Compare& comp, const allocator_type& a) : base_t(comp, a) { //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } + //! Effects: Constructs an empty map using the specified comparison object. + //! + //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE + explicit map(const Compare& comp) + : base_t(comp) + { + //A type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } + //! Effects: Constructs an empty map using the specified allocator. //! //! Complexity: Constant. @@ -178,14 +189,28 @@ class map //! comp and otherwise N logN, where N is last - first. template BOOST_CONTAINER_FORCEINLINE - map(InputIterator first, InputIterator last, const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) + map(InputIterator first, InputIterator last, const Compare& comp, + const allocator_type& a) : base_t(true, first, last, comp, a) { //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } + //! Effects: Constructs an empty map using the specified comparison object and + //! inserts elements from the range [first ,last ). + //! + //! Complexity: Linear in N if the range [first ,last ) is already sorted using + //! comp and otherwise N logN, where N is last - first. + template + BOOST_CONTAINER_FORCEINLINE + map(InputIterator first, InputIterator last, const Compare& comp = Compare()) + : base_t(true, first, last, comp) + { + //A type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } + //! Effects: Constructs an empty map using the specified //! allocator, and inserts elements from the range [first ,last ). //! @@ -213,13 +238,33 @@ class map template BOOST_CONTAINER_FORCEINLINE map( ordered_unique_range_t, InputIterator first, InputIterator last - , const Compare& comp = Compare(), const allocator_type& a = allocator_type()) + , const Compare& comp, const allocator_type& a) : base_t(ordered_range, first, last, comp, a) { //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } + //! Effects: Constructs an empty map using the specified comparison object 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 + BOOST_CONTAINER_FORCEINLINE + map( ordered_unique_range_t, InputIterator first, InputIterator last + , const Compare& comp = Compare()) + : base_t(ordered_range, first, last, comp) + { + //A type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) //! Effects: Constructs an empty map using the specified comparison object and //! allocator, and inserts elements from the range [il.begin(), il.end()). @@ -227,13 +272,26 @@ class map //! Complexity: Linear in N if the range [first ,last ) is already sorted using //! comp and otherwise N logN, where N is il.first() - il.end(). BOOST_CONTAINER_FORCEINLINE - map(std::initializer_list il, const Compare& comp = Compare(), const allocator_type& a = allocator_type()) + map(std::initializer_list il, const Compare& comp, const allocator_type& a) : base_t(true, il.begin(), il.end(), comp, a) { //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } + //! Effects: Constructs an empty map using the specified comparison object and + //! inserts elements from the range [il.begin(), il.end()). + //! + //! Complexity: Linear in N if the range [first ,last ) is already sorted using + //! comp and otherwise N logN, where N is il.first() - il.end(). + BOOST_CONTAINER_FORCEINLINE + map(std::initializer_list il, const Compare& comp = Compare()) + : base_t(true, il.begin(), il.end(), comp) + { + //A type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } + //! Effects: Constructs an empty map using the specified //! allocator, and inserts elements from the range [il.begin(), il.end()). //! @@ -259,12 +317,30 @@ class map //! Note: Non-standard extension. BOOST_CONTAINER_FORCEINLINE map(ordered_unique_range_t, std::initializer_list il, const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) + const allocator_type& a) : base_t(ordered_range, il.begin(), il.end(), comp, a) { //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } + + //! Effects: Constructs an empty set using the specified comparison object and + //! allocator, and inserts elements from the ordered unique range [il.begin(), il.end()). This function + //! is more efficient than the normal range creation for ordered ranges. + //! + //! Requires: [il.begin(), il.end()) must be ordered according to the predicate and must be + //! unique values. + //! + //! Complexity: Linear in N. + //! + //! Note: Non-standard extension. + BOOST_CONTAINER_FORCEINLINE + map(ordered_unique_range_t, std::initializer_list il, const Compare& comp = Compare()) + : base_t(ordered_range, il.begin(), il.end(), comp) + { + //A type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } #endif //! Effects: Copy constructs a map. @@ -1268,14 +1344,29 @@ class multimap template BOOST_CONTAINER_FORCEINLINE multimap(InputIterator first, InputIterator last, - const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) + const Compare& comp, + const allocator_type& a) : base_t(false, first, last, comp, a) { //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } + //! Effects: Constructs an empty multimap using the specified comparison object and + //! inserts elements from the range [first ,last ). + //! + //! Complexity: Linear in N if the range [first ,last ) is already sorted using + //! comp and otherwise N logN, where N is last - first. + template + BOOST_CONTAINER_FORCEINLINE + multimap(InputIterator first, InputIterator last, + const Compare& comp = Compare()) + : base_t(false, first, last, comp) + { + //A type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } + //! Effects: Constructs an empty multimap using the specified //! allocator, and inserts elements from the range [first ,last ). //! @@ -1299,11 +1390,25 @@ class multimap //! //! Note: Non-standard extension. template - BOOST_CONTAINER_FORCEINLINE multimap(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) + BOOST_CONTAINER_FORCEINLINE multimap(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp, + const allocator_type& a) : base_t(ordered_range, first, last, comp, a) {} + //! Effects: Constructs an empty multimap using the specified comparison object 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 + BOOST_CONTAINER_FORCEINLINE multimap(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp = Compare()) + : base_t(ordered_range, first, last, comp) + {} + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) //! Effects: Constructs an empty multimap using the specified comparison object and //! allocator, and inserts elements from the range [il.begin(), il.end()). @@ -1312,13 +1417,26 @@ class multimap //! comp and otherwise N logN, where N is il.first() - il.end(). BOOST_CONTAINER_FORCEINLINE multimap(std::initializer_list il, const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) + const allocator_type& a) : base_t(false, il.begin(), il.end(), comp, a) { //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } + //! Effects: Constructs an empty multimap using the specified comparison object and + //! inserts elements from the range [il.begin(), il.end()). + //! + //! Complexity: Linear in N if the range [first ,last ) is already sorted using + //! comp and otherwise N logN, where N is il.first() - il.end(). + BOOST_CONTAINER_FORCEINLINE + multimap(std::initializer_list il, const Compare& comp = Compare()) + : base_t(false, il.begin(), il.end(), comp) + { + //A type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } + //! Effects: Constructs an empty multimap using the specified //! allocator, and inserts elements from the range [il.begin(), il.end()). //! @@ -1343,12 +1461,29 @@ class multimap //! Note: Non-standard extension. BOOST_CONTAINER_FORCEINLINE multimap(ordered_range_t, std::initializer_list il, const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) + const allocator_type& a) : base_t(ordered_range, il.begin(), il.end(), comp, a) { //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } + + //! Effects: Constructs an empty set using the specified comparison object and + //! inserts elements from the ordered range [il.begin(), il.end()). This function + //! is more efficient than the normal range creation for ordered ranges. + //! + //! Requires: [il.begin(), il.end()) must be ordered according to the predicate. + //! + //! Complexity: Linear in N. + //! + //! Note: Non-standard extension. + BOOST_CONTAINER_FORCEINLINE + multimap(ordered_range_t, std::initializer_list il, const Compare& comp = Compare()) + : base_t(ordered_range, il.begin(), il.end(), comp) + { + //A type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } #endif //! Effects: Copy constructs a multimap. From ec91367383d2c39040f55878ae2ab72926343b80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Tue, 16 May 2017 16:29:49 +0200 Subject: [PATCH 2/2] Review all associative containers and implement a different constructor overload to avoid any unnecessary copy construction of the predicate or the allocator. --- include/boost/container/detail/flat_tree.hpp | 145 +++- .../container/detail/node_alloc_holder.hpp | 18 +- include/boost/container/detail/tree.hpp | 157 ++-- include/boost/container/flat_map.hpp | 778 +++++++++++------- include/boost/container/flat_set.hpp | 362 ++++++-- include/boost/container/map.hpp | 571 ++++++------- include/boost/container/set.hpp | 343 ++++++-- test/emplace_test.hpp | 24 +- test/flat_map_test.cpp | 3 + test/flat_set_test.cpp | 3 + test/map_test.cpp | 13 +- test/map_test.hpp | 82 ++ test/set_test.cpp | 4 +- test/set_test.hpp | 105 ++- 14 files changed, 1694 insertions(+), 914 deletions(-) diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp index 89ff735..9aab873 100644 --- a/include/boost/container/detail/flat_tree.hpp +++ b/include/boost/container/detail/flat_tree.hpp @@ -132,6 +132,18 @@ class flat_tree : value_compare(), m_seq() {} + explicit Data(const allocator_t &alloc) + : value_compare(), m_seq(alloc) + {} + + explicit Data(const Compare &comp) + : value_compare(comp), m_seq() + {} + + Data(const Compare &comp, const allocator_t &alloc) + : value_compare(comp), m_seq(alloc) + {} + explicit Data(const Data &d) : value_compare(static_cast(d)), m_seq(d.m_seq) {} @@ -148,18 +160,6 @@ class flat_tree : value_compare(boost::move(static_cast(d))), m_seq(boost::move(d.m_seq), a) {} - explicit Data(const Compare &comp) - : value_compare(comp), m_seq() - {} - - Data(const Compare &comp, const allocator_t &alloc) - : value_compare(comp), m_seq(alloc) - {} - - explicit Data(const allocator_t &alloc) - : value_compare(), m_seq(alloc) - {} - Data& operator=(BOOST_COPY_ASSIGN_REF(Data) d) { this->value_compare::operator=(d); @@ -219,14 +219,14 @@ class flat_tree : m_data(comp) { } - BOOST_CONTAINER_FORCEINLINE flat_tree(const Compare& comp, const allocator_type& a) - : m_data(comp, a) - { } - BOOST_CONTAINER_FORCEINLINE explicit flat_tree(const allocator_type& a) : m_data(a) { } + BOOST_CONTAINER_FORCEINLINE flat_tree(const Compare& comp, const allocator_type& a) + : m_data(comp, a) + { } + BOOST_CONTAINER_FORCEINLINE flat_tree(const flat_tree& x) : m_data(x.m_data) { } @@ -245,9 +245,26 @@ class flat_tree { } template - flat_tree( ordered_range_t, InputIterator first, InputIterator last - , const Compare& comp = Compare() - , const allocator_type& a = allocator_type()) + BOOST_CONTAINER_FORCEINLINE + flat_tree( ordered_range_t, InputIterator first, InputIterator last) + : m_data() + { + this->m_data.m_seq.insert(this->m_data.m_seq.end(), first, last); + BOOST_ASSERT((is_sorted)(this->m_data.m_seq.cbegin(), this->m_data.m_seq.cend(), this->priv_value_comp())); + } + + template + BOOST_CONTAINER_FORCEINLINE + flat_tree( ordered_range_t, InputIterator first, InputIterator last, const Compare& comp) + : m_data(comp) + { + this->m_data.m_seq.insert(this->m_data.m_seq.end(), first, last); + BOOST_ASSERT((is_sorted)(this->m_data.m_seq.cbegin(), this->m_data.m_seq.cend(), this->priv_value_comp())); + } + + template + BOOST_CONTAINER_FORCEINLINE + flat_tree( ordered_range_t, InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a) : m_data(comp, a) { this->m_data.m_seq.insert(this->m_data.m_seq.end(), first, last); @@ -255,9 +272,26 @@ class flat_tree } template - flat_tree( ordered_unique_range_t, InputIterator first, InputIterator last - , const Compare& comp = Compare() - , const allocator_type& a = allocator_type()) + BOOST_CONTAINER_FORCEINLINE + flat_tree( ordered_unique_range_t, InputIterator first, InputIterator last) + : m_data() + { + this->m_data.m_seq.insert(this->m_data.m_seq.end(), first, last); + BOOST_ASSERT((is_sorted_and_unique)(this->m_data.m_seq.cbegin(), this->m_data.m_seq.cend(), this->priv_value_comp())); + } + + template + BOOST_CONTAINER_FORCEINLINE + flat_tree( ordered_unique_range_t, InputIterator first, InputIterator last, const Compare& comp) + : m_data(comp) + { + this->m_data.m_seq.insert(this->m_data.m_seq.end(), first, last); + BOOST_ASSERT((is_sorted_and_unique)(this->m_data.m_seq.cbegin(), this->m_data.m_seq.cend(), this->priv_value_comp())); + } + + template + BOOST_CONTAINER_FORCEINLINE + flat_tree( ordered_unique_range_t, InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a) : m_data(comp, a) { this->m_data.m_seq.insert(this->m_data.m_seq.end(), first, last); @@ -265,26 +299,38 @@ class flat_tree } template - flat_tree( bool unique_insertion - , InputIterator first, InputIterator last - , const Compare& comp = Compare() - , const allocator_type& a = allocator_type()) + BOOST_CONTAINER_FORCEINLINE + flat_tree( bool unique_insertion, InputIterator first, InputIterator last) + : m_data() + { + this->priv_range_insertion_construct(unique_insertion, first, last); + } + + template + BOOST_CONTAINER_FORCEINLINE + flat_tree( bool unique_insertion, InputIterator first, InputIterator last + , const Compare& comp) + : m_data(comp) + { + this->priv_range_insertion_construct(unique_insertion, first, last); + } + + template + BOOST_CONTAINER_FORCEINLINE + flat_tree( bool unique_insertion, InputIterator first, InputIterator last + , const allocator_type& a) + : m_data(a) + { + this->priv_range_insertion_construct(unique_insertion, first, last); + } + + template + BOOST_CONTAINER_FORCEINLINE + flat_tree( bool unique_insertion, InputIterator first, InputIterator last + , const Compare& comp, const allocator_type& a) : m_data(comp, a) { - //Use cend() as hint to achieve linear time for - //ordered ranges as required by the standard - //for the constructor - //Call end() every iteration as reallocation might have invalidated iterators - if(unique_insertion){ - for ( ; first != last; ++first){ - this->insert_unique(this->cend(), *first); - } - } - else{ - for ( ; first != last; ++first){ - this->insert_equal(this->cend(), *first); - } - } + this->priv_range_insertion_construct(unique_insertion, first, last); } BOOST_CONTAINER_FORCEINLINE ~flat_tree() @@ -923,6 +969,25 @@ class flat_tree private: + template + void priv_range_insertion_construct( bool unique_insertion, InputIterator first, InputIterator last) + { + //Use cend() as hint to achieve linear time for + //ordered ranges as required by the standard + //for the constructor + //Call end() every iteration as reallocation might have invalidated iterators + if(unique_insertion){ + for ( ; first != last; ++first){ + this->insert_unique(this->cend(), *first); + } + } + else{ + for ( ; first != last; ++first){ + this->insert_equal(this->cend(), *first); + } + } + } + BOOST_CONTAINER_FORCEINLINE bool priv_in_range_or_end(const_iterator pos) const { return (this->begin() <= pos) && (pos <= this->end()); diff --git a/include/boost/container/detail/node_alloc_holder.hpp b/include/boost/container/detail/node_alloc_holder.hpp index 0341ce1..b6e602e 100644 --- a/include/boost/container/detail/node_alloc_holder.hpp +++ b/include/boost/container/detail/node_alloc_holder.hpp @@ -106,23 +106,23 @@ struct node_alloc_holder : members_(a) {} + //Constructors for associative containers + node_alloc_holder(const value_compare &c, const ValAlloc &a) + : members_(a, c) + {} + explicit node_alloc_holder(const node_alloc_holder &x) : members_(NodeAllocTraits::select_on_container_copy_construction(x.node_alloc())) {} + node_alloc_holder(const node_alloc_holder &x, const value_compare &c) + : members_(NodeAllocTraits::select_on_container_copy_construction(x.node_alloc()), c) + {} + explicit node_alloc_holder(BOOST_RV_REF(node_alloc_holder) x) : members_(boost::move(x.node_alloc())) { this->icont().swap(x.icont()); } - //Constructors for associative containers - explicit node_alloc_holder(const value_compare &c, const ValAlloc &a) - : members_(a, c) - {} - - explicit node_alloc_holder(const value_compare &c, const node_alloc_holder &x) - : members_(NodeAllocTraits::select_on_container_copy_construction(x.node_alloc()), c) - {} - explicit node_alloc_holder(const value_compare &c) : members_(c) {} diff --git a/include/boost/container/detail/tree.hpp b/include/boost/container/detail/tree.hpp index 2524eed..99baf3a 100644 --- a/include/boost/container/detail/tree.hpp +++ b/include/boost/container/detail/tree.hpp @@ -509,7 +509,11 @@ class tree : AllocHolder() {} - BOOST_CONTAINER_FORCEINLINE explicit tree(const key_compare& comp, const allocator_type& a = allocator_type()) + BOOST_CONTAINER_FORCEINLINE explicit tree(const key_compare& comp) + : AllocHolder(ValComp(comp)) + {} + + BOOST_CONTAINER_FORCEINLINE explicit tree(const key_compare& comp, const allocator_type& a) : AllocHolder(ValComp(comp), a) {} @@ -518,85 +522,110 @@ class tree {} template - tree(bool unique_insertion, InputIterator first, InputIterator last, const key_compare& comp, - const allocator_type& a = allocator_type() - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::enable_if_or - < void - , container_detail::is_same - , container_detail::is_input_iterator - >::type * = 0 - #endif - ) + tree(bool unique_insertion, InputIterator first, InputIterator last) + : AllocHolder(value_compare(key_compare())) + { + this->tree_construct(unique_insertion, first, last); + //AllocHolder clears in case of exception + } + + template + tree(bool unique_insertion, InputIterator first, InputIterator last, const key_compare& comp) + : AllocHolder(value_compare(comp)) + { + this->tree_construct(unique_insertion, first, last); + //AllocHolder clears in case of exception + } + + template + tree(bool unique_insertion, InputIterator first, InputIterator last, const key_compare& comp, const allocator_type& a) : AllocHolder(value_compare(comp), a) + { + this->tree_construct(unique_insertion, first, last); + //AllocHolder clears in case of exception + } + + //construct with ordered range + template + tree( ordered_range_t, InputIterator first, InputIterator last) + : AllocHolder(value_compare(key_compare())) + { + this->tree_construct(ordered_range_t(), first, last); + } + + template + tree( ordered_range_t, InputIterator first, InputIterator last, const key_compare& comp) + : AllocHolder(value_compare(comp)) + { + this->tree_construct(ordered_range_t(), first, last); + } + + template + tree( ordered_range_t, InputIterator first, InputIterator last + , const key_compare& comp, const allocator_type& a) + : AllocHolder(value_compare(comp), a) + { + this->tree_construct(ordered_range_t(), first, last); + } + + private: + + template + void tree_construct(bool unique_insertion, InputIterator first, InputIterator last) { //Use cend() as hint to achieve linear time for //ordered ranges as required by the standard //for the constructor - const const_iterator end_it(this->cend()); if(unique_insertion){ - for ( ; first != last; ++first){ - this->insert_unique_convertible(end_it, *first); - } - } - else{ - for ( ; first != last; ++first){ - this->insert_equal_convertible(end_it, *first); - } - } - } - - template - tree(bool unique_insertion, InputIterator first, InputIterator last, const key_compare& comp, - const allocator_type& a = allocator_type() - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::disable_if_or - < void - , container_detail::is_same - , container_detail::is_input_iterator - >::type * = 0 - #endif - ) - : AllocHolder(value_compare(comp), a) - { - if(unique_insertion){ - //Use cend() as hint to achieve linear time for - //ordered ranges as required by the standard - //for the constructor const const_iterator end_it(this->cend()); for ( ; first != last; ++first){ this->insert_unique_convertible(end_it, *first); } } else{ - //Optimized allocation and construction - this->allocate_many_and_construct - ( first, boost::container::iterator_distance(first, last) - , insert_equal_end_hint_functor(this->icont())); + this->tree_construct_non_unique(first, last); } } template - tree( ordered_range_t, InputIterator first, InputIterator last - , const key_compare& comp = key_compare(), const allocator_type& a = allocator_type() - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + void tree_construct_non_unique(InputIterator first, InputIterator last + #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) , typename container_detail::enable_if_or < void , container_detail::is_same , container_detail::is_input_iterator >::type * = 0 - #endif + #endif ) - : AllocHolder(value_compare(comp), a) { + //Use cend() as hint to achieve linear time for + //ordered ranges as required by the standard + //for the constructor + const const_iterator end_it(this->cend()); for ( ; first != last; ++first){ - this->push_back_impl(*first); + this->insert_equal_convertible(end_it, *first); } } template - tree( ordered_range_t, InputIterator first, InputIterator last - , const key_compare& comp = key_compare(), const allocator_type& a = allocator_type() + void tree_construct_non_unique(InputIterator first, InputIterator last + #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + , typename container_detail::disable_if_or + < void + , container_detail::is_same + , container_detail::is_input_iterator + >::type * = 0 + #endif + ) + { + //Optimized allocation and construction + this->allocate_many_and_construct + ( first, boost::container::iterator_distance(first, last) + , insert_equal_end_hint_functor(this->icont())); + } + + template + void tree_construct( ordered_range_t, InputIterator first, InputIterator last #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) , typename container_detail::disable_if_or < void @@ -605,16 +634,34 @@ class tree >::type * = 0 #endif ) - : AllocHolder(value_compare(comp), a) { //Optimized allocation and construction this->allocate_many_and_construct ( first, boost::container::iterator_distance(first, last) , container_detail::push_back_functor(this->icont())); + //AllocHolder clears in case of exception } + template + void tree_construct( ordered_range_t, InputIterator first, InputIterator last + #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + , typename container_detail::enable_if_or + < void + , container_detail::is_same + , container_detail::is_input_iterator + >::type * = 0 + #endif + ) + { + for ( ; first != last; ++first){ + this->push_back_impl(*first); + } + } + + public: + BOOST_CONTAINER_FORCEINLINE tree(const tree& x) - : AllocHolder(x.value_comp(), x) + : AllocHolder(x, x.value_comp()) { this->icont().clone_from (x.icont(), typename AllocHolder::cloner(*this), Destroyer(this->node_alloc())); @@ -630,6 +677,7 @@ class tree { this->icont().clone_from (x.icont(), typename AllocHolder::cloner(*this), Destroyer(this->node_alloc())); + //AllocHolder clears in case of exception } tree(BOOST_RV_REF(tree) x, const allocator_type &a) @@ -642,6 +690,7 @@ class tree this->icont().clone_from (boost::move(x.icont()), typename AllocHolder::move_cloner(*this), Destroyer(this->node_alloc())); } + //AllocHolder clears in case of exception } BOOST_CONTAINER_FORCEINLINE ~tree() diff --git a/include/boost/container/flat_map.hpp b/include/boost/container/flat_map.hpp index ebfd44e..56f12ec 100644 --- a/include/boost/container/flat_map.hpp +++ b/include/boost/container/flat_map.hpp @@ -59,14 +59,15 @@ class flat_multimap; namespace container_detail{ template -BOOST_CONTAINER_FORCEINLINE static D &force(const S &s) -{ return *const_cast((reinterpret_cast(&s))); } +BOOST_CONTAINER_FORCEINLINE static D &force(S &s) +{ return *reinterpret_cast(&s); } template -BOOST_CONTAINER_FORCEINLINE static D force_copy(S s) +BOOST_CONTAINER_FORCEINLINE static D force_copy(const S &s) { - D *vp = reinterpret_cast(&s); - return D(*vp); + const D *const vp = reinterpret_cast(&s); + D ret_val(*vp); + return ret_val; } } //namespace container_detail{ @@ -149,10 +150,10 @@ class flat_map typedef typename impl_tree_t::stored_allocator_type impl_stored_allocator_type; typedef typename impl_tree_t::sequence_type impl_sequence_type; - impl_tree_t &tree() + BOOST_CONTAINER_FORCEINLINE impl_tree_t &tree() { return m_flat_tree; } - const impl_tree_t &tree() const + BOOST_CONTAINER_FORCEINLINE const impl_tree_t &tree() const { return m_flat_tree; } private: @@ -186,7 +187,9 @@ class flat_map typedef BOOST_CONTAINER_IMPDEF(impl_value_type) movable_value_type; typedef typename BOOST_CONTAINER_IMPDEF(tree_t::sequence_type) sequence_type; - public: + //Allocator::value_type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + ////////////////////////////////////////////// // // construct/copy/destroy @@ -196,106 +199,183 @@ class flat_map //! Effects: Default constructs an empty flat_map. //! //! Complexity: Constant. - flat_map() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value && - container_detail::is_nothrow_default_constructible::value) + flat_map() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value && + container_detail::is_nothrow_default_constructible::value) : m_flat_tree() - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} + + //! Effects: Constructs an empty flat_map using the specified allocator. + //! + //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE explicit flat_map(const allocator_type& a) + : m_flat_tree(container_detail::force(a)) + {} + + //! Effects: Constructs an empty flat_map using the specified + //! comparison object. + //! + //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE explicit flat_map(const Compare& comp) + : m_flat_tree(comp) + {} //! Effects: Constructs an empty flat_map using the specified //! comparison object and allocator. //! //! Complexity: Constant. - explicit flat_map(const Compare& comp, const allocator_type& a = allocator_type()) - : m_flat_tree(comp, container_detail::force(a)) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + BOOST_CONTAINER_FORCEINLINE flat_map(const Compare& comp, const allocator_type& a) + : m_flat_tree(comp, container_detail::force(a)) + {} - //! Effects: Constructs an empty flat_map using the specified allocator. - //! - //! Complexity: Constant. - explicit flat_map(const allocator_type& a) - : m_flat_tree(container_detail::force(a)) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Constructs an empty flat_map using the specified comparison object and - //! allocator, and inserts elements from the range [first ,last ). + //! Effects: Constructs an empty flat_map and + //! and inserts elements from the range [first ,last ). //! //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is last - first. + //! the predicate and otherwise N logN, where N is last - first. template - flat_map(InputIterator first, InputIterator last, const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) - : m_flat_tree(true, first, last, comp, container_detail::force(a)) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + BOOST_CONTAINER_FORCEINLINE flat_map(InputIterator first, InputIterator last) + : m_flat_tree(true, first, last) + {} //! Effects: Constructs an empty flat_map using the specified //! allocator, and inserts elements from the range [first ,last ). //! //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is last - first. + //! the predicate and otherwise N logN, where N is last - first. template - flat_map(InputIterator first, InputIterator last, const allocator_type& a) - : m_flat_tree(true, first, last, Compare(), container_detail::force(a)) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + BOOST_CONTAINER_FORCEINLINE flat_map(InputIterator first, InputIterator last, const allocator_type& a) + : m_flat_tree(true, first, last, container_detail::force(a)) + {} //! Effects: Constructs an empty flat_map using the specified comparison object and - //! allocator, and inserts elements from the ordered unique range [first ,last). This function + //! and inserts elements from the range [first ,last ). + //! + //! Complexity: Linear in N if the range [first ,last ) is already sorted using + //! the predicate and otherwise N logN, where N is last - first. + template + BOOST_CONTAINER_FORCEINLINE flat_map(InputIterator first, InputIterator last, const Compare& comp) + : m_flat_tree(true, first, last, comp) + {} + + //! 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 + //! the predicate and otherwise N logN, where N is last - first. + template + BOOST_CONTAINER_FORCEINLINE flat_map(InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a) + : m_flat_tree(true, first, last, comp, container_detail::force(a)) + {} + + //! Effects: Constructs an empty flat_map + //! 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 and must be - //! unique values. + //! Requires: [first ,last) must be ordered according to the predicate. //! //! Complexity: Linear in N. //! //! Note: Non-standard extension. template - flat_map( ordered_unique_range_t, InputIterator first, InputIterator last - , const Compare& comp = Compare(), const allocator_type& a = allocator_type()) - : m_flat_tree(ordered_unique_range, first, last, comp, a) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + BOOST_CONTAINER_FORCEINLINE + flat_map(ordered_unique_range_t, InputIterator first, InputIterator last) + : m_flat_tree(ordered_range, first, last) + {} + + //! Effects: Constructs an empty flat_map using the specified comparison object 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 + BOOST_CONTAINER_FORCEINLINE + flat_map(ordered_unique_range_t, InputIterator first, InputIterator last, const Compare& comp) + : m_flat_tree(ordered_range, first, last, comp) + {} + + //! Effects: Constructs an empty flat_map 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 + BOOST_CONTAINER_FORCEINLINE + flat_map(ordered_unique_range_t, InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a) + : m_flat_tree(ordered_range, first, last, comp, a) + {} #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Constructs an empty flat_map using the specified comparison object and - //! allocator, and inserts elements from the range [il.begin() ,il.end()). + //! Effects: Constructs an empty flat_map and + //! inserts elements from the range [il.begin() ,il.end()). //! //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using - //! comp and otherwise N logN, where N is last - first. - flat_map(std::initializer_list il, const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) - : m_flat_tree(true, il.begin(), il.end(), comp, container_detail::force(a)) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + //! the predicate and otherwise N logN, where N is last - first. + BOOST_CONTAINER_FORCEINLINE flat_map(std::initializer_list il) + : m_flat_tree(true, il.begin(), il.end()) + {} //! Effects: Constructs an empty flat_map using the specified //! allocator, and inserts elements from the range [il.begin() ,il.end()). //! //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using - //! comp and otherwise N logN, where N is last - first. - flat_map(std::initializer_list il, const allocator_type& a) - : m_flat_tree(true, il.begin(), il.end(), Compare(), container_detail::force(a)) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + //! the predicate and otherwise N logN, where N is last - first. + BOOST_CONTAINER_FORCEINLINE flat_map(std::initializer_list il, const allocator_type& a) + : m_flat_tree(true, il.begin(), il.end(), container_detail::force(a)) + {} + + //! Effects: Constructs an empty flat_map using the specified comparison object and + //! inserts elements from the range [il.begin() ,il.end()). + //! + //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using + //! the predicate and otherwise N logN, where N is last - first. + BOOST_CONTAINER_FORCEINLINE flat_map(std::initializer_list il, const Compare& comp) + : m_flat_tree(true, il.begin(), il.end(), comp) + {} + + //! Effects: Constructs an empty flat_map using the specified comparison object and + //! allocator, and inserts elements from the range [il.begin() ,il.end()). + //! + //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using + //! the predicate and otherwise N logN, where N is last - first. + BOOST_CONTAINER_FORCEINLINE flat_map(std::initializer_list il, const Compare& comp, const allocator_type& a) + : m_flat_tree(true, il.begin(), il.end(), comp, container_detail::force(a)) + {} + + //! Effects: Constructs an empty flat_map using and + //! inserts elements from the ordered unique range [il.begin(), il.end()). This function + //! is more efficient than the normal range creation for ordered ranges. + //! + //! Requires: [il.begin(), il.end()) must be ordered according to the predicate and must be + //! unique values. + //! + //! Complexity: Linear in N. + //! + //! Note: Non-standard extension. + BOOST_CONTAINER_FORCEINLINE flat_map(ordered_unique_range_t, std::initializer_list il) + : m_flat_tree(ordered_unique_range, il.begin(), il.end()) + {} + + //! Effects: Constructs an empty flat_map using the specified comparison object and + //! inserts elements from the ordered unique range [il.begin(), il.end()). This function + //! is more efficient than the normal range creation for ordered ranges. + //! + //! Requires: [il.begin(), il.end()) must be ordered according to the predicate and must be + //! unique values. + //! + //! Complexity: Linear in N. + //! + //! Note: Non-standard extension. + BOOST_CONTAINER_FORCEINLINE flat_map(ordered_unique_range_t, std::initializer_list il, const Compare& comp) + : m_flat_tree(ordered_unique_range, il.begin(), il.end(), comp) + {} //! Effects: Constructs an empty flat_map using the specified comparison object and //! allocator, and inserts elements from the ordered unique range [il.begin(), il.end()). This function @@ -307,24 +387,17 @@ class flat_map //! Complexity: Linear in N. //! //! Note: Non-standard extension. - flat_map(ordered_unique_range_t, std::initializer_list il, const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) + BOOST_CONTAINER_FORCEINLINE flat_map(ordered_unique_range_t, std::initializer_list il, const Compare& comp, const allocator_type& a) : m_flat_tree(ordered_unique_range, il.begin(), il.end(), comp, a) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} #endif //! Effects: Copy constructs a flat_map. //! //! Complexity: Linear in x.size(). - flat_map(const flat_map& x) + BOOST_CONTAINER_FORCEINLINE flat_map(const flat_map& x) : m_flat_tree(x.m_flat_tree) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Move constructs a flat_map. //! Constructs *this using x's resources. @@ -332,39 +405,30 @@ class flat_map //! Complexity: Constant. //! //! Postcondition: x is emptied. - flat_map(BOOST_RV_REF(flat_map) x) + BOOST_CONTAINER_FORCEINLINE flat_map(BOOST_RV_REF(flat_map) x) BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible::value) : m_flat_tree(boost::move(x.m_flat_tree)) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! 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) + BOOST_CONTAINER_FORCEINLINE flat_map(const flat_map& x, const allocator_type &a) : m_flat_tree(x.m_flat_tree, a) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! 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) + BOOST_CONTAINER_FORCEINLINE flat_map(BOOST_RV_REF(flat_map) x, const allocator_type &a) : m_flat_tree(boost::move(x.m_flat_tree), a) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Makes *this a copy of x. //! //! Complexity: Linear in x.size(). - flat_map& operator=(BOOST_COPY_ASSIGN_REF(flat_map) x) + BOOST_CONTAINER_FORCEINLINE 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. @@ -376,7 +440,7 @@ class flat_map //! Complexity: Constant if allocator_traits_type:: //! propagate_on_container_move_assignment is true or //! this->get>allocator() == x.get_allocator(). Linear otherwise. - flat_map& operator=(BOOST_RV_REF(flat_map) x) + BOOST_CONTAINER_FORCEINLINE flat_map& operator=(BOOST_RV_REF(flat_map) x) BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value || allocator_traits_type::is_always_equal::value) && boost::container::container_detail::is_nothrow_move_assignable::value) @@ -396,7 +460,7 @@ class flat_map //! was passed to the object's constructor. //! //! Complexity: Constant. - allocator_type get_allocator() const BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE allocator_type get_allocator() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.get_allocator()); } //! Effects: Returns a reference to the internal allocator. @@ -406,7 +470,7 @@ class flat_map //! Complexity: Constant. //! //! Note: Non-standard extension. - stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force(m_flat_tree.get_stored_allocator()); } //! Effects: Returns a reference to the internal allocator. @@ -416,8 +480,8 @@ class flat_map //! Complexity: Constant. //! //! Note: Non-standard extension. - const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW - { return container_detail::force(m_flat_tree.get_stored_allocator()); } + BOOST_CONTAINER_FORCEINLINE const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW + { return container_detail::force(m_flat_tree.get_stored_allocator()); } ////////////////////////////////////////////// // @@ -430,7 +494,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - iterator begin() BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE iterator begin() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.begin()); } //! Effects: Returns a const_iterator to the first element contained in the container. @@ -438,7 +502,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.begin()); } //! Effects: Returns an iterator to the end of the container. @@ -446,7 +510,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - iterator end() BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE iterator end() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.end()); } //! Effects: Returns a const_iterator to the end of the container. @@ -454,7 +518,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.end()); } //! Effects: Returns a reverse_iterator pointing to the beginning @@ -463,7 +527,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.rbegin()); } //! Effects: Returns a const_reverse_iterator pointing to the beginning @@ -472,7 +536,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.rbegin()); } //! Effects: Returns a reverse_iterator pointing to the end @@ -481,7 +545,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.rend()); } //! Effects: Returns a const_reverse_iterator pointing to the end @@ -490,7 +554,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.rend()); } //! Effects: Returns a const_iterator to the first element contained in the container. @@ -498,7 +562,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.cbegin()); } //! Effects: Returns a const_iterator to the end of the container. @@ -506,7 +570,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.cend()); } //! Effects: Returns a const_reverse_iterator pointing to the beginning @@ -515,7 +579,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.crbegin()); } //! Effects: Returns a const_reverse_iterator pointing to the end @@ -524,7 +588,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.crend()); } ////////////////////////////////////////////// @@ -538,7 +602,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - bool empty() const BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE bool empty() const BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.empty(); } //! Effects: Returns the number of the elements contained in the container. @@ -546,7 +610,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - size_type size() const BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE size_type size() const BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.size(); } //! Effects: Returns the largest possible size of the container. @@ -554,7 +618,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.max_size(); } //! Effects: Number of elements for which memory has been allocated. @@ -563,7 +627,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - size_type capacity() const BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE size_type capacity() const BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.capacity(); } //! Effects: If n is less than or equal to capacity(), this call has no @@ -575,7 +639,7 @@ class flat_map //! //! Note: If capacity() is less than "cnt", iterators and references to //! to values might be invalidated. - void reserve(size_type cnt) + BOOST_CONTAINER_FORCEINLINE void reserve(size_type cnt) { m_flat_tree.reserve(cnt); } //! Effects: Tries to deallocate the excess of memory created @@ -584,7 +648,7 @@ class flat_map //! Throws: If memory allocation throws, or T's copy constructor throws. //! //! Complexity: Linear to size(). - void shrink_to_fit() + BOOST_CONTAINER_FORCEINLINE void shrink_to_fit() { m_flat_tree.shrink_to_fit(); } ////////////////////////////////////////////// @@ -611,8 +675,8 @@ class flat_map mapped_type &operator[](key_type &&k) ; #elif defined(BOOST_MOVE_HELPERS_RETURN_SFINAE_BROKEN) //in compilers like GCC 3.4, we can't catch temporaries - mapped_type& operator[](const key_type &k) { return this->priv_subscript(k); } - mapped_type& operator[](BOOST_RV_REF(key_type) k) { return this->priv_subscript(::boost::move(k)); } + BOOST_CONTAINER_FORCEINLINE mapped_type& operator[](const key_type &k) { return this->priv_subscript(k); } + BOOST_CONTAINER_FORCEINLINE mapped_type& operator[](BOOST_RV_REF(key_type) k) { return this->priv_subscript(::boost::move(k)); } #else BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript) #endif @@ -708,19 +772,19 @@ class flat_map } //! @copydoc ::boost::container::flat_set::nth(size_type) - iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.nth(n)); } //! @copydoc ::boost::container::flat_set::nth(size_type) const - const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.nth(n)); } //! @copydoc ::boost::container::flat_set::index_of(iterator) - size_type index_of(iterator p) BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE size_type index_of(iterator p) BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.index_of(container_detail::force_copy(p)); } //! @copydoc ::boost::container::flat_set::index_of(const_iterator) const - size_type index_of(const_iterator p) const BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE size_type index_of(const_iterator p) const BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.index_of(container_detail::force_copy(p)); } //! Returns: A reference to the element whose key is equivalent to x. @@ -772,7 +836,7 @@ class flat_map //! //! Note: If an element is inserted it might invalidate elements. template - std::pair emplace(BOOST_FWD_REF(Args)... args) + BOOST_CONTAINER_FORCEINLINE std::pair emplace(BOOST_FWD_REF(Args)... args) { return container_detail::force_copy< std::pair >(m_flat_tree.emplace_unique(boost::forward(args)...)); } //! Effects: Inserts an object of type T constructed with @@ -788,7 +852,7 @@ class flat_map //! //! Note: If an element is inserted it might invalidate elements. template - iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args) + BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args) { return container_detail::force_copy (m_flat_tree.emplace_hint_unique( container_detail::force_copy(hint) @@ -872,14 +936,14 @@ class flat_map #define BOOST_CONTAINER_FLAT_MAP_EMPLACE_CODE(N) \ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ - std::pair emplace(BOOST_MOVE_UREF##N)\ + BOOST_CONTAINER_FORCEINLINE std::pair emplace(BOOST_MOVE_UREF##N)\ {\ return container_detail::force_copy< std::pair >\ (m_flat_tree.emplace_unique(BOOST_MOVE_FWD##N));\ }\ \ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ - iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ {\ return container_detail::force_copy(m_flat_tree.emplace_hint_unique\ (container_detail::force_copy(hint) BOOST_MOVE_I##N BOOST_MOVE_FWD##N));\ @@ -924,9 +988,9 @@ 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) + BOOST_CONTAINER_FORCEINLINE std::pair insert(const value_type& x) { return container_detail::force_copy >( - m_flat_tree.insert_unique(container_detail::force(x))); } + 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. @@ -939,7 +1003,7 @@ class flat_map //! to the elements with bigger keys than x. //! //! Note: If an element is inserted it might invalidate elements. - std::pair insert(BOOST_RV_REF(value_type) x) + BOOST_CONTAINER_FORCEINLINE std::pair insert(BOOST_RV_REF(value_type) x) { return container_detail::force_copy >( m_flat_tree.insert_unique(boost::move(container_detail::force(x)))); } @@ -954,7 +1018,7 @@ class flat_map //! to the elements with bigger keys than x. //! //! Note: If an element is inserted it might invalidate elements. - std::pair insert(BOOST_RV_REF(movable_value_type) x) + BOOST_CONTAINER_FORCEINLINE std::pair insert(BOOST_RV_REF(movable_value_type) x) { return container_detail::force_copy > (m_flat_tree.insert_unique(boost::move(x))); @@ -971,11 +1035,11 @@ class flat_map //! right before p) plus insertion linear to the elements with bigger keys than x. //! //! Note: If an element is inserted it might invalidate elements. - iterator insert(const_iterator p, const value_type& x) + BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator p, const value_type& x) { return container_detail::force_copy( m_flat_tree.insert_unique( container_detail::force_copy(p) - , container_detail::force(x))); + , container_detail::force(x))); } //! Effects: Inserts an element move constructed from x in the container. @@ -987,7 +1051,7 @@ class flat_map //! right before p) plus insertion linear to the elements with bigger keys than x. //! //! Note: If an element is inserted it might invalidate elements. - iterator insert(const_iterator p, BOOST_RV_REF(value_type) x) + BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator p, BOOST_RV_REF(value_type) x) { return container_detail::force_copy (m_flat_tree.insert_unique( container_detail::force_copy(p) @@ -1003,7 +1067,7 @@ class flat_map //! right before p) plus insertion linear to the elements with bigger keys than x. //! //! Note: If an element is inserted it might invalidate elements. - iterator insert(const_iterator p, BOOST_RV_REF(movable_value_type) x) + BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator p, BOOST_RV_REF(movable_value_type) x) { return container_detail::force_copy( m_flat_tree.insert_unique(container_detail::force_copy(p), boost::move(x))); @@ -1019,7 +1083,7 @@ class flat_map //! //! Note: If an element is inserted it might invalidate elements. template - void insert(InputIterator first, InputIterator last) + BOOST_CONTAINER_FORCEINLINE void insert(InputIterator first, InputIterator last) { m_flat_tree.insert_unique(first, last); } //! Requires: first, last are not iterators into *this. @@ -1038,7 +1102,7 @@ class flat_map //! //! Note: Non-standard extension. template - void insert(ordered_unique_range_t, InputIterator first, InputIterator last) + BOOST_CONTAINER_FORCEINLINE void insert(ordered_unique_range_t, InputIterator first, InputIterator last) { m_flat_tree.insert_unique(ordered_unique_range, first, last); } #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) @@ -1049,7 +1113,7 @@ class flat_map //! search time plus N*size() insertion time. //! //! Note: If an element is inserted it might invalidate elements. - void insert(std::initializer_list il) + BOOST_CONTAINER_FORCEINLINE void insert(std::initializer_list il) { m_flat_tree.insert_unique(il.begin(), il.end()); } //! Requires: [il.begin(), il.end()) must be ordered according to the predicate and must be @@ -1065,7 +1129,7 @@ class flat_map //! Note: If an element is inserted it might invalidate elements. //! //! Note: Non-standard extension. - void insert(ordered_unique_range_t, std::initializer_list il) + BOOST_CONTAINER_FORCEINLINE void insert(ordered_unique_range_t, std::initializer_list il) { m_flat_tree.insert_unique(ordered_unique_range, il.begin(), il.end()); } #endif @@ -1112,7 +1176,7 @@ class flat_map //! //! Note: Invalidates elements with keys //! not less than the erased element. - iterator erase(const_iterator p) + BOOST_CONTAINER_FORCEINLINE iterator erase(const_iterator p) { return container_detail::force_copy (m_flat_tree.erase(container_detail::force_copy(p))); @@ -1124,7 +1188,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) + BOOST_CONTAINER_FORCEINLINE 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 +1199,7 @@ class flat_map //! //! Complexity: Logarithmic search time plus erasure time //! linear to the elements with bigger keys. - iterator erase(const_iterator first, const_iterator last) + BOOST_CONTAINER_FORCEINLINE iterator erase(const_iterator first, const_iterator last) { return container_detail::force_copy( m_flat_tree.erase( container_detail::force_copy(first) @@ -1147,7 +1211,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - void swap(flat_map& x) + BOOST_CONTAINER_FORCEINLINE void swap(flat_map& x) BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value && boost::container::container_detail::is_nothrow_swappable::value ) { m_flat_tree.swap(x.m_flat_tree); } @@ -1157,7 +1221,7 @@ class flat_map //! Postcondition: size() == 0. //! //! Complexity: linear in size(). - void clear() BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE void clear() BOOST_NOEXCEPT_OR_NOTHROW { m_flat_tree.clear(); } ////////////////////////////////////////////// @@ -1170,14 +1234,14 @@ class flat_map //! of which a was constructed. //! //! Complexity: Constant. - key_compare key_comp() const + BOOST_CONTAINER_FORCEINLINE key_compare key_comp() const { return container_detail::force_copy(m_flat_tree.key_comp()); } //! Effects: Returns an object of value_compare constructed out //! of the comparison object. //! //! Complexity: Constant. - value_compare value_comp() const + BOOST_CONTAINER_FORCEINLINE value_compare value_comp() const { return value_compare(container_detail::force_copy(m_flat_tree.key_comp())); } ////////////////////////////////////////////// @@ -1190,60 +1254,60 @@ class flat_map //! equivalent to x, or end() if such an element is not found. //! //! Complexity: Logarithmic. - iterator find(const key_type& x) + BOOST_CONTAINER_FORCEINLINE 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. - const_iterator find(const key_type& x) const + BOOST_CONTAINER_FORCEINLINE const_iterator find(const key_type& x) const { return container_detail::force_copy(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 + BOOST_CONTAINER_FORCEINLINE size_type count(const key_type& x) const { return static_cast(m_flat_tree.find(x) != m_flat_tree.end()); } //! 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) + BOOST_CONTAINER_FORCEINLINE 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 + BOOST_CONTAINER_FORCEINLINE const_iterator lower_bound(const key_type& x) const { return container_detail::force_copy(m_flat_tree.lower_bound(x)); } //! Returns: An iterator pointing to the first element with key not less //! than x, or end() if such an element is not found. //! //! Complexity: Logarithmic. - iterator upper_bound(const key_type& x) + BOOST_CONTAINER_FORCEINLINE 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 + BOOST_CONTAINER_FORCEINLINE const_iterator upper_bound(const key_type& x) const { return container_detail::force_copy(m_flat_tree.upper_bound(x)); } //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). //! //! Complexity: Logarithmic. - std::pair equal_range(const key_type& x) + BOOST_CONTAINER_FORCEINLINE std::pair equal_range(const key_type& x) { return container_detail::force_copy >(m_flat_tree.lower_bound_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 + BOOST_CONTAINER_FORCEINLINE std::pair equal_range(const key_type& x) const { return container_detail::force_copy >(m_flat_tree.lower_bound_range(x)); } //! Effects: Extracts the internal sequence container. @@ -1253,7 +1317,7 @@ class flat_map //! Postcondition: this->empty() //! //! Throws: If secuence_type's move constructor throws - sequence_type extract_sequence() + BOOST_CONTAINER_FORCEINLINE sequence_type extract_sequence() { return boost::move(container_detail::force(m_flat_tree.get_sequence_ref())); } @@ -1264,7 +1328,7 @@ class flat_map //! Complexity: Assuming O(1) move assignment, O(NlogN) with N = seq.size() //! //! Throws: If the comparison or the move constructor throws - void adopt_sequence(BOOST_RV_REF(sequence_type) seq) + BOOST_CONTAINER_FORCEINLINE void adopt_sequence(BOOST_RV_REF(sequence_type) seq) { this->m_flat_tree.adopt_sequence_unique(boost::move(container_detail::force(seq))); } //! Requires: seq shall be ordered according to this->compare() @@ -1276,49 +1340,49 @@ class flat_map //! Complexity: Assuming O(1) move assignment, O(1) //! //! Throws: If the move assignment throws - void adopt_sequence(ordered_unique_range_t, BOOST_RV_REF(sequence_type) seq) + BOOST_CONTAINER_FORCEINLINE void adopt_sequence(ordered_unique_range_t, BOOST_RV_REF(sequence_type) seq) { this->m_flat_tree.adopt_sequence_unique(ordered_unique_range_t(), boost::move(container_detail::force(seq))); } //! Effects: Returns true if x and y are equal //! //! Complexity: Linear to the number of elements in the container. - friend bool operator==(const flat_map& x, const flat_map& y) + BOOST_CONTAINER_FORCEINLINE friend bool operator==(const flat_map& x, const flat_map& y) { return x.size() == y.size() && ::boost::container::algo_equal(x.begin(), x.end(), y.begin()); } //! Effects: Returns true if x and y are unequal //! //! Complexity: Linear to the number of elements in the container. - friend bool operator!=(const flat_map& x, const flat_map& y) + BOOST_CONTAINER_FORCEINLINE friend bool operator!=(const flat_map& x, const flat_map& y) { return !(x == y); } //! Effects: Returns true if x is less than y //! //! Complexity: Linear to the number of elements in the container. - friend bool operator<(const flat_map& x, const flat_map& y) + BOOST_CONTAINER_FORCEINLINE friend bool operator<(const flat_map& x, const flat_map& y) { return ::boost::container::algo_lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } //! Effects: Returns true if x is greater than y //! //! Complexity: Linear to the number of elements in the container. - friend bool operator>(const flat_map& x, const flat_map& y) + BOOST_CONTAINER_FORCEINLINE friend bool operator>(const flat_map& x, const flat_map& y) { return y < x; } //! Effects: Returns true if x is equal or less than y //! //! Complexity: Linear to the number of elements in the container. - friend bool operator<=(const flat_map& x, const flat_map& y) + BOOST_CONTAINER_FORCEINLINE friend bool operator<=(const flat_map& x, const flat_map& y) { return !(y < x); } //! Effects: Returns true if x is equal or greater than y //! //! Complexity: Linear to the number of elements in the container. - friend bool operator>=(const flat_map& x, const flat_map& y) + BOOST_CONTAINER_FORCEINLINE friend bool operator>=(const flat_map& x, const flat_map& y) { return !(x < y); } //! Effects: x.swap(y) //! //! Complexity: Constant. - friend void swap(flat_map& x, flat_map& y) + BOOST_CONTAINER_FORCEINLINE friend void swap(flat_map& x, flat_map& y) { x.swap(y); } #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED @@ -1439,10 +1503,10 @@ class flat_multimap typedef typename impl_tree_t::stored_allocator_type impl_stored_allocator_type; typedef typename impl_tree_t::sequence_type impl_sequence_type; - impl_tree_t &tree() + BOOST_CONTAINER_FORCEINLINE impl_tree_t &tree() { return m_flat_tree; } - const impl_tree_t &tree() const + BOOST_CONTAINER_FORCEINLINE const impl_tree_t &tree() const { return m_flat_tree; } private: @@ -1476,6 +1540,9 @@ class flat_multimap typedef BOOST_CONTAINER_IMPDEF(impl_value_type) movable_value_type; typedef typename BOOST_CONTAINER_IMPDEF(tree_t::sequence_type) sequence_type; + //Allocator::value_type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + ////////////////////////////////////////////// // // construct/copy/destroy @@ -1485,63 +1552,109 @@ class flat_multimap //! Effects: Default constructs an empty flat_map. //! //! Complexity: Constant. - flat_multimap() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value && - container_detail::is_nothrow_default_constructible::value) + BOOST_CONTAINER_FORCEINLINE flat_multimap() + BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value && + container_detail::is_nothrow_default_constructible::value) : m_flat_tree() - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} + + //! Effects: Constructs an empty flat_multimap using the specified allocator. + //! + //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE explicit flat_multimap(const allocator_type& a) + : m_flat_tree(container_detail::force(a)) + {} + + //! Effects: Constructs an empty flat_multimap using the specified comparison + //! object . + //! + //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE explicit flat_multimap(const Compare& comp) + : m_flat_tree(comp) + {} //! Effects: Constructs an empty flat_multimap using the specified comparison //! object and allocator. //! //! Complexity: Constant. - explicit flat_multimap(const Compare& comp, - const allocator_type& a = allocator_type()) - : m_flat_tree(comp, container_detail::force(a)) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + BOOST_CONTAINER_FORCEINLINE + flat_multimap(const Compare& comp, const allocator_type& a) + : m_flat_tree(comp, container_detail::force(a)) + {} - //! Effects: Constructs an empty flat_multimap using the specified allocator. - //! - //! Complexity: Constant. - explicit flat_multimap(const allocator_type& a) - : m_flat_tree(container_detail::force(a)) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Constructs an empty flat_multimap using the specified comparison object - //! and allocator, and inserts elements from the range [first ,last ). + //! Effects: Constructs an empty flat_multimap + //! and inserts elements from the range [first ,last ). //! //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is last - first. + //! the predicate and otherwise N logN, where N is last - first. template - flat_multimap(InputIterator first, InputIterator last, - const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) - : m_flat_tree(false, first, last, comp, container_detail::force(a)) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + BOOST_CONTAINER_FORCEINLINE + flat_multimap(InputIterator first, InputIterator last) + : m_flat_tree(false, first, last) + {} //! Effects: Constructs an empty flat_multimap using the specified //! allocator, and inserts elements from the range [first ,last ). //! //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is last - first. + //! the predicate and otherwise N logN, where N is last - first. template + BOOST_CONTAINER_FORCEINLINE flat_multimap(InputIterator first, InputIterator last, const allocator_type& a) - : m_flat_tree(false, first, last, Compare(), container_detail::force(a)) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + : m_flat_tree(false, first, last, container_detail::force(a)) + {} + + //! Effects: Constructs an empty flat_multimap using the specified comparison object + //! and inserts elements from the range [first ,last ). + //! + //! Complexity: Linear in N if the range [first ,last ) is already sorted using + //! the predicate and otherwise N logN, where N is last - first. + template + BOOST_CONTAINER_FORCEINLINE + flat_multimap(InputIterator first, InputIterator last, const Compare& comp) + : m_flat_tree(false, first, last, comp) + {} + + //! 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 + //! the predicate and otherwise N logN, where N is last - first. + template + BOOST_CONTAINER_FORCEINLINE + flat_multimap(InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a) + : m_flat_tree(false, first, last, comp, container_detail::force(a)) + {} + + //! Effects: Constructs an empty flat_multimap + //! 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 + BOOST_CONTAINER_FORCEINLINE + flat_multimap(ordered_range_t, InputIterator first, InputIterator last) + : m_flat_tree(ordered_range, first, last) + {} + + //! Effects: Constructs an empty flat_multimap using the specified comparison object 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 + BOOST_CONTAINER_FORCEINLINE + flat_multimap(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp) + : m_flat_tree(ordered_range, first, last, comp) + {} //! Effects: Constructs an empty flat_multimap using the specified comparison object and //! allocator, and inserts elements from the ordered range [first ,last). This function @@ -1553,39 +1666,79 @@ class flat_multimap //! //! Note: Non-standard extension. template - flat_multimap(ordered_range_t, InputIterator first, InputIterator last, - const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) + BOOST_CONTAINER_FORCEINLINE + flat_multimap(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a) : m_flat_tree(ordered_range, first, last, comp, a) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Constructs an empty flat_map using the specified comparison object and - //! allocator, and inserts elements from the range [il.begin(), il.end()). + //! Effects: Constructs an empty flat_map and + //! inserts elements from the range [il.begin(), il.end()). //! //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using - //! comp and otherwise N logN, where N is last - first. - flat_multimap(std::initializer_list il, const Compare& comp = Compare(), const allocator_type& a = allocator_type()) - : m_flat_tree(false, il.begin(), il.end(), comp, container_detail::force(a)) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + //! the predicate and otherwise N logN, where N is last - first. + BOOST_CONTAINER_FORCEINLINE + flat_multimap(std::initializer_list il) + : m_flat_tree(false, il.begin(), il.end()) + {} //! Effects: Constructs an empty flat_map using the specified //! allocator, and inserts elements from the range [il.begin(), il.end()). //! //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using - //! comp and otherwise N logN, where N is last - first. + //! the predicate and otherwise N logN, where N is last - first. + BOOST_CONTAINER_FORCEINLINE flat_multimap(std::initializer_list il, const allocator_type& a) - : m_flat_tree(false, il.begin(), il.end(), Compare(), container_detail::force(a)) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + : m_flat_tree(false, il.begin(), il.end(), container_detail::force(a)) + {} + + //! Effects: Constructs an empty flat_map using the specified comparison object and + //! inserts elements from the range [il.begin(), il.end()). + //! + //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using + //! the predicate and otherwise N logN, where N is last - first. + BOOST_CONTAINER_FORCEINLINE + flat_multimap(std::initializer_list il, const Compare& comp) + : m_flat_tree(false, il.begin(), il.end(), comp) + {} + + //! Effects: Constructs an empty flat_map using the specified comparison object and + //! allocator, and inserts elements from the range [il.begin(), il.end()). + //! + //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using + //! the predicate and otherwise N logN, where N is last - first. + BOOST_CONTAINER_FORCEINLINE + flat_multimap(std::initializer_list il, const Compare& comp, const allocator_type& a) + : m_flat_tree(false, il.begin(), il.end(), comp, container_detail::force(a)) + {} + + //! Effects: Constructs an empty flat_multimap and + //! inserts elements from the ordered range [il.begin(), il.end()). This function + //! is more efficient than the normal range creation for ordered ranges. + //! + //! Requires: [il.begin(), il.end()) must be ordered according to the predicate. + //! + //! Complexity: Linear in N. + //! + //! Note: Non-standard extension. + BOOST_CONTAINER_FORCEINLINE + flat_multimap(ordered_range_t, std::initializer_list il) + : m_flat_tree(ordered_range, il.begin(), il.end()) + {} + + //! Effects: Constructs an empty flat_multimap using the specified comparison object and + //! inserts elements from the ordered range [il.begin(), il.end()). This function + //! is more efficient than the normal range creation for ordered ranges. + //! + //! Requires: [il.begin(), il.end()) must be ordered according to the predicate. + //! + //! Complexity: Linear in N. + //! + //! Note: Non-standard extension. + BOOST_CONTAINER_FORCEINLINE + flat_multimap(ordered_range_t, std::initializer_list il, const Compare& comp) + : m_flat_tree(ordered_range, il.begin(), il.end(), comp) + {} //! Effects: Constructs an empty flat_multimap using the specified comparison object and //! allocator, and inserts elements from the ordered range [il.begin(), il.end()). This function @@ -1596,68 +1749,59 @@ class flat_multimap //! Complexity: Linear in N. //! //! Note: Non-standard extension. - flat_multimap(ordered_range_t, std::initializer_list il, const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) + BOOST_CONTAINER_FORCEINLINE + flat_multimap(ordered_range_t, std::initializer_list il, const Compare& comp, const allocator_type& a) : m_flat_tree(ordered_range, il.begin(), il.end(), comp, a) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} #endif //! Effects: Copy constructs a flat_multimap. //! //! Complexity: Linear in x.size(). + BOOST_CONTAINER_FORCEINLINE flat_multimap(const flat_multimap& x) : m_flat_tree(x.m_flat_tree) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Move constructs a flat_multimap. Constructs *this using x's resources. //! //! Complexity: Constant. //! //! Postcondition: x is emptied. + BOOST_CONTAINER_FORCEINLINE flat_multimap(BOOST_RV_REF(flat_multimap) x) BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible::value) : m_flat_tree(boost::move(x.m_flat_tree)) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Copy constructs a flat_multimap using the specified allocator. //! //! Complexity: Linear in x.size(). + BOOST_CONTAINER_FORCEINLINE flat_multimap(const flat_multimap& x, const allocator_type &a) : m_flat_tree(x.m_flat_tree, a) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Move constructs a flat_multimap using the specified allocator. //! Constructs *this using x's resources. //! //! Complexity: Constant if a == x.get_allocator(), linear otherwise. + BOOST_CONTAINER_FORCEINLINE flat_multimap(BOOST_RV_REF(flat_multimap) x, const allocator_type &a) : m_flat_tree(boost::move(x.m_flat_tree), a) - { - //value_type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Makes *this a copy of x. //! //! Complexity: Linear in x.size(). + BOOST_CONTAINER_FORCEINLINE 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. + BOOST_CONTAINER_FORCEINLINE flat_multimap& operator=(BOOST_RV_REF(flat_multimap) x) BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value || allocator_traits_type::is_always_equal::value) && @@ -1668,6 +1812,7 @@ class flat_multimap //! Effects: Assign content of il to *this //! //! Complexity: Linear in il.size(). + BOOST_CONTAINER_FORCEINLINE flat_multimap& operator=(std::initializer_list il) { this->clear(); @@ -1680,6 +1825,7 @@ class flat_multimap //! was passed to the object's constructor. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE allocator_type get_allocator() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.get_allocator()); } @@ -1690,6 +1836,7 @@ class flat_multimap //! Complexity: Constant. //! //! Note: Non-standard extension. + BOOST_CONTAINER_FORCEINLINE stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force(m_flat_tree.get_stored_allocator()); } @@ -1700,8 +1847,9 @@ class flat_multimap //! Complexity: Constant. //! //! Note: Non-standard extension. + BOOST_CONTAINER_FORCEINLINE const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW - { return container_detail::force(m_flat_tree.get_stored_allocator()); } + { return container_detail::force(m_flat_tree.get_stored_allocator()); } ////////////////////////////////////////////// // @@ -1714,6 +1862,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE iterator begin() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.begin()); } @@ -1722,6 +1871,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.begin()); } @@ -1730,6 +1880,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE iterator end() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.end()); } @@ -1738,6 +1889,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.end()); } @@ -1747,6 +1899,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.rbegin()); } @@ -1756,6 +1909,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.rbegin()); } @@ -1765,6 +1919,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.rend()); } @@ -1774,6 +1929,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.rend()); } @@ -1782,6 +1938,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.cbegin()); } @@ -1790,6 +1947,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.cend()); } @@ -1799,6 +1957,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.crbegin()); } @@ -1808,6 +1967,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.crend()); } @@ -1822,6 +1982,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE bool empty() const BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.empty(); } @@ -1830,6 +1991,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE size_type size() const BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.size(); } @@ -1838,6 +2000,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.max_size(); } @@ -1847,6 +2010,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE size_type capacity() const BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.capacity(); } @@ -1859,6 +2023,7 @@ class flat_multimap //! //! Note: If capacity() is less than "cnt", iterators and references to //! to values might be invalidated. + BOOST_CONTAINER_FORCEINLINE void reserve(size_type cnt) { m_flat_tree.reserve(cnt); } @@ -1868,22 +2033,27 @@ class flat_multimap //! Throws: If memory allocation throws, or T's copy constructor throws. //! //! Complexity: Linear to size(). + BOOST_CONTAINER_FORCEINLINE void shrink_to_fit() { m_flat_tree.shrink_to_fit(); } //! @copydoc ::boost::container::flat_set::nth(size_type) + BOOST_CONTAINER_FORCEINLINE iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.nth(n)); } //! @copydoc ::boost::container::flat_set::nth(size_type) const + BOOST_CONTAINER_FORCEINLINE const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.nth(n)); } //! @copydoc ::boost::container::flat_set::index_of(iterator) + BOOST_CONTAINER_FORCEINLINE size_type index_of(iterator p) BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.index_of(container_detail::force_copy(p)); } //! @copydoc ::boost::container::flat_set::index_of(const_iterator) const + BOOST_CONTAINER_FORCEINLINE size_type index_of(const_iterator p) const BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.index_of(container_detail::force_copy(p)); } @@ -1898,6 +2068,7 @@ class flat_multimap //! //! Note: If an element is inserted it might invalidate elements. template + BOOST_CONTAINER_FORCEINLINE iterator emplace(BOOST_FWD_REF(Args)... args) { return container_detail::force_copy(m_flat_tree.emplace_equal(boost::forward(args)...)); } @@ -1914,6 +2085,7 @@ class flat_multimap //! //! Note: If an element is inserted it might invalidate elements. template + BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args) { return container_detail::force_copy(m_flat_tree.emplace_hint_equal @@ -1924,11 +2096,11 @@ class flat_multimap #define BOOST_CONTAINER_FLAT_MULTIMAP_EMPLACE_CODE(N) \ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ - iterator emplace(BOOST_MOVE_UREF##N)\ + BOOST_CONTAINER_FORCEINLINE iterator emplace(BOOST_MOVE_UREF##N)\ { return container_detail::force_copy(m_flat_tree.emplace_equal(BOOST_MOVE_FWD##N)); }\ \ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ - iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ {\ return container_detail::force_copy(m_flat_tree.emplace_hint_equal\ (container_detail::force_copy(hint) BOOST_MOVE_I##N BOOST_MOVE_FWD##N));\ @@ -1946,10 +2118,10 @@ class flat_multimap //! to the elements with bigger keys than x. //! //! Note: If an element is inserted it might invalidate elements. - iterator insert(const value_type& x) + BOOST_CONTAINER_FORCEINLINE iterator insert(const value_type& x) { return container_detail::force_copy( - m_flat_tree.insert_equal(container_detail::force(x))); + m_flat_tree.insert_equal(container_detail::force(x))); } //! Effects: Inserts a new value move-constructed from x and returns @@ -1959,7 +2131,7 @@ class flat_multimap //! 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) + BOOST_CONTAINER_FORCEINLINE 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 @@ -1969,7 +2141,7 @@ class flat_multimap //! 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) + BOOST_CONTAINER_FORCEINLINE 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. @@ -1983,11 +2155,11 @@ 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 p, const value_type& x) + BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator p, const value_type& x) { return container_detail::force_copy (m_flat_tree.insert_equal( container_detail::force_copy(p) - , container_detail::force(x))); + , container_detail::force(x))); } //! Effects: Inserts a value move constructed from x in the container. @@ -2001,7 +2173,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 p, BOOST_RV_REF(value_type) x) + BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator p, BOOST_RV_REF(value_type) x) { return container_detail::force_copy (m_flat_tree.insert_equal(container_detail::force_copy(p) @@ -2019,7 +2191,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 p, BOOST_RV_REF(impl_value_type) x) + BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator p, BOOST_RV_REF(impl_value_type) x) { return container_detail::force_copy( m_flat_tree.insert_equal(container_detail::force_copy(p), boost::move(x))); @@ -2034,7 +2206,7 @@ class flat_multimap //! //! Note: If an element is inserted it might invalidate elements. template - void insert(InputIterator first, InputIterator last) + BOOST_CONTAINER_FORCEINLINE void insert(InputIterator first, InputIterator last) { m_flat_tree.insert_equal(first, last); } //! Requires: first, last are not iterators into *this. @@ -2052,7 +2224,7 @@ class flat_multimap //! //! Note: Non-standard extension. template - void insert(ordered_range_t, InputIterator first, InputIterator last) + BOOST_CONTAINER_FORCEINLINE void insert(ordered_range_t, InputIterator first, InputIterator last) { m_flat_tree.insert_equal(ordered_range, first, last); } #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) @@ -2062,7 +2234,7 @@ class flat_multimap //! search time plus N*size() insertion time. //! //! Note: If an element is inserted it might invalidate elements. - void insert(std::initializer_list il) + BOOST_CONTAINER_FORCEINLINE void insert(std::initializer_list il) { m_flat_tree.insert_equal(il.begin(), il.end()); } //! Requires: [il.begin(), il.end()) must be ordered according to the predicate. @@ -2077,7 +2249,7 @@ class flat_multimap //! Note: If an element is inserted it might invalidate elements. //! //! Note: Non-standard extension. - void insert(ordered_range_t, std::initializer_list il) + BOOST_CONTAINER_FORCEINLINE void insert(ordered_range_t, std::initializer_list il) { m_flat_tree.insert_equal(ordered_range, il.begin(), il.end()); } #endif @@ -2095,22 +2267,22 @@ class flat_multimap //! //! Complexity: N log(a.size() + N) (N has the value source.size()) template - void merge(flat_multimap& source) + BOOST_CONTAINER_FORCEINLINE void merge(flat_multimap& source) { m_flat_tree.merge_equal(source.tree()); } //! @copydoc ::boost::container::flat_multimap::merge(flat_multimap&) template - void merge(BOOST_RV_REF_BEG flat_multimap BOOST_RV_REF_END source) + BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG flat_multimap BOOST_RV_REF_END source) { return this->merge(static_cast&>(source)); } //! @copydoc ::boost::container::flat_multimap::merge(flat_multimap&) template - void merge(flat_map& source) + BOOST_CONTAINER_FORCEINLINE void merge(flat_map& source) { m_flat_tree.merge_equal(source.tree()); } //! @copydoc ::boost::container::flat_multimap::merge(flat_map&) template - void merge(BOOST_RV_REF_BEG flat_map BOOST_RV_REF_END source) + BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG flat_map BOOST_RV_REF_END source) { return this->merge(static_cast&>(source)); } //! Effects: Erases the element pointed to by p. @@ -2123,7 +2295,7 @@ class flat_multimap //! //! Note: Invalidates elements with keys //! not less than the erased element. - iterator erase(const_iterator p) + BOOST_CONTAINER_FORCEINLINE iterator erase(const_iterator p) { return container_detail::force_copy( m_flat_tree.erase(container_detail::force_copy(p))); @@ -2135,7 +2307,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) + BOOST_CONTAINER_FORCEINLINE size_type erase(const key_type& x) { return m_flat_tree.erase(x); } //! Effects: Erases all the elements in the range [first, last). @@ -2146,7 +2318,7 @@ class flat_multimap //! //! Complexity: Logarithmic search time plus erasure time //! linear to the elements with bigger keys. - iterator erase(const_iterator first, const_iterator last) + BOOST_CONTAINER_FORCEINLINE iterator erase(const_iterator first, const_iterator last) { return container_detail::force_copy (m_flat_tree.erase( container_detail::force_copy(first) @@ -2158,7 +2330,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. - void swap(flat_multimap& x) + BOOST_CONTAINER_FORCEINLINE void swap(flat_multimap& x) BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value && boost::container::container_detail::is_nothrow_swappable::value ) { m_flat_tree.swap(x.m_flat_tree); } @@ -2168,7 +2340,7 @@ class flat_multimap //! Postcondition: size() == 0. //! //! Complexity: linear in size(). - void clear() BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE void clear() BOOST_NOEXCEPT_OR_NOTHROW { m_flat_tree.clear(); } ////////////////////////////////////////////// @@ -2181,14 +2353,14 @@ class flat_multimap //! of which a was constructed. //! //! Complexity: Constant. - key_compare key_comp() const + BOOST_CONTAINER_FORCEINLINE key_compare key_comp() const { return container_detail::force_copy(m_flat_tree.key_comp()); } //! Effects: Returns an object of value_compare constructed out //! of the comparison object. //! //! Complexity: Constant. - value_compare value_comp() const + BOOST_CONTAINER_FORCEINLINE value_compare value_comp() const { return value_compare(container_detail::force_copy(m_flat_tree.key_comp())); } ////////////////////////////////////////////// @@ -2201,60 +2373,60 @@ class flat_multimap //! equivalent to x, or end() if such an element is not found. //! //! Complexity: Logarithmic. - iterator find(const key_type& x) + BOOST_CONTAINER_FORCEINLINE iterator find(const key_type& x) { return container_detail::force_copy(m_flat_tree.find(x)); } //! Returns: An 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 + BOOST_CONTAINER_FORCEINLINE const_iterator find(const key_type& x) const { return container_detail::force_copy(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 + BOOST_CONTAINER_FORCEINLINE 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) + BOOST_CONTAINER_FORCEINLINE 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 + BOOST_CONTAINER_FORCEINLINE const_iterator lower_bound(const key_type& x) const { return container_detail::force_copy(m_flat_tree.lower_bound(x)); } //! Returns: An iterator pointing to the first element with key not less //! than x, or end() if such an element is not found. //! //! Complexity: Logarithmic - iterator upper_bound(const key_type& x) + BOOST_CONTAINER_FORCEINLINE 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 + BOOST_CONTAINER_FORCEINLINE const_iterator upper_bound(const key_type& x) const { return container_detail::force_copy(m_flat_tree.upper_bound(x)); } //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). //! //! Complexity: Logarithmic - std::pair equal_range(const key_type& x) + BOOST_CONTAINER_FORCEINLINE 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 + BOOST_CONTAINER_FORCEINLINE std::pair equal_range(const key_type& x) const { return container_detail::force_copy >(m_flat_tree.equal_range(x)); } //! Effects: Extracts the internal sequence container. @@ -2264,7 +2436,7 @@ class flat_multimap //! Postcondition: this->empty() //! //! Throws: If secuence_type's move constructor throws - sequence_type extract_sequence() + BOOST_CONTAINER_FORCEINLINE sequence_type extract_sequence() { return boost::move(container_detail::force(m_flat_tree.get_sequence_ref())); } @@ -2275,7 +2447,7 @@ class flat_multimap //! Complexity: Assuming O(1) move assignment, O(NlogN) with N = seq.size() //! //! Throws: If the comparison or the move constructor throws - void adopt_sequence(BOOST_RV_REF(sequence_type) seq) + BOOST_CONTAINER_FORCEINLINE void adopt_sequence(BOOST_RV_REF(sequence_type) seq) { this->m_flat_tree.adopt_sequence_equal(boost::move(container_detail::force(seq))); } //! Requires: seq shall be ordered according to this->compare(). @@ -2286,49 +2458,49 @@ class flat_multimap //! Complexity: Assuming O(1) move assignment, O(1) //! //! Throws: If the move assignment throws - void adopt_sequence(ordered_range_t, BOOST_RV_REF(sequence_type) seq) + BOOST_CONTAINER_FORCEINLINE void adopt_sequence(ordered_range_t, BOOST_RV_REF(sequence_type) seq) { this->m_flat_tree.adopt_sequence_equal(ordered_range_t(), boost::move(container_detail::force(seq))); } //! Effects: Returns true if x and y are equal //! //! Complexity: Linear to the number of elements in the container. - friend bool operator==(const flat_multimap& x, const flat_multimap& y) + BOOST_CONTAINER_FORCEINLINE friend bool operator==(const flat_multimap& x, const flat_multimap& y) { return x.size() == y.size() && ::boost::container::algo_equal(x.begin(), x.end(), y.begin()); } //! Effects: Returns true if x and y are unequal //! //! Complexity: Linear to the number of elements in the container. - friend bool operator!=(const flat_multimap& x, const flat_multimap& y) + BOOST_CONTAINER_FORCEINLINE friend bool operator!=(const flat_multimap& x, const flat_multimap& y) { return !(x == y); } //! Effects: Returns true if x is less than y //! //! Complexity: Linear to the number of elements in the container. - friend bool operator<(const flat_multimap& x, const flat_multimap& y) + BOOST_CONTAINER_FORCEINLINE friend bool operator<(const flat_multimap& x, const flat_multimap& y) { return ::boost::container::algo_lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } //! Effects: Returns true if x is greater than y //! //! Complexity: Linear to the number of elements in the container. - friend bool operator>(const flat_multimap& x, const flat_multimap& y) + BOOST_CONTAINER_FORCEINLINE friend bool operator>(const flat_multimap& x, const flat_multimap& y) { return y < x; } //! Effects: Returns true if x is equal or less than y //! //! Complexity: Linear to the number of elements in the container. - friend bool operator<=(const flat_multimap& x, const flat_multimap& y) + BOOST_CONTAINER_FORCEINLINE friend bool operator<=(const flat_multimap& x, const flat_multimap& y) { return !(y < x); } //! Effects: Returns true if x is equal or greater than y //! //! Complexity: Linear to the number of elements in the container. - friend bool operator>=(const flat_multimap& x, const flat_multimap& y) + BOOST_CONTAINER_FORCEINLINE friend bool operator>=(const flat_multimap& x, const flat_multimap& y) { return !(x < y); } //! Effects: x.swap(y) //! //! Complexity: Constant. - friend void swap(flat_multimap& x, flat_multimap& y) + BOOST_CONTAINER_FORCEINLINE friend void swap(flat_multimap& x, flat_multimap& y) { x.swap(y); } }; diff --git a/include/boost/container/flat_set.hpp b/include/boost/container/flat_set.hpp index 1068734..9e39be8 100644 --- a/include/boost/container/flat_set.hpp +++ b/include/boost/container/flat_set.hpp @@ -126,47 +126,112 @@ class flat_set //! Effects: Default constructs an empty container. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE explicit flat_set() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value && container_detail::is_nothrow_default_constructible::value) : base_t() {} //! Effects: Constructs an empty container using the specified - //! comparison object and allocator. + //! comparison object. //! //! Complexity: Constant. - explicit flat_set(const Compare& comp, - const allocator_type& a = allocator_type()) - : base_t(comp, a) + BOOST_CONTAINER_FORCEINLINE + explicit flat_set(const Compare& comp) + : base_t(comp) {} //! Effects: Constructs an empty container using the specified allocator. //! //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE explicit flat_set(const allocator_type& a) : base_t(a) {} + //! Effects: Constructs an empty container using the specified + //! comparison object and allocator. + //! + //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE + flat_set(const Compare& comp, const allocator_type& a) + : base_t(comp, a) + {} + + //! Effects: Constructs an empty container and + //! inserts elements from the range [first ,last ). + //! + //! Complexity: Linear in N if the range [first ,last ) is already sorted using + //! comp and otherwise N logN, where N is last - first. + template + BOOST_CONTAINER_FORCEINLINE + flat_set(InputIterator first, InputIterator last) + : base_t(true, first, last) + {} + + //! Effects: Constructs an empty container using the specified + //! allocator, and inserts elements from the range [first ,last ). + //! + //! Complexity: Linear in N if the range [first ,last ) is already sorted using + //! comp and otherwise N logN, where N is last - first. + template + BOOST_CONTAINER_FORCEINLINE + flat_set(InputIterator first, InputIterator last, const allocator_type& a) + : base_t(true, first, last, a) + {} + + //! Effects: Constructs an empty container using the specified comparison object and + //! inserts elements from the range [first ,last ). + //! + //! Complexity: Linear in N if the range [first ,last ) is already sorted using + //! comp and otherwise N logN, where N is last - first. + template + BOOST_CONTAINER_FORCEINLINE + flat_set(InputIterator first, InputIterator last, const Compare& comp) + : base_t(true, first, last, comp) + {} + //! Effects: Constructs an empty container 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 //! comp and otherwise N logN, where N is last - first. template - flat_set(InputIterator first, InputIterator last, - const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) + BOOST_CONTAINER_FORCEINLINE + flat_set(InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a) : base_t(true, first, last, comp, a) {} - //! Effects: Constructs an empty container using the specified - //! allocator, and inserts elements from the range [first ,last ). + //! Effects: Constructs an empty container and + //! inserts elements from the ordered unique range [first ,last). This function + //! is more efficient than the normal range creation for ordered ranges. //! - //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is last - first. + //! 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(InputIterator first, InputIterator last, const allocator_type& a) - : base_t(true, first, last, Compare(), a) + BOOST_CONTAINER_FORCEINLINE + flat_set(ordered_unique_range_t, InputIterator first, InputIterator last) + : base_t(ordered_unique_range, first, last) + {} + + //! Effects: Constructs an empty container using the specified comparison object 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 + BOOST_CONTAINER_FORCEINLINE + flat_set(ordered_unique_range_t, InputIterator first, InputIterator last, const Compare& comp) + : base_t(ordered_unique_range, first, last, comp) {} //! Effects: Constructs an empty container using the specified comparison object and @@ -180,21 +245,19 @@ class flat_set //! //! Note: Non-standard extension. template - flat_set(ordered_unique_range_t, InputIterator first, InputIterator last, - const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) + BOOST_CONTAINER_FORCEINLINE + flat_set(ordered_unique_range_t, InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a) : base_t(ordered_unique_range, first, last, comp, a) {} #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Constructs an empty container using the specified comparison object and - //! allocator, and inserts elements from the range [il.begin(), il.end()). + //! Effects: Constructs an empty container and + //! inserts elements from the range [il.begin(), il.end()). //! //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using //! comp and otherwise N logN, where N is il.begin() - il.end(). - flat_set(std::initializer_list il, const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) - : base_t(true, il.begin(), il.end(), comp, a) + BOOST_CONTAINER_FORCEINLINE flat_set(std::initializer_list il) + : base_t(true, il.begin(), il.end()) {} //! Effects: Constructs an empty container using the specified @@ -202,8 +265,54 @@ class flat_set //! //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using //! comp and otherwise N logN, where N is il.begin() - il.end(). - flat_set(std::initializer_list il, const allocator_type& a) - : base_t(true, il.begin(), il.end(), Compare(), a) + BOOST_CONTAINER_FORCEINLINE flat_set(std::initializer_list il, const allocator_type& a) + : base_t(true, il.begin(), il.end(), a) + {} + + //! Effects: Constructs an empty container using the specified comparison object and + //! inserts elements from the range [il.begin(), il.end()). + //! + //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using + //! comp and otherwise N logN, where N is il.begin() - il.end(). + BOOST_CONTAINER_FORCEINLINE flat_set(std::initializer_list il, const Compare& comp) + : base_t(true, il.begin(), il.end(), comp) + {} + + //! Effects: Constructs an empty container using the specified comparison object and + //! allocator, and inserts elements from the range [il.begin(), il.end()). + //! + //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using + //! comp and otherwise N logN, where N is il.begin() - il.end(). + BOOST_CONTAINER_FORCEINLINE flat_set(std::initializer_list il, const Compare& comp, const allocator_type& a) + : base_t(true, il.begin(), il.end(), comp, a) + {} + + //! Effects: Constructs an empty container using the specified comparison object and + //! inserts elements from the ordered unique range [il.begin(), il.end()). This function + //! is more efficient than the normal range creation for ordered ranges. + //! + //! Requires: [il.begin(), il.end()) must be ordered according to the predicate and must be + //! unique values. + //! + //! Complexity: Linear in N. + //! + //! Note: Non-standard extension. + BOOST_CONTAINER_FORCEINLINE flat_set(ordered_unique_range_t, std::initializer_list il) + : base_t(ordered_unique_range, il.begin(), il.end()) + {} + + //! Effects: Constructs an empty container using the specified comparison object and + //! inserts elements from the ordered unique range [il.begin(), il.end()). This function + //! is more efficient than the normal range creation for ordered ranges. + //! + //! Requires: [il.begin(), il.end()) must be ordered according to the predicate and must be + //! unique values. + //! + //! Complexity: Linear in N. + //! + //! Note: Non-standard extension. + BOOST_CONTAINER_FORCEINLINE flat_set(ordered_unique_range_t, std::initializer_list il, const Compare& comp) + : base_t(ordered_unique_range, il.begin(), il.end(), comp) {} //! Effects: Constructs an empty container using the specified comparison object and @@ -216,8 +325,7 @@ class flat_set //! Complexity: Linear in N. //! //! Note: Non-standard extension. - flat_set(ordered_unique_range_t, std::initializer_list il, - const Compare& comp = Compare(), const allocator_type& a = allocator_type()) + BOOST_CONTAINER_FORCEINLINE flat_set(ordered_unique_range_t, std::initializer_list il, const Compare& comp, const allocator_type& a) : base_t(ordered_unique_range, il.begin(), il.end(), comp, a) {} #endif @@ -225,7 +333,7 @@ class flat_set //! Effects: Copy constructs the container. //! //! Complexity: Linear in x.size(). - flat_set(const flat_set& x) + BOOST_CONTAINER_FORCEINLINE flat_set(const flat_set& x) : base_t(static_cast(x)) {} @@ -234,7 +342,7 @@ class flat_set //! Complexity: Constant. //! //! Postcondition: x is emptied. - flat_set(BOOST_RV_REF(flat_set) x) + BOOST_CONTAINER_FORCEINLINE flat_set(BOOST_RV_REF(flat_set) x) BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible::value) : base_t(BOOST_MOVE_BASE(base_t, x)) {} @@ -242,7 +350,7 @@ class flat_set //! Effects: Copy constructs a container using the specified allocator. //! //! Complexity: Linear in x.size(). - flat_set(const flat_set& x, const allocator_type &a) + BOOST_CONTAINER_FORCEINLINE flat_set(const flat_set& x, const allocator_type &a) : base_t(static_cast(x), a) {} @@ -250,14 +358,14 @@ class flat_set //! Constructs *this using x's resources. //! //! Complexity: Constant if a == x.get_allocator(), linear otherwise - flat_set(BOOST_RV_REF(flat_set) x, const allocator_type &a) + BOOST_CONTAINER_FORCEINLINE flat_set(BOOST_RV_REF(flat_set) x, const allocator_type &a) : base_t(BOOST_MOVE_BASE(base_t, x), a) {} //! Effects: Makes *this a copy of x. //! //! Complexity: Linear in x.size(). - flat_set& operator=(BOOST_COPY_ASSIGN_REF(flat_set) x) + BOOST_CONTAINER_FORCEINLINE flat_set& operator=(BOOST_COPY_ASSIGN_REF(flat_set) x) { return static_cast(this->base_t::operator=(static_cast(x))); } //! Throws: If allocator_traits_type::propagate_on_container_move_assignment @@ -266,7 +374,7 @@ class flat_set //! Complexity: Constant if allocator_traits_type:: //! propagate_on_container_move_assignment is true or //! this->get>allocator() == x.get_allocator(). Linear otherwise. - flat_set& operator=(BOOST_RV_REF(flat_set) x) + BOOST_CONTAINER_FORCEINLINE flat_set& operator=(BOOST_RV_REF(flat_set) x) BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value || allocator_traits_type::is_always_equal::value) && boost::container::container_detail::is_nothrow_move_assignable::value) @@ -470,7 +578,7 @@ class flat_set //! //! Note: If an element is inserted it might invalidate elements. template - std::pair emplace(BOOST_FWD_REF(Args)... args) + BOOST_CONTAINER_FORCEINLINE std::pair emplace(BOOST_FWD_REF(Args)... args) { return this->base_t::emplace_unique(boost::forward(args)...); } //! Effects: Inserts an object of type Key constructed with @@ -486,18 +594,18 @@ class flat_set //! //! Note: If an element is inserted it might invalidate elements. template - iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args) + BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args) { return this->base_t::emplace_hint_unique(p, boost::forward(args)...); } #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #define BOOST_CONTAINER_FLAT_SET_EMPLACE_CODE(N) \ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ - std::pair emplace(BOOST_MOVE_UREF##N)\ + BOOST_CONTAINER_FORCEINLINE std::pair emplace(BOOST_MOVE_UREF##N)\ { return this->base_t::emplace_unique(BOOST_MOVE_FWD##N); }\ \ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ - iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ { return this->base_t::emplace_hint_unique(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\ // BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_FLAT_SET_EMPLACE_CODE) @@ -576,7 +684,7 @@ class flat_set //! //! Note: If an element is inserted it might invalidate elements. template - void insert(InputIterator first, InputIterator last) + BOOST_CONTAINER_FORCEINLINE void insert(InputIterator first, InputIterator last) { this->base_t::insert_unique(first, last); } //! Requires: first, last are not iterators into *this and @@ -591,7 +699,7 @@ class flat_set //! //! Note: Non-standard extension. If an element is inserted it might invalidate elements. template - void insert(ordered_unique_range_t, InputIterator first, InputIterator last) + BOOST_CONTAINER_FORCEINLINE void insert(ordered_unique_range_t, InputIterator first, InputIterator last) { this->base_t::insert_unique(ordered_unique_range, first, last); } #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) @@ -602,7 +710,7 @@ class flat_set //! search time plus N*size() insertion time. //! //! Note: If an element is inserted it might invalidate elements. - void insert(std::initializer_list il) + BOOST_CONTAINER_FORCEINLINE void insert(std::initializer_list il) { this->base_t::insert_unique(il.begin(), il.end()); } //! Requires: Range [il.begin(), il.end()) must be ordered according to the predicate @@ -615,7 +723,7 @@ class flat_set //! search time plus N*size() insertion time. //! //! Note: Non-standard extension. If an element is inserted it might invalidate elements. - void insert(ordered_unique_range_t, std::initializer_list il) + BOOST_CONTAINER_FORCEINLINE void insert(ordered_unique_range_t, std::initializer_list il) { this->base_t::insert_unique(ordered_unique_range, il.begin(), il.end()); } #endif @@ -766,7 +874,7 @@ class flat_set //! Returns: The number of elements with key equivalent to x. //! //! Complexity: log(size())+count(k) - size_type count(const key_type& x) const + BOOST_CONTAINER_FORCEINLINE size_type count(const key_type& x) const { return static_cast(this->base_t::find(x) != this->base_t::cend()); } #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) @@ -799,13 +907,13 @@ class flat_set //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). //! //! Complexity: Logarithmic - std::pair equal_range(const key_type& x) const + BOOST_CONTAINER_FORCEINLINE std::pair equal_range(const key_type& x) const { return this->base_t::lower_bound_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) + BOOST_CONTAINER_FORCEINLINE std::pair equal_range(const key_type& x) { return this->base_t::lower_bound_range(x); } #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) @@ -862,7 +970,7 @@ class flat_set //! Complexity: Assuming O(1) move assignment, O(NlogN) with N = seq.size() //! //! Throws: If the comparison or the move constructor throws - void adopt_sequence(BOOST_RV_REF(sequence_type) seq) + BOOST_CONTAINER_FORCEINLINE void adopt_sequence(BOOST_RV_REF(sequence_type) seq) { this->base_t::adopt_sequence_unique(boost::move(seq)); } //! Requires: seq shall be ordered according to this->compare() @@ -874,17 +982,17 @@ class flat_set //! Complexity: Assuming O(1) move assignment, O(1) //! //! Throws: If the move assignment throws - void adopt_sequence(ordered_unique_range_t, BOOST_RV_REF(sequence_type) seq) + BOOST_CONTAINER_FORCEINLINE void adopt_sequence(ordered_unique_range_t, BOOST_RV_REF(sequence_type) seq) { this->base_t::adopt_sequence_unique(ordered_unique_range_t(), boost::move(seq)); } #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: template - std::pair priv_insert(BOOST_FWD_REF(KeyType) x) + BOOST_CONTAINER_FORCEINLINE std::pair priv_insert(BOOST_FWD_REF(KeyType) x) { return this->base_t::insert_unique(::boost::forward(x)); } template - iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x) + BOOST_CONTAINER_FORCEINLINE iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x) { return this->base_t::insert_unique(p, ::boost::forward(x)); } #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED }; @@ -973,38 +1081,52 @@ class flat_multiset typedef typename BOOST_CONTAINER_IMPDEF(base_t::sequence_type) sequence_type; //! @copydoc ::boost::container::flat_set::flat_set() - explicit flat_multiset() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value && + BOOST_CONTAINER_FORCEINLINE explicit flat_multiset() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value && container_detail::is_nothrow_default_constructible::value) : base_t() {} - //! @copydoc ::boost::container::flat_set::flat_set(const Compare&, const allocator_type&) - explicit flat_multiset(const Compare& comp, - const allocator_type& a = allocator_type()) - : base_t(comp, a) + //! @copydoc ::boost::container::flat_set::flat_set(const Compare&) + BOOST_CONTAINER_FORCEINLINE explicit flat_multiset(const Compare& comp) + : base_t(comp) {} //! @copydoc ::boost::container::flat_set::flat_set(const allocator_type&) - explicit flat_multiset(const allocator_type& a) + BOOST_CONTAINER_FORCEINLINE explicit flat_multiset(const allocator_type& a) : base_t(a) {} - //! @copydoc ::boost::container::flat_set::flat_set(InputIterator, InputIterator, const Compare& comp, const allocator_type&) + //! @copydoc ::boost::container::flat_set::flat_set(const Compare&, const allocator_type&) + BOOST_CONTAINER_FORCEINLINE flat_multiset(const Compare& comp, const allocator_type& a) + : base_t(comp, a) + {} + + //! @copydoc ::boost::container::flat_set::flat_set(InputIterator, InputIterator) template - flat_multiset(InputIterator first, InputIterator last, - const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) - : base_t(false, first, last, comp, a) + BOOST_CONTAINER_FORCEINLINE flat_multiset(InputIterator first, InputIterator last) + : base_t(false, first, last) {} //! @copydoc ::boost::container::flat_set::flat_set(InputIterator, InputIterator, const allocator_type&) template - flat_multiset(InputIterator first, InputIterator last, const allocator_type& a) - : base_t(false, first, last, Compare(), a) + BOOST_CONTAINER_FORCEINLINE flat_multiset(InputIterator first, InputIterator last, const allocator_type& a) + : base_t(false, first, last, a) {} - //! Effects: Constructs an empty flat_multiset using the specified comparison object and - //! allocator, and inserts elements from the ordered range [first ,last ). This function + //! @copydoc ::boost::container::flat_set::flat_set(InputIterator, InputIterator, const Compare& comp) + template + BOOST_CONTAINER_FORCEINLINE flat_multiset(InputIterator first, InputIterator last, const Compare& comp) + : base_t(false, first, last, comp) + {} + + //! @copydoc ::boost::container::flat_set::flat_set(InputIterator, InputIterator, const Compare& comp, const allocator_type&) + template + BOOST_CONTAINER_FORCEINLINE flat_multiset(InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a) + : base_t(false, first, last, comp, a) + {} + + //! Effects: Constructs an empty flat_multiset 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. @@ -1013,22 +1135,83 @@ class flat_multiset //! //! Note: Non-standard extension. template - flat_multiset(ordered_range_t, InputIterator first, InputIterator last, - const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) + BOOST_CONTAINER_FORCEINLINE flat_multiset(ordered_range_t, InputIterator first, InputIterator last) + : base_t(ordered_range, first, last) + {} + + //! Effects: Constructs an empty flat_multiset using the specified comparison object 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 + BOOST_CONTAINER_FORCEINLINE flat_multiset(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp) + : base_t(ordered_range, first, last, comp) + {} + + //! 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 + BOOST_CONTAINER_FORCEINLINE flat_multiset(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a) : base_t(ordered_range, first, last, comp, a) {} #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! @copydoc ::boost::container::flat_set::flat_set(std::initializer_list, const Compare& comp, const allocator_type&) - flat_multiset(std::initializer_list il, const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) - : base_t(false, il.begin(), il.end(), comp, a) + //! @copydoc ::boost::container::flat_set::flat_set(std::initializer_list il) + : base_t(false, il.begin(), il.end()) {} //! @copydoc ::boost::container::flat_set::flat_set(std::initializer_list, const allocator_type&) - flat_multiset(std::initializer_list il, const allocator_type& a) - : base_t(false, il.begin(), il.end(), Compare(), a) + BOOST_CONTAINER_FORCEINLINE flat_multiset(std::initializer_list il, const allocator_type& a) + : base_t(false, il.begin(), il.end(), a) + {} + + //! @copydoc ::boost::container::flat_set::flat_set(std::initializer_list, const Compare& comp) + BOOST_CONTAINER_FORCEINLINE flat_multiset(std::initializer_list il, const Compare& comp) + : base_t(false, il.begin(), il.end(), comp) + {} + + //! @copydoc ::boost::container::flat_set::flat_set(std::initializer_list, const Compare& comp, const allocator_type&) + BOOST_CONTAINER_FORCEINLINE flat_multiset(std::initializer_list il, const Compare& comp, const allocator_type& a) + : base_t(false, il.begin(), il.end(), comp, a) + {} + + //! Effects: Constructs an empty containerand + //! inserts elements from the ordered unique range [il.begin(), il.end()). This function + //! is more efficient than the normal range creation for ordered ranges. + //! + //! Requires: [il.begin(), il.end()) must be ordered according to the predicate. + //! + //! Complexity: Linear in N. + //! + //! Note: Non-standard extension. + BOOST_CONTAINER_FORCEINLINE flat_multiset(ordered_range_t, std::initializer_list il) + : base_t(ordered_range, il.begin(), il.end()) + {} + + //! Effects: Constructs an empty container using the specified comparison object and + //! inserts elements from the ordered unique range [il.begin(), il.end()). This function + //! is more efficient than the normal range creation for ordered ranges. + //! + //! Requires: [il.begin(), il.end()) must be ordered according to the predicate. + //! + //! Complexity: Linear in N. + //! + //! Note: Non-standard extension. + BOOST_CONTAINER_FORCEINLINE flat_multiset(ordered_range_t, std::initializer_list il, const Compare& comp) + : base_t(ordered_range, il.begin(), il.end(), comp) {} //! Effects: Constructs an empty container using the specified comparison object and @@ -1040,39 +1223,38 @@ class flat_multiset //! Complexity: Linear in N. //! //! Note: Non-standard extension. - flat_multiset(ordered_range_t, std::initializer_list il, - const Compare& comp = Compare(), const allocator_type& a = allocator_type()) + BOOST_CONTAINER_FORCEINLINE flat_multiset(ordered_range_t, std::initializer_list il, const Compare& comp, const allocator_type& a) : base_t(ordered_range, il.begin(), il.end(), comp, a) {} #endif //! @copydoc ::boost::container::flat_set::flat_set(const flat_set &) - flat_multiset(const flat_multiset& x) + BOOST_CONTAINER_FORCEINLINE flat_multiset(const flat_multiset& x) : base_t(static_cast(x)) {} //! @copydoc ::boost::container::flat_set::flat_set(flat_set &&) - flat_multiset(BOOST_RV_REF(flat_multiset) x) + BOOST_CONTAINER_FORCEINLINE flat_multiset(BOOST_RV_REF(flat_multiset) x) BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible::value) : base_t(boost::move(static_cast(x))) {} //! @copydoc ::boost::container::flat_set::flat_set(const flat_set &, const allocator_type &) - flat_multiset(const flat_multiset& x, const allocator_type &a) + BOOST_CONTAINER_FORCEINLINE flat_multiset(const flat_multiset& x, const allocator_type &a) : base_t(static_cast(x), a) {} //! @copydoc ::boost::container::flat_set::flat_set(flat_set &&, const allocator_type &) - flat_multiset(BOOST_RV_REF(flat_multiset) x, const allocator_type &a) + BOOST_CONTAINER_FORCEINLINE flat_multiset(BOOST_RV_REF(flat_multiset) x, const allocator_type &a) : base_t(BOOST_MOVE_BASE(base_t, x), a) {} //! @copydoc ::boost::container::flat_set::operator=(const flat_set &) - flat_multiset& operator=(BOOST_COPY_ASSIGN_REF(flat_multiset) x) + BOOST_CONTAINER_FORCEINLINE flat_multiset& operator=(BOOST_COPY_ASSIGN_REF(flat_multiset) x) { return static_cast(this->base_t::operator=(static_cast(x))); } //! @copydoc ::boost::container::flat_set::operator=(flat_set &&) - flat_multiset& operator=(BOOST_RV_REF(flat_multiset) x) + BOOST_CONTAINER_FORCEINLINE flat_multiset& operator=(BOOST_RV_REF(flat_multiset) x) BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value || allocator_traits_type::is_always_equal::value) && boost::container::container_detail::is_nothrow_move_assignable::value) @@ -1172,7 +1354,7 @@ class flat_multiset //! //! Note: If an element is inserted it might invalidate elements. template - iterator emplace(BOOST_FWD_REF(Args)... args) + BOOST_CONTAINER_FORCEINLINE iterator emplace(BOOST_FWD_REF(Args)... args) { return this->base_t::emplace_equal(boost::forward(args)...); } //! Effects: Inserts an object of type Key constructed with @@ -1187,18 +1369,18 @@ class flat_multiset //! //! Note: If an element is inserted it might invalidate elements. template - iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args) + BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args) { return this->base_t::emplace_hint_equal(p, boost::forward(args)...); } #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #define BOOST_CONTAINER_FLAT_MULTISET_EMPLACE_CODE(N) \ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ - iterator emplace(BOOST_MOVE_UREF##N)\ + BOOST_CONTAINER_FORCEINLINE iterator emplace(BOOST_MOVE_UREF##N)\ { return this->base_t::emplace_equal(BOOST_MOVE_FWD##N); }\ \ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ - iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ { return this->base_t::emplace_hint_equal(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\ // BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_FLAT_MULTISET_EMPLACE_CODE) @@ -1265,7 +1447,7 @@ class flat_multiset //! //! Note: If an element is inserted it might invalidate elements. template - void insert(InputIterator first, InputIterator last) + BOOST_CONTAINER_FORCEINLINE void insert(InputIterator first, InputIterator last) { this->base_t::insert_equal(first, last); } //! Requires: first, last are not iterators into *this and @@ -1279,7 +1461,7 @@ class flat_multiset //! //! Note: Non-standard extension. If an element is inserted it might invalidate elements. template - void insert(ordered_range_t, InputIterator first, InputIterator last) + BOOST_CONTAINER_FORCEINLINE void insert(ordered_range_t, InputIterator first, InputIterator last) { this->base_t::insert_equal(ordered_range, first, last); } #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) @@ -1289,7 +1471,7 @@ class flat_multiset //! search time plus N*size() insertion time. //! //! Note: If an element is inserted it might invalidate elements. - void insert(std::initializer_list il) + BOOST_CONTAINER_FORCEINLINE void insert(std::initializer_list il) { this->base_t::insert_equal(il.begin(), il.end()); } //! Requires: Range [il.begin(), il.end()) must be ordered according to the predicate. @@ -1301,7 +1483,7 @@ class flat_multiset //! search time plus N*size() insertion time. //! //! Note: Non-standard extension. If an element is inserted it might invalidate elements. - void insert(ordered_range_t, std::initializer_list il) + BOOST_CONTAINER_FORCEINLINE void insert(ordered_range_t, std::initializer_list il) { this->base_t::insert_equal(ordered_range, il.begin(), il.end()); } #endif @@ -1441,7 +1623,7 @@ class flat_multiset //! Complexity: Assuming O(1) move assignment, O(NlogN) with N = seq.size() //! //! Throws: If the comparison or the move constructor throws - void adopt_sequence(BOOST_RV_REF(sequence_type) seq) + BOOST_CONTAINER_FORCEINLINE void adopt_sequence(BOOST_RV_REF(sequence_type) seq) { this->base_t::adopt_sequence_equal(boost::move(seq)); } //! Requires: seq shall be ordered according to this->compare() @@ -1452,17 +1634,17 @@ class flat_multiset //! Complexity: Assuming O(1) move assignment, O(1) //! //! Throws: If the move assignment throws - void adopt_sequence(ordered_range_t, BOOST_RV_REF(sequence_type) seq) + BOOST_CONTAINER_FORCEINLINE void adopt_sequence(ordered_range_t, BOOST_RV_REF(sequence_type) seq) { this->base_t::adopt_sequence_equal(ordered_range_t(), boost::move(seq)); } #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: template - iterator priv_insert(BOOST_FWD_REF(KeyType) x) + BOOST_CONTAINER_FORCEINLINE iterator priv_insert(BOOST_FWD_REF(KeyType) x) { return this->base_t::insert_equal(::boost::forward(x)); } template - iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x) + BOOST_CONTAINER_FORCEINLINE iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x) { return this->base_t::insert_equal(p, ::boost::forward(x)); } #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED }; diff --git a/include/boost/container/map.hpp b/include/boost/container/map.hpp index fa095c4..33e0331 100644 --- a/include/boost/container/map.hpp +++ b/include/boost/container/map.hpp @@ -106,7 +106,7 @@ class map typedef Key key_type; typedef ::boost::container::allocator_traits allocator_traits_type; typedef T mapped_type; - typedef std::pair value_type; + typedef typename boost::container::allocator_traits::value_type value_type; typedef typename boost::container::allocator_traits::pointer pointer; typedef typename boost::container::allocator_traits::const_pointer const_pointer; typedef typename boost::container::allocator_traits::reference reference; @@ -130,6 +130,9 @@ class map typedef BOOST_CONTAINER_IMPDEF (insert_return_type_base) insert_return_type; + //allocator_type::value_type type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same >::value)); + ////////////////////////////////////////////// // // construct/copy/destroy @@ -143,90 +146,72 @@ class map map() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value && container_detail::is_nothrow_default_constructible::value) : base_t() - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Constructs an empty map using the specified comparison object //! and allocator. //! //! Complexity: Constant. - BOOST_CONTAINER_FORCEINLINE - explicit map(const Compare& comp, const allocator_type& a) + BOOST_CONTAINER_FORCEINLINE map(const Compare& comp, const allocator_type& a) : base_t(comp, a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Constructs an empty map using the specified comparison object. //! //! Complexity: Constant. - BOOST_CONTAINER_FORCEINLINE - explicit map(const Compare& comp) + BOOST_CONTAINER_FORCEINLINE explicit map(const Compare& comp) : base_t(comp) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Constructs an empty map using the specified allocator. //! //! Complexity: Constant. - BOOST_CONTAINER_FORCEINLINE - explicit map(const allocator_type& a) + BOOST_CONTAINER_FORCEINLINE explicit map(const allocator_type& a) : base_t(a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} - //! 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 - //! comp and otherwise N logN, where N is last - first. - template - BOOST_CONTAINER_FORCEINLINE - map(InputIterator first, InputIterator last, const Compare& comp, - const allocator_type& a) - : base_t(true, first, last, comp, a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Constructs an empty map using the specified comparison object and + //! Effects: Constructs an empty map and //! inserts elements from the range [first ,last ). //! //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is last - first. + //! the predicate and otherwise N logN, where N is last - first. template - BOOST_CONTAINER_FORCEINLINE - map(InputIterator first, InputIterator last, const Compare& comp = Compare()) - : base_t(true, first, last, comp) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + BOOST_CONTAINER_FORCEINLINE map(InputIterator first, InputIterator last) + : base_t(true, first, last) + {} //! Effects: Constructs an empty map using the specified //! allocator, and inserts elements from the range [first ,last ). //! //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is last - first. + //! the predicate and otherwise N logN, where N is last - first. template - BOOST_CONTAINER_FORCEINLINE - map(InputIterator first, InputIterator last, const allocator_type& a) + BOOST_CONTAINER_FORCEINLINE map(InputIterator first, InputIterator last, const allocator_type& a) : base_t(true, first, last, Compare(), a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Constructs an empty map using the specified comparison object and - //! allocator, and inserts elements from the ordered unique range [first ,last). This function + //! inserts elements from the range [first ,last ). + //! + //! Complexity: Linear in N if the range [first ,last ) is already sorted using + //! the predicate and otherwise N logN, where N is last - first. + template + BOOST_CONTAINER_FORCEINLINE map(InputIterator first, InputIterator last, const Compare& comp) + : base_t(true, first, last, comp) + {} + + //! 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 + //! the predicate and otherwise N logN, where N is last - first. + template + BOOST_CONTAINER_FORCEINLINE map(InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a) + : base_t(true, first, last, comp, a) + {} + + //! Effects: Constructs an empty map 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 @@ -236,14 +221,9 @@ class map //! //! Note: Non-standard extension. template - BOOST_CONTAINER_FORCEINLINE - map( ordered_unique_range_t, InputIterator first, InputIterator last - , const Compare& comp, const allocator_type& a) - : base_t(ordered_range, first, last, comp, a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + BOOST_CONTAINER_FORCEINLINE map( ordered_unique_range_t, InputIterator first, InputIterator last) + : base_t(ordered_range, first, last) + {} //! Effects: Constructs an empty map using the specified comparison object and //! inserts elements from the ordered unique range [first ,last). This function @@ -256,57 +236,78 @@ class map //! //! Note: Non-standard extension. template - BOOST_CONTAINER_FORCEINLINE - map( ordered_unique_range_t, InputIterator first, InputIterator last - , const Compare& comp = Compare()) + BOOST_CONTAINER_FORCEINLINE map( ordered_unique_range_t, InputIterator first, InputIterator last, const Compare& comp) : base_t(ordered_range, first, last, comp) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} + + //! 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. + //! + //! Note: Non-standard extension. + template + BOOST_CONTAINER_FORCEINLINE map( ordered_unique_range_t, InputIterator first, InputIterator last + , const Compare& comp, const allocator_type& a) + : base_t(ordered_range, first, last, comp, a) + {} #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Constructs an empty map using the specified comparison object and - //! allocator, and inserts elements from the range [il.begin(), il.end()). + //! Effects: Constructs an empty map and + //! inserts elements from the range [il.begin(), il.end()). //! - //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is il.first() - il.end(). - BOOST_CONTAINER_FORCEINLINE - map(std::initializer_list il, const Compare& comp, const allocator_type& a) - : base_t(true, il.begin(), il.end(), comp, a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + //! Complexity: Linear in N if the range [first ,last ) is already sorted according + //! to the predicate and otherwise N logN, where N is il.first() - il.end(). + BOOST_CONTAINER_FORCEINLINE map(std::initializer_list il) + : base_t(true, il.begin(), il.end()) + {} //! Effects: Constructs an empty map using the specified comparison object and //! inserts elements from the range [il.begin(), il.end()). //! //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is il.first() - il.end(). - BOOST_CONTAINER_FORCEINLINE - map(std::initializer_list il, const Compare& comp = Compare()) + //! the predicate and otherwise N logN, where N is il.first() - il.end(). + BOOST_CONTAINER_FORCEINLINE map(std::initializer_list il, const Compare& comp) : base_t(true, il.begin(), il.end(), comp) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Constructs an empty map using the specified //! allocator, and inserts elements from the range [il.begin(), il.end()). //! //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is il.first() - il.end(). - BOOST_CONTAINER_FORCEINLINE - map(std::initializer_list il, const allocator_type& a) + //! the predicate and otherwise N logN, where N is il.first() - il.end(). + BOOST_CONTAINER_FORCEINLINE map(std::initializer_list il, const allocator_type& a) : base_t(true, il.begin(), il.end(), Compare(), a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} - //! Effects: Constructs an empty set using the specified comparison object and - //! allocator, and inserts elements from the ordered unique range [il.begin(), il.end()). This function + //! Effects: Constructs an empty map using the specified comparison object and + //! allocator, and inserts elements from the range [il.begin(), il.end()). + //! + //! Complexity: Linear in N if the range [first ,last ) is already sorted using + //! the predicate and otherwise N logN, where N is il.first() - il.end(). + BOOST_CONTAINER_FORCEINLINE map(std::initializer_list il, const Compare& comp, const allocator_type& a) + : base_t(true, il.begin(), il.end(), comp, a) + {} + + //! Effects: Constructs an empty map and inserts elements from the ordered unique range [il.begin(), il.end()). + //! This function is more efficient than the normal range creation for ordered ranges. + //! + //! Requires: [il.begin(), il.end()) must be ordered according to the predicate and must be + //! unique values. + //! + //! Complexity: Linear in N. + //! + //! Note: Non-standard extension. + BOOST_CONTAINER_FORCEINLINE map(ordered_unique_range_t, std::initializer_list il) + : base_t(ordered_range, il.begin(), il.end()) + {} + + //! Effects: Constructs an empty map using the specified comparison object, + //! and inserts elements from the ordered unique range [il.begin(), il.end()). This function //! is more efficient than the normal range creation for ordered ranges. //! //! Requires: [il.begin(), il.end()) must be ordered according to the predicate and must be @@ -315,69 +316,50 @@ class map //! Complexity: Linear in N. //! //! Note: Non-standard extension. - BOOST_CONTAINER_FORCEINLINE - map(ordered_unique_range_t, std::initializer_list il, const Compare& comp = Compare(), - const allocator_type& a) - : base_t(ordered_range, il.begin(), il.end(), comp, a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Constructs an empty set using the specified comparison object and - //! allocator, and inserts elements from the ordered unique range [il.begin(), il.end()). This function - //! is more efficient than the normal range creation for ordered ranges. - //! - //! Requires: [il.begin(), il.end()) must be ordered according to the predicate and must be - //! unique values. - //! - //! Complexity: Linear in N. - //! - //! Note: Non-standard extension. - BOOST_CONTAINER_FORCEINLINE - map(ordered_unique_range_t, std::initializer_list il, const Compare& comp = Compare()) + BOOST_CONTAINER_FORCEINLINE map(ordered_unique_range_t, std::initializer_list il, const Compare& comp) : base_t(ordered_range, il.begin(), il.end(), comp) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} + + //! Effects: Constructs an empty map using the specified comparison object and + //! allocator, and inserts elements from the ordered unique range [il.begin(), il.end()). This function + //! is more efficient than the normal range creation for ordered ranges. + //! + //! Requires: [il.begin(), il.end()) must be ordered according to the predicate and must be + //! unique values. + //! + //! Complexity: Linear in N. + //! + //! Note: Non-standard extension. + BOOST_CONTAINER_FORCEINLINE map( ordered_unique_range_t, std::initializer_list il + , const Compare& comp, const allocator_type& a) + : base_t(ordered_range, il.begin(), il.end(), comp, a) + {} + #endif //! Effects: Copy constructs a map. //! //! Complexity: Linear in x.size(). - BOOST_CONTAINER_FORCEINLINE - map(const map& x) + BOOST_CONTAINER_FORCEINLINE map(const map& x) : base_t(static_cast(x)) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Move constructs a map. Constructs *this using x's resources. //! //! Complexity: Constant. //! //! Postcondition: x is emptied. - BOOST_CONTAINER_FORCEINLINE - map(BOOST_RV_REF(map) x) + BOOST_CONTAINER_FORCEINLINE map(BOOST_RV_REF(map) x) BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible::value) : base_t(BOOST_MOVE_BASE(base_t, x)) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Copy constructs a map using the specified allocator. //! //! Complexity: Linear in x.size(). - BOOST_CONTAINER_FORCEINLINE - map(const map& x, const allocator_type &a) + BOOST_CONTAINER_FORCEINLINE map(const map& x, const allocator_type &a) : base_t(static_cast(x), a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Move constructs a map using the specified allocator. //! Constructs *this using x's resources. @@ -385,19 +367,14 @@ class map //! Complexity: Constant if x == x.get_allocator(), linear otherwise. //! //! Postcondition: x is emptied. - BOOST_CONTAINER_FORCEINLINE - map(BOOST_RV_REF(map) x, const allocator_type &a) + BOOST_CONTAINER_FORCEINLINE map(BOOST_RV_REF(map) x, const allocator_type &a) : base_t(BOOST_MOVE_BASE(base_t, x), a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Makes *this a copy of x. //! //! Complexity: Linear in x.size(). - BOOST_CONTAINER_FORCEINLINE - map& operator=(BOOST_COPY_ASSIGN_REF(map) x) + BOOST_CONTAINER_FORCEINLINE map& operator=(BOOST_COPY_ASSIGN_REF(map) x) { return static_cast(this->base_t::operator=(static_cast(x))); } //! Effects: this->swap(x.get()). @@ -408,8 +385,7 @@ class map //! Complexity: Constant if allocator_traits_type:: //! propagate_on_container_move_assignment is true or //! this->get>allocator() == x.get_allocator(). Linear otherwise. - BOOST_CONTAINER_FORCEINLINE - map& operator=(BOOST_RV_REF(map) x) + BOOST_CONTAINER_FORCEINLINE map& operator=(BOOST_RV_REF(map) x) BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value || allocator_traits_type::is_always_equal::value) && boost::container::container_detail::is_nothrow_move_assignable::value) @@ -418,8 +394,7 @@ class map #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) //! Effects: Assign content of il to *this. //! - BOOST_CONTAINER_FORCEINLINE - map& operator=(std::initializer_list il) + BOOST_CONTAINER_FORCEINLINE map& operator=(std::initializer_list il) { this->clear(); insert(il.begin(), il.end()); @@ -764,7 +739,7 @@ class map //! //! Complexity: Logarithmic in general, but amortized constant if t //! is inserted right before p. - iterator insert(const_iterator p, BOOST_RV_REF(nonconst_value_type) x) + BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator p, BOOST_RV_REF(nonconst_value_type) x) { return this->try_emplace(p, boost::move(x.first), boost::move(x.second)); } //! Effects: Move constructs a new value from x if and only if there is @@ -776,7 +751,7 @@ class map //! //! Complexity: Logarithmic in general, but amortized constant if t //! is inserted right before p. - iterator insert(const_iterator p, BOOST_RV_REF(movable_value_type) x) + BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator p, BOOST_RV_REF(movable_value_type) x) { return this->try_emplace(p, boost::move(x.first), boost::move(x.second)); } //! Effects: Inserts a copy of x in the container. @@ -794,7 +769,7 @@ class map //! 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) + BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator p, BOOST_RV_REF(value_type) x) { return this->base_t::insert_unique(p, boost::move(x)); } //! Requires: first, last are not iterators into *this. @@ -1273,7 +1248,7 @@ class multimap typedef Key key_type; typedef T mapped_type; - typedef std::pair value_type; + typedef typename boost::container::allocator_traits::value_type value_type; typedef typename boost::container::allocator_traits::pointer pointer; typedef typename boost::container::allocator_traits::const_pointer const_pointer; typedef typename boost::container::allocator_traits::reference reference; @@ -1295,6 +1270,9 @@ class multimap BOOST_MOVE_I pair_key_mapped_of_value >) node_type; + //allocator_type::value_type type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same >::value)); + ////////////////////////////////////////////// // // construct/copy/destroy @@ -1304,81 +1282,102 @@ class multimap //! Effects: Default constructs an empty multimap. //! //! Complexity: Constant. - BOOST_CONTAINER_FORCEINLINE - multimap() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value && - container_detail::is_nothrow_default_constructible::value) + BOOST_CONTAINER_FORCEINLINE multimap() + BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value && + container_detail::is_nothrow_default_constructible::value) : base_t() - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} - //! Effects: Constructs an empty multimap using the specified allocator. - //! - //! Complexity: Constant. - BOOST_CONTAINER_FORCEINLINE - explicit multimap(const Compare& comp, const allocator_type& a = allocator_type()) - : base_t(comp, a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Constructs an empty multimap using the specified comparison + //! Effects: Constructs an empty multimap using the specified allocator //! object and allocator. //! //! Complexity: Constant. - BOOST_CONTAINER_FORCEINLINE - explicit multimap(const allocator_type& a) + BOOST_CONTAINER_FORCEINLINE explicit multimap(const allocator_type& a) : base_t(a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} - //! Effects: Constructs an empty multimap using the specified comparison object - //! and allocator, and inserts elements from the range [first ,last ). + //! Effects: Constructs an empty multimap using the specified comparison. //! - //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is last - first. - template - BOOST_CONTAINER_FORCEINLINE - multimap(InputIterator first, InputIterator last, - const Compare& comp, - const allocator_type& a) - : base_t(false, first, last, comp, a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE explicit multimap(const Compare& comp) + : base_t(comp) + {} - //! Effects: Constructs an empty multimap using the specified comparison object and + //! Effects: Constructs an empty multimap using the specified comparison and allocator. + //! + //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE multimap(const Compare& comp, const allocator_type& a) + : base_t(comp, a) + {} + + //! Effects: Constructs an empty multimap and //! inserts elements from the range [first ,last ). //! //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is last - first. + //! the predicate and otherwise N logN, where N is last - first. template - BOOST_CONTAINER_FORCEINLINE - multimap(InputIterator first, InputIterator last, - const Compare& comp = Compare()) - : base_t(false, first, last, comp) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + BOOST_CONTAINER_FORCEINLINE multimap(InputIterator first, InputIterator last) + : base_t(false, first, last) + {} //! Effects: Constructs an empty multimap using the specified //! allocator, and inserts elements from the range [first ,last ). //! //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is last - first. + //! the predicate and otherwise N logN, where N is last - first. template BOOST_CONTAINER_FORCEINLINE multimap(InputIterator first, InputIterator last, const allocator_type& a) : base_t(false, first, last, Compare(), a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} + + //! Effects: Constructs an empty multimap using the specified comparison object and + //! inserts elements from the range [first ,last ). + //! + //! Complexity: Linear in N if the range [first ,last ) is already sorted using + //! the predicate and otherwise N logN, where N is last - first. + template + BOOST_CONTAINER_FORCEINLINE multimap(InputIterator first, InputIterator last, const Compare& comp) + : base_t(false, first, last, comp) + {} + + //! 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 + //! the predicate and otherwise N logN, where N is last - first. + template + BOOST_CONTAINER_FORCEINLINE multimap(InputIterator first, InputIterator last, + const Compare& comp, const allocator_type& a) + : base_t(false, first, last, comp, a) + {} + + //! Effects: Constructs an empty multimap 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 + BOOST_CONTAINER_FORCEINLINE multimap(ordered_range_t, InputIterator first, InputIterator last) + : base_t(ordered_range, first, last) + {} + + //! Effects: Constructs an empty multimap using the specified comparison object 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 + BOOST_CONTAINER_FORCEINLINE multimap(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp) + : base_t(ordered_range, first, last, comp) + {} //! Effects: Constructs an empty multimap using the specified comparison object and //! allocator, and inserts elements from the ordered range [first ,last). This function @@ -1395,80 +1394,45 @@ class multimap : base_t(ordered_range, first, last, comp, a) {} - //! Effects: Constructs an empty multimap using the specified comparison object 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 - BOOST_CONTAINER_FORCEINLINE multimap(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp = Compare()) - : base_t(ordered_range, first, last, comp) - {} - #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Constructs an empty multimap using the specified comparison object and - //! allocator, and inserts elements from the range [il.begin(), il.end()). + //! Effects: Constructs an empty multimap and + //! and inserts elements from the range [il.begin(), il.end()). //! //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is il.first() - il.end(). - BOOST_CONTAINER_FORCEINLINE - multimap(std::initializer_list il, const Compare& comp = Compare(), - const allocator_type& a) - : base_t(false, il.begin(), il.end(), comp, a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Constructs an empty multimap using the specified comparison object and - //! inserts elements from the range [il.begin(), il.end()). - //! - //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is il.first() - il.end(). - BOOST_CONTAINER_FORCEINLINE - multimap(std::initializer_list il, const Compare& comp = Compare()) - : base_t(false, il.begin(), il.end(), comp) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + //! the predicate and otherwise N logN, where N is il.first() - il.end(). + BOOST_CONTAINER_FORCEINLINE multimap(std::initializer_list il) + : base_t(false, il.begin(), il.end()) + {} //! Effects: Constructs an empty multimap using the specified //! allocator, and inserts elements from the range [il.begin(), il.end()). //! //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is il.first() - il.end(). - BOOST_CONTAINER_FORCEINLINE - multimap(std::initializer_list il, const allocator_type& a) + //! the predicate and otherwise N logN, where N is il.first() - il.end(). + BOOST_CONTAINER_FORCEINLINE multimap(std::initializer_list il, const allocator_type& a) : base_t(false, il.begin(), il.end(), Compare(), a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} - //! Effects: Constructs an empty set using the specified comparison object and - //! allocator, and inserts elements from the ordered range [il.begin(), il.end()). This function - //! is more efficient than the normal range creation for ordered ranges. + //! Effects: Constructs an empty multimap using the specified comparison object and + //! inserts elements from the range [il.begin(), il.end()). //! - //! Requires: [il.begin(), il.end()) must be ordered according to the predicate. - //! - //! Complexity: Linear in N. - //! - //! Note: Non-standard extension. - BOOST_CONTAINER_FORCEINLINE - multimap(ordered_range_t, std::initializer_list il, const Compare& comp = Compare(), - const allocator_type& a) - : base_t(ordered_range, il.begin(), il.end(), comp, a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + //! Complexity: Linear in N if the range [first ,last ) is already sorted using + //! the predicate and otherwise N logN, where N is il.first() - il.end(). + BOOST_CONTAINER_FORCEINLINE multimap(std::initializer_list il, const Compare& comp) + : base_t(false, il.begin(), il.end(), comp) + {} - //! Effects: Constructs an empty set using the specified comparison object and + //! Effects: Constructs an empty multimap using the specified comparison object and + //! allocator, and inserts elements from the range [il.begin(), il.end()). + //! + //! Complexity: Linear in N if the range [first ,last ) is already sorted using + //! the predicate and otherwise N logN, where N is il.first() - il.end(). + BOOST_CONTAINER_FORCEINLINE multimap(std::initializer_list il, const Compare& comp, const allocator_type& a) + : base_t(false, il.begin(), il.end(), comp, a) + {} + + + //! Effects: Constructs an empty map and //! inserts elements from the ordered range [il.begin(), il.end()). This function //! is more efficient than the normal range creation for ordered ranges. //! @@ -1477,13 +1441,36 @@ class multimap //! Complexity: Linear in N. //! //! Note: Non-standard extension. - BOOST_CONTAINER_FORCEINLINE - multimap(ordered_range_t, std::initializer_list il, const Compare& comp = Compare()) + BOOST_CONTAINER_FORCEINLINE multimap(ordered_range_t, std::initializer_list il) + : base_t(ordered_range, il.begin(), il.end()) + {} + + //! Effects: Constructs an empty map using the specified comparison object and + //! inserts elements from the ordered range [il.begin(), il.end()). This function + //! is more efficient than the normal range creation for ordered ranges. + //! + //! Requires: [il.begin(), il.end()) must be ordered according to the predicate. + //! + //! Complexity: Linear in N. + //! + //! Note: Non-standard extension. + BOOST_CONTAINER_FORCEINLINE multimap(ordered_range_t, std::initializer_list il, const Compare& comp) : base_t(ordered_range, il.begin(), il.end(), comp) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} + + //! Effects: Constructs an empty map and + //! inserts elements from the ordered range [il.begin(), il.end()). This function + //! is more efficient than the normal range creation for ordered ranges. + //! + //! Requires: [il.begin(), il.end()) must be ordered according to the predicate. + //! + //! Complexity: Linear in N. + //! + //! Note: Non-standard extension. + BOOST_CONTAINER_FORCEINLINE multimap(ordered_range_t, std::initializer_list il, const Compare& comp, const allocator_type& a) + : base_t(ordered_range, il.begin(), il.end(), comp, a) + {} + #endif //! Effects: Copy constructs a multimap. @@ -1491,10 +1478,7 @@ class multimap //! Complexity: Linear in x.size(). BOOST_CONTAINER_FORCEINLINE multimap(const multimap& x) : base_t(static_cast(x)) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Move constructs a multimap. Constructs *this using x's resources. //! @@ -1504,20 +1488,14 @@ class multimap BOOST_CONTAINER_FORCEINLINE multimap(BOOST_RV_REF(multimap) x) BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible::value) : base_t(BOOST_MOVE_BASE(base_t, x)) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Copy constructs a multimap. //! //! Complexity: Linear in x.size(). BOOST_CONTAINER_FORCEINLINE multimap(const multimap& x, const allocator_type &a) : base_t(static_cast(x), a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Move constructs a multimap using the specified allocator. //! Constructs *this using x's resources. @@ -1526,10 +1504,7 @@ class multimap //! Postcondition: x is emptied. BOOST_CONTAINER_FORCEINLINE multimap(BOOST_RV_REF(multimap) x, const allocator_type &a) : base_t(BOOST_MOVE_BASE(base_t, x), a) - { - //A type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } + {} //! Effects: Makes *this a copy of x. //! @@ -1813,7 +1788,7 @@ class multimap //! //! Complexity: N log(a.size() + N) (N has the value source.size()) template - void merge(multimap& source) + BOOST_CONTAINER_FORCEINLINE void merge(multimap& source) { typedef container_detail::tree base2_t; @@ -1822,12 +1797,12 @@ class multimap //! @copydoc ::boost::container::multimap::merge(multimap&) template - void merge(BOOST_RV_REF_BEG multimap BOOST_RV_REF_END source) + BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG multimap BOOST_RV_REF_END source) { return this->merge(static_cast&>(source)); } //! @copydoc ::boost::container::multimap::merge(multimap&) template - void merge(map& source) + BOOST_CONTAINER_FORCEINLINE void merge(map& source) { typedef container_detail::tree base2_t; @@ -1836,7 +1811,7 @@ class multimap //! @copydoc ::boost::container::multimap::merge(multimap&) template - void merge(BOOST_RV_REF_BEG map BOOST_RV_REF_END source) + BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG map BOOST_RV_REF_END source) { return this->merge(static_cast&>(source)); } #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) diff --git a/include/boost/container/set.hpp b/include/boost/container/set.hpp index 5cf0f96..6f7f6ff 100644 --- a/include/boost/container/set.hpp +++ b/include/boost/container/set.hpp @@ -112,48 +112,105 @@ class set //! Effects: Default constructs an empty set. //! //! Complexity: Constant. - set() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value && - container_detail::is_nothrow_default_constructible::value) + + BOOST_CONTAINER_FORCEINLINE set() + BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value && + container_detail::is_nothrow_default_constructible::value) : base_t() {} + //! Effects: Constructs an empty set using the specified allocator object. + //! + //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE explicit set(const allocator_type& a) + : base_t(a) + {} + + //! Effects: Constructs an empty set using the specified comparison object. + //! + //! Complexity: Constant. + BOOST_CONTAINER_FORCEINLINE explicit set(const Compare& comp) + : base_t(comp) + {} + //! Effects: Constructs an empty set using the specified comparison object //! and allocator. //! //! Complexity: Constant. - explicit set(const Compare& comp, - const allocator_type& a = allocator_type()) + BOOST_CONTAINER_FORCEINLINE set(const Compare& comp, const allocator_type& a) : base_t(comp, a) {} - //! Effects: Constructs an empty set using the specified allocator object. - //! - //! Complexity: Constant. - explicit set(const allocator_type& a) - : base_t(a) - {} - - //! Effects: Constructs an empty set using the specified comparison object and - //! allocator, and inserts elements from the range [first ,last ). + //! Effects: Constructs an empty set using and + //! inserts elements from the range [first ,last ). //! //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is last - first. + //! the predicate and otherwise N logN, where N is last - first. template - set(InputIterator first, InputIterator last, const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) - : base_t(true, first, last, comp, a) + BOOST_CONTAINER_FORCEINLINE set(InputIterator first, InputIterator last) + : base_t(true, first, last) {} //! Effects: Constructs an empty set using the specified //! allocator, and inserts elements from the range [first ,last ). //! //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is last - first. + //! the predicate and otherwise N logN, where N is last - first. template - set(InputIterator first, InputIterator last, const allocator_type& a) + BOOST_CONTAINER_FORCEINLINE set(InputIterator first, InputIterator last, const allocator_type& a) : base_t(true, first, last, key_compare(), a) {} + //! Effects: Constructs an empty set using the specified comparison object and + //! inserts elements from the range [first ,last ). + //! + //! Complexity: Linear in N if the range [first ,last ) is already sorted using + //! the predicate and otherwise N logN, where N is last - first. + template + BOOST_CONTAINER_FORCEINLINE set(InputIterator first, InputIterator last, const Compare& comp) + : base_t(true, first, last, comp) + {} + + //! 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 + //! the predicate and otherwise N logN, where N is last - first. + template + BOOST_CONTAINER_FORCEINLINE set(InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a) + : base_t(true, first, last, comp, a) + {} + + //! Effects: Constructs an empty set 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 + BOOST_CONTAINER_FORCEINLINE set( ordered_unique_range_t, InputIterator first, InputIterator last) + : base_t(ordered_range, first, last) + {} + + //! Effects: Constructs an empty set using the specified comparison object 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 + BOOST_CONTAINER_FORCEINLINE set( ordered_unique_range_t, InputIterator first, InputIterator last, const Compare& comp ) + : base_t(ordered_range, first, last, comp) + {} + //! 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. @@ -165,30 +222,76 @@ class set //! //! Note: Non-standard extension. template - set( ordered_unique_range_t, InputIterator first, InputIterator last - , const Compare& comp = Compare(), const allocator_type& a = allocator_type()) + BOOST_CONTAINER_FORCEINLINE set( ordered_unique_range_t, InputIterator first, InputIterator last + , const Compare& comp, const allocator_type& a) : base_t(ordered_range, first, last, comp, a) {} #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Constructs an empty set using the specified comparison object and - //! allocator, and inserts elements from the range [il.begin(), il.end()). + //! Effects: Constructs an empty set and + //! inserts elements from the range [il.begin(), il.end()). //! //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using - //! comp and otherwise N logN, where N is il.begin() - il.end(). - set(std::initializer_list il, const Compare& comp = Compare(), const allocator_type& a = allocator_type()) - : base_t(true, il.begin(), il.end(), comp, a) + //! the predicate and otherwise N logN, where N is il.begin() - il.end(). + BOOST_CONTAINER_FORCEINLINE set(std::initializer_list il) + : base_t(true, il.begin(), il.end()) {} //! Effects: Constructs an empty set using the specified //! allocator, and inserts elements from the range [il.begin(), il.end()). //! //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using - //! comp and otherwise N logN, where N is il.begin() - il.end(). - set(std::initializer_list il, const allocator_type& a) + //! the predicate and otherwise N logN, where N is il.begin() - il.end(). + BOOST_CONTAINER_FORCEINLINE set(std::initializer_list il, const allocator_type& a) : base_t(true, il.begin(), il.end(), Compare(), a) {} + //! Effects: Constructs an empty set using the specified comparison object and + //! inserts elements from the range [il.begin(), il.end()). + //! + //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using + //! the predicate and otherwise N logN, where N is il.begin() - il.end(). + BOOST_CONTAINER_FORCEINLINE set(std::initializer_list il, const Compare& comp ) + : base_t(true, il.begin(), il.end(), comp) + {} + + //! Effects: Constructs an empty set using the specified comparison object and + //! allocator, and inserts elements from the range [il.begin(), il.end()). + //! + //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using + //! the predicate and otherwise N logN, where N is il.begin() - il.end(). + BOOST_CONTAINER_FORCEINLINE set(std::initializer_list il, const Compare& comp, const allocator_type& a) + : base_t(true, il.begin(), il.end(), comp, a) + {} + + //! Effects: Constructs an empty set and + //! inserts elements from the ordered unique range [il.begin(), il.end()). This function + //! is more efficient than the normal range creation for ordered ranges. + //! + //! Requires: [il.begin(), il.end()) must be ordered according to the predicate and must be + //! unique values. + //! + //! Complexity: Linear in N. + //! + //! Note: Non-standard extension. + BOOST_CONTAINER_FORCEINLINE set( ordered_unique_range_t, std::initializer_list il) + : base_t(ordered_range, il.begin(), il.end()) + {} + + //! Effects: Constructs an empty set using the specified comparison object and + //! inserts elements from the ordered unique range [il.begin(), il.end()). This function + //! is more efficient than the normal range creation for ordered ranges. + //! + //! Requires: [il.begin(), il.end()) must be ordered according to the predicate and must be + //! unique values. + //! + //! Complexity: Linear in N. + //! + //! Note: Non-standard extension. + BOOST_CONTAINER_FORCEINLINE set( ordered_unique_range_t, std::initializer_list il, const Compare& comp) + : base_t(ordered_range, il.begin(), il.end(), comp) + {} + //! Effects: Constructs an empty set using the specified comparison object and //! allocator, and inserts elements from the ordered unique range [il.begin(), il.end()). This function //! is more efficient than the normal range creation for ordered ranges. @@ -199,8 +302,7 @@ class set //! Complexity: Linear in N. //! //! Note: Non-standard extension. - set( ordered_unique_range_t, std::initializer_list il, const Compare& comp = Compare() - , const allocator_type& a = allocator_type()) + BOOST_CONTAINER_FORCEINLINE set( ordered_unique_range_t, std::initializer_list il, const Compare& comp, const allocator_type& a) : base_t(ordered_range, il.begin(), il.end(), comp, a) {} #endif @@ -208,7 +310,7 @@ class set //! Effects: Copy constructs a set. //! //! Complexity: Linear in x.size(). - set(const set& x) + BOOST_CONTAINER_FORCEINLINE set(const set& x) : base_t(static_cast(x)) {} @@ -217,7 +319,7 @@ class set //! Complexity: Constant. //! //! Postcondition: x is emptied. - set(BOOST_RV_REF(set) x) + BOOST_CONTAINER_FORCEINLINE set(BOOST_RV_REF(set) x) BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible::value) : base_t(BOOST_MOVE_BASE(base_t, x)) {} @@ -225,7 +327,7 @@ class set //! Effects: Copy constructs a set using the specified allocator. //! //! Complexity: Linear in x.size(). - set(const set& x, const allocator_type &a) + BOOST_CONTAINER_FORCEINLINE set(const set& x, const allocator_type &a) : base_t(static_cast(x), a) {} @@ -233,14 +335,14 @@ 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) + BOOST_CONTAINER_FORCEINLINE set(BOOST_RV_REF(set) x, const allocator_type &a) : base_t(BOOST_MOVE_BASE(base_t, x), a) {} //! Effects: Makes *this a copy of x. //! //! Complexity: Linear in x.size(). - set& operator=(BOOST_COPY_ASSIGN_REF(set) x) + BOOST_CONTAINER_FORCEINLINE set& operator=(BOOST_COPY_ASSIGN_REF(set) x) { return static_cast(this->base_t::operator=(static_cast(x))); } //! Effects: this->swap(x.get()). @@ -251,7 +353,7 @@ class set //! Complexity: Constant if allocator_traits_type:: //! propagate_on_container_move_assignment is true or //! this->get>allocator() == x.get_allocator(). Linear otherwise. - set& operator=(BOOST_RV_REF(set) x) + BOOST_CONTAINER_FORCEINLINE set& operator=(BOOST_RV_REF(set) x) BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value || allocator_traits_type::is_always_equal::value) && boost::container::container_detail::is_nothrow_move_assignable::value) @@ -424,7 +526,7 @@ class set //! //! Complexity: Logarithmic. template - std::pair emplace(BOOST_FWD_REF(Args)... args) + BOOST_CONTAINER_FORCEINLINE std::pair emplace(BOOST_FWD_REF(Args)... args) { return this->base_t::emplace_unique(boost::forward(args)...); } //! Effects: Inserts an object of type Key constructed with @@ -437,18 +539,18 @@ class set //! //! Complexity: Logarithmic. template - iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args) + BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args) { return this->base_t::emplace_hint_unique(p, boost::forward(args)...); } #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #define BOOST_CONTAINER_SET_EMPLACE_CODE(N) \ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ - std::pair emplace(BOOST_MOVE_UREF##N)\ + BOOST_CONTAINER_FORCEINLINE std::pair emplace(BOOST_MOVE_UREF##N)\ { return this->base_t::emplace_unique(BOOST_MOVE_FWD##N); }\ \ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ - iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ { return this->base_t::emplace_hint_unique(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\ // BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_SET_EMPLACE_CODE) @@ -513,7 +615,7 @@ class set //! //! Complexity: At most N log(size()+N) (N is the distance from first to last) template - void insert(InputIterator first, InputIterator last) + BOOST_CONTAINER_FORCEINLINE void insert(InputIterator first, InputIterator last) { this->base_t::insert_unique(first, last); } #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) @@ -521,16 +623,16 @@ class set //! 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 il.begin() to il.end()) - void insert(std::initializer_list il) + BOOST_CONTAINER_FORCEINLINE void insert(std::initializer_list il) { this->base_t::insert_unique(il.begin(), il.end()); } #endif //! @copydoc ::boost::container::map::insert(node_type&&) - insert_return_type insert(BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh) + BOOST_CONTAINER_FORCEINLINE insert_return_type insert(BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh) { return this->base_t::insert_unique_node(boost::move(nh)); } //! @copydoc ::boost::container::map::insert(const_iterator, node_type&&) - insert_return_type insert(const_iterator hint, BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh) + BOOST_CONTAINER_FORCEINLINE insert_return_type insert(const_iterator hint, BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh) { return this->base_t::insert_unique_node(hint, boost::move(nh)); } //! @copydoc ::boost::container::map::merge(map&) @@ -631,13 +733,13 @@ class set //! Returns: The number of elements with key equivalent to x. //! //! Complexity: log(size())+count(k) - size_type count(const key_type& x) const + BOOST_CONTAINER_FORCEINLINE size_type count(const key_type& x) const { return static_cast(this->base_t::find(x) != this->base_t::cend()); } //! Returns: The number of elements with key equivalent to x. //! //! Complexity: log(size())+count(k) - size_type count(const key_type& x) + BOOST_CONTAINER_FORCEINLINE size_type count(const key_type& x) { return static_cast(this->base_t::find(x) != this->base_t::end()); } #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) @@ -671,13 +773,13 @@ class set //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). //! //! Complexity: Logarithmic - std::pair equal_range(const key_type& x) + BOOST_CONTAINER_FORCEINLINE std::pair equal_range(const key_type& x) { return this->base_t::lower_bound_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 + BOOST_CONTAINER_FORCEINLINE std::pair equal_range(const key_type& x) const { return this->base_t::lower_bound_range(x); } #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) @@ -737,11 +839,11 @@ class set #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: template - std::pair priv_insert(BOOST_FWD_REF(KeyType) x) + BOOST_CONTAINER_FORCEINLINE std::pair priv_insert(BOOST_FWD_REF(KeyType) x) { return this->base_t::insert_unique(::boost::forward(x)); } template - iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x) + BOOST_CONTAINER_FORCEINLINE iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x) { return this->base_t::insert_unique(p, ::boost::forward(x)); } #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED }; @@ -829,36 +931,79 @@ class multiset ////////////////////////////////////////////// //! @copydoc ::boost::container::set::set() - multiset() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value && - container_detail::is_nothrow_default_constructible::value) + BOOST_CONTAINER_FORCEINLINE multiset() + BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value && + container_detail::is_nothrow_default_constructible::value) : base_t() {} - //! @copydoc ::boost::container::set::set(const Compare&, const allocator_type&) - explicit multiset(const Compare& comp, - const allocator_type& a = allocator_type()) - : base_t(comp, a) - {} - //! @copydoc ::boost::container::set::set(const allocator_type&) - explicit multiset(const allocator_type& a) + BOOST_CONTAINER_FORCEINLINE explicit multiset(const allocator_type& a) : base_t(a) {} - //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const Compare& comp, const allocator_type&) + //! @copydoc ::boost::container::set::set(const Compare&) + BOOST_CONTAINER_FORCEINLINE explicit multiset(const Compare& comp) + : base_t(comp) + {} + + //! @copydoc ::boost::container::set::set(const Compare&, const allocator_type&) + BOOST_CONTAINER_FORCEINLINE multiset(const Compare& comp, const allocator_type& a) + : base_t(comp, a) + {} + + //! @copydoc ::boost::container::set::set(InputIterator, InputIterator) template - multiset(InputIterator first, InputIterator last, - const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) - : base_t(false, first, last, comp, a) + BOOST_CONTAINER_FORCEINLINE multiset(InputIterator first, InputIterator last) + : base_t(false, first, last) {} //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const allocator_type&) template - multiset(InputIterator first, InputIterator last, const allocator_type& a) + BOOST_CONTAINER_FORCEINLINE multiset(InputIterator first, InputIterator last, const allocator_type& a) : base_t(false, first, last, key_compare(), a) {} + //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const Compare&) + template + BOOST_CONTAINER_FORCEINLINE multiset(InputIterator first, InputIterator last, const Compare& comp) + : base_t(false, first, last, comp) + {} + + //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const Compare&, const allocator_type&) + template + BOOST_CONTAINER_FORCEINLINE multiset(InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a) + : base_t(false, first, last, comp, a) + {} + + //! Effects: Constructs an empty multiset and + //! 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 + BOOST_CONTAINER_FORCEINLINE multiset( ordered_range_t, InputIterator first, InputIterator last ) + : base_t(ordered_range, first, last) + {} + + //! Effects: Constructs an empty multiset using the specified comparison object 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 + BOOST_CONTAINER_FORCEINLINE multiset( ordered_range_t, InputIterator first, InputIterator last, const Compare& comp) + : base_t(ordered_range, first, last, comp) + {} + //! 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. @@ -869,56 +1014,74 @@ class multiset //! //! Note: Non-standard extension. template - multiset( ordered_range_t, InputIterator first, InputIterator last - , const Compare& comp = Compare() - , const allocator_type& a = allocator_type()) + BOOST_CONTAINER_FORCEINLINE multiset( ordered_range_t, InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a) : base_t(ordered_range, first, last, comp, a) {} #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! @copydoc ::boost::container::set::set(std::initializer_list, const Compare& comp, const allocator_type&) - multiset(std::initializer_list il, const Compare& comp = Compare(), const allocator_type& a = allocator_type()) - : base_t(false, il.begin(), il.end(), comp, a) + //! @copydoc ::boost::container::set::set(std::initializer_list) + BOOST_CONTAINER_FORCEINLINE multiset(std::initializer_list il) + : base_t(false, il.begin(), il.end()) {} //! @copydoc ::boost::container::set::set(std::initializer_list, const allocator_type&) - multiset(std::initializer_list il, const allocator_type& a) + BOOST_CONTAINER_FORCEINLINE multiset(std::initializer_list il, const allocator_type& a) : base_t(false, il.begin(), il.end(), Compare(), a) {} - //! @copydoc ::boost::container::set::set(ordered_unique_range_t, std::initializer_list, const Compare& comp, const allocator_type&) - multiset(ordered_unique_range_t, std::initializer_list il, const Compare& comp = Compare(), const allocator_type& a = allocator_type()) + //! @copydoc ::boost::container::set::set(std::initializer_list, const Compare&) + BOOST_CONTAINER_FORCEINLINE multiset(std::initializer_list il, const Compare& comp) + : base_t(false, il.begin(), il.end(), comp) + {} + + //! @copydoc ::boost::container::set::set(std::initializer_list, const Compare&, const allocator_type&) + BOOST_CONTAINER_FORCEINLINE multiset(std::initializer_list il, const Compare& comp, const allocator_type& a) + : base_t(false, il.begin(), il.end(), comp, a) + {} + + //! @copydoc ::boost::container::set::set(ordered_unique_range_t, std::initializer_list) + BOOST_CONTAINER_FORCEINLINE multiset(ordered_range_t, std::initializer_list il) + : base_t(ordered_range, il.begin(), il.end()) + {} + + //! @copydoc ::boost::container::set::set(ordered_unique_range_t, std::initializer_list, const Compare&) + BOOST_CONTAINER_FORCEINLINE multiset(ordered_range_t, std::initializer_list il, const Compare& comp) + : base_t(ordered_range, il.begin(), il.end(), comp) + {} + + //! @copydoc ::boost::container::set::set(ordered_unique_range_t, std::initializer_list, const Compare&, const allocator_type&) + BOOST_CONTAINER_FORCEINLINE multiset(ordered_range_t, std::initializer_list il, const Compare& comp, const allocator_type& a) : base_t(ordered_range, il.begin(), il.end(), comp, a) {} #endif //! @copydoc ::boost::container::set::set(const set &) - multiset(const multiset& x) + BOOST_CONTAINER_FORCEINLINE multiset(const multiset& x) : base_t(static_cast(x)) {} //! @copydoc ::boost::container::set::set(set &&) - multiset(BOOST_RV_REF(multiset) x) + BOOST_CONTAINER_FORCEINLINE multiset(BOOST_RV_REF(multiset) x) BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible::value) : base_t(BOOST_MOVE_BASE(base_t, x)) {} //! @copydoc ::boost::container::set::set(const set &, const allocator_type &) - multiset(const multiset& x, const allocator_type &a) + BOOST_CONTAINER_FORCEINLINE multiset(const multiset& x, const allocator_type &a) : base_t(static_cast(x), a) {} //! @copydoc ::boost::container::set::set(set &&, const allocator_type &) - multiset(BOOST_RV_REF(multiset) x, const allocator_type &a) + BOOST_CONTAINER_FORCEINLINE multiset(BOOST_RV_REF(multiset) x, const allocator_type &a) : base_t(BOOST_MOVE_BASE(base_t, x), a) {} //! @copydoc ::boost::container::set::operator=(const set &) - multiset& operator=(BOOST_COPY_ASSIGN_REF(multiset) x) + BOOST_CONTAINER_FORCEINLINE multiset& operator=(BOOST_COPY_ASSIGN_REF(multiset) x) { return static_cast(this->base_t::operator=(static_cast(x))); } //! @copydoc ::boost::container::set::operator=(set &&) - multiset& operator=(BOOST_RV_REF(multiset) x) + BOOST_CONTAINER_FORCEINLINE multiset& operator=(BOOST_RV_REF(multiset) x) BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value || allocator_traits_type::is_always_equal::value) && boost::container::container_detail::is_nothrow_move_assignable::value) @@ -999,7 +1162,7 @@ class multiset //! //! Complexity: Logarithmic. template - iterator emplace(BOOST_FWD_REF(Args)... args) + BOOST_CONTAINER_FORCEINLINE iterator emplace(BOOST_FWD_REF(Args)... args) { return this->base_t::emplace_equal(boost::forward(args)...); } //! Effects: Inserts an object of type Key constructed with @@ -1011,18 +1174,18 @@ class multiset //! Complexity: Logarithmic in general, but amortized constant if t //! is inserted right before p. template - iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args) + BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args) { return this->base_t::emplace_hint_equal(p, boost::forward(args)...); } #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #define BOOST_CONTAINER_MULTISET_EMPLACE_CODE(N) \ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ - iterator emplace(BOOST_MOVE_UREF##N)\ + BOOST_CONTAINER_FORCEINLINE iterator emplace(BOOST_MOVE_UREF##N)\ { return this->base_t::emplace_equal(BOOST_MOVE_FWD##N); }\ \ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ - iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ { return this->base_t::emplace_hint_equal(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\ // BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_MULTISET_EMPLACE_CODE) @@ -1079,21 +1242,21 @@ class multiset //! //! Complexity: At most N log(size()+N) (N is the distance from first to last) template - void insert(InputIterator first, InputIterator last) + BOOST_CONTAINER_FORCEINLINE void insert(InputIterator first, InputIterator last) { this->base_t::insert_equal(first, last); } #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) //! @copydoc ::boost::container::set::insert(std::initializer_list) - void insert(std::initializer_list il) + BOOST_CONTAINER_FORCEINLINE void insert(std::initializer_list il) { this->base_t::insert_equal(il.begin(), il.end()); } #endif //! @copydoc ::boost::container::multimap::insert(node_type&&) - iterator insert(BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh) + BOOST_CONTAINER_FORCEINLINE iterator insert(BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh) { return this->base_t::insert_equal_node(boost::move(nh)); } //! @copydoc ::boost::container::multimap::insert(const_iterator, node_type&&) - iterator insert(const_iterator hint, BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh) + BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator hint, BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh) { return this->base_t::insert_equal_node(hint, boost::move(nh)); } //! @copydoc ::boost::container::multimap::merge(multimap&) @@ -1219,11 +1382,11 @@ class multiset #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: template - iterator priv_insert(BOOST_FWD_REF(KeyType) x) + BOOST_CONTAINER_FORCEINLINE iterator priv_insert(BOOST_FWD_REF(KeyType) x) { return this->base_t::insert_equal(::boost::forward(x)); } template - iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x) + BOOST_CONTAINER_FORCEINLINE iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x) { return this->base_t::insert_equal(p, ::boost::forward(x)); } #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED diff --git a/test/emplace_test.hpp b/test/emplace_test.hpp index c6a75dc..89f4255 100644 --- a/test/emplace_test.hpp +++ b/test/emplace_test.hpp @@ -143,8 +143,6 @@ bool test_expected_container(const Container &ec, const std::pair EmplaceIntPair; static boost::container::container_detail::aligned_storage::type pair_storage; @@ -166,6 +164,7 @@ bool test_emplace_back(container_detail::true_) { std::cout << "Starting test_emplace_back." << std::endl << " Class: " << typeid(Container).name() << std::endl; + static EmplaceInt expected [10]; { new(&expected [0]) EmplaceInt(); @@ -218,7 +217,7 @@ bool test_emplace_front(container_detail::true_) { std::cout << "Starting test_emplace_front." << std::endl << " Class: " << typeid(Container).name() << std::endl; - + static EmplaceInt expected [10]; { new(&expected [0]) EmplaceInt(1, 2, 3, 4, 5); new(&expected [1]) EmplaceInt(1, 2, 3, 4); @@ -270,7 +269,7 @@ bool test_emplace_before(container_detail::true_) { std::cout << "Starting test_emplace_before." << std::endl << " Class: " << typeid(Container).name() << std::endl; - + static EmplaceInt expected [10]; { new(&expected [0]) EmplaceInt(); new(&expected [1]) EmplaceInt(1); @@ -382,6 +381,7 @@ bool test_emplace_after(container_detail::true_) { std::cout << "Starting test_emplace_after." << std::endl << " Class: " << typeid(Container).name() << std::endl; + static EmplaceInt expected [10]; { new(&expected [0]) EmplaceInt(); new(&expected [1]) EmplaceInt(1); @@ -467,7 +467,7 @@ bool test_emplace_assoc(container_detail::true_) { std::cout << "Starting test_emplace_assoc." << std::endl << " Class: " << typeid(Container).name() << std::endl; - + static EmplaceInt expected [10]; new(&expected [0]) EmplaceInt(); new(&expected [1]) EmplaceInt(1); new(&expected [2]) EmplaceInt(1, 2); @@ -514,7 +514,7 @@ bool test_emplace_hint(container_detail::true_) { std::cout << "Starting test_emplace_hint." << std::endl << " Class: " << typeid(Container).name() << std::endl; - + static EmplaceInt expected [10]; new(&expected [0]) EmplaceInt(); new(&expected [1]) EmplaceInt(1); new(&expected [2]) EmplaceInt(1, 2); @@ -565,11 +565,11 @@ bool test_emplace_assoc_pair(container_detail::true_) std::cout << "Starting test_emplace_assoc_pair." << std::endl << " Class: " << typeid(Container).name() << std::endl; - new(&expected_pair[0].first) EmplaceInt(); + new(&expected_pair[0].first) EmplaceInt(); new(&expected_pair[0].second) EmplaceInt(); - new(&expected_pair[1].first) EmplaceInt(1); + new(&expected_pair[1].first) EmplaceInt(1); new(&expected_pair[1].second) EmplaceInt(1); - new(&expected_pair[2].first) EmplaceInt(2); + new(&expected_pair[2].first) EmplaceInt(2); new(&expected_pair[2].second) EmplaceInt(2); { Container c; @@ -603,11 +603,11 @@ bool test_emplace_hint_pair(container_detail::true_) std::cout << "Starting test_emplace_hint_pair." << std::endl << " Class: " << typeid(Container).name() << std::endl; - new(&expected_pair[0].first) EmplaceInt(); + new(&expected_pair[0].first) EmplaceInt(); new(&expected_pair[0].second) EmplaceInt(); - new(&expected_pair[1].first) EmplaceInt(1); + new(&expected_pair[1].first) EmplaceInt(1); new(&expected_pair[1].second) EmplaceInt(1); - new(&expected_pair[2].first) EmplaceInt(2); + new(&expected_pair[2].first) EmplaceInt(2); new(&expected_pair[2].second) EmplaceInt(2); { Container c; diff --git a/test/flat_map_test.cpp b/test/flat_map_test.cpp index b2376dc..314d188 100644 --- a/test/flat_map_test.cpp +++ b/test/flat_map_test.cpp @@ -502,6 +502,9 @@ int main() return 1; } + if (!boost::container::test::instantiate_constructors, flat_multimap >()) + return 1; + //////////////////////////////////// // Testing allocator implementations //////////////////////////////////// diff --git a/test/flat_set_test.cpp b/test/flat_set_test.cpp index 74742ea..41c2642 100644 --- a/test/flat_set_test.cpp +++ b/test/flat_set_test.cpp @@ -608,6 +608,9 @@ int main() return 1; } + if (!boost::container::test::instantiate_constructors, flat_multiset >()) + return 1; + //////////////////////////////////// // Testing allocator implementations //////////////////////////////////// diff --git a/test/map_test.cpp b/test/map_test.cpp index dcb96f3..516d64a 100644 --- a/test/map_test.cpp +++ b/test/map_test.cpp @@ -432,6 +432,9 @@ int main () if(!node_type_test()) return 1; + if (!boost::container::test::instantiate_constructors, multimap >()) + return 1; + test::test_merge_from_different_comparison(); //////////////////////////////////// @@ -440,22 +443,22 @@ int main () // // map // - typedef map< int*, int*, std::less, std::allocator< std::pair > + typedef map< int*, int*, std::less, std::allocator< std::pair > , tree_assoc_options< optimize_size, tree_type >::type > rbmap_size_optimized_no; - typedef map< int*, int*, std::less, std::allocator< std::pair > + typedef map< int*, int*, std::less, std::allocator< std::pair > , tree_assoc_options< optimize_size, tree_type >::type > avlmap_size_optimized_yes; // // multimap // - typedef multimap< int*, int*, std::less, std::allocator< std::pair > + typedef multimap< int*, int*, std::less, std::allocator< std::pair > , tree_assoc_options< optimize_size, tree_type >::type > rbmmap_size_optimized_yes; - typedef multimap< int*, int*, std::less, std::allocator< std::pair > + typedef multimap< int*, int*, std::less, std::allocator< std::pair > , tree_assoc_options< optimize_size, tree_type >::type > avlmmap_size_optimized_no; + BOOST_STATIC_ASSERT(sizeof(rbmmap_size_optimized_yes) < sizeof(rbmap_size_optimized_no)); BOOST_STATIC_ASSERT(sizeof(avlmap_size_optimized_yes) < sizeof(avlmmap_size_optimized_no)); - return 0; } diff --git a/test/map_test.hpp b/test/map_test.hpp index 9731943..18b38a8 100644 --- a/test/map_test.hpp +++ b/test/map_test.hpp @@ -945,6 +945,88 @@ bool test_map_support_for_initialization_list_for() return true; } +template +bool instantiate_constructors() +{ + { + typedef typename MapType::value_type value_type; + typename MapType::key_compare comp; + typename MapType::allocator_type a; + typename MapType::value_type value; + { + MapType s0; + MapType s1(comp); + MapType s2(a); + MapType s3(comp, a); + } + { + MapType s0(&value, &value); + MapType s1(&value, &value ,comp); + MapType s2(&value, &value ,a); + MapType s3(&value, &value ,comp, a); + } + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + { + std::initializer_list il; + MapType s0(il); + MapType s1(il, comp); + MapType s2(il, a); + MapType s3(il, comp, a); + } + { + std::initializer_list il; + MapType s0(ordered_unique_range, il); + MapType s1(ordered_unique_range, il, comp); + MapType s3(ordered_unique_range, il, comp, a); + } + #endif + { + MapType s0(ordered_unique_range, &value, &value); + MapType s1(ordered_unique_range, &value, &value ,comp); + MapType s2(ordered_unique_range, &value, &value ,comp, a); + } + } + + { + typedef typename MultimapType::value_type value_type; + typename MultimapType::key_compare comp; + typename MultimapType::allocator_type a; + typename MultimapType::value_type value; + { + MultimapType s0; + MultimapType s1(comp); + MultimapType s2(a); + MultimapType s3(comp, a); + } + { + MultimapType s0(&value, &value); + MultimapType s1(&value, &value ,comp); + MultimapType s2(&value, &value ,a); + MultimapType s3(&value, &value ,comp, a); + } + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + { + std::initializer_list il; + MultimapType s0(il); + MultimapType s1(il, comp); + MultimapType s2(il, a); + MultimapType s3(il, comp, a); + } + { + std::initializer_list il; + MultimapType s0(ordered_range, il); + MultimapType s1(ordered_range, il, comp); + MultimapType s3(ordered_range, il, comp, a); + } + #endif + { + MultimapType s0(ordered_range, &value, &value); + MultimapType s1(ordered_range, &value, &value ,comp); + MultimapType s2(ordered_range, &value, &value ,comp, a); + } + } + return true; +} } //namespace test{ } //namespace container { diff --git a/test/set_test.cpp b/test/set_test.cpp index f805b4f..57270c2 100644 --- a/test/set_test.cpp +++ b/test/set_test.cpp @@ -318,7 +318,6 @@ void test_merge_from_different_comparison() set1.merge(set2); } - int main () { //Recursive container instantiation @@ -345,6 +344,9 @@ int main () s.emplace(p); } + if (!boost::container::test::instantiate_constructors, multiset >()) + return 1; + test_merge_from_different_comparison(); //////////////////////////////////// diff --git a/test/set_test.hpp b/test/set_test.hpp index d123eb1..ce901c9 100644 --- a/test/set_test.hpp +++ b/test/set_test.hpp @@ -162,14 +162,14 @@ int set_test () IntType move_me(i/2); aux_vect3[i] = boost::move(move_me); } - ::boost::movelib::unique_ptr const pboostset = ::boost::movelib::make_unique + ::boost::movelib::unique_ptr const pboostset2 = ::boost::movelib::make_unique (boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0]+50), typename MyBoostSet::key_compare()); - ::boost::movelib::unique_ptr const pstdset = ::boost::movelib::make_unique(&aux_vect2[0], &aux_vect2[0]+50); - if(!test::CheckEqualContainers(*pboostset, *pstdset)) return 1; - ::boost::movelib::unique_ptr const pboostmultiset = ::boost::movelib::make_unique + ::boost::movelib::unique_ptr const pstdset2 = ::boost::movelib::make_unique(&aux_vect2[0], &aux_vect2[0]+50); + if(!test::CheckEqualContainers(*pboostset2, *pstdset2)) return 1; + ::boost::movelib::unique_ptr const pboostmultiset2 = ::boost::movelib::make_unique (boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0]+50), typename MyBoostMultiSet::key_compare()); - ::boost::movelib::unique_ptr const pstdmultiset = ::boost::movelib::make_unique(&aux_vect2[0], &aux_vect2[0]+50); - if(!test::CheckEqualContainers(*pboostmultiset, *pstdmultiset)) return 1; + ::boost::movelib::unique_ptr const pstdmultiset2 = ::boost::movelib::make_unique(&aux_vect2[0], &aux_vect2[0]+50); + if(!test::CheckEqualContainers(*pboostmultiset2, *pstdmultiset2)) return 1; } { //Set(beg, end, alloc) IntType aux_vect[50]; @@ -186,14 +186,14 @@ int set_test () IntType move_me(i/2); aux_vect3[i] = boost::move(move_me); } - ::boost::movelib::unique_ptr const pboostset = ::boost::movelib::make_unique + ::boost::movelib::unique_ptr const pboostset2 = ::boost::movelib::make_unique (boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0]+50), typename MyBoostSet::allocator_type()); - ::boost::movelib::unique_ptr const pstdset = ::boost::movelib::make_unique(&aux_vect2[0], &aux_vect2[0]+50); - if(!test::CheckEqualContainers(*pboostset, *pstdset)) return 1; - ::boost::movelib::unique_ptr const pboostmultiset = ::boost::movelib::make_unique + ::boost::movelib::unique_ptr const pstdset2 = ::boost::movelib::make_unique(&aux_vect2[0], &aux_vect2[0]+50); + if(!test::CheckEqualContainers(*pboostset2, *pstdset2)) return 1; + ::boost::movelib::unique_ptr const pboostmultiset2 = ::boost::movelib::make_unique (boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0]+50), typename MyBoostMultiSet::allocator_type()); - ::boost::movelib::unique_ptr const pstdmultiset = ::boost::movelib::make_unique(&aux_vect2[0], &aux_vect2[0]+50); - if(!test::CheckEqualContainers(*pboostmultiset, *pstdmultiset)) return 1; + ::boost::movelib::unique_ptr const pstdmultiset2 = ::boost::movelib::make_unique(&aux_vect2[0], &aux_vect2[0]+50); + if(!test::CheckEqualContainers(*pboostmultiset2, *pstdmultiset2)) return 1; } { IntType aux_vect[50]; @@ -842,6 +842,87 @@ bool test_set_methods_with_initializer_list_as_argument_for() return true; } +template +bool instantiate_constructors() +{ + { + typedef typename SetType::value_type value_type; + typename SetType::key_compare comp; + typename SetType::allocator_type a; + typename SetType::value_type value; + { + SetType s0; + SetType s1(comp); + SetType s2(a); + SetType s3(comp, a); + } + { + SetType s0(&value, &value); + SetType s1(&value, &value ,comp); + SetType s2(&value, &value ,a); + SetType s3(&value, &value ,comp, a); + } + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + { + SetType s0({ 0 }); + SetType s1({ 0 },comp); + SetType s2({ 0 },a); + SetType s3({ 0 },comp, a); + } + { + std::initializer_list il{0}; + SetType s0(ordered_unique_range, il); + SetType s1(ordered_unique_range, il,comp); + SetType s3(ordered_unique_range, il,comp, a); + } + #endif + { + SetType s0(ordered_unique_range, &value, &value); + SetType s1(ordered_unique_range, &value, &value ,comp); + SetType s2(ordered_unique_range, &value, &value ,comp, a); + } + } + + { + typename MultisetType::key_compare comp; + typename MultisetType::allocator_type a; + typename MultisetType::value_type value; + { + MultisetType s0; + MultisetType s1(comp); + MultisetType s2(a); + MultisetType s3(comp, a); + } + { + MultisetType s0(&value, &value); + MultisetType s1(&value, &value ,comp); + MultisetType s2(&value, &value ,a); + MultisetType s3(&value, &value ,comp, a); + } + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + { + MultisetType s0({ 0 }); + MultisetType s1({ 0 },comp); + MultisetType s2({ 0 },a); + MultisetType s3({ 0 },comp, a); + } + { + typedef typename MultisetType::value_type value_type; + std::initializer_listil{0}; + MultisetType s0(ordered_range, il); + MultisetType s1(ordered_range, il,comp); + MultisetType s3(ordered_range, il,comp, a); + } + #endif + { + MultisetType s0(ordered_range, &value, &value); + MultisetType s1(ordered_range, &value, &value ,comp); + MultisetType s2(ordered_range, &value, &value ,comp, a); + } + } + return true; +} + } //namespace test{ } //namespace container { } //namespace boost{