9 #include <boost/test/unit_test.hpp>
11 #include <type_traits>
13 #include <boost/hana.hpp>
14 #include <boost/hana/core/to.hpp>
15 #include <boost/hana/equal.hpp>
16 #include <boost/hana/ext/std/tuple.hpp>
17 #include <boost/hana/integral_constant.hpp>
18 #include <boost/hana/set.hpp>
19 #include <boost/hana/transform.hpp>
20 #include <boost/hana/tuple.hpp>
21 #include <boost/hana/type.hpp>
22 #include <boost/hana/union.hpp>
32 namespace hana = boost::hana;
40 static_assert(not all_of_v<true, true, false>,
41 "all_of_v<true, true, false> failed");
42 static_assert(not all_of_v<false, true, true, false>,
43 "all_of_v<false, true, true, false> failed");
44 static_assert(all_of_v<true, true, true>,
45 "all_of_v<true, true, true> failed");
46 static_assert(all_of_v<true>,
"all_of_v<true> failed");
47 static_assert(not all_of_v<false>,
"all_of_v<false> failed");
48 static_assert(all_of_v<>,
"all_of_v<> failed");
53 constexpr
auto first = hana::make_set(hana::type_c<float>, hana::type_c<int>,
54 hana::type_c<char>, hana::type_c<bool>);
56 constexpr
auto second = hana::make_set(hana::type_c<long>, hana::type_c<int>);
57 constexpr
auto found = hana::union_(first, second);
60 constexpr
auto expected =
61 hana::make_set(hana::type_c<float>, hana::type_c<int>, hana::type_c<char>,
62 hana::type_c<bool>, hana::type_c<long>);
64 static_assert(found == expected,
"union of hana::sets failed");
68 constexpr
auto a_set = hana::make_set(hana::type_c<float>, hana::type_c<int>,
69 hana::type_c<char>, hana::type_c<bool>);
70 constexpr
auto h_tuple =
71 hana::make_tuple(hana::type_c<float>, hana::type_c<int>,
72 hana::type_c<char>, hana::type_c<bool>);
74 static_assert(hana::to<hana::tuple_tag>(a_set) == h_tuple,
"not equal");
83 template <
typename... args>
85 using tuple = std::tuple<args...>;
89 constexpr
auto hana_set = hana::make_set(
90 hana::type_c<float>, hana::type_c<int>, hana::type_c<char>);
92 decltype(hana::unpack(hana_set, hana::template_<variadic_struct>))::type;
97 "using boost::mpl::set for variadic templates failed");
100 std::is_same<expected::tuple, std::tuple<float, int, char>>::
value,
106 using result_type =
int;
107 using action_type = char;
115 using result_type = bool;
116 using action_type = float;
121 using action_type = float;
125 template <
typename... Args>
132 static_assert(detail::has_result_type_v<traits1>,
"Did not find result type");
134 "Did not find result type");
136 "Did find result type");
138 static_assert(detail::has_action_type_v<traits1>,
"Did not find action type");
140 "Did not find action type");
142 "Did not find action type");
144 constexpr
auto found_results =
147 constexpr
auto expected_results =
148 hana::make_set(hana::type_c<int>, hana::type_c<bool>);
149 static_assert(found_results == expected_results,
150 "Didn't find expected results");
153 using found_results_tuple = decltype(
154 hana::unpack(found_results, hana::template_<tuple_helper>))::type::tuple;
155 using expected_results_tuple = std::tuple<int, bool>;
158 "Unpacked results tuple not correct");
160 constexpr
auto found_actions =
162 traits2<true>, traits2<false>>;
163 constexpr
auto expected_actions =
164 hana::make_set(hana::type_c<char>, hana::type_c<float>);
165 static_assert(found_actions == expected_actions,
166 "Didn't find expected actions");
169 using found_actions_tuple = decltype(
170 hana::unpack(found_actions, hana::template_<tuple_helper>))::type::tuple;
171 using expected_actions_tuple = std::tuple<char, float>;
174 "Unpacked actions tuple not correct");
179 static_assert(has_duplicates_v<int, float, char, int>,
180 "has_duplicates_v failed");
181 static_assert(has_duplicates_v<int, int, char, float>,
182 "has_duplicates_v failed");
183 static_assert(has_duplicates_v<int, char, float, float>,
184 "has_duplicates_v failed");
185 static_assert(has_duplicates_v<int, char, char, float>,
186 "has_duplicates_v failed");
187 static_assert(not has_duplicates_v<int, bool, char, float>,
188 "has_duplicates_v failed");
194 static_assert(any_of_v<true, true, false>,
195 "any_of_v<true, true, false> failed");
196 static_assert(any_of_v<false, true, true, false>,
197 "any_of_v<false, true, true, false> failed");
198 static_assert(any_of_v<true, true, true>,
199 "any_of_v<true, true, true> failed");
200 static_assert(not any_of_v<false, false>,
"any_of_v<false, false> failed");
201 static_assert(any_of_v<true>,
"any_of_v<true> failed");
202 static_assert(not any_of_v<false>,
"any_of_v<false> failed");
203 static_assert(not any_of_v<>,
"any_of_v<> failed");
227 using detail::are_sorted;
263 using detail::are_within;
278 using detail::at_index;