mirror of
https://github.com/boostorg/intrusive.git
synced 2025-08-03 06:24:44 +02:00
tests: bounded pointers tests for (splay/sg/treap)x(set/multiset)
This commit is contained in:
@@ -21,13 +21,13 @@
|
|||||||
namespace boost { namespace intrusive { namespace test {
|
namespace boost { namespace intrusive { namespace test {
|
||||||
|
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
template<class T, class O1, class O2, class O3, class O4>
|
template<class T, class O1, class O2, class O3, class O4, class O5>
|
||||||
#else
|
#else
|
||||||
template<class T, class ...Options>
|
template<class T, class ...Options>
|
||||||
#endif
|
#endif
|
||||||
struct has_insert_before<boost::intrusive::avl_multiset<T,
|
struct has_insert_before<boost::intrusive::avl_multiset<T,
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
O1, O2, O3, O4
|
O1, O2, O3, O4, O5
|
||||||
#else
|
#else
|
||||||
Options...
|
Options...
|
||||||
#endif
|
#endif
|
||||||
@@ -242,7 +242,7 @@ int main( int, char* [] )
|
|||||||
// test (plain pointers) x (nonconst/const size) x (standard node allocator)
|
// test (plain pointers) x (nonconst/const size) x (standard node allocator)
|
||||||
test_main_template<void*, false, false>()();
|
test_main_template<void*, false, false>()();
|
||||||
test_main_template<void*, true, false>()();
|
test_main_template<void*, true, false>()();
|
||||||
// test (bounded pointers) x ((nonconst/const size) x (special node allocator)
|
// test (bounded pointers) x (nonconst/const size) x (special node allocator)
|
||||||
test_main_template_bptr< true >()();
|
test_main_template_bptr< true >()();
|
||||||
test_main_template_bptr< false >()();
|
test_main_template_bptr< false >()();
|
||||||
|
|
||||||
|
@@ -20,13 +20,13 @@
|
|||||||
namespace boost { namespace intrusive { namespace test {
|
namespace boost { namespace intrusive { namespace test {
|
||||||
|
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
template<class T, class O1, class O2, class O3, class O4>
|
template<class T, class O1, class O2, class O3, class O4, class O5>
|
||||||
#else
|
#else
|
||||||
template<class T, class ...Options>
|
template<class T, class ...Options>
|
||||||
#endif
|
#endif
|
||||||
struct has_insert_before<boost::intrusive::avl_set<T,
|
struct has_insert_before<boost::intrusive::avl_set<T,
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
O1, O2, O3, O4
|
O1, O2, O3, O4, O5
|
||||||
#else
|
#else
|
||||||
Options...
|
Options...
|
||||||
#endif
|
#endif
|
||||||
@@ -243,7 +243,7 @@ int main( int, char* [] )
|
|||||||
// test (plain pointers) x (nonconst/const size) x (standard node allocator)
|
// test (plain pointers) x (nonconst/const size) x (standard node allocator)
|
||||||
test_main_template<void*, false, false>()();
|
test_main_template<void*, false, false>()();
|
||||||
test_main_template<void*, true, false>()();
|
test_main_template<void*, true, false>()();
|
||||||
// test (bounded pointers) x ((nonconst/const size) x (special node allocator)
|
// test (bounded pointers) x (nonconst/const size) x (special node allocator)
|
||||||
test_main_template_bptr< true >()();
|
test_main_template_bptr< true >()();
|
||||||
test_main_template_bptr< false >()();
|
test_main_template_bptr< false >()();
|
||||||
|
|
||||||
|
@@ -222,44 +222,92 @@ std::vector< bool > Bounded_Allocator< T >::_in_use;
|
|||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
class Bounded_Reference_Cont
|
class Bounded_Reference_Cont
|
||||||
: public std::vector< Bounded_Reference< T > >
|
: private std::vector< Bounded_Reference< T > >
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef T value_type;
|
typedef T val_type;
|
||||||
typedef std::vector< Bounded_Reference< T > > Base;
|
typedef std::vector< Bounded_Reference< T > > Base;
|
||||||
typedef Bounded_Allocator< T > allocator_type;
|
typedef Bounded_Allocator< T > allocator_type;
|
||||||
typedef Bounded_Pointer< T > pointer;
|
typedef Bounded_Pointer< T > pointer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
typedef typename Base::value_type value_type;
|
||||||
|
typedef typename Base::iterator iterator;
|
||||||
|
typedef typename Base::const_iterator const_iterator;
|
||||||
|
typedef typename Base::reference reference;
|
||||||
|
typedef typename Base::const_reference const_reference;
|
||||||
|
typedef typename Base::reverse_iterator reverse_iterator;
|
||||||
|
typedef typename Base::const_reverse_iterator const_reverse_iterator;
|
||||||
|
|
||||||
|
iterator begin() { return Base::begin(); }
|
||||||
|
iterator end() { return Base::end(); }
|
||||||
|
const_iterator begin() const { return Base::begin(); }
|
||||||
|
const_iterator end() const { return Base::end(); }
|
||||||
|
reverse_iterator rbegin() { return Base::rbegin(); }
|
||||||
|
reverse_iterator rend() { return Base::rend(); }
|
||||||
|
const_reverse_iterator rbegin() const { return Base::rbegin(); }
|
||||||
|
const_reverse_iterator rend() const { return Base::rend(); }
|
||||||
|
reference front() { return Base::front(); }
|
||||||
|
const_reference front() const { return Base::front(); }
|
||||||
|
reference back() { return Base::back(); }
|
||||||
|
const_reference back() const { return Base::back(); }
|
||||||
|
size_t size() const { return Base::size(); }
|
||||||
|
reference operator [] (size_t i) { return Base::operator [] (i); }
|
||||||
|
const_reference operator [] (size_t i) const { return Base::operator [] (i); }
|
||||||
|
void push_back(const value_type& v) { Base::push_back(v); }
|
||||||
|
|
||||||
Bounded_Reference_Cont(size_t n = 0) : Base(), _allocator()
|
Bounded_Reference_Cont(size_t n = 0) : Base(), _allocator()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < n; ++i)
|
for (size_t i = 0; i < n; ++i)
|
||||||
{
|
{
|
||||||
pointer p = _allocator.allocate(1);
|
pointer p = _allocator.allocate(1);
|
||||||
new (p.raw()) value_type();
|
new (p.raw()) val_type();
|
||||||
Base::push_back(*p);
|
Base::push_back(*p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Bounded_Reference_Cont(const Bounded_Reference_Cont& other) : Base(), _allocator(other._allocator)
|
Bounded_Reference_Cont(const Bounded_Reference_Cont& other) : Base(), _allocator(other._allocator)
|
||||||
{
|
{
|
||||||
//std::clog << "copying values container\n";
|
//std::clog << "copying values container\n";
|
||||||
for (typename Base::const_iterator it = other.begin(); it != other.end(); ++it)
|
*this = other;
|
||||||
|
}
|
||||||
|
template < typename InputIterator >
|
||||||
|
Bounded_Reference_Cont(InputIterator it_start, InputIterator it_end) : Base(), _allocator()
|
||||||
|
{
|
||||||
|
for (InputIterator it = it_start; it != it_end; ++it)
|
||||||
{
|
{
|
||||||
pointer p = _allocator.allocate(1);
|
pointer p = _allocator.allocate(1);
|
||||||
new (p.raw()) value_type(*it);
|
new (p.raw()) val_type(*it);
|
||||||
Base::push_back(*p);
|
Base::push_back(*p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
~Bounded_Reference_Cont()
|
~Bounded_Reference_Cont()
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
void clear()
|
||||||
{
|
{
|
||||||
while (not Base::empty())
|
while (not Base::empty())
|
||||||
{
|
{
|
||||||
pointer p = &Base::back();
|
pointer p = &Base::back();
|
||||||
p->~value_type();
|
p->~val_type();
|
||||||
_allocator.deallocate(p, 1);
|
_allocator.deallocate(p, 1);
|
||||||
Base::pop_back();
|
Base::pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Bounded_Reference_Cont& operator = (const Bounded_Reference_Cont& other)
|
||||||
|
{
|
||||||
|
if (&other != this)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
for (typename Base::const_iterator it = other.begin(); it != other.end(); ++it)
|
||||||
|
{
|
||||||
|
pointer p = _allocator.allocate(1);
|
||||||
|
new (p.raw()) val_type(*it);
|
||||||
|
Base::push_back(*p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
allocator_type _allocator;
|
allocator_type _allocator;
|
||||||
|
@@ -167,6 +167,21 @@ struct AVLTree_BPtr_Node_Traits
|
|||||||
static balance positive() { return 1; }
|
static balance positive() { return 1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Tree_BPtr_Node_Traits
|
||||||
|
{
|
||||||
|
typedef BPtr_Value val_t;
|
||||||
|
typedef val_t node;
|
||||||
|
typedef Bounded_Pointer< val_t > node_ptr;
|
||||||
|
typedef Bounded_Pointer< const val_t > const_node_ptr;
|
||||||
|
|
||||||
|
static node_ptr get_parent(const_node_ptr p) { return p->_parent; }
|
||||||
|
static void set_parent(node_ptr p, node_ptr parent) { p->_parent = parent; }
|
||||||
|
static node_ptr get_left(const_node_ptr p) { return p->_l_child; }
|
||||||
|
static void set_left(node_ptr p, node_ptr l_child) { p->_l_child = l_child; }
|
||||||
|
static node_ptr get_right(const_node_ptr p) { return p->_r_child; }
|
||||||
|
static void set_right(node_ptr p, node_ptr r_child) { p->_r_child = r_child; }
|
||||||
|
};
|
||||||
|
|
||||||
template < typename Node_Traits >
|
template < typename Node_Traits >
|
||||||
struct BPtr_Value_Traits
|
struct BPtr_Value_Traits
|
||||||
{
|
{
|
||||||
|
@@ -78,38 +78,32 @@ struct test_generic_assoc
|
|||||||
typedef typename Value_Container< value_type >::type value_cont_type;
|
typedef typename Value_Container< value_type >::type value_cont_type;
|
||||||
typedef typename ValueTraits::reference reference;
|
typedef typename ValueTraits::reference reference;
|
||||||
typedef typename ValueTraits::const_reference const_reference;
|
typedef typename ValueTraits::const_reference const_reference;
|
||||||
static void test_all(value_cont_type& values);
|
static void test_all(value_cont_type&);
|
||||||
static void test_clone(value_cont_type& values);
|
static void test_clone(value_cont_type&);
|
||||||
static void test_insert_erase_burst();
|
static void test_insert_erase_burst();
|
||||||
static void test_container_from_end(value_cont_type& values);
|
static void test_container_from_end(value_cont_type&, detail::true_type);
|
||||||
static void test_splay_up(value_cont_type& values);
|
static void test_container_from_end(value_cont_type&, detail::false_type) {}
|
||||||
static void test_splay_up(value_cont_type& values, boost::intrusive::detail::true_type);
|
static void test_splay_up(value_cont_type&, detail::true_type);
|
||||||
static void test_splay_up(value_cont_type& values, boost::intrusive::detail::false_type);
|
static void test_splay_up(value_cont_type&, detail::false_type) {}
|
||||||
static void test_splay_down(value_cont_type& values);
|
static void test_splay_down(value_cont_type&, detail::true_type);
|
||||||
static void test_splay_down(value_cont_type& values, boost::intrusive::detail::true_type);
|
static void test_splay_down(value_cont_type&, detail::false_type) {}
|
||||||
static void test_splay_down(value_cont_type& values, boost::intrusive::detail::false_type);
|
static void test_rebalance(value_cont_type&, detail::true_type);
|
||||||
static void test_rebalance(value_cont_type& values);
|
static void test_rebalance(value_cont_type&, detail::false_type) {}
|
||||||
static void test_rebalance(value_cont_type& values, boost::intrusive::detail::true_type);
|
static void test_insert_before(value_cont_type&, detail::true_type);
|
||||||
static void test_rebalance(value_cont_type& values, boost::intrusive::detail::false_type);
|
static void test_insert_before(value_cont_type&, detail::false_type) {}
|
||||||
static void test_insert_before(value_cont_type& values);
|
static void test_container_from_iterator(value_cont_type&, detail::true_type);
|
||||||
static void test_insert_before(value_cont_type& values, boost::intrusive::detail::true_type);
|
static void test_container_from_iterator(value_cont_type&, detail::false_type) {}
|
||||||
static void test_insert_before(value_cont_type& values, boost::intrusive::detail::false_type);
|
|
||||||
static void test_container_from_iterator(value_cont_type& values);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template < bool Has_Container_From_Iterator, typename assoc_type, typename Value_Container >
|
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||||
struct test_container_from_iterator_impl
|
void test_generic_assoc<ValueTraits, ContainerDefiner>::
|
||||||
{
|
test_container_from_iterator(value_cont_type& values, detail::true_type)
|
||||||
void operator () (Value_Container&)
|
|
||||||
{
|
|
||||||
std::clog << "skipping test_container_from_iterator\n";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template < typename assoc_type, typename Value_Container >
|
|
||||||
struct test_container_from_iterator_impl< true, assoc_type, Value_Container >
|
|
||||||
{
|
|
||||||
void operator () (Value_Container& values)
|
|
||||||
{
|
{
|
||||||
|
typedef typename ContainerDefiner
|
||||||
|
< value_type
|
||||||
|
, value_traits<ValueTraits>
|
||||||
|
, constant_time_size<value_type::constant_time_size>
|
||||||
|
>::type assoc_type;
|
||||||
assoc_type testset(values.begin(), values.end());
|
assoc_type testset(values.begin(), values.end());
|
||||||
typedef typename assoc_type::iterator it_type;
|
typedef typename assoc_type::iterator it_type;
|
||||||
typedef typename assoc_type::const_iterator cit_type;
|
typedef typename assoc_type::const_iterator cit_type;
|
||||||
@@ -127,19 +121,6 @@ struct test_container_from_iterator_impl< true, assoc_type, Value_Container >
|
|||||||
BOOST_TEST(testset.size() == sz);
|
BOOST_TEST(testset.size() == sz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
|
||||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::
|
|
||||||
test_container_from_iterator(value_cont_type& values)
|
|
||||||
{
|
|
||||||
typedef typename ContainerDefiner
|
|
||||||
< value_type
|
|
||||||
, value_traits<ValueTraits>
|
|
||||||
, constant_time_size<value_type::constant_time_size>
|
|
||||||
>::type assoc_type;
|
|
||||||
test_container_from_iterator_impl< assoc_type::has_container_from_iterator, assoc_type, value_cont_type >()(values);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_erase_burst()
|
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_erase_burst()
|
||||||
@@ -202,14 +183,20 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_erase_burst(
|
|||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_all(value_cont_type& values)
|
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_all(value_cont_type& values)
|
||||||
{
|
{
|
||||||
|
typedef typename ContainerDefiner
|
||||||
|
< value_type
|
||||||
|
, value_traits<ValueTraits>
|
||||||
|
, constant_time_size<value_type::constant_time_size>
|
||||||
|
>::type assoc_type;
|
||||||
|
|
||||||
test_clone(values);
|
test_clone(values);
|
||||||
test_container_from_end(values);
|
test_container_from_end(values, detail::bool_< assoc_type::has_container_from_iterator >());
|
||||||
test_splay_up(values);
|
test_splay_up(values, detail::bool_< has_splay< assoc_type >::value >());
|
||||||
test_splay_down(values);
|
test_splay_down(values, detail::bool_< has_splay< assoc_type >::value >());
|
||||||
test_rebalance(values);
|
test_rebalance(values, detail::bool_< has_rebalance< assoc_type >::value >());
|
||||||
test_insert_before(values);
|
test_insert_before(values, detail::bool_< has_insert_before< assoc_type >::value >());
|
||||||
test_insert_erase_burst();
|
test_insert_erase_burst();
|
||||||
test_container_from_iterator(values);
|
test_container_from_iterator(values, detail::bool_< assoc_type::has_container_from_iterator >());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||||
@@ -230,28 +217,9 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>
|
|||||||
BOOST_TEST (testset2.empty());
|
BOOST_TEST (testset2.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
template < bool Has_Container_From_Iterator, typename assoc_type, typename value_cont_type >
|
|
||||||
struct test_container_from_end_impl
|
|
||||||
{
|
|
||||||
void operator () (value_cont_type&)
|
|
||||||
{
|
|
||||||
std::clog << "skipping test_container_from_end\n";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template < typename assoc_type, typename value_cont_type >
|
|
||||||
struct test_container_from_end_impl< true, assoc_type, value_cont_type >
|
|
||||||
{
|
|
||||||
void operator () (value_cont_type& values)
|
|
||||||
{
|
|
||||||
assoc_type testset (values.begin(), values.begin() + values.size());
|
|
||||||
BOOST_TEST (testset == assoc_type::container_from_end_iterator(testset.end()));
|
|
||||||
BOOST_TEST (testset == assoc_type::container_from_end_iterator(testset.cend()));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||||
void test_generic_assoc<ValueTraits, ContainerDefiner>
|
void test_generic_assoc<ValueTraits, ContainerDefiner>
|
||||||
::test_container_from_end(value_cont_type& values)
|
::test_container_from_end(value_cont_type& values, detail::true_type)
|
||||||
{
|
{
|
||||||
typedef typename ValueTraits::value_type value_type;
|
typedef typename ValueTraits::value_type value_type;
|
||||||
typedef typename ContainerDefiner
|
typedef typename ContainerDefiner
|
||||||
@@ -259,12 +227,14 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>
|
|||||||
, value_traits<ValueTraits>
|
, value_traits<ValueTraits>
|
||||||
, constant_time_size<value_type::constant_time_size>
|
, constant_time_size<value_type::constant_time_size>
|
||||||
>::type assoc_type;
|
>::type assoc_type;
|
||||||
test_container_from_end_impl< assoc_type::has_container_from_iterator, assoc_type, value_cont_type >()(values);
|
assoc_type testset (values.begin(), values.begin() + values.size());
|
||||||
|
BOOST_TEST (testset == assoc_type::container_from_end_iterator(testset.end()));
|
||||||
|
BOOST_TEST (testset == assoc_type::container_from_end_iterator(testset.cend()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_up
|
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_up
|
||||||
(value_cont_type& values, boost::intrusive::detail::true_type)
|
(value_cont_type& values, detail::true_type)
|
||||||
{
|
{
|
||||||
typedef typename ValueTraits::value_type value_type;
|
typedef typename ValueTraits::value_type value_type;
|
||||||
typedef typename ContainerDefiner
|
typedef typename ContainerDefiner
|
||||||
@@ -279,7 +249,7 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_up
|
|||||||
{
|
{
|
||||||
assoc_type testset (values.begin(), values.end());
|
assoc_type testset (values.begin(), values.end());
|
||||||
num_values = testset.size();
|
num_values = testset.size();
|
||||||
original_testset.insert(original_testset.end(), testset.begin(), testset.end());
|
original_testset = value_cont_type(testset.begin(), testset.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::size_t i = 0; i != num_values; ++i){
|
for(std::size_t i = 0; i != num_values; ++i){
|
||||||
@@ -300,28 +270,9 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_up
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
|
||||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_up
|
|
||||||
(value_cont_type&, boost::intrusive::detail::false_type)
|
|
||||||
{}
|
|
||||||
|
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
|
||||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_up
|
|
||||||
(value_cont_type& values)
|
|
||||||
{
|
|
||||||
typedef typename ContainerDefiner
|
|
||||||
< value_type
|
|
||||||
, value_traits<ValueTraits>
|
|
||||||
, constant_time_size<value_type::constant_time_size>
|
|
||||||
>::type assoc_type;
|
|
||||||
typedef typename detail::remove_const<assoc_type>::type Type;
|
|
||||||
typedef detail::bool_<has_splay<Type>::value> enabler;
|
|
||||||
test_splay_up(values, enabler());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_down
|
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_down
|
||||||
(value_cont_type& values, boost::intrusive::detail::true_type)
|
(value_cont_type& values, detail::true_type)
|
||||||
{
|
{
|
||||||
typedef typename ValueTraits::value_type value_type;
|
typedef typename ValueTraits::value_type value_type;
|
||||||
typedef typename ContainerDefiner
|
typedef typename ContainerDefiner
|
||||||
@@ -336,7 +287,7 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_down
|
|||||||
{
|
{
|
||||||
assoc_type testset (values.begin(), values.end());
|
assoc_type testset (values.begin(), values.end());
|
||||||
num_values = testset.size();
|
num_values = testset.size();
|
||||||
original_testset.insert(original_testset.end(), testset.begin(), testset.end());
|
original_testset = value_cont_type(testset.begin(), testset.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::size_t i = 0; i != num_values; ++i){
|
for(std::size_t i = 0; i != num_values; ++i){
|
||||||
@@ -358,28 +309,9 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_down
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
|
||||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_down
|
|
||||||
(value_cont_type&, boost::intrusive::detail::false_type)
|
|
||||||
{}
|
|
||||||
|
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
|
||||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_down
|
|
||||||
(value_cont_type& values)
|
|
||||||
{
|
|
||||||
typedef typename ContainerDefiner
|
|
||||||
< value_type
|
|
||||||
, value_traits<ValueTraits>
|
|
||||||
, constant_time_size<value_type::constant_time_size>
|
|
||||||
>::type assoc_type;
|
|
||||||
typedef typename detail::remove_const<assoc_type>::type Type;
|
|
||||||
typedef detail::bool_<has_splay<Type>::value> enabler;
|
|
||||||
test_splay_down(values, enabler());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_rebalance
|
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_rebalance
|
||||||
(value_cont_type& values, boost::intrusive::detail::true_type)
|
(value_cont_type& values, detail::true_type)
|
||||||
{
|
{
|
||||||
typedef typename ValueTraits::value_type value_type;
|
typedef typename ValueTraits::value_type value_type;
|
||||||
typedef typename ContainerDefiner
|
typedef typename ContainerDefiner
|
||||||
@@ -391,7 +323,8 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_rebalance
|
|||||||
orig_set_t original_testset;
|
orig_set_t original_testset;
|
||||||
{
|
{
|
||||||
assoc_type testset (values.begin(), values.end());
|
assoc_type testset (values.begin(), values.end());
|
||||||
original_testset.insert(original_testset.end(), testset.begin(), testset.end());
|
//original_testset.insert(original_testset.end(), testset.begin(), testset.end());
|
||||||
|
original_testset = value_cont_type(testset.begin(), testset.end());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
assoc_type testset(values.begin(), values.end());
|
assoc_type testset(values.begin(), values.end());
|
||||||
@@ -416,28 +349,9 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_rebalance
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
|
||||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_rebalance
|
|
||||||
(value_cont_type&, boost::intrusive::detail::false_type)
|
|
||||||
{}
|
|
||||||
|
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
|
||||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_rebalance
|
|
||||||
(value_cont_type& values)
|
|
||||||
{
|
|
||||||
typedef typename ContainerDefiner
|
|
||||||
< value_type
|
|
||||||
, value_traits<ValueTraits>
|
|
||||||
, constant_time_size<value_type::constant_time_size>
|
|
||||||
>::type assoc_type;
|
|
||||||
typedef typename detail::remove_const<assoc_type>::type Type;
|
|
||||||
typedef detail::bool_<has_rebalance<Type>::value> enabler;
|
|
||||||
test_rebalance(values, enabler());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_before
|
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_before
|
||||||
(value_cont_type& values, boost::intrusive::detail::true_type)
|
(value_cont_type& values, detail::true_type)
|
||||||
{
|
{
|
||||||
typedef typename ValueTraits::value_type value_type;
|
typedef typename ValueTraits::value_type value_type;
|
||||||
typedef typename ContainerDefiner
|
typedef typename ContainerDefiner
|
||||||
@@ -485,25 +399,6 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_before
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
|
||||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_before
|
|
||||||
(value_cont_type&, boost::intrusive::detail::false_type)
|
|
||||||
{}
|
|
||||||
|
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
|
||||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_before
|
|
||||||
(value_cont_type& values)
|
|
||||||
{
|
|
||||||
typedef typename ContainerDefiner
|
|
||||||
< value_type
|
|
||||||
, value_traits<ValueTraits>
|
|
||||||
, constant_time_size<value_type::constant_time_size>
|
|
||||||
>::type assoc_type;
|
|
||||||
typedef typename detail::remove_const<assoc_type>::type Type;
|
|
||||||
typedef detail::bool_<has_insert_before<Type>::value> enabler;
|
|
||||||
test_insert_before(values, enabler());
|
|
||||||
}
|
|
||||||
|
|
||||||
}}} //namespace boost::intrusive::test
|
}}} //namespace boost::intrusive::test
|
||||||
|
|
||||||
#include <boost/intrusive/detail/config_end.hpp>
|
#include <boost/intrusive/detail/config_end.hpp>
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
#include "test_macros.hpp"
|
#include "test_macros.hpp"
|
||||||
#include "test_container.hpp"
|
#include "test_container.hpp"
|
||||||
#include "generic_assoc_test.hpp"
|
#include "generic_assoc_test.hpp"
|
||||||
|
#include <typeinfo>
|
||||||
|
|
||||||
namespace boost{
|
namespace boost{
|
||||||
namespace intrusive{
|
namespace intrusive{
|
||||||
@@ -30,11 +31,11 @@ struct test_generic_multiset
|
|||||||
typedef typename Value_Container< value_type >::type value_cont_type;
|
typedef typename Value_Container< value_type >::type value_cont_type;
|
||||||
typedef typename ValueTraits::reference reference;
|
typedef typename ValueTraits::reference reference;
|
||||||
typedef typename ValueTraits::const_reference const_reference;
|
typedef typename ValueTraits::const_reference const_reference;
|
||||||
static void test_all ();
|
static void test_all();
|
||||||
static void test_sort(value_cont_type& values);
|
static void test_sort(value_cont_type&);
|
||||||
static void test_insert(value_cont_type& values);
|
static void test_insert(value_cont_type&);
|
||||||
static void test_swap(value_cont_type& values);
|
static void test_swap(value_cont_type&);
|
||||||
static void test_find(value_cont_type& values);
|
static void test_find(value_cont_type&);
|
||||||
static void test_impl();
|
static void test_impl();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -52,6 +53,22 @@ void test_generic_multiset<ValueTraits, ContainerDefiner>::test_all ()
|
|||||||
, value_traits<ValueTraits>
|
, value_traits<ValueTraits>
|
||||||
, constant_time_size<value_type::constant_time_size>
|
, constant_time_size<value_type::constant_time_size>
|
||||||
>::type multiset_type;
|
>::type multiset_type;
|
||||||
|
#ifdef PRINT_TESTS
|
||||||
|
std::clog << "testing multiset with:\n"
|
||||||
|
<< " value_type = " << typeid(value_type).name() << "\n"
|
||||||
|
<< " sizeof(value_type) = " << sizeof(value_type) << "\n"
|
||||||
|
<< " link_mode = " << ValueTraits::link_mode << "\n"
|
||||||
|
<< " node = " << typeid(typename multiset_type::node).name() << "\n"
|
||||||
|
<< " sizeof(node) = " << sizeof(typename multiset_type::node) << "\n"
|
||||||
|
<< " node_ptr = " << typeid(typename multiset_type::node_ptr).name() << "\n"
|
||||||
|
<< " sizeof(node_ptr) = " << sizeof(typename multiset_type::node_ptr) << "\n"
|
||||||
|
<< " constant_time_size = " << multiset_type::constant_time_size << "\n"
|
||||||
|
<< " has_container_from_iterator = " << multiset_type::has_container_from_iterator << "\n"
|
||||||
|
<< " has_splay = " << has_splay< multiset_type >::value << "\n"
|
||||||
|
<< " has_rebalance = " << has_rebalance< multiset_type >::value << "\n"
|
||||||
|
<< " has_insert_before = " << has_insert_before< multiset_type >::value << "\n"
|
||||||
|
<< " sizeof(multiset_type) = " << sizeof(multiset_type) << "\n";
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
multiset_type testset(values.begin(), values.end());
|
multiset_type testset(values.begin(), values.end());
|
||||||
test::test_container(testset);
|
test::test_container(testset);
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
#include "test_macros.hpp"
|
#include "test_macros.hpp"
|
||||||
#include "test_container.hpp"
|
#include "test_container.hpp"
|
||||||
#include "generic_assoc_test.hpp"
|
#include "generic_assoc_test.hpp"
|
||||||
|
#include <typeinfo>
|
||||||
|
|
||||||
namespace boost{
|
namespace boost{
|
||||||
namespace intrusive{
|
namespace intrusive{
|
||||||
@@ -37,13 +38,12 @@ struct test_generic_set
|
|||||||
typedef typename ValueTraits::reference reference;
|
typedef typename ValueTraits::reference reference;
|
||||||
typedef typename ValueTraits::const_reference const_reference;
|
typedef typename ValueTraits::const_reference const_reference;
|
||||||
static void test_all();
|
static void test_all();
|
||||||
static void test_sort(value_cont_type& values);
|
static void test_sort(value_cont_type&);
|
||||||
static void test_insert(value_cont_type& values);
|
static void test_insert(value_cont_type&);
|
||||||
static void test_insert_advanced(value_cont_type& values, boost::intrusive::detail::true_type);
|
static void test_insert_advanced(value_cont_type&, detail::true_type);
|
||||||
static void test_insert_advanced(value_cont_type& values, boost::intrusive::detail::false_type);
|
static void test_insert_advanced(value_cont_type&, detail::false_type);
|
||||||
static void test_insert_advanced(value_cont_type& values);
|
static void test_swap(value_cont_type&);
|
||||||
static void test_swap(value_cont_type& values);
|
static void test_find(value_cont_type&);
|
||||||
static void test_find(value_cont_type& values);
|
|
||||||
static void test_impl();
|
static void test_impl();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -62,6 +62,23 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_all()
|
|||||||
, value_traits<ValueTraits>
|
, value_traits<ValueTraits>
|
||||||
, constant_time_size<value_type::constant_time_size>
|
, constant_time_size<value_type::constant_time_size>
|
||||||
>::type set_type;
|
>::type set_type;
|
||||||
|
#ifdef PRINT_TESTS
|
||||||
|
std::clog << "testing set with:\n"
|
||||||
|
<< " value_type = " << typeid(value_type).name() << "\n"
|
||||||
|
<< " sizeof(value_type) = " << sizeof(value_type) << "\n"
|
||||||
|
<< " link_mode = " << ValueTraits::link_mode << "\n"
|
||||||
|
<< " node = " << typeid(typename set_type::node).name() << "\n"
|
||||||
|
<< " sizeof(node) = " << sizeof(typename set_type::node) << "\n"
|
||||||
|
<< " node_ptr = " << typeid(typename set_type::node_ptr).name() << "\n"
|
||||||
|
<< " sizeof(node_ptr) = " << sizeof(typename set_type::node_ptr) << "\n"
|
||||||
|
<< " constant_time_size = " << set_type::constant_time_size << "\n"
|
||||||
|
<< " has_container_from_iterator = " << set_type::has_container_from_iterator << "\n"
|
||||||
|
<< " is_treap = " << is_treap< set_type >::value << "\n"
|
||||||
|
<< " has_splay = " << has_splay< set_type >::value << "\n"
|
||||||
|
<< " has_rebalance = " << has_rebalance< set_type >::value << "\n"
|
||||||
|
<< " has_insert_before = " << has_insert_before< set_type >::value << "\n"
|
||||||
|
<< " sizeof(set_type) = " << sizeof(set_type) << "\n";
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
set_type testset(values.begin(), values.end());
|
set_type testset(values.begin(), values.end());
|
||||||
test::test_container(testset);
|
test::test_container(testset);
|
||||||
@@ -77,7 +94,7 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_all()
|
|||||||
}
|
}
|
||||||
test_sort(values);
|
test_sort(values);
|
||||||
test_insert(values);
|
test_insert(values);
|
||||||
test_insert_advanced(values);
|
test_insert_advanced(values, detail::bool_< is_treap< set_type >::value >());
|
||||||
test_swap(values);
|
test_swap(values);
|
||||||
test_find(values);
|
test_find(values);
|
||||||
test_impl();
|
test_impl();
|
||||||
@@ -187,9 +204,10 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_insert(value_cont_typ
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// treap version
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||||
void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
|
void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
|
||||||
(value_cont_type& values, boost::intrusive::detail::true_type)
|
(value_cont_type& values, detail::true_type)
|
||||||
{
|
{
|
||||||
typedef typename ValueTraits::value_type value_type;
|
typedef typename ValueTraits::value_type value_type;
|
||||||
typedef typename ContainerDefiner
|
typedef typename ContainerDefiner
|
||||||
@@ -207,28 +225,10 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
|
||||||
void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
|
|
||||||
(value_cont_type& values)
|
|
||||||
{
|
|
||||||
typedef typename ValueTraits::value_type value_type;
|
|
||||||
typedef typename ContainerDefiner
|
|
||||||
< value_type
|
|
||||||
, value_traits<ValueTraits>
|
|
||||||
, constant_time_size<value_type::constant_time_size>
|
|
||||||
>::type set_type;
|
|
||||||
typedef typename detail::remove_const<set_type>::type Type;
|
|
||||||
typedef detail::bool_<is_treap<Type>::value> enabler;
|
|
||||||
test_insert_advanced(values, enabler());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//test: insert, const_iterator, const_reverse_iterator, erase, s_iterator_to:
|
//test: insert, const_iterator, const_reverse_iterator, erase, s_iterator_to:
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||||
void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
|
void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
|
||||||
( value_cont_type& values
|
(value_cont_type& values, detail::false_type)
|
||||||
, boost::intrusive::detail::false_type)
|
|
||||||
{
|
{
|
||||||
typedef typename ValueTraits::value_type value_type;
|
typedef typename ValueTraits::value_type value_type;
|
||||||
typedef typename ContainerDefiner
|
typedef typename ContainerDefiner
|
||||||
@@ -246,7 +246,6 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//test: insert (seq-version), swap, erase (seq-version), size:
|
//test: insert (seq-version), swap, erase (seq-version), size:
|
||||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||||
void test_generic_set<ValueTraits, ContainerDefiner>::test_swap(value_cont_type& values)
|
void test_generic_set<ValueTraits, ContainerDefiner>::test_swap(value_cont_type& values)
|
||||||
|
@@ -118,16 +118,15 @@ void swap_nodes(testvalue< Hooks, ConstantTimeSize >& lhs, testvalue< Hooks, Con
|
|||||||
lhs.swap_nodes(rhs);
|
lhs.swap_nodes(rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Hooks, bool ConstantTimeSize>
|
template < typename Value_Type >
|
||||||
std::size_t hash_value(const testvalue<Hooks, ConstantTimeSize> &t)
|
std::size_t hash_value(const Value_Type& t)
|
||||||
{
|
{
|
||||||
boost::hash<int> hasher;
|
boost::hash<int> hasher;
|
||||||
return hasher(t.value_);
|
return hasher((&t)->value_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Hooks, bool ConstantTimeSize>
|
template < typename Value_Type >
|
||||||
bool priority_order( const testvalue<Hooks, ConstantTimeSize> &t1
|
bool priority_order(const Value_Type& t1, const Value_Type& t2)
|
||||||
, const testvalue<Hooks, ConstantTimeSize> &t2)
|
|
||||||
{
|
{
|
||||||
std::size_t hash1 = hash_value(t1);
|
std::size_t hash1 = hash_value(t1);
|
||||||
boost::hash_combine(hash1, &t1);
|
boost::hash_combine(hash1, &t1);
|
||||||
|
@@ -51,21 +51,23 @@ struct test_list
|
|||||||
typedef typename value_traits::value_type value_type;
|
typedef typename value_traits::value_type value_type;
|
||||||
typedef typename list_type::node_algorithms node_algorithms;
|
typedef typename list_type::node_algorithms node_algorithms;
|
||||||
|
|
||||||
static void test_all(Value_Container& values);
|
static void test_all(Value_Container&);
|
||||||
static void test_front_back(Value_Container& values);
|
static void test_front_back(Value_Container&);
|
||||||
static void test_sort(Value_Container& values);
|
static void test_sort(Value_Container&);
|
||||||
static void test_merge(Value_Container& values);
|
static void test_merge(Value_Container&);
|
||||||
static void test_remove_unique(Value_Container& values);
|
static void test_remove_unique(Value_Container&);
|
||||||
static void test_insert(Value_Container& values);
|
static void test_insert(Value_Container&);
|
||||||
static void test_shift(Value_Container& values);
|
static void test_shift(Value_Container&);
|
||||||
static void test_swap(Value_Container& values);
|
static void test_swap(Value_Container&);
|
||||||
static void test_clone(Value_Container& values);
|
static void test_clone(Value_Container&);
|
||||||
static void test_container_from_end(Value_Container& values);
|
static void test_container_from_end(Value_Container&, detail::true_type);
|
||||||
|
static void test_container_from_end(Value_Container&, detail::false_type) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template < typename List_Type, typename Value_Container >
|
template < typename List_Type, typename Value_Container >
|
||||||
void test_list< List_Type, Value_Container >::test_all(Value_Container& values)
|
void test_list< List_Type, Value_Container >::test_all(Value_Container& values)
|
||||||
{
|
{
|
||||||
|
#ifdef PRINT_TESTS
|
||||||
std::clog << "testing list with:\n"
|
std::clog << "testing list with:\n"
|
||||||
<< " value_type = " << typeid(value_type).name() << "\n"
|
<< " value_type = " << typeid(value_type).name() << "\n"
|
||||||
<< " sizeof(value_type) = " << sizeof(value_type) << "\n"
|
<< " sizeof(value_type) = " << sizeof(value_type) << "\n"
|
||||||
@@ -77,6 +79,7 @@ void test_list< List_Type, Value_Container >::test_all(Value_Container& values)
|
|||||||
<< " constant_time_size = " << list_type::constant_time_size << "\n"
|
<< " constant_time_size = " << list_type::constant_time_size << "\n"
|
||||||
<< " has_container_from_iterator = " << list_type::has_container_from_iterator << "\n"
|
<< " has_container_from_iterator = " << list_type::has_container_from_iterator << "\n"
|
||||||
<< " sizeof(list_type) = " << sizeof(list_type) << "\n";
|
<< " sizeof(list_type) = " << sizeof(list_type) << "\n";
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
list_type list(values.begin(), values.end());
|
list_type list(values.begin(), values.end());
|
||||||
test::test_container(list);
|
test::test_container(list);
|
||||||
@@ -93,7 +96,7 @@ void test_list< List_Type, Value_Container >::test_all(Value_Container& values)
|
|||||||
test_shift(values);
|
test_shift(values);
|
||||||
test_swap(values);
|
test_swap(values);
|
||||||
test_clone(values);
|
test_clone(values);
|
||||||
test_container_from_end(values);
|
test_container_from_end(values, detail::bool_< List_Type::has_container_from_iterator >());
|
||||||
}
|
}
|
||||||
|
|
||||||
//test: push_front, pop_front, push_back, pop_back, front, back, size, empty:
|
//test: push_front, pop_front, push_back, pop_back, front, back, size, empty:
|
||||||
@@ -338,33 +341,14 @@ void test_list< List_Type, Value_Container >
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class List_Type, typename Value_Container, bool >
|
|
||||||
struct test_container_from_end_impl
|
|
||||||
{
|
|
||||||
void operator () (Value_Container&)
|
|
||||||
{
|
|
||||||
std::clog << "skipping test_container_from_end\n";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template < class List_Type, typename Value_Container >
|
template < class List_Type, typename Value_Container >
|
||||||
struct test_container_from_end_impl< List_Type, Value_Container, true >
|
void test_list< List_Type, Value_Container >
|
||||||
|
::test_container_from_end(Value_Container& values, detail::true_type)
|
||||||
{
|
{
|
||||||
void operator () (Value_Container& values)
|
|
||||||
{
|
|
||||||
typedef List_Type list_type;
|
|
||||||
list_type testlist1 (values.begin(), values.begin() + values.size());
|
list_type testlist1 (values.begin(), values.begin() + values.size());
|
||||||
BOOST_TEST (testlist1 == list_type::container_from_end_iterator(testlist1.end()));
|
BOOST_TEST (testlist1 == list_type::container_from_end_iterator(testlist1.end()));
|
||||||
BOOST_TEST (testlist1 == list_type::container_from_end_iterator(testlist1.cend()));
|
BOOST_TEST (testlist1 == list_type::container_from_end_iterator(testlist1.cend()));
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template < class List_Type, typename Value_Container >
|
|
||||||
void test_list< List_Type, Value_Container >
|
|
||||||
::test_container_from_end(Value_Container& values)
|
|
||||||
{
|
|
||||||
test_container_from_end_impl< List_Type, Value_Container, List_Type::has_container_from_iterator >()(values);
|
|
||||||
}
|
|
||||||
|
|
||||||
template < class List_Type, typename Value_Container >
|
template < class List_Type, typename Value_Container >
|
||||||
void test_list< List_Type, Value_Container >
|
void test_list< List_Type, Value_Container >
|
||||||
@@ -546,15 +530,15 @@ struct test_main_template_bptr
|
|||||||
|
|
||||||
int main( int, char* [] )
|
int main( int, char* [] )
|
||||||
{
|
{
|
||||||
// test combinations of (regular/smart)_ptr x (const/nonconst)_size x (default/non-default)_header_holder
|
// test (plain/smart pointers) x (nonconst/const size) x (void node allocator)
|
||||||
// skip smart_ptr with non-default header_holder
|
|
||||||
test_main_template<void*, false, true>()();
|
test_main_template<void*, false, true>()();
|
||||||
test_main_template<smart_ptr<void>, false, true>()();
|
test_main_template<boost::intrusive::smart_ptr<void>, false, true>()();
|
||||||
test_main_template<void*, true, true>()();
|
test_main_template<void*, true, true>()();
|
||||||
test_main_template<smart_ptr<void>, true, true>()();
|
test_main_template<boost::intrusive::smart_ptr<void>, true, true>()();
|
||||||
|
// test (plain pointers) x (nonconst/const size) x (standard node allocator)
|
||||||
test_main_template<void*, false, false>()();
|
test_main_template<void*, false, false>()();
|
||||||
test_main_template<void*, true, false>()();
|
test_main_template<void*, true, false>()();
|
||||||
// test bounded pointers with const/non_const size (always with non-default header_holder)
|
// test (bounded pointers) x ((nonconst/const size) x (special node allocator)
|
||||||
test_main_template_bptr< true >()();
|
test_main_template_bptr< true >()();
|
||||||
test_main_template_bptr< false >()();
|
test_main_template_bptr< false >()();
|
||||||
|
|
||||||
|
@@ -20,13 +20,13 @@
|
|||||||
namespace boost { namespace intrusive { namespace test {
|
namespace boost { namespace intrusive { namespace test {
|
||||||
|
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
template<class T, class O1, class O2, class O3, class O4>
|
template<class T, class O1, class O2, class O3, class O4, class O5>
|
||||||
#else
|
#else
|
||||||
template<class T, class ...Options>
|
template<class T, class ...Options>
|
||||||
#endif
|
#endif
|
||||||
struct has_insert_before<boost::intrusive::multiset<T,
|
struct has_insert_before<boost::intrusive::multiset<T,
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
O1, O2, O3, O4
|
O1, O2, O3, O4, O5
|
||||||
#else
|
#else
|
||||||
Options...
|
Options...
|
||||||
#endif
|
#endif
|
||||||
@@ -242,7 +242,7 @@ int main( int, char* [] )
|
|||||||
// test (plain pointers) x (nonconst/const size) x (standard node allocator)
|
// test (plain pointers) x (nonconst/const size) x (standard node allocator)
|
||||||
test_main_template<void*, false, false>()();
|
test_main_template<void*, false, false>()();
|
||||||
test_main_template<void*, true, false>()();
|
test_main_template<void*, true, false>()();
|
||||||
// test (bounded pointers) x ((nonconst/const size) x (special node allocator)
|
// test (bounded pointers) x (nonconst/const size) x (special node allocator)
|
||||||
test_main_template_bptr< true >()();
|
test_main_template_bptr< true >()();
|
||||||
test_main_template_bptr< false >()();
|
test_main_template_bptr< false >()();
|
||||||
|
|
||||||
|
@@ -21,13 +21,13 @@
|
|||||||
namespace boost { namespace intrusive { namespace test {
|
namespace boost { namespace intrusive { namespace test {
|
||||||
|
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
template<class T, class O1, class O2, class O3, class O4>
|
template<class T, class O1, class O2, class O3, class O4, class O5>
|
||||||
#else
|
#else
|
||||||
template<class T, class ...Options>
|
template<class T, class ...Options>
|
||||||
#endif
|
#endif
|
||||||
struct has_insert_before<boost::intrusive::set<T,
|
struct has_insert_before<boost::intrusive::set<T,
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
O1, O2, O3, O4
|
O1, O2, O3, O4, O5
|
||||||
#else
|
#else
|
||||||
Options...
|
Options...
|
||||||
#endif
|
#endif
|
||||||
@@ -245,7 +245,7 @@ int main( int, char* [] )
|
|||||||
// test (plain pointers) x (nonconst/const size) x (standard node allocator)
|
// test (plain pointers) x (nonconst/const size) x (standard node allocator)
|
||||||
test_main_template<void*, false, false>()();
|
test_main_template<void*, false, false>()();
|
||||||
test_main_template<void*, true, false>()();
|
test_main_template<void*, true, false>()();
|
||||||
// test (bounded pointers) x ((nonconst/const size) x (special node allocator)
|
// test (bounded pointers) x (nonconst/const size) x (special node allocator)
|
||||||
test_main_template_bptr< true >()();
|
test_main_template_bptr< true >()();
|
||||||
test_main_template_bptr< false >()();
|
test_main_template_bptr< false >()();
|
||||||
|
|
||||||
|
@@ -13,19 +13,20 @@
|
|||||||
#include <boost/intrusive/detail/config_begin.hpp>
|
#include <boost/intrusive/detail/config_begin.hpp>
|
||||||
#include <boost/intrusive/sg_set.hpp>
|
#include <boost/intrusive/sg_set.hpp>
|
||||||
#include "itestvalue.hpp"
|
#include "itestvalue.hpp"
|
||||||
|
#include "bptr_value.hpp"
|
||||||
#include "smart_ptr.hpp"
|
#include "smart_ptr.hpp"
|
||||||
#include "generic_multiset_test.hpp"
|
#include "generic_multiset_test.hpp"
|
||||||
|
|
||||||
namespace boost { namespace intrusive { namespace test {
|
namespace boost { namespace intrusive { namespace test {
|
||||||
|
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
template<class T, class O1, class O2, class O3, class O4>
|
template<class T, class O1, class O2, class O3, class O4, class O5>
|
||||||
#else
|
#else
|
||||||
template<class T, class ...Options>
|
template<class T, class ...Options>
|
||||||
#endif
|
#endif
|
||||||
struct has_rebalance<boost::intrusive::sg_multiset<T,
|
struct has_rebalance<boost::intrusive::sg_multiset<T,
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
O1, O2, O3, O4
|
O1, O2, O3, O4, O5
|
||||||
#else
|
#else
|
||||||
Options...
|
Options...
|
||||||
#endif
|
#endif
|
||||||
@@ -36,13 +37,13 @@ struct has_rebalance<boost::intrusive::sg_multiset<T,
|
|||||||
|
|
||||||
|
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
template<class T, class O1, class O2, class O3, class O4>
|
template<class T, class O1, class O2, class O3, class O4, class O5>
|
||||||
#else
|
#else
|
||||||
template<class T, class ...Options>
|
template<class T, class ...Options>
|
||||||
#endif
|
#endif
|
||||||
struct has_insert_before<boost::intrusive::sg_multiset<T,
|
struct has_insert_before<boost::intrusive::sg_multiset<T,
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
O1, O2, O3, O4
|
O1, O2, O3, O4, O5
|
||||||
#else
|
#else
|
||||||
Options...
|
Options...
|
||||||
#endif
|
#endif
|
||||||
@@ -79,7 +80,7 @@ template< class ValueType
|
|||||||
>
|
>
|
||||||
struct GetContainer
|
struct GetContainer
|
||||||
{
|
{
|
||||||
typedef boost::intrusive::sg_multiset
|
typedef boost::intrusive::sg_set
|
||||||
< ValueType
|
< ValueType
|
||||||
, Option1
|
, Option1
|
||||||
, Option2
|
, Option2
|
||||||
@@ -94,7 +95,7 @@ template< class ValueType
|
|||||||
>
|
>
|
||||||
struct GetContainerFixedAlpha
|
struct GetContainerFixedAlpha
|
||||||
{
|
{
|
||||||
typedef boost::intrusive::sg_multiset
|
typedef boost::intrusive::sg_set
|
||||||
< ValueType
|
< ValueType
|
||||||
, Option1
|
, Option1
|
||||||
, Option2
|
, Option2
|
||||||
@@ -103,7 +104,101 @@ struct GetContainerFixedAlpha
|
|||||||
> type;
|
> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class VoidPointer>
|
// container generator with void node allocator
|
||||||
|
template < bool Default_Holder >
|
||||||
|
struct GetContainer_With_Holder
|
||||||
|
{
|
||||||
|
template< class ValueType
|
||||||
|
, class Option1 =void
|
||||||
|
, class Option2 =void
|
||||||
|
, class Option3 =void
|
||||||
|
>
|
||||||
|
struct GetContainer
|
||||||
|
{
|
||||||
|
typedef boost::intrusive::sg_multiset
|
||||||
|
< ValueType
|
||||||
|
, Option1
|
||||||
|
, Option2
|
||||||
|
, Option3
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// container generator with standard (non-void) node allocator
|
||||||
|
template <>
|
||||||
|
struct GetContainer_With_Holder< false >
|
||||||
|
{
|
||||||
|
template< class ValueType
|
||||||
|
, class Option1 =void
|
||||||
|
, class Option2 =void
|
||||||
|
, class Option3 =void
|
||||||
|
>
|
||||||
|
struct GetContainer
|
||||||
|
{
|
||||||
|
// extract node type through options->value_traits->node_traits->node
|
||||||
|
typedef typename pack_options< sgtree_defaults, Option1, Option2, Option3 >::type packed_options;
|
||||||
|
typedef typename detail::get_value_traits< ValueType, typename packed_options::proto_value_traits>::type value_traits;
|
||||||
|
typedef typename value_traits::node_traits::node node;
|
||||||
|
|
||||||
|
typedef boost::intrusive::sg_multiset
|
||||||
|
< ValueType
|
||||||
|
, Option1
|
||||||
|
, Option2
|
||||||
|
, Option3
|
||||||
|
, header_holder_type< pointer_holder< node > >
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// container generator with void node allocator
|
||||||
|
template < bool Default_Holder >
|
||||||
|
struct GetContainerFixedAlpha_With_Holder
|
||||||
|
{
|
||||||
|
template< class ValueType
|
||||||
|
, class Option1 =void
|
||||||
|
, class Option2 =void
|
||||||
|
, class Option3 =void
|
||||||
|
>
|
||||||
|
struct GetContainerFixedAlpha
|
||||||
|
{
|
||||||
|
typedef boost::intrusive::sg_multiset
|
||||||
|
< ValueType
|
||||||
|
, Option1
|
||||||
|
, Option2
|
||||||
|
, Option3
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// container generator with standard (non-void) node allocator
|
||||||
|
template <>
|
||||||
|
struct GetContainerFixedAlpha_With_Holder< false >
|
||||||
|
{
|
||||||
|
template< class ValueType
|
||||||
|
, class Option1 =void
|
||||||
|
, class Option2 =void
|
||||||
|
, class Option3 =void
|
||||||
|
>
|
||||||
|
struct GetContainerFixedAlpha
|
||||||
|
{
|
||||||
|
// extract node type through options->value_traits->node_traits->node
|
||||||
|
typedef typename pack_options< sgtree_defaults, Option1, Option2, Option3 >::type packed_options;
|
||||||
|
typedef typename detail::get_value_traits< ValueType, typename packed_options::proto_value_traits>::type value_traits;
|
||||||
|
typedef typename value_traits::node_traits::node node;
|
||||||
|
|
||||||
|
typedef boost::intrusive::sg_multiset
|
||||||
|
< ValueType
|
||||||
|
, Option1
|
||||||
|
, Option2
|
||||||
|
, Option3
|
||||||
|
, boost::intrusive::floating_point<false>
|
||||||
|
, header_holder_type< pointer_holder< node > >
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<class VoidPointer, bool Default_Holder>
|
||||||
class test_main_template
|
class test_main_template
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -116,7 +211,7 @@ class test_main_template
|
|||||||
< value_type
|
< value_type
|
||||||
, typename hooks<VoidPointer>::base_hook_type
|
, typename hooks<VoidPointer>::base_hook_type
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||||
< value_type
|
< value_type
|
||||||
@@ -125,13 +220,13 @@ class test_main_template
|
|||||||
, &value_type::node_
|
, &value_type::node_
|
||||||
>
|
>
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
test::test_generic_multiset < typename detail::get_base_value_traits
|
test::test_generic_multiset < typename detail::get_base_value_traits
|
||||||
< value_type
|
< value_type
|
||||||
, typename hooks<VoidPointer>::base_hook_type
|
, typename hooks<VoidPointer>::base_hook_type
|
||||||
>::type
|
>::type
|
||||||
, GetContainerFixedAlpha
|
, GetContainerFixedAlpha_With_Holder< Default_Holder >::template GetContainerFixedAlpha
|
||||||
>::test_all();
|
>::test_all();
|
||||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||||
< value_type
|
< value_type
|
||||||
@@ -140,22 +235,73 @@ class test_main_template
|
|||||||
, &value_type::node_
|
, &value_type::node_
|
||||||
>
|
>
|
||||||
>::type
|
>::type
|
||||||
, GetContainerFixedAlpha
|
, GetContainerFixedAlpha_With_Holder< Default_Holder >::template GetContainerFixedAlpha
|
||||||
>::test_all();
|
>::test_all();
|
||||||
test::test_generic_multiset < nonhook_node_member_value_traits< value_type,
|
test::test_generic_multiset < nonhook_node_member_value_traits< value_type,
|
||||||
typename hooks<VoidPointer>::nonhook_node_member_type,
|
typename hooks<VoidPointer>::nonhook_node_member_type,
|
||||||
&value_type::nhn_member_,
|
&value_type::nhn_member_,
|
||||||
safe_link
|
safe_link
|
||||||
>,
|
>,
|
||||||
GetContainerFixedAlpha
|
GetContainerFixedAlpha_With_Holder< Default_Holder >::template GetContainerFixedAlpha
|
||||||
>::test_all();
|
>::test_all();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// container generator which ignores further parametrization, except for compare option
|
||||||
|
template < typename Value_Traits, bool Constant_Time_Size, typename Header_Holder >
|
||||||
|
struct Get_Preset_Container
|
||||||
|
{
|
||||||
|
template < class
|
||||||
|
, class Option1 = void
|
||||||
|
, class Option2 = void
|
||||||
|
, class Option3 = void
|
||||||
|
>
|
||||||
|
struct GetContainer
|
||||||
|
{
|
||||||
|
// ignore further paramatrization except for the compare option
|
||||||
|
// notably ignore the size option (use preset)
|
||||||
|
typedef typename pack_options< sgtree_defaults, Option1, Option2, Option3 >::type packed_options;
|
||||||
|
typedef typename packed_options::compare compare_option;
|
||||||
|
|
||||||
|
typedef boost::intrusive::sg_multiset< typename Value_Traits::value_type,
|
||||||
|
value_traits< Value_Traits >,
|
||||||
|
constant_time_size< Constant_Time_Size >,
|
||||||
|
compare< compare_option >,
|
||||||
|
header_holder_type< Header_Holder >
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
template < bool Constant_Time_Size >
|
||||||
|
struct test_main_template_bptr
|
||||||
|
{
|
||||||
|
void operator () ()
|
||||||
|
{
|
||||||
|
typedef BPtr_Value value_type;
|
||||||
|
typedef BPtr_Value_Traits< Tree_BPtr_Node_Traits > value_traits;
|
||||||
|
typedef Bounded_Allocator< value_type > allocator_type;
|
||||||
|
|
||||||
|
allocator_type::init();
|
||||||
|
test::test_generic_multiset< value_traits,
|
||||||
|
Get_Preset_Container< value_traits, Constant_Time_Size,
|
||||||
|
Bounded_Pointer_Holder< value_type > >::template GetContainer
|
||||||
|
>::test_all();
|
||||||
|
assert(allocator_type::is_clear());
|
||||||
|
allocator_type::destroy();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
int main( int, char* [] )
|
int main( int, char* [] )
|
||||||
{
|
{
|
||||||
test_main_template<void*>()();
|
// test (plain/smart pointers) x (const size) x (void node allocator)
|
||||||
test_main_template<boost::intrusive::smart_ptr<void> >()();
|
test_main_template<void*, true>()();
|
||||||
|
test_main_template<boost::intrusive::smart_ptr<void>, true >()();
|
||||||
|
// test (plain pointers) x (const size) x (standard node allocator)
|
||||||
|
test_main_template<void*, false>()();
|
||||||
|
// test (bounded pointers) x (nonconst/const size) x (special node allocator)
|
||||||
|
test_main_template_bptr< true >()();
|
||||||
|
test_main_template_bptr< false >()();
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@@ -12,19 +12,20 @@
|
|||||||
#include <boost/intrusive/detail/config_begin.hpp>
|
#include <boost/intrusive/detail/config_begin.hpp>
|
||||||
#include <boost/intrusive/sg_set.hpp>
|
#include <boost/intrusive/sg_set.hpp>
|
||||||
#include "itestvalue.hpp"
|
#include "itestvalue.hpp"
|
||||||
|
#include "bptr_value.hpp"
|
||||||
#include "smart_ptr.hpp"
|
#include "smart_ptr.hpp"
|
||||||
#include "generic_set_test.hpp"
|
#include "generic_set_test.hpp"
|
||||||
|
|
||||||
namespace boost { namespace intrusive { namespace test {
|
namespace boost { namespace intrusive { namespace test {
|
||||||
|
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
template<class T, class O1, class O2, class O3, class O4>
|
template<class T, class O1, class O2, class O3, class O4, class O5>
|
||||||
#else
|
#else
|
||||||
template<class T, class ...Options>
|
template<class T, class ...Options>
|
||||||
#endif
|
#endif
|
||||||
struct has_rebalance<boost::intrusive::sg_set<T,
|
struct has_rebalance<boost::intrusive::sg_set<T,
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
O1, O2, O3, O4
|
O1, O2, O3, O4, O5
|
||||||
#else
|
#else
|
||||||
Options...
|
Options...
|
||||||
#endif
|
#endif
|
||||||
@@ -34,13 +35,13 @@ struct has_rebalance<boost::intrusive::sg_set<T,
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
template<class T, class O1, class O2, class O3, class O4>
|
template<class T, class O1, class O2, class O3, class O4, class O5>
|
||||||
#else
|
#else
|
||||||
template<class T, class ...Options>
|
template<class T, class ...Options>
|
||||||
#endif
|
#endif
|
||||||
struct has_insert_before<boost::intrusive::sg_set<T,
|
struct has_insert_before<boost::intrusive::sg_set<T,
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
O1, O2, O3, O4
|
O1, O2, O3, O4, O5
|
||||||
#else
|
#else
|
||||||
Options...
|
Options...
|
||||||
#endif
|
#endif
|
||||||
@@ -101,7 +102,100 @@ struct GetContainerFixedAlpha
|
|||||||
> type;
|
> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class VoidPointer>
|
// container generator with void node allocator
|
||||||
|
template < bool Default_Holder >
|
||||||
|
struct GetContainer_With_Holder
|
||||||
|
{
|
||||||
|
template< class ValueType
|
||||||
|
, class Option1 =void
|
||||||
|
, class Option2 =void
|
||||||
|
, class Option3 =void
|
||||||
|
>
|
||||||
|
struct GetContainer
|
||||||
|
{
|
||||||
|
typedef boost::intrusive::sg_set
|
||||||
|
< ValueType
|
||||||
|
, Option1
|
||||||
|
, Option2
|
||||||
|
, Option3
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// container generator with standard (non-void) node allocator
|
||||||
|
template <>
|
||||||
|
struct GetContainer_With_Holder< false >
|
||||||
|
{
|
||||||
|
template< class ValueType
|
||||||
|
, class Option1 =void
|
||||||
|
, class Option2 =void
|
||||||
|
, class Option3 =void
|
||||||
|
>
|
||||||
|
struct GetContainer
|
||||||
|
{
|
||||||
|
// extract node type through options->value_traits->node_traits->node
|
||||||
|
typedef typename pack_options< sgtree_defaults, Option1, Option2, Option3 >::type packed_options;
|
||||||
|
typedef typename detail::get_value_traits< ValueType, typename packed_options::proto_value_traits>::type value_traits;
|
||||||
|
typedef typename value_traits::node_traits::node node;
|
||||||
|
|
||||||
|
typedef boost::intrusive::sg_set
|
||||||
|
< ValueType
|
||||||
|
, Option1
|
||||||
|
, Option2
|
||||||
|
, Option3
|
||||||
|
, header_holder_type< pointer_holder< node > >
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// container generator with void node allocator
|
||||||
|
template < bool Default_Holder >
|
||||||
|
struct GetContainerFixedAlpha_With_Holder
|
||||||
|
{
|
||||||
|
template< class ValueType
|
||||||
|
, class Option1 =void
|
||||||
|
, class Option2 =void
|
||||||
|
, class Option3 =void
|
||||||
|
>
|
||||||
|
struct GetContainerFixedAlpha
|
||||||
|
{
|
||||||
|
typedef boost::intrusive::sg_set
|
||||||
|
< ValueType
|
||||||
|
, Option1
|
||||||
|
, Option2
|
||||||
|
, Option3
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// container generator with standard (non-void) node allocator
|
||||||
|
template <>
|
||||||
|
struct GetContainerFixedAlpha_With_Holder< false >
|
||||||
|
{
|
||||||
|
template< class ValueType
|
||||||
|
, class Option1 =void
|
||||||
|
, class Option2 =void
|
||||||
|
, class Option3 =void
|
||||||
|
>
|
||||||
|
struct GetContainerFixedAlpha
|
||||||
|
{
|
||||||
|
// extract node type through options->value_traits->node_traits->node
|
||||||
|
typedef typename pack_options< sgtree_defaults, Option1, Option2, Option3 >::type packed_options;
|
||||||
|
typedef typename detail::get_value_traits< ValueType, typename packed_options::proto_value_traits>::type value_traits;
|
||||||
|
typedef typename value_traits::node_traits::node node;
|
||||||
|
|
||||||
|
typedef boost::intrusive::sg_set
|
||||||
|
< ValueType
|
||||||
|
, Option1
|
||||||
|
, Option2
|
||||||
|
, Option3
|
||||||
|
, boost::intrusive::floating_point<false>
|
||||||
|
, header_holder_type< pointer_holder< node > >
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class VoidPointer, bool Default_Holder>
|
||||||
class test_main_template
|
class test_main_template
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -114,7 +208,7 @@ class test_main_template
|
|||||||
< value_type
|
< value_type
|
||||||
, typename hooks<VoidPointer>::base_hook_type
|
, typename hooks<VoidPointer>::base_hook_type
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
test::test_generic_set < typename detail::get_member_value_traits
|
test::test_generic_set < typename detail::get_member_value_traits
|
||||||
< value_type
|
< value_type
|
||||||
@@ -123,14 +217,14 @@ class test_main_template
|
|||||||
, &value_type::node_
|
, &value_type::node_
|
||||||
>
|
>
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
|
|
||||||
test::test_generic_set < typename detail::get_base_value_traits
|
test::test_generic_set < typename detail::get_base_value_traits
|
||||||
< value_type
|
< value_type
|
||||||
, typename hooks<VoidPointer>::base_hook_type
|
, typename hooks<VoidPointer>::base_hook_type
|
||||||
>::type
|
>::type
|
||||||
, GetContainerFixedAlpha
|
, GetContainerFixedAlpha_With_Holder< Default_Holder >::template GetContainerFixedAlpha
|
||||||
>::test_all();
|
>::test_all();
|
||||||
test::test_generic_set < typename detail::get_member_value_traits
|
test::test_generic_set < typename detail::get_member_value_traits
|
||||||
< value_type
|
< value_type
|
||||||
@@ -139,23 +233,74 @@ class test_main_template
|
|||||||
, &value_type::node_
|
, &value_type::node_
|
||||||
>
|
>
|
||||||
>::type
|
>::type
|
||||||
, GetContainerFixedAlpha
|
, GetContainerFixedAlpha_With_Holder< Default_Holder >::template GetContainerFixedAlpha
|
||||||
>::test_all();
|
>::test_all();
|
||||||
test::test_generic_set < nonhook_node_member_value_traits< value_type,
|
test::test_generic_set < nonhook_node_member_value_traits< value_type,
|
||||||
typename hooks<VoidPointer>::nonhook_node_member_type,
|
typename hooks<VoidPointer>::nonhook_node_member_type,
|
||||||
&value_type::nhn_member_,
|
&value_type::nhn_member_,
|
||||||
safe_link
|
safe_link
|
||||||
>,
|
>,
|
||||||
GetContainerFixedAlpha
|
GetContainerFixedAlpha_With_Holder< Default_Holder >::template GetContainerFixedAlpha
|
||||||
>::test_all();
|
>::test_all();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// container generator which ignores further parametrization, except for compare option
|
||||||
|
template < typename Value_Traits, bool Constant_Time_Size, typename Header_Holder >
|
||||||
|
struct Get_Preset_Container
|
||||||
|
{
|
||||||
|
template < class
|
||||||
|
, class Option1 = void
|
||||||
|
, class Option2 = void
|
||||||
|
, class Option3 = void
|
||||||
|
>
|
||||||
|
struct GetContainer
|
||||||
|
{
|
||||||
|
// ignore further paramatrization except for the compare option
|
||||||
|
// notably ignore the size option (use preset)
|
||||||
|
typedef typename pack_options< sgtree_defaults, Option1, Option2, Option3 >::type packed_options;
|
||||||
|
typedef typename packed_options::compare compare_option;
|
||||||
|
|
||||||
|
typedef boost::intrusive::sg_set< typename Value_Traits::value_type,
|
||||||
|
value_traits< Value_Traits >,
|
||||||
|
constant_time_size< Constant_Time_Size >,
|
||||||
|
compare< compare_option >,
|
||||||
|
header_holder_type< Header_Holder >
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
template < bool Constant_Time_Size >
|
||||||
|
struct test_main_template_bptr
|
||||||
|
{
|
||||||
|
void operator () ()
|
||||||
|
{
|
||||||
|
typedef BPtr_Value value_type;
|
||||||
|
typedef BPtr_Value_Traits< Tree_BPtr_Node_Traits > value_traits;
|
||||||
|
typedef Bounded_Allocator< value_type > allocator_type;
|
||||||
|
|
||||||
|
allocator_type::init();
|
||||||
|
test::test_generic_set< value_traits,
|
||||||
|
Get_Preset_Container< value_traits, Constant_Time_Size,
|
||||||
|
Bounded_Pointer_Holder< value_type > >::template GetContainer
|
||||||
|
>::test_all();
|
||||||
|
assert(allocator_type::is_clear());
|
||||||
|
allocator_type::destroy();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
int main( int, char* [] )
|
int main( int, char* [] )
|
||||||
{
|
{
|
||||||
test_main_template<void*>()();
|
// test (plain/smart pointers) x (const size) x (void node allocator)
|
||||||
test_main_template<boost::intrusive::smart_ptr<void> >()();
|
test_main_template<void*, true>()();
|
||||||
|
test_main_template<boost::intrusive::smart_ptr<void>, true >()();
|
||||||
|
// test (plain pointers) x (const size) x (standard node allocator)
|
||||||
|
test_main_template<void*, false>()();
|
||||||
|
// test (bounded pointers) x (nonconst/const size) x (special node allocator)
|
||||||
|
test_main_template_bptr< true >()();
|
||||||
|
test_main_template_bptr< false >()();
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
#include <boost/intrusive/detail/config_end.hpp>
|
#include <boost/intrusive/detail/config_end.hpp>
|
||||||
|
@@ -50,26 +50,27 @@ struct test_slist
|
|||||||
typedef typename value_traits::value_type value_type;
|
typedef typename value_traits::value_type value_type;
|
||||||
typedef typename list_type::node_algorithms node_algorithms;
|
typedef typename list_type::node_algorithms node_algorithms;
|
||||||
|
|
||||||
static void test_all(Value_Container& values);
|
static void test_all(Value_Container&);
|
||||||
static void test_front(Value_Container& values);
|
static void test_front(Value_Container&);
|
||||||
static void test_back(Value_Container& values, detail::bool_<true>);
|
static void test_back(Value_Container&, detail::true_type);
|
||||||
static void test_back(Value_Container& values, detail::bool_<false>);
|
static void test_back(Value_Container&, detail::false_type) {}
|
||||||
static void test_sort(Value_Container& values);
|
static void test_sort(Value_Container&);
|
||||||
static void test_merge(Value_Container& values);
|
static void test_merge(Value_Container&);
|
||||||
static void test_remove_unique(Value_Container& values);
|
static void test_remove_unique(Value_Container&);
|
||||||
static void test_insert(Value_Container& values);
|
static void test_insert(Value_Container&);
|
||||||
static void test_shift(Value_Container& values);
|
static void test_shift(Value_Container&);
|
||||||
static void test_swap(Value_Container& values);
|
static void test_swap(Value_Container&);
|
||||||
static void test_slow_insert(Value_Container& values);
|
static void test_slow_insert(Value_Container&);
|
||||||
static void test_clone(Value_Container& values);
|
static void test_clone(Value_Container&);
|
||||||
static void test_container_from_end(Value_Container &, detail::bool_<true>){}
|
static void test_container_from_end(Value_Container&, detail::true_type);
|
||||||
static void test_container_from_end(Value_Container &values, detail::bool_<false>);
|
static void test_container_from_end(Value_Container&, detail::false_type) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template < typename List_Type, typename Value_Container >
|
template < typename List_Type, typename Value_Container >
|
||||||
void test_slist< List_Type, Value_Container >
|
void test_slist< List_Type, Value_Container >
|
||||||
::test_all (Value_Container& values)
|
::test_all (Value_Container& values)
|
||||||
{
|
{
|
||||||
|
#ifdef PRINT_TESTS
|
||||||
std::clog << "testing slist with:\n"
|
std::clog << "testing slist with:\n"
|
||||||
<< " value_type = " << typeid(value_type).name() << "\n"
|
<< " value_type = " << typeid(value_type).name() << "\n"
|
||||||
<< " sizeof(value_type) = " << sizeof(value_type) << "\n"
|
<< " sizeof(value_type) = " << sizeof(value_type) << "\n"
|
||||||
@@ -83,6 +84,7 @@ void test_slist< List_Type, Value_Container >
|
|||||||
<< " cache_last = " << list_type::cache_last << "\n"
|
<< " cache_last = " << list_type::cache_last << "\n"
|
||||||
<< " has_container_from_iterator = " << list_type::has_container_from_iterator << "\n"
|
<< " has_container_from_iterator = " << list_type::has_container_from_iterator << "\n"
|
||||||
<< " sizeof(list_type) = " << sizeof(list_type) << "\n";
|
<< " sizeof(list_type) = " << sizeof(list_type) << "\n";
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
list_type list(values.begin(), values.end());
|
list_type list(values.begin(), values.end());
|
||||||
test::test_container(list);
|
test::test_container(list);
|
||||||
@@ -91,7 +93,7 @@ void test_slist< List_Type, Value_Container >
|
|||||||
test::test_sequence_container(list, values);
|
test::test_sequence_container(list, values);
|
||||||
}
|
}
|
||||||
test_front(values);
|
test_front(values);
|
||||||
test_back(values, detail::bool_<list_type::cache_last>());
|
test_back(values, detail::bool_< list_type::cache_last >());
|
||||||
test_sort(values);
|
test_sort(values);
|
||||||
test_merge (values);
|
test_merge (values);
|
||||||
test_remove_unique(values);
|
test_remove_unique(values);
|
||||||
@@ -100,7 +102,7 @@ void test_slist< List_Type, Value_Container >
|
|||||||
test_slow_insert (values);
|
test_slow_insert (values);
|
||||||
test_swap(values);
|
test_swap(values);
|
||||||
test_clone(values);
|
test_clone(values);
|
||||||
test_container_from_end(values, detail::bool_<list_type::linear or not list_type::has_container_from_iterator>());
|
test_container_from_end(values, detail::bool_< not list_type::linear and list_type::has_container_from_iterator >());
|
||||||
}
|
}
|
||||||
|
|
||||||
//test: push_front, pop_front, front, size, empty:
|
//test: push_front, pop_front, front, size, empty:
|
||||||
@@ -130,7 +132,7 @@ void test_slist< List_Type, Value_Container >
|
|||||||
//test: push_front, pop_front, front, size, empty:
|
//test: push_front, pop_front, front, size, empty:
|
||||||
template < typename List_Type, typename Value_Container >
|
template < typename List_Type, typename Value_Container >
|
||||||
void test_slist< List_Type, Value_Container >
|
void test_slist< List_Type, Value_Container >
|
||||||
::test_back(Value_Container& values, detail::bool_<true>)
|
::test_back(Value_Container& values, detail::true_type)
|
||||||
{
|
{
|
||||||
list_type testlist;
|
list_type testlist;
|
||||||
BOOST_TEST (testlist.empty());
|
BOOST_TEST (testlist.empty());
|
||||||
@@ -145,13 +147,6 @@ void test_slist< List_Type, Value_Container >
|
|||||||
BOOST_TEST (&testlist.back() == &values[1]);
|
BOOST_TEST (&testlist.back() == &values[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//test: push_front, pop_front, front, size, empty:
|
|
||||||
template < typename List_Type, typename Value_Container >
|
|
||||||
void test_slist< List_Type, Value_Container >
|
|
||||||
::test_back(Value_Container&, detail::bool_<false>)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
//test: merge due to error in merge implementation:
|
//test: merge due to error in merge implementation:
|
||||||
template < typename List_Type, typename Value_Container >
|
template < typename List_Type, typename Value_Container >
|
||||||
void test_slist< List_Type, Value_Container >
|
void test_slist< List_Type, Value_Container >
|
||||||
@@ -440,10 +435,8 @@ void test_slist< List_Type, Value_Container >
|
|||||||
|
|
||||||
template < typename List_Type, typename Value_Container >
|
template < typename List_Type, typename Value_Container >
|
||||||
void test_slist< List_Type, Value_Container >
|
void test_slist< List_Type, Value_Container >
|
||||||
::test_container_from_end(Value_Container& values
|
::test_container_from_end(Value_Container& values, detail::true_type)
|
||||||
,detail::bool_<false>)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
list_type testlist1 (values.begin(), values.begin() + values.size());
|
list_type testlist1 (values.begin(), values.begin() + values.size());
|
||||||
BOOST_TEST (testlist1 == list_type::container_from_end_iterator(testlist1.end()));
|
BOOST_TEST (testlist1 == list_type::container_from_end_iterator(testlist1.end()));
|
||||||
BOOST_TEST (testlist1 == list_type::container_from_end_iterator(testlist1.cend()));
|
BOOST_TEST (testlist1 == list_type::container_from_end_iterator(testlist1.cend()));
|
||||||
@@ -782,18 +775,19 @@ struct test_main_template_bptr
|
|||||||
|
|
||||||
int main(int, char* [])
|
int main(int, char* [])
|
||||||
{
|
{
|
||||||
// test combinations of (regular/smart)_ptr x (const/nonconst)_size x (default/non-default)_header_holder
|
// test (plain/smart pointers) x (nonconst/const size) x (void node allocator)
|
||||||
// skip smart_ptr with non-default header_holder
|
|
||||||
test_main_template<void*, false, true>()();
|
test_main_template<void*, false, true>()();
|
||||||
test_main_template<smart_ptr<void>, false, true>()();
|
test_main_template<boost::intrusive::smart_ptr<void>, false, true>()();
|
||||||
test_main_template<void*, true, true>()();
|
test_main_template<void*, true, true>()();
|
||||||
test_main_template<smart_ptr<void>, true, true>()();
|
test_main_template<boost::intrusive::smart_ptr<void>, true, true>()();
|
||||||
|
// test (plain pointers) x (nonconst/const size) x (standard node allocator)
|
||||||
test_main_template<void*, false, false>()();
|
test_main_template<void*, false, false>()();
|
||||||
test_main_template<void*, true, false>()();
|
test_main_template<void*, true, false>()();
|
||||||
// test bounded pointers with const/non_const size (always with non-default header_holder)
|
// test (bounded pointers) x ((nonconst/const size) x (special node allocator)
|
||||||
test_main_template_bptr< true >()();
|
test_main_template_bptr< true >()();
|
||||||
test_main_template_bptr< false >()();
|
test_main_template_bptr< false >()();
|
||||||
|
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
#include <boost/intrusive/detail/config_end.hpp>
|
#include <boost/intrusive/detail/config_end.hpp>
|
||||||
|
@@ -14,19 +14,20 @@
|
|||||||
#include <boost/intrusive/splay_set.hpp>
|
#include <boost/intrusive/splay_set.hpp>
|
||||||
#include <boost/intrusive/pointer_traits.hpp>
|
#include <boost/intrusive/pointer_traits.hpp>
|
||||||
#include "itestvalue.hpp"
|
#include "itestvalue.hpp"
|
||||||
|
#include "bptr_value.hpp"
|
||||||
#include "smart_ptr.hpp"
|
#include "smart_ptr.hpp"
|
||||||
#include "generic_multiset_test.hpp"
|
#include "generic_multiset_test.hpp"
|
||||||
|
|
||||||
namespace boost { namespace intrusive { namespace test {
|
namespace boost { namespace intrusive { namespace test {
|
||||||
|
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
template<class T, class O1, class O2, class O3, class O4>
|
template<class T, class O1, class O2, class O3, class O4, class O5>
|
||||||
#else
|
#else
|
||||||
template<class T, class ...Options>
|
template<class T, class ...Options>
|
||||||
#endif
|
#endif
|
||||||
struct has_splay<boost::intrusive::splay_multiset<T,
|
struct has_splay<boost::intrusive::splay_multiset<T,
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
O1, O2, O3, O4
|
O1, O2, O3, O4, O5
|
||||||
#else
|
#else
|
||||||
Options...
|
Options...
|
||||||
#endif
|
#endif
|
||||||
@@ -36,13 +37,13 @@ struct has_splay<boost::intrusive::splay_multiset<T,
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
template<class T, class O1, class O2, class O3, class O4>
|
template<class T, class O1, class O2, class O3, class O4, class O5>
|
||||||
#else
|
#else
|
||||||
template<class T, class ...Options>
|
template<class T, class ...Options>
|
||||||
#endif
|
#endif
|
||||||
struct has_rebalance<boost::intrusive::splay_multiset<T,
|
struct has_rebalance<boost::intrusive::splay_multiset<T,
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
O1, O2, O3, O4
|
O1, O2, O3, O4, O5
|
||||||
#else
|
#else
|
||||||
Options...
|
Options...
|
||||||
#endif
|
#endif
|
||||||
@@ -52,13 +53,13 @@ struct has_rebalance<boost::intrusive::splay_multiset<T,
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
template<class T, class O1, class O2, class O3, class O4>
|
template<class T, class O1, class O2, class O3, class O4, class O5>
|
||||||
#else
|
#else
|
||||||
template<class T, class ...Options>
|
template<class T, class ...Options>
|
||||||
#endif
|
#endif
|
||||||
struct has_const_searches<boost::intrusive::splay_multiset<T,
|
struct has_const_searches<boost::intrusive::splay_multiset<T,
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
O1, O2, O3, O4
|
O1, O2, O3, O4, O5
|
||||||
#else
|
#else
|
||||||
Options...
|
Options...
|
||||||
#endif
|
#endif
|
||||||
@@ -91,6 +92,10 @@ struct hooks
|
|||||||
> nonhook_node_member_type;
|
> nonhook_node_member_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// container generator with void node allocator
|
||||||
|
template < bool Default_Holder >
|
||||||
|
struct GetContainer_With_Holder
|
||||||
|
{
|
||||||
template< class ValueType
|
template< class ValueType
|
||||||
, class Option1 =void
|
, class Option1 =void
|
||||||
, class Option2 =void
|
, class Option2 =void
|
||||||
@@ -105,8 +110,35 @@ struct GetContainer
|
|||||||
, Option3
|
, Option3
|
||||||
> type;
|
> type;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
template<class VoidPointer, bool constant_time_size>
|
// container generator with standard (non-void) node allocator
|
||||||
|
template <>
|
||||||
|
struct GetContainer_With_Holder< false >
|
||||||
|
{
|
||||||
|
template< class ValueType
|
||||||
|
, class Option1 =void
|
||||||
|
, class Option2 =void
|
||||||
|
, class Option3 =void
|
||||||
|
>
|
||||||
|
struct GetContainer
|
||||||
|
{
|
||||||
|
// extract node type through options->value_traits->node_traits->node
|
||||||
|
typedef typename pack_options< splaytree_defaults, Option1, Option2, Option3 >::type packed_options;
|
||||||
|
typedef typename detail::get_value_traits< ValueType, typename packed_options::proto_value_traits>::type value_traits;
|
||||||
|
typedef typename value_traits::node_traits::node node;
|
||||||
|
|
||||||
|
typedef boost::intrusive::splay_multiset
|
||||||
|
< ValueType
|
||||||
|
, Option1
|
||||||
|
, Option2
|
||||||
|
, Option3
|
||||||
|
, header_holder_type< pointer_holder< node > >
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class VoidPointer, bool constant_time_size, bool Default_Holder>
|
||||||
class test_main_template
|
class test_main_template
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -119,7 +151,7 @@ class test_main_template
|
|||||||
< value_type
|
< value_type
|
||||||
, typename hooks<VoidPointer>::base_hook_type
|
, typename hooks<VoidPointer>::base_hook_type
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||||
< value_type
|
< value_type
|
||||||
@@ -128,22 +160,22 @@ class test_main_template
|
|||||||
, &value_type::node_
|
, &value_type::node_
|
||||||
>
|
>
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
test::test_generic_multiset < nonhook_node_member_value_traits< value_type,
|
test::test_generic_multiset < nonhook_node_member_value_traits< value_type,
|
||||||
typename hooks<VoidPointer>::nonhook_node_member_type,
|
typename hooks<VoidPointer>::nonhook_node_member_type,
|
||||||
&value_type::nhn_member_,
|
&value_type::nhn_member_,
|
||||||
safe_link
|
safe_link
|
||||||
>,
|
>,
|
||||||
GetContainer
|
GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class VoidPointer>
|
template<class VoidPointer, bool Default_Holder>
|
||||||
class test_main_template<VoidPointer, false>
|
class test_main_template<VoidPointer, false, Default_Holder>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int operator()()
|
int operator()()
|
||||||
@@ -155,7 +187,7 @@ class test_main_template<VoidPointer, false>
|
|||||||
< value_type
|
< value_type
|
||||||
, typename hooks<VoidPointer>::base_hook_type
|
, typename hooks<VoidPointer>::base_hook_type
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
|
|
||||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||||
@@ -165,14 +197,14 @@ class test_main_template<VoidPointer, false>
|
|||||||
, &value_type::node_
|
, &value_type::node_
|
||||||
>
|
>
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
|
|
||||||
test::test_generic_multiset < typename detail::get_base_value_traits
|
test::test_generic_multiset < typename detail::get_base_value_traits
|
||||||
< value_type
|
< value_type
|
||||||
, typename hooks<VoidPointer>::auto_base_hook_type
|
, typename hooks<VoidPointer>::auto_base_hook_type
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
|
|
||||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||||
@@ -182,17 +214,69 @@ class test_main_template<VoidPointer, false>
|
|||||||
, &value_type::auto_node_
|
, &value_type::auto_node_
|
||||||
>
|
>
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// container generator which ignores further parametrization, except for compare option
|
||||||
|
template < typename Value_Traits, bool Constant_Time_Size, typename Header_Holder >
|
||||||
|
struct Get_Preset_Container
|
||||||
|
{
|
||||||
|
template < class
|
||||||
|
, class Option1 = void
|
||||||
|
, class Option2 = void
|
||||||
|
, class Option3 = void
|
||||||
|
>
|
||||||
|
struct GetContainer
|
||||||
|
{
|
||||||
|
// ignore further paramatrization except for the compare option
|
||||||
|
// notably ignore the size option (use preset)
|
||||||
|
typedef typename pack_options< splaytree_defaults, Option1, Option2, Option3 >::type packed_options;
|
||||||
|
typedef typename packed_options::compare compare_option;
|
||||||
|
|
||||||
|
typedef boost::intrusive::splay_multiset< typename Value_Traits::value_type,
|
||||||
|
value_traits< Value_Traits >,
|
||||||
|
constant_time_size< Constant_Time_Size >,
|
||||||
|
compare< compare_option >,
|
||||||
|
header_holder_type< Header_Holder >
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
template < bool Constant_Time_Size >
|
||||||
|
struct test_main_template_bptr
|
||||||
|
{
|
||||||
|
void operator () ()
|
||||||
|
{
|
||||||
|
typedef BPtr_Value value_type;
|
||||||
|
typedef BPtr_Value_Traits< Tree_BPtr_Node_Traits > value_traits;
|
||||||
|
typedef Bounded_Allocator< value_type > allocator_type;
|
||||||
|
|
||||||
|
allocator_type::init();
|
||||||
|
test::test_generic_multiset< value_traits,
|
||||||
|
Get_Preset_Container< value_traits, Constant_Time_Size,
|
||||||
|
Bounded_Pointer_Holder< value_type > >::template GetContainer
|
||||||
|
>::test_all();
|
||||||
|
assert(allocator_type::is_clear());
|
||||||
|
allocator_type::destroy();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
int main( int, char* [] )
|
int main( int, char* [] )
|
||||||
{
|
{
|
||||||
test_main_template<void*, false>()();
|
// test (plain/smart pointers) x (nonconst/const size) x (void node allocator)
|
||||||
test_main_template<boost::intrusive::smart_ptr<void>, false>()();
|
test_main_template<void*, false, true>()();
|
||||||
test_main_template<void*, true>()();
|
test_main_template<boost::intrusive::smart_ptr<void>, false, true>()();
|
||||||
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
|
test_main_template<void*, true, true>()();
|
||||||
|
test_main_template<boost::intrusive::smart_ptr<void>, true, true>()();
|
||||||
|
// test (plain pointers) x (nonconst/const size) x (standard node allocator)
|
||||||
|
test_main_template<void*, false, false>()();
|
||||||
|
test_main_template<void*, true, false>()();
|
||||||
|
// test (bounded pointers) x (nonconst/const size) x (special node allocator)
|
||||||
|
test_main_template_bptr< true >()();
|
||||||
|
test_main_template_bptr< false >()();
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@@ -12,19 +12,20 @@
|
|||||||
#include <boost/intrusive/detail/config_begin.hpp>
|
#include <boost/intrusive/detail/config_begin.hpp>
|
||||||
#include <boost/intrusive/splay_set.hpp>
|
#include <boost/intrusive/splay_set.hpp>
|
||||||
#include "itestvalue.hpp"
|
#include "itestvalue.hpp"
|
||||||
|
#include "bptr_value.hpp"
|
||||||
#include "smart_ptr.hpp"
|
#include "smart_ptr.hpp"
|
||||||
#include "generic_set_test.hpp"
|
#include "generic_set_test.hpp"
|
||||||
|
|
||||||
namespace boost { namespace intrusive { namespace test {
|
namespace boost { namespace intrusive { namespace test {
|
||||||
|
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
template<class T, class O1, class O2, class O3, class O4>
|
template<class T, class O1, class O2, class O3, class O4, class O5>
|
||||||
#else
|
#else
|
||||||
template<class T, class ...Options>
|
template<class T, class ...Options>
|
||||||
#endif
|
#endif
|
||||||
struct has_splay<boost::intrusive::splay_set<T,
|
struct has_splay<boost::intrusive::splay_set<T,
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
O1, O2, O3, O4
|
O1, O2, O3, O4, O5
|
||||||
#else
|
#else
|
||||||
Options...
|
Options...
|
||||||
#endif
|
#endif
|
||||||
@@ -34,13 +35,13 @@ struct has_splay<boost::intrusive::splay_set<T,
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
template<class T, class O1, class O2, class O3, class O4>
|
template<class T, class O1, class O2, class O3, class O4, class O5>
|
||||||
#else
|
#else
|
||||||
template<class T, class ...Options>
|
template<class T, class ...Options>
|
||||||
#endif
|
#endif
|
||||||
struct has_rebalance<boost::intrusive::splay_set<T,
|
struct has_rebalance<boost::intrusive::splay_set<T,
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
O1, O2, O3, O4
|
O1, O2, O3, O4, O5
|
||||||
#else
|
#else
|
||||||
Options...
|
Options...
|
||||||
#endif
|
#endif
|
||||||
@@ -50,13 +51,13 @@ struct has_rebalance<boost::intrusive::splay_set<T,
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
template<class T, class O1, class O2, class O3, class O4>
|
template<class T, class O1, class O2, class O3, class O4, class O5>
|
||||||
#else
|
#else
|
||||||
template<class T, class ...Options>
|
template<class T, class ...Options>
|
||||||
#endif
|
#endif
|
||||||
struct has_const_searches<boost::intrusive::splay_set<T,
|
struct has_const_searches<boost::intrusive::splay_set<T,
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
O1, O2, O3, O4
|
O1, O2, O3, O4, O5
|
||||||
#else
|
#else
|
||||||
Options...
|
Options...
|
||||||
#endif
|
#endif
|
||||||
@@ -88,6 +89,10 @@ struct hooks
|
|||||||
> nonhook_node_member_type;
|
> nonhook_node_member_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// container generator with void node allocator
|
||||||
|
template < bool Default_Holder >
|
||||||
|
struct GetContainer_With_Holder
|
||||||
|
{
|
||||||
template< class ValueType
|
template< class ValueType
|
||||||
, class Option1 =void
|
, class Option1 =void
|
||||||
, class Option2 =void
|
, class Option2 =void
|
||||||
@@ -102,8 +107,35 @@ struct GetContainer
|
|||||||
, Option3
|
, Option3
|
||||||
> type;
|
> type;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
template<class VoidPointer, bool constant_time_size>
|
// container generator with standard (non-void) node allocator
|
||||||
|
template <>
|
||||||
|
struct GetContainer_With_Holder< false >
|
||||||
|
{
|
||||||
|
template< class ValueType
|
||||||
|
, class Option1 =void
|
||||||
|
, class Option2 =void
|
||||||
|
, class Option3 =void
|
||||||
|
>
|
||||||
|
struct GetContainer
|
||||||
|
{
|
||||||
|
// extract node type through options->value_traits->node_traits->node
|
||||||
|
typedef typename pack_options< splaytree_defaults, Option1, Option2, Option3 >::type packed_options;
|
||||||
|
typedef typename detail::get_value_traits< ValueType, typename packed_options::proto_value_traits>::type value_traits;
|
||||||
|
typedef typename value_traits::node_traits::node node;
|
||||||
|
|
||||||
|
typedef boost::intrusive::splay_set
|
||||||
|
< ValueType
|
||||||
|
, Option1
|
||||||
|
, Option2
|
||||||
|
, Option3
|
||||||
|
, header_holder_type< pointer_holder< node > >
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class VoidPointer, bool constant_time_size, bool Default_Holder>
|
||||||
class test_main_template
|
class test_main_template
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -116,7 +148,7 @@ class test_main_template
|
|||||||
< value_type
|
< value_type
|
||||||
, typename hooks<VoidPointer>::base_hook_type
|
, typename hooks<VoidPointer>::base_hook_type
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
test::test_generic_set < typename detail::get_member_value_traits
|
test::test_generic_set < typename detail::get_member_value_traits
|
||||||
< value_type
|
< value_type
|
||||||
@@ -125,21 +157,21 @@ class test_main_template
|
|||||||
, &value_type::node_
|
, &value_type::node_
|
||||||
>
|
>
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
test::test_generic_set < nonhook_node_member_value_traits< value_type,
|
test::test_generic_set < nonhook_node_member_value_traits< value_type,
|
||||||
typename hooks<VoidPointer>::nonhook_node_member_type,
|
typename hooks<VoidPointer>::nonhook_node_member_type,
|
||||||
&value_type::nhn_member_,
|
&value_type::nhn_member_,
|
||||||
safe_link
|
safe_link
|
||||||
>,
|
>,
|
||||||
GetContainer
|
GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class VoidPointer>
|
template<class VoidPointer, bool Default_Holder>
|
||||||
class test_main_template<VoidPointer, false>
|
class test_main_template<VoidPointer, false, Default_Holder>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int operator()()
|
int operator()()
|
||||||
@@ -151,7 +183,7 @@ class test_main_template<VoidPointer, false>
|
|||||||
< value_type
|
< value_type
|
||||||
, typename hooks<VoidPointer>::base_hook_type
|
, typename hooks<VoidPointer>::base_hook_type
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
|
|
||||||
test::test_generic_set < typename detail::get_member_value_traits
|
test::test_generic_set < typename detail::get_member_value_traits
|
||||||
@@ -161,14 +193,14 @@ class test_main_template<VoidPointer, false>
|
|||||||
, &value_type::node_
|
, &value_type::node_
|
||||||
>
|
>
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
|
|
||||||
test::test_generic_set < typename detail::get_base_value_traits
|
test::test_generic_set < typename detail::get_base_value_traits
|
||||||
< value_type
|
< value_type
|
||||||
, typename hooks<VoidPointer>::auto_base_hook_type
|
, typename hooks<VoidPointer>::auto_base_hook_type
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
|
|
||||||
test::test_generic_set < typename detail::get_member_value_traits
|
test::test_generic_set < typename detail::get_member_value_traits
|
||||||
@@ -178,19 +210,71 @@ class test_main_template<VoidPointer, false>
|
|||||||
, &value_type::auto_node_
|
, &value_type::auto_node_
|
||||||
>
|
>
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// container generator which ignores further parametrization, except for compare option
|
||||||
|
template < typename Value_Traits, bool Constant_Time_Size, typename Header_Holder >
|
||||||
|
struct Get_Preset_Container
|
||||||
|
{
|
||||||
|
template < class
|
||||||
|
, class Option1 = void
|
||||||
|
, class Option2 = void
|
||||||
|
, class Option3 = void
|
||||||
|
>
|
||||||
|
struct GetContainer
|
||||||
|
{
|
||||||
|
// ignore further paramatrization except for the compare option
|
||||||
|
// notably ignore the size option (use preset)
|
||||||
|
typedef typename pack_options< splaytree_defaults, Option1, Option2, Option3 >::type packed_options;
|
||||||
|
typedef typename packed_options::compare compare_option;
|
||||||
|
|
||||||
|
typedef boost::intrusive::splay_set< typename Value_Traits::value_type,
|
||||||
|
value_traits< Value_Traits >,
|
||||||
|
constant_time_size< Constant_Time_Size >,
|
||||||
|
compare< compare_option >,
|
||||||
|
header_holder_type< Header_Holder >
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
template < bool Constant_Time_Size >
|
||||||
|
struct test_main_template_bptr
|
||||||
|
{
|
||||||
|
void operator () ()
|
||||||
|
{
|
||||||
|
typedef BPtr_Value value_type;
|
||||||
|
typedef BPtr_Value_Traits< Tree_BPtr_Node_Traits > value_traits;
|
||||||
|
typedef Bounded_Allocator< value_type > allocator_type;
|
||||||
|
|
||||||
|
allocator_type::init();
|
||||||
|
test::test_generic_set< value_traits,
|
||||||
|
Get_Preset_Container< value_traits, Constant_Time_Size,
|
||||||
|
Bounded_Pointer_Holder< value_type > >::template GetContainer
|
||||||
|
>::test_all();
|
||||||
|
assert(allocator_type::is_clear());
|
||||||
|
allocator_type::destroy();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
int main( int, char* [] )
|
int main( int, char* [] )
|
||||||
{
|
{
|
||||||
test_main_template<void*, false>()();
|
// test (plain/smart pointers) x (nonconst/const size) x (void node allocator)
|
||||||
test_main_template<boost::intrusive::smart_ptr<void>, false>()();
|
test_main_template<void*, false, true>()();
|
||||||
test_main_template<void*, true>()();
|
test_main_template<boost::intrusive::smart_ptr<void>, false, true>()();
|
||||||
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
|
test_main_template<void*, true, true>()();
|
||||||
|
test_main_template<boost::intrusive::smart_ptr<void>, true, true>()();
|
||||||
|
// test (plain pointers) x (nonconst/const size) x (standard node allocator)
|
||||||
|
test_main_template<void*, false, false>()();
|
||||||
|
test_main_template<void*, true, false>()();
|
||||||
|
// test (bounded pointers) x (nonconst/const size) x (special node allocator)
|
||||||
|
test_main_template_bptr< true >()();
|
||||||
|
test_main_template_bptr< false >()();
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
#include <boost/intrusive/detail/config_end.hpp>
|
#include <boost/intrusive/detail/config_end.hpp>
|
||||||
|
@@ -14,19 +14,20 @@
|
|||||||
#include <boost/intrusive/detail/config_begin.hpp>
|
#include <boost/intrusive/detail/config_begin.hpp>
|
||||||
#include <boost/intrusive/treap_set.hpp>
|
#include <boost/intrusive/treap_set.hpp>
|
||||||
#include "itestvalue.hpp"
|
#include "itestvalue.hpp"
|
||||||
|
#include "bptr_value.hpp"
|
||||||
#include "smart_ptr.hpp"
|
#include "smart_ptr.hpp"
|
||||||
#include "generic_multiset_test.hpp"
|
#include "generic_multiset_test.hpp"
|
||||||
|
|
||||||
namespace boost { namespace intrusive { namespace test {
|
namespace boost { namespace intrusive { namespace test {
|
||||||
|
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
template<class T, class O1, class O2, class O3, class O4>
|
template<class T, class O1, class O2, class O3, class O4, class O5>
|
||||||
#else
|
#else
|
||||||
template<class T, class ...Options>
|
template<class T, class ...Options>
|
||||||
#endif
|
#endif
|
||||||
struct has_insert_before<boost::intrusive::treap_multiset<T,
|
struct has_insert_before<boost::intrusive::treap_multiset<T,
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
O1, O2, O3, O4
|
O1, O2, O3, O4, O5
|
||||||
#else
|
#else
|
||||||
Options...
|
Options...
|
||||||
#endif
|
#endif
|
||||||
@@ -57,6 +58,10 @@ struct hooks
|
|||||||
> nonhook_node_member_type;
|
> nonhook_node_member_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// container generator with void node allocator
|
||||||
|
template < bool Default_Holder >
|
||||||
|
struct GetContainer_With_Holder
|
||||||
|
{
|
||||||
template< class ValueType
|
template< class ValueType
|
||||||
, class Option1 =void
|
, class Option1 =void
|
||||||
, class Option2 =void
|
, class Option2 =void
|
||||||
@@ -71,8 +76,35 @@ struct GetContainer
|
|||||||
, Option3
|
, Option3
|
||||||
> type;
|
> type;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
template<class VoidPointer, bool constant_time_size>
|
// container generator with standard (non-void) node allocator
|
||||||
|
template <>
|
||||||
|
struct GetContainer_With_Holder< false >
|
||||||
|
{
|
||||||
|
template< class ValueType
|
||||||
|
, class Option1 =void
|
||||||
|
, class Option2 =void
|
||||||
|
, class Option3 =void
|
||||||
|
>
|
||||||
|
struct GetContainer
|
||||||
|
{
|
||||||
|
// extract node type through options->value_traits->node_traits->node
|
||||||
|
typedef typename pack_options< treap_defaults, Option1, Option2, Option3 >::type packed_options;
|
||||||
|
typedef typename detail::get_value_traits< ValueType, typename packed_options::proto_value_traits>::type value_traits;
|
||||||
|
typedef typename value_traits::node_traits::node node;
|
||||||
|
|
||||||
|
typedef boost::intrusive::treap_multiset
|
||||||
|
< ValueType
|
||||||
|
, Option1
|
||||||
|
, Option2
|
||||||
|
, Option3
|
||||||
|
, header_holder_type< pointer_holder< node > >
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class VoidPointer, bool constant_time_size, bool Default_Holder>
|
||||||
class test_main_template
|
class test_main_template
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -85,7 +117,7 @@ class test_main_template
|
|||||||
< value_type
|
< value_type
|
||||||
, typename hooks<VoidPointer>::base_hook_type
|
, typename hooks<VoidPointer>::base_hook_type
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||||
< value_type
|
< value_type
|
||||||
@@ -94,21 +126,21 @@ class test_main_template
|
|||||||
, &value_type::node_
|
, &value_type::node_
|
||||||
>
|
>
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
test::test_generic_multiset < nonhook_node_member_value_traits< value_type,
|
test::test_generic_multiset < nonhook_node_member_value_traits< value_type,
|
||||||
typename hooks<VoidPointer>::nonhook_node_member_type,
|
typename hooks<VoidPointer>::nonhook_node_member_type,
|
||||||
&value_type::nhn_member_,
|
&value_type::nhn_member_,
|
||||||
safe_link
|
safe_link
|
||||||
>,
|
>,
|
||||||
GetContainer
|
GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class VoidPointer>
|
template<class VoidPointer, bool Default_Holder>
|
||||||
class test_main_template<VoidPointer, false>
|
class test_main_template<VoidPointer, false, Default_Holder>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int operator()()
|
int operator()()
|
||||||
@@ -120,7 +152,7 @@ class test_main_template<VoidPointer, false>
|
|||||||
< value_type
|
< value_type
|
||||||
, typename hooks<VoidPointer>::base_hook_type
|
, typename hooks<VoidPointer>::base_hook_type
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
|
|
||||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||||
@@ -130,14 +162,14 @@ class test_main_template<VoidPointer, false>
|
|||||||
, &value_type::node_
|
, &value_type::node_
|
||||||
>
|
>
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
|
|
||||||
test::test_generic_multiset < typename detail::get_base_value_traits
|
test::test_generic_multiset < typename detail::get_base_value_traits
|
||||||
< value_type
|
< value_type
|
||||||
, typename hooks<VoidPointer>::auto_base_hook_type
|
, typename hooks<VoidPointer>::auto_base_hook_type
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
|
|
||||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||||
@@ -147,18 +179,70 @@ class test_main_template<VoidPointer, false>
|
|||||||
, &value_type::auto_node_
|
, &value_type::auto_node_
|
||||||
>
|
>
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// container generator which ignores further parametrization, except for compare option
|
||||||
|
template < typename Value_Traits, bool Constant_Time_Size, typename Header_Holder >
|
||||||
|
struct Get_Preset_Container
|
||||||
|
{
|
||||||
|
template < class
|
||||||
|
, class Option1 = void
|
||||||
|
, class Option2 = void
|
||||||
|
, class Option3 = void
|
||||||
|
>
|
||||||
|
struct GetContainer
|
||||||
|
{
|
||||||
|
// ignore further paramatrization except for the compare option
|
||||||
|
// notably ignore the size option (use preset)
|
||||||
|
typedef typename pack_options< treap_defaults, Option1, Option2, Option3 >::type packed_options;
|
||||||
|
typedef typename packed_options::compare compare_option;
|
||||||
|
|
||||||
|
typedef boost::intrusive::treap_multiset< typename Value_Traits::value_type,
|
||||||
|
value_traits< Value_Traits >,
|
||||||
|
constant_time_size< Constant_Time_Size >,
|
||||||
|
compare< compare_option >,
|
||||||
|
header_holder_type< Header_Holder >
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
template < bool Constant_Time_Size >
|
||||||
|
struct test_main_template_bptr
|
||||||
|
{
|
||||||
|
void operator () ()
|
||||||
|
{
|
||||||
|
typedef BPtr_Value value_type;
|
||||||
|
typedef BPtr_Value_Traits< Tree_BPtr_Node_Traits > value_traits;
|
||||||
|
typedef Bounded_Allocator< value_type > allocator_type;
|
||||||
|
|
||||||
|
allocator_type::init();
|
||||||
|
test::test_generic_multiset< value_traits,
|
||||||
|
Get_Preset_Container< value_traits, Constant_Time_Size,
|
||||||
|
Bounded_Pointer_Holder< value_type > >::template GetContainer
|
||||||
|
>::test_all();
|
||||||
|
assert(allocator_type::is_clear());
|
||||||
|
allocator_type::destroy();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
int main( int, char* [] )
|
int main( int, char* [] )
|
||||||
{
|
{
|
||||||
test_main_template<void*, false>()();
|
// test (plain/smart pointers) x (nonconst/const size) x (void node allocator)
|
||||||
test_main_template<boost::intrusive::smart_ptr<void>, false>()();
|
test_main_template<void*, false, true>()();
|
||||||
test_main_template<void*, true>()();
|
test_main_template<boost::intrusive::smart_ptr<void>, false, true>()();
|
||||||
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
|
test_main_template<void*, true, true>()();
|
||||||
|
test_main_template<boost::intrusive::smart_ptr<void>, true, true>()();
|
||||||
|
// test (plain pointers) x (nonconst/const size) x (standard node allocator)
|
||||||
|
test_main_template<void*, false, false>()();
|
||||||
|
test_main_template<void*, true, false>()();
|
||||||
|
// test (bounded pointers) x (nonconst/const size) x (special node allocator)
|
||||||
|
test_main_template_bptr< true >()();
|
||||||
|
test_main_template_bptr< false >()();
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,19 +12,20 @@
|
|||||||
#include <boost/intrusive/detail/config_begin.hpp>
|
#include <boost/intrusive/detail/config_begin.hpp>
|
||||||
#include <boost/intrusive/treap_set.hpp>
|
#include <boost/intrusive/treap_set.hpp>
|
||||||
#include "itestvalue.hpp"
|
#include "itestvalue.hpp"
|
||||||
|
#include "bptr_value.hpp"
|
||||||
#include "smart_ptr.hpp"
|
#include "smart_ptr.hpp"
|
||||||
#include "generic_set_test.hpp"
|
#include "generic_set_test.hpp"
|
||||||
|
|
||||||
namespace boost { namespace intrusive { namespace test {
|
namespace boost { namespace intrusive { namespace test {
|
||||||
|
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
template<class T, class O1, class O2, class O3, class O4>
|
template<class T, class O1, class O2, class O3, class O4, class O5>
|
||||||
#else
|
#else
|
||||||
template<class T, class ...Options>
|
template<class T, class ...Options>
|
||||||
#endif
|
#endif
|
||||||
struct has_insert_before<boost::intrusive::treap_set<T,
|
struct has_insert_before<boost::intrusive::treap_set<T,
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
O1, O2, O3, O4
|
O1, O2, O3, O4, O5
|
||||||
#else
|
#else
|
||||||
Options...
|
Options...
|
||||||
#endif
|
#endif
|
||||||
@@ -34,13 +35,13 @@ struct has_insert_before<boost::intrusive::treap_set<T,
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
template<class T, class O1, class O2, class O3, class O4>
|
template<class T, class O1, class O2, class O3, class O4, class O5>
|
||||||
#else
|
#else
|
||||||
template<class T, class ...Options>
|
template<class T, class ...Options>
|
||||||
#endif
|
#endif
|
||||||
struct is_treap<boost::intrusive::treap_set<T,
|
struct is_treap<boost::intrusive::treap_set<T,
|
||||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
O1, O2, O3, O4
|
O1, O2, O3, O4, O5
|
||||||
#else
|
#else
|
||||||
Options...
|
Options...
|
||||||
#endif
|
#endif
|
||||||
@@ -72,6 +73,10 @@ struct hooks
|
|||||||
> nonhook_node_member_type;
|
> nonhook_node_member_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// container generator with void node allocator
|
||||||
|
template < bool Default_Holder >
|
||||||
|
struct GetContainer_With_Holder
|
||||||
|
{
|
||||||
template< class ValueType
|
template< class ValueType
|
||||||
, class Option1 =void
|
, class Option1 =void
|
||||||
, class Option2 =void
|
, class Option2 =void
|
||||||
@@ -86,8 +91,35 @@ struct GetContainer
|
|||||||
, Option3
|
, Option3
|
||||||
> type;
|
> type;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
template<class VoidPointer, bool constant_time_size>
|
// container generator with standard (non-void) node allocator
|
||||||
|
template <>
|
||||||
|
struct GetContainer_With_Holder< false >
|
||||||
|
{
|
||||||
|
template< class ValueType
|
||||||
|
, class Option1 =void
|
||||||
|
, class Option2 =void
|
||||||
|
, class Option3 =void
|
||||||
|
>
|
||||||
|
struct GetContainer
|
||||||
|
{
|
||||||
|
// extract node type through options->value_traits->node_traits->node
|
||||||
|
typedef typename pack_options< treap_defaults, Option1, Option2, Option3 >::type packed_options;
|
||||||
|
typedef typename detail::get_value_traits< ValueType, typename packed_options::proto_value_traits>::type value_traits;
|
||||||
|
typedef typename value_traits::node_traits::node node;
|
||||||
|
|
||||||
|
typedef boost::intrusive::treap_set
|
||||||
|
< ValueType
|
||||||
|
, Option1
|
||||||
|
, Option2
|
||||||
|
, Option3
|
||||||
|
, header_holder_type< pointer_holder< node > >
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class VoidPointer, bool constant_time_size, bool Default_Holder>
|
||||||
class test_main_template
|
class test_main_template
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -100,7 +132,7 @@ class test_main_template
|
|||||||
< value_type
|
< value_type
|
||||||
, typename hooks<VoidPointer>::base_hook_type
|
, typename hooks<VoidPointer>::base_hook_type
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
test::test_generic_set < typename detail::get_member_value_traits
|
test::test_generic_set < typename detail::get_member_value_traits
|
||||||
< value_type
|
< value_type
|
||||||
@@ -109,21 +141,21 @@ class test_main_template
|
|||||||
, &value_type::node_
|
, &value_type::node_
|
||||||
>
|
>
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
test::test_generic_set < nonhook_node_member_value_traits< value_type,
|
test::test_generic_set < nonhook_node_member_value_traits< value_type,
|
||||||
typename hooks<VoidPointer>::nonhook_node_member_type,
|
typename hooks<VoidPointer>::nonhook_node_member_type,
|
||||||
&value_type::nhn_member_,
|
&value_type::nhn_member_,
|
||||||
safe_link
|
safe_link
|
||||||
>,
|
>,
|
||||||
GetContainer
|
GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class VoidPointer>
|
template<class VoidPointer, bool Default_Holder>
|
||||||
class test_main_template<VoidPointer, false>
|
class test_main_template<VoidPointer, false, Default_Holder>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int operator()()
|
int operator()()
|
||||||
@@ -135,7 +167,7 @@ class test_main_template<VoidPointer, false>
|
|||||||
< value_type
|
< value_type
|
||||||
, typename hooks<VoidPointer>::base_hook_type
|
, typename hooks<VoidPointer>::base_hook_type
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
|
|
||||||
test::test_generic_set < typename detail::get_member_value_traits
|
test::test_generic_set < typename detail::get_member_value_traits
|
||||||
@@ -145,14 +177,14 @@ class test_main_template<VoidPointer, false>
|
|||||||
, &value_type::node_
|
, &value_type::node_
|
||||||
>
|
>
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
|
|
||||||
test::test_generic_set < typename detail::get_base_value_traits
|
test::test_generic_set < typename detail::get_base_value_traits
|
||||||
< value_type
|
< value_type
|
||||||
, typename hooks<VoidPointer>::auto_base_hook_type
|
, typename hooks<VoidPointer>::auto_base_hook_type
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
|
|
||||||
test::test_generic_set < typename detail::get_member_value_traits
|
test::test_generic_set < typename detail::get_member_value_traits
|
||||||
@@ -162,19 +194,71 @@ class test_main_template<VoidPointer, false>
|
|||||||
, &value_type::auto_node_
|
, &value_type::auto_node_
|
||||||
>
|
>
|
||||||
>::type
|
>::type
|
||||||
, GetContainer
|
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||||
>::test_all();
|
>::test_all();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// container generator which ignores further parametrization, except for compare option
|
||||||
|
template < typename Value_Traits, bool Constant_Time_Size, typename Header_Holder >
|
||||||
|
struct Get_Preset_Container
|
||||||
|
{
|
||||||
|
template < class
|
||||||
|
, class Option1 = void
|
||||||
|
, class Option2 = void
|
||||||
|
, class Option3 = void
|
||||||
|
>
|
||||||
|
struct GetContainer
|
||||||
|
{
|
||||||
|
// ignore further paramatrization except for the compare option
|
||||||
|
// notably ignore the size option (use preset)
|
||||||
|
typedef typename pack_options< treap_defaults, Option1, Option2, Option3 >::type packed_options;
|
||||||
|
typedef typename packed_options::compare compare_option;
|
||||||
|
|
||||||
|
typedef boost::intrusive::treap_set< typename Value_Traits::value_type,
|
||||||
|
value_traits< Value_Traits >,
|
||||||
|
constant_time_size< Constant_Time_Size >,
|
||||||
|
compare< compare_option >,
|
||||||
|
header_holder_type< Header_Holder >
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
template < bool Constant_Time_Size >
|
||||||
|
struct test_main_template_bptr
|
||||||
|
{
|
||||||
|
void operator () ()
|
||||||
|
{
|
||||||
|
typedef BPtr_Value value_type;
|
||||||
|
typedef BPtr_Value_Traits< Tree_BPtr_Node_Traits > value_traits;
|
||||||
|
typedef Bounded_Allocator< value_type > allocator_type;
|
||||||
|
|
||||||
|
allocator_type::init();
|
||||||
|
test::test_generic_set< value_traits,
|
||||||
|
Get_Preset_Container< value_traits, Constant_Time_Size,
|
||||||
|
Bounded_Pointer_Holder< value_type > >::template GetContainer
|
||||||
|
>::test_all();
|
||||||
|
assert(allocator_type::is_clear());
|
||||||
|
allocator_type::destroy();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
int main( int, char* [] )
|
int main( int, char* [] )
|
||||||
{
|
{
|
||||||
test_main_template<void*, false>()();
|
// test (plain/smart pointers) x (nonconst/const size) x (void node allocator)
|
||||||
test_main_template<boost::intrusive::smart_ptr<void>, false>()();
|
test_main_template<void*, false, true>()();
|
||||||
test_main_template<void*, true>()();
|
test_main_template<boost::intrusive::smart_ptr<void>, false, true>()();
|
||||||
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
|
test_main_template<void*, true, true>()();
|
||||||
|
test_main_template<boost::intrusive::smart_ptr<void>, true, true>()();
|
||||||
|
// test (plain pointers) x (nonconst/const size) x (standard node allocator)
|
||||||
|
test_main_template<void*, false, false>()();
|
||||||
|
test_main_template<void*, true, false>()();
|
||||||
|
// test (bounded pointers) x (nonconst/const size) x (special node allocator)
|
||||||
|
test_main_template_bptr< true >()();
|
||||||
|
test_main_template_bptr< false >()();
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user