]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/fusion/test/sequence/define_tpl_struct_inline.cpp
1 /*=============================================================================
2 Copyright (c) 2010, 2012 Christopher Schmidt, nathan Ridge
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 ==============================================================================*/
8 #include <boost/detail/lightweight_test.hpp>
9 #include <boost/fusion/sequence.hpp>
10 #include <boost/fusion/container.hpp>
11 #include <boost/fusion/support.hpp>
12 #include <boost/fusion/sequence/io/out.hpp>
13 #include <boost/fusion/adapted/struct/define_struct_inline.hpp>
14 #include <boost/preprocessor/empty.hpp>
15 #include <boost/mpl/assert.hpp>
16 #include <boost/static_assert.hpp>
22 BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE(
30 template <typename
= int>
33 BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE(
43 BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE((M
), s
, (M
, m
))
45 BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE((M
), empty_struct
, )
48 template <typename Point
>
51 using namespace boost::fusion
;
53 std::cout
<< tuple_open('[');
54 std::cout
<< tuple_close(']');
55 std::cout
<< tuple_delimiter(", ");
58 BOOST_STATIC_ASSERT(boost::fusion::result_of::size
<ns::empty_struct
<int> >::value
== 0);
59 BOOST_STATIC_ASSERT(boost::fusion::result_of::empty
<ns::empty_struct
<int> >::value
);
63 BOOST_MPL_ASSERT_NOT((traits::is_view
<Point
>));
66 std::cout
<< at_c
<0>(p
) << std::endl
;
67 std::cout
<< at_c
<1>(p
) << std::endl
;
68 std::cout
<< p
<< std::endl
;
69 BOOST_TEST(p
== make_vector(123, 456));
73 BOOST_TEST(p
== make_vector(6, 9));
75 BOOST_STATIC_ASSERT(boost::fusion::result_of::size
<Point
>::value
== 2);
76 BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty
<Point
>::value
);
78 BOOST_TEST(front(p
) == 6);
79 BOOST_TEST(back(p
) == 9);
83 vector
<int, float> v1(4, 2.f
);
85 vector
<long, double> v3(5, 4.);
97 // conversion from Point to vector
99 vector
<int, long> v(p
);
104 // conversion from Point to list
106 list
<int, long> l(p
);
111 using namespace boost::fusion
;
113 typedef boost::fusion::result_of::begin
<ns::s
<int> >::type b
;
114 typedef boost::fusion::result_of::end
<ns::s
<int> >::type e
;
116 BOOST_MPL_ASSERT((boost::is_same
<boost::fusion::result_of::next
<b
>::type
, e
>));
121 Point p
= make_list(5,3);
122 BOOST_TEST(p
== make_vector(5,3));
125 BOOST_TEST(p
== make_vector(3,5));
132 run_test
<cls::point
<int, int> >(); // test non-template enclosing class
133 run_test
<tpl_cls
<>::point
<int, int> >(); // test template enclosing class
135 return boost::report_errors();