1 /*============================================================================= 2 Copyright (c) 2016 Kohei Takahashi 3 4 Distributed under the Boost Software License, Version 1.0. (See accompanying 5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 ==============================================================================*/ 7 #include <boost/detail/lightweight_test.hpp> 8 #include <boost/fusion/adapted/struct/adapt_struct.hpp> 9 #include <boost/fusion/sequence/intrinsic/size.hpp> 10 #include <boost/fusion/sequence/intrinsic/empty.hpp> 11 #include <boost/fusion/sequence/intrinsic/begin.hpp> 12 #include <boost/fusion/sequence/intrinsic/end.hpp> 13 #include <boost/fusion/sequence/io/out.hpp> 14 #include <boost/fusion/iterator/equal_to.hpp> 15 #include <boost/fusion/container/vector/vector.hpp> 16 #include <boost/fusion/container/list/list.hpp> 17 #include <boost/fusion/container/generation/make_vector.hpp> 18 #include <boost/fusion/sequence/comparison/equal_to.hpp> 19 #include <boost/fusion/sequence/comparison/not_equal_to.hpp> 20 #include <boost/fusion/sequence/comparison/less.hpp> 21 #include <boost/fusion/sequence/comparison/less_equal.hpp> 22 #include <boost/fusion/sequence/comparison/greater.hpp> 23 #include <boost/fusion/sequence/comparison/greater_equal.hpp> 24 #include <boost/fusion/mpl.hpp> 25 #include <boost/fusion/support/is_view.hpp> 26 #include <boost/mpl/is_sequence.hpp> 27 #include <boost/mpl/assert.hpp> 28 #include <iostream> 29 30 class empty_struct{}; 31 BOOST_FUSION_ADAPT_STRUCT(empty_struct,) 32 33 int main()34main() 35 { 36 using namespace boost::fusion; 37 using namespace boost; 38 39 std::cout << tuple_open('['); 40 std::cout << tuple_close(']'); 41 std::cout << tuple_delimiter(", "); 42 43 { 44 BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct>)); 45 BOOST_STATIC_ASSERT(!traits::is_view<empty_struct>::value); 46 empty_struct e; 47 48 std::cout << e << std::endl; 49 BOOST_TEST(e == make_vector()); 50 51 BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct>::value == 0); 52 BOOST_MPL_ASSERT((fusion::result_of::empty<empty_struct>)); 53 54 BOOST_MPL_ASSERT((fusion::result_of::equal_to< 55 fusion::result_of::begin<empty_struct>::type, 56 fusion::result_of::end<empty_struct>::type>)); 57 } 58 59 { 60 fusion::vector<> v; 61 empty_struct e; 62 BOOST_TEST(v == e); 63 BOOST_TEST_NOT(e != v); 64 BOOST_TEST_NOT(v < e); 65 BOOST_TEST(v <= e); 66 BOOST_TEST_NOT(e > v); 67 BOOST_TEST(e >= v); 68 } 69 70 { 71 empty_struct e; 72 73 // conversion from empty_struct to vector 74 fusion::vector<> v(e); 75 v = e; 76 77 // FIXME 78 // conversion from empty_struct to list 79 //fusion::list<> l(e); 80 //l = e; 81 } 82 83 BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct>)); 84 85 return boost::report_errors(); 86 } 87 88