From 3af1cdefe0352b89c39086ed4a2303f04aeb0ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 5 Jan 2014 22:29:33 +0100 Subject: [PATCH] Inherit flat_set/flat_multiset from flat_tree to avoid code instantiation in debug mode and several trivial functions. Declarations still there for doxygen documentation. --- include/boost/container/flat_set.hpp | 96 ++++++++++------------------ 1 file changed, 34 insertions(+), 62 deletions(-) diff --git a/include/boost/container/flat_set.hpp b/include/boost/container/flat_set.hpp index e5a5269..c1b2e57 100644 --- a/include/boost/container/flat_set.hpp +++ b/include/boost/container/flat_set.hpp @@ -92,14 +92,14 @@ class flat_set // ////////////////////////////////////////////// - //! Effects: Default constructs an empty flat_set. + //! Effects: Default constructs an empty container. //! //! Complexity: Constant. explicit flat_set() : base_t() {} - //! Effects: Constructs an empty flat_set using the specified + //! Effects: Constructs an empty container using the specified //! comparison object and allocator. //! //! Complexity: Constant. @@ -108,14 +108,14 @@ class flat_set : base_t(comp, a) {} - //! Effects: Constructs an empty flat_set using the specified allocator. + //! Effects: Constructs an empty container using the specified allocator. //! //! Complexity: Constant. explicit flat_set(const allocator_type& a) : base_t(a) {} - //! Effects: Constructs an empty set using the specified comparison object and + //! 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 @@ -127,7 +127,7 @@ class flat_set : base_t(true, first, last, comp, a) {} - //! Effects: Constructs an empty flat_set using the specified comparison object and + //! Effects: Constructs an empty container 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. //! @@ -144,31 +144,31 @@ class flat_set : base_t(ordered_range, first, last, comp, a) {} - //! Effects: Copy constructs a set. + //! Effects: Copy constructs the container. //! //! Complexity: Linear in x.size(). flat_set(const flat_set& x) : base_t(static_cast(x)) {} - //! Effects: Move constructs a set. Constructs *this using x's resources. + //! Effects: Move constructs thecontainer. Constructs *this using mx's resources. //! //! Complexity: Constant. //! - //! Postcondition: x is emptied. + //! Postcondition: mx is emptied. flat_set(BOOST_RV_REF(flat_set) mx) : base_t(boost::move(static_cast(mx))) {} - //! Effects: Copy constructs a set using the specified allocator. + //! Effects: Copy constructs a container using the specified allocator. //! //! Complexity: Linear in x.size(). flat_set(const flat_set& x, const allocator_type &a) : base_t(static_cast(x), a) {} - //! Effects: Move constructs a set using the specified allocator. - //! Constructs *this using x's resources. + //! Effects: Move constructs a container using the specified allocator. + //! Constructs *this using mx's resources. //! //! Complexity: Constant if a == mx.get_allocator(), linear otherwise flat_set(BOOST_RV_REF(flat_set) mx, const allocator_type &a) @@ -179,9 +179,9 @@ class flat_set //! //! Complexity: Linear in x.size(). flat_set& operator=(BOOST_COPY_ASSIGN_REF(flat_set) x) - { return static_cast(this->base_t::operator=(x)); } + { return static_cast(this->base_t::operator=(static_cast(x))); } - //! Effects: Makes *this a copy of the previous value of xx. + //! Effects: Makes *this a copy of the previous value of mx. //! //! Complexity: Linear in x.size(). flat_set& operator=(BOOST_RV_REF(flat_set) mx) @@ -690,7 +690,7 @@ namespace container { //! //! This container provides random-access iterators. //! -//! \tparam Key is the type to be inserted in the set, which is also the key_type +//! \tparam Key is the type to be inserted in the multiset, which is also the key_type //! \tparam Compare is the comparison functor used to order keys //! \tparam Allocator is the allocator to be used to allocate memory for this container #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED @@ -732,29 +732,23 @@ class flat_multiset typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator; typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator; - //! Effects: Default constructs an empty flat_multiset. - //! - //! Complexity: Constant. + //! @copydoc ::boost::container::flat_set::flat_set() explicit flat_multiset() : base_t() {} - //! Effects: Constructs an empty flat_multiset using the specified - //! comparison object and allocator. - //! - //! Complexity: Constant. + //! @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) {} - //! Effects: Constructs an empty flat_multiset using the specified allocator. - //! - //! Complexity: Constant. + //! @copydoc ::boost::container::flat_set::flat_set(const allocator_type&) 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&) template flat_multiset(InputIterator first, InputIterator last, const Compare& comp = Compare(), @@ -778,46 +772,31 @@ class flat_multiset : base_t(ordered_range, first, last, comp, a) {} - //! Effects: Copy constructs a flat_multiset. - //! - //! Complexity: Linear in x.size(). + //! @copydoc ::boost::container::flat_set::flat_set(const flat_set &) flat_multiset(const flat_multiset& x) : base_t(static_cast(x)) {} - //! Effects: Move constructs a flat_multiset. Constructs *this using x's resources. - //! - //! Complexity: Constant. - //! - //! Postcondition: x is emptied. + //! @copydoc ::boost::container::flat_set(flat_set &&) flat_multiset(BOOST_RV_REF(flat_multiset) mx) : base_t(boost::move(static_cast(mx))) {} - //! Effects: Copy constructs a flat_multiset using the specified allocator. - //! - //! Complexity: Linear in x.size(). + //! @copydoc ::boost::container::flat_set(const flat_set &, const allocator_type &) flat_multiset(const flat_multiset& x, const allocator_type &a) : base_t(static_cast(x), a) {} - //! Effects: Move constructs a flat_multiset using the specified allocator. - //! Constructs *this using x's resources. - //! - //! Complexity: Constant if a == mx.get_allocator(), linear otherwise + //! @copydoc ::boost::container::flat_set(flat_set &&, const allocator_type &) flat_multiset(BOOST_RV_REF(flat_multiset) mx, const allocator_type &a) : base_t(boost::move(static_cast(mx)), a) {} - //! Effects: Makes *this a copy of x. - //! - //! Complexity: Linear in x.size(). + //! @copydoc ::boost::container::flat_set::operator=(const flat_set &) flat_multiset& operator=(BOOST_COPY_ASSIGN_REF(flat_multiset) x) - { return static_cast(this->base_t::operator=(x)); } + { return static_cast(this->base_t::operator=(static_cast(x))); } - //! Effects: Makes *this a copy of x. - //! - //! Complexity: Linear in x.size(). + //! @copydoc ::boost::container::flat_set::operator=(flat_set &&) flat_multiset& operator=(BOOST_RV_REF(flat_multiset) mx) { return static_cast(this->base_t::operator=(boost::move(static_cast(mx)))); } @@ -1067,49 +1046,42 @@ class flat_multiset //! @copydoc ::boost::container::flat_set::equal_range(const key_type& ) std::pair equal_range(const key_type& x); - #endif - //! Effects: Returns true if x and y are equal //! //! Complexity: Linear to the number of elements in the container. - friend bool operator==(const flat_multiset& x, const flat_multiset& y) - { return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); } + friend bool operator==(const flat_multiset& x, const flat_multiset& y); //! Effects: Returns true if x and y are unequal //! //! Complexity: Linear to the number of elements in the container. - friend bool operator!=(const flat_multiset& x, const flat_multiset& y) - { return !(x == y); } + friend bool operator!=(const flat_multiset& x, const flat_multiset& 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_multiset& x, const flat_multiset& y) - { return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } + friend bool operator<(const flat_multiset& x, const flat_multiset& y); //! Effects: Returns true if x is greater than y //! //! Complexity: Linear to the number of elements in the container. - friend bool operator>(const flat_multiset& x, const flat_multiset& y) - { return y < x; } + friend bool operator>(const flat_multiset& x, const flat_multiset& y); //! 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_multiset& x, const flat_multiset& y) - { return !(y < x); } + friend bool operator<=(const flat_multiset& x, const flat_multiset& y); //! 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_multiset& x, const flat_multiset& y) - { return !(x < y); } + friend bool operator>=(const flat_multiset& x, const flat_multiset& y); //! Effects: x.swap(y) //! //! Complexity: Constant. - friend void swap(flat_multiset& x, flat_multiset& y) - { x.swap(y); } + friend void swap(flat_multiset& x, flat_multiset& y); + + #endif //#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: