#include #include #include template struct int_mapper { typedef int type; }; int main (void) { cruft::TAP::logger tap; { using tuple_t = std::tuple; tap.expect_eq (cruft::tuple::type::index::value, 1u, "tuple index extraction"); } { using tuple_t = std::tuple; tap.expect ( std::is_same_v< cruft::tuple::type::nth_t, int >, "tuple type indexing with 'nth'" ); } { #if !defined(NO_RTTI) auto tuple = std::make_tuple (1u, 1, 1.f, 1.); std::vector expected { std::type_index (typeid (1u)), std::type_index (typeid (1)), std::type_index (typeid (1.f)), std::type_index (typeid (1.)) }; std::vector actual; cruft::tuple::type::each ([&actual] (auto i) { actual.push_back (typeid (typename decltype(i)::type)); }); tap.expect_eq (actual, expected, "type iteration"); #else tap.skip ("type iteration because no-rtti"); #endif } { using pair_t = std::pair; using tuple_t = std::tuple; tap.expect (std::is_same_v, tuple_t>, "entuple a pair"); } { using a = std::pair; using b = std::tuple; using c = std::tuple; tap.expect (std::is_same_v< cruft::tuple::type::cat_t, c >, "concatenate pair and tuple"); } { using original_t = std::tuple; using removed_t = std::tuple; tap.expect (std::is_same_v< cruft::tuple::type::remove_t, removed_t >, "removed int from tuple"); } { using original_t = std::tuple; using unique_t = std::tuple; tap.expect (std::is_same_v< cruft::tuple::type::unique_t, unique_t >, "removed duplicates from tuple"); } { using src_t = std::tuple; using dst_t = typename cruft::tuple::type::map::type; tap.expect (std::is_same>::value, "tuple type mapping"); } { // Test that prefix extraction of a tuple works as expected. using full_t = std::tuple; static constexpr std::size_t LENGTH = 2; using prefix_t = cruft::tuple::type::prefix_t; using expected_t = std::tuple; tap.expect (std::is_same_v, "tuple prefix"); } return tap.status (); }