define_tpl_struct_inline_empty.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*=============================================================================
  2. Copyright (c) 2016 Kohei Takahashi
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #include <boost/detail/lightweight_test.hpp>
  7. #include <boost/fusion/container.hpp>
  8. #include <boost/fusion/sequence.hpp>
  9. #include <boost/fusion/sequence/io/out.hpp>
  10. #include <boost/fusion/iterator/equal_to.hpp>
  11. #include <boost/fusion/adapted/struct/define_struct_inline.hpp>
  12. #include <boost/mpl/assert.hpp>
  13. #include <boost/mpl/is_sequence.hpp>
  14. #include <boost/static_assert.hpp>
  15. #include <iostream>
  16. BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE((M), empty_struct, )
  17. int
  18. main()
  19. {
  20. using namespace boost;
  21. using namespace boost::fusion;
  22. std::cout << tuple_open('[');
  23. std::cout << tuple_close(']');
  24. std::cout << tuple_delimiter(", ");
  25. {
  26. BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct<void> >));
  27. empty_struct<void> e;
  28. std::cout << e << std::endl;
  29. BOOST_TEST(e == make_vector());
  30. BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct<void> >::value == 0);
  31. BOOST_STATIC_ASSERT(fusion::result_of::empty<empty_struct<void> >::value);
  32. }
  33. {
  34. vector<> v;
  35. empty_struct<void> e;
  36. BOOST_TEST(v == e);
  37. BOOST_TEST_NOT(v != e);
  38. BOOST_TEST_NOT(v < e);
  39. BOOST_TEST(v <= e);
  40. BOOST_TEST_NOT(v > e);
  41. BOOST_TEST(v >= e);
  42. }
  43. {
  44. empty_struct<void> e;
  45. // conversion from empty_struct to vector
  46. vector<> v(e);
  47. v = e;
  48. // conversion from empty_struct to list
  49. //list<> l(e);
  50. //l = e;
  51. }
  52. { // begin/end
  53. typedef fusion::result_of::begin<empty_struct<void> >::type b;
  54. typedef fusion::result_of::end<empty_struct<void> >::type e;
  55. BOOST_MPL_ASSERT((fusion::result_of::equal_to<b, e>));
  56. }
  57. BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct<void> >));
  58. return boost::report_errors();
  59. }