added rvalue ref merge

(test expected to fail in C++03)
This commit is contained in:
joaquintides 2021-08-05 09:23:32 +02:00
parent 6dd60d07ac
commit 7d2b9dd808
2 changed files with 25 additions and 5 deletions

View File

@ -77,7 +77,6 @@
#if !defined(BOOST_NO_SFINAE)
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/utility/enable_if.hpp>
#endif
@ -546,9 +545,8 @@ public:
#if !defined(BOOST_NO_SFINAE)
typename enable_if_c<
is_same<
typename remove_reference<Index>::type::node_type,node_type>::value&&
!is_const<typename remove_reference<Index>::type>::value
!is_const<Index>::value&&
is_same<typename Index::node_type,node_type>::value
>::type
#else
void
@ -559,7 +557,7 @@ public:
BOOST_MULTI_INDEX_CHECK_EQUAL_ALLOCATORS(*this,x);
BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT;
typedef typename remove_reference<Index>::type::iterator source_iterator;
typedef typename Index::iterator source_iterator;
source_iterator first=x.begin(),last=x.end();
if(static_cast<final_node_type*>(last.get_node())!=
@ -571,6 +569,20 @@ public:
}
}
template<typename Index>
#if !defined(BOOST_NO_SFINAE)
typename enable_if_c<
!is_const<Index>::value&&
is_same<typename Index::node_type,node_type>::value
>::type
#else
void
#endif
merge(BOOST_RV_REF(Index) x){merge(static_cast<Index&>(x));}
/* observers */
key_from_value key_extractor()const{return key;}

View File

@ -428,6 +428,14 @@ void test_merge()
BOOST_TEST(c1.size()==10&&c2.size()==0);
c2.merge(c1.get<2>());
BOOST_TEST(c1.size()==0&&c2.size()==10);
c2.merge(c2);
BOOST_TEST(c2.size()==10);
c2.merge(boost::move(c2));
BOOST_TEST(c2.size()==10);
c2.merge(boost::move(c2.get<3>()));
BOOST_TEST(c2.size()==10);
c2.merge(container(c2));
BOOST_TEST(c2.size()==20);
}
void test_node_handling()