]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/util/tuples.cpp
4 // Copyright (c) 2019 Oracle and/or its affiliates.
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
8 // Use, modification and distribution is subject to the Boost Software License,
9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt)
13 #include <geometry_test_common.hpp>
15 #include <boost/geometry/util/tuples.hpp>
17 namespace bt
= boost::tuples
;
18 namespace bgt
= boost::geometry::tuples
;
19 namespace bm
= boost::mpl
;
23 : boost::is_same
<T
, double>
28 : boost::is_same
<T
, float>
32 template <typename Tuple
>
34 : boost::integral_constant
<bool, false>
37 template <class T0
, class T1
, class T2
, class T3
, class T4
, class T5
, class T6
, class T7
, class T8
, class T9
>
38 struct is_boost_tuple
<boost::tuple
<T0
, T1
, T2
, T3
, T4
, T5
, T6
, T7
, T8
, T9
> >
39 : boost::integral_constant
<bool, true>
42 template <typename Tuple
>
43 struct is_boost_tuples_cons
44 : boost::integral_constant
<bool, false>
47 template <typename HT
, typename TT
>
48 struct is_boost_tuples_cons
<boost::tuples::cons
<HT
, TT
> >
49 : boost::integral_constant
<bool, true>
52 template <typename Tuple
>
54 : boost::integral_constant
<bool, false>
57 template <typename F
, typename S
>
58 struct is_std_pair
<std::pair
<F
, S
> >
59 : boost::integral_constant
<bool, true>
62 #if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_VARIADIC_TEMPLATES)
64 template <typename Tuple
>
66 : boost::integral_constant
<bool, false>
69 template <typename
...Ts
>
70 struct is_std_tuple
<std::tuple
<Ts
...> >
71 : boost::integral_constant
<bool, true>
76 template <typename Tuple
>
79 typedef Tuple tuple_id
;
80 tuple_id
tup_id(1, 2.0);
82 BOOST_CHECK_EQUAL((bgt::get
<0>(tup_id
)), 1);
83 BOOST_CHECK_EQUAL((bgt::get
<1>(tup_id
)), 2.0);
85 BOOST_CHECK_EQUAL(int(bgt::size
<tuple_id
>::value
), 2);
87 BOOST_CHECK_EQUAL((bgt::find_index_if
<tuple_id
, is_double
>::value
), 1);
88 BOOST_CHECK((boost::is_same
<typename
bgt::find_if
<tuple_id
, is_double
>::type
, double>::value
));
90 BOOST_CHECK_EQUAL((bgt::find_index_if
<tuple_id
, is_float
>::value
), 2);
91 BOOST_CHECK((boost::is_same
<typename
bgt::find_if
<tuple_id
, is_float
>::type
, boost::tuples::null_type
>::value
));
93 typedef typename
bgt::push_back
<tuple_id
, float>::type tuple_idf
;
94 tuple_idf tup_idf
= bgt::push_back
<tuple_id
, float>::apply(tup_id
, 3.0f
);
96 BOOST_CHECK_EQUAL((bgt::get
<0>(tup_idf
)), 1);
97 BOOST_CHECK_EQUAL((bgt::get
<1>(tup_idf
)), 2.0);
98 BOOST_CHECK_EQUAL((bgt::get
<2>(tup_idf
)), 3.0f
);
100 BOOST_CHECK_EQUAL(int(bgt::size
<tuple_idf
>::value
), 3);
102 BOOST_CHECK_EQUAL((bgt::find_index_if
<tuple_idf
, is_float
>::value
), 2);
103 BOOST_CHECK((boost::is_same
<typename
bgt::find_if
<tuple_idf
, is_float
>::type
, float>::value
));
105 #if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_VARIADIC_TEMPLATES)
108 (is_boost_tuple
<tuple_id
>::value
&& is_boost_tuples_cons
<tuple_idf
>::value
)
109 || (!is_boost_tuple
<tuple_id
>::value
&& is_std_tuple
<tuple_idf
>::value
)
112 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
114 tup_idf
= bgt::push_back
<tuple_id
, float>::apply(std::move(tup_id
), 3.0f
);
116 BOOST_CHECK_EQUAL((bgt::get
<0>(tup_idf
)), 1);
117 BOOST_CHECK_EQUAL((bgt::get
<1>(tup_idf
)), 2.0);
118 BOOST_CHECK_EQUAL((bgt::get
<2>(tup_idf
)), 3.0f
);
124 BOOST_CHECK((is_boost_tuples_cons
<tuple_idf
>::type
, float>::value
));
129 int test_main(int, char* [])
131 test_all
<boost::tuple
<int, double> >();
132 test_all
<std::pair
<int, double> >();
134 #if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_VARIADIC_TEMPLATES)
136 test_all
<std::tuple
<int, double> >();