mirror of
https://github.com/boostorg/intrusive.git
synced 2025-08-02 14:04:36 +02:00
Merge branch 'header-holder' of https://github.com/mateidavid/intrusive into mateidavid-header-holder
This commit is contained in:
@@ -36,15 +36,15 @@ namespace intrusive {
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize>
|
||||
template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
class avl_set_impl
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
: public bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, AvlTreeAlgorithms>
|
||||
: public bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, AvlTreeAlgorithms, Header_Holder>
|
||||
#endif
|
||||
{
|
||||
/// @cond
|
||||
typedef bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, AvlTreeAlgorithms> tree_type;
|
||||
typedef bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, AvlTreeAlgorithms, Header_Holder> tree_type;
|
||||
BOOST_MOVABLE_BUT_NOT_COPYABLE(avl_set_impl)
|
||||
|
||||
typedef tree_type implementation_defined;
|
||||
@@ -397,7 +397,8 @@ void swap(avl_set_impl<T, Options...> &x, avl_set_impl<T, Options...> &y);
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void
|
||||
, class O3 = void, class O4 = void>
|
||||
, class O3 = void, class O4 = void
|
||||
, class O5 = void>
|
||||
#endif
|
||||
struct make_avl_set
|
||||
{
|
||||
@@ -405,7 +406,7 @@ struct make_avl_set
|
||||
typedef typename pack_options
|
||||
< avltree_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -413,12 +414,15 @@ struct make_avl_set
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef avl_set_impl
|
||||
< value_traits
|
||||
, typename packed_options::compare
|
||||
, typename packed_options::size_type
|
||||
, packed_options::constant_time_size
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -426,14 +430,14 @@ struct make_avl_set
|
||||
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class avl_set
|
||||
: public make_avl_set<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -442,7 +446,7 @@ class avl_set
|
||||
typedef typename make_avl_set
|
||||
<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -506,15 +510,15 @@ class avl_set
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize>
|
||||
template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
class avl_multiset_impl
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
: public bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, AvlTreeAlgorithms>
|
||||
: public bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, AvlTreeAlgorithms, Header_Holder>
|
||||
#endif
|
||||
{
|
||||
/// @cond
|
||||
typedef bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, AvlTreeAlgorithms> tree_type;
|
||||
typedef bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, AvlTreeAlgorithms, Header_Holder> tree_type;
|
||||
|
||||
BOOST_MOVABLE_BUT_NOT_COPYABLE(avl_multiset_impl)
|
||||
typedef tree_type implementation_defined;
|
||||
@@ -834,7 +838,8 @@ void swap(avl_multiset_impl<T, Options...> &x, avl_multiset_impl<T, Options...>
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void
|
||||
, class O3 = void, class O4 = void>
|
||||
, class O3 = void, class O4 = void
|
||||
, class O5 = void>
|
||||
#endif
|
||||
struct make_avl_multiset
|
||||
{
|
||||
@@ -842,7 +847,7 @@ struct make_avl_multiset
|
||||
typedef typename pack_options
|
||||
< avltree_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -850,12 +855,15 @@ struct make_avl_multiset
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef avl_multiset_impl
|
||||
< value_traits
|
||||
, typename packed_options::compare
|
||||
, typename packed_options::size_type
|
||||
, packed_options::constant_time_size
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -864,14 +872,14 @@ struct make_avl_multiset
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class avl_multiset
|
||||
: public make_avl_multiset<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -879,7 +887,7 @@ class avl_multiset
|
||||
{
|
||||
typedef typename make_avl_multiset<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
|
@@ -47,6 +47,7 @@ struct avltree_defaults
|
||||
static const bool constant_time_size = true;
|
||||
typedef std::size_t size_type;
|
||||
typedef void compare;
|
||||
typedef void header_holder_type;
|
||||
};
|
||||
|
||||
/// @endcond
|
||||
@@ -67,18 +68,19 @@ struct avltree_defaults
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class VoidOrKeyComp, class SizeType, bool ConstantTimeSize>
|
||||
template<class ValueTraits, class VoidOrKeyComp, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
class avltree_impl
|
||||
/// @cond
|
||||
: public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, AvlTreeAlgorithms>
|
||||
: public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, AvlTreeAlgorithms, Header_Holder>
|
||||
/// @endcond
|
||||
{
|
||||
public:
|
||||
typedef ValueTraits value_traits;
|
||||
/// @cond
|
||||
typedef bstree_impl< ValueTraits, VoidOrKeyComp, SizeType
|
||||
, ConstantTimeSize, AvlTreeAlgorithms> tree_type;
|
||||
, ConstantTimeSize, AvlTreeAlgorithms
|
||||
, Header_Holder> tree_type;
|
||||
typedef tree_type implementation_defined;
|
||||
/// @endcond
|
||||
|
||||
@@ -430,7 +432,8 @@ void swap(avltree_impl<T, Options...> &x, avltree_impl<T, Options...> &y);
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void
|
||||
, class O3 = void, class O4 = void>
|
||||
, class O3 = void, class O4 = void
|
||||
, class O5 = void>
|
||||
#endif
|
||||
struct make_avltree
|
||||
{
|
||||
@@ -438,7 +441,7 @@ struct make_avltree
|
||||
typedef typename pack_options
|
||||
< avltree_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -446,12 +449,15 @@ struct make_avltree
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef avltree_impl
|
||||
< value_traits
|
||||
, typename packed_options::compare
|
||||
, typename packed_options::size_type
|
||||
, packed_options::constant_time_size
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -461,14 +467,14 @@ struct make_avltree
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class avltree
|
||||
: public make_avltree<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -477,7 +483,7 @@ class avltree
|
||||
typedef typename make_avltree
|
||||
<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
|
@@ -36,15 +36,15 @@ namespace intrusive {
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize>
|
||||
template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
class bs_set_impl
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
: public bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, BsTreeAlgorithms>
|
||||
: public bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, BsTreeAlgorithms, Header_Holder>
|
||||
#endif
|
||||
{
|
||||
/// @cond
|
||||
typedef bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, BsTreeAlgorithms> tree_type;
|
||||
typedef bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, BsTreeAlgorithms, Header_Holder> tree_type;
|
||||
BOOST_MOVABLE_BUT_NOT_COPYABLE(bs_set_impl)
|
||||
|
||||
typedef tree_type implementation_defined;
|
||||
@@ -395,7 +395,8 @@ void swap(bs_set_impl<T, Options...> &x, bs_set_impl<T, Options...> &y);
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void
|
||||
, class O3 = void, class O4 = void>
|
||||
, class O3 = void, class O4 = void
|
||||
, class O5 = void>
|
||||
#endif
|
||||
struct make_bs_set
|
||||
{
|
||||
@@ -403,7 +404,7 @@ struct make_bs_set
|
||||
typedef typename pack_options
|
||||
< bstree_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -411,12 +412,15 @@ struct make_bs_set
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef bs_set_impl
|
||||
< value_traits
|
||||
, typename packed_options::compare
|
||||
, typename packed_options::size_type
|
||||
, packed_options::constant_time_size
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -424,14 +428,14 @@ struct make_bs_set
|
||||
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class bs_set
|
||||
: public make_bs_set<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -440,7 +444,7 @@ class bs_set
|
||||
typedef typename make_bs_set
|
||||
<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -504,15 +508,15 @@ class bs_set
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize>
|
||||
template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
class bs_multiset_impl
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
: public bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, RbTreeAlgorithms>
|
||||
: public bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, RbTreeAlgorithms, Header_Holder>
|
||||
#endif
|
||||
{
|
||||
/// @cond
|
||||
typedef bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, RbTreeAlgorithms> tree_type;
|
||||
typedef bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, RbTreeAlgorithms, Header_Holder> tree_type;
|
||||
|
||||
BOOST_MOVABLE_BUT_NOT_COPYABLE(bs_multiset_impl)
|
||||
typedef tree_type implementation_defined;
|
||||
@@ -832,7 +836,8 @@ void swap(bs_multiset_impl<T, Options...> &x, bs_multiset_impl<T, Options...> &y
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void
|
||||
, class O3 = void, class O4 = void>
|
||||
, class O3 = void, class O4 = void
|
||||
, class O5 = void>
|
||||
#endif
|
||||
struct make_bs_multiset
|
||||
{
|
||||
@@ -840,7 +845,7 @@ struct make_bs_multiset
|
||||
typedef typename pack_options
|
||||
< bstree_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -848,12 +853,15 @@ struct make_bs_multiset
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef bs_multiset_impl
|
||||
< value_traits
|
||||
, typename packed_options::compare
|
||||
, typename packed_options::size_type
|
||||
, packed_options::constant_time_size
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -862,14 +870,14 @@ struct make_bs_multiset
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class bs_multiset
|
||||
: public make_bs_multiset<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -877,7 +885,7 @@ class bs_multiset
|
||||
{
|
||||
typedef typename make_bs_multiset<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
|
@@ -49,9 +49,10 @@ struct bstree_defaults
|
||||
typedef void compare;
|
||||
static const bool floating_point = true; //For sgtree
|
||||
typedef void priority; //For treap
|
||||
typedef void header_holder_type;
|
||||
};
|
||||
|
||||
template<class ValueTraits, algo_types AlgoType>
|
||||
template<class ValueTraits, algo_types AlgoType, typename Header_Holder>
|
||||
struct bstbase3
|
||||
{
|
||||
typedef ValueTraits value_traits;
|
||||
@@ -60,18 +61,38 @@ struct bstbase3
|
||||
typedef typename get_algo<AlgoType, node_traits>::type node_algorithms;
|
||||
typedef typename node_traits::node_ptr node_ptr;
|
||||
typedef typename node_traits::const_node_ptr const_node_ptr;
|
||||
typedef tree_iterator<value_traits, false> iterator;
|
||||
typedef tree_iterator<value_traits, true> const_iterator;
|
||||
typedef boost::intrusive::detail::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef boost::intrusive::detail::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::pointer) pointer;
|
||||
typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::const_pointer) const_pointer;
|
||||
typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::element_type) value_type;
|
||||
typedef BOOST_INTRUSIVE_IMPDEF(value_type) key_type;
|
||||
typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::reference) reference;
|
||||
typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::reference) const_reference;
|
||||
typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::difference_type) difference_type;
|
||||
typedef Header_Holder header_holder_type;
|
||||
|
||||
static const bool safemode_or_autounlink = is_safe_autounlink<value_traits::link_mode>::value;
|
||||
static const bool stateful_value_traits = detail::is_stateful_value_traits<value_traits>::value;
|
||||
static const bool has_container_from_iterator =
|
||||
boost::is_same< header_holder_type, detail::default_header_holder< node_traits > >::value;
|
||||
|
||||
struct holder_t : public ValueTraits
|
||||
{
|
||||
explicit holder_t(const ValueTraits &vtraits)
|
||||
: ValueTraits(vtraits)
|
||||
{}
|
||||
node_type root;
|
||||
header_holder_type root;
|
||||
} holder;
|
||||
|
||||
static bstbase3 &get_tree_base_from_root(node_type &root)
|
||||
static bstbase3 &get_tree_base_from_end_iterator(const const_iterator &end_iterator)
|
||||
{
|
||||
holder_t *holder = get_parent_from_member<holder_t, node_type>(&root, &holder_t::root);
|
||||
BOOST_STATIC_ASSERT(has_container_from_iterator);
|
||||
node_ptr p = end_iterator.pointed_node();
|
||||
header_holder_type* h = header_holder_type::get_holder(p);
|
||||
holder_t *holder = get_parent_from_member<holder_t, header_holder_type>(h, &holder_t::root);
|
||||
bstbase3 *base = get_parent_from_member<bstbase3, holder_t> (holder, &bstbase3::holder);
|
||||
return *base;
|
||||
}
|
||||
@@ -83,10 +104,10 @@ struct bstbase3
|
||||
}
|
||||
|
||||
node_ptr header_ptr()
|
||||
{ return pointer_traits<node_ptr>::pointer_to(this->holder.root); }
|
||||
{ return holder.root.get_node(); }
|
||||
|
||||
const_node_ptr header_ptr() const
|
||||
{ return pointer_traits<const_node_ptr>::pointer_to(this->holder.root); }
|
||||
{ return holder.root.get_node(); }
|
||||
|
||||
const value_traits &get_value_traits() const
|
||||
{ return this->holder; }
|
||||
@@ -100,20 +121,6 @@ struct bstbase3
|
||||
const_value_traits_ptr value_traits_ptr() const
|
||||
{ return pointer_traits<const_value_traits_ptr>::pointer_to(this->get_value_traits()); }
|
||||
|
||||
typedef tree_iterator<value_traits, false> iterator;
|
||||
typedef tree_iterator<value_traits, true> const_iterator;
|
||||
typedef boost::intrusive::detail::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef boost::intrusive::detail::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::pointer) pointer;
|
||||
typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::const_pointer) const_pointer;
|
||||
typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::element_type) value_type;
|
||||
typedef BOOST_INTRUSIVE_IMPDEF(value_type) key_type;
|
||||
typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::reference) reference;
|
||||
typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::reference) const_reference;
|
||||
typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::difference_type) difference_type;
|
||||
static const bool safemode_or_autounlink = is_safe_autounlink<value_traits::link_mode>::value;
|
||||
static const bool stateful_value_traits = detail::is_stateful_value_traits<value_traits>::value;
|
||||
|
||||
iterator begin()
|
||||
{ return iterator(node_algorithms::begin_node(this->header_ptr()), this->value_traits_ptr()); }
|
||||
|
||||
@@ -197,15 +204,15 @@ struct bstbase3
|
||||
|
||||
};
|
||||
|
||||
template<class ValueTraits, class VoidOrKeyComp, algo_types AlgoType>
|
||||
template<class ValueTraits, class VoidOrKeyComp, algo_types AlgoType, typename Header_Holder>
|
||||
struct bstbase2
|
||||
//Put the (possibly empty) functor in the first position to get EBO in MSVC
|
||||
: public detail::ebo_functor_holder<typename get_less< VoidOrKeyComp
|
||||
, typename ValueTraits::value_type
|
||||
>::type>
|
||||
, public bstbase3<ValueTraits, AlgoType>
|
||||
, public bstbase3<ValueTraits, AlgoType, Header_Holder>
|
||||
{
|
||||
typedef bstbase3<ValueTraits, AlgoType> treeheader_t;
|
||||
typedef bstbase3<ValueTraits, AlgoType, Header_Holder> treeheader_t;
|
||||
typedef typename treeheader_t::value_traits value_traits;
|
||||
typedef typename treeheader_t::node_algorithms node_algorithms;
|
||||
typedef typename get_less
|
||||
@@ -443,12 +450,12 @@ struct bstbase2
|
||||
//Due to MSVC's EBO implementation, to save space and maintain the ABI, we must put the non-empty size member
|
||||
//in the first position, but if size is not going to be stored then we'll use an specialization
|
||||
//that doesn't inherit from size_holder
|
||||
template<class ValueTraits, class VoidOrKeyComp, bool ConstantTimeSize, class SizeType, algo_types AlgoType>
|
||||
template<class ValueTraits, class VoidOrKeyComp, bool ConstantTimeSize, class SizeType, algo_types AlgoType, typename Header_Holder>
|
||||
struct bstbase_hack
|
||||
: public detail::size_holder<ConstantTimeSize, SizeType>
|
||||
, public bstbase2 < ValueTraits, VoidOrKeyComp, AlgoType>
|
||||
, public bstbase2 < ValueTraits, VoidOrKeyComp, AlgoType, Header_Holder>
|
||||
{
|
||||
typedef bstbase2< ValueTraits, VoidOrKeyComp, AlgoType> base_type;
|
||||
typedef bstbase2< ValueTraits, VoidOrKeyComp, AlgoType, Header_Holder> base_type;
|
||||
typedef typename base_type::value_compare value_compare;
|
||||
typedef SizeType size_type;
|
||||
typedef typename base_type::node_traits node_traits;
|
||||
@@ -471,11 +478,11 @@ struct bstbase_hack
|
||||
};
|
||||
|
||||
//Specialization for ConstantTimeSize == false
|
||||
template<class ValueTraits, class VoidOrKeyComp, class SizeType, algo_types AlgoType>
|
||||
struct bstbase_hack<ValueTraits, VoidOrKeyComp, false, SizeType, AlgoType>
|
||||
: public bstbase2 < ValueTraits, VoidOrKeyComp, AlgoType>
|
||||
template<class ValueTraits, class VoidOrKeyComp, class SizeType, algo_types AlgoType, typename Header_Holder>
|
||||
struct bstbase_hack<ValueTraits, VoidOrKeyComp, false, SizeType, AlgoType, Header_Holder>
|
||||
: public bstbase2 < ValueTraits, VoidOrKeyComp, AlgoType, Header_Holder>
|
||||
{
|
||||
typedef bstbase2< ValueTraits, VoidOrKeyComp, AlgoType> base_type;
|
||||
typedef bstbase2< ValueTraits, VoidOrKeyComp, AlgoType, Header_Holder> base_type;
|
||||
typedef typename base_type::value_compare value_compare;
|
||||
bstbase_hack(const value_compare & comp, const ValueTraits &vtraits)
|
||||
: base_type(comp, vtraits)
|
||||
@@ -492,15 +499,15 @@ struct bstbase_hack<ValueTraits, VoidOrKeyComp, false, SizeType, AlgoType>
|
||||
static size_traits s_size_traits;
|
||||
};
|
||||
|
||||
template<class ValueTraits, class VoidOrKeyComp, class SizeType, algo_types AlgoType>
|
||||
detail::size_holder<true, SizeType> bstbase_hack<ValueTraits, VoidOrKeyComp, false, SizeType, AlgoType>::s_size_traits;
|
||||
template<class ValueTraits, class VoidOrKeyComp, class SizeType, algo_types AlgoType, typename Header_Holder>
|
||||
detail::size_holder<true, SizeType> bstbase_hack<ValueTraits, VoidOrKeyComp, false, SizeType, AlgoType, Header_Holder>::s_size_traits;
|
||||
|
||||
//This class will
|
||||
template<class ValueTraits, class VoidOrKeyComp, bool ConstantTimeSize, class SizeType, algo_types AlgoType>
|
||||
template<class ValueTraits, class VoidOrKeyComp, bool ConstantTimeSize, class SizeType, algo_types AlgoType, typename Header_Holder>
|
||||
struct bstbase
|
||||
: public bstbase_hack< ValueTraits, VoidOrKeyComp, ConstantTimeSize, SizeType, AlgoType>
|
||||
: public bstbase_hack< ValueTraits, VoidOrKeyComp, ConstantTimeSize, SizeType, AlgoType, Header_Holder>
|
||||
{
|
||||
typedef bstbase_hack< ValueTraits, VoidOrKeyComp, ConstantTimeSize, SizeType, AlgoType> base_type;
|
||||
typedef bstbase_hack< ValueTraits, VoidOrKeyComp, ConstantTimeSize, SizeType, AlgoType, Header_Holder> base_type;
|
||||
typedef ValueTraits value_traits;
|
||||
typedef typename base_type::value_compare value_compare;
|
||||
typedef value_compare key_compare;
|
||||
@@ -552,14 +559,14 @@ struct bstbase
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType>
|
||||
template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType, typename Header_Holder>
|
||||
#endif
|
||||
class bstree_impl
|
||||
: public bstbase<ValueTraits, VoidKeyComp, ConstantTimeSize, SizeType, AlgoType>
|
||||
: public bstbase<ValueTraits, VoidKeyComp, ConstantTimeSize, SizeType, AlgoType, Header_Holder>
|
||||
{
|
||||
public:
|
||||
/// @cond
|
||||
typedef bstbase<ValueTraits, VoidKeyComp, ConstantTimeSize, SizeType, AlgoType> data_type;
|
||||
typedef bstbase<ValueTraits, VoidKeyComp, ConstantTimeSize, SizeType, AlgoType, Header_Holder> data_type;
|
||||
typedef tree_iterator<ValueTraits, false> iterator_type;
|
||||
typedef tree_iterator<ValueTraits, true> const_iterator_type;
|
||||
/// @endcond
|
||||
@@ -775,7 +782,7 @@ class bstree_impl
|
||||
static bstree_impl &container_from_end_iterator(iterator end_iterator)
|
||||
{
|
||||
return static_cast<bstree_impl&>
|
||||
(data_type::get_tree_base_from_root(*boost::intrusive::detail::to_raw_pointer(end_iterator.pointed_node())));
|
||||
(data_type::get_tree_base_from_end_iterator(end_iterator));
|
||||
}
|
||||
|
||||
//! <b>Precondition</b>: end_iterator must be a valid end const_iterator
|
||||
@@ -789,7 +796,7 @@ class bstree_impl
|
||||
static const bstree_impl &container_from_end_iterator(const_iterator end_iterator)
|
||||
{
|
||||
return static_cast<bstree_impl&>
|
||||
(data_type::get_tree_base_from_root(*boost::intrusive::detail::to_raw_pointer(end_iterator.pointed_node())));
|
||||
(data_type::get_tree_base_from_end_iterator(end_iterator));
|
||||
}
|
||||
|
||||
//! <b>Precondition</b>: it must be a valid iterator
|
||||
@@ -1863,43 +1870,36 @@ class bstree_impl
|
||||
return b.unconst();
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
private:
|
||||
static bstree_impl &priv_container_from_end_iterator(const const_iterator &end_iterator)
|
||||
{
|
||||
return *static_cast<bstree_impl*>
|
||||
(boost::intrusive::detail::to_raw_pointer(end_iterator.pointed_node()));
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType>
|
||||
template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType, typename Header_Holder>
|
||||
#endif
|
||||
inline bool operator<
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(const bstree_impl<T, Options...> &x, const bstree_impl<T, Options...> &y)
|
||||
#else
|
||||
( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x
|
||||
, const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y)
|
||||
( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType, Header_Holder> &x
|
||||
, const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType, Header_Holder> &y)
|
||||
#endif
|
||||
{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
|
||||
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType>
|
||||
template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType, typename Header_Holder>
|
||||
#endif
|
||||
bool operator==
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(const bstree_impl<T, Options...> &x, const bstree_impl<T, Options...> &y)
|
||||
#else
|
||||
( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x
|
||||
, const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y)
|
||||
( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType, Header_Holder> &x
|
||||
, const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType, Header_Holder> &y)
|
||||
#endif
|
||||
{
|
||||
typedef bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> tree_type;
|
||||
typedef bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType, Header_Holder> tree_type;
|
||||
typedef typename tree_type::const_iterator const_iterator;
|
||||
|
||||
if(tree_type::constant_time_size && x.size() != y.size()){
|
||||
@@ -1928,70 +1928,70 @@ bool operator==
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType>
|
||||
template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType, typename Header_Holder>
|
||||
#endif
|
||||
inline bool operator!=
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(const bstree_impl<T, Options...> &x, const bstree_impl<T, Options...> &y)
|
||||
#else
|
||||
( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x
|
||||
, const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y)
|
||||
( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType, Header_Holder> &x
|
||||
, const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType, Header_Holder> &y)
|
||||
#endif
|
||||
{ return !(x == y); }
|
||||
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType>
|
||||
template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType, typename Header_Holder>
|
||||
#endif
|
||||
inline bool operator>
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(const bstree_impl<T, Options...> &x, const bstree_impl<T, Options...> &y)
|
||||
#else
|
||||
( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x
|
||||
, const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y)
|
||||
( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType, Header_Holder> &x
|
||||
, const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType, Header_Holder> &y)
|
||||
#endif
|
||||
{ return y < x; }
|
||||
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType>
|
||||
template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType, typename Header_Holder>
|
||||
#endif
|
||||
inline bool operator<=
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(const bstree_impl<T, Options...> &x, const bstree_impl<T, Options...> &y)
|
||||
#else
|
||||
( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x
|
||||
, const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y)
|
||||
( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType, Header_Holder> &x
|
||||
, const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType, Header_Holder> &y)
|
||||
#endif
|
||||
{ return !(y < x); }
|
||||
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType>
|
||||
template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType, typename Header_Holder>
|
||||
#endif
|
||||
inline bool operator>=
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(const bstree_impl<T, Options...> &x, const bstree_impl<T, Options...> &y)
|
||||
#else
|
||||
( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x
|
||||
, const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y)
|
||||
( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType, Header_Holder> &x
|
||||
, const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType, Header_Holder> &y)
|
||||
#endif
|
||||
{ return !(x < y); }
|
||||
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType>
|
||||
template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType, typename Header_Holder>
|
||||
#endif
|
||||
inline void swap
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(bstree_impl<T, Options...> &x, bstree_impl<T, Options...> &y)
|
||||
#else
|
||||
( bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x
|
||||
, bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y)
|
||||
( bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType, Header_Holder> &x
|
||||
, bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType, Header_Holder> &y)
|
||||
#endif
|
||||
{ x.swap(y); }
|
||||
|
||||
@@ -2001,7 +2001,8 @@ inline void swap
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void
|
||||
, class O3 = void, class O4 = void>
|
||||
, class O3 = void, class O4 = void
|
||||
, class O5 = void>
|
||||
#endif
|
||||
struct make_bstree
|
||||
{
|
||||
@@ -2009,7 +2010,7 @@ struct make_bstree
|
||||
typedef typename pack_options
|
||||
< bstree_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -2017,6 +2018,8 @@ struct make_bstree
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef bstree_impl
|
||||
< value_traits
|
||||
@@ -2024,6 +2027,7 @@ struct make_bstree
|
||||
, typename packed_options::size_type
|
||||
, packed_options::constant_time_size
|
||||
, BsTreeAlgorithms
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -2033,14 +2037,14 @@ struct make_bstree
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class bstree
|
||||
: public make_bstree<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -2049,7 +2053,7 @@ class bstree
|
||||
typedef typename make_bstree
|
||||
<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include <boost/detail/no_exceptions_support.hpp>
|
||||
#include <functional>
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/tti/tti.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
@@ -238,14 +239,25 @@ struct node_cloner
|
||||
typedef typename real_value_traits::pointer pointer;
|
||||
typedef typename node_traits::node node;
|
||||
typedef typename real_value_traits::const_node_ptr const_node_ptr;
|
||||
typedef typename real_value_traits::reference reference;
|
||||
typedef typename real_value_traits::const_reference const_reference;
|
||||
|
||||
node_cloner(F f, const RealValueTraits *traits)
|
||||
: base_t(f), traits_(traits)
|
||||
{}
|
||||
|
||||
// tree-based containers use this method, which is proxy-reference friendly
|
||||
node_ptr operator()(const node_ptr & p)
|
||||
{ return this->operator()(*p); }
|
||||
{
|
||||
const_reference v = *traits_->to_value_ptr(p);
|
||||
node_ptr n = traits_->to_node_ptr(*base_t::get()(v));
|
||||
//Cloned node must be in default mode if the linking mode requires it
|
||||
if(safemode_or_autounlink)
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(n));
|
||||
return n;
|
||||
}
|
||||
|
||||
// hashtables use this method, which is proxy-reference unfriendly
|
||||
node_ptr operator()(const node &to_clone)
|
||||
{
|
||||
const value_type &v =
|
||||
@@ -894,6 +906,45 @@ static typename uncast_types<ConstNodePtr>::non_const_pointer
|
||||
return uncast_types<ConstNodePtr>::non_const_traits::const_cast_from(ptr);
|
||||
}
|
||||
|
||||
// trivial header node holder
|
||||
template < typename Node_Traits >
|
||||
struct default_header_holder : public Node_Traits::node
|
||||
{
|
||||
typedef Node_Traits node_traits;
|
||||
typedef typename node_traits::node node;
|
||||
typedef typename node_traits::node_ptr node_ptr;
|
||||
typedef typename node_traits::const_node_ptr const_node_ptr;
|
||||
|
||||
default_header_holder() : node() {}
|
||||
|
||||
const_node_ptr get_node() const
|
||||
{ return pointer_traits< const_node_ptr >::pointer_to(*static_cast< const node* >(this)); }
|
||||
node_ptr get_node()
|
||||
{ return pointer_traits< node_ptr >::pointer_to(*static_cast< node* >(this)); }
|
||||
|
||||
// (unsafe) downcast used to implement container-from-iterator
|
||||
static default_header_holder* get_holder(node_ptr p)
|
||||
{ return static_cast< default_header_holder* >(boost::intrusive::detail::to_raw_pointer(p)); }
|
||||
};
|
||||
|
||||
//BOOST_TTI_HAS_MEMBER_FUNCTION(get_node)
|
||||
|
||||
// type function producing the header node holder
|
||||
template < typename Value_Traits, typename Header_Holder >
|
||||
struct get_header_holder_type
|
||||
{
|
||||
//typedef typename Value_Traits::node_ptr node_ptr;
|
||||
//typedef typename Value_Traits::const_node_ptr const_node_ptr;
|
||||
//BOOST_STATIC_ASSERT((has_member_function_get_node< Header_Holder, node_ptr () >::value));
|
||||
//BOOST_STATIC_ASSERT((has_member_function_get_node< Header_Holder, const_node_ptr () const>::value));
|
||||
typedef Header_Holder type;
|
||||
};
|
||||
template < typename Value_Traits >
|
||||
struct get_header_holder_type< Value_Traits, void >
|
||||
{
|
||||
typedef default_header_holder< typename Value_Traits::node_traits > type;
|
||||
};
|
||||
|
||||
} //namespace detail
|
||||
|
||||
template<class Node, class Tag, unsigned int>
|
||||
|
@@ -102,6 +102,7 @@ template
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
, class O6 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -137,6 +138,7 @@ template
|
||||
, class O1 = void
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -173,6 +175,7 @@ template
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -186,6 +189,7 @@ template
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -199,6 +203,7 @@ template
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -237,6 +242,7 @@ template
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -250,6 +256,7 @@ template
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -263,6 +270,7 @@ template
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -277,6 +285,7 @@ template
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -290,6 +299,7 @@ template
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -303,6 +313,7 @@ template
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -342,6 +353,7 @@ template
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -355,6 +367,7 @@ template
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -368,6 +381,7 @@ template
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -382,6 +396,7 @@ template
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -395,6 +410,7 @@ template
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -408,6 +424,7 @@ template
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -421,6 +438,7 @@ template
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -434,6 +452,7 @@ template
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
@@ -447,6 +466,7 @@ template
|
||||
, class O2 = void
|
||||
, class O3 = void
|
||||
, class O4 = void
|
||||
, class O5 = void
|
||||
>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
|
@@ -42,6 +42,7 @@ struct list_defaults
|
||||
typedef detail::default_list_hook proto_value_traits;
|
||||
static const bool constant_time_size = true;
|
||||
typedef std::size_t size_type;
|
||||
typedef void header_holder_type;
|
||||
};
|
||||
|
||||
/// @endcond
|
||||
@@ -59,7 +60,7 @@ struct list_defaults
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template <class ValueTraits, class SizeType, bool ConstantTimeSize>
|
||||
template <class ValueTraits, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
class list_impl
|
||||
{
|
||||
@@ -82,9 +83,12 @@ class list_impl
|
||||
typedef typename node_traits::node_ptr node_ptr;
|
||||
typedef typename node_traits::const_node_ptr const_node_ptr;
|
||||
typedef circular_list_algorithms<node_traits> node_algorithms;
|
||||
typedef Header_Holder header_holder_type;
|
||||
|
||||
static const bool constant_time_size = ConstantTimeSize;
|
||||
static const bool stateful_value_traits = detail::is_stateful_value_traits<value_traits>::value;
|
||||
static const bool has_container_from_iterator =
|
||||
boost::is_same< header_holder_type, detail::default_header_holder< node_traits > >::value;
|
||||
|
||||
/// @cond
|
||||
|
||||
@@ -102,15 +106,13 @@ class list_impl
|
||||
));
|
||||
|
||||
node_ptr get_root_node()
|
||||
{ return pointer_traits<node_ptr>::pointer_to(data_.root_plus_size_.root_); }
|
||||
{ return data_.root_plus_size_.get_node(); }
|
||||
|
||||
const_node_ptr get_root_node() const
|
||||
{ return pointer_traits<const_node_ptr>::pointer_to(data_.root_plus_size_.root_); }
|
||||
{ return data_.root_plus_size_.get_node(); }
|
||||
|
||||
struct root_plus_size : public size_traits
|
||||
{
|
||||
node root_;
|
||||
};
|
||||
struct root_plus_size : public header_holder_type, public size_traits
|
||||
{ };
|
||||
|
||||
struct data_t : public value_traits
|
||||
{
|
||||
@@ -1254,8 +1256,10 @@ class list_impl
|
||||
private:
|
||||
static list_impl &priv_container_from_end_iterator(const const_iterator &end_iterator)
|
||||
{
|
||||
root_plus_size *r = detail::parent_from_member<root_plus_size, node>
|
||||
( boost::intrusive::detail::to_raw_pointer(end_iterator.pointed_node()), &root_plus_size::root_);
|
||||
BOOST_STATIC_ASSERT((has_container_from_iterator));
|
||||
node_ptr p = end_iterator.pointed_node();
|
||||
header_holder_type* h = header_holder_type::get_holder(p);
|
||||
root_plus_size* r = static_cast< root_plus_size* >(h);
|
||||
data_t *d = detail::parent_from_member<data_t, root_plus_size>
|
||||
( r, &data_t::root_plus_size_);
|
||||
list_impl *s = detail::parent_from_member<list_impl, data_t>(d, &list_impl::data_);
|
||||
@@ -1267,29 +1271,29 @@ class list_impl
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template <class ValueTraits, class SizeType, bool ConstantTimeSize>
|
||||
template <class ValueTraits, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
inline bool operator<
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(const list_impl<T, Options...> &x, const list_impl<T, Options...> &y)
|
||||
#else
|
||||
(const list_impl<ValueTraits, SizeType, ConstantTimeSize> &x, const list_impl<ValueTraits, SizeType, ConstantTimeSize> &y)
|
||||
(const list_impl<ValueTraits, SizeType, ConstantTimeSize, Header_Holder> &x, const list_impl<ValueTraits, SizeType, ConstantTimeSize, Header_Holder> &y)
|
||||
#endif
|
||||
{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
|
||||
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template <class ValueTraits, class SizeType, bool ConstantTimeSize>
|
||||
template <class ValueTraits, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
bool operator==
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(const list_impl<T, Options...> &x, const list_impl<T, Options...> &y)
|
||||
#else
|
||||
(const list_impl<ValueTraits, SizeType, ConstantTimeSize> &x, const list_impl<ValueTraits, SizeType, ConstantTimeSize> &y)
|
||||
(const list_impl<ValueTraits, SizeType, ConstantTimeSize, Header_Holder> &x, const list_impl<ValueTraits, SizeType, ConstantTimeSize, Header_Holder> &y)
|
||||
#endif
|
||||
{
|
||||
typedef list_impl<ValueTraits, SizeType, ConstantTimeSize> list_type;
|
||||
typedef list_impl<ValueTraits, SizeType, ConstantTimeSize, Header_Holder> list_type;
|
||||
typedef typename list_type::const_iterator const_iterator;
|
||||
const bool C = list_type::constant_time_size;
|
||||
if(C && x.size() != y.size()){
|
||||
@@ -1319,65 +1323,65 @@ bool operator==
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template <class ValueTraits, class SizeType, bool ConstantTimeSize>
|
||||
template <class ValueTraits, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
inline bool operator!=
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(const list_impl<T, Options...> &x, const list_impl<T, Options...> &y)
|
||||
#else
|
||||
(const list_impl<ValueTraits, SizeType, ConstantTimeSize> &x, const list_impl<ValueTraits, SizeType, ConstantTimeSize> &y)
|
||||
(const list_impl<ValueTraits, SizeType, ConstantTimeSize, Header_Holder> &x, const list_impl<ValueTraits, SizeType, ConstantTimeSize, Header_Holder> &y)
|
||||
#endif
|
||||
{ return !(x == y); }
|
||||
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template <class ValueTraits, class SizeType, bool ConstantTimeSize>
|
||||
template <class ValueTraits, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
inline bool operator>
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(const list_impl<T, Options...> &x, const list_impl<T, Options...> &y)
|
||||
#else
|
||||
(const list_impl<ValueTraits, SizeType, ConstantTimeSize> &x, const list_impl<ValueTraits, SizeType, ConstantTimeSize> &y)
|
||||
(const list_impl<ValueTraits, SizeType, ConstantTimeSize, Header_Holder> &x, const list_impl<ValueTraits, SizeType, ConstantTimeSize, Header_Holder> &y)
|
||||
#endif
|
||||
{ return y < x; }
|
||||
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template <class ValueTraits, class SizeType, bool ConstantTimeSize>
|
||||
template <class ValueTraits, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
inline bool operator<=
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(const list_impl<T, Options...> &x, const list_impl<T, Options...> &y)
|
||||
#else
|
||||
(const list_impl<ValueTraits, SizeType, ConstantTimeSize> &x, const list_impl<ValueTraits, SizeType, ConstantTimeSize> &y)
|
||||
(const list_impl<ValueTraits, SizeType, ConstantTimeSize, Header_Holder> &x, const list_impl<ValueTraits, SizeType, ConstantTimeSize, Header_Holder> &y)
|
||||
#endif
|
||||
{ return !(y < x); }
|
||||
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template <class ValueTraits, class SizeType, bool ConstantTimeSize>
|
||||
template <class ValueTraits, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
inline bool operator>=
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(const list_impl<T, Options...> &x, const list_impl<T, Options...> &y)
|
||||
#else
|
||||
(const list_impl<ValueTraits, SizeType, ConstantTimeSize> &x, const list_impl<ValueTraits, SizeType, ConstantTimeSize> &y)
|
||||
(const list_impl<ValueTraits, SizeType, ConstantTimeSize, Header_Holder> &x, const list_impl<ValueTraits, SizeType, ConstantTimeSize, Header_Holder> &y)
|
||||
#endif
|
||||
{ return !(x < y); }
|
||||
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template <class ValueTraits, class SizeType, bool ConstantTimeSize>
|
||||
template <class ValueTraits, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
inline void swap
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(list_impl<T, Options...> &x, list_impl<T, Options...> &y)
|
||||
#else
|
||||
(list_impl<ValueTraits, SizeType, ConstantTimeSize> &x, list_impl<ValueTraits, SizeType, ConstantTimeSize> &y)
|
||||
(list_impl<ValueTraits, SizeType, ConstantTimeSize, Header_Holder> &x, list_impl<ValueTraits, SizeType, ConstantTimeSize, Header_Holder> &y)
|
||||
#endif
|
||||
{ x.swap(y); }
|
||||
|
||||
@@ -1386,7 +1390,7 @@ inline void swap
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void, class O3 = void>
|
||||
template<class T, class O1 = void, class O2 = void, class O3 = void, class O4 = void>
|
||||
#endif
|
||||
struct make_list
|
||||
{
|
||||
@@ -1394,7 +1398,7 @@ struct make_list
|
||||
typedef typename pack_options
|
||||
< list_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3
|
||||
O1, O2, O3, O4
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -1402,12 +1406,15 @@ struct make_list
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef list_impl
|
||||
<
|
||||
value_traits,
|
||||
typename packed_options::size_type,
|
||||
packed_options::constant_time_size
|
||||
packed_options::constant_time_size,
|
||||
header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -1417,14 +1424,14 @@ struct make_list
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
template<class T, class O1, class O2, class O3>
|
||||
template<class T, class O1, class O2, class O3, class O4>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class list
|
||||
: public make_list<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3
|
||||
O1, O2, O3, O4
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -1433,7 +1440,7 @@ class list
|
||||
typedef typename make_list
|
||||
<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3
|
||||
O1, O2, O3, O4
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
|
@@ -182,6 +182,9 @@ struct get_node_traits
|
||||
//!obtain constant-time size() member.
|
||||
BOOST_INTRUSIVE_OPTION_CONSTANT(constant_time_size, bool, Enabled, constant_time_size)
|
||||
|
||||
//!This option setter specifies a container header holder type
|
||||
BOOST_INTRUSIVE_OPTION_TYPE(header_holder_type, Header_Holder, Header_Holder, header_holder_type)
|
||||
|
||||
//!This option setter specifies the type that
|
||||
//!the container will use to store its size.
|
||||
BOOST_INTRUSIVE_OPTION_TYPE(size_type, SizeType, SizeType, size_type)
|
||||
|
@@ -45,6 +45,7 @@ struct rbtree_defaults
|
||||
static const bool constant_time_size = true;
|
||||
typedef std::size_t size_type;
|
||||
typedef void compare;
|
||||
typedef void header_holder_type;
|
||||
};
|
||||
|
||||
/// @endcond
|
||||
@@ -65,18 +66,19 @@ struct rbtree_defaults
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class VoidOrKeyComp, class SizeType, bool ConstantTimeSize>
|
||||
template<class ValueTraits, class VoidOrKeyComp, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
class rbtree_impl
|
||||
/// @cond
|
||||
: public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, RbTreeAlgorithms>
|
||||
: public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, RbTreeAlgorithms, Header_Holder>
|
||||
/// @endcond
|
||||
{
|
||||
public:
|
||||
typedef ValueTraits value_traits;
|
||||
/// @cond
|
||||
typedef bstree_impl< ValueTraits, VoidOrKeyComp, SizeType
|
||||
, ConstantTimeSize, RbTreeAlgorithms> tree_type;
|
||||
, ConstantTimeSize, RbTreeAlgorithms
|
||||
, Header_Holder> tree_type;
|
||||
typedef tree_type implementation_defined;
|
||||
/// @endcond
|
||||
|
||||
@@ -426,7 +428,8 @@ void swap(rbtree_impl<T, Options...> &x, rbtree_impl<T, Options...> &y);
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void
|
||||
, class O3 = void, class O4 = void>
|
||||
, class O3 = void, class O4 = void
|
||||
, class O5 = void>
|
||||
#endif
|
||||
struct make_rbtree
|
||||
{
|
||||
@@ -434,7 +437,7 @@ struct make_rbtree
|
||||
typedef typename pack_options
|
||||
< rbtree_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -442,12 +445,15 @@ struct make_rbtree
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef rbtree_impl
|
||||
< value_traits
|
||||
, typename packed_options::compare
|
||||
, typename packed_options::size_type
|
||||
, packed_options::constant_time_size
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -457,14 +463,14 @@ struct make_rbtree
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class rbtree
|
||||
: public make_rbtree<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -473,7 +479,7 @@ class rbtree
|
||||
typedef typename make_rbtree
|
||||
<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
|
@@ -38,15 +38,15 @@ namespace intrusive {
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize>
|
||||
template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
class set_impl
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
: public bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, RbTreeAlgorithms>
|
||||
: public bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, RbTreeAlgorithms, Header_Holder>
|
||||
#endif
|
||||
{
|
||||
/// @cond
|
||||
typedef bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, RbTreeAlgorithms> tree_type;
|
||||
typedef bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, RbTreeAlgorithms, Header_Holder> tree_type;
|
||||
BOOST_MOVABLE_BUT_NOT_COPYABLE(set_impl)
|
||||
|
||||
typedef tree_type implementation_defined;
|
||||
@@ -397,7 +397,8 @@ void swap(set_impl<T, Options...> &x, set_impl<T, Options...> &y);
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void
|
||||
, class O3 = void, class O4 = void>
|
||||
, class O3 = void, class O4 = void
|
||||
, class O5 = void>
|
||||
#endif
|
||||
struct make_set
|
||||
{
|
||||
@@ -405,7 +406,7 @@ struct make_set
|
||||
typedef typename pack_options
|
||||
< rbtree_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -413,12 +414,15 @@ struct make_set
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef set_impl
|
||||
< value_traits
|
||||
, typename packed_options::compare
|
||||
, typename packed_options::size_type
|
||||
, packed_options::constant_time_size
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -426,14 +430,14 @@ struct make_set
|
||||
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class set
|
||||
: public make_set<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -442,7 +446,7 @@ class set
|
||||
typedef typename make_set
|
||||
<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -506,15 +510,15 @@ class set
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize>
|
||||
template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
class multiset_impl
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
: public bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, RbTreeAlgorithms>
|
||||
: public bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, RbTreeAlgorithms, Header_Holder>
|
||||
#endif
|
||||
{
|
||||
/// @cond
|
||||
typedef bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, RbTreeAlgorithms> tree_type;
|
||||
typedef bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, RbTreeAlgorithms, Header_Holder> tree_type;
|
||||
|
||||
BOOST_MOVABLE_BUT_NOT_COPYABLE(multiset_impl)
|
||||
typedef tree_type implementation_defined;
|
||||
@@ -834,7 +838,8 @@ void swap(multiset_impl<T, Options...> &x, multiset_impl<T, Options...> &y);
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void
|
||||
, class O3 = void, class O4 = void>
|
||||
, class O3 = void, class O4 = void
|
||||
, class O5 = void>
|
||||
#endif
|
||||
struct make_multiset
|
||||
{
|
||||
@@ -842,7 +847,7 @@ struct make_multiset
|
||||
typedef typename pack_options
|
||||
< rbtree_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -850,12 +855,15 @@ struct make_multiset
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef multiset_impl
|
||||
< value_traits
|
||||
, typename packed_options::compare
|
||||
, typename packed_options::size_type
|
||||
, packed_options::constant_time_size
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -864,14 +872,14 @@ struct make_multiset
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class multiset
|
||||
: public make_multiset<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -879,7 +887,7 @@ class multiset
|
||||
{
|
||||
typedef typename make_multiset<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
|
@@ -36,15 +36,15 @@ namespace intrusive {
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class Compare, class SizeType, bool FloatingPoint>
|
||||
template<class ValueTraits, class Compare, class SizeType, bool FloatingPoint, typename Header_Holder>
|
||||
#endif
|
||||
class sg_set_impl
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
: public sgtree_impl<ValueTraits, Compare, SizeType, FloatingPoint>
|
||||
: public sgtree_impl<ValueTraits, Compare, SizeType, FloatingPoint, Header_Holder>
|
||||
#endif
|
||||
{
|
||||
/// @cond
|
||||
typedef sgtree_impl<ValueTraits, Compare, SizeType, FloatingPoint> tree_type;
|
||||
typedef sgtree_impl<ValueTraits, Compare, SizeType, FloatingPoint, Header_Holder> tree_type;
|
||||
BOOST_MOVABLE_BUT_NOT_COPYABLE(sg_set_impl)
|
||||
|
||||
typedef tree_type implementation_defined;
|
||||
@@ -408,7 +408,8 @@ void swap(sg_set_impl<T, Options...> &x, sg_set_impl<T, Options...> &y);
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void
|
||||
, class O3 = void, class O4 = void>
|
||||
, class O3 = void, class O4 = void
|
||||
, class O5 = void>
|
||||
#endif
|
||||
struct make_sg_set
|
||||
{
|
||||
@@ -416,7 +417,7 @@ struct make_sg_set
|
||||
typedef typename pack_options
|
||||
< sgtree_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -424,12 +425,15 @@ struct make_sg_set
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef sg_set_impl
|
||||
< value_traits
|
||||
, typename packed_options::compare
|
||||
, typename packed_options::size_type
|
||||
, packed_options::floating_point
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -437,14 +441,14 @@ struct make_sg_set
|
||||
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class sg_set
|
||||
: public make_sg_set<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -453,7 +457,7 @@ class sg_set
|
||||
typedef typename make_sg_set
|
||||
<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -517,15 +521,15 @@ class sg_set
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class Compare, class SizeType, bool FloatingPoint>
|
||||
template<class ValueTraits, class Compare, class SizeType, bool FloatingPoint, typename Header_Holder>
|
||||
#endif
|
||||
class sg_multiset_impl
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
: public sgtree_impl<ValueTraits, Compare, SizeType, FloatingPoint>
|
||||
: public sgtree_impl<ValueTraits, Compare, SizeType, FloatingPoint, Header_Holder>
|
||||
#endif
|
||||
{
|
||||
/// @cond
|
||||
typedef sgtree_impl<ValueTraits, Compare, SizeType, FloatingPoint> tree_type;
|
||||
typedef sgtree_impl<ValueTraits, Compare, SizeType, FloatingPoint, Header_Holder> tree_type;
|
||||
|
||||
BOOST_MOVABLE_BUT_NOT_COPYABLE(sg_multiset_impl)
|
||||
typedef tree_type implementation_defined;
|
||||
@@ -858,7 +862,8 @@ void swap(sg_multiset_impl<T, Options...> &x, sg_multiset_impl<T, Options...> &y
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void
|
||||
, class O3 = void, class O4 = void>
|
||||
, class O3 = void, class O4 = void
|
||||
, class O5 = void>
|
||||
#endif
|
||||
struct make_sg_multiset
|
||||
{
|
||||
@@ -866,7 +871,7 @@ struct make_sg_multiset
|
||||
typedef typename pack_options
|
||||
< sgtree_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -874,12 +879,15 @@ struct make_sg_multiset
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef sg_multiset_impl
|
||||
< value_traits
|
||||
, typename packed_options::compare
|
||||
, typename packed_options::size_type
|
||||
, packed_options::floating_point
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -888,14 +896,14 @@ struct make_sg_multiset
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class sg_multiset
|
||||
: public make_sg_multiset<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -903,7 +911,7 @@ class sg_multiset
|
||||
{
|
||||
typedef typename make_sg_multiset<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
|
@@ -192,6 +192,7 @@ struct sgtree_defaults
|
||||
typedef std::size_t size_type;
|
||||
typedef void compare;
|
||||
static const bool floating_point = true;
|
||||
typedef void header_holder_type;
|
||||
};
|
||||
|
||||
/// @endcond
|
||||
@@ -212,11 +213,11 @@ struct sgtree_defaults
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class VoidOrKeyComp, class SizeType, bool FloatingPoint>
|
||||
template<class ValueTraits, class VoidOrKeyComp, class SizeType, bool FloatingPoint, typename Header_Holder>
|
||||
#endif
|
||||
class sgtree_impl
|
||||
/// @cond
|
||||
: public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, true, SgTreeAlgorithms>
|
||||
: public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, true, SgTreeAlgorithms, Header_Holder>
|
||||
, public detail::alpha_holder<FloatingPoint, SizeType>
|
||||
/// @endcond
|
||||
{
|
||||
@@ -224,7 +225,7 @@ class sgtree_impl
|
||||
typedef ValueTraits value_traits;
|
||||
/// @cond
|
||||
typedef bstree_impl< ValueTraits, VoidOrKeyComp, SizeType
|
||||
, true, SgTreeAlgorithms> tree_type;
|
||||
, true, SgTreeAlgorithms, Header_Holder> tree_type;
|
||||
typedef tree_type implementation_defined;
|
||||
|
||||
/// @endcond
|
||||
@@ -872,7 +873,8 @@ void swap(sgtree_impl<T, Options...> &x, sgtree_impl<T, Options...> &y);
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void
|
||||
, class O3 = void, class O4 = void>
|
||||
, class O3 = void, class O4 = void
|
||||
, class O5 = void>
|
||||
#endif
|
||||
struct make_sgtree
|
||||
{
|
||||
@@ -880,7 +882,7 @@ struct make_sgtree
|
||||
typedef typename pack_options
|
||||
< sgtree_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -888,12 +890,15 @@ struct make_sgtree
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef sgtree_impl
|
||||
< value_traits
|
||||
, typename packed_options::compare
|
||||
, typename packed_options::size_type
|
||||
, packed_options::floating_point
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -903,14 +908,14 @@ struct make_sgtree
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class sgtree
|
||||
: public make_sgtree<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -919,7 +924,7 @@ class sgtree
|
||||
typedef typename make_sgtree
|
||||
<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
|
@@ -37,17 +37,17 @@ namespace intrusive {
|
||||
|
||||
/// @cond
|
||||
|
||||
template<class Node, class NodePtr, bool>
|
||||
struct root_plus_last
|
||||
template<class Header_Holder, class NodePtr, bool>
|
||||
struct header_holder_plus_last
|
||||
{
|
||||
Node root_;
|
||||
Header_Holder header_holder_;
|
||||
NodePtr last_;
|
||||
};
|
||||
|
||||
template<class Node, class NodePtr>
|
||||
struct root_plus_last<Node, NodePtr, false>
|
||||
template<class Header_Holder, class NodePtr>
|
||||
struct header_holder_plus_last<Header_Holder, NodePtr, false>
|
||||
{
|
||||
Node root_;
|
||||
Header_Holder header_holder_;
|
||||
};
|
||||
|
||||
struct slist_defaults
|
||||
@@ -57,6 +57,7 @@ struct slist_defaults
|
||||
static const bool linear = false;
|
||||
typedef std::size_t size_type;
|
||||
static const bool cache_last = false;
|
||||
typedef void header_holder_type;
|
||||
};
|
||||
|
||||
struct slist_bool_flags
|
||||
@@ -95,7 +96,7 @@ struct slist_bool_flags
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class SizeType, std::size_t BoolFlags>
|
||||
template<class ValueTraits, class SizeType, std::size_t BoolFlags, typename Header_Holder>
|
||||
#endif
|
||||
class slist_impl
|
||||
{
|
||||
@@ -115,11 +116,14 @@ class slist_impl
|
||||
typedef typename node_traits::node node;
|
||||
typedef typename node_traits::node_ptr node_ptr;
|
||||
typedef typename node_traits::const_node_ptr const_node_ptr;
|
||||
typedef Header_Holder header_holder_type;
|
||||
|
||||
static const bool constant_time_size = 0 != (BoolFlags & slist_bool_flags::constant_time_size_pos);
|
||||
static const bool stateful_value_traits = detail::is_stateful_value_traits<value_traits>::value;
|
||||
static const bool linear = 0 != (BoolFlags & slist_bool_flags::linear_pos);
|
||||
static const bool cache_last = 0 != (BoolFlags & slist_bool_flags::cache_last_pos);
|
||||
static const bool has_container_from_iterator =
|
||||
boost::is_same< header_holder_type, detail::default_header_holder< node_traits > >::value;
|
||||
|
||||
typedef typename detail::if_c
|
||||
< linear
|
||||
@@ -152,10 +156,10 @@ class slist_impl
|
||||
(linear ? const_node_ptr() : this->get_root_node()); }
|
||||
|
||||
node_ptr get_root_node()
|
||||
{ return pointer_traits<node_ptr>::pointer_to(data_.root_plus_size_.root_); }
|
||||
{ return data_.root_plus_size_.header_holder_.get_node(); }
|
||||
|
||||
const_node_ptr get_root_node() const
|
||||
{ return pointer_traits<const_node_ptr>::pointer_to(data_.root_plus_size_.root_); }
|
||||
{ return data_.root_plus_size_.header_holder_.get_node(); }
|
||||
|
||||
node_ptr get_last_node()
|
||||
{ return this->get_last_node(detail::bool_<cache_last>()); }
|
||||
@@ -197,9 +201,10 @@ class slist_impl
|
||||
}
|
||||
}
|
||||
|
||||
typedef header_holder_plus_last<header_holder_type, node_ptr, cache_last> header_holder_plus_last_t;
|
||||
struct root_plus_size
|
||||
: public size_traits
|
||||
, public root_plus_last<node, node_ptr, cache_last>
|
||||
, public header_holder_plus_last_t
|
||||
{};
|
||||
|
||||
struct data_t
|
||||
@@ -225,16 +230,6 @@ class slist_impl
|
||||
value_traits &priv_value_traits()
|
||||
{ return data_; }
|
||||
|
||||
protected:
|
||||
node &prot_root_node()
|
||||
{ return data_.root_plus_size_.root_; }
|
||||
|
||||
node const &prot_root_node() const
|
||||
{ return data_.root_plus_size_.root_; }
|
||||
|
||||
void prot_set_size(size_type s)
|
||||
{ data_.root_plus_size_.set_size(s); }
|
||||
|
||||
public:
|
||||
|
||||
typedef typename pointer_traits<node_ptr>::template
|
||||
@@ -1959,8 +1954,12 @@ class slist_impl
|
||||
//Obtaining the container from the end iterator is not possible with linear
|
||||
//singly linked lists (because "end" is represented by the null pointer)
|
||||
BOOST_STATIC_ASSERT(!linear);
|
||||
root_plus_size *r = detail::parent_from_member<root_plus_size, node>
|
||||
( boost::intrusive::detail::to_raw_pointer(end_iterator.pointed_node()), (&root_plus_size::root_));
|
||||
BOOST_STATIC_ASSERT((has_container_from_iterator));
|
||||
node_ptr p = end_iterator.pointed_node();
|
||||
header_holder_type* h = header_holder_type::get_holder(p);
|
||||
header_holder_plus_last_t* hpl = detail::parent_from_member< header_holder_plus_last_t, header_holder_type>
|
||||
(h, &header_holder_plus_last_t::header_holder_);
|
||||
root_plus_size* r = static_cast< root_plus_size* >(hpl);
|
||||
data_t *d = detail::parent_from_member<data_t, root_plus_size>
|
||||
( r, &data_t::root_plus_size_);
|
||||
slist_impl *s = detail::parent_from_member<slist_impl, data_t>(d, &slist_impl::data_);
|
||||
@@ -1971,31 +1970,31 @@ class slist_impl
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class SizeType, std::size_t BoolFlags>
|
||||
template<class ValueTraits, class SizeType, std::size_t BoolFlags, typename Header_Holder>
|
||||
#endif
|
||||
inline bool operator<
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(const slist_impl<T, Options...> &x, const slist_impl<T, Options...> &y)
|
||||
#else
|
||||
( const slist_impl<ValueTraits, SizeType, BoolFlags> &x
|
||||
, const slist_impl<ValueTraits, SizeType, BoolFlags> &y)
|
||||
( const slist_impl<ValueTraits, SizeType, BoolFlags, Header_Holder> &x
|
||||
, const slist_impl<ValueTraits, SizeType, BoolFlags, Header_Holder> &y)
|
||||
#endif
|
||||
{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
|
||||
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class SizeType, std::size_t BoolFlags>
|
||||
template<class ValueTraits, class SizeType, std::size_t BoolFlags, typename Header_Holder>
|
||||
#endif
|
||||
bool operator==
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(const slist_impl<T, Options...> &x, const slist_impl<T, Options...> &y)
|
||||
#else
|
||||
( const slist_impl<ValueTraits, SizeType, BoolFlags> &x
|
||||
, const slist_impl<ValueTraits, SizeType, BoolFlags> &y)
|
||||
( const slist_impl<ValueTraits, SizeType, BoolFlags, Header_Holder> &x
|
||||
, const slist_impl<ValueTraits, SizeType, BoolFlags, Header_Holder> &y)
|
||||
#endif
|
||||
{
|
||||
typedef slist_impl<ValueTraits, SizeType, BoolFlags> slist_type;
|
||||
typedef slist_impl<ValueTraits, SizeType, BoolFlags, Header_Holder> slist_type;
|
||||
typedef typename slist_type::const_iterator const_iterator;
|
||||
const bool C = slist_type::constant_time_size;
|
||||
if(C && x.size() != y.size()){
|
||||
@@ -2025,70 +2024,70 @@ bool operator==
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class SizeType, std::size_t BoolFlags>
|
||||
template<class ValueTraits, class SizeType, std::size_t BoolFlags, typename Header_Holder>
|
||||
#endif
|
||||
inline bool operator!=
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(const slist_impl<T, Options...> &x, const slist_impl<T, Options...> &y)
|
||||
#else
|
||||
( const slist_impl<ValueTraits, SizeType, BoolFlags> &x
|
||||
, const slist_impl<ValueTraits, SizeType, BoolFlags> &y)
|
||||
( const slist_impl<ValueTraits, SizeType, BoolFlags, Header_Holder> &x
|
||||
, const slist_impl<ValueTraits, SizeType, BoolFlags, Header_Holder> &y)
|
||||
#endif
|
||||
{ return !(x == y); }
|
||||
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class SizeType, std::size_t BoolFlags>
|
||||
template<class ValueTraits, class SizeType, std::size_t BoolFlags, typename Header_Holder>
|
||||
#endif
|
||||
inline bool operator>
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(const slist_impl<T, Options...> &x, const slist_impl<T, Options...> &y)
|
||||
#else
|
||||
( const slist_impl<ValueTraits, SizeType, BoolFlags> &x
|
||||
, const slist_impl<ValueTraits, SizeType, BoolFlags> &y)
|
||||
( const slist_impl<ValueTraits, SizeType, BoolFlags, Header_Holder> &x
|
||||
, const slist_impl<ValueTraits, SizeType, BoolFlags, Header_Holder> &y)
|
||||
#endif
|
||||
{ return y < x; }
|
||||
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class SizeType, std::size_t BoolFlags>
|
||||
template<class ValueTraits, class SizeType, std::size_t BoolFlags, typename Header_Holder>
|
||||
#endif
|
||||
inline bool operator<=
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(const slist_impl<T, Options...> &x, const slist_impl<T, Options...> &y)
|
||||
#else
|
||||
( const slist_impl<ValueTraits, SizeType, BoolFlags> &x
|
||||
, const slist_impl<ValueTraits, SizeType, BoolFlags> &y)
|
||||
( const slist_impl<ValueTraits, SizeType, BoolFlags, Header_Holder> &x
|
||||
, const slist_impl<ValueTraits, SizeType, BoolFlags, Header_Holder> &y)
|
||||
#endif
|
||||
{ return !(y < x); }
|
||||
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class SizeType, std::size_t BoolFlags>
|
||||
template<class ValueTraits, class SizeType, std::size_t BoolFlags, typename Header_Holder>
|
||||
#endif
|
||||
inline bool operator>=
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(const slist_impl<T, Options...> &x, const slist_impl<T, Options...> &y)
|
||||
#else
|
||||
( const slist_impl<ValueTraits, SizeType, BoolFlags> &x
|
||||
, const slist_impl<ValueTraits, SizeType, BoolFlags> &y)
|
||||
( const slist_impl<ValueTraits, SizeType, BoolFlags, Header_Holder> &x
|
||||
, const slist_impl<ValueTraits, SizeType, BoolFlags, Header_Holder> &y)
|
||||
#endif
|
||||
{ return !(x < y); }
|
||||
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class SizeType, std::size_t BoolFlags>
|
||||
template<class ValueTraits, class SizeType, std::size_t BoolFlags, typename Header_Holder>
|
||||
#endif
|
||||
inline void swap
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
(slist_impl<T, Options...> &x, slist_impl<T, Options...> &y)
|
||||
#else
|
||||
( slist_impl<ValueTraits, SizeType, BoolFlags> &x
|
||||
, slist_impl<ValueTraits, SizeType, BoolFlags> &y)
|
||||
( slist_impl<ValueTraits, SizeType, BoolFlags, Header_Holder> &x
|
||||
, slist_impl<ValueTraits, SizeType, BoolFlags, Header_Holder> &y)
|
||||
#endif
|
||||
{ x.swap(y); }
|
||||
|
||||
@@ -2097,7 +2096,7 @@ inline void swap
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void, class O3 = void, class O4 = void, class O5 = void>
|
||||
template<class T, class O1 = void, class O2 = void, class O3 = void, class O4 = void, class O5 = void, class O6 = void>
|
||||
#endif
|
||||
struct make_slist
|
||||
{
|
||||
@@ -2105,19 +2104,22 @@ struct make_slist
|
||||
typedef typename pack_options
|
||||
< slist_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4, O5
|
||||
O1, O2, O3, O4, O5, O6
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
>::type packed_options;
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
typedef slist_impl
|
||||
< value_traits
|
||||
, typename packed_options::size_type
|
||||
, (std::size_t(packed_options::linear)*slist_bool_flags::linear_pos)
|
||||
|(std::size_t(packed_options::constant_time_size)*slist_bool_flags::constant_time_size_pos)
|
||||
|(std::size_t(packed_options::cache_last)*slist_bool_flags::cache_last_pos)
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -2127,14 +2129,14 @@ struct make_slist
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
template<class T, class O1, class O2, class O3, class O4, class O5>
|
||||
template<class T, class O1, class O2, class O3, class O4, class O5, class O6>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class slist
|
||||
: public make_slist<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4, O5
|
||||
O1, O2, O3, O4, O5, O6
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -2143,7 +2145,7 @@ class slist
|
||||
typedef typename make_slist
|
||||
<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4, O5
|
||||
O1, O2, O3, O4, O5, O6
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
|
@@ -36,15 +36,15 @@ namespace intrusive {
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize>
|
||||
template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
class splay_set_impl
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
: public splaytree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize>
|
||||
: public splaytree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, Header_Holder>
|
||||
#endif
|
||||
{
|
||||
/// @cond
|
||||
typedef splaytree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize> tree_type;
|
||||
typedef splaytree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, Header_Holder> tree_type;
|
||||
BOOST_MOVABLE_BUT_NOT_COPYABLE(splay_set_impl)
|
||||
|
||||
typedef tree_type implementation_defined;
|
||||
@@ -418,7 +418,8 @@ void swap(splay_set_impl<T, Options...> &x, splay_set_impl<T, Options...> &y);
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void
|
||||
, class O3 = void, class O4 = void>
|
||||
, class O3 = void, class O4 = void
|
||||
, class O5 = void>
|
||||
#endif
|
||||
struct make_splay_set
|
||||
{
|
||||
@@ -426,7 +427,7 @@ struct make_splay_set
|
||||
typedef typename pack_options
|
||||
< splaytree_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -434,12 +435,15 @@ struct make_splay_set
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef splay_set_impl
|
||||
< value_traits
|
||||
, typename packed_options::compare
|
||||
, typename packed_options::size_type
|
||||
, packed_options::constant_time_size
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -447,14 +451,14 @@ struct make_splay_set
|
||||
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class splay_set
|
||||
: public make_splay_set<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -463,7 +467,7 @@ class splay_set
|
||||
typedef typename make_splay_set
|
||||
<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -527,15 +531,15 @@ class splay_set
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize>
|
||||
template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
class splay_multiset_impl
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
: public splaytree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize>
|
||||
: public splaytree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, Header_Holder>
|
||||
#endif
|
||||
{
|
||||
/// @cond
|
||||
typedef splaytree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize> tree_type;
|
||||
typedef splaytree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, Header_Holder> tree_type;
|
||||
|
||||
BOOST_MOVABLE_BUT_NOT_COPYABLE(splay_multiset_impl)
|
||||
typedef tree_type implementation_defined;
|
||||
@@ -871,7 +875,8 @@ void swap(splay_multiset_impl<T, Options...> &x, splay_multiset_impl<T, Options.
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void
|
||||
, class O3 = void, class O4 = void>
|
||||
, class O3 = void, class O4 = void
|
||||
, class O5 = void>
|
||||
#endif
|
||||
struct make_splay_multiset
|
||||
{
|
||||
@@ -879,7 +884,7 @@ struct make_splay_multiset
|
||||
typedef typename pack_options
|
||||
< splaytree_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -887,12 +892,15 @@ struct make_splay_multiset
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef splay_multiset_impl
|
||||
< value_traits
|
||||
, typename packed_options::compare
|
||||
, typename packed_options::size_type
|
||||
, packed_options::constant_time_size
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -901,14 +909,14 @@ struct make_splay_multiset
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class splay_multiset
|
||||
: public make_splay_multiset<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -916,7 +924,7 @@ class splay_multiset
|
||||
{
|
||||
typedef typename make_splay_multiset<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
|
@@ -44,6 +44,7 @@ struct splaytree_defaults
|
||||
static const bool constant_time_size = true;
|
||||
typedef std::size_t size_type;
|
||||
typedef void compare;
|
||||
typedef void header_holder_type;
|
||||
};
|
||||
|
||||
/// @endcond
|
||||
@@ -64,18 +65,19 @@ struct splaytree_defaults
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class VoidOrKeyComp, class SizeType, bool ConstantTimeSize>
|
||||
template<class ValueTraits, class VoidOrKeyComp, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
class splaytree_impl
|
||||
/// @cond
|
||||
: public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, SplayTreeAlgorithms>
|
||||
: public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, SplayTreeAlgorithms, Header_Holder>
|
||||
/// @endcond
|
||||
{
|
||||
public:
|
||||
typedef ValueTraits value_traits;
|
||||
/// @cond
|
||||
typedef bstree_impl< ValueTraits, VoidOrKeyComp, SizeType
|
||||
, ConstantTimeSize, SplayTreeAlgorithms> tree_type;
|
||||
, ConstantTimeSize, SplayTreeAlgorithms
|
||||
, Header_Holder> tree_type;
|
||||
typedef tree_type implementation_defined;
|
||||
/// @endcond
|
||||
|
||||
@@ -513,7 +515,8 @@ void swap(splaytree_impl<T, Options...> &x, splaytree_impl<T, Options...> &y);
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void
|
||||
, class O3 = void, class O4 = void>
|
||||
, class O3 = void, class O4 = void
|
||||
, class O5 = void>
|
||||
#endif
|
||||
struct make_splaytree
|
||||
{
|
||||
@@ -521,7 +524,7 @@ struct make_splaytree
|
||||
typedef typename pack_options
|
||||
< splaytree_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -529,12 +532,15 @@ struct make_splaytree
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef splaytree_impl
|
||||
< value_traits
|
||||
, typename packed_options::compare
|
||||
, typename packed_options::size_type
|
||||
, packed_options::constant_time_size
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -544,14 +550,14 @@ struct make_splaytree
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class splaytree
|
||||
: public make_splaytree<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -560,7 +566,7 @@ class splaytree
|
||||
typedef typename make_splaytree
|
||||
<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
|
@@ -48,6 +48,7 @@ struct treap_defaults
|
||||
typedef std::size_t size_type;
|
||||
typedef void compare;
|
||||
typedef void priority;
|
||||
typedef void header_holder_type;
|
||||
};
|
||||
|
||||
/// @endcond
|
||||
@@ -68,16 +69,16 @@ struct treap_defaults
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class VoidOrKeyComp, class VoidOrPrioComp, class SizeType, bool ConstantTimeSize>
|
||||
template<class ValueTraits, class VoidOrKeyComp, class VoidOrPrioComp, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
class treap_impl
|
||||
/// @cond
|
||||
: public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, BsTreeAlgorithms>
|
||||
: public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, BsTreeAlgorithms, Header_Holder>
|
||||
, public detail::ebo_functor_holder
|
||||
< typename get_prio
|
||||
< VoidOrPrioComp
|
||||
, typename bstree_impl
|
||||
<ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, BsTreeAlgorithms>::value_type>::type
|
||||
<ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, BsTreeAlgorithms, Header_Holder>::value_type>::type
|
||||
>
|
||||
/// @endcond
|
||||
{
|
||||
@@ -85,7 +86,8 @@ class treap_impl
|
||||
typedef ValueTraits value_traits;
|
||||
/// @cond
|
||||
typedef bstree_impl< ValueTraits, VoidOrKeyComp, SizeType
|
||||
, ConstantTimeSize, BsTreeAlgorithms> tree_type;
|
||||
, ConstantTimeSize, BsTreeAlgorithms
|
||||
, Header_Holder> tree_type;
|
||||
typedef tree_type implementation_defined;
|
||||
typedef get_prio
|
||||
< VoidOrPrioComp
|
||||
@@ -1062,14 +1064,15 @@ void swap(treap_impl<T, Options...> &x, treap_impl<T, Options...> &y);
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void
|
||||
, class O3 = void, class O4 = void>
|
||||
, class O3 = void, class O4 = void
|
||||
, class O5 = void>
|
||||
#endif
|
||||
struct make_treap
|
||||
{
|
||||
typedef typename pack_options
|
||||
< treap_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -1077,6 +1080,8 @@ struct make_treap
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef treap_impl
|
||||
< value_traits
|
||||
@@ -1084,6 +1089,7 @@ struct make_treap
|
||||
, typename packed_options::priority
|
||||
, typename packed_options::size_type
|
||||
, packed_options::constant_time_size
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -1092,14 +1098,14 @@ struct make_treap
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class treap
|
||||
: public make_treap<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -1108,7 +1114,7 @@ class treap
|
||||
typedef typename make_treap
|
||||
<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
|
@@ -36,16 +36,16 @@ namespace intrusive {
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class VoidOrKeyComp, class VoidOrPrioComp, class SizeType, bool ConstantTimeSize>
|
||||
template<class ValueTraits, class VoidOrKeyComp, class VoidOrPrioComp, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
class treap_set_impl
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
: public treap_impl<ValueTraits, VoidOrKeyComp, VoidOrPrioComp, SizeType, ConstantTimeSize>
|
||||
: public treap_impl<ValueTraits, VoidOrKeyComp, VoidOrPrioComp, SizeType, ConstantTimeSize, Header_Holder>
|
||||
#endif
|
||||
{
|
||||
/// @cond
|
||||
public:
|
||||
typedef treap_impl<ValueTraits, VoidOrKeyComp, VoidOrPrioComp, SizeType, ConstantTimeSize> tree_type;
|
||||
typedef treap_impl<ValueTraits, VoidOrKeyComp, VoidOrPrioComp, SizeType, ConstantTimeSize, Header_Holder> tree_type;
|
||||
BOOST_MOVABLE_BUT_NOT_COPYABLE(treap_set_impl)
|
||||
|
||||
typedef tree_type implementation_defined;
|
||||
@@ -423,14 +423,15 @@ class treap_set_impl
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void
|
||||
, class O3 = void, class O4 = void>
|
||||
, class O3 = void, class O4 = void
|
||||
, class O5 = void>
|
||||
#endif
|
||||
struct make_treap_set
|
||||
{
|
||||
typedef typename pack_options
|
||||
< treap_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -438,6 +439,8 @@ struct make_treap_set
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef treap_set_impl
|
||||
< value_traits
|
||||
@@ -445,6 +448,7 @@ struct make_treap_set
|
||||
, typename packed_options::priority
|
||||
, typename packed_options::size_type
|
||||
, packed_options::constant_time_size
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -453,14 +457,14 @@ struct make_treap_set
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class treap_set
|
||||
: public make_treap_set<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -469,7 +473,7 @@ class treap_set
|
||||
typedef typename make_treap_set
|
||||
<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -536,15 +540,15 @@ class treap_set
|
||||
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class ValueTraits, class VoidOrKeyComp, class VoidOrPrioComp, class SizeType, bool ConstantTimeSize>
|
||||
template<class ValueTraits, class VoidOrKeyComp, class VoidOrPrioComp, class SizeType, bool ConstantTimeSize, typename Header_Holder>
|
||||
#endif
|
||||
class treap_multiset_impl
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
: public treap_impl<ValueTraits, VoidOrKeyComp, VoidOrPrioComp, SizeType, ConstantTimeSize>
|
||||
: public treap_impl<ValueTraits, VoidOrKeyComp, VoidOrPrioComp, SizeType, ConstantTimeSize, Header_Holder>
|
||||
#endif
|
||||
{
|
||||
/// @cond
|
||||
typedef treap_impl<ValueTraits, VoidOrKeyComp, VoidOrPrioComp, SizeType, ConstantTimeSize> tree_type;
|
||||
typedef treap_impl<ValueTraits, VoidOrKeyComp, VoidOrPrioComp, SizeType, ConstantTimeSize, Header_Holder> tree_type;
|
||||
BOOST_MOVABLE_BUT_NOT_COPYABLE(treap_multiset_impl)
|
||||
|
||||
typedef tree_type implementation_defined;
|
||||
@@ -889,14 +893,15 @@ class treap_multiset_impl
|
||||
template<class T, class ...Options>
|
||||
#else
|
||||
template<class T, class O1 = void, class O2 = void
|
||||
, class O3 = void, class O4 = void>
|
||||
, class O3 = void, class O4 = void
|
||||
, class O5 = void>
|
||||
#endif
|
||||
struct make_treap_multiset
|
||||
{
|
||||
typedef typename pack_options
|
||||
< treap_defaults,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -904,6 +909,8 @@ struct make_treap_multiset
|
||||
|
||||
typedef typename detail::get_value_traits
|
||||
<T, typename packed_options::proto_value_traits>::type value_traits;
|
||||
typedef typename detail::get_header_holder_type
|
||||
< value_traits, typename packed_options::header_holder_type >::type header_holder_type;
|
||||
|
||||
typedef treap_multiset_impl
|
||||
< value_traits
|
||||
@@ -911,6 +918,7 @@ struct make_treap_multiset
|
||||
, typename packed_options::priority
|
||||
, typename packed_options::size_type
|
||||
, packed_options::constant_time_size
|
||||
, header_holder_type
|
||||
> implementation_defined;
|
||||
/// @endcond
|
||||
typedef implementation_defined type;
|
||||
@@ -919,14 +927,14 @@ struct make_treap_multiset
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
class treap_multiset
|
||||
: public make_treap_multiset<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -935,7 +943,7 @@ class treap_multiset
|
||||
typedef typename make_treap_multiset
|
||||
<T,
|
||||
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
|
@@ -14,19 +14,20 @@
|
||||
#include <boost/intrusive/avl_set.hpp>
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
#include "itestvalue.hpp"
|
||||
#include "bptr_value.hpp"
|
||||
#include "smart_ptr.hpp"
|
||||
#include "generic_multiset_test.hpp"
|
||||
|
||||
namespace boost { namespace intrusive { namespace test {
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_insert_before<boost::intrusive::avl_multiset<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -60,6 +61,10 @@ struct hooks
|
||||
> nonhook_node_member_type;
|
||||
};
|
||||
|
||||
// container generator with void node allocator
|
||||
template < bool Default_Holder >
|
||||
struct GetContainer_With_Holder
|
||||
{
|
||||
template< class ValueType
|
||||
, class Option1 =void
|
||||
, class Option2 =void
|
||||
@@ -74,8 +79,35 @@ struct GetContainer
|
||||
, Option3
|
||||
> 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< avltree_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::avl_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
|
||||
{
|
||||
public:
|
||||
@@ -88,7 +120,7 @@ class test_main_template
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
@@ -97,21 +129,21 @@ class test_main_template
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_multiset < nonhook_node_member_value_traits< value_type,
|
||||
typename hooks<VoidPointer>::nonhook_node_member_type,
|
||||
&value_type::nhn_member_,
|
||||
safe_link
|
||||
>,
|
||||
GetContainer
|
||||
GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<class VoidPointer>
|
||||
class test_main_template<VoidPointer, false>
|
||||
template<class VoidPointer, bool Default_Holder>
|
||||
class test_main_template<VoidPointer, false, Default_Holder>
|
||||
{
|
||||
public:
|
||||
int operator()()
|
||||
@@ -123,7 +155,7 @@ class test_main_template<VoidPointer, false>
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||
@@ -133,14 +165,14 @@ class test_main_template<VoidPointer, false>
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_multiset < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::auto_base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||
@@ -150,18 +182,70 @@ class test_main_template<VoidPointer, false>
|
||||
, &value_type::auto_node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
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< avltree_defaults, Option1, Option2, Option3 >::type packed_options;
|
||||
typedef typename packed_options::compare compare_option;
|
||||
|
||||
typedef boost::intrusive::avl_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< AVLTree_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* [] )
|
||||
{
|
||||
test_main_template<void*, false>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false>()();
|
||||
test_main_template<void*, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
|
||||
// test (plain/smart pointers) x (nonconst/const size) x (void node allocator)
|
||||
test_main_template<void*, false, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false, 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();
|
||||
}
|
||||
|
||||
|
@@ -13,19 +13,20 @@
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/avl_set.hpp>
|
||||
#include "itestvalue.hpp"
|
||||
#include "bptr_value.hpp"
|
||||
#include "smart_ptr.hpp"
|
||||
#include "generic_set_test.hpp"
|
||||
|
||||
namespace boost { namespace intrusive { namespace test {
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_insert_before<boost::intrusive::avl_set<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -60,6 +61,10 @@ struct hooks
|
||||
> nonhook_node_member_type;
|
||||
};
|
||||
|
||||
// container generator with void node allocator
|
||||
template < bool Default_Holder >
|
||||
struct GetContainer_With_Holder
|
||||
{
|
||||
template< class ValueType
|
||||
, class Option1 =void
|
||||
, class Option2 =void
|
||||
@@ -74,8 +79,35 @@ struct GetContainer
|
||||
, Option3
|
||||
> 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< avltree_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::avl_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
|
||||
{
|
||||
public:
|
||||
@@ -88,7 +120,7 @@ class test_main_template
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_set < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
@@ -97,21 +129,21 @@ class test_main_template
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_set < nonhook_node_member_value_traits< value_type,
|
||||
typename hooks<VoidPointer>::nonhook_node_member_type,
|
||||
&value_type::nhn_member_,
|
||||
safe_link
|
||||
>,
|
||||
GetContainer
|
||||
GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<class VoidPointer>
|
||||
class test_main_template<VoidPointer, false>
|
||||
template<class VoidPointer, bool Default_Holder>
|
||||
class test_main_template<VoidPointer, false, Default_Holder>
|
||||
{
|
||||
public:
|
||||
int operator()()
|
||||
@@ -123,7 +155,7 @@ class test_main_template<VoidPointer, false>
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_set < typename detail::get_member_value_traits
|
||||
@@ -133,14 +165,14 @@ class test_main_template<VoidPointer, false>
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_set < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::auto_base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_set < typename detail::get_member_value_traits
|
||||
@@ -150,19 +182,70 @@ class test_main_template<VoidPointer, false>
|
||||
, &value_type::auto_node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
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< avltree_defaults, Option1, Option2, Option3 >::type packed_options;
|
||||
typedef typename packed_options::compare compare_option;
|
||||
|
||||
typedef boost::intrusive::avl_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< AVLTree_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* [] )
|
||||
{
|
||||
test_main_template<void*, false>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false>()();
|
||||
test_main_template<void*, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
|
||||
// test (plain/smart pointers) x (nonconst/const size) x (void node allocator)
|
||||
test_main_template<void*, false, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false, 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();
|
||||
}
|
||||
|
403
test/bounded_pointer.hpp
Normal file
403
test/bounded_pointer.hpp
Normal file
@@ -0,0 +1,403 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Matei David 2014
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/intrusive for documentation.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOUNDED_POINTER_HPP
|
||||
#define BOUNDED_POINTER_HPP
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
|
||||
#define CONST_CONVERSIONS(_type, _t) \
|
||||
operator const _type< typename boost::add_const< _t >::type >& () const \
|
||||
{ return *reinterpret_cast< const _type< typename boost::add_const< _t >::type >* >(this); } \
|
||||
operator _type< typename boost::add_const< _t >::type >& () \
|
||||
{ return *reinterpret_cast< _type< typename boost::add_const< _t >::type >* >(this); } \
|
||||
\
|
||||
const _type< typename boost::remove_const< _t >::type >& unconst() const \
|
||||
{ return *reinterpret_cast< const _type< typename boost::remove_const< _t >::type >* >(this); } \
|
||||
_type< typename boost::remove_const< _t >::type >& unconst() \
|
||||
{ return *reinterpret_cast< _type< typename boost::remove_const< _t >::type >* >(this); }
|
||||
|
||||
|
||||
template < typename T >
|
||||
class Bounded_Pointer;
|
||||
template < typename T >
|
||||
class Bounded_Reference;
|
||||
template < typename T >
|
||||
class Bounded_Allocator;
|
||||
|
||||
|
||||
template < typename T >
|
||||
class Bounded_Pointer
|
||||
{
|
||||
public:
|
||||
typedef typename boost::remove_const< T >::type mut_val_t;
|
||||
typedef const mut_val_t const_val_t;
|
||||
|
||||
template <class U>
|
||||
struct rebind
|
||||
{
|
||||
typedef typename boost::mpl::if_<
|
||||
boost::is_same<
|
||||
typename boost::remove_const< U >::type,
|
||||
typename boost::remove_const< T >::type >,
|
||||
Bounded_Pointer< U >,
|
||||
U*
|
||||
>::type type;
|
||||
};
|
||||
|
||||
Bounded_Pointer() : _offset(255) {}
|
||||
Bounded_Pointer(const Bounded_Pointer& other) : _offset(other._offset) {}
|
||||
Bounded_Pointer& operator = (const Bounded_Pointer& other) { _offset = other._offset; return *this; }
|
||||
CONST_CONVERSIONS(Bounded_Pointer, T)
|
||||
|
||||
static mut_val_t* base()
|
||||
{
|
||||
assert(Bounded_Allocator< mut_val_t >::inited());
|
||||
return &Bounded_Allocator< mut_val_t >::_base[0];
|
||||
}
|
||||
|
||||
operator bool() const { return _offset != 255; }
|
||||
|
||||
T* raw() const { return base() + _offset; }
|
||||
Bounded_Reference< T > operator * () const { return Bounded_Reference< T >(*this); }
|
||||
T* operator -> () const { return raw(); }
|
||||
Bounded_Pointer& operator ++ () { ++_offset; return *this; }
|
||||
Bounded_Pointer operator ++ (int) { Bounded_Pointer res(*this); ++(*this); return res; }
|
||||
|
||||
template < typename U >
|
||||
// typename boost::enable_if< boost::is_same< typename boost::remove_const< U >::type,
|
||||
// typename boost::remove_const< T >::type >, int >::type = 42 >
|
||||
bool operator == (const Bounded_Pointer< U >& rhs) const
|
||||
{
|
||||
return _offset == rhs._offset;
|
||||
}
|
||||
template < typename U >
|
||||
// typename boost::enable_if< boost::is_same< typename boost::remove_const< U >::type,
|
||||
// typename boost::remove_const< T >::type >, int >::type = 42 >
|
||||
bool operator < (const Bounded_Pointer< U >& rhs) const
|
||||
{
|
||||
return _offset < rhs._offset;
|
||||
}
|
||||
|
||||
friend std::ostream& operator << (std::ostream& os, const Bounded_Pointer< T >& ptr)
|
||||
{
|
||||
os << static_cast< int >(ptr._offset);
|
||||
return os;
|
||||
}
|
||||
private:
|
||||
template <typename> friend class Bounded_Pointer;
|
||||
friend class Bounded_Reference< T >;
|
||||
friend class Bounded_Allocator< T >;
|
||||
|
||||
uint8_t _offset;
|
||||
}; // class Bounded_Pointer
|
||||
|
||||
template < typename T >
|
||||
class Bounded_Reference
|
||||
{
|
||||
public:
|
||||
typedef typename boost::remove_const< T >::type mut_val_t;
|
||||
typedef const mut_val_t const_val_t;
|
||||
|
||||
Bounded_Reference() : _offset(255) {}
|
||||
Bounded_Reference(const Bounded_Reference& other) : _offset(other._offset) {}
|
||||
CONST_CONVERSIONS(Bounded_Reference, T)
|
||||
|
||||
T& raw() const { assert(_offset != 255); return *(Bounded_Pointer< T >::base() + _offset); }
|
||||
operator T& () const { assert(_offset != 255); return raw(); }
|
||||
Bounded_Pointer< T > operator & () const { assert(_offset != 255); Bounded_Pointer< T > res; res._offset = _offset; return res; }
|
||||
|
||||
Bounded_Reference& operator = (const T& rhs) { assert(_offset != 255); raw() = rhs; return *this; }
|
||||
Bounded_Reference& operator = (const Bounded_Reference& rhs) { assert(_offset != 255); raw() = rhs.raw(); return *this; }
|
||||
|
||||
friend std::ostream& operator << (std::ostream& os, const Bounded_Reference< T >& ref)
|
||||
{
|
||||
os << "[bptr=" << static_cast< int >(ref._offset) << ",deref=" << ref.raw() << "]";
|
||||
return os;
|
||||
}
|
||||
|
||||
// the copy asop is shallow; we need swap overload to shuffle a vector of references
|
||||
friend void swap(Bounded_Reference& lhs, Bounded_Reference& rhs)
|
||||
{
|
||||
std::swap(lhs._offset, rhs._offset);
|
||||
}
|
||||
|
||||
private:
|
||||
friend class Bounded_Pointer< T >;
|
||||
Bounded_Reference(Bounded_Pointer< T > bptr) : _offset(bptr._offset) { assert(_offset != 255); }
|
||||
|
||||
uint8_t _offset;
|
||||
}; // class Bounded_Reference
|
||||
|
||||
template < typename T >
|
||||
class Bounded_Allocator
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef Bounded_Pointer< T > pointer;
|
||||
|
||||
pointer allocate(size_t n)
|
||||
{
|
||||
assert(inited());
|
||||
assert(n == 1);
|
||||
pointer p;
|
||||
uint8_t i;
|
||||
for (i = 0; i < 255 and _in_use[i]; ++i);
|
||||
assert(i < 255);
|
||||
p._offset = i;
|
||||
_in_use[p._offset] = true;
|
||||
//std::clog << "allocating node " << static_cast< int >(p._offset) << "\n";
|
||||
return p;
|
||||
}
|
||||
void deallocate(pointer p, size_t n)
|
||||
{
|
||||
assert(inited());
|
||||
assert(n == 1);
|
||||
assert(_in_use[p._offset]);
|
||||
//std::clog << "deallocating node " << static_cast< int >(p._offset) << "\n";
|
||||
_in_use[p._offset] = false;
|
||||
}
|
||||
|
||||
// static methods
|
||||
static void init()
|
||||
{
|
||||
assert(_in_use.empty());
|
||||
_in_use = std::vector< bool >(255, false);
|
||||
// allocate non-constructed storage
|
||||
_base = static_cast< T* >(::operator new [] (255 * sizeof(T)));
|
||||
}
|
||||
static bool inited()
|
||||
{
|
||||
return _in_use.size() == 255;
|
||||
}
|
||||
static bool is_clear()
|
||||
{
|
||||
assert(inited());
|
||||
for (uint8_t i = 0; i < 255; ++i)
|
||||
{
|
||||
if (_in_use[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static void destroy()
|
||||
{
|
||||
// deallocate storage without destructors
|
||||
::operator delete [] (_base);
|
||||
_in_use.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
friend class Bounded_Pointer< T >;
|
||||
friend class Bounded_Pointer< const T >;
|
||||
static T* _base;
|
||||
static std::vector< bool > _in_use;
|
||||
}; // class Bounded_Allocator
|
||||
|
||||
template < typename T >
|
||||
T* Bounded_Allocator< T >::_base = NULL;
|
||||
|
||||
template < typename T >
|
||||
std::vector< bool > Bounded_Allocator< T >::_in_use;
|
||||
|
||||
|
||||
template < typename T >
|
||||
class Bounded_Reference_Cont
|
||||
: private std::vector< Bounded_Reference< T > >
|
||||
{
|
||||
private:
|
||||
typedef T val_type;
|
||||
typedef std::vector< Bounded_Reference< T > > Base;
|
||||
typedef Bounded_Allocator< T > allocator_type;
|
||||
typedef Bounded_Pointer< T > pointer;
|
||||
|
||||
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()
|
||||
{
|
||||
for (size_t i = 0; i < n; ++i)
|
||||
{
|
||||
pointer p = _allocator.allocate(1);
|
||||
new (p.raw()) val_type();
|
||||
Base::push_back(*p);
|
||||
}
|
||||
}
|
||||
Bounded_Reference_Cont(const Bounded_Reference_Cont& other) : Base(), _allocator(other._allocator)
|
||||
{
|
||||
//std::clog << "copying values container\n";
|
||||
*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);
|
||||
new (p.raw()) val_type(*it);
|
||||
Base::push_back(*p);
|
||||
}
|
||||
}
|
||||
~Bounded_Reference_Cont()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
while (not Base::empty())
|
||||
{
|
||||
pointer p = &Base::back();
|
||||
p->~val_type();
|
||||
_allocator.deallocate(p, 1);
|
||||
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:
|
||||
allocator_type _allocator;
|
||||
}; // class Bounded_Reference_Cont
|
||||
|
||||
template < typename T >
|
||||
class Bounded_Pointer_Holder
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef Bounded_Pointer< value_type > pointer;
|
||||
typedef Bounded_Pointer< const value_type > const_pointer;
|
||||
typedef Bounded_Allocator< value_type > allocator_type;
|
||||
|
||||
Bounded_Pointer_Holder() : _ptr(allocator_type().allocate(1))
|
||||
{
|
||||
new (_ptr.raw()) value_type();
|
||||
}
|
||||
~Bounded_Pointer_Holder()
|
||||
{
|
||||
_ptr->~value_type();
|
||||
allocator_type().deallocate(_ptr, 1);
|
||||
}
|
||||
|
||||
const_pointer get_node () const { return _ptr; }
|
||||
pointer get_node () { return _ptr; }
|
||||
|
||||
private:
|
||||
const pointer _ptr;
|
||||
}; // class Bounded_Pointer_Holder
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace intrusive
|
||||
{
|
||||
|
||||
template < typename T >
|
||||
struct pointer_traits< Bounded_Pointer< T > >
|
||||
{
|
||||
typedef T element_type;
|
||||
typedef Bounded_Pointer< T > pointer;
|
||||
typedef Bounded_Pointer< const T > const_pointer;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef Bounded_Reference< T > reference;
|
||||
|
||||
template <class U>
|
||||
struct rebind_pointer
|
||||
{
|
||||
typedef typename Bounded_Pointer< T >::template rebind< U >::type type;
|
||||
};
|
||||
|
||||
static pointer pointer_to(reference r) { return &r; }
|
||||
static pointer const_cast_from(const_pointer cptr) { return cptr.unconst(); }
|
||||
};
|
||||
|
||||
} // namespace intrusive
|
||||
} // namespace boost
|
||||
|
||||
template < typename T, typename U >
|
||||
// typename boost::enable_if< boost::is_same< typename boost::remove_const< T >::type,
|
||||
// typename boost::remove_const< U >::type >, int >::type = 42 >
|
||||
bool operator != (const Bounded_Pointer< T >& lhs, const Bounded_Pointer< U >& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
template < typename T >
|
||||
bool operator == (const Bounded_Pointer< T >& lhs, const void* p)
|
||||
{
|
||||
assert(!p);
|
||||
return lhs == Bounded_Pointer< T >();
|
||||
}
|
||||
template < typename T >
|
||||
bool operator == (const void* p, const Bounded_Pointer< T >& rhs)
|
||||
{
|
||||
assert(!p);
|
||||
return Bounded_Pointer< T >() == rhs;
|
||||
}
|
||||
template < typename T >
|
||||
bool operator != (const Bounded_Pointer< T >& lhs, const void* p)
|
||||
{
|
||||
assert(!p);
|
||||
return lhs != Bounded_Pointer< T >();
|
||||
}
|
||||
template < typename T >
|
||||
bool operator != (const void* p, const Bounded_Pointer< T >& rhs)
|
||||
{
|
||||
assert(!p);
|
||||
return Bounded_Pointer< T >() != rhs;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
255
test/bptr_value.hpp
Normal file
255
test/bptr_value.hpp
Normal file
@@ -0,0 +1,255 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Matei David 2014
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/intrusive for documentation.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_INTRUSIVE_BPTR_VALUE_HPP
|
||||
#define BOOST_INTRUSIVE_BPTR_VALUE_HPP
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/intrusive/list.hpp>
|
||||
#include "bounded_pointer.hpp"
|
||||
#include "common_functors.hpp"
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace intrusive
|
||||
{
|
||||
|
||||
struct BPtr_Value
|
||||
{
|
||||
static const bool constant_time_size = true;
|
||||
|
||||
BPtr_Value(int value = 42) : value_(value) {}
|
||||
//BPtr_Value(const BPtr_Value& rhs) = delete;
|
||||
BPtr_Value(const BPtr_Value& rhs) : value_(rhs.value_) {}
|
||||
//BPtr_Value(BPtr_Value&&) = delete;
|
||||
~BPtr_Value()
|
||||
{
|
||||
if (is_linked())
|
||||
{
|
||||
std::cerr << "BPtr_Value dtor: destructing linked value: &=" << (void*)this << "\n";
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
// testvalue is used in std::vector and thus prev and next
|
||||
// have to be handled appropriately when copied:
|
||||
BPtr_Value& operator = (const BPtr_Value& src)
|
||||
{
|
||||
if (is_linked())
|
||||
{
|
||||
std::cerr << "BPtr_Value asop: assigning to linked value: &=" << (void*)this << ", src=" << (void*)&src << "\n";
|
||||
assert(false);
|
||||
}
|
||||
value_ = src.value_;
|
||||
//_previous = src._previous;
|
||||
//_next = src._next;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// value
|
||||
int value_;
|
||||
|
||||
// list node hooks
|
||||
Bounded_Pointer< BPtr_Value > _previous;
|
||||
Bounded_Pointer< BPtr_Value > _next;
|
||||
// tree node hooks
|
||||
Bounded_Pointer< BPtr_Value > _parent;
|
||||
Bounded_Pointer< BPtr_Value > _l_child;
|
||||
Bounded_Pointer< BPtr_Value > _r_child;
|
||||
char _extra;
|
||||
|
||||
bool is_linked() const { return _previous or _next or _parent or _l_child or _r_child; }
|
||||
|
||||
friend bool operator< (const BPtr_Value &other1, const BPtr_Value &other2)
|
||||
{ return other1.value_ < other2.value_; }
|
||||
|
||||
friend bool operator< (int other1, const BPtr_Value &other2)
|
||||
{ return other1 < other2.value_; }
|
||||
|
||||
friend bool operator< (const BPtr_Value &other1, int other2)
|
||||
{ return other1.value_ < other2; }
|
||||
|
||||
friend bool operator== (const BPtr_Value &other1, const BPtr_Value &other2)
|
||||
{ return other1.value_ == other2.value_; }
|
||||
|
||||
friend bool operator== (int other1, const BPtr_Value &other2)
|
||||
{ return other1 == other2.value_; }
|
||||
|
||||
friend bool operator== (const BPtr_Value &other1, int other2)
|
||||
{ return other1.value_ == other2; }
|
||||
|
||||
friend bool operator!= (const BPtr_Value &other1, const BPtr_Value &other2)
|
||||
{ return !(other1 == other2); }
|
||||
|
||||
friend bool operator!= (int other1, const BPtr_Value &other2)
|
||||
{ return !(other1 == other2.value_); }
|
||||
|
||||
friend bool operator!= (const BPtr_Value &other1, int other2)
|
||||
{ return !(other1.value_ == other2); }
|
||||
|
||||
friend std::ostream& operator << (std::ostream& os, const BPtr_Value& v)
|
||||
{
|
||||
os << v.value_;
|
||||
return os;
|
||||
}
|
||||
}; // class BPtr_Value
|
||||
|
||||
template < typename Node_Algorithms >
|
||||
void swap_nodes(Bounded_Reference< BPtr_Value > lhs,
|
||||
Bounded_Reference< BPtr_Value > rhs)
|
||||
{
|
||||
Node_Algorithms::swap_nodes(
|
||||
boost::intrusive::pointer_traits< Bounded_Pointer< BPtr_Value > >::pointer_to(lhs),
|
||||
boost::intrusive::pointer_traits< Bounded_Pointer< BPtr_Value > >::pointer_to(rhs));
|
||||
}
|
||||
|
||||
struct List_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_previous(const_node_ptr p) { return p->_previous; }
|
||||
static void set_previous(node_ptr p, node_ptr prev) { p->_previous = prev; }
|
||||
static node_ptr get_next(const_node_ptr p) { return p->_next; }
|
||||
static void set_next(node_ptr p, node_ptr next) { p->_next = next; }
|
||||
};
|
||||
|
||||
struct RBTree_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;
|
||||
typedef char color;
|
||||
|
||||
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; }
|
||||
static color get_color(const_node_ptr p) { return p->_extra; }
|
||||
static void set_color(node_ptr p, color c) { p->_extra = c; }
|
||||
static color black() { return 0; }
|
||||
static color red() { return 1; }
|
||||
};
|
||||
|
||||
struct AVLTree_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;
|
||||
typedef char balance;
|
||||
|
||||
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; }
|
||||
static balance get_balance(const_node_ptr p) { return p->_extra; }
|
||||
static void set_balance(node_ptr p, balance b) { p->_extra = b; }
|
||||
static balance negative() { return -1; }
|
||||
static balance zero() { return 0; }
|
||||
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 >
|
||||
struct BPtr_Value_Traits
|
||||
{
|
||||
typedef Node_Traits node_traits;
|
||||
typedef typename node_traits::val_t value_type;
|
||||
typedef typename node_traits::node_ptr node_ptr;
|
||||
typedef typename node_traits::const_node_ptr const_node_ptr;
|
||||
typedef node_ptr pointer;
|
||||
typedef const_node_ptr const_pointer;
|
||||
typedef Bounded_Reference< value_type > reference;
|
||||
typedef Bounded_Reference< const value_type > const_reference;
|
||||
|
||||
static const boost::intrusive::link_mode_type link_mode = boost::intrusive::safe_link;
|
||||
|
||||
static const_node_ptr to_node_ptr(const_reference v) { return &v; }
|
||||
static node_ptr to_node_ptr(reference v) { return &v; }
|
||||
static const_pointer to_value_ptr(const_node_ptr p) { return p; }
|
||||
static pointer to_value_ptr(node_ptr p) { return p; }
|
||||
};
|
||||
|
||||
template < typename >
|
||||
struct Value_Container;
|
||||
|
||||
template <>
|
||||
struct Value_Container< BPtr_Value >
|
||||
{
|
||||
typedef Bounded_Reference_Cont< BPtr_Value > type;
|
||||
};
|
||||
|
||||
namespace test
|
||||
{
|
||||
|
||||
template <>
|
||||
class new_cloner< BPtr_Value >
|
||||
{
|
||||
public:
|
||||
typedef BPtr_Value value_type;
|
||||
typedef Bounded_Pointer< value_type > pointer;
|
||||
typedef Bounded_Reference< const value_type > const_reference;
|
||||
typedef Bounded_Allocator< value_type > allocator_type;
|
||||
|
||||
pointer operator () (const_reference r)
|
||||
{
|
||||
pointer p = allocator_type().allocate(1);
|
||||
new (p.raw()) value_type(r);
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
class delete_disposer< BPtr_Value >
|
||||
{
|
||||
public:
|
||||
typedef BPtr_Value value_type;
|
||||
typedef Bounded_Pointer< value_type > pointer;
|
||||
typedef Bounded_Allocator< value_type > allocator_type;
|
||||
|
||||
void operator () (pointer p)
|
||||
{
|
||||
p->~value_type();
|
||||
allocator_type().deallocate(p, 1);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace test
|
||||
|
||||
} // namespace intrusive
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif
|
@@ -23,6 +23,7 @@
|
||||
#include <boost/intrusive/treap_set.hpp>
|
||||
#include <boost/intrusive/unordered_set.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include "itestvalue.hpp"
|
||||
|
||||
using namespace boost::intrusive;
|
||||
|
||||
@@ -71,6 +72,16 @@ void test_sizes(boolean<true>, std::size_t wordsize)
|
||||
BOOST_TEST_EQ(sizeof(c), wordsize*2);
|
||||
test_iterator_sizes(c, wordsize);
|
||||
}
|
||||
{
|
||||
list< node< list_base_hook<> >, header_holder_type< pointer_holder< list_node<void*> > > > c;
|
||||
BOOST_TEST_EQ(sizeof(c), wordsize*2);
|
||||
test_iterator_sizes(c, wordsize);
|
||||
}
|
||||
{
|
||||
list< node< list_base_hook<> >, constant_time_size<false>, header_holder_type< pointer_holder< list_node<void*> > > > c;
|
||||
BOOST_TEST_EQ(sizeof(c), wordsize*1);
|
||||
test_iterator_sizes(c, wordsize);
|
||||
}
|
||||
{ //slist
|
||||
slist<node< node< slist_base_hook<> > > > c;
|
||||
BOOST_TEST_EQ(sizeof(c), wordsize*2);
|
||||
@@ -101,6 +112,16 @@ void test_sizes(boolean<true>, std::size_t wordsize)
|
||||
BOOST_TEST_EQ(sizeof(c), wordsize*3);
|
||||
test_iterator_sizes(c, wordsize);
|
||||
}
|
||||
{
|
||||
set< node< set_base_hook<> >, header_holder_type< pointer_holder< rbtree_node<void*> > > > c;
|
||||
BOOST_TEST_EQ(sizeof(c), wordsize*2);
|
||||
test_iterator_sizes(c, wordsize);
|
||||
}
|
||||
{
|
||||
set< node< set_base_hook<> >, constant_time_size<false>, header_holder_type< pointer_holder< rbtree_node<void*> > > > c;
|
||||
BOOST_TEST_EQ(sizeof(c), wordsize*1);
|
||||
test_iterator_sizes(c, wordsize);
|
||||
}
|
||||
{ //avl
|
||||
avl_set<node< node< avl_set_base_hook<> > > > c;
|
||||
BOOST_TEST_EQ(sizeof(c), wordsize*5);
|
||||
@@ -116,6 +137,16 @@ void test_sizes(boolean<true>, std::size_t wordsize)
|
||||
BOOST_TEST_EQ(sizeof(c), wordsize*3);
|
||||
test_iterator_sizes(c, wordsize);
|
||||
}
|
||||
{
|
||||
avl_set< node< avl_set_base_hook<> >, header_holder_type< pointer_holder< avltree_node<void*> > > > c;
|
||||
BOOST_TEST_EQ(sizeof(c), wordsize*2);
|
||||
test_iterator_sizes(c, wordsize);
|
||||
}
|
||||
{
|
||||
avl_set< node< avl_set_base_hook<> >, constant_time_size<false>, header_holder_type< pointer_holder< avltree_node<void*> > > > c;
|
||||
BOOST_TEST_EQ(sizeof(c), wordsize*1);
|
||||
test_iterator_sizes(c, wordsize);
|
||||
}
|
||||
{ //splay
|
||||
splay_set<node< node< bs_set_base_hook<> > > > c;
|
||||
BOOST_TEST_EQ(sizeof(c), wordsize*4);
|
||||
|
@@ -75,35 +75,35 @@ template<class ValueTraits, template <class = void, class = void, class = void,
|
||||
struct test_generic_assoc
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
static void test_all(std::vector<value_type>& values);
|
||||
static void test_clone(std::vector<value_type>& values);
|
||||
typedef typename Value_Container< value_type >::type value_cont_type;
|
||||
typedef typename ValueTraits::reference reference;
|
||||
typedef typename ValueTraits::const_reference const_reference;
|
||||
static void test_all(value_cont_type&);
|
||||
static void test_clone(value_cont_type&);
|
||||
static void test_insert_erase_burst();
|
||||
static void test_container_from_end(std::vector<value_type>& values);
|
||||
static void test_splay_up(std::vector<value_type>& values);
|
||||
static void test_splay_up(std::vector<value_type>& values, boost::intrusive::detail::true_type);
|
||||
static void test_splay_up(std::vector<value_type>& values, boost::intrusive::detail::false_type);
|
||||
static void test_splay_down(std::vector<value_type>& values);
|
||||
static void test_splay_down(std::vector<value_type>& values, boost::intrusive::detail::true_type);
|
||||
static void test_splay_down(std::vector<value_type>& values, boost::intrusive::detail::false_type);
|
||||
static void test_rebalance(std::vector<value_type>& values);
|
||||
static void test_rebalance(std::vector<value_type>& values, boost::intrusive::detail::true_type);
|
||||
static void test_rebalance(std::vector<value_type>& values, boost::intrusive::detail::false_type);
|
||||
static void test_insert_before(std::vector<value_type>& values);
|
||||
static void test_insert_before(std::vector<value_type>& values, boost::intrusive::detail::true_type);
|
||||
static void test_insert_before(std::vector<value_type>& values, boost::intrusive::detail::false_type);
|
||||
static void test_container_from_iterator(std::vector<value_type>& values);
|
||||
static void test_container_from_end(value_cont_type&, detail::true_type);
|
||||
static void test_container_from_end(value_cont_type&, detail::false_type) {}
|
||||
static void test_splay_up(value_cont_type&, detail::true_type);
|
||||
static void test_splay_up(value_cont_type&, detail::false_type) {}
|
||||
static void test_splay_down(value_cont_type&, detail::true_type);
|
||||
static void test_splay_down(value_cont_type&, detail::false_type) {}
|
||||
static void test_rebalance(value_cont_type&, detail::true_type);
|
||||
static void test_rebalance(value_cont_type&, detail::false_type) {}
|
||||
static void test_insert_before(value_cont_type&, detail::true_type);
|
||||
static void test_insert_before(value_cont_type&, detail::false_type) {}
|
||||
static void test_container_from_iterator(value_cont_type&, detail::true_type);
|
||||
static void test_container_from_iterator(value_cont_type&, detail::false_type) {}
|
||||
};
|
||||
|
||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::
|
||||
test_container_from_iterator(std::vector<value_type>& values)
|
||||
test_container_from_iterator(value_cont_type& values, detail::true_type)
|
||||
{
|
||||
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());
|
||||
typedef typename assoc_type::iterator it_type;
|
||||
typedef typename assoc_type::const_iterator cit_type;
|
||||
@@ -127,10 +127,11 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_erase_burst(
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
|
||||
std::vector<value_type> values;
|
||||
//value_cont_type values;
|
||||
const int MaxValues = 100;
|
||||
value_cont_type values(MaxValues);
|
||||
for(int i = 0; i != MaxValues; ++i){
|
||||
values.push_back(value_type(i));
|
||||
(&values[i])->value_ = i;
|
||||
}
|
||||
|
||||
typedef typename ContainerDefiner
|
||||
@@ -141,7 +142,7 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_erase_burst(
|
||||
typedef typename assoc_type::iterator iterator;
|
||||
|
||||
//First ordered insertions
|
||||
assoc_type testset (&values[0], &values[0] + values.size());
|
||||
assoc_type testset (values.begin(), values.begin() + values.size());
|
||||
TEST_INTRUSIVE_SEQUENCE_EXPECTED(testset, testset.begin());
|
||||
|
||||
//Ordered erasure
|
||||
@@ -157,13 +158,11 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_erase_burst(
|
||||
|
||||
//Now random insertions
|
||||
std::random_shuffle(values.begin(), values.end());
|
||||
testset.insert(&values[0], &values[0] + values.size());
|
||||
std::vector<value_type> values_ordered(values);
|
||||
std::sort(values_ordered.begin(), values_ordered.end());
|
||||
testset.insert(values.begin(), values.begin() + values.size());
|
||||
TEST_INTRUSIVE_SEQUENCE_EXPECTED(testset, testset.begin());
|
||||
|
||||
{
|
||||
typedef typename std::vector<value_type>::const_iterator cvec_iterator;
|
||||
typedef typename value_cont_type::const_iterator cvec_iterator;
|
||||
//Random erasure
|
||||
std::vector<cvec_iterator> it_vector;
|
||||
|
||||
@@ -182,30 +181,34 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_erase_burst(
|
||||
}
|
||||
|
||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_all(std::vector<typename ValueTraits::value_type>& values)
|
||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_all(value_cont_type& values)
|
||||
{
|
||||
test_clone(values);
|
||||
test_container_from_end(values);
|
||||
test_splay_up(values);
|
||||
test_splay_down(values);
|
||||
test_rebalance(values);
|
||||
test_insert_before(values);
|
||||
test_insert_erase_burst();
|
||||
test_container_from_iterator(values);
|
||||
}
|
||||
|
||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||
void test_generic_assoc<ValueTraits, ContainerDefiner>
|
||||
::test_clone(std::vector<typename ValueTraits::value_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 assoc_type;
|
||||
|
||||
assoc_type testset1 (&values[0], &values[0] + values.size());
|
||||
test_clone(values);
|
||||
test_container_from_end(values, detail::bool_< assoc_type::has_container_from_iterator >());
|
||||
test_splay_up(values, detail::bool_< has_splay< assoc_type >::value >());
|
||||
test_splay_down(values, detail::bool_< has_splay< assoc_type >::value >());
|
||||
test_rebalance(values, detail::bool_< has_rebalance< assoc_type >::value >());
|
||||
test_insert_before(values, detail::bool_< has_insert_before< assoc_type >::value >());
|
||||
test_insert_erase_burst();
|
||||
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>
|
||||
void test_generic_assoc<ValueTraits, ContainerDefiner>
|
||||
::test_clone(value_cont_type& values)
|
||||
{
|
||||
typedef typename ContainerDefiner
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
>::type assoc_type;
|
||||
assoc_type testset1 (values.begin(), values.begin() + values.size());
|
||||
assoc_type testset2;
|
||||
|
||||
testset2.clone_from(testset1, test::new_cloner<value_type>(), test::delete_disposer<value_type>());
|
||||
@@ -216,7 +219,7 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>
|
||||
|
||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||
void test_generic_assoc<ValueTraits, ContainerDefiner>
|
||||
::test_container_from_end(std::vector<typename ValueTraits::value_type>& values)
|
||||
::test_container_from_end(value_cont_type& values, detail::true_type)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
@@ -224,14 +227,14 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>
|
||||
, value_traits<ValueTraits>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
>::type assoc_type;
|
||||
assoc_type testset (&values[0], &values[0] + values.size());
|
||||
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>
|
||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_up
|
||||
(std::vector<typename ValueTraits::value_type>& values, boost::intrusive::detail::true_type)
|
||||
(value_cont_type& values, detail::true_type)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
@@ -240,13 +243,13 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_up
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
>::type assoc_type;
|
||||
typedef typename assoc_type::iterator iterator;
|
||||
typedef std::vector<value_type> orig_set_t;
|
||||
typedef value_cont_type orig_set_t;
|
||||
std::size_t num_values;
|
||||
orig_set_t original_testset;
|
||||
{
|
||||
assoc_type testset (values.begin(), values.end());
|
||||
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){
|
||||
@@ -267,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
|
||||
(std::vector<typename ValueTraits::value_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
|
||||
(std::vector<typename ValueTraits::value_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>
|
||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_down
|
||||
(std::vector<typename ValueTraits::value_type>& values, boost::intrusive::detail::true_type)
|
||||
(value_cont_type& values, detail::true_type)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
@@ -297,13 +281,13 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_down
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
>::type assoc_type;
|
||||
typedef typename assoc_type::iterator iterator;
|
||||
typedef std::vector<value_type> orig_set_t;
|
||||
typedef value_cont_type orig_set_t;
|
||||
std::size_t num_values;
|
||||
orig_set_t original_testset;
|
||||
{
|
||||
assoc_type testset (values.begin(), values.end());
|
||||
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){
|
||||
@@ -325,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
|
||||
(std::vector<typename ValueTraits::value_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
|
||||
(std::vector<typename ValueTraits::value_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>
|
||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_rebalance
|
||||
(std::vector<typename ValueTraits::value_type>& values, boost::intrusive::detail::true_type)
|
||||
(value_cont_type& values, detail::true_type)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
@@ -354,11 +319,12 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_rebalance
|
||||
, value_traits<ValueTraits>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
>::type assoc_type;
|
||||
typedef std::vector<value_type> orig_set_t;
|
||||
typedef value_cont_type orig_set_t;
|
||||
orig_set_t original_testset;
|
||||
{
|
||||
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());
|
||||
@@ -383,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
|
||||
(std::vector<typename ValueTraits::value_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
|
||||
(std::vector<typename ValueTraits::value_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>
|
||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_before
|
||||
(std::vector<typename ValueTraits::value_type>& values, boost::intrusive::detail::true_type)
|
||||
(value_cont_type& values, detail::true_type)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
@@ -414,7 +361,7 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_before
|
||||
>::type assoc_type;
|
||||
{
|
||||
assoc_type testset;
|
||||
typedef typename std::vector<value_type>::iterator vec_iterator;
|
||||
typedef typename value_cont_type::iterator vec_iterator;
|
||||
for(vec_iterator it(values.begin()), itend(values.end())
|
||||
; it != itend
|
||||
; ++it){
|
||||
@@ -425,7 +372,7 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_before
|
||||
}
|
||||
{
|
||||
assoc_type testset;
|
||||
typedef typename std::vector<value_type>::iterator vec_iterator;
|
||||
typedef typename value_cont_type::iterator vec_iterator;
|
||||
|
||||
for(vec_iterator it(--values.end()); true; --it){
|
||||
testset.push_front(*it);
|
||||
@@ -438,7 +385,7 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_before
|
||||
}
|
||||
{
|
||||
assoc_type testset;
|
||||
typedef typename std::vector<value_type>::iterator vec_iterator;
|
||||
typedef typename value_cont_type::iterator vec_iterator;
|
||||
typename assoc_type::iterator it_pos =
|
||||
testset.insert_before(testset.end(), *values.rbegin());
|
||||
testset.insert_before(testset.begin(), *values.begin());
|
||||
@@ -452,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
|
||||
(std::vector<typename ValueTraits::value_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
|
||||
(std::vector<typename ValueTraits::value_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
|
||||
|
||||
#include <boost/intrusive/detail/config_end.hpp>
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include "test_macros.hpp"
|
||||
#include "test_container.hpp"
|
||||
#include "generic_assoc_test.hpp"
|
||||
#include <typeinfo>
|
||||
|
||||
namespace boost{
|
||||
namespace intrusive{
|
||||
@@ -27,11 +28,14 @@ template<class ValueTraits, template <class = void, class = void, class = void,
|
||||
struct test_generic_multiset
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
static void test_all ();
|
||||
static void test_sort(std::vector<value_type>& values);
|
||||
static void test_insert(std::vector<value_type>& values);
|
||||
static void test_swap(std::vector<value_type>& values);
|
||||
static void test_find(std::vector<value_type>& values);
|
||||
typedef typename Value_Container< value_type >::type value_cont_type;
|
||||
typedef typename ValueTraits::reference reference;
|
||||
typedef typename ValueTraits::const_reference const_reference;
|
||||
static void test_all();
|
||||
static void test_sort(value_cont_type&);
|
||||
static void test_insert(value_cont_type&);
|
||||
static void test_swap(value_cont_type&);
|
||||
static void test_find(value_cont_type&);
|
||||
static void test_impl();
|
||||
};
|
||||
|
||||
@@ -40,15 +44,31 @@ void test_generic_multiset<ValueTraits, ContainerDefiner>::test_all ()
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
static const int random_init[6] = { 3, 2, 4, 1, 5, 2 };
|
||||
std::vector<value_type> values (6);
|
||||
value_cont_type values (6);
|
||||
for (int i = 0; i < 6; ++i)
|
||||
values[i].value_ = random_init[i];
|
||||
(&values[i])->value_ = random_init[i];
|
||||
|
||||
typedef typename ContainerDefiner
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
>::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());
|
||||
test::test_container(testset);
|
||||
@@ -75,9 +95,9 @@ template<class ValueTraits, template <class = void, class = void, class = void,
|
||||
void test_generic_multiset<ValueTraits, ContainerDefiner>::test_impl()
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
std::vector<value_type> values (5);
|
||||
value_cont_type values (5);
|
||||
for (int i = 0; i < 5; ++i)
|
||||
values[i].value_ = i;
|
||||
(&values[i])->value_ = i;
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
< value_type
|
||||
@@ -99,7 +119,7 @@ void test_generic_multiset<ValueTraits, ContainerDefiner>::test_impl()
|
||||
|
||||
//test: constructor, iterator, clear, reverse_iterator, front, back, size:
|
||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||
void test_generic_multiset<ValueTraits, ContainerDefiner>::test_sort(std::vector<typename ValueTraits::value_type>& values)
|
||||
void test_generic_multiset<ValueTraits, ContainerDefiner>::test_sort(value_cont_type& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
@@ -121,7 +141,7 @@ void test_generic_multiset<ValueTraits, ContainerDefiner>::test_sort(std::vector
|
||||
, value_traits<ValueTraits>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
>::type multiset_type2;
|
||||
multiset_type2 testset2 (&values[0], &values[0] + 6);
|
||||
multiset_type2 testset2 (values.begin(), values.begin() + 6);
|
||||
{ int init_values [] = { 5, 3, 1, 4, 2, 2 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset2.rbegin() ); }
|
||||
|
||||
@@ -131,7 +151,7 @@ void test_generic_multiset<ValueTraits, ContainerDefiner>::test_sort(std::vector
|
||||
|
||||
//test: insert, const_iterator, const_reverse_iterator, erase, iterator_to:
|
||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||
void test_generic_multiset<ValueTraits, ContainerDefiner>::test_insert(std::vector<typename ValueTraits::value_type>& values)
|
||||
void test_generic_multiset<ValueTraits, ContainerDefiner>::test_insert(value_cont_type& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
@@ -142,7 +162,7 @@ void test_generic_multiset<ValueTraits, ContainerDefiner>::test_insert(std::vect
|
||||
>::type multiset_type;
|
||||
|
||||
multiset_type testset;
|
||||
testset.insert(&values[0] + 2, &values[0] + 5);
|
||||
testset.insert(values.begin() + 2, values.begin() + 5);
|
||||
{ int init_values [] = { 1, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset.begin() ); }
|
||||
|
||||
@@ -169,7 +189,7 @@ void test_generic_multiset<ValueTraits, ContainerDefiner>::test_insert(std::vect
|
||||
|
||||
//test: insert (seq-version), swap, erase (seq-version), size:
|
||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||
void test_generic_multiset<ValueTraits, ContainerDefiner>::test_swap(std::vector<typename ValueTraits::value_type>& values)
|
||||
void test_generic_multiset<ValueTraits, ContainerDefiner>::test_swap(value_cont_type& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
@@ -178,9 +198,9 @@ void test_generic_multiset<ValueTraits, ContainerDefiner>::test_swap(std::vector
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
>::type multiset_type;
|
||||
multiset_type testset1 (&values[0], &values[0] + 2);
|
||||
multiset_type testset1 (values.begin(), values.begin() + 2);
|
||||
multiset_type testset2;
|
||||
testset2.insert (&values[0] + 2, &values[0] + 6);
|
||||
testset2.insert (values.begin() + 2, values.begin() + 6);
|
||||
testset1.swap (testset2);
|
||||
|
||||
{ int init_values [] = { 1, 2, 4, 5 };
|
||||
@@ -195,7 +215,7 @@ void test_generic_multiset<ValueTraits, ContainerDefiner>::test_swap(std::vector
|
||||
|
||||
//test: find, equal_range (lower_bound, upper_bound):
|
||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||
void test_generic_multiset<ValueTraits, ContainerDefiner>::test_find(std::vector<typename ValueTraits::value_type>& values)
|
||||
void test_generic_multiset<ValueTraits, ContainerDefiner>::test_find(value_cont_type& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
@@ -208,8 +228,9 @@ void test_generic_multiset<ValueTraits, ContainerDefiner>::test_find(std::vector
|
||||
typedef typename multiset_type::iterator iterator;
|
||||
|
||||
{
|
||||
value_type cmp_val;
|
||||
cmp_val.value_ = 2;
|
||||
value_cont_type cmp_val_cont(1);
|
||||
reference cmp_val = cmp_val_cont.front();
|
||||
(&cmp_val)->value_ = 2;
|
||||
iterator i = testset.find (cmp_val);
|
||||
BOOST_TEST (i->value_ == 2);
|
||||
BOOST_TEST ((++i)->value_ == 2);
|
||||
@@ -219,7 +240,7 @@ void test_generic_multiset<ValueTraits, ContainerDefiner>::test_find(std::vector
|
||||
BOOST_TEST (range.second->value_ == 3);
|
||||
BOOST_TEST (std::distance (range.first, range.second) == 2);
|
||||
|
||||
cmp_val.value_ = 7;
|
||||
(&cmp_val)->value_ = 7;
|
||||
BOOST_TEST (testset.find (cmp_val) == testset.end());
|
||||
}
|
||||
{ //1, 2, 2, 3, 4, 5
|
||||
@@ -227,10 +248,12 @@ void test_generic_multiset<ValueTraits, ContainerDefiner>::test_find(std::vector
|
||||
std::pair<iterator,iterator> range;
|
||||
std::pair<typename search_const_iterator<multiset_type>::type
|
||||
,typename search_const_iterator<multiset_type>::type> const_range;
|
||||
value_type cmp_val_lower, cmp_val_upper;
|
||||
value_cont_type cmp_val_cont(2);
|
||||
reference cmp_val_lower = cmp_val_cont.front();
|
||||
reference cmp_val_upper = cmp_val_cont.back();
|
||||
{
|
||||
cmp_val_lower.value_ = 1;
|
||||
cmp_val_upper.value_ = 2;
|
||||
(&cmp_val_lower)->value_ = 1;
|
||||
(&cmp_val_upper)->value_ = 2;
|
||||
//left-closed, right-closed
|
||||
range = testset.bounded_range (cmp_val_lower, cmp_val_upper, true, true);
|
||||
BOOST_TEST (range.first->value_ == 1);
|
||||
@@ -238,39 +261,39 @@ void test_generic_multiset<ValueTraits, ContainerDefiner>::test_find(std::vector
|
||||
BOOST_TEST (std::distance (range.first, range.second) == 3);
|
||||
}
|
||||
{
|
||||
cmp_val_lower.value_ = 1;
|
||||
cmp_val_upper.value_ = 2;
|
||||
(&cmp_val_lower)->value_ = 1;
|
||||
(&cmp_val_upper)->value_ = 2;
|
||||
const_range = const_testset.bounded_range (cmp_val_lower, cmp_val_upper, true, false);
|
||||
BOOST_TEST (const_range.first->value_ == 1);
|
||||
BOOST_TEST (const_range.second->value_ == 2);
|
||||
BOOST_TEST (std::distance (const_range.first, const_range.second) == 1);
|
||||
|
||||
cmp_val_lower.value_ = 1;
|
||||
cmp_val_upper.value_ = 3;
|
||||
(&cmp_val_lower)->value_ = 1;
|
||||
(&cmp_val_upper)->value_ = 3;
|
||||
range = testset.bounded_range (cmp_val_lower, cmp_val_upper, true, false);
|
||||
BOOST_TEST (range.first->value_ == 1);
|
||||
BOOST_TEST (range.second->value_ == 3);
|
||||
BOOST_TEST (std::distance (range.first, range.second) == 3);
|
||||
}
|
||||
{
|
||||
cmp_val_lower.value_ = 1;
|
||||
cmp_val_upper.value_ = 2;
|
||||
(&cmp_val_lower)->value_ = 1;
|
||||
(&cmp_val_upper)->value_ = 2;
|
||||
const_range = const_testset.bounded_range (cmp_val_lower, cmp_val_upper, false, true);
|
||||
BOOST_TEST (const_range.first->value_ == 2);
|
||||
BOOST_TEST (const_range.second->value_ == 3);
|
||||
BOOST_TEST (std::distance (const_range.first, const_range.second) == 2);
|
||||
}
|
||||
{
|
||||
cmp_val_lower.value_ = 1;
|
||||
cmp_val_upper.value_ = 2;
|
||||
(&cmp_val_lower)->value_ = 1;
|
||||
(&cmp_val_upper)->value_ = 2;
|
||||
range = testset.bounded_range (cmp_val_lower, cmp_val_upper, false, false);
|
||||
BOOST_TEST (range.first->value_ == 2);
|
||||
BOOST_TEST (range.second->value_ == 2);
|
||||
BOOST_TEST (std::distance (range.first, range.second) == 0);
|
||||
}
|
||||
{
|
||||
cmp_val_lower.value_ = 5;
|
||||
cmp_val_upper.value_ = 6;
|
||||
(&cmp_val_lower)->value_ = 5;
|
||||
(&cmp_val_upper)->value_ = 6;
|
||||
const_range = const_testset.bounded_range (cmp_val_lower, cmp_val_upper, true, false);
|
||||
BOOST_TEST (const_range.first->value_ == 5);
|
||||
BOOST_TEST (const_range.second == const_testset.end());
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include "test_macros.hpp"
|
||||
#include "test_container.hpp"
|
||||
#include "generic_assoc_test.hpp"
|
||||
#include <typeinfo>
|
||||
|
||||
namespace boost{
|
||||
namespace intrusive{
|
||||
@@ -33,14 +34,16 @@ template<class ValueTraits, template <class = void, class = void, class = void,
|
||||
struct test_generic_set
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename Value_Container< value_type >::type value_cont_type;
|
||||
typedef typename ValueTraits::reference reference;
|
||||
typedef typename ValueTraits::const_reference const_reference;
|
||||
static void test_all();
|
||||
static void test_sort(std::vector<value_type>& values);
|
||||
static void test_insert(std::vector<value_type>& values);
|
||||
static void test_insert_advanced(std::vector<value_type>& values, boost::intrusive::detail::true_type);
|
||||
static void test_insert_advanced(std::vector<value_type>& values, boost::intrusive::detail::false_type);
|
||||
static void test_insert_advanced(std::vector<value_type>& values);
|
||||
static void test_swap(std::vector<value_type>& values);
|
||||
static void test_find(std::vector<value_type>& values);
|
||||
static void test_sort(value_cont_type&);
|
||||
static void test_insert(value_cont_type&);
|
||||
static void test_insert_advanced(value_cont_type&, detail::true_type);
|
||||
static void test_insert_advanced(value_cont_type&, detail::false_type);
|
||||
static void test_swap(value_cont_type&);
|
||||
static void test_find(value_cont_type&);
|
||||
static void test_impl();
|
||||
};
|
||||
|
||||
@@ -50,15 +53,32 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_all()
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
static const int random_init[6] = { 3, 2, 4, 1, 5, 2 };
|
||||
std::vector<value_type> values (6);
|
||||
value_cont_type values(6);
|
||||
for (int i = 0; i < 6; ++i)
|
||||
values[i].value_ = random_init[i];
|
||||
(&values[i])->value_ = random_init[i];
|
||||
|
||||
typedef typename ContainerDefiner
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
>::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());
|
||||
test::test_container(testset);
|
||||
@@ -74,7 +94,7 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_all()
|
||||
}
|
||||
test_sort(values);
|
||||
test_insert(values);
|
||||
test_insert_advanced(values);
|
||||
test_insert_advanced(values, detail::bool_< is_treap< set_type >::value >());
|
||||
test_swap(values);
|
||||
test_find(values);
|
||||
test_impl();
|
||||
@@ -86,9 +106,9 @@ template<class ValueTraits, template <class = void, class = void, class = void,
|
||||
void test_generic_set<ValueTraits, ContainerDefiner>::test_impl()
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
std::vector<value_type> values (5);
|
||||
value_cont_type values (5);
|
||||
for (int i = 0; i < 5; ++i)
|
||||
values[i].value_ = i;
|
||||
(&values[i])->value_ = i;
|
||||
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
@@ -110,7 +130,7 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_impl()
|
||||
|
||||
//test: constructor, iterator, clear, reverse_iterator, front, back, size:
|
||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||
void test_generic_set<ValueTraits, ContainerDefiner>::test_sort(std::vector<typename ValueTraits::value_type>& values)
|
||||
void test_generic_set<ValueTraits, ContainerDefiner>::test_sort(value_cont_type& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
@@ -132,7 +152,7 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_sort(std::vector<type
|
||||
, value_traits<ValueTraits>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
>::type set_type2;
|
||||
set_type2 testset2 (&values[0], &values[0] + 6);
|
||||
set_type2 testset2 (values.begin(), values.begin() + 6);
|
||||
{ int init_values [] = { 5, 3, 1, 4, 2 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset2.rbegin() ); }
|
||||
BOOST_TEST (testset2.begin()->value_ == 2);
|
||||
@@ -141,7 +161,7 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_sort(std::vector<type
|
||||
|
||||
//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>
|
||||
void test_generic_set<ValueTraits, ContainerDefiner>::test_insert(std::vector<typename ValueTraits::value_type>& values)
|
||||
void test_generic_set<ValueTraits, ContainerDefiner>::test_insert(value_cont_type& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
@@ -151,7 +171,7 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_insert(std::vector<ty
|
||||
>::type set_type;
|
||||
{
|
||||
set_type testset;
|
||||
testset.insert(&values[0] + 2, &values[0] + 5);
|
||||
testset.insert(values.begin() + 2, values.begin() + 5);
|
||||
|
||||
const set_type& const_testset = testset;
|
||||
{ int init_values [] = { 1, 4, 5 };
|
||||
@@ -173,9 +193,9 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_insert(std::vector<ty
|
||||
BOOST_TEST (&*i == &values[2]);
|
||||
|
||||
typename set_type::const_iterator ic;
|
||||
ic = testset.iterator_to (const_cast<const value_type &>(values[2]));
|
||||
ic = testset.iterator_to (static_cast< const_reference >(values[2]));
|
||||
BOOST_TEST (&*ic == &values[2]);
|
||||
ic = set_type::s_iterator_to (const_cast<const value_type &>(values[2]));
|
||||
ic = set_type::s_iterator_to (static_cast< const_reference >(values[2]));
|
||||
BOOST_TEST (&*ic == &values[2]);
|
||||
|
||||
testset.erase (i);
|
||||
@@ -184,9 +204,10 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_insert(std::vector<ty
|
||||
}
|
||||
}
|
||||
|
||||
// treap version
|
||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||
void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
|
||||
(std::vector<typename ValueTraits::value_type>& values, boost::intrusive::detail::true_type)
|
||||
(value_cont_type& values, detail::true_type)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
@@ -196,7 +217,7 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
|
||||
>::type set_type;
|
||||
{
|
||||
set_type testset;
|
||||
testset.insert(&values[0], &values[0] + values.size());
|
||||
testset.insert(values.begin(), values.begin() + values.size());
|
||||
value_type v(1);
|
||||
typename set_type::insert_commit_data data;
|
||||
BOOST_TEST (!testset.insert_check(v, testset.value_comp(), testset.priority_comp(), data).second);
|
||||
@@ -204,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
|
||||
(std::vector<typename ValueTraits::value_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:
|
||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||
void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
|
||||
( std::vector<typename ValueTraits::value_type>& values
|
||||
, boost::intrusive::detail::false_type)
|
||||
(value_cont_type& values, detail::false_type)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
@@ -235,7 +238,7 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
|
||||
>::type set_type;
|
||||
{
|
||||
set_type testset;
|
||||
testset.insert(&values[0], &values[0] + values.size());
|
||||
testset.insert(values.begin(), values.begin() + values.size());
|
||||
value_type v(1);
|
||||
typename set_type::insert_commit_data data;
|
||||
BOOST_TEST (!testset.insert_check(v, testset.value_comp(), data).second);
|
||||
@@ -243,10 +246,9 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//test: insert (seq-version), swap, erase (seq-version), size:
|
||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||
void test_generic_set<ValueTraits, ContainerDefiner>::test_swap(std::vector<typename ValueTraits::value_type>& values)
|
||||
void test_generic_set<ValueTraits, ContainerDefiner>::test_swap(value_cont_type& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
@@ -254,9 +256,9 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_swap(std::vector<type
|
||||
, value_traits<ValueTraits>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
>::type set_type;
|
||||
set_type testset1 (&values[0], &values[0] + 2);
|
||||
set_type testset1 (values.begin(), values.begin() + 2);
|
||||
set_type testset2;
|
||||
testset2.insert (&values[0] + 2, &values[0] + 6);
|
||||
testset2.insert (values.begin() + 2, values.begin() + 6);
|
||||
testset1.swap (testset2);
|
||||
|
||||
{ int init_values [] = { 1, 2, 4, 5 };
|
||||
@@ -273,7 +275,7 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_swap(std::vector<type
|
||||
|
||||
//test: find, equal_range (lower_bound, upper_bound), bounded_range:
|
||||
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
|
||||
void test_generic_set<ValueTraits, ContainerDefiner>::test_find(std::vector<typename ValueTraits::value_type>& values)
|
||||
void test_generic_set<ValueTraits, ContainerDefiner>::test_find(value_cont_type& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
@@ -285,8 +287,10 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_find(std::vector<type
|
||||
typedef typename set_type::iterator iterator;
|
||||
|
||||
{
|
||||
value_type cmp_val;
|
||||
cmp_val.value_ = 2;
|
||||
//value_type cmp_val;
|
||||
value_cont_type cmp_val_cont(1);
|
||||
reference cmp_val = cmp_val_cont.front();
|
||||
(&cmp_val)->value_ = 2;
|
||||
iterator i = testset.find (cmp_val);
|
||||
BOOST_TEST (i->value_ == 2);
|
||||
BOOST_TEST ((++i)->value_ != 2);
|
||||
@@ -296,7 +300,7 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_find(std::vector<type
|
||||
BOOST_TEST (range.second->value_ == 3);
|
||||
BOOST_TEST (std::distance (range.first, range.second) == 1);
|
||||
|
||||
cmp_val.value_ = 7;
|
||||
(&cmp_val)->value_ = 7;
|
||||
BOOST_TEST (testset.find (cmp_val) == testset.end());
|
||||
}
|
||||
|
||||
@@ -305,10 +309,13 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_find(std::vector<type
|
||||
std::pair<iterator,iterator> range;
|
||||
std::pair<typename search_const_iterator<set_type>::type
|
||||
,typename search_const_iterator<set_type>::type> const_range;
|
||||
value_type cmp_val_lower, cmp_val_upper;
|
||||
//value_type cmp_val_lower, cmp_val_upper;
|
||||
value_cont_type cmp_val_cont(2);
|
||||
reference cmp_val_lower = cmp_val_cont.front();
|
||||
reference cmp_val_upper = cmp_val_cont.back();
|
||||
{
|
||||
cmp_val_lower.value_ = 1;
|
||||
cmp_val_upper.value_ = 2;
|
||||
(&cmp_val_lower)->value_ = 1;
|
||||
(&cmp_val_upper)->value_ = 2;
|
||||
//left-closed, right-closed
|
||||
range = testset.bounded_range (cmp_val_lower, cmp_val_upper, true, true);
|
||||
BOOST_TEST (range.first->value_ == 1);
|
||||
@@ -316,39 +323,39 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_find(std::vector<type
|
||||
BOOST_TEST (std::distance (range.first, range.second) == 2);
|
||||
}
|
||||
{
|
||||
cmp_val_lower.value_ = 1;
|
||||
cmp_val_upper.value_ = 2;
|
||||
(&cmp_val_lower)->value_ = 1;
|
||||
(&cmp_val_upper)->value_ = 2;
|
||||
const_range = const_testset.bounded_range (cmp_val_lower, cmp_val_upper, true, false);
|
||||
BOOST_TEST (const_range.first->value_ == 1);
|
||||
BOOST_TEST (const_range.second->value_ == 2);
|
||||
BOOST_TEST (std::distance (const_range.first, const_range.second) == 1);
|
||||
|
||||
cmp_val_lower.value_ = 1;
|
||||
cmp_val_upper.value_ = 3;
|
||||
(&cmp_val_lower)->value_ = 1;
|
||||
(&cmp_val_upper)->value_ = 3;
|
||||
range = testset.bounded_range (cmp_val_lower, cmp_val_upper, true, false);
|
||||
BOOST_TEST (range.first->value_ == 1);
|
||||
BOOST_TEST (range.second->value_ == 3);
|
||||
BOOST_TEST (std::distance (range.first, range.second) == 2);
|
||||
}
|
||||
{
|
||||
cmp_val_lower.value_ = 1;
|
||||
cmp_val_upper.value_ = 2;
|
||||
(&cmp_val_lower)->value_ = 1;
|
||||
(&cmp_val_upper)->value_ = 2;
|
||||
const_range = const_testset.bounded_range (cmp_val_lower, cmp_val_upper, false, true);
|
||||
BOOST_TEST (const_range.first->value_ == 2);
|
||||
BOOST_TEST (const_range.second->value_ == 3);
|
||||
BOOST_TEST (std::distance (const_range.first, const_range.second) == 1);
|
||||
}
|
||||
{
|
||||
cmp_val_lower.value_ = 1;
|
||||
cmp_val_upper.value_ = 2;
|
||||
(&cmp_val_lower)->value_ = 1;
|
||||
(&cmp_val_upper)->value_ = 2;
|
||||
range = testset.bounded_range (cmp_val_lower, cmp_val_upper, false, false);
|
||||
BOOST_TEST (range.first->value_ == 2);
|
||||
BOOST_TEST (range.second->value_ == 2);
|
||||
BOOST_TEST (std::distance (range.first, range.second) == 0);
|
||||
}
|
||||
{
|
||||
cmp_val_lower.value_ = 5;
|
||||
cmp_val_upper.value_ = 6;
|
||||
(&cmp_val_lower)->value_ = 5;
|
||||
(&cmp_val_upper)->value_ = 6;
|
||||
const_range = const_testset.bounded_range (cmp_val_lower, cmp_val_upper, true, false);
|
||||
BOOST_TEST (const_range.first->value_ == 5);
|
||||
BOOST_TEST (const_range.second == const_testset.end());
|
||||
|
@@ -112,16 +112,21 @@ struct testvalue
|
||||
{ return other1.value_ != other2; }
|
||||
};
|
||||
|
||||
template<class Hooks, bool ConstantTimeSize>
|
||||
std::size_t hash_value(const testvalue<Hooks, ConstantTimeSize> &t)
|
||||
template < typename Node_Algorithms, class Hooks, bool ConstantTimeSize >
|
||||
void swap_nodes(testvalue< Hooks, ConstantTimeSize >& lhs, testvalue< Hooks, ConstantTimeSize >& rhs)
|
||||
{
|
||||
boost::hash<int> hasher;
|
||||
return hasher(t.value_);
|
||||
lhs.swap_nodes(rhs);
|
||||
}
|
||||
|
||||
template<class Hooks, bool ConstantTimeSize>
|
||||
bool priority_order( const testvalue<Hooks, ConstantTimeSize> &t1
|
||||
, const testvalue<Hooks, ConstantTimeSize> &t2)
|
||||
template < typename Value_Type >
|
||||
std::size_t hash_value(const Value_Type& t)
|
||||
{
|
||||
boost::hash<int> hasher;
|
||||
return hasher((&t)->value_);
|
||||
}
|
||||
|
||||
template < typename Value_Type >
|
||||
bool priority_order(const Value_Type& t1, const Value_Type& t2)
|
||||
{
|
||||
std::size_t hash1 = hash_value(t1);
|
||||
boost::hash_combine(hash1, &t1);
|
||||
@@ -137,25 +142,56 @@ std::ostream& operator<<
|
||||
|
||||
struct even_odd
|
||||
{
|
||||
template<class Hooks, bool constant_time_size>
|
||||
template < typename value_type_1, typename value_type_2 >
|
||||
bool operator()
|
||||
(const testvalue<Hooks, constant_time_size>& v1
|
||||
,const testvalue<Hooks, constant_time_size>& v2) const
|
||||
(const value_type_1& v1
|
||||
,const value_type_2& v2) const
|
||||
{
|
||||
if ((v1.value_ & 1) == (v2.value_ & 1))
|
||||
return v1.value_ < v2.value_;
|
||||
if (((&v1)->value_ & 1) == ((&v2)->value_ & 1))
|
||||
return (&v1)->value_ < (&v2)->value_;
|
||||
else
|
||||
return v2.value_ & 1;
|
||||
return (&v2)->value_ & 1;
|
||||
}
|
||||
};
|
||||
|
||||
struct is_even
|
||||
{
|
||||
template<class Hooks, bool constant_time_size>
|
||||
template <typename value_type>
|
||||
bool operator()
|
||||
(const testvalue<Hooks, constant_time_size>& v1) const
|
||||
{ return (v1.value_ & 1) == 0; }
|
||||
(const value_type& v1) const
|
||||
{ return ((&v1)->value_ & 1) == 0; }
|
||||
};
|
||||
|
||||
template <typename>
|
||||
struct Value_Container;
|
||||
|
||||
template < class Hooks, bool ConstantTimeSize >
|
||||
struct Value_Container< testvalue< Hooks, ConstantTimeSize > >
|
||||
{
|
||||
typedef std::vector< testvalue< Hooks, ConstantTimeSize > > type;
|
||||
};
|
||||
|
||||
template < typename T >
|
||||
class pointer_holder
|
||||
{
|
||||
public:
|
||||
pointer_holder() : _ptr(new T())
|
||||
{
|
||||
//std::clog << "constructing holder pointing to &=" << (void*)_ptr << "\n";
|
||||
}
|
||||
~pointer_holder()
|
||||
{
|
||||
//std::clog << "destructing holder pointing to &=" << (void*)_ptr << "\n";
|
||||
delete _ptr;
|
||||
}
|
||||
|
||||
const T* get_node() const { return _ptr; }
|
||||
T* get_node() { return _ptr; }
|
||||
|
||||
private:
|
||||
T* const _ptr;
|
||||
};
|
||||
|
||||
/*
|
||||
struct int_testvalue_comp
|
||||
{
|
||||
|
@@ -14,12 +14,15 @@
|
||||
#include <boost/intrusive/list.hpp>
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
#include "itestvalue.hpp"
|
||||
#include "bptr_value.hpp"
|
||||
#include "smart_ptr.hpp"
|
||||
#include "common_functors.hpp"
|
||||
#include <vector>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include "test_macros.hpp"
|
||||
#include "test_container.hpp"
|
||||
#include <boost/tti/tti.hpp>
|
||||
#include <typeinfo>
|
||||
|
||||
using namespace boost::intrusive;
|
||||
|
||||
@@ -39,32 +42,44 @@ struct hooks
|
||||
> nonhook_node_member_type;
|
||||
};
|
||||
|
||||
template<class ValueTraits>
|
||||
|
||||
template < typename List_Type, typename Value_Container >
|
||||
struct test_list
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
static void test_all(std::vector<value_type>& values);
|
||||
static void test_front_back(std::vector<value_type>& values);
|
||||
static void test_sort(std::vector<value_type>& values);
|
||||
static void test_merge(std::vector<value_type>& values);
|
||||
static void test_remove_unique(std::vector<value_type>& values);
|
||||
static void test_insert(std::vector<value_type>& values);
|
||||
static void test_shift(std::vector<value_type>& values);
|
||||
static void test_swap(std::vector<value_type>& values);
|
||||
static void test_clone(std::vector<value_type>& values);
|
||||
static void test_container_from_end(std::vector<value_type>& values);
|
||||
typedef List_Type list_type;
|
||||
typedef typename list_type::value_traits value_traits;
|
||||
typedef typename value_traits::value_type value_type;
|
||||
typedef typename list_type::node_algorithms node_algorithms;
|
||||
|
||||
static void test_all(Value_Container&);
|
||||
static void test_front_back(Value_Container&);
|
||||
static void test_sort(Value_Container&);
|
||||
static void test_merge(Value_Container&);
|
||||
static void test_remove_unique(Value_Container&);
|
||||
static void test_insert(Value_Container&);
|
||||
static void test_shift(Value_Container&);
|
||||
static void test_swap(Value_Container&);
|
||||
static void test_clone(Value_Container&);
|
||||
static void test_container_from_end(Value_Container&, detail::true_type);
|
||||
static void test_container_from_end(Value_Container&, detail::false_type) {}
|
||||
};
|
||||
|
||||
template<class ValueTraits>
|
||||
void test_list<ValueTraits>::test_all(std::vector<typename ValueTraits::value_type>& values)
|
||||
template < typename List_Type, typename Value_Container >
|
||||
void test_list< List_Type, Value_Container >::test_all(Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef list
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
> list_type;
|
||||
#ifdef PRINT_TESTS
|
||||
std::clog << "testing list with:\n"
|
||||
<< " value_type = " << typeid(value_type).name() << "\n"
|
||||
<< " sizeof(value_type) = " << sizeof(value_type) << "\n"
|
||||
<< " link_mode = " << value_traits::link_mode << "\n"
|
||||
<< " node = " << typeid(typename list_type::node).name() << "\n"
|
||||
<< " sizeof(node) = " << sizeof(typename list_type::node) << "\n"
|
||||
<< " node_ptr = " << typeid(typename list_type::node_ptr).name() << "\n"
|
||||
<< " sizeof(node_ptr) = " << sizeof(typename list_type::node_ptr) << "\n"
|
||||
<< " constant_time_size = " << list_type::constant_time_size << "\n"
|
||||
<< " has_container_from_iterator = " << list_type::has_container_from_iterator << "\n"
|
||||
<< " sizeof(list_type) = " << sizeof(list_type) << "\n";
|
||||
#endif
|
||||
{
|
||||
list_type list(values.begin(), values.end());
|
||||
test::test_container(list);
|
||||
@@ -81,21 +96,14 @@ void test_list<ValueTraits>::test_all(std::vector<typename ValueTraits::value_ty
|
||||
test_shift(values);
|
||||
test_swap(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:
|
||||
template<class ValueTraits>
|
||||
void test_list<ValueTraits>
|
||||
::test_front_back(std::vector<typename ValueTraits::value_type>& values)
|
||||
template < class List_Type, typename Value_Container >
|
||||
void test_list< List_Type, Value_Container >
|
||||
::test_front_back(Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef list
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
> list_type;
|
||||
list_type testlist;
|
||||
BOOST_TEST (testlist.empty());
|
||||
|
||||
@@ -119,19 +127,11 @@ void test_list<ValueTraits>
|
||||
BOOST_TEST (testlist.empty());
|
||||
}
|
||||
|
||||
|
||||
//test: constructor, iterator, reverse_iterator, sort, reverse:
|
||||
template<class ValueTraits>
|
||||
void test_list<ValueTraits>
|
||||
::test_sort(std::vector<typename ValueTraits::value_type>& values)
|
||||
template < class List_Type, typename Value_Container >
|
||||
void test_list< List_Type, Value_Container >
|
||||
::test_sort(Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef list
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
> list_type;
|
||||
list_type testlist(values.begin(), values.end());
|
||||
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
@@ -147,17 +147,10 @@ void test_list<ValueTraits>
|
||||
}
|
||||
|
||||
//test: merge due to error in merge implementation:
|
||||
template<class ValueTraits>
|
||||
void test_list<ValueTraits>
|
||||
::test_remove_unique (std::vector<typename ValueTraits::value_type>& values)
|
||||
template < class List_Type, typename Value_Container >
|
||||
void test_list< List_Type, Value_Container >
|
||||
::test_remove_unique (Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef list
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
> list_type;
|
||||
{
|
||||
list_type list(values.begin(), values.end());
|
||||
list.remove_if(is_even());
|
||||
@@ -165,7 +158,7 @@ void test_list<ValueTraits>
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, list.begin() );
|
||||
}
|
||||
{
|
||||
std::vector<typename ValueTraits::value_type> values2(values);
|
||||
Value_Container values2(values); // NOTE: problematic copy of value container
|
||||
list_type list(values.begin(), values.end());
|
||||
list.insert(list.end(), values2.begin(), values2.end());
|
||||
list.sort();
|
||||
@@ -178,17 +171,10 @@ void test_list<ValueTraits>
|
||||
}
|
||||
|
||||
//test: merge due to error in merge implementation:
|
||||
template<class ValueTraits>
|
||||
void test_list<ValueTraits>
|
||||
::test_merge (std::vector<typename ValueTraits::value_type>& values)
|
||||
template < class List_Type, typename Value_Container >
|
||||
void test_list< List_Type, Value_Container >
|
||||
::test_merge (Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef list
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
> list_type;
|
||||
list_type testlist1, testlist2;
|
||||
testlist1.push_front (values[0]);
|
||||
testlist2.push_front (values[4]);
|
||||
@@ -201,19 +187,12 @@ void test_list<ValueTraits>
|
||||
}
|
||||
|
||||
//test: assign, insert, const_iterator, const_reverse_iterator, erase, s_iterator_to:
|
||||
template<class ValueTraits>
|
||||
void test_list<ValueTraits>
|
||||
::test_insert(std::vector<typename ValueTraits::value_type>& values)
|
||||
template < class List_Type, typename Value_Container >
|
||||
void test_list< List_Type, Value_Container >
|
||||
::test_insert(Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef list
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
> list_type;
|
||||
list_type testlist;
|
||||
testlist.assign (&values[0] + 2, &values[0] + 5);
|
||||
testlist.assign (values.begin() + 2, values.begin() + 5);
|
||||
|
||||
const list_type& const_testlist = testlist;
|
||||
{ int init_values [] = { 3, 4, 5 };
|
||||
@@ -238,10 +217,10 @@ void test_list<ValueTraits>
|
||||
BOOST_TEST (&*i == &values[4]);
|
||||
|
||||
typename list_type::const_iterator ic;
|
||||
ic = testlist.iterator_to (const_cast<const value_type &>(values[4]));
|
||||
ic = testlist.iterator_to (static_cast< typename list_type::const_reference >(values[4]));
|
||||
BOOST_TEST (&*ic == &values[4]);
|
||||
|
||||
ic = list_type::s_iterator_to (const_cast<const value_type &>(values[4]));
|
||||
ic = list_type::s_iterator_to (static_cast< typename list_type::const_reference >(values[4]));
|
||||
BOOST_TEST (&*ic == &values[4]);
|
||||
|
||||
i = testlist.erase (i);
|
||||
@@ -251,18 +230,10 @@ void test_list<ValueTraits>
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); }
|
||||
}
|
||||
|
||||
|
||||
template<class ValueTraits>
|
||||
void test_list<ValueTraits>
|
||||
::test_shift(std::vector<typename ValueTraits::value_type>& values)
|
||||
template < class List_Type, typename Value_Container >
|
||||
void test_list< List_Type, Value_Container >
|
||||
::test_shift(Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef list
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
> list_type;
|
||||
list_type testlist;
|
||||
const int num_values = (int)values.size();
|
||||
std::vector<int> expected_values(num_values);
|
||||
@@ -271,7 +242,7 @@ void test_list<ValueTraits>
|
||||
expected_values.resize(s);
|
||||
//Shift forward all possible positions 3 times
|
||||
for(int i = 0; i < s*3; ++i){
|
||||
testlist.insert(testlist.begin(), &values[0], &values[0] + s);
|
||||
testlist.insert(testlist.begin(), values.begin(), values.begin() + s);
|
||||
testlist.shift_forward(i);
|
||||
for(int j = 0; j < s; ++j){
|
||||
expected_values[(j + s - i%s) % s] = (j + 1);
|
||||
@@ -282,7 +253,7 @@ void test_list<ValueTraits>
|
||||
|
||||
//Shift backwards all possible positions
|
||||
for(int i = 0; i < s*3; ++i){
|
||||
testlist.insert(testlist.begin(), &values[0], &values[0] + s);
|
||||
testlist.insert(testlist.begin(), values.begin(), values.begin() + s);
|
||||
testlist.shift_backwards(i);
|
||||
for(int j = 0; j < s; ++j){
|
||||
expected_values[(j + i) % s] = (j + 1);
|
||||
@@ -294,21 +265,14 @@ void test_list<ValueTraits>
|
||||
}
|
||||
|
||||
//test: insert (seq-version), swap, splice, erase (seq-version):
|
||||
template<class ValueTraits>
|
||||
void test_list<ValueTraits>
|
||||
::test_swap(std::vector<typename ValueTraits::value_type>& values)
|
||||
template < class List_Type, typename Value_Container >
|
||||
void test_list< List_Type, Value_Container >
|
||||
::test_swap(Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef list
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
> list_type;
|
||||
{
|
||||
list_type testlist1 (&values[0], &values[0] + 2);
|
||||
list_type testlist1 (values.begin(), values.begin() + 2);
|
||||
list_type testlist2;
|
||||
testlist2.insert (testlist2.end(), &values[0] + 2, &values[0] + 5);
|
||||
testlist2.insert (testlist2.end(), values.begin() + 2, values.begin() + 5);
|
||||
testlist1.swap (testlist2);
|
||||
|
||||
{ int init_values [] = { 3, 4, 5 };
|
||||
@@ -341,72 +305,56 @@ void test_list<ValueTraits>
|
||||
BOOST_TEST (&testlist1.front() == &values[3]);
|
||||
}
|
||||
{
|
||||
list_type testlist1 (&values[0], &values[0] + 2);
|
||||
list_type testlist2 (&values[0] + 3, &values[0] + 5);
|
||||
list_type testlist1 (values.begin(), values.begin() + 2);
|
||||
list_type testlist2 (values.begin() + 3, values.begin() + 5);
|
||||
|
||||
values[0].swap_nodes(values[2]);
|
||||
swap_nodes< node_algorithms >(values[0], values[2]);
|
||||
{ int init_values [] = { 3, 2 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
values[2].swap_nodes(values[4]);
|
||||
swap_nodes< node_algorithms >(values[2], values[4]);
|
||||
{ int init_values [] = { 5, 2 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
{ int init_values [] = { 4, 3 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
|
||||
}
|
||||
{
|
||||
list_type testlist1 (&values[0], &values[1]);
|
||||
list_type testlist1 (values.begin(), values.begin() + 1);
|
||||
|
||||
{ int init_values [] = { 1 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
values[1].swap_nodes(values[2]);
|
||||
swap_nodes< node_algorithms >(values[1], values[2]);
|
||||
|
||||
{ int init_values [] = { 1 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
values[0].swap_nodes(values[2]);
|
||||
swap_nodes< node_algorithms >(values[0], values[2]);
|
||||
|
||||
{ int init_values [] = { 3 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
values[0].swap_nodes(values[2]);
|
||||
swap_nodes< node_algorithms >(values[0], values[2]);
|
||||
|
||||
{ int init_values [] = { 1 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template<class ValueTraits>
|
||||
void test_list<ValueTraits>
|
||||
::test_container_from_end(std::vector<typename ValueTraits::value_type>& values)
|
||||
template < class List_Type, typename Value_Container >
|
||||
void test_list< List_Type, Value_Container >
|
||||
::test_container_from_end(Value_Container& values, detail::true_type)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef list
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
> list_type;
|
||||
list_type testlist1 (&values[0], &values[0] + 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.cend()));
|
||||
}
|
||||
|
||||
|
||||
template<class ValueTraits>
|
||||
void test_list<ValueTraits>
|
||||
::test_clone(std::vector<typename ValueTraits::value_type>& values)
|
||||
template < class List_Type, typename Value_Container >
|
||||
void test_list< List_Type, Value_Container >
|
||||
::test_clone(Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef list
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
> list_type;
|
||||
list_type testlist1 (&values[0], &values[0] + values.size());
|
||||
list_type testlist1 (values.begin(), values.begin() + values.size());
|
||||
list_type testlist2;
|
||||
|
||||
testlist2.clone_from(testlist1, test::new_cloner<value_type>(), test::delete_disposer<value_type>());
|
||||
@@ -415,42 +363,74 @@ void test_list<ValueTraits>
|
||||
BOOST_TEST (testlist2.empty());
|
||||
}
|
||||
|
||||
template<class VoidPointer, bool constant_time_size>
|
||||
template < typename Value_Traits, bool Constant_Time_Size, bool Default_Holder, typename Value_Container >
|
||||
struct make_and_test_list
|
||||
: test_list< list< typename Value_Traits::value_type,
|
||||
value_traits< Value_Traits >,
|
||||
size_type< std::size_t >,
|
||||
constant_time_size< Constant_Time_Size >
|
||||
>,
|
||||
Value_Container
|
||||
>
|
||||
{};
|
||||
|
||||
template < typename Value_Traits, bool Constant_Time_Size, typename Value_Container >
|
||||
struct make_and_test_list< Value_Traits, Constant_Time_Size, false, Value_Container >
|
||||
: test_list< list< typename Value_Traits::value_type,
|
||||
value_traits< Value_Traits >,
|
||||
size_type< std::size_t >,
|
||||
constant_time_size< Constant_Time_Size >,
|
||||
header_holder_type< pointer_holder< typename Value_Traits::node_traits::node > >
|
||||
>,
|
||||
Value_Container
|
||||
>
|
||||
{};
|
||||
|
||||
|
||||
template < class VoidPointer, bool ConstantTimeSize, bool Default_Holder >
|
||||
class test_main_template
|
||||
{
|
||||
public:
|
||||
int operator()()
|
||||
{
|
||||
typedef testvalue<hooks<VoidPointer>, constant_time_size> value_type;
|
||||
typedef testvalue<hooks<VoidPointer>, ConstantTimeSize> value_type;
|
||||
std::vector<value_type> data (5);
|
||||
for (int i = 0; i < 5; ++i)
|
||||
data[i].value_ = i + 1;
|
||||
|
||||
test_list < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
make_and_test_list < typename detail::get_base_value_traits <
|
||||
value_type,
|
||||
typename hooks<VoidPointer>::base_hook_type
|
||||
>::type,
|
||||
ConstantTimeSize,
|
||||
Default_Holder,
|
||||
std::vector< value_type >
|
||||
>::test_all(data);
|
||||
test_list < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
, member_hook< value_type
|
||||
, typename hooks<VoidPointer>::member_hook_type
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
make_and_test_list < typename detail::get_member_value_traits <
|
||||
value_type,
|
||||
member_hook< value_type, typename hooks<VoidPointer>::member_hook_type, &value_type::node_>
|
||||
>::type,
|
||||
ConstantTimeSize,
|
||||
Default_Holder,
|
||||
std::vector< value_type >
|
||||
>::test_all(data);
|
||||
test_list < nonhook_node_member_value_traits< value_type,
|
||||
make_and_test_list< nonhook_node_member_value_traits <
|
||||
value_type,
|
||||
typename hooks<VoidPointer>::nonhook_node_member_type,
|
||||
&value_type::nhn_member_,
|
||||
safe_link
|
||||
>
|
||||
>,
|
||||
ConstantTimeSize,
|
||||
Default_Holder,
|
||||
std::vector< value_type >
|
||||
>::test_all(data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<class VoidPointer>
|
||||
class test_main_template<VoidPointer, false>
|
||||
template < class VoidPointer, bool Default_Holder >
|
||||
class test_main_template< VoidPointer, false, Default_Holder >
|
||||
{
|
||||
public:
|
||||
int operator()()
|
||||
@@ -460,19 +440,21 @@ class test_main_template<VoidPointer, false>
|
||||
for (int i = 0; i < 5; ++i)
|
||||
data[i].value_ = i + 1;
|
||||
|
||||
test_list < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
make_and_test_list < typename detail::get_base_value_traits <
|
||||
value_type,
|
||||
typename hooks<VoidPointer>::base_hook_type
|
||||
>::type,
|
||||
false,
|
||||
Default_Holder,
|
||||
std::vector< value_type >
|
||||
>::test_all(data);
|
||||
|
||||
test_list < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
, member_hook< value_type
|
||||
, typename hooks<VoidPointer>::member_hook_type
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
make_and_test_list < typename detail::get_member_value_traits <
|
||||
value_type,
|
||||
member_hook< value_type, typename hooks<VoidPointer>::member_hook_type, &value_type::node_>
|
||||
>::type,
|
||||
false,
|
||||
Default_Holder,
|
||||
std::vector< value_type >
|
||||
>::test_all(data);
|
||||
|
||||
// test_list<stateful_value_traits
|
||||
@@ -480,19 +462,22 @@ class test_main_template<VoidPointer, false>
|
||||
// , list_node_traits<VoidPointer>
|
||||
// , safe_link>
|
||||
// >::test_all(data);
|
||||
test_list < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::auto_base_hook_type
|
||||
>::type
|
||||
>::test_all(data);
|
||||
|
||||
test_list < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
, member_hook< value_type
|
||||
, typename hooks<VoidPointer>::auto_member_hook_type
|
||||
, &value_type::auto_node_
|
||||
>
|
||||
>::type
|
||||
make_and_test_list < typename detail::get_base_value_traits <
|
||||
value_type,
|
||||
typename hooks<VoidPointer>::auto_base_hook_type
|
||||
>::type,
|
||||
false,
|
||||
Default_Holder,
|
||||
std::vector< value_type >
|
||||
>::test_all(data);
|
||||
make_and_test_list < typename detail::get_member_value_traits <
|
||||
value_type,
|
||||
member_hook< value_type, typename hooks<VoidPointer>::auto_member_hook_type, &value_type::auto_node_>
|
||||
>::type,
|
||||
false,
|
||||
Default_Holder,
|
||||
std::vector< value_type >
|
||||
>::test_all(data);
|
||||
|
||||
// test_list<stateful_value_traits
|
||||
@@ -505,11 +490,57 @@ class test_main_template<VoidPointer, false>
|
||||
}
|
||||
};
|
||||
|
||||
template < bool Constant_Time_Size >
|
||||
struct test_main_template_bptr
|
||||
{
|
||||
int operator()()
|
||||
{
|
||||
typedef BPtr_Value value_type;
|
||||
typedef BPtr_Value_Traits< List_BPtr_Node_Traits > list_value_traits;
|
||||
typedef typename list_value_traits::node_ptr node_ptr;
|
||||
typedef Bounded_Allocator< value_type > allocator_type;
|
||||
|
||||
allocator_type::init();
|
||||
allocator_type allocator;
|
||||
|
||||
{
|
||||
Bounded_Reference_Cont< value_type > ref_cont;
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
node_ptr tmp = allocator.allocate(1);
|
||||
new (tmp.raw()) value_type(i + 1);
|
||||
ref_cont.push_back(*tmp);
|
||||
}
|
||||
|
||||
test_list < list < value_type,
|
||||
value_traits< list_value_traits >,
|
||||
size_type< std::size_t >,
|
||||
constant_time_size< Constant_Time_Size >,
|
||||
header_holder_type< Bounded_Pointer_Holder< value_type > >
|
||||
>,
|
||||
Bounded_Reference_Cont< value_type >
|
||||
>::test_all(ref_cont);
|
||||
}
|
||||
|
||||
assert(allocator_type::is_clear());
|
||||
allocator_type::destroy();
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
int main( int, char* [] )
|
||||
{
|
||||
test_main_template<void*, false>()();
|
||||
test_main_template<smart_ptr<void>, false>()();
|
||||
test_main_template<void*, true>()();
|
||||
test_main_template<smart_ptr<void>, true>()();
|
||||
// test (plain/smart pointers) x (nonconst/const size) x (void node allocator)
|
||||
test_main_template<void*, false, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false, 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();
|
||||
}
|
||||
|
@@ -13,19 +13,20 @@
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/set.hpp>
|
||||
#include "itestvalue.hpp"
|
||||
#include "bptr_value.hpp"
|
||||
#include "smart_ptr.hpp"
|
||||
#include "generic_multiset_test.hpp"
|
||||
|
||||
namespace boost { namespace intrusive { namespace test {
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_insert_before<boost::intrusive::multiset<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -59,6 +60,10 @@ struct hooks
|
||||
> nonhook_node_member_type;
|
||||
};
|
||||
|
||||
// container generator with void node allocator
|
||||
template < bool Default_Holder >
|
||||
struct GetContainer_With_Holder
|
||||
{
|
||||
template< class ValueType
|
||||
, class Option1 =void
|
||||
, class Option2 =void
|
||||
@@ -73,8 +78,36 @@ struct GetContainer
|
||||
, Option3
|
||||
> 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< rbtree_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::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
|
||||
{
|
||||
public:
|
||||
@@ -87,7 +120,7 @@ class test_main_template
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
@@ -96,21 +129,21 @@ class test_main_template
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_multiset < nonhook_node_member_value_traits< value_type,
|
||||
typename hooks<VoidPointer>::nonhook_node_member_type,
|
||||
&value_type::nhn_member_,
|
||||
safe_link
|
||||
>,
|
||||
GetContainer
|
||||
GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<class VoidPointer>
|
||||
class test_main_template<VoidPointer, false>
|
||||
template<class VoidPointer, bool Default_Holder>
|
||||
class test_main_template<VoidPointer, false, Default_Holder>
|
||||
{
|
||||
public:
|
||||
int operator()()
|
||||
@@ -122,7 +155,7 @@ class test_main_template<VoidPointer, false>
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||
@@ -132,14 +165,14 @@ class test_main_template<VoidPointer, false>
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_multiset < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::auto_base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||
@@ -149,18 +182,70 @@ class test_main_template<VoidPointer, false>
|
||||
, &value_type::auto_node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
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< rbtree_defaults, Option1, Option2, Option3 >::type packed_options;
|
||||
typedef typename packed_options::compare compare_option;
|
||||
|
||||
typedef boost::intrusive::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< RBTree_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* [] )
|
||||
{
|
||||
test_main_template<void*, false>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false>()();
|
||||
test_main_template<void*, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
|
||||
// test (plain/smart pointers) x (nonconst/const size) x (void node allocator)
|
||||
test_main_template<void*, false, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false, 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();
|
||||
}
|
||||
|
||||
|
@@ -14,19 +14,20 @@
|
||||
|
||||
#include <boost/intrusive/set.hpp>
|
||||
#include "itestvalue.hpp"
|
||||
#include "bptr_value.hpp"
|
||||
#include "smart_ptr.hpp"
|
||||
#include "generic_set_test.hpp"
|
||||
|
||||
namespace boost { namespace intrusive { namespace test {
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_insert_before<boost::intrusive::set<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -60,6 +61,10 @@ struct hooks
|
||||
> nonhook_node_member_type;
|
||||
};
|
||||
|
||||
// container generator with void node allocator
|
||||
template < bool Default_Holder >
|
||||
struct GetContainer_With_Holder
|
||||
{
|
||||
template< class ValueType
|
||||
, class Option1 =void
|
||||
, class Option2 =void
|
||||
@@ -74,8 +79,36 @@ struct GetContainer
|
||||
, Option3
|
||||
> 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< rbtree_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::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
|
||||
{
|
||||
public:
|
||||
@@ -88,7 +121,7 @@ class test_main_template
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_set < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
@@ -97,21 +130,21 @@ class test_main_template
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_set < nonhook_node_member_value_traits< value_type,
|
||||
typename hooks<VoidPointer>::nonhook_node_member_type,
|
||||
&value_type::nhn_member_,
|
||||
safe_link
|
||||
>,
|
||||
GetContainer
|
||||
GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<class VoidPointer>
|
||||
class test_main_template<VoidPointer, false>
|
||||
template<class VoidPointer, bool Default_Holder>
|
||||
class test_main_template<VoidPointer, false, Default_Holder>
|
||||
{
|
||||
public:
|
||||
int operator()()
|
||||
@@ -123,7 +156,7 @@ class test_main_template<VoidPointer, false>
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_set < typename detail::get_member_value_traits
|
||||
@@ -133,14 +166,14 @@ class test_main_template<VoidPointer, false>
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_set < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::auto_base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_set < typename detail::get_member_value_traits
|
||||
@@ -150,20 +183,72 @@ class test_main_template<VoidPointer, false>
|
||||
, &value_type::auto_node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
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< rbtree_defaults, Option1, Option2, Option3 >::type packed_options;
|
||||
typedef typename packed_options::compare compare_option;
|
||||
|
||||
typedef boost::intrusive::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< RBTree_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* [] )
|
||||
{
|
||||
test_main_template<void*, false>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false>()();
|
||||
test_main_template<void*, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
|
||||
// test (plain/smart pointers) x (nonconst/const size) x (void node allocator)
|
||||
test_main_template<void*, false, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false, 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();
|
||||
}
|
||||
|
||||
|
@@ -13,19 +13,20 @@
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/sg_set.hpp>
|
||||
#include "itestvalue.hpp"
|
||||
#include "bptr_value.hpp"
|
||||
#include "smart_ptr.hpp"
|
||||
#include "generic_multiset_test.hpp"
|
||||
|
||||
namespace boost { namespace intrusive { namespace test {
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_rebalance<boost::intrusive::sg_multiset<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -36,13 +37,13 @@ struct has_rebalance<boost::intrusive::sg_multiset<T,
|
||||
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_insert_before<boost::intrusive::sg_multiset<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -79,7 +80,7 @@ template< class ValueType
|
||||
>
|
||||
struct GetContainer
|
||||
{
|
||||
typedef boost::intrusive::sg_multiset
|
||||
typedef boost::intrusive::sg_set
|
||||
< ValueType
|
||||
, Option1
|
||||
, Option2
|
||||
@@ -94,7 +95,7 @@ template< class ValueType
|
||||
>
|
||||
struct GetContainerFixedAlpha
|
||||
{
|
||||
typedef boost::intrusive::sg_multiset
|
||||
typedef boost::intrusive::sg_set
|
||||
< ValueType
|
||||
, Option1
|
||||
, Option2
|
||||
@@ -103,7 +104,101 @@ struct GetContainerFixedAlpha
|
||||
> 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
|
||||
{
|
||||
public:
|
||||
@@ -116,7 +211,7 @@ class test_main_template
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
@@ -125,13 +220,13 @@ class test_main_template
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_multiset < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainerFixedAlpha
|
||||
, GetContainerFixedAlpha_With_Holder< Default_Holder >::template GetContainerFixedAlpha
|
||||
>::test_all();
|
||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
@@ -140,22 +235,73 @@ class test_main_template
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainerFixedAlpha
|
||||
, GetContainerFixedAlpha_With_Holder< Default_Holder >::template GetContainerFixedAlpha
|
||||
>::test_all();
|
||||
test::test_generic_multiset < nonhook_node_member_value_traits< value_type,
|
||||
typename hooks<VoidPointer>::nonhook_node_member_type,
|
||||
&value_type::nhn_member_,
|
||||
safe_link
|
||||
>,
|
||||
GetContainerFixedAlpha
|
||||
GetContainerFixedAlpha_With_Holder< Default_Holder >::template GetContainerFixedAlpha
|
||||
>::test_all();
|
||||
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* [] )
|
||||
{
|
||||
test_main_template<void*>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void> >()();
|
||||
// test (plain/smart pointers) x (const size) x (void node allocator)
|
||||
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();
|
||||
}
|
||||
|
@@ -12,19 +12,20 @@
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/sg_set.hpp>
|
||||
#include "itestvalue.hpp"
|
||||
#include "bptr_value.hpp"
|
||||
#include "smart_ptr.hpp"
|
||||
#include "generic_set_test.hpp"
|
||||
|
||||
namespace boost { namespace intrusive { namespace test {
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_rebalance<boost::intrusive::sg_set<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -34,13 +35,13 @@ struct has_rebalance<boost::intrusive::sg_set<T,
|
||||
};
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_insert_before<boost::intrusive::sg_set<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -101,7 +102,100 @@ struct GetContainerFixedAlpha
|
||||
> 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
|
||||
{
|
||||
public:
|
||||
@@ -114,7 +208,7 @@ class test_main_template
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_set < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
@@ -123,14 +217,14 @@ class test_main_template
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_set < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainerFixedAlpha
|
||||
, GetContainerFixedAlpha_With_Holder< Default_Holder >::template GetContainerFixedAlpha
|
||||
>::test_all();
|
||||
test::test_generic_set < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
@@ -139,23 +233,74 @@ class test_main_template
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainerFixedAlpha
|
||||
, GetContainerFixedAlpha_With_Holder< Default_Holder >::template GetContainerFixedAlpha
|
||||
>::test_all();
|
||||
test::test_generic_set < nonhook_node_member_value_traits< value_type,
|
||||
typename hooks<VoidPointer>::nonhook_node_member_type,
|
||||
&value_type::nhn_member_,
|
||||
safe_link
|
||||
>,
|
||||
GetContainerFixedAlpha
|
||||
GetContainerFixedAlpha_With_Holder< Default_Holder >::template GetContainerFixedAlpha
|
||||
>::test_all();
|
||||
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* [] )
|
||||
{
|
||||
test_main_template<void*>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void> >()();
|
||||
// test (plain/smart pointers) x (const size) x (void node allocator)
|
||||
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();
|
||||
}
|
||||
#include <boost/intrusive/detail/config_end.hpp>
|
||||
|
@@ -15,12 +15,14 @@
|
||||
#include <boost/intrusive/slist.hpp>
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
#include "itestvalue.hpp"
|
||||
#include "bptr_value.hpp"
|
||||
#include "smart_ptr.hpp"
|
||||
#include "common_functors.hpp"
|
||||
#include <vector>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include "test_macros.hpp"
|
||||
#include "test_container.hpp"
|
||||
#include <typeinfo>
|
||||
|
||||
using namespace boost::intrusive;
|
||||
|
||||
@@ -40,39 +42,49 @@ struct hooks
|
||||
> nonhook_node_member_type;
|
||||
};
|
||||
|
||||
template<class ValueTraits, bool Linear, bool CacheLast>
|
||||
template < typename List_Type, typename Value_Container >
|
||||
struct test_slist
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
static void test_all(std::vector<value_type>& values);
|
||||
static void test_front(std::vector<value_type>& values);
|
||||
static void test_back(std::vector<value_type>& values, detail::bool_<true>);
|
||||
static void test_back(std::vector<value_type>& values, detail::bool_<false>);
|
||||
static void test_sort(std::vector<value_type>& values);
|
||||
static void test_merge(std::vector<value_type>& values);
|
||||
static void test_remove_unique(std::vector<value_type>& values);
|
||||
static void test_insert(std::vector<value_type>& values);
|
||||
static void test_shift(std::vector<value_type>& values);
|
||||
static void test_swap(std::vector<value_type>& values);
|
||||
static void test_slow_insert(std::vector<value_type>& values);
|
||||
static void test_clone(std::vector<value_type>& values);
|
||||
static void test_container_from_end(std::vector<value_type> &, detail::bool_<true>){}
|
||||
static void test_container_from_end(std::vector<value_type> &values, detail::bool_<false>);
|
||||
typedef List_Type list_type;
|
||||
typedef typename list_type::value_traits value_traits;
|
||||
typedef typename value_traits::value_type value_type;
|
||||
typedef typename list_type::node_algorithms node_algorithms;
|
||||
|
||||
static void test_all(Value_Container&);
|
||||
static void test_front(Value_Container&);
|
||||
static void test_back(Value_Container&, detail::true_type);
|
||||
static void test_back(Value_Container&, detail::false_type) {}
|
||||
static void test_sort(Value_Container&);
|
||||
static void test_merge(Value_Container&);
|
||||
static void test_remove_unique(Value_Container&);
|
||||
static void test_insert(Value_Container&);
|
||||
static void test_shift(Value_Container&);
|
||||
static void test_swap(Value_Container&);
|
||||
static void test_slow_insert(Value_Container&);
|
||||
static void test_clone(Value_Container&);
|
||||
static void test_container_from_end(Value_Container&, detail::true_type);
|
||||
static void test_container_from_end(Value_Container&, detail::false_type) {}
|
||||
};
|
||||
|
||||
template<class ValueTraits, bool Linear, bool CacheLast>
|
||||
void test_slist<ValueTraits, Linear, CacheLast>
|
||||
::test_all (std::vector<typename ValueTraits::value_type>& values)
|
||||
template < typename List_Type, typename Value_Container >
|
||||
void test_slist< List_Type, Value_Container >
|
||||
::test_all (Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef slist
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, linear<Linear>
|
||||
, cache_last<CacheLast>
|
||||
> list_type;
|
||||
#ifdef PRINT_TESTS
|
||||
std::clog << "testing slist with:\n"
|
||||
<< " value_type = " << typeid(value_type).name() << "\n"
|
||||
<< " sizeof(value_type) = " << sizeof(value_type) << "\n"
|
||||
<< " link_mode = " << value_traits::link_mode << "\n"
|
||||
<< " node = " << typeid(typename list_type::node).name() << "\n"
|
||||
<< " sizeof(node) = " << sizeof(typename list_type::node) << "\n"
|
||||
<< " node_ptr = " << typeid(typename list_type::node_ptr).name() << "\n"
|
||||
<< " sizeof(node_ptr) = " << sizeof(typename list_type::node_ptr) << "\n"
|
||||
<< " constant_time_size = " << list_type::constant_time_size << "\n"
|
||||
<< " linear = " << list_type::linear << "\n"
|
||||
<< " cache_last = " << list_type::cache_last << "\n"
|
||||
<< " has_container_from_iterator = " << list_type::has_container_from_iterator << "\n"
|
||||
<< " sizeof(list_type) = " << sizeof(list_type) << "\n";
|
||||
#endif
|
||||
{
|
||||
list_type list(values.begin(), values.end());
|
||||
test::test_container(list);
|
||||
@@ -81,7 +93,7 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
test::test_sequence_container(list, values);
|
||||
}
|
||||
test_front(values);
|
||||
test_back(values, detail::bool_<CacheLast>());
|
||||
test_back(values, detail::bool_< list_type::cache_last >());
|
||||
test_sort(values);
|
||||
test_merge (values);
|
||||
test_remove_unique(values);
|
||||
@@ -90,23 +102,14 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
test_slow_insert (values);
|
||||
test_swap(values);
|
||||
test_clone(values);
|
||||
test_container_from_end(values, detail::bool_<Linear>());
|
||||
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:
|
||||
template<class ValueTraits, bool Linear, bool CacheLast>
|
||||
void test_slist<ValueTraits, Linear, CacheLast>
|
||||
::test_front(std::vector<typename ValueTraits::value_type>& values)
|
||||
template < typename List_Type, typename Value_Container >
|
||||
void test_slist< List_Type, Value_Container >
|
||||
::test_front(Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef slist
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, linear<Linear>
|
||||
, cache_last<CacheLast>
|
||||
> list_type;
|
||||
list_type testlist;
|
||||
BOOST_TEST (testlist.empty());
|
||||
|
||||
@@ -127,19 +130,10 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
}
|
||||
|
||||
//test: push_front, pop_front, front, size, empty:
|
||||
template<class ValueTraits, bool Linear, bool CacheLast>
|
||||
void test_slist<ValueTraits, Linear, CacheLast>
|
||||
::test_back(std::vector<typename ValueTraits::value_type>& values, detail::bool_<true>)
|
||||
template < typename List_Type, typename Value_Container >
|
||||
void test_slist< List_Type, Value_Container >
|
||||
::test_back(Value_Container& values, detail::true_type)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef slist
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, linear<Linear>
|
||||
, cache_last<CacheLast>
|
||||
> list_type;
|
||||
list_type testlist;
|
||||
BOOST_TEST (testlist.empty());
|
||||
|
||||
@@ -153,27 +147,11 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
BOOST_TEST (&testlist.back() == &values[1]);
|
||||
}
|
||||
|
||||
//test: push_front, pop_front, front, size, empty:
|
||||
template<class ValueTraits, bool Linear, bool CacheLast>
|
||||
void test_slist<ValueTraits, Linear, CacheLast>
|
||||
::test_back(std::vector<typename ValueTraits::value_type>&, detail::bool_<false>)
|
||||
{}
|
||||
|
||||
|
||||
//test: merge due to error in merge implementation:
|
||||
template<class ValueTraits, bool Linear, bool CacheLast>
|
||||
void test_slist<ValueTraits, Linear, CacheLast>
|
||||
::test_merge (std::vector<typename ValueTraits::value_type>& values)
|
||||
template < typename List_Type, typename Value_Container >
|
||||
void test_slist< List_Type, Value_Container >
|
||||
::test_merge (Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef slist
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, linear<Linear>
|
||||
, cache_last<CacheLast>
|
||||
> list_type;
|
||||
list_type testlist1, testlist2;
|
||||
testlist1.push_front (values[0]);
|
||||
testlist2.push_front (values[4]);
|
||||
@@ -186,19 +164,10 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
}
|
||||
|
||||
//test: merge due to error in merge implementation:
|
||||
template<class ValueTraits, bool Linear, bool CacheLast>
|
||||
void test_slist<ValueTraits, Linear, CacheLast>
|
||||
::test_remove_unique (std::vector<typename ValueTraits::value_type>& values)
|
||||
template < typename List_Type, typename Value_Container >
|
||||
void test_slist< List_Type, Value_Container >
|
||||
::test_remove_unique (Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef slist
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, linear<Linear>
|
||||
, cache_last<CacheLast>
|
||||
> list_type;
|
||||
{
|
||||
list_type list(values.begin(), values.end());
|
||||
list.remove_if(is_even());
|
||||
@@ -206,7 +175,7 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, list.begin() );
|
||||
}
|
||||
{
|
||||
std::vector<typename ValueTraits::value_type> values2(values);
|
||||
Value_Container values2(values);
|
||||
list_type list(values.begin(), values.end());
|
||||
list.insert_after(list.before_begin(), values2.begin(), values2.end());
|
||||
list.sort();
|
||||
@@ -219,19 +188,10 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
}
|
||||
|
||||
//test: constructor, iterator, sort, reverse:
|
||||
template<class ValueTraits, bool Linear, bool CacheLast>
|
||||
void test_slist<ValueTraits, Linear, CacheLast>
|
||||
::test_sort(std::vector<typename ValueTraits::value_type>& values)
|
||||
template < typename List_Type, typename Value_Container >
|
||||
void test_slist< List_Type, Value_Container >
|
||||
::test_sort(Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef slist
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, linear<Linear>
|
||||
, cache_last<CacheLast>
|
||||
> list_type;
|
||||
list_type testlist (values.begin(), values.end());
|
||||
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
@@ -247,21 +207,12 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
}
|
||||
|
||||
//test: assign, insert_after, const_iterator, erase_after, s_iterator_to, previous:
|
||||
template<class ValueTraits, bool Linear, bool CacheLast>
|
||||
void test_slist<ValueTraits, Linear, CacheLast>
|
||||
::test_insert(std::vector<typename ValueTraits::value_type>& values)
|
||||
template < typename List_Type, typename Value_Container >
|
||||
void test_slist< List_Type, Value_Container >
|
||||
::test_insert(Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef slist
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, linear<Linear>
|
||||
, cache_last<CacheLast>
|
||||
> list_type;
|
||||
list_type testlist;
|
||||
testlist.assign (&values[0] + 2, &values[0] + 5);
|
||||
testlist.assign (values.begin() + 2, values.begin() + 5);
|
||||
|
||||
const list_type& const_testlist = testlist;
|
||||
{ int init_values [] = { 3, 4, 5 };
|
||||
@@ -280,9 +231,9 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
BOOST_TEST (&*i == &values[4]);
|
||||
|
||||
typename list_type::const_iterator ic;
|
||||
ic = testlist.iterator_to (const_cast<const value_type &>(values[4]));
|
||||
ic = testlist.iterator_to (static_cast< typename list_type::const_reference >(values[4]));
|
||||
BOOST_TEST (&*ic == &values[4]);
|
||||
ic = list_type::s_iterator_to (const_cast<const value_type &>(values[4]));
|
||||
ic = list_type::s_iterator_to (static_cast< typename list_type::const_reference >(values[4]));
|
||||
BOOST_TEST (&*ic == &values[4]);
|
||||
|
||||
i = testlist.previous (i);
|
||||
@@ -295,22 +246,13 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
}
|
||||
|
||||
//test: insert, const_iterator, erase, siterator_to:
|
||||
template<class ValueTraits, bool Linear, bool CacheLast>
|
||||
void test_slist<ValueTraits, Linear, CacheLast>
|
||||
::test_slow_insert (std::vector<typename ValueTraits::value_type>& values)
|
||||
template < typename List_Type, typename Value_Container >
|
||||
void test_slist< List_Type, Value_Container >
|
||||
::test_slow_insert (Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef slist
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, linear<Linear>
|
||||
, cache_last<CacheLast>
|
||||
> list_type;
|
||||
list_type testlist;
|
||||
testlist.push_front (values[4]);
|
||||
testlist.insert (testlist.begin(), &values[0] + 2, &values[0] + 4);
|
||||
testlist.insert (testlist.begin(), values.begin() + 2, values.begin() + 4);
|
||||
|
||||
const list_type& const_testlist = testlist;
|
||||
{ int init_values [] = { 3, 4, 5 };
|
||||
@@ -337,24 +279,14 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
|
||||
testlist.erase (++testlist.begin(), testlist.end());
|
||||
BOOST_TEST (testlist.size() == 1);
|
||||
BOOST_TEST (testlist.front().value_ == 3);
|
||||
BOOST_TEST (testlist.begin()->value_ == 3);
|
||||
}
|
||||
|
||||
template<class ValueTraits, bool Linear, bool CacheLast>
|
||||
void test_slist<ValueTraits, Linear, CacheLast>
|
||||
::test_shift(std::vector<typename ValueTraits::value_type>& values)
|
||||
template < typename List_Type, typename Value_Container >
|
||||
void test_slist< List_Type, Value_Container >
|
||||
::test_shift(Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef slist
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, linear<Linear>
|
||||
, cache_last<CacheLast>
|
||||
> list_type;
|
||||
list_type testlist;
|
||||
|
||||
const int num_values = (int)values.size();
|
||||
std::vector<int> expected_values(num_values);
|
||||
|
||||
@@ -362,7 +294,7 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
for(int s = 1; s <= num_values; ++s){
|
||||
expected_values.resize(s);
|
||||
for(int i = 0; i < s*3; ++i){
|
||||
testlist.insert_after(testlist.before_begin(), &values[0], &values[0] + s);
|
||||
testlist.insert_after(testlist.before_begin(), values.begin(), values.begin() + s);
|
||||
testlist.shift_forward(i);
|
||||
for(int j = 0; j < s; ++j){
|
||||
expected_values[(j + s - i%s) % s] = (j + 1);
|
||||
@@ -374,7 +306,7 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
|
||||
//Shift backwards all possible positions
|
||||
for(int i = 0; i < s*3; ++i){
|
||||
testlist.insert_after(testlist.before_begin(), &values[0], &values[0] + s);
|
||||
testlist.insert_after(testlist.before_begin(), values.begin(), values.begin() + s);
|
||||
testlist.shift_backwards(i);
|
||||
for(int j = 0; j < s; ++j){
|
||||
expected_values[(j + i) % s] = (j + 1);
|
||||
@@ -387,23 +319,14 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
}
|
||||
|
||||
//test: insert_after (seq-version), swap, splice_after:
|
||||
template<class ValueTraits, bool Linear, bool CacheLast>
|
||||
void test_slist<ValueTraits, Linear, CacheLast>
|
||||
::test_swap(std::vector<typename ValueTraits::value_type>& values)
|
||||
template < typename List_Type, typename Value_Container >
|
||||
void test_slist< List_Type, Value_Container >
|
||||
::test_swap(Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef slist
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, linear<Linear>
|
||||
, cache_last<CacheLast>
|
||||
> list_type;
|
||||
{
|
||||
list_type testlist1 (&values[0], &values[0] + 2);
|
||||
list_type testlist1 (values.begin(), values.begin() + 2);
|
||||
list_type testlist2;
|
||||
testlist2.insert_after (testlist2.before_begin(), &values[0] + 2, &values[0] + 5);
|
||||
testlist2.insert_after (testlist2.before_begin(), values.begin() + 2, values.begin() + 5);
|
||||
testlist1.swap(testlist2);
|
||||
{ int init_values [] = { 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
@@ -428,7 +351,7 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
|
||||
}
|
||||
{ //Now test swap when testlist2 is empty
|
||||
list_type testlist1 (&values[0], &values[0] + 2);
|
||||
list_type testlist1 (values.begin(), values.begin() + 2);
|
||||
list_type testlist2;
|
||||
testlist1.swap(testlist2);
|
||||
BOOST_TEST (testlist1.empty());
|
||||
@@ -436,7 +359,7 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
|
||||
}
|
||||
{ //Now test swap when testlist1 is empty
|
||||
list_type testlist2 (&values[0], &values[0] + 2);
|
||||
list_type testlist2 (values.begin(), values.begin() + 2);
|
||||
list_type testlist1;
|
||||
testlist1.swap(testlist2);
|
||||
BOOST_TEST (testlist2.empty());
|
||||
@@ -451,14 +374,14 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
|
||||
if(!list_type::linear)
|
||||
{
|
||||
list_type testlist1 (&values[0], &values[0] + 2);
|
||||
list_type testlist2 (&values[0] + 3, &values[0] + 5);
|
||||
list_type testlist1 (values.begin(), values.begin() + 2);
|
||||
list_type testlist2 (values.begin() + 3, values.begin() + 5);
|
||||
|
||||
values[0].swap_nodes(values[2]);
|
||||
swap_nodes< node_algorithms >(values[0], values[2]);
|
||||
{ int init_values [] = { 3, 2 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
values[2].swap_nodes(values[4]);
|
||||
swap_nodes< node_algorithms >(values[2], values[4]);
|
||||
{ int init_values [] = { 5, 2 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
{ int init_values [] = { 4, 3 };
|
||||
@@ -466,52 +389,42 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
}
|
||||
if(!list_type::linear)
|
||||
{
|
||||
list_type testlist1 (&values[0], &values[0]+1);
|
||||
list_type testlist1 (values.begin(), values.begin()+1);
|
||||
if(testlist1.size() != 1){
|
||||
abort();
|
||||
}
|
||||
{ int init_values [] = { 1 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
values[1].swap_nodes(values[2]);
|
||||
swap_nodes< node_algorithms >(values[1], values[2]);
|
||||
|
||||
BOOST_TEST(testlist1.size() == 1);
|
||||
BOOST_TEST(!values[1].is_linked());
|
||||
BOOST_TEST(!values[2].is_linked());
|
||||
BOOST_TEST(!(&values[1])->is_linked());
|
||||
BOOST_TEST(!(&values[2])->is_linked());
|
||||
{ int init_values [] = { 1 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
values[0].swap_nodes(values[2]);
|
||||
swap_nodes< node_algorithms >(values[0], values[2]);
|
||||
BOOST_TEST(testlist1.size() == 1);
|
||||
BOOST_TEST(values[2].is_linked());
|
||||
BOOST_TEST(!values[0].is_linked());
|
||||
BOOST_TEST((&values[2])->is_linked());
|
||||
BOOST_TEST(!(&values[0])->is_linked());
|
||||
{ int init_values [] = { 3 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
values[0].swap_nodes(values[2]);
|
||||
swap_nodes< node_algorithms >(values[0], values[2]);
|
||||
BOOST_TEST(testlist1.size() == 1);
|
||||
BOOST_TEST(!values[2].is_linked());
|
||||
BOOST_TEST(values[0].is_linked());
|
||||
BOOST_TEST(!(&values[2])->is_linked());
|
||||
BOOST_TEST((&values[0])->is_linked());
|
||||
{ int init_values [] = { 1 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
}
|
||||
}
|
||||
|
||||
template<class ValueTraits, bool Linear, bool CacheLast>
|
||||
void test_slist<ValueTraits, Linear, CacheLast>
|
||||
::test_clone(std::vector<typename ValueTraits::value_type>& values)
|
||||
template < typename List_Type, typename Value_Container >
|
||||
void test_slist< List_Type, Value_Container >
|
||||
::test_clone(Value_Container& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef slist
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, linear<Linear>
|
||||
, cache_last<CacheLast>
|
||||
> list_type;
|
||||
|
||||
list_type testlist1 (&values[0], &values[0] + values.size());
|
||||
list_type testlist1 (values.begin(), values.begin() + values.size());
|
||||
list_type testlist2;
|
||||
|
||||
testlist2.clone_from(testlist1, test::new_cloner<value_type>(), test::delete_disposer<value_type>());
|
||||
@@ -520,144 +433,191 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
BOOST_TEST (testlist2.empty());
|
||||
}
|
||||
|
||||
template<class ValueTraits, bool Linear, bool CacheLast>
|
||||
void test_slist<ValueTraits, Linear, CacheLast>
|
||||
::test_container_from_end(std::vector<typename ValueTraits::value_type>& values
|
||||
,detail::bool_<false>)
|
||||
template < typename List_Type, typename Value_Container >
|
||||
void test_slist< List_Type, Value_Container >
|
||||
::test_container_from_end(Value_Container& values, detail::true_type)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef slist
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, size_type<std::size_t>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, linear<Linear>
|
||||
, cache_last<CacheLast>
|
||||
> list_type;
|
||||
list_type testlist1 (&values[0], &values[0] + 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.cend()));
|
||||
}
|
||||
|
||||
template<class VoidPointer, bool constant_time_size>
|
||||
template < typename Value_Traits, bool Constant_Time_Size, bool Linear, bool CacheLast, bool Default_Holder, typename Value_Container >
|
||||
struct make_and_test_slist
|
||||
: test_slist< slist< typename Value_Traits::value_type,
|
||||
value_traits< Value_Traits >,
|
||||
size_type< std::size_t >,
|
||||
constant_time_size< Constant_Time_Size >,
|
||||
linear<Linear>,
|
||||
cache_last<CacheLast>
|
||||
>,
|
||||
Value_Container
|
||||
>
|
||||
{};
|
||||
|
||||
template < typename Value_Traits, bool Constant_Time_Size, bool Linear, bool CacheLast, typename Value_Container >
|
||||
struct make_and_test_slist< Value_Traits, Constant_Time_Size, Linear, CacheLast, false, Value_Container >
|
||||
: test_slist< slist< typename Value_Traits::value_type,
|
||||
value_traits< Value_Traits >,
|
||||
size_type< std::size_t >,
|
||||
constant_time_size< Constant_Time_Size >,
|
||||
linear<Linear>,
|
||||
cache_last<CacheLast>,
|
||||
header_holder_type< pointer_holder< typename Value_Traits::node_traits::node > >
|
||||
>,
|
||||
Value_Container
|
||||
>
|
||||
{};
|
||||
|
||||
template<class VoidPointer, bool constant_time_size, bool Default_Holder>
|
||||
class test_main_template
|
||||
{
|
||||
public:
|
||||
int operator()()
|
||||
{
|
||||
typedef testvalue<hooks<VoidPointer> , constant_time_size> value_type;
|
||||
std::vector<value_type> data (5);
|
||||
std::vector< value_type > data (5);
|
||||
for (int i = 0; i < 5; ++i)
|
||||
data[i].value_ = i + 1;
|
||||
|
||||
test_slist < typename detail::get_base_value_traits
|
||||
make_and_test_slist < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, constant_time_size
|
||||
, false
|
||||
, false
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
test_slist < typename detail::get_member_value_traits
|
||||
make_and_test_slist < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
, member_hook< value_type
|
||||
, typename hooks<VoidPointer>::member_hook_type
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, constant_time_size
|
||||
, false
|
||||
, false
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
test_slist < nonhook_node_member_value_traits< value_type,
|
||||
make_and_test_slist < nonhook_node_member_value_traits< value_type,
|
||||
typename hooks<VoidPointer>::nonhook_node_member_type,
|
||||
&value_type::nhn_member_,
|
||||
safe_link
|
||||
>,
|
||||
false,
|
||||
false
|
||||
>
|
||||
, constant_time_size
|
||||
, false
|
||||
, false
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
|
||||
//Now linear slists
|
||||
test_slist < typename detail::get_base_value_traits
|
||||
make_and_test_slist < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, constant_time_size
|
||||
, true
|
||||
, false
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
|
||||
test_slist < typename detail::get_member_value_traits
|
||||
make_and_test_slist < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
, member_hook< value_type
|
||||
, typename hooks<VoidPointer>::member_hook_type
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, constant_time_size
|
||||
, true
|
||||
, false
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
|
||||
//Now the same but caching the last node
|
||||
test_slist < typename detail::get_base_value_traits
|
||||
make_and_test_slist < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, constant_time_size
|
||||
, false
|
||||
, true
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
test_slist < typename detail::get_member_value_traits
|
||||
make_and_test_slist < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
, member_hook< value_type
|
||||
, typename hooks<VoidPointer>::member_hook_type
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, constant_time_size
|
||||
, false
|
||||
, true
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
|
||||
//Now linear slists
|
||||
test_slist < typename detail::get_base_value_traits
|
||||
make_and_test_slist < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, constant_time_size
|
||||
, true
|
||||
, true
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
|
||||
test_slist < typename detail::get_member_value_traits
|
||||
make_and_test_slist < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
, member_hook< value_type
|
||||
, typename hooks<VoidPointer>::member_hook_type
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, constant_time_size
|
||||
, true
|
||||
, true
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<class VoidPointer>
|
||||
class test_main_template<VoidPointer, false>
|
||||
template<class VoidPointer, bool Default_Holder>
|
||||
class test_main_template<VoidPointer, false, Default_Holder>
|
||||
{
|
||||
public:
|
||||
int operator()()
|
||||
{
|
||||
typedef testvalue<hooks<VoidPointer> , false> value_type;
|
||||
std::vector<value_type> data (5);
|
||||
std::vector< value_type > data (5);
|
||||
for (int i = 0; i < 5; ++i)
|
||||
data[i].value_ = i + 1;
|
||||
|
||||
test_slist < typename detail::get_base_value_traits
|
||||
make_and_test_slist < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, false
|
||||
, false
|
||||
, false
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
|
||||
test_slist < typename detail::get_member_value_traits
|
||||
make_and_test_slist < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
, member_hook< value_type
|
||||
, typename hooks<VoidPointer>::member_hook_type
|
||||
@@ -666,17 +626,23 @@ class test_main_template<VoidPointer, false>
|
||||
>::type
|
||||
, false
|
||||
, false
|
||||
, false
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
|
||||
test_slist < typename detail::get_base_value_traits
|
||||
make_and_test_slist < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::auto_base_hook_type
|
||||
>::type
|
||||
, false
|
||||
, false
|
||||
, false
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
|
||||
test_slist < typename detail::get_member_value_traits
|
||||
make_and_test_slist < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
, member_hook< value_type
|
||||
, typename hooks<VoidPointer>::auto_member_hook_type
|
||||
@@ -685,37 +651,74 @@ class test_main_template<VoidPointer, false>
|
||||
>::type
|
||||
, false
|
||||
, false
|
||||
, false
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
|
||||
test_slist < typename detail::get_base_value_traits
|
||||
make_and_test_slist < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, false
|
||||
, true
|
||||
, false
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
|
||||
test_slist < typename detail::get_member_value_traits
|
||||
make_and_test_slist < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
, member_hook< value_type
|
||||
, typename hooks<VoidPointer>::member_hook_type
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, false
|
||||
, true
|
||||
, false
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
|
||||
//Now cache last
|
||||
test_slist < typename detail::get_base_value_traits
|
||||
make_and_test_slist < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, false
|
||||
, false
|
||||
, true
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
|
||||
make_and_test_slist < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
, member_hook< value_type
|
||||
, typename hooks<VoidPointer>::member_hook_type
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, false
|
||||
, false
|
||||
, true
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
|
||||
make_and_test_slist < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, false
|
||||
, true
|
||||
, true
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
|
||||
test_slist < typename detail::get_member_value_traits
|
||||
make_and_test_slist < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
, member_hook< value_type
|
||||
, typename hooks<VoidPointer>::member_hook_type
|
||||
@@ -724,36 +727,67 @@ class test_main_template<VoidPointer, false>
|
||||
>::type
|
||||
, false
|
||||
, true
|
||||
, true
|
||||
, Default_Holder
|
||||
, std::vector< value_type >
|
||||
>::test_all(data);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
test_slist < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, true
|
||||
, true
|
||||
>::test_all(data);
|
||||
template < bool Constant_Time_Size >
|
||||
struct test_main_template_bptr
|
||||
{
|
||||
int operator()()
|
||||
{
|
||||
typedef BPtr_Value value_type;
|
||||
typedef BPtr_Value_Traits< List_BPtr_Node_Traits > list_value_traits;
|
||||
typedef typename list_value_traits::node_ptr node_ptr;
|
||||
typedef Bounded_Allocator< value_type > allocator_type;
|
||||
|
||||
test_slist < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
, member_hook< value_type
|
||||
, typename hooks<VoidPointer>::member_hook_type
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, true
|
||||
, true
|
||||
>::test_all(data);
|
||||
allocator_type::init();
|
||||
allocator_type allocator;
|
||||
|
||||
{
|
||||
Bounded_Reference_Cont< value_type > ref_cont;
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
node_ptr tmp = allocator.allocate(1);
|
||||
new (tmp.raw()) value_type(i + 1);
|
||||
ref_cont.push_back(*tmp);
|
||||
}
|
||||
|
||||
test_slist < slist < value_type,
|
||||
value_traits< list_value_traits >,
|
||||
size_type< std::size_t >,
|
||||
constant_time_size< Constant_Time_Size >,
|
||||
header_holder_type< Bounded_Pointer_Holder< value_type > >
|
||||
>,
|
||||
Bounded_Reference_Cont< value_type >
|
||||
>::test_all(ref_cont);
|
||||
}
|
||||
|
||||
assert(allocator_type::is_clear());
|
||||
allocator_type::destroy();
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
int main(int, char* [])
|
||||
{
|
||||
test_main_template<void*, false>()();
|
||||
test_main_template<smart_ptr<void>, false>()();
|
||||
test_main_template<void*, true>()();
|
||||
test_main_template<smart_ptr<void>, true>()();
|
||||
// test (plain/smart pointers) x (nonconst/const size) x (void node allocator)
|
||||
test_main_template<void*, false, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false, 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();
|
||||
}
|
||||
#include <boost/intrusive/detail/config_end.hpp>
|
||||
|
@@ -14,19 +14,20 @@
|
||||
#include <boost/intrusive/splay_set.hpp>
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
#include "itestvalue.hpp"
|
||||
#include "bptr_value.hpp"
|
||||
#include "smart_ptr.hpp"
|
||||
#include "generic_multiset_test.hpp"
|
||||
|
||||
namespace boost { namespace intrusive { namespace test {
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_splay<boost::intrusive::splay_multiset<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -36,13 +37,13 @@ struct has_splay<boost::intrusive::splay_multiset<T,
|
||||
};
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_rebalance<boost::intrusive::splay_multiset<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -52,13 +53,13 @@ struct has_rebalance<boost::intrusive::splay_multiset<T,
|
||||
};
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_const_searches<boost::intrusive::splay_multiset<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -91,6 +92,10 @@ struct hooks
|
||||
> nonhook_node_member_type;
|
||||
};
|
||||
|
||||
// container generator with void node allocator
|
||||
template < bool Default_Holder >
|
||||
struct GetContainer_With_Holder
|
||||
{
|
||||
template< class ValueType
|
||||
, class Option1 =void
|
||||
, class Option2 =void
|
||||
@@ -105,8 +110,35 @@ struct GetContainer
|
||||
, Option3
|
||||
> 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
|
||||
{
|
||||
public:
|
||||
@@ -119,7 +151,7 @@ class test_main_template
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
@@ -128,22 +160,22 @@ class test_main_template
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_multiset < nonhook_node_member_value_traits< value_type,
|
||||
typename hooks<VoidPointer>::nonhook_node_member_type,
|
||||
&value_type::nhn_member_,
|
||||
safe_link
|
||||
>,
|
||||
GetContainer
|
||||
GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<class VoidPointer>
|
||||
class test_main_template<VoidPointer, false>
|
||||
template<class VoidPointer, bool Default_Holder>
|
||||
class test_main_template<VoidPointer, false, Default_Holder>
|
||||
{
|
||||
public:
|
||||
int operator()()
|
||||
@@ -155,7 +187,7 @@ class test_main_template<VoidPointer, false>
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||
@@ -165,14 +197,14 @@ class test_main_template<VoidPointer, false>
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_multiset < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::auto_base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||
@@ -182,17 +214,69 @@ class test_main_template<VoidPointer, false>
|
||||
, &value_type::auto_node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
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* [] )
|
||||
{
|
||||
test_main_template<void*, false>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false>()();
|
||||
test_main_template<void*, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
|
||||
// test (plain/smart pointers) x (nonconst/const size) x (void node allocator)
|
||||
test_main_template<void*, false, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false, 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();
|
||||
}
|
||||
|
@@ -12,19 +12,20 @@
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/splay_set.hpp>
|
||||
#include "itestvalue.hpp"
|
||||
#include "bptr_value.hpp"
|
||||
#include "smart_ptr.hpp"
|
||||
#include "generic_set_test.hpp"
|
||||
|
||||
namespace boost { namespace intrusive { namespace test {
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_splay<boost::intrusive::splay_set<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -34,13 +35,13 @@ struct has_splay<boost::intrusive::splay_set<T,
|
||||
};
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_rebalance<boost::intrusive::splay_set<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -50,13 +51,13 @@ struct has_rebalance<boost::intrusive::splay_set<T,
|
||||
};
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_const_searches<boost::intrusive::splay_set<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -88,6 +89,10 @@ struct hooks
|
||||
> nonhook_node_member_type;
|
||||
};
|
||||
|
||||
// container generator with void node allocator
|
||||
template < bool Default_Holder >
|
||||
struct GetContainer_With_Holder
|
||||
{
|
||||
template< class ValueType
|
||||
, class Option1 =void
|
||||
, class Option2 =void
|
||||
@@ -102,8 +107,35 @@ struct GetContainer
|
||||
, Option3
|
||||
> 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
|
||||
{
|
||||
public:
|
||||
@@ -116,7 +148,7 @@ class test_main_template
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_set < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
@@ -125,21 +157,21 @@ class test_main_template
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_set < nonhook_node_member_value_traits< value_type,
|
||||
typename hooks<VoidPointer>::nonhook_node_member_type,
|
||||
&value_type::nhn_member_,
|
||||
safe_link
|
||||
>,
|
||||
GetContainer
|
||||
GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<class VoidPointer>
|
||||
class test_main_template<VoidPointer, false>
|
||||
template<class VoidPointer, bool Default_Holder>
|
||||
class test_main_template<VoidPointer, false, Default_Holder>
|
||||
{
|
||||
public:
|
||||
int operator()()
|
||||
@@ -151,7 +183,7 @@ class test_main_template<VoidPointer, false>
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_set < typename detail::get_member_value_traits
|
||||
@@ -161,14 +193,14 @@ class test_main_template<VoidPointer, false>
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_set < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::auto_base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_set < typename detail::get_member_value_traits
|
||||
@@ -178,19 +210,71 @@ class test_main_template<VoidPointer, false>
|
||||
, &value_type::auto_node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
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* [] )
|
||||
{
|
||||
test_main_template<void*, false>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false>()();
|
||||
test_main_template<void*, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
|
||||
// test (plain/smart pointers) x (nonconst/const size) x (void node allocator)
|
||||
test_main_template<void*, false, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false, 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();
|
||||
}
|
||||
#include <boost/intrusive/detail/config_end.hpp>
|
||||
|
@@ -428,12 +428,15 @@ void test_unordered_associative_container(Container & c, Data & d)
|
||||
template< class Container, class Data >
|
||||
void test_unique_container(Container & c, Data & d)
|
||||
{
|
||||
typedef typename Container::value_type value_type;
|
||||
//typedef typename Container::value_type value_type;
|
||||
c.clear();
|
||||
c.insert(d.begin(),d.end());
|
||||
typename Container::size_type old_size = c.size();
|
||||
value_type v(*d.begin());
|
||||
c.insert(v);
|
||||
//value_type v(*d.begin());
|
||||
//c.insert(v);
|
||||
Data d2(1);
|
||||
(&d2.front())->value_ = (&d.front())->value_;
|
||||
c.insert(d2.front());
|
||||
BOOST_TEST( c.size() == old_size );
|
||||
c.clear();
|
||||
}
|
||||
@@ -441,12 +444,15 @@ void test_unique_container(Container & c, Data & d)
|
||||
template< class Container, class Data >
|
||||
void test_non_unique_container(Container & c, Data & d)
|
||||
{
|
||||
typedef typename Container::value_type value_type;
|
||||
//typedef typename Container::value_type value_type;
|
||||
c.clear();
|
||||
c.insert(d.begin(),d.end());
|
||||
typename Container::size_type old_size = c.size();
|
||||
value_type v(*d.begin());
|
||||
c.insert(v);
|
||||
//value_type v(*d.begin());
|
||||
//c.insert(v);
|
||||
Data d2(1);
|
||||
(&d2.front())->value_ = (&d.front())->value_;
|
||||
c.insert(d2.front());
|
||||
BOOST_TEST( c.size() == (old_size+1) );
|
||||
c.clear();
|
||||
}
|
||||
|
@@ -14,19 +14,20 @@
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/treap_set.hpp>
|
||||
#include "itestvalue.hpp"
|
||||
#include "bptr_value.hpp"
|
||||
#include "smart_ptr.hpp"
|
||||
#include "generic_multiset_test.hpp"
|
||||
|
||||
namespace boost { namespace intrusive { namespace test {
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_insert_before<boost::intrusive::treap_multiset<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -57,6 +58,10 @@ struct hooks
|
||||
> nonhook_node_member_type;
|
||||
};
|
||||
|
||||
// container generator with void node allocator
|
||||
template < bool Default_Holder >
|
||||
struct GetContainer_With_Holder
|
||||
{
|
||||
template< class ValueType
|
||||
, class Option1 =void
|
||||
, class Option2 =void
|
||||
@@ -71,8 +76,35 @@ struct GetContainer
|
||||
, Option3
|
||||
> 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
|
||||
{
|
||||
public:
|
||||
@@ -85,7 +117,7 @@ class test_main_template
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
@@ -94,21 +126,21 @@ class test_main_template
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_multiset < nonhook_node_member_value_traits< value_type,
|
||||
typename hooks<VoidPointer>::nonhook_node_member_type,
|
||||
&value_type::nhn_member_,
|
||||
safe_link
|
||||
>,
|
||||
GetContainer
|
||||
GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<class VoidPointer>
|
||||
class test_main_template<VoidPointer, false>
|
||||
template<class VoidPointer, bool Default_Holder>
|
||||
class test_main_template<VoidPointer, false, Default_Holder>
|
||||
{
|
||||
public:
|
||||
int operator()()
|
||||
@@ -120,7 +152,7 @@ class test_main_template<VoidPointer, false>
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||
@@ -130,14 +162,14 @@ class test_main_template<VoidPointer, false>
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_multiset < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::auto_base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_multiset < typename detail::get_member_value_traits
|
||||
@@ -147,18 +179,70 @@ class test_main_template<VoidPointer, false>
|
||||
, &value_type::auto_node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
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* [] )
|
||||
{
|
||||
test_main_template<void*, false>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false>()();
|
||||
test_main_template<void*, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
|
||||
// test (plain/smart pointers) x (nonconst/const size) x (void node allocator)
|
||||
test_main_template<void*, false, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false, 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();
|
||||
}
|
||||
|
||||
|
@@ -12,19 +12,20 @@
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/treap_set.hpp>
|
||||
#include "itestvalue.hpp"
|
||||
#include "bptr_value.hpp"
|
||||
#include "smart_ptr.hpp"
|
||||
#include "generic_set_test.hpp"
|
||||
|
||||
namespace boost { namespace intrusive { namespace test {
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_insert_before<boost::intrusive::treap_set<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -34,13 +35,13 @@ struct has_insert_before<boost::intrusive::treap_set<T,
|
||||
};
|
||||
|
||||
#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
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct is_treap<boost::intrusive::treap_set<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
O1, O2, O3, O4, O5
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
@@ -72,6 +73,10 @@ struct hooks
|
||||
> nonhook_node_member_type;
|
||||
};
|
||||
|
||||
// container generator with void node allocator
|
||||
template < bool Default_Holder >
|
||||
struct GetContainer_With_Holder
|
||||
{
|
||||
template< class ValueType
|
||||
, class Option1 =void
|
||||
, class Option2 =void
|
||||
@@ -86,8 +91,35 @@ struct GetContainer
|
||||
, Option3
|
||||
> 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
|
||||
{
|
||||
public:
|
||||
@@ -100,7 +132,7 @@ class test_main_template
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_set < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
@@ -109,21 +141,21 @@ class test_main_template
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
test::test_generic_set < nonhook_node_member_value_traits< value_type,
|
||||
typename hooks<VoidPointer>::nonhook_node_member_type,
|
||||
&value_type::nhn_member_,
|
||||
safe_link
|
||||
>,
|
||||
GetContainer
|
||||
GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<class VoidPointer>
|
||||
class test_main_template<VoidPointer, false>
|
||||
template<class VoidPointer, bool Default_Holder>
|
||||
class test_main_template<VoidPointer, false, Default_Holder>
|
||||
{
|
||||
public:
|
||||
int operator()()
|
||||
@@ -135,7 +167,7 @@ class test_main_template<VoidPointer, false>
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_set < typename detail::get_member_value_traits
|
||||
@@ -145,14 +177,14 @@ class test_main_template<VoidPointer, false>
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_set < typename detail::get_base_value_traits
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::auto_base_hook_type
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
test::test_generic_set < typename detail::get_member_value_traits
|
||||
@@ -162,19 +194,71 @@ class test_main_template<VoidPointer, false>
|
||||
, &value_type::auto_node_
|
||||
>
|
||||
>::type
|
||||
, GetContainer
|
||||
, GetContainer_With_Holder< Default_Holder >::template GetContainer
|
||||
>::test_all();
|
||||
|
||||
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* [] )
|
||||
{
|
||||
test_main_template<void*, false>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false>()();
|
||||
test_main_template<void*, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
|
||||
// test (plain/smart pointers) x (nonconst/const size) x (void node allocator)
|
||||
test_main_template<void*, false, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false, 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();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user