]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/intrusive/test/recursive_test.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2007-2013
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)
9 // See http://www.boost.org/libs/intrusive for documentation.
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>
22 using namespace boost::intrusive
;
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
;
30 typedef unordered_set
<Foo
, base_hook
<USetBaseHook
> > USet
;
32 class Foo
: public ListBaseHook
, public SListBaseHook
, public SetBaseHook
, public USetBaseHook
34 USet::bucket_type buckets
[1];
36 Foo
& operator=(const Foo
&);
39 Foo() : uset_children(USet::bucket_traits(buckets
, 1))
41 list
<Foo
, base_hook
<ListBaseHook
> > list_children
;
42 slist
<Foo
, base_hook
<SListBaseHook
> > slist_children
;
43 set
<Foo
, base_hook
<SetBaseHook
> > set_children
;
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();
53 USet::bucket_type buckets
[1];
54 USet
unordered_set_(USet::bucket_traits(buckets
, 1)); unordered_set_
.clear();
60 //A small test with list
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();