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