]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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_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_struct{}; | |
31 | BOOST_FUSION_ADAPT_STRUCT_NAMED(::empty_struct,empty_struct,) | |
32 | ||
33 | int | |
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_struct empty; | |
44 | { | |
45 | BOOST_MPL_ASSERT((traits::is_view<adapted::empty_struct>)); | |
92f5a8d4 | 46 | BOOST_STATIC_ASSERT(traits::is_view<adapted::empty_struct>::value); |
7c673cae FG |
47 | adapted::empty_struct 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_struct>::value == 0); | |
53 | BOOST_MPL_ASSERT((fusion::result_of::empty<adapted::empty_struct>)); | |
54 | ||
55 | BOOST_MPL_ASSERT((fusion::result_of::equal_to< | |
56 | fusion::result_of::begin<adapted::empty_struct>::type, | |
57 | fusion::result_of::end<adapted::empty_struct>::type>)); | |
58 | } | |
59 | ||
60 | { | |
61 | fusion::vector<> v; | |
62 | adapted::empty_struct 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_struct e(empty); | |
73 | ||
74 | // conversion from empty_struct to vector | |
75 | fusion::vector<> v(e); | |
76 | v = e; | |
77 | ||
78 | // FIXME | |
79 | // conversion from empty_struct to list | |
80 | //fusion::list<> l(e); | |
81 | //l = e; | |
82 | } | |
83 | ||
84 | BOOST_MPL_ASSERT((mpl::is_sequence<adapted::empty_struct>)); | |
85 | ||
86 | return boost::report_errors(); | |
87 | } | |
88 |