• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Ion Gaztanaga 2013-2013. 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)
6 //
7 // See http://www.boost.org/libs/intrusive for documentation.
8 //
9 //////////////////////////////////////////////////////////////////////////////
10 #include <boost/intrusive/pack_options.hpp>
11 #include <boost/intrusive/detail/mpl.hpp>
12 #include <boost/static_assert.hpp>
13 
14 struct empty_default{};
15 
16 using namespace boost::intrusive;
17 
18 //Test BOOST_INTRUSIVE_OPTION_CONSTANT
19 BOOST_INTRUSIVE_OPTION_CONSTANT(incremental, bool, Enabled, is_incremental)
20 const bool is_incremental_value = pack_options< empty_default, incremental<true> >::type::is_incremental;
21 BOOST_STATIC_ASSERT(( is_incremental_value == true ));
22 
23 //Test BOOST_INTRUSIVE_OPTION_TYPE
24 BOOST_INTRUSIVE_OPTION_TYPE(my_pointer, VoidPointer, typename boost::intrusive::detail::remove_pointer<VoidPointer>::type, my_pointer_type)
25 typedef pack_options< empty_default, my_pointer<void*> >::type::my_pointer_type my_pointer_type;
26 BOOST_STATIC_ASSERT(( boost::intrusive::detail::is_same<my_pointer_type, void>::value ));
27 
28 //test combination of BOOST_INTRUSIVE_OPTION_CONSTANT and BOOST_INTRUSIVE_OPTION_TYPE
29 //    First add new options
30 struct default_options
31 {
32    static const long long_constant = -3;
33    typedef double *  double_typedef;
34 };
35 
36 BOOST_INTRUSIVE_OPTION_CONSTANT(incremental2, bool, Enabled, is_incremental2)
37 BOOST_INTRUSIVE_OPTION_TYPE(my_pointer2, VoidPointer, typename boost::intrusive::detail::add_pointer<VoidPointer>::type, my_pointer_type2)
38 typedef pack_options < default_options
39                      , incremental<false>
40                      , my_pointer<float*>
41                      , incremental2<true>
42                      , my_pointer2<const char*>
43                      >::type combined_type;
44 BOOST_STATIC_ASSERT(( combined_type::is_incremental  == false ));
45 BOOST_STATIC_ASSERT(( combined_type::is_incremental2 == true  ));
46 BOOST_STATIC_ASSERT(( boost::intrusive::detail::is_same<combined_type::my_pointer_type,       float  >::value ));
47 BOOST_STATIC_ASSERT(( boost::intrusive::detail::is_same<combined_type::my_pointer_type2, const char**>::value ));
48 
49 //test packing the default options leads to a default options type
50 BOOST_STATIC_ASSERT(( boost::intrusive::detail::is_same<pack_options<default_options>::type, default_options>::value ));
51 
main()52 int main()
53 {
54    return 0;
55 }
56