mirror of
https://github.com/boostorg/container.git
synced 2026-01-19 04:02:17 +00:00
Fixes #280 ("Several containers don't support non-movable types when move assigning")
This commit is contained in:
@@ -307,14 +307,17 @@ int test_cont_variants()
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::movable_int>::type MyMoveCont;
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::movable_and_copyable_int>::type MyCopyMoveCont;
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::copyable_int>::type MyCopyCont;
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::moveconstruct_int>::type MyMoveConstructCont;
|
||||
|
||||
if(test::vector_test<MyCont>())
|
||||
if (test::vector_test<MyCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyMoveCont>())
|
||||
if (test::vector_test<MyMoveCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyCopyMoveCont>())
|
||||
if (test::vector_test<MyCopyMoveCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyCopyCont>())
|
||||
if (test::vector_test<MyCopyCont>())
|
||||
return 1;
|
||||
if (test::vector_test<MyMoveConstructCont>())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3903,7 +3903,7 @@ struct GetAllocatorCont
|
||||
template<class ValueType>
|
||||
struct apply
|
||||
{
|
||||
typedef vector< ValueType
|
||||
typedef devector< ValueType
|
||||
, typename allocator_traits<VoidAllocator>
|
||||
::template portable_rebind_alloc<ValueType>::type
|
||||
> type;
|
||||
@@ -3962,14 +3962,19 @@ int test_cont_variants()
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::movable_int>::type MyMoveCont;
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::movable_and_copyable_int>::type MyCopyMoveCont;
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::copyable_int>::type MyCopyCont;
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::moveconstruct_int>::type MyMoveConstructCont;
|
||||
|
||||
if(test::vector_test<MyCont>())
|
||||
if (test::vector_test<MyCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyMoveCont>())
|
||||
if (test::vector_test<MyMoveCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyCopyMoveCont>())
|
||||
if (test::vector_test<MyCopyMoveCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyCopyCont>())
|
||||
if (test::vector_test<MyCopyCont>())
|
||||
return 1;
|
||||
if (test::vector_test<MyCopyCont>())
|
||||
return 1;
|
||||
if (test::vector_test<MyMoveConstructCont>())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <boost/container/list.hpp>
|
||||
#include <boost/container/adaptive_pool.hpp>
|
||||
#include <boost/container/node_allocator.hpp>
|
||||
|
||||
#include "dummy_test_allocator.hpp"
|
||||
#include <memory>
|
||||
@@ -78,9 +79,9 @@ struct GetAllocatorCont
|
||||
struct apply
|
||||
{
|
||||
typedef list< ValueType
|
||||
, typename allocator_traits<VoidAllocator>
|
||||
, typename allocator_traits<VoidAllocator>
|
||||
::template portable_rebind_alloc<ValueType>::type
|
||||
> type;
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -91,9 +92,11 @@ int test_cont_variants()
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::movable_int>::type MyMoveCont;
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::movable_and_copyable_int>::type MyCopyMoveCont;
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::copyable_int>::type MyCopyCont;
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::moveconstruct_int>::type MyMoveConstructCont;
|
||||
|
||||
if(test::list_test<MyCont, true>())
|
||||
return 1;
|
||||
|
||||
if(test::list_test<MyMoveCont, true>())
|
||||
return 1;
|
||||
if(test::list_test<MyCopyMoveCont, true>())
|
||||
@@ -102,6 +105,8 @@ int test_cont_variants()
|
||||
return 1;
|
||||
if(test::list_test<MyCopyCont, true>())
|
||||
return 1;
|
||||
if (test::list_test<MyMoveConstructCont, true>())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -171,20 +176,27 @@ int main ()
|
||||
////////////////////////////////////
|
||||
// Testing allocator implementations
|
||||
////////////////////////////////////
|
||||
// int variants
|
||||
if (test::list_test<list<int, std::allocator<int> >, true>())
|
||||
if (test_cont_variants< new_allocator<void> >()) {
|
||||
std::cerr << "test_cont_variants< std::allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
if (test::list_test<list<int>, true>())
|
||||
}
|
||||
|
||||
if (test_cont_variants< std::allocator<void> >()) {
|
||||
std::cerr << "test_cont_variants< std::allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
if (test::list_test<list<int, adaptive_pool<int> >, true>())
|
||||
return 1;
|
||||
if (test::list_test<list<test::movable_int>, true>())
|
||||
return 1;
|
||||
if (test::list_test<list<test::movable_and_copyable_int>, true>())
|
||||
return 1;
|
||||
if (test::list_test<list<test::copyable_int>, true>())
|
||||
return 1;
|
||||
|
||||
if (test::list_test<list<int, node_allocator<int> >, false>())
|
||||
return 1;
|
||||
/*
|
||||
// boost::container::allocator
|
||||
if (test_cont_variants< allocator<void> >()) {
|
||||
std::cerr << "test_cont_variants< allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
////////////////////////////////////
|
||||
// Emplace testing
|
||||
////////////////////////////////////
|
||||
|
||||
@@ -166,6 +166,61 @@ struct list_pop_back_function<false>
|
||||
}
|
||||
};
|
||||
|
||||
template<class
|
||||
, bool>
|
||||
int list_move_assignable_only(boost::container::dtl::false_type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Function to check if both sets are equal
|
||||
template < class MyBoostList
|
||||
, bool DoublyLinked >
|
||||
int list_move_assignable_only(boost::container::dtl::true_type)
|
||||
{
|
||||
typedef std::list<int> MyStdList;
|
||||
typedef typename MyBoostList::value_type IntType;
|
||||
const std::size_t max = 100u;
|
||||
typedef list_push_data_function<DoublyLinked> push_data_t;
|
||||
|
||||
{
|
||||
::boost::movelib::unique_ptr<MyStdList> const stdlistp = ::boost::movelib::make_unique<MyStdList>(100u);
|
||||
::boost::movelib::unique_ptr<MyBoostList> const boostlistp = ::boost::movelib::make_unique<MyBoostList>(100u);
|
||||
MyBoostList& boostlist = *boostlistp;
|
||||
MyStdList& stdlist = *stdlistp;
|
||||
|
||||
if (push_data_t::execute(max, boostlist, stdlist)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
IntType aux_vect[50];
|
||||
for (int i = 0; i < 50; ++i) {
|
||||
aux_vect[i] = -1;
|
||||
}
|
||||
int aux_vect2[50];
|
||||
for (int i = 0; i < 50; ++i) {
|
||||
aux_vect2[i] = -1;
|
||||
}
|
||||
boostlist.assign(boost::make_move_iterator(&aux_vect[0])
|
||||
, boost::make_move_iterator(&aux_vect[50]));
|
||||
stdlist.assign(&aux_vect2[0], &aux_vect2[50]);
|
||||
if (!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
|
||||
for (int i = 0; i < 50; ++i) {
|
||||
aux_vect[i] = -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 50; ++i) {
|
||||
aux_vect2[i] = -1;
|
||||
}
|
||||
boostlist.assign(boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0]))
|
||||
, boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[50])));
|
||||
stdlist.assign(&aux_vect2[0], &aux_vect2[50]);
|
||||
if (!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class MyBoostList
|
||||
,bool DoublyLinked>
|
||||
int list_test (bool copied_allocators_equal = true)
|
||||
@@ -203,9 +258,10 @@ int list_test (bool copied_allocators_equal = true)
|
||||
::boost::movelib::unique_ptr<MyBoostList> const boostlistp = ::boost::movelib::make_unique<MyBoostList>(100u);
|
||||
::boost::movelib::unique_ptr<MyBoostList> const boostlistp2 = ::boost::movelib::make_unique<MyBoostList>();
|
||||
*boostlistp2 = ::boost::move(*boostlistp);
|
||||
if(!test::CheckEqualContainers(*boostlistp2, *stdlistp)) return 1;
|
||||
if (!test::CheckEqualContainers(*boostlistp2, *stdlistp)) return 1;
|
||||
}
|
||||
|
||||
|
||||
::boost::movelib::unique_ptr<MyBoostList> const pboostlist = ::boost::movelib::make_unique<MyBoostList>();
|
||||
::boost::movelib::unique_ptr<MyStdList> const pstdlist = ::boost::movelib::make_unique<MyStdList>();
|
||||
|
||||
@@ -228,35 +284,9 @@ int list_test (bool copied_allocators_equal = true)
|
||||
stdlist.pop_front();
|
||||
if(!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
|
||||
{
|
||||
IntType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(-1);
|
||||
aux_vect[i] = boost::move(move_me);
|
||||
}
|
||||
int aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -1;
|
||||
}
|
||||
boostlist.assign(boost::make_move_iterator(&aux_vect[0])
|
||||
,boost::make_move_iterator(&aux_vect[50]));
|
||||
stdlist.assign(&aux_vect2[0], &aux_vect2[50]);
|
||||
if(!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(-1);
|
||||
aux_vect[i] = boost::move(move_me);
|
||||
}
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -1;
|
||||
}
|
||||
boostlist.assign(boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0]))
|
||||
,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[50])));
|
||||
stdlist.assign(&aux_vect2[0], &aux_vect2[50]);
|
||||
if(!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
}
|
||||
|
||||
if (0 != list_move_assignable_only<MyBoostList, DoublyLinked>(dtl::bool_<boost::container::test::is_move_assignable<IntType>::value>()))
|
||||
return 1;
|
||||
|
||||
if(copied_allocators_equal){
|
||||
boostlist.sort();
|
||||
stdlist.sort();
|
||||
@@ -274,8 +304,7 @@ int list_test (bool copied_allocators_equal = true)
|
||||
{
|
||||
IntType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(-1);
|
||||
aux_vect[i] = boost::move(move_me);
|
||||
aux_vect[i] = -1;
|
||||
}
|
||||
int aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
@@ -294,8 +323,7 @@ int list_test (bool copied_allocators_equal = true)
|
||||
return 1;
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(-1);
|
||||
aux_vect[i] = boost::move(move_me);
|
||||
aux_vect[i] = -1;
|
||||
}
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
|
||||
@@ -557,6 +557,15 @@ int main ()
|
||||
std::cout << "Error in map_test<new_allocator<void>, red_black_tree>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::map_test
|
||||
< GetAllocatorMap<new_allocator<void>, red_black_tree>::apply<test::moveconstruct_int>::map_type
|
||||
, MyStdMap
|
||||
, GetAllocatorMap<new_allocator<void>, red_black_tree>::apply<test::moveconstruct_int>::multimap_type
|
||||
, MyStdMultiMap>()) {
|
||||
std::cout << "Error in map_test<new_allocator<void>, red_black_tree>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
|
||||
@@ -54,6 +54,78 @@ void map_test_rebalanceable(C &c, boost::container::dtl::true_type)
|
||||
c.rebalance();
|
||||
}
|
||||
|
||||
template<class MyBoostMap
|
||||
, class MyStdMap
|
||||
, class MyBoostMultiMap
|
||||
, class MyStdMultiMap>
|
||||
int map_move_assignable_only(boost::container::dtl::false_type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Function to check if both sets are equal
|
||||
template<class MyBoostMap
|
||||
, class MyStdMap
|
||||
, class MyBoostMultiMap
|
||||
, class MyStdMultiMap>
|
||||
int map_move_assignable_only(boost::container::dtl::true_type)
|
||||
{
|
||||
typedef typename MyBoostMap::key_type IntType;
|
||||
typedef dtl::pair<IntType, IntType> IntPairType;
|
||||
|
||||
//This is really nasty, but we have no other simple choice
|
||||
IntPairType aux_vect[(std::size_t)MaxElem];
|
||||
for (int i = 0; i < MaxElem; ++i) {
|
||||
IntType i1(i / 2);
|
||||
IntType i2(i / 2);
|
||||
new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
|
||||
typedef typename MyStdMap::value_type StdValueType;
|
||||
typedef typename MyStdMap::key_type StdKeyType;
|
||||
typedef typename MyStdMap::mapped_type StdMappedType;
|
||||
StdValueType aux_vect2[(std::size_t)MaxElem];
|
||||
for (int i = 0; i < MaxElem; ++i) {
|
||||
new(&aux_vect2[i])StdValueType(StdKeyType(i / 2), StdMappedType(i / 2));
|
||||
}
|
||||
|
||||
IntPairType aux_vect3[(std::size_t)MaxElem];
|
||||
for (int i = 0; i < MaxElem; ++i) {
|
||||
IntType i1(i / 2);
|
||||
IntType i2(i / 2);
|
||||
new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
|
||||
::boost::movelib::unique_ptr<MyBoostMap> const pboostmap2 = ::boost::movelib::make_unique<MyBoostMap>
|
||||
(boost::make_move_iterator(&aux_vect[0])
|
||||
, boost::make_move_iterator(&aux_vect[0] + MaxElem));
|
||||
::boost::movelib::unique_ptr<MyStdMap> const pstdmap2 = ::boost::movelib::make_unique<MyStdMap>
|
||||
(&aux_vect2[0], &aux_vect2[0] + MaxElem);
|
||||
::boost::movelib::unique_ptr<MyBoostMultiMap> const pboostmultimap2 = ::boost::movelib::make_unique<MyBoostMultiMap>
|
||||
(boost::make_move_iterator(&aux_vect3[0])
|
||||
, boost::make_move_iterator(&aux_vect3[0] + MaxElem));
|
||||
::boost::movelib::unique_ptr<MyStdMultiMap> const pstdmultimap2 = ::boost::movelib::make_unique<MyStdMultiMap>
|
||||
(&aux_vect2[0], &aux_vect2[0] + MaxElem);
|
||||
MyBoostMap& boostmap2 = *pboostmap2;
|
||||
MyStdMap& stdmap2 = *pstdmap2;
|
||||
|
||||
/* fix assignable */
|
||||
{
|
||||
IntType i0(0);
|
||||
IntType i1(1);
|
||||
boostmap2[::boost::move(i0)] = ::boost::move(i1);
|
||||
}
|
||||
{
|
||||
IntType i1(1);
|
||||
boostmap2[IntType(0)] = ::boost::move(i1);
|
||||
}
|
||||
stdmap2[0] = 1;
|
||||
if (!CheckEqualContainers(boostmap2, stdmap2)) return 1;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class MyBoostMap
|
||||
,class MyStdMap
|
||||
,class MyBoostMultiMap
|
||||
@@ -67,8 +139,8 @@ template<class MyBoostMap
|
||||
,class MyStdMultiMap>
|
||||
int map_test_copyable(boost::container::dtl::true_type)
|
||||
{
|
||||
typedef typename MyBoostMap::key_type IntType;
|
||||
typedef dtl::pair<IntType, IntType> IntPairType;
|
||||
typedef typename MyBoostMap::key_type IntType;
|
||||
typedef dtl::pair<IntType, IntType> IntPairType;
|
||||
typedef typename MyStdMap::value_type StdPairType;
|
||||
|
||||
::boost::movelib::unique_ptr<MyBoostMap> const pboostmap = ::boost::movelib::make_unique<MyBoostMap>();
|
||||
@@ -366,6 +438,9 @@ int map_test_step(MyBoostMap &, MyStdMap &, MyBoostMultiMap &, MyStdMultiMap &)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != map_move_assignable_only<MyBoostMap, MyStdMap, MyBoostMultiMap, MyStdMultiMap>(dtl::bool_<boost::container::test::is_move_assignable<IntType>::value>()))
|
||||
return 1;
|
||||
|
||||
{
|
||||
IntType i0(0);
|
||||
boostmap2.erase(i0);
|
||||
@@ -373,17 +448,6 @@ int map_test_step(MyBoostMap &, MyStdMap &, MyBoostMultiMap &, MyStdMultiMap &)
|
||||
stdmap2.erase(0);
|
||||
stdmultimap2.erase(0);
|
||||
}
|
||||
{
|
||||
IntType i0(0);
|
||||
IntType i1(1);
|
||||
boostmap2[::boost::move(i0)] = ::boost::move(i1);
|
||||
}
|
||||
{
|
||||
IntType i1(1);
|
||||
boostmap2[IntType(0)] = ::boost::move(i1);
|
||||
}
|
||||
stdmap2[0] = 1;
|
||||
if(!CheckEqualContainers(boostmap2, stdmap2)) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -819,12 +883,12 @@ int map_test_indexing(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &b
|
||||
IntType i2(i);
|
||||
new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
|
||||
/*
|
||||
for(int i = 0; i < MaxElem; ++i){
|
||||
boostmap[boost::move(aux_vect[i].first)] = boost::move(aux_vect[i].second);
|
||||
stdmap[i] = i;
|
||||
}
|
||||
|
||||
*/
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
}
|
||||
@@ -934,14 +998,20 @@ int map_test_insert_or_assign_impl()
|
||||
return 0;
|
||||
}
|
||||
|
||||
template< class MyBoostMap, class StdMap, class Copyable>
|
||||
int map_test_insert_or_assign(dtl::bool_<false>, Copyable)//noncopyable
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template< class MyBoostMap, class StdMap>
|
||||
int map_test_insert_or_assign(dtl::bool_<false> )//noncopyable
|
||||
int map_test_insert_or_assign(dtl::bool_<true>, dtl::bool_<false> )//noncopyable
|
||||
{
|
||||
return map_test_insert_or_assign_impl<MyBoostMap, StdMap, move_op>();
|
||||
}
|
||||
|
||||
template< class MyBoostMap, class StdMap>
|
||||
int map_test_insert_or_assign(dtl::bool_<true> )//copyable
|
||||
int map_test_insert_or_assign(dtl::bool_<true>, dtl::bool_<true> )//copyable
|
||||
{
|
||||
int r = map_test_insert_or_assign_impl<MyBoostMap, StdMap, const_ref_op>();
|
||||
if (r)
|
||||
@@ -1165,6 +1235,7 @@ int map_test()
|
||||
MyBoostMultiMap &boostmultimap = *pboostmultimap;
|
||||
MyStdMultiMap &stdmultimap = *pstdmultimap;
|
||||
typedef dtl::bool_<boost::container::test::is_copyable<IntType>::value> copyable_t;
|
||||
typedef dtl::bool_<boost::container::test::is_move_assignable<IntType>::value> move_assignable_t;
|
||||
|
||||
if (map_test_step(boostmap, stdmap, boostmultimap, stdmultimap))
|
||||
return 1;
|
||||
@@ -1190,7 +1261,7 @@ int map_test()
|
||||
if (map_test_merge(boostmap, stdmap, boostmultimap, stdmultimap))
|
||||
return 1;
|
||||
|
||||
if (map_test_insert_or_assign<MyBoostMap, MyStdMap>(copyable_t()))
|
||||
if (map_test_insert_or_assign<MyBoostMap, MyStdMap>(move_assignable_t(), copyable_t()))
|
||||
return 1;
|
||||
|
||||
if(map_test_copyable<MyBoostMap, MyStdMap, MyBoostMultiMap, MyStdMultiMap>(copyable_t()))
|
||||
|
||||
@@ -37,6 +37,11 @@ struct is_move_assignable
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct is_move_constructible
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////
|
||||
@@ -594,6 +599,13 @@ struct life_count< non_copymovable_int >
|
||||
{ return c == non_copymovable_int::count; }
|
||||
};
|
||||
|
||||
template<>
|
||||
struct is_move_constructible<non_copymovable_int>
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
|
||||
} //namespace test {
|
||||
} //namespace container {
|
||||
} //namespace boost {
|
||||
|
||||
@@ -544,6 +544,15 @@ int main ()
|
||||
std::cout << "Error in set_test<new_allocator<void>, red_black_tree>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::set_test
|
||||
< GetAllocatorSet<new_allocator<void>, red_black_tree>::apply<test::moveconstruct_int>::set_type
|
||||
, MyStdSet
|
||||
, GetAllocatorSet<new_allocator<void>, red_black_tree>::apply<test::moveconstruct_int>::multiset_type
|
||||
, MyStdMultiSet>()) {
|
||||
std::cout << "Error in set_test<new_allocator<void>, red_black_tree>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
|
||||
@@ -161,8 +161,7 @@ int set_test ()
|
||||
{ //Set(beg, end, compare)
|
||||
IntType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(i/2);
|
||||
aux_vect[i] = boost::move(move_me);
|
||||
aux_vect[i] = i/2;
|
||||
}
|
||||
int aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
@@ -170,8 +169,7 @@ int set_test ()
|
||||
}
|
||||
IntType aux_vect3[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(i/2);
|
||||
aux_vect3[i] = boost::move(move_me);
|
||||
aux_vect3[i] = i/2;
|
||||
}
|
||||
::boost::movelib::unique_ptr<MyBoostSet> const pboostset2 = ::boost::movelib::make_unique<MyBoostSet>
|
||||
(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0]+50), typename MyBoostSet::key_compare());
|
||||
@@ -185,8 +183,7 @@ int set_test ()
|
||||
{ //Set(beg, end, alloc)
|
||||
IntType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(i/2);
|
||||
aux_vect[i] = boost::move(move_me);
|
||||
aux_vect[i] = i/2;
|
||||
}
|
||||
int aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
@@ -194,8 +191,7 @@ int set_test ()
|
||||
}
|
||||
IntType aux_vect3[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(i/2);
|
||||
aux_vect3[i] = boost::move(move_me);
|
||||
aux_vect3[i] = i/2;
|
||||
}
|
||||
::boost::movelib::unique_ptr<MyBoostSet> const pboostset2 = ::boost::movelib::make_unique<MyBoostSet>
|
||||
(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0]+50), typename MyBoostSet::allocator_type());
|
||||
@@ -209,8 +205,7 @@ int set_test ()
|
||||
{
|
||||
IntType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(i/2);
|
||||
aux_vect[i] = boost::move(move_me);
|
||||
aux_vect[i] = i/2;
|
||||
}
|
||||
int aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
@@ -218,8 +213,7 @@ int set_test ()
|
||||
}
|
||||
IntType aux_vect3[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(i/2);
|
||||
aux_vect3[i] = boost::move(move_me);
|
||||
aux_vect3[i] = i/2;
|
||||
}
|
||||
|
||||
::boost::movelib::unique_ptr<MyBoostSet> const pboostset2 = ::boost::movelib::make_unique<MyBoostSet>
|
||||
@@ -249,8 +243,7 @@ int set_test ()
|
||||
|
||||
//ordered range insertion
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(i);
|
||||
aux_vect[i] = boost::move(move_me);
|
||||
aux_vect[i] = i;
|
||||
}
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
@@ -258,8 +251,7 @@ int set_test ()
|
||||
}
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(i);
|
||||
aux_vect3[i] = boost::move(move_me);
|
||||
aux_vect3[i] = i;
|
||||
}
|
||||
|
||||
//some comparison operators
|
||||
@@ -410,8 +402,7 @@ int set_test ()
|
||||
{
|
||||
IntType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(-1);
|
||||
aux_vect[i] = boost::move(move_me);
|
||||
aux_vect[i] = -1;
|
||||
}
|
||||
int aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
@@ -419,8 +410,7 @@ int set_test ()
|
||||
}
|
||||
IntType aux_vect3[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(-1);
|
||||
aux_vect3[i] = boost::move(move_me);
|
||||
aux_vect3[i] = -1;
|
||||
}
|
||||
|
||||
boostset.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + 50));
|
||||
@@ -455,8 +445,7 @@ int set_test ()
|
||||
{
|
||||
IntType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(-1);
|
||||
aux_vect[i] = boost::move(move_me);
|
||||
aux_vect[i] = -1;
|
||||
}
|
||||
int aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
@@ -464,20 +453,17 @@ int set_test ()
|
||||
}
|
||||
IntType aux_vect3[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(-1);
|
||||
aux_vect3[i] = boost::move(move_me);
|
||||
aux_vect3[i] = -1;
|
||||
}
|
||||
|
||||
IntType aux_vect4[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(-1);
|
||||
aux_vect4[i] = boost::move(move_me);
|
||||
aux_vect4[i] = -1;
|
||||
}
|
||||
|
||||
IntType aux_vect5[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(-1);
|
||||
aux_vect5[i] = boost::move(move_me);
|
||||
aux_vect5[i] = -1;
|
||||
}
|
||||
|
||||
boostset.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + 50));
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/container/slist.hpp>
|
||||
#include <boost/container/node_allocator.hpp>
|
||||
#include <boost/container/adaptive_pool.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include "dummy_test_allocator.hpp"
|
||||
@@ -54,6 +55,32 @@ struct GetAllocatorCont
|
||||
};
|
||||
};
|
||||
|
||||
template<class VoidAllocator>
|
||||
int test_cont_variants()
|
||||
{
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<int>::type MyCont;
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::movable_int>::type MyMoveCont;
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::movable_and_copyable_int>::type MyCopyMoveCont;
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::copyable_int>::type MyCopyCont;
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::moveconstruct_int>::type MyMoveConstructCont;
|
||||
|
||||
if(test::list_test<MyCont, false>())
|
||||
return 1;
|
||||
|
||||
if(test::list_test<MyMoveCont, false>())
|
||||
return 1;
|
||||
if(test::list_test<MyCopyMoveCont, false>())
|
||||
return 1;
|
||||
if(test::list_test<MyCopyMoveCont, false>())
|
||||
return 1;
|
||||
if(test::list_test<MyCopyCont, false>())
|
||||
return 1;
|
||||
if (test::list_test<MyMoveConstructCont, false>())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool test_support_for_initializer_list()
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||
@@ -168,18 +195,18 @@ int main ()
|
||||
////////////////////////////////////
|
||||
// Testing allocator implementations
|
||||
////////////////////////////////////
|
||||
if (test::list_test<slist<int, std::allocator<int> >, false>())
|
||||
if (test_cont_variants< new_allocator<void> >()) {
|
||||
std::cerr << "test_cont_variants< std::allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
if (test::list_test<slist<int>, false>())
|
||||
}
|
||||
if (test_cont_variants< std::allocator<void> >()) {
|
||||
std::cerr << "test_cont_variants< std::allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
if (test::list_test<slist<int, adaptive_pool<int> >, false>())
|
||||
return 1;
|
||||
if (test::list_test<slist<int, node_allocator<int> >, false>())
|
||||
return 1;
|
||||
if (test::list_test<slist<test::movable_int>, false>())
|
||||
return 1;
|
||||
if (test::list_test<slist<test::movable_and_copyable_int>, false>())
|
||||
return 1;
|
||||
if (test::list_test<slist<test::copyable_int>, false>())
|
||||
return 1;
|
||||
|
||||
////////////////////////////////////
|
||||
// Emplace testing
|
||||
|
||||
@@ -193,10 +193,10 @@ int main()
|
||||
if(!test_swap())
|
||||
return 1;
|
||||
|
||||
if(test::vector_test< small_vector<int, 0> >())
|
||||
if (test::vector_test< small_vector<int, 0> >())
|
||||
return 1;
|
||||
|
||||
if(test::vector_test< small_vector<int, 2000> >())
|
||||
if (test::vector_test< small_vector<int, 2000> >())
|
||||
return 1;
|
||||
|
||||
if (test_cont_variants< new_allocator<void> >())
|
||||
|
||||
@@ -72,14 +72,17 @@ int test_cont_variants()
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::movable_int>::type MyMoveCont;
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::movable_and_copyable_int>::type MyCopyMoveCont;
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::copyable_int>::type MyCopyCont;
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::moveconstruct_int>::type MyMoveConstructCont;
|
||||
|
||||
if(test::vector_test<MyCont>())
|
||||
if (test::vector_test<MyCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyMoveCont>())
|
||||
if (test::vector_test<MyMoveCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyCopyMoveCont>())
|
||||
if (test::vector_test<MyCopyMoveCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyCopyCont>())
|
||||
if (test::vector_test<MyCopyCont>())
|
||||
return 1;
|
||||
if (test::vector_test<MyMoveConstructCont>())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include <boost/container/vector.hpp>
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <boost/container/node_allocator.hpp>
|
||||
#include <boost/container/adaptive_pool.hpp>
|
||||
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include "check_equal_containers.hpp"
|
||||
@@ -129,13 +131,13 @@ int test_cont_variants()
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::copyable_int>::type MyCopyCont;
|
||||
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::moveconstruct_int>::type MyMoveConstructCont;
|
||||
|
||||
if(test::vector_test<MyCont>())
|
||||
if (test::vector_test<MyCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyMoveCont>())
|
||||
if (test::vector_test<MyMoveCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyCopyMoveCont>())
|
||||
if (test::vector_test<MyCopyMoveCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyCopyCont>())
|
||||
if (test::vector_test<MyCopyCont>())
|
||||
return 1;
|
||||
if (test::vector_test<MyMoveConstructCont>())
|
||||
return 1;
|
||||
|
||||
@@ -269,6 +269,8 @@ bool vector_copyable_only(MyBoostVector &boostvector, MyStdVector &stdvector, bo
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class MyBoostVector>
|
||||
int vector_move_assignable_only(boost::container::dtl::false_type)
|
||||
{
|
||||
@@ -345,9 +347,7 @@ int vector_move_assignable_only(boost::container::dtl::true_type)
|
||||
//Initialize values
|
||||
IntType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType new_int(-1);
|
||||
BOOST_CONTAINER_STATIC_ASSERT((boost::container::test::is_copyable<boost::container::test::movable_int>::value == false));
|
||||
aux_vect[i] = boost::move(new_int);
|
||||
aux_vect[i] = -1;
|
||||
}
|
||||
int aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
@@ -374,8 +374,7 @@ int vector_move_assignable_only(boost::container::dtl::true_type)
|
||||
|
||||
IntType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType new_int(-i);
|
||||
aux_vect[i] = boost::move(new_int);
|
||||
aux_vect[i] = -i;
|
||||
}
|
||||
int aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
@@ -391,8 +390,7 @@ int vector_move_assignable_only(boost::container::dtl::true_type)
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType new_int(-i);
|
||||
aux_vect[i] = boost::move(new_int);
|
||||
aux_vect[i] = -i;
|
||||
}
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
@@ -511,6 +509,30 @@ int vector_move_assignable_only(boost::container::dtl::true_type)
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class MyBoostVector>
|
||||
int vector_test_fully_propagable(dtl::true_ /* fully_propagable */)
|
||||
{
|
||||
typedef std::vector<int> MyStdVector;
|
||||
{
|
||||
//operator=(Vector &&)
|
||||
::boost::movelib::unique_ptr<MyStdVector> const stdvectorp =
|
||||
::boost::movelib::make_unique<MyStdVector>(100u);
|
||||
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp =
|
||||
::boost::movelib::make_unique<MyBoostVector>(100u);
|
||||
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp2 =
|
||||
::boost::movelib::make_unique<MyBoostVector>();
|
||||
*boostvectorp2 = ::boost::move(*boostvectorp);
|
||||
if (!test::CheckEqualContainers(*boostvectorp2, *stdvectorp)) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class MyBoostVector>
|
||||
int vector_test_fully_propagable(dtl::false_ /* fully_propagable */)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class MyBoostVector>
|
||||
int vector_test()
|
||||
{
|
||||
@@ -551,7 +573,10 @@ int vector_test()
|
||||
if(!test::CheckEqualContainers(*boostvectorp2, *stdvectorp)) return 1;
|
||||
}
|
||||
|
||||
if (0 != vector_move_assignable_only< MyBoostVector>(dtl::bool_<boost::container::test::is_copyable<IntType>::value>()))
|
||||
if (0 != vector_test_fully_propagable<MyBoostVector>
|
||||
( dtl::bool_< !allocator_traits<typename MyBoostVector::allocator_type>::is_partially_propagable::value >() )) return 1;
|
||||
|
||||
if (0 != vector_move_assignable_only< MyBoostVector>(dtl::bool_<boost::container::test::is_move_assignable<IntType>::value>()))
|
||||
return 1;
|
||||
|
||||
std::cout << std::endl << "Test OK!" << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user