* Big refactoring in order to reduce template and debug symbol bloat.

* Fixes #8698
* Implemented SCARY iterators

[SVN r85165]
This commit is contained in:
Ion Gaztañaga
2013-07-28 22:10:37 +00:00
parent 83f5f4b95b
commit fbd8e26461
146 changed files with 12087 additions and 22796 deletions
+2 -1
View File
@@ -1,7 +1,8 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2012.
// (C) Copyright Ion Gaztanaga 2006-2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
+4 -4
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2012.
// (C) Copyright Ion Gaztanaga 2006-2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -58,9 +58,9 @@ struct hooks
};
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
, class Option1 =void
, class Option2 =void
, class Option3 =void
>
struct GetContainer
{
+4 -4
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2012.
// (C) Copyright Ion Gaztanaga 2006-2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -58,9 +58,9 @@ struct hooks
};
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
, class Option1 =void
, class Option2 =void
, class Option3 =void
>
struct GetContainer
{
+1 -1
View File
@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2012
// (C) Copyright Ion Gaztanaga 2006-2013
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
+1 -1
View File
@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007-2012
// (C) Copyright Ion Gaztanaga 2007-2013
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
+92 -54
View File
@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007-2012
// (C) Copyright Ion Gaztanaga 2007-2013
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -16,6 +16,8 @@
#include <boost/intrusive/splay_set.hpp>
#include <boost/intrusive/avl_set.hpp>
#include <boost/intrusive/sg_set.hpp>
#include <boost/intrusive/treap_set.hpp>
#include <boost/intrusive/bs_set.hpp>
#include <boost/intrusive/pointer_traits.hpp>
#include "smart_ptr.hpp"
#include <vector>
@@ -25,19 +27,17 @@ using namespace boost::intrusive;
class MyClass
: public list_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >
< void_pointer<smart_ptr<void> >, link_mode<safe_link> >
, public slist_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >
< void_pointer<smart_ptr<void> >, link_mode<safe_link> >
, public set_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >
< void_pointer<smart_ptr<void> >, link_mode<safe_link> >
, public unordered_set_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >
< void_pointer<smart_ptr<void> >, link_mode<safe_link> >
, public avl_set_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >
, public splay_set_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >
< void_pointer<smart_ptr<void> >, link_mode<safe_link> >
, public bs_set_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >
< void_pointer<smart_ptr<void> >, link_mode<safe_link> >
{
int int_;
@@ -54,6 +54,9 @@ class MyClass
friend std::size_t hash_value(const MyClass &v)
{ return boost::hash_value(v.int_); }
friend bool priority_order(const MyClass &l, const MyClass &r)
{ return l.int_ < r.int_; }
};
//Define a list that will store MyClass using the public base hook
@@ -63,7 +66,9 @@ typedef set<MyClass> Set;
typedef unordered_set<MyClass> USet;
typedef avl_set<MyClass> AvlSet;
typedef splay_set<MyClass> SplaySet;
typedef treap_set<MyClass> TreapSet;
typedef sg_set<MyClass> SgSet;
typedef bs_set<MyClass> BsSet;
int main()
{
@@ -73,56 +78,89 @@ int main()
//Create several MyClass objects, each one with a different value
std::vector<MyClass> values;
for(int i = 0; i < 100; ++i) values.push_back(MyClass(i));
USet::bucket_type buckets[100];
List my_list;
Slist my_slist;
Set my_set;
USet my_uset(USet::bucket_traits(pointer_traits<USet::bucket_ptr>::pointer_to(*buckets), 100));
AvlSet my_avlset;
SplaySet my_splayset;
SgSet my_sgset;
//Now insert them in the reverse order
//in the base hook intrusive list
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it){
my_list.push_front(*it);
my_slist.push_front(*it);
my_set.insert(*it);
my_uset.insert(*it);
my_avlset.insert(*it);
my_splayset.insert(*it);
my_sgset.insert(*it);
}
//Now test lists
{
List::const_iterator list_it(my_list.cbegin());
Slist::const_iterator slist_it(my_slist.cbegin());
Set::const_reverse_iterator set_rit(my_set.crbegin());
AvlSet::const_reverse_iterator avl_set_rit(my_avlset.crbegin());
SplaySet::const_reverse_iterator splay_set_rit(my_splayset.crbegin());
SgSet::const_reverse_iterator sg_set_rit(my_sgset.crbegin());
List my_list;
Slist my_slist;
Set my_set;
USet::bucket_type buckets[100];
USet my_uset(USet::bucket_traits(pointer_traits<USet::bucket_ptr>::pointer_to(*buckets), 100));
AvlSet my_avlset;
SplaySet my_splayset;
VectRit vect_it(values.rbegin()), vect_itend(values.rend());
//Now insert them in the reverse order
//in the base hook intrusive list
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it){
my_list.push_front(*it);
my_slist.push_front(*it);
my_set.insert(*it);
my_uset.insert(*it);
my_avlset.insert(*it);
my_splayset.insert(*it);
}
//Test the objects inserted in the base hook list
for(; vect_it != vect_itend
; ++vect_it, ++list_it
, ++slist_it, ++set_rit
, ++avl_set_rit, ++splay_set_rit
, ++sg_set_rit){
if(&*list_it != &*vect_it) return 1;
if(&*slist_it != &*vect_it) return 1;
if(&*set_rit != &*vect_it) return 1;
if(&*avl_set_rit != &*vect_it) return 1;
if(&*splay_set_rit != &*vect_it)return 1;
if(&*sg_set_rit != &*vect_it) return 1;
if(my_uset.find(*set_rit) == my_uset.cend()) return 1;
//Now test lists
{
List::const_iterator list_it(my_list.cbegin());
Slist::const_iterator slist_it(my_slist.cbegin());
Set::const_reverse_iterator set_rit(my_set.crbegin());
AvlSet::const_reverse_iterator avl_set_rit(my_avlset.crbegin());
SplaySet::const_reverse_iterator splay_set_rit(my_splayset.crbegin());
VectRit vect_it(values.rbegin()), vect_itend(values.rend());
//Test the objects inserted in the base hook list
for(; vect_it != vect_itend
; ++vect_it, ++list_it
, ++slist_it, ++set_rit
, ++avl_set_rit
, ++splay_set_rit
){
if(&*list_it != &*vect_it) return 1;
if(&*slist_it != &*vect_it) return 1;
if(&*set_rit != &*vect_it) return 1;
if(&*avl_set_rit != &*vect_it) return 1;
if(&*splay_set_rit != &*vect_it)return 1;
if(my_uset.find(*set_rit) == my_uset.cend()) return 1;
}
}
}
//Since treap_set, sg_set & bs_set reuse the hook, treat them apart
{
TreapSet my_treapset;
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it){
my_treapset.insert(*it);
}
TreapSet::const_reverse_iterator treap_set_rit(my_treapset.crbegin());
VectRit vect_it(values.rbegin()), vect_itend(values.rend());
for(; vect_it != vect_itend; ++vect_it, ++treap_set_rit){
if(&*treap_set_rit != &*vect_it) return 1;
}
}
{
SgSet my_sgset;
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it){
my_sgset.insert(*it);
}
SgSet::const_reverse_iterator sg_set_rit(my_sgset.crbegin());
VectRit vect_it(values.rbegin()), vect_itend(values.rend());
for(; vect_it != vect_itend; ++vect_it, ++sg_set_rit){
if(&*sg_set_rit != &*vect_it) return 1;
}
}
{
BsSet my_bsset;
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it){
my_bsset.insert(*it);
}
BsSet::const_reverse_iterator bs_set_rit(my_bsset.crbegin());
VectRit vect_it(values.rbegin()), vect_itend(values.rend());
for(; vect_it != vect_itend; ++vect_it, ++bs_set_rit){
if(&*bs_set_rit != &*vect_it) return 1;
}
}
return 0;
}
+2 -1
View File
@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007-2012
// (C) Copyright Ion Gaztanaga 2007-2013
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -130,6 +130,7 @@ typedef rbtree< MyClass
, value_traits<rbtree_value_traits_proxy>
, compare<std::greater<MyClass> > > Rbtree;
//Define a hashtable that will store MyClass using the external hook
typedef hashtable< MyClass
, value_traits<hash_value_traits_proxy>
, bucket_traits<bucket_traits_proxy>
+1 -1
View File
@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2010-2012
// (C) Copyright Ion Gaztanaga 2010-2013
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
+19 -19
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2012.
// (C) Copyright Ion Gaztanaga 2006-2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -71,7 +71,7 @@ struct search_const_container<T, false>
typedef T type;
};
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
struct test_generic_assoc
{
typedef typename ValueTraits::value_type value_type;
@@ -94,7 +94,7 @@ struct test_generic_assoc
static void test_container_from_iterator(std::vector<value_type>& values);
};
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
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)
{
@@ -122,7 +122,7 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::
}
}
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_erase_burst()
{
typedef typename ValueTraits::value_type value_type;
@@ -181,7 +181,7 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_erase_burst(
}
}
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
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)
{
typedef typename ValueTraits::value_type value_type;
@@ -195,7 +195,7 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_all(std::vector<typ
test_container_from_iterator(values);
}
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
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)
{
@@ -215,7 +215,7 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>
BOOST_TEST (testset2.empty());
}
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class 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)
{
@@ -230,7 +230,7 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>
BOOST_TEST (testset == assoc_type::container_from_end_iterator(testset.cend()));
}
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_up
(std::vector<typename ValueTraits::value_type>& values, boost::intrusive::detail::true_type)
{
@@ -268,12 +268,12 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_up
}
}
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_up
(std::vector<typename ValueTraits::value_type>&, boost::intrusive::detail::false_type)
{}
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_up
(std::vector<typename ValueTraits::value_type>& values)
{
@@ -287,7 +287,7 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_up
test_splay_up(values, enabler());
}
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_down
(std::vector<typename ValueTraits::value_type>& values, boost::intrusive::detail::true_type)
{
@@ -326,12 +326,12 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_down
}
}
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_down
(std::vector<typename ValueTraits::value_type>&, boost::intrusive::detail::false_type)
{}
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_down
(std::vector<typename ValueTraits::value_type>& values)
{
@@ -345,7 +345,7 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_splay_down
test_splay_down(values, enabler());
}
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
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)
{
@@ -385,12 +385,12 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_rebalance
}
}
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
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 = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
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)
{
@@ -404,7 +404,7 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_rebalance
test_rebalance(values, enabler());
}
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_before
(std::vector<typename ValueTraits::value_type>& values, boost::intrusive::detail::true_type)
{
@@ -454,12 +454,12 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_before
}
}
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_before
(std::vector<typename ValueTraits::value_type>&, boost::intrusive::detail::false_type)
{}
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_before
(std::vector<typename ValueTraits::value_type>& values)
{
+8 -8
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2012.
// (C) Copyright Ion Gaztanaga 2006-2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -23,7 +23,7 @@ namespace boost{
namespace intrusive{
namespace test{
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
struct test_generic_multiset
{
typedef typename ValueTraits::value_type value_type;
@@ -35,7 +35,7 @@ struct test_generic_multiset
static void test_impl();
};
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
void test_generic_multiset<ValueTraits, ContainerDefiner>::test_all ()
{
typedef typename ValueTraits::value_type value_type;
@@ -71,7 +71,7 @@ void test_generic_multiset<ValueTraits, ContainerDefiner>::test_all ()
}
//test case due to an error in tree implementation:
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
void test_generic_multiset<ValueTraits, ContainerDefiner>::test_impl()
{
typedef typename ValueTraits::value_type value_type;
@@ -98,7 +98,7 @@ void test_generic_multiset<ValueTraits, ContainerDefiner>::test_impl()
}
//test: constructor, iterator, clear, reverse_iterator, front, back, size:
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
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)
{
typedef typename ValueTraits::value_type value_type;
@@ -130,7 +130,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 = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
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)
{
typedef typename ValueTraits::value_type value_type;
@@ -168,7 +168,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 = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
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)
{
typedef typename ValueTraits::value_type value_type;
@@ -194,7 +194,7 @@ void test_generic_multiset<ValueTraits, ContainerDefiner>::test_swap(std::vector
}
//test: find, equal_range (lower_bound, upper_bound):
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
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)
{
typedef typename ValueTraits::value_type value_type;
+11 -11
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2012.
// (C) Copyright Ion Gaztanaga 2006-2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -29,7 +29,7 @@ struct is_treap
static const bool value = false;
};
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
struct test_generic_set
{
typedef typename ValueTraits::value_type value_type;
@@ -45,7 +45,7 @@ struct test_generic_set
};
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
void test_generic_set<ValueTraits, ContainerDefiner>::test_all()
{
typedef typename ValueTraits::value_type value_type;
@@ -82,7 +82,7 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_all()
}
//test case due to an error in tree implementation:
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
void test_generic_set<ValueTraits, ContainerDefiner>::test_impl()
{
typedef typename ValueTraits::value_type value_type;
@@ -109,7 +109,7 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_impl()
}
//test: constructor, iterator, clear, reverse_iterator, front, back, size:
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
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)
{
typedef typename ValueTraits::value_type value_type;
@@ -140,7 +140,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 = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
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)
{
typedef typename ValueTraits::value_type value_type;
@@ -178,7 +178,7 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_insert(std::vector<ty
}
}
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
(std::vector<typename ValueTraits::value_type>& values, boost::intrusive::detail::true_type)
{
@@ -199,7 +199,7 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
}
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
(std::vector<typename ValueTraits::value_type>& values)
{
@@ -216,7 +216,7 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
//test: insert, const_iterator, const_reverse_iterator, erase, s_iterator_to:
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
template<class ValueTraits, template <class = void, class = void, class = void, class = void> class ContainerDefiner>
void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
( std::vector<typename ValueTraits::value_type>& values
, boost::intrusive::detail::false_type)
@@ -239,7 +239,7 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
//test: insert (seq-version), swap, erase (seq-version), size:
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
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)
{
typedef typename ValueTraits::value_type value_type;
@@ -266,7 +266,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 = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
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)
{
typedef typename ValueTraits::value_type value_type;
+1 -1
View File
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2011-2012. Distributed under the Boost
// (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
+1 -1
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2012.
// (C) Copyright Ion Gaztanaga 2006-2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
+1 -1
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2012.
// (C) Copyright Ion Gaztanaga 2006-2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
+8 -4
View File
@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007-2012
// (C) Copyright Ion Gaztanaga 2007-2013
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -25,10 +25,14 @@
using namespace boost::intrusive;
struct my_tag;
struct my_tag2;
typedef make_bs_set_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link>
, tag<my_tag> >::type TreapHook;
typedef make_bs_set_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link>
, tag<my_tag2> >::type SplayHook;
class MyClass
: public make_list_base_hook
@@ -41,11 +45,10 @@ class MyClass
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >::type
, public make_avl_set_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >::type
, public make_splay_set_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >::type
, public make_bs_set_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >::type
, public TreapHook
, public SplayHook
{
int int_;
@@ -74,10 +77,11 @@ typedef make_set<MyClass>::type Set;
typedef make_unordered_set<MyClass>::type USet;
typedef make_avl_set<MyClass>::type AvlSet;
typedef make_splay_set<MyClass>::type SplaySet;
typedef make_sg_set<MyClass>::type SgSet;
typedef make_treap_set<MyClass
, base_hook<TreapHook> >::type TreapSet;
typedef make_splay_set<MyClass
, base_hook<SplayHook> >::type SplaySet;
int main()
{
+4 -4
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2012.
// (C) Copyright Ion Gaztanaga 2006-2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -57,9 +57,9 @@ struct hooks
};
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
, class Option1 =void
, class Option2 =void
, class Option3 =void
>
struct GetContainer
{
+1 -1
View File
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2011-2012. Distributed under the Boost
// (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
+1 -1
View File
@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007-2012
// (C) Copyright Ion Gaztanaga 2007-2013
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
+314
View File
@@ -0,0 +1,314 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2013-2013
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/intrusive for documentation.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/list.hpp>
#include <boost/intrusive/slist.hpp>
#include <boost/intrusive/set.hpp>
#include <boost/intrusive/unordered_set.hpp>
#include <boost/intrusive/avl_set.hpp>
#include <boost/intrusive/sg_set.hpp>
#include <boost/intrusive/bs_set.hpp>
#include <boost/intrusive/splay_set.hpp>
#include <boost/intrusive/treap_set.hpp>
#include <boost/intrusive/detail/mpl.hpp>
#include <boost/static_assert.hpp>
#include "smart_ptr.hpp"
#include <functional> //std::greater/std::less
using namespace boost::intrusive;
struct my_tag;
template<class VoidPtr = void*, link_mode_type mode = normal_link>
class MyClass
: public make_list_base_hook
< void_pointer<VoidPtr>, link_mode<mode> >::type
, public make_slist_base_hook
< void_pointer<VoidPtr>, link_mode<mode> >::type
, public make_set_base_hook
< void_pointer<VoidPtr>, link_mode<mode> >::type
, public make_unordered_set_base_hook
< void_pointer<VoidPtr>, link_mode<mode> >::type
, public make_avl_set_base_hook
< void_pointer<VoidPtr>, link_mode<mode> >::type
, public make_bs_set_base_hook
< void_pointer<VoidPtr>, link_mode<mode> >::type
{
int int_;
public:
MyClass(int i)
: int_(i)
{}
friend bool operator<(const MyClass &l, const MyClass &r)
{ return l.int_ < r.int_; }
friend bool operator==(const MyClass &l, const MyClass &r)
{ return l.int_ == r.int_; }
friend std::size_t hash_value(const MyClass &v)
{ return boost::hash_value(v.int_); }
friend bool priority_order(const MyClass &l, const MyClass &r)
{ return l.int_ < r.int_; }
};
template<class T>
struct inverse_priority
{
bool operator()(const T &l, const T &r)
{ return l.int_ > r.int_; }
};
template<class T>
struct inverse_hash
{
bool operator()(const T &l)
{ return hash_value(l); }
};
template<class T>
struct alternative_equal
{
bool operator()(const T &l, const T &r)
{ return l.int_ == r.int_; }
};
int main()
{
////////////
// list
////////////
BOOST_STATIC_ASSERT((!detail::is_same< list<MyClass<> >::iterator
, list<MyClass<> >::const_iterator
>::value));
//constant_time_size does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< list<MyClass<>, constant_time_size<true> >::iterator
, list<MyClass<>, constant_time_size<false> >::iterator
>::value));
//void_pointer does change iterator
BOOST_STATIC_ASSERT((!detail::is_same< list<MyClass<> >::iterator
, list<MyClass<smart_ptr<void> > >::iterator
>::value));
//size_type does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< list<MyClass<>, size_type<unsigned int > >::iterator
, list<MyClass<>, size_type<unsigned char> >::iterator
>::value));
////////////
// slist
////////////
BOOST_STATIC_ASSERT((!detail::is_same< slist<MyClass<> >::iterator
, slist<MyClass<> >::const_iterator
>::value));
//constant_time_size does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< slist<MyClass<>, constant_time_size<true> >::iterator
, slist<MyClass<>, constant_time_size<false> >::iterator
>::value));
//void_pointer does change iterator
BOOST_STATIC_ASSERT((!detail::is_same< slist<MyClass<> >::iterator
, slist<MyClass<smart_ptr<void> > >::iterator
>::value));
//size_type does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< slist<MyClass<>, size_type<unsigned int > >::iterator
, slist<MyClass<>, size_type<unsigned char> >::iterator
>::value));
//cache_last does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< slist<MyClass<>, cache_last<false> >::iterator
, slist<MyClass<>, cache_last<true> >::iterator
>::value));
//linear does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< slist<MyClass<>, linear<false> >::iterator
, slist<MyClass<>, linear<true> >::iterator
>::value));
////////////
// set
////////////
BOOST_STATIC_ASSERT((!detail::is_same< set<MyClass<> >::iterator
, set<MyClass<> >::const_iterator
>::value));
//constant_time_size does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< set<MyClass<>, constant_time_size<true> >::iterator
, set<MyClass<>, constant_time_size<false> >::iterator
>::value));
//void_pointer does change iterator
BOOST_STATIC_ASSERT((!detail::is_same< set<MyClass<> >::iterator
, set<MyClass<smart_ptr<void> > >::iterator
>::value));
//size_type does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< set<MyClass<>, size_type<unsigned int > >::iterator
, set<MyClass<>, size_type<unsigned char> >::iterator
>::value));
//compare does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< set<MyClass<>, compare< std::greater<MyClass<> > > >::iterator
, set<MyClass<>, compare< std::less<MyClass<> > > >::iterator
>::value));
////////////
// avl_set
////////////
BOOST_STATIC_ASSERT((!detail::is_same< avl_set<MyClass<> >::iterator
, avl_set<MyClass<> >::const_iterator
>::value));
//constant_time_size does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< avl_set<MyClass<>, constant_time_size<true> >::iterator
, avl_set<MyClass<>, constant_time_size<false> >::iterator
>::value));
//void_pointer does change iterator
BOOST_STATIC_ASSERT((!detail::is_same< avl_set<MyClass<> >::iterator
, avl_set<MyClass<smart_ptr<void> > >::iterator
>::value));
//size_type does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< avl_set<MyClass<>, size_type<unsigned int > >::iterator
, avl_set<MyClass<>, size_type<unsigned char> >::iterator
>::value));
//compare does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< avl_set<MyClass<>, compare< std::greater<MyClass<> > > >::iterator
, avl_set<MyClass<>, compare< std::less<MyClass<> > > >::iterator
>::value));
////////////
// sg_set
////////////
BOOST_STATIC_ASSERT((!detail::is_same< sg_set<MyClass<> >::iterator
, sg_set<MyClass<> >::const_iterator
>::value));
//void_pointer does change iterator
BOOST_STATIC_ASSERT((!detail::is_same< sg_set<MyClass<> >::iterator
, sg_set<MyClass<smart_ptr<void> > >::iterator
>::value));
//size_type does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< sg_set<MyClass<>, size_type<unsigned int > >::iterator
, sg_set<MyClass<>, size_type<unsigned char> >::iterator
>::value));
//compare does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< sg_set<MyClass<>, compare< std::greater<MyClass<> > > >::iterator
, sg_set<MyClass<>, compare< std::less<MyClass<> > > >::iterator
>::value));
//floating_point does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< sg_set<MyClass<>, floating_point<false> >::iterator
, sg_set<MyClass<>, floating_point<true> >::iterator
>::value));
////////////
// bs_set
////////////
BOOST_STATIC_ASSERT((!detail::is_same< bs_set<MyClass<> >::iterator
, bs_set<MyClass<> >::const_iterator
>::value));
//constant_time_size does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< bs_set<MyClass<>, constant_time_size<true> >::iterator
, bs_set<MyClass<>, constant_time_size<false> >::iterator
>::value));
//void_pointer does change iterator
BOOST_STATIC_ASSERT((!detail::is_same< bs_set<MyClass<> >::iterator
, bs_set<MyClass<smart_ptr<void> > >::iterator
>::value));
//size_type does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< bs_set<MyClass<>, size_type<unsigned int > >::iterator
, bs_set<MyClass<>, size_type<unsigned char> >::iterator
>::value));
//compare does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< bs_set<MyClass<>, compare< std::greater<MyClass<> > > >::iterator
, bs_set<MyClass<>, compare< std::less<MyClass<> > > >::iterator
>::value));
////////////
// splay_set
////////////
BOOST_STATIC_ASSERT((!detail::is_same< splay_set<MyClass<> >::iterator
, splay_set<MyClass<> >::const_iterator
>::value));
//constant_time_size does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< splay_set<MyClass<>, constant_time_size<true> >::iterator
, splay_set<MyClass<>, constant_time_size<false> >::iterator
>::value));
//void_pointer does change iterator
BOOST_STATIC_ASSERT((!detail::is_same< splay_set<MyClass<> >::iterator
, splay_set<MyClass<smart_ptr<void> > >::iterator
>::value));
//size_type does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< splay_set<MyClass<>, size_type<unsigned int > >::iterator
, splay_set<MyClass<>, size_type<unsigned char> >::iterator
>::value));
//compare does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< splay_set<MyClass<>, compare< std::greater<MyClass<> > > >::iterator
, splay_set<MyClass<>, compare< std::less<MyClass<> > > >::iterator
>::value));
////////////
// treap_set
////////////
BOOST_STATIC_ASSERT((!detail::is_same< treap_set<MyClass<> >::iterator
, treap_set<MyClass<> >::const_iterator
>::value));
//constant_time_size does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< treap_set<MyClass<>, constant_time_size<true> >::iterator
, treap_set<MyClass<>, constant_time_size<false> >::iterator
>::value));
//void_pointer does change iterator
BOOST_STATIC_ASSERT((!detail::is_same< treap_set<MyClass<> >::iterator
, treap_set<MyClass<smart_ptr<void> > >::iterator
>::value));
//size_type does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< treap_set<MyClass<>, size_type<unsigned int > >::iterator
, treap_set<MyClass<>, size_type<unsigned char> >::iterator
>::value));
//compare does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< treap_set<MyClass<>, compare< std::greater<MyClass<> > > >::iterator
, treap_set<MyClass<>, compare< std::less<MyClass<> > > >::iterator
>::value));
//priority does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< treap_set<MyClass<> >::iterator
, treap_set<MyClass<>, priority< inverse_priority<MyClass<> > > >::iterator
>::value));
//////////////
// common tree
//////////////
BOOST_STATIC_ASSERT((detail::is_same< bs_set<MyClass<> >::iterator
, sg_set<MyClass<> >::iterator
>::value));
BOOST_STATIC_ASSERT((detail::is_same< bs_set<MyClass<> >::iterator
, treap_set<MyClass<> >::iterator
>::value));
BOOST_STATIC_ASSERT((detail::is_same< bs_set<MyClass<> >::iterator
, splay_set<MyClass<> >::iterator
>::value));
////////////
// unordered_set
////////////
BOOST_STATIC_ASSERT((!detail::is_same< unordered_set<MyClass<> >::iterator
, unordered_set<MyClass<> >::const_iterator
>::value));
//constant_time_size does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< unordered_set<MyClass<>, constant_time_size<true> >::iterator
, unordered_set<MyClass<>, constant_time_size<false> >::iterator
>::value));
//void_pointer does change iterator
BOOST_STATIC_ASSERT((!detail::is_same< unordered_set<MyClass<> >::iterator
, unordered_set<MyClass<smart_ptr<void> > >::iterator
>::value));
//size_type does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< unordered_set<MyClass<>, size_type<unsigned int > >::iterator
, unordered_set<MyClass<>, size_type<unsigned char> >::iterator
>::value));
//hash does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< unordered_set<MyClass<> >::iterator
, unordered_set<MyClass<>, hash< inverse_hash<MyClass<> > > >::iterator
>::value));
//equal does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< unordered_set<MyClass<> >::iterator
, unordered_set<MyClass<>, equal< alternative_equal<MyClass<> > > >::iterator
>::value));
//power_2_buckets does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< unordered_set<MyClass<> >::iterator
, unordered_set<MyClass<>, power_2_buckets<true> >::iterator
>::value));
//cache_begin does not change iterator
BOOST_STATIC_ASSERT((detail::is_same< unordered_set<MyClass<> >::iterator
, unordered_set<MyClass<>, cache_begin<true> >::iterator
>::value));
return 0;
}
+4 -4
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2012.
// (C) Copyright Ion Gaztanaga 2006-2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -58,9 +58,9 @@ struct hooks
};
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
, class Option1 =void
, class Option2 =void
, class Option3 =void
>
struct GetContainer
{
+7 -7
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2012.
// (C) Copyright Ion Gaztanaga 2006-2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -70,9 +70,9 @@ struct hooks
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
, class Option1 =void
, class Option2 =void
, class Option3 =void
>
struct GetContainer
{
@@ -85,9 +85,9 @@ struct GetContainer
};
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
, class Option1 =void
, class Option2 =void
, class Option3 =void
>
struct GetContainerFixedAlpha
{
+7 -7
View File
@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007-2012
// (C) Copyright Ion Gaztanaga 2007-2013
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -68,9 +68,9 @@ struct hooks
};
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
, class Option1 =void
, class Option2 =void
, class Option3 =void
>
struct GetContainer
{
@@ -83,9 +83,9 @@ struct GetContainer
};
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
, class Option1 =void
, class Option2 =void
, class Option3 =void
>
struct GetContainerFixedAlpha
{
+205 -1
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2012.
// (C) Copyright Ion Gaztanaga 2006-2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -730,3 +730,207 @@ int main(int, char* [])
return boost::report_errors();
}
#include <boost/intrusive/detail/config_end.hpp>
/*
#include <iostream>
#include <string>
#include <boost/noncopyable.hpp>
#include <boost/intrusive/list.hpp>
#include <boost/intrusive/set.hpp>
namespace intrusive = boost::intrusive;
class object : public boost::noncopyable
{
public:
int o;
object()
{
}
virtual ~object()
{
}
};
class signal : virtual public object
{
public:
signal()
{
}
virtual ~signal()
{
}
};
class set_item : public signal
{
public:
set_item()
{
}
virtual ~set_item()
{
}
public:
virtual const std::string& get_buffer() const
{
return m_buffer;
}
typedef intrusive::set_member_hook<
intrusive::link_mode<intrusive::auto_unlink>
> hook;
hook m_hook;
std::string m_buffer;
};
template <class T, class M, M (T::*V)>
struct member_comparator
{
bool operator()(const T& t1, const T& t2) const
{
return (t1.*V) < (t2.*V);
}
bool operator()(const M& m, const T& t) const
{
return m < (t.*V);
}
bool operator()(const T& t, const M& m) const
{
return (t.*V) < m;
}
};
class kk{ int a; float f; };
class list_item : public kk, virtual public object
{
public:
list_item()
{
}
virtual ~list_item()
{
}
virtual void f()
{
}
typedef intrusive::list_member_hook<
intrusive::link_mode<intrusive::auto_unlink>
> hook;
hook m_hook;
};
set_item srec;
list_item lrec;
const set_item::hook set_item::* sptr_to_member = &set_item::m_hook;
const list_item::hook list_item::* lptr_to_member = &list_item::m_hook;
int main(int argc, char** argv)
{
int a = sizeof(sptr_to_member);
int b = sizeof(lptr_to_member);
const std::type_info &ta = typeid(set_item);
const std::type_info &tb = typeid(list_item);
const set_item::hook &sh = srec.*sptr_to_member;
const list_item::hook &l2 = lrec.*lptr_to_member;
{
typedef member_comparator<
set_item,
std::string,
&set_item::m_buffer
> set_item_comparator;
typedef intrusive::set<
set_item,
intrusive::compare<set_item_comparator>,
intrusive::member_hook<
set_item,
set_item::hook,
&set_item::m_hook
>,
intrusive::constant_time_size<false>
> set_items
;
union
{
int as_int[2];
const set_item::hook set_item::* ptr_to_member;
}
sss;
sss.ptr_to_member = &set_item::m_hook;
std::cout << "set offsets: " << sss.as_int[0] << ":" << sss.as_int[1] << " and " << offsetof(set_item,m_hook) << std::endl;
set_items rr;
std::string key = "123";
set_items::insert_commit_data icd;
std::pair<set_items::iterator,bool> ir = rr.insert_check(
key,
set_item_comparator(),
icd
);
if ( !ir.second )
{
throw std::exception();
}
set_item rec;
rec.m_buffer = key;
set_items::iterator i = rr.insert_commit( rec, icd );
set_item* rrr = &(*i);
std::cout << "set pointers: " << ((void*)rrr) << " and " << ((void*)&rec) << std::endl;
}
{
typedef intrusive::list<
list_item,
intrusive::member_hook<
list_item,
list_item::hook,
&list_item::m_hook
>,
intrusive::constant_time_size<false>
> list_items
;
union
{
int as_int[2];
const list_item::hook list_item::* ptr_to_member;
}
sss;
sss.ptr_to_member = &list_item::m_hook;
std::cout << "list offsets: " << sss.as_int[0] << ":" << sss.as_int[1] << " and " << offsetof(list_item,m_hook) << std::endl;
list_items rr;
list_item rec;
const list_item::hook &h = rec.*sss.ptr_to_member;
rr.push_back( rec );
list_item* rrr = &rr.front();
std::cout << "list pointers: " << ((void*)rrr) << " and " << ((void*)&rec) << std::endl;
}
return 0;
}
*/
+5 -22
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2012.
// (C) Copyright Ion Gaztanaga 2006-2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -19,23 +19,6 @@
namespace boost { namespace intrusive { namespace test {
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template<class T, class O1, class O2, class O3, class O4>
#else
template<class T, class ...Options>
#endif
struct has_const_overloads<boost::intrusive::splay_multiset<
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
T, O1, O2, O3, O4
#else
T, Options...
#endif
>
>
{
static const bool value = false;
};
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template<class T, class O1, class O2, class O3, class O4>
#else
@@ -81,7 +64,7 @@ struct has_const_searches<boost::intrusive::splay_multiset<T,
#endif
> >
{
static const bool value = false;
static const bool value = true;
};
@@ -106,9 +89,9 @@ struct hooks
};
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
, class Option1 =void
, class Option2 =void
, class Option3 =void
>
struct GetContainer
{
+4 -20
View File
@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007-2012
// (C) Copyright Ion Gaztanaga 2007-2013
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -17,22 +17,6 @@
namespace boost { namespace intrusive { namespace test {
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template<class T, class O1, class O2, class O3, class O4>
#else
template<class T, class ...Options>
#endif
struct has_const_overloads<boost::intrusive::splay_set<T,
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
O1, O2, O3, O4
#else
Options...
#endif
> >
{
static const bool value = false;
};
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template<class T, class O1, class O2, class O3, class O4>
#else
@@ -102,9 +86,9 @@ struct hooks
};
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
, class Option1 =void
, class Option2 =void
, class Option3 =void
>
struct GetContainer
{
+1 -1
View File
@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007-2012
// (C) Copyright Ion Gaztanaga 2007-2013
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
+3 -35
View File
@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007-2012
// (C) Copyright Ion Gaztanaga 2007-2013
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -27,12 +27,6 @@ struct is_unordered
static const bool value = false;
};
template<class T>
struct has_const_overloads
{
static const bool value = true;
};
template< class Container >
void test_container( Container & c )
{
@@ -290,7 +284,7 @@ void test_common_unordered_and_associative_container(Container & c, Data & d)
}
template< class Container, class Data >
void test_associative_container_invariants(Container & c, Data & d, boost::intrusive::detail::true_type)
void test_associative_container_invariants(Container & c, Data & d)
{
typedef typename Container::const_iterator const_iterator;
for( typename Data::const_iterator di = d.begin(), de = d.end();
@@ -316,19 +310,6 @@ void test_associative_container_invariants(Container & c, Data & d, boost::intru
}
}
template< class Container, class Data >
void test_associative_container_invariants(Container &, Data &, boost::intrusive::detail::false_type)
{}
template< class Container, class Data >
void test_associative_container_invariants(Container & c, Data & d)
{
using namespace boost::intrusive;
typedef typename detail::remove_const<Container>::type Type;
typedef detail::bool_<has_const_overloads<Type>::value> enabler;
test_associative_container_invariants(c, d, enabler());
}
template< class Container, class Data >
void test_associative_container(Container & c, Data & d)
{
@@ -346,7 +327,7 @@ void test_associative_container(Container & c, Data & d)
}
template< class Container, class Data >
void test_unordered_associative_container_invariants(Container & c, Data & d, boost::intrusive::detail::true_type)
void test_unordered_associative_container_invariants(Container & c, Data & d)
{
typedef typename Container::size_type size_type;
typedef typename Container::const_iterator const_iterator;
@@ -380,19 +361,6 @@ void test_unordered_associative_container_invariants(Container & c, Data & d, bo
BOOST_TEST( total_objects == c.size() );
}
template< class Container, class Data >
void test_unordered_associative_container_invariants(Container &, Data &, boost::intrusive::detail::false_type)
{}
template< class Container, class Data >
void test_unordered_associative_container_invariants(Container & c, Data & d)
{
using namespace boost::intrusive;
typedef typename detail::remove_const<Container>::type Type;
typedef detail::bool_<has_const_overloads<Type>::value> enabler;
test_unordered_associative_container_invariants(c, d, enabler());
}
template< class Container, class Data >
void test_unordered_associative_container(Container & c, Data & d)
{
+1 -1
View File
@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2012
// (C) Copyright Ion Gaztanaga 2006-2013
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
+4 -4
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2012.
// (C) Copyright Ion Gaztanaga 2006-2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -55,9 +55,9 @@ struct hooks
};
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
, class Option1 =void
, class Option2 =void
, class Option3 =void
>
struct GetContainer
{
+4 -4
View File
@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2012.
// (C) Copyright Ion Gaztanaga 2006-2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -70,9 +70,9 @@ struct hooks
};
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
, class Option1 =void
, class Option2 =void
, class Option3 =void
>
struct GetContainer
{
+1 -1
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2012.
// (C) Copyright Ion Gaztanaga 2006-2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
+1 -1
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2012.
// (C) Copyright Ion Gaztanaga 2006-2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
+3 -2
View File
@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007-2012
// (C) Copyright Ion Gaztanaga 2007-2013
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -57,6 +57,7 @@ typedef list<MyClass, MemberHook> List;
int main()
{
#ifndef _MSC_VER
typedef std::vector<MyClass>::iterator VectIt;
typedef std::vector<MyClass>::reverse_iterator VectRit;
@@ -81,6 +82,6 @@ int main()
if(&*list_it != &*vect_it)
return 1;
}
#endif
return 0;
}