]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/intrusive/test/recursive_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / intrusive / test / recursive_test.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Ion Gaztanaga 2007-2013
4 //
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 //
9 // See http://www.boost.org/libs/intrusive for documentation.
10 //
11 /////////////////////////////////////////////////////////////////////////////
12 #include <boost/intrusive/list.hpp>
13 #include <boost/intrusive/slist.hpp>
14 #include <boost/intrusive/set.hpp>
15 #include <boost/intrusive/unordered_set.hpp>
16 #include <boost/intrusive/avl_set.hpp>
17 #include <boost/intrusive/sg_set.hpp>
18 #include <boost/intrusive/splay_set.hpp>
19 #include <boost/intrusive/treap_set.hpp>
20 #include <cassert>
21
22 using namespace boost::intrusive;
23
24 typedef list_base_hook<> ListBaseHook;
25 typedef slist_base_hook<> SListBaseHook;
26 typedef set_base_hook<> SetBaseHook;
27 typedef unordered_set_base_hook<> USetBaseHook;
28
29 class Foo;
30 typedef unordered_set<Foo, base_hook<USetBaseHook> > USet;
31
32 class Foo : public ListBaseHook, public SListBaseHook, public SetBaseHook, public USetBaseHook
33 {
34 USet::bucket_type buckets[1];
35 Foo(const Foo &);
36 Foo & operator=(const Foo &);
37
38 public:
39 Foo() : uset_children(USet::bucket_traits(buckets, 1))
40 {}
41 list <Foo, base_hook<ListBaseHook> > list_children;
42 slist<Foo, base_hook<SListBaseHook> > slist_children;
43 set <Foo, base_hook<SetBaseHook> > set_children;
44 USet uset_children;
45 };
46
47 void instantiate()
48 {
49 list< Foo, base_hook<ListBaseHook> > list_; list_.clear();
50 slist< Foo, base_hook<SListBaseHook> > slist_; slist_.clear();
51 set< Foo, base_hook<SetBaseHook> > set_; set_.clear();
52
53 USet::bucket_type buckets[1];
54 USet unordered_set_(USet::bucket_traits(buckets, 1)); unordered_set_.clear();
55 }
56 int main()
57 {
58 instantiate();
59
60 //A small test with list
61 {
62 Foo f, f2;
63 list< Foo, base_hook<ListBaseHook> > l;
64 l.insert(l.begin(), f);
65 l.begin()->list_children.insert(l.begin()->list_children.begin(), f2);
66 assert(l.size() == l.begin()->list_children.size());
67 l.begin()->list_children.clear();
68 l.clear();
69 }
70 return 0;
71 }