9 #include <boost/test/unit_test.hpp>
20 #include <type_traits>
22 #include <boost/hana.hpp>
23 #include <boost/hana/core/to.hpp>
24 #include <boost/hana/equal.hpp>
25 #include <boost/hana/ext/std/tuple.hpp>
26 #include <boost/hana/integral_constant.hpp>
27 #include <boost/hana/set.hpp>
28 #include <boost/hana/transform.hpp>
29 #include <boost/hana/tuple.hpp>
30 #include <boost/hana/type.hpp>
31 #include <boost/hana/union.hpp>
33 namespace hana = boost::hana;
36 template <
bool ascending,
bool strict,
typename T,
T...
values>
49 static_assert(not all_of_v<true, true, false>,
50 "all_of_v<true, true, false> failed");
51 static_assert(not all_of_v<false, true, true, false>,
52 "all_of_v<false, true, true, false> failed");
53 static_assert(all_of_v<true, true, true>,
54 "all_of_v<true, true, true> failed");
55 static_assert(all_of_v<true>,
"all_of_v<true> failed");
56 static_assert(not all_of_v<false>,
"all_of_v<false> failed");
57 static_assert(all_of_v<>,
"all_of_v<> failed");
62 constexpr
auto first = hana::make_set(hana::type_c<float>, hana::type_c<int>,
63 hana::type_c<char>, hana::type_c<bool>);
65 constexpr
auto second = hana::make_set(hana::type_c<long>, hana::type_c<int>);
66 constexpr
auto found = hana::union_(first, second);
69 constexpr
auto expected =
70 hana::make_set(hana::type_c<float>, hana::type_c<int>, hana::type_c<char>,
71 hana::type_c<bool>, hana::type_c<long>);
73 static_assert(found == expected,
"union of hana::sets failed");
77 constexpr
auto a_set = hana::make_set(hana::type_c<float>, hana::type_c<int>,
78 hana::type_c<char>, hana::type_c<bool>);
79 constexpr
auto h_tuple =
81 hana::type_c<char>, hana::type_c<bool>);
83 static_assert(hana::to<hana::tuple_tag>(a_set) == h_tuple,
"not equal");
92 template <
typename...
args>
98 constexpr
auto hana_set = hana::make_set(
99 hana::type_c<float>, hana::type_c<int>, hana::type_c<char>);
101 decltype(hana::unpack(hana_set, hana::template_<variadic_struct>))::
type;
106 "using boost::mpl::set for variadic templates failed");
109 std::is_same<expected::tuple, std::tuple<float, int, char>>::
value,
115 using result_type = int;
116 using action_type = char;
124 using result_type = bool;
125 using action_type = float;
130 using action_type = float;
134 template <
typename...
Args>
141 static_assert(detail::has_result_type_v<traits1>,
"Did not find result type");
143 "Did not find result type");
145 "Did find result type");
147 static_assert(detail::has_action_type_v<traits1>,
"Did not find action type");
149 "Did not find action type");
151 "Did not find action type");
153 constexpr
auto found_results =
156 constexpr
auto expected_results =
157 hana::make_set(hana::type_c<int>, hana::type_c<bool>);
158 static_assert(found_results == expected_results,
159 "Didn't find expected results");
162 using found_results_tuple = decltype(hana::unpack(
163 found_results, hana::template_<tuple_helper>))::type::tuple;
164 using expected_results_tuple = std::tuple<int, bool>;
167 "Unpacked results tuple not correct");
169 constexpr
auto found_actions =
171 traits2<true>, traits2<false>>;
172 constexpr
auto expected_actions =
173 hana::make_set(hana::type_c<char>, hana::type_c<float>);
174 static_assert(found_actions == expected_actions,
175 "Didn't find expected actions");
178 using found_actions_tuple = decltype(hana::unpack(
179 found_actions, hana::template_<tuple_helper>))::type::tuple;
180 using expected_actions_tuple = std::tuple<char, float>;
183 "Unpacked actions tuple not correct");
188 static_assert(has_duplicates_v<int, float, char, int>,
189 "has_duplicates_v failed");
190 static_assert(has_duplicates_v<int, int, char, float>,
191 "has_duplicates_v failed");
192 static_assert(has_duplicates_v<int, char, float, float>,
193 "has_duplicates_v failed");
194 static_assert(has_duplicates_v<int, char, char, float>,
195 "has_duplicates_v failed");
196 static_assert(not has_duplicates_v<int, bool, char, float>,
197 "has_duplicates_v failed");
203 static_assert(any_of_v<true, true, false>,
204 "any_of_v<true, true, false> failed");
205 static_assert(any_of_v<false, true, true, false>,
206 "any_of_v<false, true, true, false> failed");
207 static_assert(any_of_v<true, true, true>,
208 "any_of_v<true, true, true> failed");
209 static_assert(not any_of_v<false, false>,
"any_of_v<false, false> failed");
210 static_assert(any_of_v<true>,
"any_of_v<true> failed");
211 static_assert(not any_of_v<false>,
"any_of_v<false> failed");
212 static_assert(not any_of_v<>,
"any_of_v<> failed");
236 using detail::are_sorted;
272 using detail::are_within;
287 using detail::at_index;