• 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.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 template <typename T>
31 class empty_adt{};
32 BOOST_FUSION_ADAPT_ASSOC_TPL_ADT((T), (empty_adt)(T),)
33 
34 int
main()35 main()
36 {
37     using namespace boost::fusion;
38     using namespace boost;
39 
40     std::cout << tuple_open('[');
41     std::cout << tuple_close(']');
42     std::cout << tuple_delimiter(", ");
43 
44     {
45         BOOST_MPL_ASSERT_NOT((traits::is_view<empty_adt<void> >));
46         empty_adt<void> e;
47 
48         std::cout << e << std::endl;
49         BOOST_TEST(e == make_vector());
50 
51         BOOST_STATIC_ASSERT(fusion::result_of::size<empty_adt<void> >::value == 0);
52         BOOST_MPL_ASSERT((fusion::result_of::empty<empty_adt<void> >));
53 
54         BOOST_MPL_ASSERT((fusion::result_of::equal_to<
55             fusion::result_of::begin<empty_adt<void> >::type,
56             fusion::result_of::end<empty_adt<void> >::type>));
57     }
58 
59     {
60         fusion::vector<> v;
61         empty_adt<void>  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_adt<void> e;
72 
73         // conversion from empty_adt to vector
74         fusion::vector<> v(e);
75         v = e;
76 
77         // FIXME
78         // conversion from empty_adt to list
79         //fusion::list<> l(e);
80         //l = e;
81     }
82 
83     BOOST_MPL_ASSERT((mpl::is_sequence<empty_adt<void> >));
84     BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_adt<void>, void>));
85     BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_adt<void>, int>));
86 
87     return boost::report_errors();
88 }
89 
90