1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2014-2014. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/container for documentation.
9 //////////////////////////////////////////////////////////////////////////////
11 #include <boost/intrusive/list.hpp>
12 #include <boost/intrusive/slist.hpp>
13 #include <boost/intrusive/bs_set.hpp>
14 #include <boost/intrusive/set.hpp>
15 #include <boost/intrusive/avl_set.hpp>
16 #include <boost/intrusive/sg_set.hpp>
17 #include <boost/intrusive/treap_set.hpp>
18 #include <boost/intrusive/splay_set.hpp>
19 #include <boost/intrusive/detail/mpl.hpp>
21 #include <boost/core/lightweight_test.hpp>
22 #include <boost/aligned_storage.hpp>
23 #include <boost/static_assert.hpp>
27 using namespace boost::intrusive
;
37 typedef boost::aligned_storage
<sizeof(void*)*4>::type buffer_t
;
39 static buffer_t buffer_0x00
;
40 static buffer_t buffer_0xFF
;
42 template<class Iterator
>
43 const Iterator
&on_0x00_buffer()
45 BOOST_STATIC_ASSERT(sizeof(buffer_t
) >= sizeof(Iterator
));
46 return * ::new(std::memset(&buffer_0x00
, 0x00, sizeof(buffer_0x00
))) Iterator();
49 template<class Iterator
>
50 const Iterator
&on_0xFF_buffer()
52 BOOST_STATIC_ASSERT(sizeof(buffer_t
) >= sizeof(Iterator
));
53 return * ::new(std::memset(&buffer_0xFF
, 0xFF, sizeof(buffer_0xFF
))) Iterator();
56 BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reverse_iterator
)
57 BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_reverse_iterator
)
60 template<class Container
>
61 void check_null_iterators()
63 typedef typename
Container::iterator iterator
;
64 typedef typename
Container::const_iterator const_iterator
;
65 typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT
67 ,reverse_iterator
, iterator
) reverse_iterator
;
68 typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT
70 ,const_reverse_iterator
, const_iterator
) const_reverse_iterator
;
72 BOOST_TEST(on_0xFF_buffer
<iterator
>() == on_0x00_buffer
<iterator
>());
73 BOOST_TEST(on_0xFF_buffer
<const_iterator
>() == on_0x00_buffer
<const_iterator
>());
74 BOOST_TEST(on_0xFF_buffer
<reverse_iterator
>() == on_0x00_buffer
<reverse_iterator
>());
75 BOOST_TEST(on_0xFF_buffer
<const_reverse_iterator
>() == on_0x00_buffer
<const_reverse_iterator
>());
80 check_null_iterators
< list
<Type
> >();
81 check_null_iterators
< slist
<Type
> >();
82 check_null_iterators
< bs_set
<Type
> >();
83 check_null_iterators
< set
<Type
> >();
84 check_null_iterators
< multiset
<Type
> >();
85 check_null_iterators
< avl_set
<Type
> >();
86 check_null_iterators
< avl_multiset
<Type
> >();
87 check_null_iterators
< sg_set
<Type
> >();
88 check_null_iterators
< sg_multiset
<Type
> >();
89 check_null_iterators
< treap_set
<Type
> >();
90 check_null_iterators
< treap_multiset
<Type
> >();
91 check_null_iterators
< splay_set
<Type
> >();
92 check_null_iterators
< splay_multiset
<Type
> >();
94 return boost::report_errors();