• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/adt/adapt_assoc_adt_named.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_adt{};
31 BOOST_FUSION_ADAPT_ASSOC_ADT_NAMED(::empty_adt,empty_adt,)
32 
33 int
main()34 main()
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     empty_adt empty;
44     {
45         BOOST_MPL_ASSERT((traits::is_view<adapted::empty_adt>));
46         BOOST_STATIC_ASSERT(traits::is_view<adapted::empty_adt>::value);
47         adapted::empty_adt e(empty);
48 
49         std::cout << e << std::endl;
50         BOOST_TEST(e == make_vector());
51 
52         BOOST_STATIC_ASSERT(fusion::result_of::size<adapted::empty_adt>::value == 0);
53         BOOST_MPL_ASSERT((fusion::result_of::empty<adapted::empty_adt>));
54 
55         BOOST_MPL_ASSERT((fusion::result_of::equal_to<
56             fusion::result_of::begin<adapted::empty_adt>::type,
57             fusion::result_of::end<adapted::empty_adt>::type>));
58     }
59 
60     {
61         fusion::vector<> v;
62         adapted::empty_adt e(empty);
63         BOOST_TEST(v == e);
64         BOOST_TEST_NOT(e != v);
65         BOOST_TEST_NOT(v < e);
66         BOOST_TEST(v <= e);
67         BOOST_TEST_NOT(e > v);
68         BOOST_TEST(e >= v);
69     }
70 
71     {
72         adapted::empty_adt e(empty);
73 
74         // conversion from empty_adt to vector
75         fusion::vector<> v(e);
76         v = e;
77 
78         // FIXME
79         // conversion from empty_adt to list
80         //fusion::list<> l(e);
81         //l = e;
82     }
83 
84     BOOST_MPL_ASSERT((mpl::is_sequence<adapted::empty_adt>));
85     BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<adapted::empty_adt, void>));
86     BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<adapted::empty_adt, int>));
87 
88     return boost::report_errors();
89 }
90 
91