Fixes #221 ("flat_set and friends should offer a const sequence_type& sequence() const method (...)")

This commit is contained in:
Ion Gaztañaga
2022-06-25 20:29:16 +02:00
parent 4ea5cd7911
commit 34cd414280
6 changed files with 69 additions and 18 deletions
+6 -6
View File
@@ -1396,15 +1396,15 @@ class flat_tree
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
container_type extract_sequence()
{
return boost::move(m_data.m_seq);
}
{ return boost::move(m_data.m_seq); }
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
container_type &get_sequence_ref()
{
return m_data.m_seq;
}
{ return m_data.m_seq; }
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
const container_type &get_sequence_cref() const
{ return m_data.m_seq; }
BOOST_CONTAINER_FORCEINLINE void adopt_sequence_equal(BOOST_RV_REF(container_type) seq)
{
+22 -4
View File
@@ -64,6 +64,10 @@ template<class D, class S>
BOOST_CONTAINER_FORCEINLINE static D &force(S &s)
{ return *move_detail::force_ptr<D*>(&s); }
template<class D, class S>
BOOST_CONTAINER_FORCEINLINE static const D &force(const S &s)
{ return *move_detail::force_ptr<const D*>(&s); }
template<class D, class S>
BOOST_CONTAINER_FORCEINLINE static D force_copy(const S &s)
{
@@ -104,7 +108,7 @@ BOOST_CONTAINER_FORCEINLINE static D force_copy(const S &s)
//! - The allocator to allocate <code>value_type</code>s (e.g. <i>allocator< std::pair<Key, T> > </i>).
//! (in this case <i>sequence_type</i> will be vector<value_type, AllocatorOrContainer>)
//! - The SequenceContainer to be used as the underlying <i>sequence_type</i>. It must be a vector-like
//! sequence container with random-access iterators..
//! sequence container with random-access iterators.
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
template <class Key, class T, class Compare = std::less<Key>, class AllocatorOrContainer = new_allocator< std::pair< Key, T> > >
#else
@@ -1569,6 +1573,14 @@ class flat_map
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(dtl::force<impl_sequence_type>(seq))); }
//! <b>Effects</b>: Returns a const view of the underlying sequence.
//!
//! <b>Complexity</b>: Constant
//!
//! <b>Throws</b>: Nothing
BOOST_CONTAINER_FORCEINLINE const sequence_type & sequence() const BOOST_NOEXCEPT
{ return dtl::force<sequence_type>(m_flat_tree.get_sequence_cref()); }
//! <b>Effects</b>: Returns true if x and y are equal
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
@@ -2887,9 +2899,7 @@ class flat_multimap
//! <b>Throws</b>: If secuence_type's move constructor throws
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
sequence_type extract_sequence()
{
return boost::move(dtl::force<sequence_type>(m_flat_tree.get_sequence_ref()));
}
{ return boost::move(dtl::force<sequence_type>(m_flat_tree.get_sequence_ref())); }
//! <b>Effects</b>: Discards the internally hold sequence container and adopts the
//! one passed externally using the move assignment.
@@ -2911,6 +2921,14 @@ class flat_multimap
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(dtl::force<impl_sequence_type>(seq))); }
//! <b>Effects</b>: Returns a const view of the underlying sequence.
//!
//! <b>Complexity</b>: Constant
//!
//! <b>Throws</b>: Nothing
BOOST_CONTAINER_FORCEINLINE const sequence_type & sequence() const BOOST_NOEXCEPT
{ return dtl::force<sequence_type>(m_flat_tree.get_sequence_cref()); }
//! <b>Effects</b>: Returns true if x and y are equal
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
+16
View File
@@ -1122,6 +1122,14 @@ class flat_set
//! <b>Throws</b>: If the move assignment throws
BOOST_CONTAINER_FORCEINLINE void adopt_sequence(ordered_unique_range_t, BOOST_RV_REF(sequence_type) seq)
{ this->tree_t::adopt_sequence_unique(ordered_unique_range_t(), boost::move(seq)); }
//! <b>Effects</b>: Returns a const view of the underlying sequence.
//!
//! <b>Complexity</b>: Constant
//!
//! <b>Throws</b>: Nothing
BOOST_CONTAINER_FORCEINLINE const sequence_type & sequence() const BOOST_NOEXCEPT
{ return this->get_sequence_cref(); }
};
#ifndef BOOST_CONTAINER_NO_CXX17_CTAD
@@ -1845,6 +1853,14 @@ class flat_multiset
//! <b>Throws</b>: If the move assignment throws
BOOST_CONTAINER_FORCEINLINE void adopt_sequence(ordered_range_t, BOOST_RV_REF(sequence_type) seq)
{ this->tree_t::adopt_sequence_equal(ordered_range_t(), boost::move(seq)); }
//! <b>Effects</b>: Returns a const view of the underlying sequence.
//!
//! <b>Complexity</b>: Constant
//!
//! <b>Throws</b>: Nothing
BOOST_CONTAINER_FORCEINLINE const sequence_type & sequence() const BOOST_NOEXCEPT
{ return this->get_sequence_cref(); }
};
#ifndef BOOST_CONTAINER_NO_CXX17_CTAD