forked from boostorg/container
Changes during Git migration:
- Added Extended Allocator support for Boost.Container. - Improved Doxygen generated reference - Fixed ticket #9338 ("VS2005 compiler errors in swap() definition after including container/memory_util.hpp")
This commit is contained in:
+2
-2
@@ -1,6 +1,6 @@
|
||||
# Boost Container Library Test Jamfile
|
||||
|
||||
# (C) Copyright Ion Gaztanaga 2009.
|
||||
# (C) Copyright Ion Gaztanaga 2009-2013.
|
||||
# Use, modification and distribution are subject to the
|
||||
# Boost Software License, Version 1.0. (See accompanying file
|
||||
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -21,7 +21,7 @@ rule test_all
|
||||
|
||||
for local fileb in [ glob *.cpp ]
|
||||
{
|
||||
all_rules += [ run $(fileb)
|
||||
all_rules += [ run $(fileb) /boost/container//boost_container /boost/timer//boost_timer
|
||||
: # additional args
|
||||
: # test-files
|
||||
: # requirements
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2011-2012. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
+66
-12
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2004-2013. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
@@ -17,6 +17,10 @@
|
||||
#include <list>
|
||||
|
||||
#include <boost/container/deque.hpp>
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <boost/container/node_allocator.hpp>
|
||||
#include <boost/container/adaptive_pool.hpp>
|
||||
|
||||
#include "print_container.hpp"
|
||||
#include "check_equal_containers.hpp"
|
||||
#include "dummy_test_allocator.hpp"
|
||||
@@ -29,6 +33,7 @@
|
||||
#include "emplace_test.hpp"
|
||||
#include "propagate_allocator_test.hpp"
|
||||
#include "vector_test.hpp"
|
||||
#include "default_init_test.hpp"
|
||||
#include <boost/detail/no_exceptions_support.hpp>
|
||||
|
||||
using namespace boost::container;
|
||||
@@ -49,6 +54,18 @@ template class boost::container::deque
|
||||
< test::movable_and_copyable_int
|
||||
, std::allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
template class boost::container::deque
|
||||
< test::movable_and_copyable_int
|
||||
, allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
template class boost::container::deque
|
||||
< test::movable_and_copyable_int
|
||||
, adaptive_pool<test::movable_and_copyable_int> >;
|
||||
|
||||
template class boost::container::deque
|
||||
< test::movable_and_copyable_int
|
||||
, node_allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
}}
|
||||
|
||||
//Function to check if both sets are equal
|
||||
@@ -145,11 +162,8 @@ bool do_test()
|
||||
typedef std::deque<int> MyStdDeque;
|
||||
const int max = 100;
|
||||
BOOST_TRY{
|
||||
//Shared memory allocator must be always be initialized
|
||||
//since it has no default constructor
|
||||
MyCntDeque *cntdeque = new MyCntDeque;
|
||||
MyStdDeque *stddeque = new MyStdDeque;
|
||||
//Compare several shared memory deque operations with std::deque
|
||||
for(int i = 0; i < max*100; ++i){
|
||||
IntType move_me(i);
|
||||
cntdeque->insert(cntdeque->end(), boost::move(move_me));
|
||||
@@ -295,6 +309,38 @@ bool do_test()
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class VoidAllocator>
|
||||
struct GetAllocatorCont
|
||||
{
|
||||
template<class ValueType>
|
||||
struct apply
|
||||
{
|
||||
typedef deque< ValueType
|
||||
, typename allocator_traits<VoidAllocator>
|
||||
::template portable_rebind_alloc<ValueType>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
if(test::vector_test<MyCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyMoveCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyCopyMoveCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyCopyCont>())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main ()
|
||||
{
|
||||
@@ -320,18 +366,26 @@ int main ()
|
||||
}
|
||||
|
||||
{
|
||||
typedef deque<int> MyDeque;
|
||||
typedef deque<test::movable_int> MyMoveDeque;
|
||||
typedef deque<test::movable_and_copyable_int> MyCopyMoveDeque;
|
||||
typedef deque<test::copyable_int> MyCopyDeque;
|
||||
if(test::vector_test<MyDeque>())
|
||||
if(test_cont_variants< std::allocator<void> >()){
|
||||
std::cerr << "test_cont_variants< std::allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
if(test::vector_test<MyMoveDeque>())
|
||||
}
|
||||
|
||||
if(test_cont_variants< allocator<void> >()){
|
||||
std::cerr << "test_cont_variants< allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
if(test::vector_test<MyCopyMoveDeque>())
|
||||
}
|
||||
|
||||
if(test_cont_variants< node_allocator<void> >()){
|
||||
std::cerr << "test_cont_variants< node_allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
if(test::vector_test<MyCopyDeque>())
|
||||
}
|
||||
|
||||
if(test_cont_variants< adaptive_pool<void> >()){
|
||||
std::cerr << "test_cont_variants< adaptive_pool<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!test::default_init_test< deque<int, test::default_init_allocator<int> > >()){
|
||||
std::cerr << "Default init test failed" << std::endl;
|
||||
return 1;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
@@ -11,7 +11,7 @@
|
||||
#ifndef BOOST_CONTAINER_DUMMY_TEST_ALLOCATOR_HPP
|
||||
#define BOOST_CONTAINER_DUMMY_TEST_ALLOCATOR_HPP
|
||||
|
||||
#if (defined _MSC_VER)
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
@@ -33,9 +33,6 @@
|
||||
#include <cstddef>
|
||||
#include <cassert>
|
||||
|
||||
//!\file
|
||||
//!Describes an allocator to test expand capabilities
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
namespace test {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
@@ -11,7 +11,7 @@
|
||||
#ifndef BOOST_CONTAINER_EXPAND_BWD_TEST_ALLOCATOR_HPP
|
||||
#define BOOST_CONTAINER_EXPAND_BWD_TEST_ALLOCATOR_HPP
|
||||
|
||||
#if (defined _MSC_VER)
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
@@ -29,9 +29,6 @@
|
||||
#include <cstddef>
|
||||
#include <cassert>
|
||||
|
||||
//!\file
|
||||
//!Describes an allocator to test expand capabilities
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
namespace test {
|
||||
|
||||
@@ -187,8 +187,8 @@ bool test_assign_with_expand_bwd()
|
||||
|
||||
const int Offset[] = { 50, 50, 50};
|
||||
const int InitialSize[] = { 25, 25, 25};
|
||||
const int AssignSize[] = { 40, 60, 80};
|
||||
const int Iterations = sizeof(AssignSize)/sizeof(int);
|
||||
const int InsertSize[] = { 15, 35, 55};
|
||||
const int Iterations = sizeof(InsertSize)/sizeof(int);
|
||||
|
||||
for(int iteration = 0; iteration <Iterations; ++iteration)
|
||||
{
|
||||
@@ -202,10 +202,10 @@ bool test_assign_with_expand_bwd()
|
||||
}
|
||||
|
||||
//Create data to assign
|
||||
std::vector<non_volatile_value_type> data_to_assign;
|
||||
data_to_assign.resize(AssignSize[iteration]);
|
||||
for(int i = 0; i < AssignSize[iteration]; ++i){
|
||||
data_to_assign[i] = -i;
|
||||
std::vector<non_volatile_value_type> data_to_insert;
|
||||
data_to_insert.resize(InsertSize[iteration]);
|
||||
for(int i = 0; i < InsertSize[iteration]; ++i){
|
||||
data_to_insert[i] = -i;
|
||||
}
|
||||
|
||||
//Insert initial data to the vector to test
|
||||
@@ -216,8 +216,8 @@ bool test_assign_with_expand_bwd()
|
||||
, initial_data.begin(), initial_data.end());
|
||||
|
||||
//Assign data
|
||||
vector.assign(data_to_assign.begin(), data_to_assign.end());
|
||||
initial_data.assign(data_to_assign.begin(), data_to_assign.end());
|
||||
vector.insert(vector.cbegin(), data_to_insert.begin(), data_to_insert.end());
|
||||
initial_data.insert(initial_data.begin(), data_to_insert.begin(), data_to_insert.end());
|
||||
|
||||
//Now check that values are equal
|
||||
if(!CheckEqualVector(vector, initial_data)){
|
||||
|
||||
@@ -1,640 +0,0 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <set>
|
||||
#include <boost/container/flat_set.hpp>
|
||||
#include <boost/container/flat_map.hpp>
|
||||
#include "print_container.hpp"
|
||||
#include "dummy_test_allocator.hpp"
|
||||
#include "movable_int.hpp"
|
||||
#include "set_test.hpp"
|
||||
#include "map_test.hpp"
|
||||
#include "propagate_allocator_test.hpp"
|
||||
#include "emplace_test.hpp"
|
||||
#include <vector>
|
||||
#include <boost/container/detail/flat_tree.hpp>
|
||||
|
||||
using namespace boost::container;
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
|
||||
//Explicit instantiation to detect compilation errors
|
||||
|
||||
//flat_map
|
||||
template class flat_map
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::dummy_test_allocator
|
||||
< std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class flat_map
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::simple_allocator
|
||||
< std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class flat_map
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, std::allocator
|
||||
< std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
//flat_multimap
|
||||
template class flat_multimap
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::dummy_test_allocator
|
||||
< std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class flat_multimap
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::simple_allocator
|
||||
< std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class flat_multimap
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, std::allocator
|
||||
< std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
//flat_set
|
||||
template class flat_set
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::dummy_test_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class flat_set
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::simple_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class flat_set
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, std::allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
//flat_multiset
|
||||
template class flat_multiset
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::dummy_test_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class flat_multiset
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::simple_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class flat_multiset
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, std::allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
//As flat container iterators are typedefs for vector::[const_]iterator,
|
||||
//no need to explicit instantiate them
|
||||
|
||||
}} //boost::container
|
||||
|
||||
|
||||
//Alias allocator type
|
||||
typedef std::allocator<int> allocator_t;
|
||||
typedef std::allocator<test::movable_int>
|
||||
movable_allocator_t;
|
||||
typedef std::allocator<std::pair<int, int> >
|
||||
pair_allocator_t;
|
||||
typedef std::allocator<std::pair<test::movable_int, test::movable_int> >
|
||||
movable_pair_allocator_t;
|
||||
typedef std::allocator<test::movable_and_copyable_int >
|
||||
move_copy_allocator_t;
|
||||
typedef std::allocator<std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
move_copy_pair_allocator_t;
|
||||
typedef std::allocator<test::copyable_int >
|
||||
copy_allocator_t;
|
||||
typedef std::allocator<std::pair<test::copyable_int, test::copyable_int> >
|
||||
copy_pair_allocator_t;
|
||||
|
||||
|
||||
//Alias set types
|
||||
typedef std::set<int> MyStdSet;
|
||||
typedef std::multiset<int> MyStdMultiSet;
|
||||
typedef std::map<int, int> MyStdMap;
|
||||
typedef std::multimap<int, int> MyStdMultiMap;
|
||||
|
||||
typedef flat_set<int, std::less<int>, allocator_t> MyBoostSet;
|
||||
typedef flat_multiset<int, std::less<int>, allocator_t> MyBoostMultiSet;
|
||||
typedef flat_map<int, int, std::less<int>, pair_allocator_t> MyBoostMap;
|
||||
typedef flat_multimap<int, int, std::less<int>, pair_allocator_t> MyBoostMultiMap;
|
||||
|
||||
typedef flat_set<test::movable_int, std::less<test::movable_int>
|
||||
,movable_allocator_t> MyMovableBoostSet;
|
||||
typedef flat_multiset<test::movable_int,std::less<test::movable_int>
|
||||
,movable_allocator_t> MyMovableBoostMultiSet;
|
||||
typedef flat_map<test::movable_int, test::movable_int
|
||||
,std::less<test::movable_int>
|
||||
,movable_pair_allocator_t> MyMovableBoostMap;
|
||||
typedef flat_multimap<test::movable_int, test::movable_int
|
||||
,std::less<test::movable_int>
|
||||
,movable_pair_allocator_t> MyMovableBoostMultiMap;
|
||||
|
||||
typedef flat_set<test::movable_and_copyable_int, std::less<test::movable_and_copyable_int>
|
||||
,move_copy_allocator_t> MyMoveCopyBoostSet;
|
||||
typedef flat_multiset<test::movable_and_copyable_int,std::less<test::movable_and_copyable_int>
|
||||
,move_copy_allocator_t> MyMoveCopyBoostMultiSet;
|
||||
typedef flat_map<test::movable_and_copyable_int, test::movable_and_copyable_int
|
||||
,std::less<test::movable_and_copyable_int>
|
||||
,move_copy_pair_allocator_t> MyMoveCopyBoostMap;
|
||||
typedef flat_multimap<test::movable_and_copyable_int, test::movable_and_copyable_int
|
||||
,std::less<test::movable_and_copyable_int>
|
||||
,move_copy_pair_allocator_t> MyMoveCopyBoostMultiMap;
|
||||
|
||||
typedef flat_set<test::copyable_int, std::less<test::copyable_int>
|
||||
,copy_allocator_t> MyCopyBoostSet;
|
||||
typedef flat_multiset<test::copyable_int,std::less<test::copyable_int>
|
||||
,copy_allocator_t> MyCopyBoostMultiSet;
|
||||
typedef flat_map<test::copyable_int, test::copyable_int
|
||||
,std::less<test::copyable_int>
|
||||
,copy_pair_allocator_t> MyCopyBoostMap;
|
||||
typedef flat_multimap<test::copyable_int, test::copyable_int
|
||||
,std::less<test::copyable_int>
|
||||
,copy_pair_allocator_t> MyCopyBoostMultiMap;
|
||||
|
||||
|
||||
//Test recursive structures
|
||||
class recursive_flat_set
|
||||
{
|
||||
public:
|
||||
recursive_flat_set(const recursive_flat_set &c)
|
||||
: id_(c.id_), flat_set_(c.flat_set_)
|
||||
{}
|
||||
|
||||
recursive_flat_set & operator =(const recursive_flat_set &c)
|
||||
{
|
||||
id_ = c.id_;
|
||||
flat_set_= c.flat_set_;
|
||||
return *this;
|
||||
}
|
||||
int id_;
|
||||
flat_set<recursive_flat_set> flat_set_;
|
||||
friend bool operator< (const recursive_flat_set &a, const recursive_flat_set &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
class recursive_flat_map
|
||||
{
|
||||
public:
|
||||
recursive_flat_map(const recursive_flat_map &c)
|
||||
: id_(c.id_), map_(c.map_)
|
||||
{}
|
||||
|
||||
recursive_flat_map & operator =(const recursive_flat_map &c)
|
||||
{
|
||||
id_ = c.id_;
|
||||
map_= c.map_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int id_;
|
||||
flat_map<recursive_flat_map, recursive_flat_map> map_;
|
||||
|
||||
friend bool operator< (const recursive_flat_map &a, const recursive_flat_map &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
};
|
||||
|
||||
//Test recursive structures
|
||||
class recursive_flat_multiset
|
||||
{
|
||||
public:
|
||||
recursive_flat_multiset(const recursive_flat_multiset &c)
|
||||
: id_(c.id_), flat_multiset_(c.flat_multiset_)
|
||||
{}
|
||||
|
||||
recursive_flat_multiset & operator =(const recursive_flat_multiset &c)
|
||||
{
|
||||
id_ = c.id_;
|
||||
flat_multiset_= c.flat_multiset_;
|
||||
return *this;
|
||||
}
|
||||
int id_;
|
||||
flat_multiset<recursive_flat_multiset> flat_multiset_;
|
||||
friend bool operator< (const recursive_flat_multiset &a, const recursive_flat_multiset &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
};
|
||||
|
||||
class recursive_flat_multimap
|
||||
{
|
||||
public:
|
||||
recursive_flat_multimap(const recursive_flat_multimap &c)
|
||||
: id_(c.id_), map_(c.map_)
|
||||
{}
|
||||
|
||||
recursive_flat_multimap & operator =(const recursive_flat_multimap &c)
|
||||
{
|
||||
id_ = c.id_;
|
||||
map_= c.map_;
|
||||
return *this;
|
||||
}
|
||||
int id_;
|
||||
flat_map<recursive_flat_multimap, recursive_flat_multimap> map_;
|
||||
friend bool operator< (const recursive_flat_multimap &a, const recursive_flat_multimap &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
};
|
||||
|
||||
template<class C>
|
||||
void test_move()
|
||||
{
|
||||
//Now test move semantics
|
||||
C original;
|
||||
C move_ctor(boost::move(original));
|
||||
C move_assign;
|
||||
move_assign = boost::move(move_ctor);
|
||||
move_assign.swap(original);
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
class flat_tree_propagate_test_wrapper
|
||||
: public container_detail::flat_tree<T, T, container_detail::identity<T>, std::less<T>, A>
|
||||
{
|
||||
BOOST_COPYABLE_AND_MOVABLE(flat_tree_propagate_test_wrapper)
|
||||
typedef container_detail::flat_tree<T, T, container_detail::identity<T>, std::less<T>, A> Base;
|
||||
public:
|
||||
flat_tree_propagate_test_wrapper()
|
||||
: Base()
|
||||
{}
|
||||
|
||||
flat_tree_propagate_test_wrapper(const flat_tree_propagate_test_wrapper &x)
|
||||
: Base(x)
|
||||
{}
|
||||
|
||||
flat_tree_propagate_test_wrapper(BOOST_RV_REF(flat_tree_propagate_test_wrapper) x)
|
||||
: Base(boost::move(static_cast<Base&>(x)))
|
||||
{}
|
||||
|
||||
flat_tree_propagate_test_wrapper &operator=(BOOST_COPY_ASSIGN_REF(flat_tree_propagate_test_wrapper) x)
|
||||
{ this->Base::operator=(x); return *this; }
|
||||
|
||||
flat_tree_propagate_test_wrapper &operator=(BOOST_RV_REF(flat_tree_propagate_test_wrapper) x)
|
||||
{ this->Base::operator=(boost::move(static_cast<Base&>(x))); return *this; }
|
||||
|
||||
void swap(flat_tree_propagate_test_wrapper &x)
|
||||
{ this->Base::swap(x); }
|
||||
};
|
||||
|
||||
namespace boost{
|
||||
namespace container {
|
||||
namespace test{
|
||||
|
||||
bool flat_tree_ordered_insertion_test()
|
||||
{
|
||||
using namespace boost::container;
|
||||
const std::size_t NumElements = 100;
|
||||
|
||||
//Ordered insertion multiset
|
||||
{
|
||||
std::multiset<int> int_mset;
|
||||
for(std::size_t i = 0; i != NumElements; ++i){
|
||||
int_mset.insert(static_cast<int>(i));
|
||||
}
|
||||
//Construction insertion
|
||||
flat_multiset<int> fmset(ordered_range, int_mset.begin(), int_mset.end());
|
||||
if(!CheckEqualContainers(&int_mset, &fmset))
|
||||
return false;
|
||||
//Insertion when empty
|
||||
fmset.clear();
|
||||
fmset.insert(ordered_range, int_mset.begin(), int_mset.end());
|
||||
if(!CheckEqualContainers(&int_mset, &fmset))
|
||||
return false;
|
||||
//Re-insertion
|
||||
fmset.insert(ordered_range, int_mset.begin(), int_mset.end());
|
||||
std::multiset<int> int_mset2(int_mset);
|
||||
int_mset2.insert(int_mset.begin(), int_mset.end());
|
||||
if(!CheckEqualContainers(&int_mset2, &fmset))
|
||||
return false;
|
||||
//Re-re-insertion
|
||||
fmset.insert(ordered_range, int_mset2.begin(), int_mset2.end());
|
||||
std::multiset<int> int_mset4(int_mset2);
|
||||
int_mset4.insert(int_mset2.begin(), int_mset2.end());
|
||||
if(!CheckEqualContainers(&int_mset4, &fmset))
|
||||
return false;
|
||||
//Re-re-insertion of even
|
||||
std::multiset<int> int_even_mset;
|
||||
for(std::size_t i = 0; i < NumElements; i+=2){
|
||||
int_mset.insert(static_cast<int>(i));
|
||||
}
|
||||
fmset.insert(ordered_range, int_even_mset.begin(), int_even_mset.end());
|
||||
int_mset4.insert(int_even_mset.begin(), int_even_mset.end());
|
||||
if(!CheckEqualContainers(&int_mset4, &fmset))
|
||||
return false;
|
||||
}
|
||||
//Ordered insertion multimap
|
||||
{
|
||||
std::multimap<int, int> int_mmap;
|
||||
for(std::size_t i = 0; i != NumElements; ++i){
|
||||
int_mmap.insert(std::multimap<int, int>::value_type(static_cast<int>(i), static_cast<int>(i)));
|
||||
}
|
||||
//Construction insertion
|
||||
flat_multimap<int, int> fmmap(ordered_range, int_mmap.begin(), int_mmap.end());
|
||||
if(!CheckEqualContainers(&int_mmap, &fmmap))
|
||||
return false;
|
||||
//Insertion when empty
|
||||
fmmap.clear();
|
||||
fmmap.insert(ordered_range, int_mmap.begin(), int_mmap.end());
|
||||
if(!CheckEqualContainers(&int_mmap, &fmmap))
|
||||
return false;
|
||||
//Re-insertion
|
||||
fmmap.insert(ordered_range, int_mmap.begin(), int_mmap.end());
|
||||
std::multimap<int, int> int_mmap2(int_mmap);
|
||||
int_mmap2.insert(int_mmap.begin(), int_mmap.end());
|
||||
if(!CheckEqualContainers(&int_mmap2, &fmmap))
|
||||
return false;
|
||||
//Re-re-insertion
|
||||
fmmap.insert(ordered_range, int_mmap2.begin(), int_mmap2.end());
|
||||
std::multimap<int, int> int_mmap4(int_mmap2);
|
||||
int_mmap4.insert(int_mmap2.begin(), int_mmap2.end());
|
||||
if(!CheckEqualContainers(&int_mmap4, &fmmap))
|
||||
return false;
|
||||
//Re-re-insertion of even
|
||||
std::multimap<int, int> int_even_mmap;
|
||||
for(std::size_t i = 0; i < NumElements; i+=2){
|
||||
int_mmap.insert(std::multimap<int, int>::value_type(static_cast<int>(i), static_cast<int>(i)));
|
||||
}
|
||||
fmmap.insert(ordered_range, int_even_mmap.begin(), int_even_mmap.end());
|
||||
int_mmap4.insert(int_even_mmap.begin(), int_even_mmap.end());
|
||||
if(!CheckEqualContainers(&int_mmap4, &fmmap))
|
||||
return false;
|
||||
}
|
||||
|
||||
//Ordered insertion set
|
||||
{
|
||||
std::set<int> int_set;
|
||||
for(std::size_t i = 0; i != NumElements; ++i){
|
||||
int_set.insert(static_cast<int>(i));
|
||||
}
|
||||
//Construction insertion
|
||||
flat_set<int> fset(ordered_unique_range, int_set.begin(), int_set.end());
|
||||
if(!CheckEqualContainers(&int_set, &fset))
|
||||
return false;
|
||||
//Insertion when empty
|
||||
fset.clear();
|
||||
fset.insert(ordered_unique_range, int_set.begin(), int_set.end());
|
||||
if(!CheckEqualContainers(&int_set, &fset))
|
||||
return false;
|
||||
//Re-insertion
|
||||
fset.insert(ordered_unique_range, int_set.begin(), int_set.end());
|
||||
std::set<int> int_set2(int_set);
|
||||
int_set2.insert(int_set.begin(), int_set.end());
|
||||
if(!CheckEqualContainers(&int_set2, &fset))
|
||||
return false;
|
||||
//Re-re-insertion
|
||||
fset.insert(ordered_unique_range, int_set2.begin(), int_set2.end());
|
||||
std::set<int> int_set4(int_set2);
|
||||
int_set4.insert(int_set2.begin(), int_set2.end());
|
||||
if(!CheckEqualContainers(&int_set4, &fset))
|
||||
return false;
|
||||
//Re-re-insertion of even
|
||||
std::set<int> int_even_set;
|
||||
for(std::size_t i = 0; i < NumElements; i+=2){
|
||||
int_set.insert(static_cast<int>(i));
|
||||
}
|
||||
fset.insert(ordered_unique_range, int_even_set.begin(), int_even_set.end());
|
||||
int_set4.insert(int_even_set.begin(), int_even_set.end());
|
||||
if(!CheckEqualContainers(&int_set4, &fset))
|
||||
return false;
|
||||
}
|
||||
//Ordered insertion map
|
||||
{
|
||||
std::map<int, int> int_map;
|
||||
for(std::size_t i = 0; i != NumElements; ++i){
|
||||
int_map.insert(std::map<int, int>::value_type(static_cast<int>(i), static_cast<int>(i)));
|
||||
}
|
||||
//Construction insertion
|
||||
flat_map<int, int> fmap(ordered_unique_range, int_map.begin(), int_map.end());
|
||||
if(!CheckEqualContainers(&int_map, &fmap))
|
||||
return false;
|
||||
//Insertion when empty
|
||||
fmap.clear();
|
||||
fmap.insert(ordered_unique_range, int_map.begin(), int_map.end());
|
||||
if(!CheckEqualContainers(&int_map, &fmap))
|
||||
return false;
|
||||
//Re-insertion
|
||||
fmap.insert(ordered_unique_range, int_map.begin(), int_map.end());
|
||||
std::map<int, int> int_map2(int_map);
|
||||
int_map2.insert(int_map.begin(), int_map.end());
|
||||
if(!CheckEqualContainers(&int_map2, &fmap))
|
||||
return false;
|
||||
//Re-re-insertion
|
||||
fmap.insert(ordered_unique_range, int_map2.begin(), int_map2.end());
|
||||
std::map<int, int> int_map4(int_map2);
|
||||
int_map4.insert(int_map2.begin(), int_map2.end());
|
||||
if(!CheckEqualContainers(&int_map4, &fmap))
|
||||
return false;
|
||||
//Re-re-insertion of even
|
||||
std::map<int, int> int_even_map;
|
||||
for(std::size_t i = 0; i < NumElements; i+=2){
|
||||
int_map.insert(std::map<int, int>::value_type(static_cast<int>(i), static_cast<int>(i)));
|
||||
}
|
||||
fmap.insert(ordered_unique_range, int_even_map.begin(), int_even_map.end());
|
||||
int_map4.insert(int_even_map.begin(), int_even_map.end());
|
||||
if(!CheckEqualContainers(&int_map4, &fmap))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::container::test;
|
||||
|
||||
//Allocator argument container
|
||||
{
|
||||
flat_set<int> set_((std::allocator<int>()));
|
||||
flat_multiset<int> multiset_((std::allocator<int>()));
|
||||
flat_map<int, int> map_((std::allocator<std::pair<int, int> >()));
|
||||
flat_multimap<int, int> multimap_((std::allocator<std::pair<int, int> >()));
|
||||
}
|
||||
//Now test move semantics
|
||||
{
|
||||
test_move<flat_set<recursive_flat_set> >();
|
||||
test_move<flat_multiset<recursive_flat_multiset> >();
|
||||
test_move<flat_map<recursive_flat_map, recursive_flat_map> >();
|
||||
test_move<flat_multimap<recursive_flat_multimap, recursive_flat_multimap> >();
|
||||
}
|
||||
|
||||
if(!flat_tree_ordered_insertion_test()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != set_test<
|
||||
MyBoostSet
|
||||
,MyStdSet
|
||||
,MyBoostMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != set_test_copyable<
|
||||
MyBoostSet
|
||||
,MyStdSet
|
||||
,MyBoostMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != set_test<
|
||||
MyMovableBoostSet
|
||||
,MyStdSet
|
||||
,MyMovableBoostMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
std::cout << "Error in set_test<MyMovableBoostSet>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != set_test<
|
||||
MyMoveCopyBoostSet
|
||||
,MyStdSet
|
||||
,MyMoveCopyBoostMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
std::cout << "Error in set_test<MyMoveCopyBoostSet>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != set_test_copyable<
|
||||
MyMoveCopyBoostSet
|
||||
,MyStdSet
|
||||
,MyMoveCopyBoostMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != set_test<
|
||||
MyCopyBoostSet
|
||||
,MyStdSet
|
||||
,MyCopyBoostMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
std::cout << "Error in set_test<MyCopyBoostSet>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != set_test_copyable<
|
||||
MyCopyBoostSet
|
||||
,MyStdSet
|
||||
,MyCopyBoostMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != map_test<
|
||||
MyBoostMap
|
||||
,MyStdMap
|
||||
,MyBoostMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
std::cout << "Error in set_test<MyBoostMap>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != map_test_copyable<
|
||||
MyBoostMap
|
||||
,MyStdMap
|
||||
,MyBoostMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
std::cout << "Error in set_test<MyBoostMap>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != map_test<
|
||||
MyMovableBoostMap
|
||||
,MyStdMap
|
||||
,MyMovableBoostMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != map_test<
|
||||
MyMoveCopyBoostMap
|
||||
,MyStdMap
|
||||
,MyMoveCopyBoostMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
std::cout << "Error in set_test<MyMoveCopyBoostMap>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != map_test_copyable<
|
||||
MyMoveCopyBoostMap
|
||||
,MyStdMap
|
||||
,MyMoveCopyBoostMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
std::cout << "Error in set_test<MyBoostMap>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != map_test<
|
||||
MyCopyBoostMap
|
||||
,MyStdMap
|
||||
,MyCopyBoostMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
std::cout << "Error in set_test<MyCopyBoostMap>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != map_test_copyable<
|
||||
MyCopyBoostMap
|
||||
,MyStdMap
|
||||
,MyCopyBoostMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
std::cout << "Error in set_test<MyBoostMap>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const test::EmplaceOptions SetOptions = (test::EmplaceOptions)(test::EMPLACE_HINT | test::EMPLACE_ASSOC);
|
||||
const test::EmplaceOptions MapOptions = (test::EmplaceOptions)(test::EMPLACE_HINT_PAIR | test::EMPLACE_ASSOC_PAIR);
|
||||
|
||||
if(!boost::container::test::test_emplace<flat_map<test::EmplaceInt, test::EmplaceInt>, MapOptions>())
|
||||
return 1;
|
||||
if(!boost::container::test::test_emplace<flat_multimap<test::EmplaceInt, test::EmplaceInt>, MapOptions>())
|
||||
return 1;
|
||||
if(!boost::container::test::test_emplace<flat_set<test::EmplaceInt>, SetOptions>())
|
||||
return 1;
|
||||
if(!boost::container::test::test_emplace<flat_multiset<test::EmplaceInt>, SetOptions>())
|
||||
return 1;
|
||||
if(!boost::container::test::test_propagate_allocator<flat_tree_propagate_test_wrapper>())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
@@ -1,158 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_CONTAINER_HEAP_ALLOCATOR_V1_HPP
|
||||
#define BOOST_CONTAINER_HEAP_ALLOCATOR_V1_HPP
|
||||
|
||||
#if (defined _MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/detail/workaround.hpp>
|
||||
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
|
||||
#include <boost/container/container_fwd.hpp>
|
||||
#include <boost/container/detail/allocation_type.hpp>
|
||||
#include <boost/container/detail/utilities.hpp>
|
||||
#include <boost/container/detail/version_type.hpp>
|
||||
#include <boost/container/exceptions.hpp>
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
|
||||
//!\file
|
||||
//!Describes an heap_allocator_v1 that allocates portions of fixed size
|
||||
//!memory buffer (shared memory, mapped file...)
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
namespace test {
|
||||
|
||||
//!An STL compatible heap_allocator_v1 that uses a segment manager as
|
||||
//!memory source. The internal pointer type will of the same type (raw, smart) as
|
||||
//!"typename SegmentManager::void_pointer" type. This allows
|
||||
//!placing the heap_allocator_v1 in shared memory, memory mapped-files, etc...*/
|
||||
template<class T, class SegmentManager>
|
||||
class heap_allocator_v1
|
||||
{
|
||||
private:
|
||||
typedef heap_allocator_v1<T, SegmentManager> self_t;
|
||||
typedef SegmentManager segment_manager;
|
||||
typedef typename segment_manager::void_pointer aux_pointer_t;
|
||||
|
||||
typedef typename
|
||||
boost::pointer_to_other
|
||||
<aux_pointer_t, const void>::type cvoid_ptr;
|
||||
|
||||
typedef typename boost::pointer_to_other
|
||||
<cvoid_ptr, segment_manager>::type alloc_ptr_t;
|
||||
|
||||
template<class T2, class SegmentManager2>
|
||||
heap_allocator_v1& operator=(const heap_allocator_v1<T2, SegmentManager2>&);
|
||||
|
||||
heap_allocator_v1& operator=(const heap_allocator_v1&);
|
||||
|
||||
alloc_ptr_t mp_mngr;
|
||||
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef typename boost::pointer_to_other
|
||||
<cvoid_ptr, T>::type pointer;
|
||||
typedef typename boost::
|
||||
pointer_to_other<pointer, const T>::type const_pointer;
|
||||
typedef typename detail::add_reference
|
||||
<value_type>::type reference;
|
||||
typedef typename detail::add_reference
|
||||
<const value_type>::type const_reference;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
//!Obtains an heap_allocator_v1 of other type
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
typedef heap_allocator_v1<T2, SegmentManager> other;
|
||||
};
|
||||
|
||||
//!Returns the segment manager. Never throws
|
||||
segment_manager* get_segment_manager()const
|
||||
{ return detail::get_pointer(mp_mngr); }
|
||||
/*
|
||||
//!Returns address of mutable object. Never throws
|
||||
pointer address(reference value) const
|
||||
{ return pointer(addressof(value)); }
|
||||
|
||||
//!Returns address of non mutable object. Never throws
|
||||
const_pointer address(const_reference value) const
|
||||
{ return const_pointer(addressof(value)); }
|
||||
*/
|
||||
//!Constructor from the segment manager. Never throws
|
||||
heap_allocator_v1(segment_manager *segment_mngr)
|
||||
: mp_mngr(segment_mngr) { }
|
||||
|
||||
//!Constructor from other heap_allocator_v1. Never throws
|
||||
heap_allocator_v1(const heap_allocator_v1 &other)
|
||||
: mp_mngr(other.get_segment_manager()){ }
|
||||
|
||||
//!Constructor from related heap_allocator_v1. Never throws
|
||||
template<class T2>
|
||||
heap_allocator_v1(const heap_allocator_v1<T2, SegmentManager> &other)
|
||||
: mp_mngr(other.get_segment_manager()){}
|
||||
|
||||
//!Allocates memory for an array of count elements.
|
||||
//!Throws boost::container::bad_alloc if there is no enough memory
|
||||
pointer allocate(size_type count, cvoid_ptr hint = 0)
|
||||
{ (void)hint; return ::new value_type[count]; }
|
||||
|
||||
//!Deallocates memory previously allocated. Never throws
|
||||
void deallocate(const pointer &ptr, size_type)
|
||||
{ return ::delete[] detail::get_pointer(ptr) ; }
|
||||
|
||||
//!Construct object, calling constructor.
|
||||
//!Throws if T(const T&) throws
|
||||
void construct(const pointer &ptr, const_reference value)
|
||||
{ new((void*)detail::get_pointer(ptr)) value_type(value); }
|
||||
|
||||
//!Destroys object. Throws if object's destructor throws
|
||||
void destroy(const pointer &ptr)
|
||||
{ BOOST_ASSERT(ptr != 0); (*ptr).~value_type(); }
|
||||
|
||||
//!Returns the number of elements that could be allocated. Never throws
|
||||
size_type max_size() const
|
||||
{ return mp_mngr->get_size(); }
|
||||
|
||||
//!Swap segment manager. Does not throw. If each heap_allocator_v1 is placed in
|
||||
//!different memory segments, the result is undefined.
|
||||
friend void swap(self_t &alloc1, self_t &alloc2)
|
||||
{ boost::container::boost::container::swap_dispatch(alloc1.mp_mngr, alloc2.mp_mngr); }
|
||||
};
|
||||
|
||||
//!Equality test for same type of heap_allocator_v1
|
||||
template<class T, class SegmentManager> inline
|
||||
bool operator==(const heap_allocator_v1<T , SegmentManager> &alloc1,
|
||||
const heap_allocator_v1<T, SegmentManager> &alloc2)
|
||||
{ return alloc1.get_segment_manager() == alloc2.get_segment_manager(); }
|
||||
|
||||
//!Inequality test for same type of heap_allocator_v1
|
||||
template<class T, class SegmentManager> inline
|
||||
bool operator!=(const heap_allocator_v1<T, SegmentManager> &alloc1,
|
||||
const heap_allocator_v1<T, SegmentManager> &alloc2)
|
||||
{ return alloc1.get_segment_manager() != alloc2.get_segment_manager(); }
|
||||
|
||||
} //namespace test {
|
||||
} //namespace container {
|
||||
} //namespace boost {
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
#endif //BOOST_CONTAINER_HEAP_ALLOCATOR_V1_HPP
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2012-2012. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2012-2013. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
+76
-18
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2004-2013. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
@@ -10,6 +10,10 @@
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/list.hpp>
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <boost/container/node_allocator.hpp>
|
||||
#include <boost/container/adaptive_pool.hpp>
|
||||
|
||||
#include "dummy_test_allocator.hpp"
|
||||
#include <memory>
|
||||
#include "movable_int.hpp"
|
||||
@@ -23,14 +27,29 @@ namespace boost {
|
||||
namespace container {
|
||||
|
||||
//Explicit instantiation to detect compilation errors
|
||||
template class boost::container::list<test::movable_and_copyable_int,
|
||||
test::simple_allocator<test::movable_and_copyable_int> >;
|
||||
template class boost::container::list
|
||||
< test::movable_and_copyable_int
|
||||
, test::simple_allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
template class boost::container::list<test::movable_and_copyable_int,
|
||||
test::dummy_test_allocator<test::movable_and_copyable_int> >;
|
||||
template class boost::container::list
|
||||
< test::movable_and_copyable_int
|
||||
, test::dummy_test_allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
template class boost::container::list<test::movable_and_copyable_int,
|
||||
std::allocator<test::movable_and_copyable_int> >;
|
||||
template class boost::container::list
|
||||
< test::movable_and_copyable_int
|
||||
, std::allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
template class boost::container::list
|
||||
< test::movable_and_copyable_int
|
||||
, allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
template class boost::container::list
|
||||
< test::movable_and_copyable_int
|
||||
, adaptive_pool<test::movable_and_copyable_int> >;
|
||||
|
||||
template class boost::container::list
|
||||
< test::movable_and_copyable_int
|
||||
, node_allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
namespace container_detail {
|
||||
|
||||
@@ -43,12 +62,6 @@ template class iterator
|
||||
|
||||
}}
|
||||
|
||||
typedef list<int> MyList;
|
||||
|
||||
typedef list<test::movable_int> MyMoveList;
|
||||
typedef list<test::movable_and_copyable_int> MyCopyMoveList;
|
||||
typedef list<test::copyable_int> MyCopyList;
|
||||
|
||||
class recursive_list
|
||||
{
|
||||
public:
|
||||
@@ -67,6 +80,42 @@ void recursive_list_test()//Test for recursive types
|
||||
}
|
||||
}
|
||||
|
||||
template<class VoidAllocator>
|
||||
struct GetAllocatorCont
|
||||
{
|
||||
template<class ValueType>
|
||||
struct apply
|
||||
{
|
||||
typedef list< ValueType
|
||||
, typename allocator_traits<VoidAllocator>
|
||||
::template portable_rebind_alloc<ValueType>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
if(test::list_test<MyCont, true>())
|
||||
return 1;
|
||||
if(test::list_test<MyMoveCont, true>())
|
||||
return 1;
|
||||
if(test::list_test<MyCopyMoveCont, true>())
|
||||
return 1;
|
||||
if(test::list_test<MyCopyMoveCont, true>())
|
||||
return 1;
|
||||
if(test::list_test<MyCopyCont, true>())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main ()
|
||||
{
|
||||
recursive_list_test();
|
||||
@@ -78,17 +127,26 @@ int main ()
|
||||
move_assign = boost::move(move_ctor);
|
||||
move_assign.swap(original);
|
||||
}
|
||||
if(test::list_test<MyList, true>())
|
||||
return 1;
|
||||
|
||||
if(test::list_test<MyMoveList, 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<MyCopyMoveList, true>())
|
||||
if(test_cont_variants< allocator<void> >()){
|
||||
std::cerr << "test_cont_variants< allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test::list_test<MyCopyList, true>())
|
||||
if(test_cont_variants< node_allocator<void> >()){
|
||||
std::cerr << "test_cont_variants< node_allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test_cont_variants< adaptive_pool<void> >()){
|
||||
std::cerr << "test_cont_variants< adaptive_pool<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const test::EmplaceOptions Options = (test::EmplaceOptions)(test::EMPLACE_BACK | test::EMPLACE_FRONT | test::EMPLACE_BEFORE);
|
||||
|
||||
|
||||
+82
-70
@@ -37,7 +37,85 @@ template<class MyBoostMap
|
||||
,class MyStdMap
|
||||
,class MyBoostMultiMap
|
||||
,class MyStdMultiMap>
|
||||
int map_test ()
|
||||
int map_test_copyable(boost::container::container_detail::false_type)
|
||||
{ return 0; }
|
||||
|
||||
template<class MyBoostMap
|
||||
,class MyStdMap
|
||||
,class MyBoostMultiMap
|
||||
,class MyStdMultiMap>
|
||||
int map_test_copyable(boost::container::container_detail::true_type)
|
||||
{
|
||||
typedef typename MyBoostMap::key_type IntType;
|
||||
typedef container_detail::pair<IntType, IntType> IntPairType;
|
||||
typedef typename MyStdMap::value_type StdPairType;
|
||||
|
||||
const int max = 100;
|
||||
|
||||
BOOST_TRY{
|
||||
MyBoostMap *boostmap = new MyBoostMap;
|
||||
MyStdMap *stdmap = new MyStdMap;
|
||||
MyBoostMultiMap *boostmultimap = new MyBoostMultiMap;
|
||||
MyStdMultiMap *stdmultimap = new MyStdMultiMap;
|
||||
|
||||
int i;
|
||||
for(i = 0; i < max; ++i){
|
||||
{
|
||||
IntType i1(i), i2(i);
|
||||
IntPairType intpair1(boost::move(i1), boost::move(i2));
|
||||
boostmap->insert(boost::move(intpair1));
|
||||
stdmap->insert(StdPairType(i, i));
|
||||
}
|
||||
{
|
||||
IntType i1(i), i2(i);
|
||||
IntPairType intpair2(boost::move(i1), boost::move(i2));
|
||||
boostmultimap->insert(boost::move(intpair2));
|
||||
stdmultimap->insert(StdPairType(i, i));
|
||||
}
|
||||
}
|
||||
if(!CheckEqualContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualContainers(boostmultimap, stdmultimap)) return 1;
|
||||
|
||||
{
|
||||
//Now, test copy constructor
|
||||
MyBoostMap boostmapcopy(*boostmap);
|
||||
MyStdMap stdmapcopy(*stdmap);
|
||||
MyBoostMultiMap boostmmapcopy(*boostmultimap);
|
||||
MyStdMultiMap stdmmapcopy(*stdmultimap);
|
||||
|
||||
if(!CheckEqualContainers(&boostmapcopy, &stdmapcopy))
|
||||
return 1;
|
||||
if(!CheckEqualContainers(&boostmmapcopy, &stdmmapcopy))
|
||||
return 1;
|
||||
|
||||
//And now assignment
|
||||
boostmapcopy = *boostmap;
|
||||
stdmapcopy = *stdmap;
|
||||
boostmmapcopy = *boostmultimap;
|
||||
stdmmapcopy = *stdmultimap;
|
||||
|
||||
if(!CheckEqualContainers(&boostmapcopy, &stdmapcopy))
|
||||
return 1;
|
||||
if(!CheckEqualContainers(&boostmmapcopy, &stdmmapcopy))
|
||||
return 1;
|
||||
delete boostmap;
|
||||
delete boostmultimap;
|
||||
delete stdmap;
|
||||
delete stdmultimap;
|
||||
}
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class MyBoostMap
|
||||
,class MyStdMap
|
||||
,class MyBoostMultiMap
|
||||
,class MyStdMultiMap>
|
||||
int map_test()
|
||||
{
|
||||
typedef typename MyBoostMap::key_type IntType;
|
||||
typedef container_detail::pair<IntType, IntType> IntPairType;
|
||||
@@ -471,77 +549,11 @@ int map_test ()
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class MyBoostMap
|
||||
,class MyStdMap
|
||||
,class MyBoostMultiMap
|
||||
,class MyStdMultiMap>
|
||||
int map_test_copyable ()
|
||||
{
|
||||
typedef typename MyBoostMap::key_type IntType;
|
||||
typedef container_detail::pair<IntType, IntType> IntPairType;
|
||||
typedef typename MyStdMap::value_type StdPairType;
|
||||
|
||||
const int max = 100;
|
||||
|
||||
BOOST_TRY{
|
||||
MyBoostMap *boostmap = new MyBoostMap;
|
||||
MyStdMap *stdmap = new MyStdMap;
|
||||
MyBoostMultiMap *boostmultimap = new MyBoostMultiMap;
|
||||
MyStdMultiMap *stdmultimap = new MyStdMultiMap;
|
||||
|
||||
int i;
|
||||
for(i = 0; i < max; ++i){
|
||||
{
|
||||
IntType i1(i), i2(i);
|
||||
IntPairType intpair1(boost::move(i1), boost::move(i2));
|
||||
boostmap->insert(boost::move(intpair1));
|
||||
stdmap->insert(StdPairType(i, i));
|
||||
}
|
||||
{
|
||||
IntType i1(i), i2(i);
|
||||
IntPairType intpair2(boost::move(i1), boost::move(i2));
|
||||
boostmultimap->insert(boost::move(intpair2));
|
||||
stdmultimap->insert(StdPairType(i, i));
|
||||
}
|
||||
if(map_test_copyable<MyBoostMap, MyStdMap, MyBoostMultiMap, MyStdMultiMap>
|
||||
(container_detail::bool_<boost::container::test::is_copyable<IntType>::value>())){
|
||||
return 1;
|
||||
}
|
||||
if(!CheckEqualContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualContainers(boostmultimap, stdmultimap)) return 1;
|
||||
|
||||
{
|
||||
//Now, test copy constructor
|
||||
MyBoostMap boostmapcopy(*boostmap);
|
||||
MyStdMap stdmapcopy(*stdmap);
|
||||
MyBoostMultiMap boostmmapcopy(*boostmultimap);
|
||||
MyStdMultiMap stdmmapcopy(*stdmultimap);
|
||||
|
||||
if(!CheckEqualContainers(&boostmapcopy, &stdmapcopy))
|
||||
return 1;
|
||||
if(!CheckEqualContainers(&boostmmapcopy, &stdmmapcopy))
|
||||
return 1;
|
||||
|
||||
//And now assignment
|
||||
boostmapcopy = *boostmap;
|
||||
stdmapcopy = *stdmap;
|
||||
boostmmapcopy = *boostmultimap;
|
||||
stdmmapcopy = *stdmultimap;
|
||||
|
||||
if(!CheckEqualContainers(&boostmapcopy, &stdmapcopy))
|
||||
return 1;
|
||||
if(!CheckEqualContainers(&boostmmapcopy, &stdmmapcopy))
|
||||
return 1;
|
||||
delete boostmap;
|
||||
delete boostmultimap;
|
||||
delete stdmap;
|
||||
delete stdmultimap;
|
||||
}
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2011-2012. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2004-2013. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2011-2012. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
+76
-66
@@ -1,6 +1,6 @@
|
||||
////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2004-2013. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
@@ -25,6 +25,77 @@ namespace boost{
|
||||
namespace container {
|
||||
namespace test{
|
||||
|
||||
template<class MyBoostSet
|
||||
,class MyStdSet
|
||||
,class MyBoostMultiSet
|
||||
,class MyStdMultiSet>
|
||||
int set_test_copyable(boost::container::container_detail::false_type)
|
||||
{ return 0; }
|
||||
|
||||
template<class MyBoostSet
|
||||
,class MyStdSet
|
||||
,class MyBoostMultiSet
|
||||
,class MyStdMultiSet>
|
||||
int set_test_copyable(boost::container::container_detail::true_type)
|
||||
{
|
||||
typedef typename MyBoostSet::value_type IntType;
|
||||
const int max = 100;
|
||||
|
||||
BOOST_TRY{
|
||||
MyBoostSet *boostset = new MyBoostSet;
|
||||
MyStdSet *stdset = new MyStdSet;
|
||||
MyBoostMultiSet *boostmultiset = new MyBoostMultiSet;
|
||||
MyStdMultiSet *stdmultiset = new MyStdMultiSet;
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType move_me(i);
|
||||
boostset->insert(boost::move(move_me));
|
||||
stdset->insert(i);
|
||||
IntType move_me2(i);
|
||||
boostmultiset->insert(boost::move(move_me2));
|
||||
stdmultiset->insert(i);
|
||||
}
|
||||
if(!CheckEqualContainers(boostset, stdset)) return 1;
|
||||
if(!CheckEqualContainers(boostmultiset, stdmultiset)) return 1;
|
||||
|
||||
{
|
||||
//Now, test copy constructor
|
||||
MyBoostSet boostsetcopy(*boostset);
|
||||
MyStdSet stdsetcopy(*stdset);
|
||||
|
||||
if(!CheckEqualContainers(&boostsetcopy, &stdsetcopy))
|
||||
return 1;
|
||||
|
||||
MyBoostMultiSet boostmsetcopy(*boostmultiset);
|
||||
MyStdMultiSet stdmsetcopy(*stdmultiset);
|
||||
|
||||
if(!CheckEqualContainers(&boostmsetcopy, &stdmsetcopy))
|
||||
return 1;
|
||||
|
||||
//And now assignment
|
||||
boostsetcopy = *boostset;
|
||||
stdsetcopy = *stdset;
|
||||
|
||||
if(!CheckEqualContainers(&boostsetcopy, &stdsetcopy))
|
||||
return 1;
|
||||
|
||||
boostmsetcopy = *boostmultiset;
|
||||
stdmsetcopy = *stdmultiset;
|
||||
|
||||
if(!CheckEqualContainers(&boostmsetcopy, &stdmsetcopy))
|
||||
return 1;
|
||||
}
|
||||
delete boostset;
|
||||
delete boostmultiset;
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
template<class MyBoostSet
|
||||
,class MyStdSet
|
||||
,class MyBoostMultiSet
|
||||
@@ -34,8 +105,6 @@ int set_test ()
|
||||
typedef typename MyBoostSet::value_type IntType;
|
||||
const int max = 100;
|
||||
|
||||
//Shared memory allocator must be always be initialized
|
||||
//since it has no default constructor
|
||||
MyBoostSet *boostset = new MyBoostSet;
|
||||
MyStdSet *stdset = new MyStdSet;
|
||||
MyBoostMultiSet *boostmultiset = new MyBoostMultiSet;
|
||||
@@ -431,71 +500,12 @@ int set_test ()
|
||||
delete stdset;
|
||||
delete boostmultiset;
|
||||
delete stdmultiset;
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class MyBoostSet
|
||||
,class MyStdSet
|
||||
,class MyBoostMultiSet
|
||||
,class MyStdMultiSet>
|
||||
int set_test_copyable ()
|
||||
{
|
||||
typedef typename MyBoostSet::value_type IntType;
|
||||
const int max = 100;
|
||||
|
||||
BOOST_TRY{
|
||||
//Shared memory allocator must be always be initialized
|
||||
//since it has no default constructor
|
||||
MyBoostSet *boostset = new MyBoostSet;
|
||||
MyStdSet *stdset = new MyStdSet;
|
||||
MyBoostMultiSet *boostmultiset = new MyBoostMultiSet;
|
||||
MyStdMultiSet *stdmultiset = new MyStdMultiSet;
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType move_me(i);
|
||||
boostset->insert(boost::move(move_me));
|
||||
stdset->insert(i);
|
||||
IntType move_me2(i);
|
||||
boostmultiset->insert(boost::move(move_me2));
|
||||
stdmultiset->insert(i);
|
||||
}
|
||||
if(!CheckEqualContainers(boostset, stdset)) return 1;
|
||||
if(!CheckEqualContainers(boostmultiset, stdmultiset)) return 1;
|
||||
|
||||
{
|
||||
//Now, test copy constructor
|
||||
MyBoostSet boostsetcopy(*boostset);
|
||||
MyStdSet stdsetcopy(*stdset);
|
||||
|
||||
if(!CheckEqualContainers(&boostsetcopy, &stdsetcopy))
|
||||
return 1;
|
||||
|
||||
MyBoostMultiSet boostmsetcopy(*boostmultiset);
|
||||
MyStdMultiSet stdmsetcopy(*stdmultiset);
|
||||
|
||||
if(!CheckEqualContainers(&boostmsetcopy, &stdmsetcopy))
|
||||
return 1;
|
||||
|
||||
//And now assignment
|
||||
boostsetcopy = *boostset;
|
||||
stdsetcopy = *stdset;
|
||||
|
||||
if(!CheckEqualContainers(&boostsetcopy, &stdsetcopy))
|
||||
return 1;
|
||||
|
||||
boostmsetcopy = *boostmultiset;
|
||||
stdmsetcopy = *stdmultiset;
|
||||
|
||||
if(!CheckEqualContainers(&boostmsetcopy, &stdmsetcopy))
|
||||
return 1;
|
||||
}
|
||||
delete boostset;
|
||||
delete boostmultiset;
|
||||
if(set_test_copyable<MyBoostSet, MyStdSet, MyBoostMultiSet, MyStdMultiSet>
|
||||
(container_detail::bool_<boost::container::test::is_copyable<IntType>::value>())){
|
||||
return 1;
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+74
-16
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2004-2013. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
@@ -9,6 +9,10 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/slist.hpp>
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <boost/container/node_allocator.hpp>
|
||||
#include <boost/container/adaptive_pool.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include "dummy_test_allocator.hpp"
|
||||
#include "movable_int.hpp"
|
||||
@@ -22,22 +26,32 @@ namespace boost {
|
||||
namespace container {
|
||||
|
||||
//Explicit instantiation to detect compilation errors
|
||||
template class boost::container::slist<test::movable_and_copyable_int,
|
||||
test::simple_allocator<test::movable_and_copyable_int> >;
|
||||
template class boost::container::slist
|
||||
< test::movable_and_copyable_int
|
||||
, test::simple_allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
template class boost::container::slist<test::movable_and_copyable_int,
|
||||
test::dummy_test_allocator<test::movable_and_copyable_int> >;
|
||||
template class boost::container::slist
|
||||
< test::movable_and_copyable_int
|
||||
, test::dummy_test_allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
template class boost::container::slist<test::movable_and_copyable_int,
|
||||
std::allocator<test::movable_and_copyable_int> >;
|
||||
template class boost::container::slist
|
||||
< test::movable_and_copyable_int
|
||||
, std::allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
template class boost::container::slist
|
||||
< test::movable_and_copyable_int
|
||||
, allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
template class boost::container::slist
|
||||
< test::movable_and_copyable_int
|
||||
, adaptive_pool<test::movable_and_copyable_int> >;
|
||||
|
||||
template class boost::container::slist
|
||||
< test::movable_and_copyable_int
|
||||
, node_allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
}}
|
||||
|
||||
typedef slist<int> MyList;
|
||||
typedef slist<test::movable_int> MyMoveList;
|
||||
typedef slist<test::movable_and_copyable_int> MyCopyMoveList;
|
||||
typedef slist<test::copyable_int> MyCopyList;
|
||||
|
||||
class recursive_slist
|
||||
{
|
||||
public:
|
||||
@@ -52,6 +66,42 @@ void recursive_slist_test()//Test for recursive types
|
||||
slist<recursive_slist> recursive_list_list;
|
||||
}
|
||||
|
||||
template<class VoidAllocator>
|
||||
struct GetAllocatorCont
|
||||
{
|
||||
template<class ValueType>
|
||||
struct apply
|
||||
{
|
||||
typedef slist< ValueType
|
||||
, typename allocator_traits<VoidAllocator>
|
||||
::template portable_rebind_alloc<ValueType>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main ()
|
||||
{
|
||||
recursive_slist_test();
|
||||
@@ -71,17 +121,25 @@ int main ()
|
||||
}
|
||||
}
|
||||
|
||||
if(test::list_test<MyList, 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<MyMoveList, false>())
|
||||
if(test_cont_variants< allocator<void> >()){
|
||||
std::cerr << "test_cont_variants< allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test::list_test<MyCopyMoveList, false>())
|
||||
if(test_cont_variants< node_allocator<void> >()){
|
||||
std::cerr << "test_cont_variants< node_allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test::list_test<MyCopyList, false>())
|
||||
if(test_cont_variants< adaptive_pool<void> >()){
|
||||
std::cerr << "test_cont_variants< adaptive_pool<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const test::EmplaceOptions Options = (test::EmplaceOptions)
|
||||
(test::EMPLACE_FRONT | test::EMPLACE_AFTER | test::EMPLACE_BEFORE | test::EMPLACE_AFTER);
|
||||
|
||||
+59
-35
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2004-2013. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
@@ -16,6 +16,10 @@
|
||||
#include <functional>
|
||||
|
||||
#include <boost/container/stable_vector.hpp>
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <boost/container/node_allocator.hpp>
|
||||
#include <boost/container/adaptive_pool.hpp>
|
||||
|
||||
#include "check_equal_containers.hpp"
|
||||
#include "movable_int.hpp"
|
||||
#include "expand_bwd_test_allocator.hpp"
|
||||
@@ -23,6 +27,7 @@
|
||||
#include "dummy_test_allocator.hpp"
|
||||
#include "propagate_allocator_test.hpp"
|
||||
#include "vector_test.hpp"
|
||||
#include "default_init_test.hpp"
|
||||
|
||||
using namespace boost::container;
|
||||
|
||||
@@ -39,6 +44,18 @@ template class stable_vector<test::movable_and_copyable_int,
|
||||
template class stable_vector<test::movable_and_copyable_int,
|
||||
std::allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
template class stable_vector
|
||||
< test::movable_and_copyable_int
|
||||
, allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
template class stable_vector
|
||||
< test::movable_and_copyable_int
|
||||
, adaptive_pool<test::movable_and_copyable_int> >;
|
||||
|
||||
template class stable_vector
|
||||
< test::movable_and_copyable_int
|
||||
, node_allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
namespace stable_vector_detail{
|
||||
|
||||
template class iterator<int*, false>;
|
||||
@@ -66,34 +83,37 @@ void recursive_vector_test()//Test for recursive types
|
||||
}
|
||||
}
|
||||
|
||||
bool default_init_test()//Test for default initialization
|
||||
template<class VoidAllocator>
|
||||
struct GetAllocatorCont
|
||||
{
|
||||
typedef stable_vector<int, test::default_init_allocator<int> > svector_t;
|
||||
|
||||
const std::size_t Capacity = 100;
|
||||
|
||||
template<class ValueType>
|
||||
struct apply
|
||||
{
|
||||
test::default_init_allocator<int>::reset_pattern(0);
|
||||
svector_t v(Capacity, default_init);
|
||||
svector_t::iterator it = v.begin();
|
||||
//Compare with the pattern
|
||||
for(std::size_t i = 0; i != Capacity; ++i, ++it){
|
||||
if(*it != static_cast<int>(i))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
{
|
||||
test::default_init_allocator<int>::reset_pattern(100);
|
||||
svector_t v;
|
||||
v.resize(Capacity, default_init);
|
||||
svector_t::iterator it = v.begin();
|
||||
//Compare with the pattern
|
||||
for(std::size_t i = 0; i != Capacity; ++i, ++it){
|
||||
if(*it != static_cast<int>(i+100))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
typedef stable_vector< ValueType
|
||||
, typename allocator_traits<VoidAllocator>
|
||||
::template portable_rebind_alloc<ValueType>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
if(test::vector_test<MyCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyMoveCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyCopyMoveCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyCopyCont>())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
@@ -115,22 +135,26 @@ int main()
|
||||
sv.resize(10);
|
||||
sv.resize(1);
|
||||
}
|
||||
typedef stable_vector<int> MyVector;
|
||||
typedef stable_vector<test::movable_int> MyMoveVector;
|
||||
typedef stable_vector<test::movable_and_copyable_int> MyCopyMoveVector;
|
||||
typedef stable_vector<test::copyable_int> MyCopyVector;
|
||||
|
||||
if(test::vector_test<MyVector>())
|
||||
if(test_cont_variants< std::allocator<void> >()){
|
||||
std::cerr << "test_cont_variants< std::allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test::vector_test<MyMoveVector>())
|
||||
if(test_cont_variants< allocator<void> >()){
|
||||
std::cerr << "test_cont_variants< allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test::vector_test<MyCopyMoveVector>())
|
||||
if(test_cont_variants< node_allocator<void> >()){
|
||||
std::cerr << "test_cont_variants< node_allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test::vector_test<MyCopyVector>())
|
||||
if(test_cont_variants< adaptive_pool<void> >()){
|
||||
std::cerr << "test_cont_variants< adaptive_pool<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!test::default_init_test< stable_vector<int, test::default_init_allocator<int> > >()){
|
||||
std::cerr << "Default init test failed" << std::endl;
|
||||
|
||||
+12
-2
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2004-2013. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "expand_bwd_test_allocator.hpp"
|
||||
#include "expand_bwd_test_template.hpp"
|
||||
#include "propagate_allocator_test.hpp"
|
||||
#include "default_init_test.hpp"
|
||||
|
||||
using namespace boost::container;
|
||||
|
||||
@@ -137,7 +138,6 @@ int string_test()
|
||||
|
||||
const int MaxSize = 100;
|
||||
|
||||
//Create shared memory
|
||||
{
|
||||
BoostStringVector *boostStringVect = new BoostStringVector;
|
||||
StdStringVector *stdStringVect = new StdStringVector;
|
||||
@@ -477,6 +477,16 @@ int main()
|
||||
if(!boost::container::test::test_propagate_allocator<string_propagate_test_wrapper>())
|
||||
return 1;
|
||||
|
||||
if(!test::default_init_test< basic_string<char, std::char_traits<char>, test::default_init_allocator<char> > >()){
|
||||
std::cerr << "Default init test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!test::default_init_test< basic_string<wchar_t, std::char_traits<wchar_t>, test::default_init_allocator<wchar_t> > >()){
|
||||
std::cerr << "Default init test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,380 +0,0 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <set>
|
||||
#include <boost/container/set.hpp>
|
||||
#include <boost/container/map.hpp>
|
||||
#include "print_container.hpp"
|
||||
#include "movable_int.hpp"
|
||||
#include "dummy_test_allocator.hpp"
|
||||
#include "set_test.hpp"
|
||||
#include "map_test.hpp"
|
||||
#include "propagate_allocator_test.hpp"
|
||||
#include "emplace_test.hpp"
|
||||
|
||||
using namespace boost::container;
|
||||
|
||||
//Alias standard types
|
||||
typedef std::set<int> MyStdSet;
|
||||
typedef std::multiset<int> MyStdMultiSet;
|
||||
typedef std::map<int, int> MyStdMap;
|
||||
typedef std::multimap<int, int> MyStdMultiMap;
|
||||
|
||||
//Alias non-movable types
|
||||
typedef set<int> MyBoostSet;
|
||||
typedef multiset<int> MyBoostMultiSet;
|
||||
typedef map<int, int> MyBoostMap;
|
||||
typedef multimap<int, int> MyBoostMultiMap;
|
||||
|
||||
//Alias movable types
|
||||
typedef set<test::movable_int> MyMovableBoostSet;
|
||||
typedef multiset<test::movable_int> MyMovableBoostMultiSet;
|
||||
typedef map<test::movable_int, test::movable_int> MyMovableBoostMap;
|
||||
typedef multimap<test::movable_int, test::movable_int> MyMovableBoostMultiMap;
|
||||
typedef set<test::movable_and_copyable_int> MyMoveCopyBoostSet;
|
||||
typedef set<test::copyable_int> MyCopyBoostSet;
|
||||
typedef multiset<test::movable_and_copyable_int> MyMoveCopyBoostMultiSet;
|
||||
typedef multiset<test::copyable_int> MyCopyBoostMultiSet;
|
||||
typedef map<test::movable_and_copyable_int
|
||||
,test::movable_and_copyable_int> MyMoveCopyBoostMap;
|
||||
typedef multimap<test::movable_and_copyable_int
|
||||
,test::movable_and_copyable_int> MyMoveCopyBoostMultiMap;
|
||||
typedef map<test::copyable_int
|
||||
,test::copyable_int> MyCopyBoostMap;
|
||||
typedef multimap<test::copyable_int
|
||||
,test::copyable_int> MyCopyBoostMultiMap;
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
|
||||
//Explicit instantiation to detect compilation errors
|
||||
|
||||
//map
|
||||
template class map
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::dummy_test_allocator
|
||||
< std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class map
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::simple_allocator
|
||||
< std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class map
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, std::allocator
|
||||
< std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
//multimap
|
||||
template class multimap
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::dummy_test_allocator
|
||||
< std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class multimap
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::simple_allocator
|
||||
< std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class multimap
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, std::allocator
|
||||
< std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
//set
|
||||
template class set
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::dummy_test_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class set
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::simple_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class set
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, std::allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
//multiset
|
||||
template class multiset
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::dummy_test_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class multiset
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::simple_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class multiset
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, std::allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
}} //boost::container
|
||||
|
||||
//Test recursive structures
|
||||
class recursive_set
|
||||
{
|
||||
public:
|
||||
recursive_set & operator=(const recursive_set &x)
|
||||
{ id_ = x.id_; set_ = x.set_; return *this; }
|
||||
|
||||
int id_;
|
||||
set<recursive_set> set_;
|
||||
friend bool operator< (const recursive_set &a, const recursive_set &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
};
|
||||
|
||||
class recursive_map
|
||||
{
|
||||
public:
|
||||
recursive_map & operator=(const recursive_map &x)
|
||||
{ id_ = x.id_; map_ = x.map_; return *this; }
|
||||
|
||||
int id_;
|
||||
map<recursive_map, recursive_map> map_;
|
||||
friend bool operator< (const recursive_map &a, const recursive_map &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
};
|
||||
|
||||
//Test recursive structures
|
||||
class recursive_multiset
|
||||
{
|
||||
public:
|
||||
recursive_multiset & operator=(const recursive_multiset &x)
|
||||
{ id_ = x.id_; multiset_ = x.multiset_; return *this; }
|
||||
|
||||
int id_;
|
||||
multiset<recursive_multiset> multiset_;
|
||||
friend bool operator< (const recursive_multiset &a, const recursive_multiset &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
};
|
||||
|
||||
class recursive_multimap
|
||||
{
|
||||
public:
|
||||
recursive_multimap & operator=(const recursive_multimap &x)
|
||||
{ id_ = x.id_; multimap_ = x.multimap_; return *this; }
|
||||
|
||||
int id_;
|
||||
multimap<recursive_multimap, recursive_multimap> multimap_;
|
||||
friend bool operator< (const recursive_multimap &a, const recursive_multimap &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
};
|
||||
|
||||
template<class C>
|
||||
void test_move()
|
||||
{
|
||||
//Now test move semantics
|
||||
C original;
|
||||
original.emplace();
|
||||
C move_ctor(boost::move(original));
|
||||
C move_assign;
|
||||
move_assign.emplace();
|
||||
move_assign = boost::move(move_ctor);
|
||||
move_assign.swap(original);
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
class tree_propagate_test_wrapper
|
||||
: public container_detail::rbtree<T, T, container_detail::identity<T>, std::less<T>, A>
|
||||
{
|
||||
BOOST_COPYABLE_AND_MOVABLE(tree_propagate_test_wrapper)
|
||||
typedef container_detail::rbtree<T, T, container_detail::identity<T>, std::less<T>, A> Base;
|
||||
public:
|
||||
tree_propagate_test_wrapper()
|
||||
: Base()
|
||||
{}
|
||||
|
||||
tree_propagate_test_wrapper(const tree_propagate_test_wrapper &x)
|
||||
: Base(x)
|
||||
{}
|
||||
|
||||
tree_propagate_test_wrapper(BOOST_RV_REF(tree_propagate_test_wrapper) x)
|
||||
: Base(boost::move(static_cast<Base&>(x)))
|
||||
{}
|
||||
|
||||
tree_propagate_test_wrapper &operator=(BOOST_COPY_ASSIGN_REF(tree_propagate_test_wrapper) x)
|
||||
{ this->Base::operator=(x); return *this; }
|
||||
|
||||
tree_propagate_test_wrapper &operator=(BOOST_RV_REF(tree_propagate_test_wrapper) x)
|
||||
{ this->Base::operator=(boost::move(static_cast<Base&>(x))); return *this; }
|
||||
|
||||
void swap(tree_propagate_test_wrapper &x)
|
||||
{ this->Base::swap(x); }
|
||||
};
|
||||
|
||||
int main ()
|
||||
{
|
||||
//Recursive container instantiation
|
||||
{
|
||||
set<recursive_set> set_;
|
||||
multiset<recursive_multiset> multiset_;
|
||||
map<recursive_map, recursive_map> map_;
|
||||
multimap<recursive_multimap, recursive_multimap> multimap_;
|
||||
}
|
||||
//Allocator argument container
|
||||
{
|
||||
set<int> set_((std::allocator<int>()));
|
||||
multiset<int> multiset_((std::allocator<int>()));
|
||||
map<int, int> map_((std::allocator<std::pair<const int, int> >()));
|
||||
multimap<int, int> multimap_((std::allocator<std::pair<const int, int> >()));
|
||||
}
|
||||
//Now test move semantics
|
||||
{
|
||||
test_move<set<recursive_set> >();
|
||||
test_move<multiset<recursive_multiset> >();
|
||||
test_move<map<recursive_map, recursive_map> >();
|
||||
test_move<multimap<recursive_multimap, recursive_multimap> >();
|
||||
}
|
||||
|
||||
|
||||
if(0 != test::set_test<MyBoostSet
|
||||
,MyStdSet
|
||||
,MyBoostMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(0 != test::set_test_copyable<MyBoostSet
|
||||
,MyStdSet
|
||||
,MyBoostMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(0 != test::set_test<MyMovableBoostSet
|
||||
,MyStdSet
|
||||
,MyMovableBoostMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(0 != test::set_test<MyMoveCopyBoostSet
|
||||
,MyStdSet
|
||||
,MyMoveCopyBoostMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(0 != test::set_test_copyable<MyMoveCopyBoostSet
|
||||
,MyStdSet
|
||||
,MyMoveCopyBoostMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(0 != test::set_test<MyCopyBoostSet
|
||||
,MyStdSet
|
||||
,MyCopyBoostMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(0 != test::set_test_copyable<MyCopyBoostSet
|
||||
,MyStdSet
|
||||
,MyCopyBoostMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::map_test<MyBoostMap
|
||||
,MyStdMap
|
||||
,MyBoostMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(0 != test::map_test_copyable<MyBoostMap
|
||||
,MyStdMap
|
||||
,MyBoostMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::map_test<MyMovableBoostMap
|
||||
,MyStdMap
|
||||
,MyMovableBoostMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::map_test<MyMoveCopyBoostMap
|
||||
,MyStdMap
|
||||
,MyMoveCopyBoostMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::map_test_copyable<MyMoveCopyBoostMap
|
||||
,MyStdMap
|
||||
,MyMoveCopyBoostMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::map_test<MyCopyBoostMap
|
||||
,MyStdMap
|
||||
,MyCopyBoostMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::map_test_copyable<MyCopyBoostMap
|
||||
,MyStdMap
|
||||
,MyCopyBoostMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
const test::EmplaceOptions SetOptions = (test::EmplaceOptions)(test::EMPLACE_HINT | test::EMPLACE_ASSOC);
|
||||
if(!boost::container::test::test_emplace<set<test::EmplaceInt>, SetOptions>())
|
||||
return 1;
|
||||
if(!boost::container::test::test_emplace<multiset<test::EmplaceInt>, SetOptions>())
|
||||
return 1;
|
||||
const test::EmplaceOptions MapOptions = (test::EmplaceOptions)(test::EMPLACE_HINT_PAIR | test::EMPLACE_ASSOC_PAIR);
|
||||
if(!boost::container::test::test_emplace<map<test::EmplaceInt, test::EmplaceInt>, MapOptions>())
|
||||
return 1;
|
||||
if(!boost::container::test::test_emplace<multimap<test::EmplaceInt, test::EmplaceInt>, MapOptions>())
|
||||
return 1;
|
||||
if(!boost::container::test::test_propagate_allocator<tree_propagate_test_wrapper>())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
+86
-22
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2004-2013. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
@@ -15,6 +15,10 @@
|
||||
#include <functional>
|
||||
|
||||
#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.hpp>
|
||||
#include "check_equal_containers.hpp"
|
||||
#include "movable_int.hpp"
|
||||
@@ -23,6 +27,7 @@
|
||||
#include "dummy_test_allocator.hpp"
|
||||
#include "propagate_allocator_test.hpp"
|
||||
#include "vector_test.hpp"
|
||||
#include "default_init_test.hpp"
|
||||
|
||||
using namespace boost::container;
|
||||
|
||||
@@ -30,14 +35,29 @@ namespace boost {
|
||||
namespace container {
|
||||
|
||||
//Explicit instantiation to detect compilation errors
|
||||
template class boost::container::vector<test::movable_and_copyable_int,
|
||||
test::simple_allocator<test::movable_and_copyable_int> >;
|
||||
template class boost::container::vector
|
||||
< test::movable_and_copyable_int
|
||||
, test::simple_allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
template class boost::container::vector<test::movable_and_copyable_int,
|
||||
test::dummy_test_allocator<test::movable_and_copyable_int> >;
|
||||
template class boost::container::vector
|
||||
< test::movable_and_copyable_int
|
||||
, test::dummy_test_allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
template class boost::container::vector<test::movable_and_copyable_int,
|
||||
std::allocator<test::movable_and_copyable_int> >;
|
||||
template class boost::container::vector
|
||||
< test::movable_and_copyable_int
|
||||
, std::allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
template class boost::container::vector
|
||||
< test::movable_and_copyable_int
|
||||
, allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
template class boost::container::vector
|
||||
< test::movable_and_copyable_int
|
||||
, adaptive_pool<test::movable_and_copyable_int> >;
|
||||
|
||||
template class boost::container::vector
|
||||
< test::movable_and_copyable_int
|
||||
, node_allocator<test::movable_and_copyable_int> >;
|
||||
|
||||
namespace container_detail {
|
||||
|
||||
@@ -104,6 +124,39 @@ enum Test
|
||||
zero, one, two, three, four, five, six
|
||||
};
|
||||
|
||||
template<class VoidAllocator>
|
||||
struct GetAllocatorCont
|
||||
{
|
||||
template<class ValueType>
|
||||
struct apply
|
||||
{
|
||||
typedef vector< ValueType
|
||||
, typename allocator_traits<VoidAllocator>
|
||||
::template portable_rebind_alloc<ValueType>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
if(test::vector_test<MyCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyMoveCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyCopyMoveCont>())
|
||||
return 1;
|
||||
if(test::vector_test<MyCopyCont>())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@@ -135,33 +188,44 @@ int main()
|
||||
move_assign = boost::move(move_ctor);
|
||||
move_assign.swap(original);
|
||||
}
|
||||
typedef vector<int> MyVector;
|
||||
typedef vector<test::movable_int> MyMoveVector;
|
||||
typedef vector<test::movable_and_copyable_int> MyCopyMoveVector;
|
||||
typedef vector<test::copyable_int> MyCopyVector;
|
||||
typedef vector<Test> MyEnumVector;
|
||||
|
||||
if(test::vector_test<MyVector>())
|
||||
if(test_cont_variants< std::allocator<void> >()){
|
||||
std::cerr << "test_cont_variants< std::allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
if(test::vector_test<MyMoveVector>())
|
||||
}
|
||||
|
||||
if(test_cont_variants< allocator<void> >()){
|
||||
std::cerr << "test_cont_variants< allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
if(test::vector_test<MyCopyMoveVector>())
|
||||
}
|
||||
|
||||
if(test_cont_variants< node_allocator<void> >()){
|
||||
std::cerr << "test_cont_variants< node_allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
if(test::vector_test<MyCopyVector>())
|
||||
}
|
||||
|
||||
if(test_cont_variants< adaptive_pool<void> >()){
|
||||
std::cerr << "test_cont_variants< adaptive_pool<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector<Test, std::allocator<Test> > MyEnumCont;
|
||||
MyEnumCont v;
|
||||
Test t;
|
||||
v.push_back(t);
|
||||
v.push_back(::boost::move(t));
|
||||
v.push_back(Test());
|
||||
}
|
||||
|
||||
if(test_expand_bwd())
|
||||
return 1;
|
||||
|
||||
if(!test::default_init_test< vector<int, test::default_init_allocator<int> > >()){
|
||||
std::cerr << "Default init test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
MyEnumVector v;
|
||||
Test t;
|
||||
v.push_back(t);
|
||||
v.push_back(::boost::move(t));
|
||||
v.push_back(Test());
|
||||
|
||||
const test::EmplaceOptions Options = (test::EmplaceOptions)(test::EMPLACE_BACK | test::EMPLACE_BEFORE);
|
||||
if(!boost::container::test::test_emplace< vector<test::EmplaceInt>, Options>()){
|
||||
return 1;
|
||||
|
||||
+1
-118
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2004-2013. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
@@ -38,123 +38,6 @@ namespace boost{
|
||||
namespace container {
|
||||
namespace test{
|
||||
|
||||
//
|
||||
template<int Dummy = 0>
|
||||
class default_init_allocator_base
|
||||
{
|
||||
protected:
|
||||
static unsigned char s_pattern;
|
||||
static bool s_ascending;
|
||||
|
||||
public:
|
||||
static void reset_pattern(unsigned char value)
|
||||
{ s_pattern = value; }
|
||||
|
||||
static void set_ascending(bool enable)
|
||||
{ s_ascending = enable; }
|
||||
};
|
||||
|
||||
template<int Dummy>
|
||||
unsigned char default_init_allocator_base<Dummy>::s_pattern = 0u;
|
||||
|
||||
template<int Dummy>
|
||||
bool default_init_allocator_base<Dummy>::s_ascending = true;
|
||||
|
||||
template<class T>
|
||||
class default_init_allocator
|
||||
: public default_init_allocator_base<0>
|
||||
{
|
||||
typedef default_init_allocator_base<0> base_t;
|
||||
public:
|
||||
typedef T value_type;
|
||||
|
||||
default_init_allocator()
|
||||
{}
|
||||
|
||||
template <class U>
|
||||
default_init_allocator(default_init_allocator<U>)
|
||||
{}
|
||||
|
||||
T* allocate(std::size_t n)
|
||||
{
|
||||
//Initialize memory to a pattern
|
||||
const std::size_t max = sizeof(T)*n;
|
||||
unsigned char *puc_raw = ::new unsigned char[max];
|
||||
|
||||
if(base_t::s_ascending){
|
||||
for(std::size_t i = 0; i != max; ++i){
|
||||
puc_raw[i] = static_cast<unsigned char>(s_pattern++);
|
||||
}
|
||||
}
|
||||
else{
|
||||
for(std::size_t i = 0; i != max; ++i){
|
||||
puc_raw[i] = static_cast<unsigned char>(s_pattern--);
|
||||
}
|
||||
}
|
||||
return (T*)puc_raw;;
|
||||
}
|
||||
|
||||
void deallocate(T *p, std::size_t)
|
||||
{ delete[] (unsigned char*)p; }
|
||||
};
|
||||
|
||||
template<class T>
|
||||
inline bool check_ascending_byte_pattern(const T&t)
|
||||
{
|
||||
const unsigned char *pch = &reinterpret_cast<const unsigned char &>(t);
|
||||
const std::size_t max = sizeof(T);
|
||||
for(std::size_t i = 1; i != max; ++i){
|
||||
if( (pch[i-1] != ((unsigned char)(pch[i]-1u))) ){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool check_descending_byte_pattern(const T&t)
|
||||
{
|
||||
const unsigned char *pch = &reinterpret_cast<const unsigned char &>(t);
|
||||
const std::size_t max = sizeof(T);
|
||||
for(std::size_t i = 1; i != max; ++i){
|
||||
if( (pch[i-1] != ((unsigned char)(pch[i]+1u))) ){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class IntDefaultInitAllocVector>
|
||||
bool default_init_test()//Test for default initialization
|
||||
{
|
||||
const std::size_t Capacity = 100;
|
||||
|
||||
{
|
||||
test::default_init_allocator<int>::reset_pattern(0);
|
||||
test::default_init_allocator<int>::set_ascending(true);
|
||||
IntDefaultInitAllocVector v(Capacity, default_init);
|
||||
typename IntDefaultInitAllocVector::iterator it = v.begin();
|
||||
//Compare with the pattern
|
||||
for(std::size_t i = 0; i != Capacity; ++i, ++it){
|
||||
if(!test::check_ascending_byte_pattern(*it))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
{
|
||||
test::default_init_allocator<int>::reset_pattern(100);
|
||||
test::default_init_allocator<int>::set_ascending(false);
|
||||
IntDefaultInitAllocVector v;
|
||||
v.resize(Capacity, default_init);
|
||||
typename IntDefaultInitAllocVector::iterator it = v.begin();
|
||||
//Compare with the pattern
|
||||
for(std::size_t i = 0; i != Capacity; ++i, ++it){
|
||||
if(!test::check_descending_byte_pattern(*it))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class V1, class V2>
|
||||
bool vector_copyable_only(V1 *, V2 *, boost::container::container_detail::false_type)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user