pack_options_test.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. struct empty_default{};
  14. using namespace boost::intrusive;
  15. //Test BOOST_INTRUSIVE_OPTION_CONSTANT
  16. BOOST_INTRUSIVE_OPTION_CONSTANT(incremental, bool, Enabled, is_incremental)
  17. const bool is_incremental_value = pack_options< empty_default, incremental<true> >::type::is_incremental;
  18. BOOST_STATIC_ASSERT(( is_incremental_value == true ));
  19. //Test BOOST_INTRUSIVE_OPTION_TYPE
  20. BOOST_INTRUSIVE_OPTION_TYPE(my_pointer, VoidPointer, typename boost::intrusive::detail::remove_pointer<VoidPointer>::type, my_pointer_type)
  21. typedef pack_options< empty_default, my_pointer<void*> >::type::my_pointer_type my_pointer_type;
  22. BOOST_STATIC_ASSERT(( boost::intrusive::detail::is_same<my_pointer_type, void>::value ));
  23. //test combination of BOOST_INTRUSIVE_OPTION_CONSTANT and BOOST_INTRUSIVE_OPTION_TYPE
  24. // First add new options
  25. struct default_options
  26. {
  27. static const long long_constant = -3;
  28. typedef double * double_typedef;
  29. };
  30. BOOST_INTRUSIVE_OPTION_CONSTANT(incremental2, bool, Enabled, is_incremental2)
  31. BOOST_INTRUSIVE_OPTION_TYPE(my_pointer2, VoidPointer, typename boost::intrusive::detail::add_pointer<VoidPointer>::type, my_pointer_type2)
  32. typedef pack_options < default_options
  33. , incremental<false>
  34. , my_pointer<float*>
  35. , incremental2<true>
  36. , my_pointer2<const char*>
  37. >::type combined_type;
  38. BOOST_STATIC_ASSERT(( combined_type::is_incremental == false ));
  39. BOOST_STATIC_ASSERT(( combined_type::is_incremental2 == true ));
  40. BOOST_STATIC_ASSERT(( boost::intrusive::detail::is_same<combined_type::my_pointer_type, float >::value ));
  41. BOOST_STATIC_ASSERT(( boost::intrusive::detail::is_same<combined_type::my_pointer_type2, const char**>::value ));
  42. //test packing the default options leads to a default options type
  43. BOOST_STATIC_ASSERT(( boost::intrusive::detail::is_same<pack_options<default_options>::type, default_options>::value ));
  44. int main()
  45. {
  46. return 0;
  47. }