diff --git a/include/continuable/detail/traits.hpp b/include/continuable/detail/traits.hpp index 1ed2d3b..cad4b1c 100644 --- a/include/continuable/detail/traits.hpp +++ b/include/continuable/detail/traits.hpp @@ -227,8 +227,14 @@ constexpr auto pack_size_of(identity>) noexcept { return size_of_t{}; } /// Returns the pack size of the given type +template +constexpr auto pack_size_of(identity>) noexcept { + return size_constant{}; +} +/// Returns the pack size of the given type template constexpr auto pack_size_of(identity) noexcept { + // TODO Replace this through the generic std::tuple_size return size_of_t{}; } diff --git a/test/unit-test/test-continuable-traverse.cpp b/test/unit-test/test-continuable-traverse.cpp index bd730a2..8f26ed5 100644 --- a/test/unit-test/test-continuable-traverse.cpp +++ b/test/unit-test/test-continuable-traverse.cpp @@ -642,6 +642,14 @@ void test_strategic_container_traverse() { } } +TEST(traverse_single_test, test_strategic_tuple_like_traverse_homogeneous) { + // Fixed size homogeneous container + std::array values{{1, 2, 3}}; + std::array res = map_pack([](int) { return 1.f; }, values); + + EXPECT_TRUE((res == std::array{{1.f, 1.f, 1.f}})); +} + void test_strategic_tuple_like_traverse() { // Every element in the tuple like type is visited { @@ -685,15 +693,6 @@ void test_strategic_tuple_like_traverse() { EXPECT_TRUE((res == expected)); } - // Fixed size homogeneous container - // TODO Fix this test - //{ - // std::array values{{1, 2, 3}}; - // std::array res = map_pack([](int) { return 1.f; }, values); - - // EXPECT_TRUE((res == std::array{{1.f, 1.f, 1.f}})); - //} - // Make it possible to pass tuples containing move only objects // in as reference, while returning those as reference. { @@ -769,6 +768,15 @@ void test_spread_container_traverse() { } } +// 1:2 mappings (multiple arguments) +TEST(traverse_single_test, test_spread_container_traverse_multiple_args) { + auto res = map_pack(duplicate_mapper{}, std::array{{1, 2}}); + + std::array expected{{1, 1, 2, 2}}; + + EXPECT_TRUE((res == expected)); +} + void test_spread_tuple_like_traverse() { // 1:2 mappings (multiple arguments) { @@ -788,16 +796,6 @@ void test_spread_tuple_like_traverse() { static_assert(std::is_void::value, "Failed..."); } - // 1:2 mappings (multiple arguments) - //{ - // std::array res = - // map_pack(duplicate_mapper{}, std::array{{1, 2}}); - - // std::array expected{{1, 1, 2, 2}}; - - // EXPECT_TRUE((res == expected)); - //} - // 1:0 mappings { using Result = @@ -805,23 +803,3 @@ void test_spread_tuple_like_traverse() { static_assert(std::is_void::value, "Failed..."); } } - -/* - TODO Convert this to gtest -int main(int, char**) { - test_mixed_traversal(); - test_mixed_early_unwrapping(); - test_mixed_container_remap(); - test_mixed_fall_through(); - - test_strategic_traverse(); - test_strategic_container_traverse(); - test_strategic_tuple_like_traverse(); - - test_spread_traverse(); - test_spread_container_traverse(); - test_spread_tuple_like_traverse(); - - return report_errors(); -} -*/