10 #define BOOST_TEST_MODULE ( MetaUtils_test ) 11 #include <boost/test/unit_test.hpp> 20 #include <string_view> 22 #include <type_traits> 30 static_assert(util::find_next_type_v<int, 0U, int, int, float> == 0U);
31 static_assert(util::find_next_type_v<float, 0U, int, int, float> == 2U);
32 static_assert(util::find_next_type_v<const float, 0U, int, int, float> == 3U);
33 static_assert(util::find_next_type_v<int, 1U, int, int, float> == 1U);
34 static_assert(util::find_next_type_v<float, 1U, int, int, float> == 2U);
35 static_assert(util::find_next_type_v<const float, 1U, int, int, float> == 3U);
36 static_assert(util::find_next_type_v<int, 2U, int, int, float> == 3U);
37 static_assert(util::find_next_type_v<float, 2U, int, int, float> == 2U);
38 static_assert(util::find_next_type_v<const float, 2U, int, int, float> == 3U);
39 static_assert(util::find_next_type_v<int, 3U, int, int, float> == 3U);
40 static_assert(util::find_next_type_v<float, 3U, int, int, float> == 3U);
41 static_assert(util::find_next_type_v<const float, 3U, int, int, float> == 3U);
42 static_assert(util::find_next_type_v<int, 4U, int, int, float> == 3U);
43 static_assert(util::find_next_type_v<float, 4U, int, int, float> == 3U);
44 static_assert(util::find_next_type_v<const float, 4U, int, int, float> == 3U);
50 static_assert(util::find_type_v<int, int, int, float> == 0U);
51 static_assert(util::find_type_v<float, int, int, float> == 2U);
52 static_assert(util::find_type_v<const float, int, int, float> == 3U);
58 static_assert( util::is_any_of_v<int, int, int, float>);
59 static_assert( util::is_any_of_v<float, int, int, float>);
60 static_assert(!util::is_any_of_v<const float, int, int, float>);
66 static_assert( util::is_same_decay_v<int, int>);
67 static_assert( util::is_same_decay_v<int const, int>);
68 static_assert( util::is_same_decay_v<int const, int&>);
69 static_assert( util::is_same_decay_v<int const, int volatile&>);
70 static_assert(!util::is_same_decay_v<int const, float&>);
71 static_assert(!util::is_same_decay_v<unsigned int const, int volatile&>);
80 static_assert(!util::is_instance_of_v<std::unique_ptr, int>);
86 static_assert( util::is_character_type_v<char>);
87 static_assert( util::is_character_type_v<signed char>);
88 static_assert( util::is_character_type_v<unsigned char>);
89 static_assert( util::is_character_type_v<wchar_t>);
90 static_assert(!util::is_character_type_v<short int>);
91 static_assert(!util::is_character_type_v<std::string>);
97 static_assert(!util::is_string_type_v<short int>);
100 static_assert( util::is_string_type_v<std::string>);
101 static_assert( util::is_string_type_v<std::string_view>);
102 static_assert( util::is_string_type_v<char const*>);
103 static_assert( util::is_string_type_v<char const*&>);
104 static_assert( util::is_string_type_v<wchar_t*>);
112 static_assert(!util::is_basic_string_type_v<short int>);
115 static_assert( util::is_basic_string_type_v<std::string>);
116 static_assert(!util::is_basic_string_type_v<std::string_view>);
117 static_assert( util::is_basic_string_type_v<std::wstring>);
118 static_assert(!util::is_basic_string_type_v<std::wstring_view>);
119 static_assert( util::is_basic_string_type_v<std::string const&>);
120 static_assert(!util::is_basic_string_type_v<std::string_view const&>);
121 static_assert( util::is_basic_string_type_v<std::wstring const&>);
122 static_assert(!util::is_basic_string_type_v<std::wstring_view const&>);
123 static_assert(!util::is_basic_string_type_v<char const*>);
124 static_assert(!util::is_basic_string_type_v<char const*&>);
125 static_assert(!util::is_basic_string_type_v<wchar_t*>);
133 static_assert(!util::is_basic_string_view_type_v<short int>);
136 static_assert(!util::is_basic_string_view_type_v<std::string>);
137 static_assert( util::is_basic_string_view_type_v<std::string_view>);
138 static_assert(!util::is_basic_string_view_type_v<std::wstring>);
139 static_assert( util::is_basic_string_view_type_v<std::wstring_view>);
140 static_assert(!util::is_basic_string_view_type_v<std::string const&>);
141 static_assert( util::is_basic_string_view_type_v<std::string_view const&>);
142 static_assert(!util::is_basic_string_view_type_v<std::wstring const&>);
143 static_assert( util::is_basic_string_view_type_v<std::wstring_view const&>);
144 static_assert(!util::is_basic_string_view_type_v<char const*>);
145 static_assert(!util::is_basic_string_view_type_v<char const*&>);
146 static_assert(!util::is_basic_string_view_type_v<wchar_t*>);
155 static_assert(!util::is_STLarray_v<int>);
164 static_assert(!util::is_reference_wrapper_v<int>);
173 static_assert(!util::is_unique_ptr_v<int>);
174 static_assert(!util::is_unique_ptr_v<int*>);
175 static_assert(!util::is_unique_ptr_v<int const*>);
284 auto refw = std::ref(v);
285 auto crefw = std::cref(v);
307 std::vector<int>
data(4U, 0);
308 std::vector<int const*> dataPtr;
309 std::transform(data.cbegin(), data.cend(), std::back_inserter(dataPtr),
313 for (
auto&& [ data, dataPtr ]:
util::zip(data, dataPtr)) {
314 BOOST_TEST(dataPtr == &data);
325 int const& cref = obj;
326 auto refw = std::ref(obj);
327 auto crefw = std::cref(obj);
Definition of util::zip().
Functor applying the proper referenced_address() function.
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.