From ceda32b912b7413b92c3c848af5a29b89f71b3b5 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 9 Feb 2022 16:33:44 +1000 Subject: [PATCH] tuple/value: fix various compile time errors --- tuple/value.hpp | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/tuple/value.hpp b/tuple/value.hpp index c037158b..7211499d 100644 --- a/tuple/value.hpp +++ b/tuple/value.hpp @@ -250,24 +250,31 @@ namespace cruft::tuple::value { /////////////////////////////////////////////////////////////////////////// namespace detail { template - requires ( - std::is_convertible_v< - std::tuple_element_t, - std::common_type< - std::tuple_element_t... - > - > && ... - ) + // requires ( + // std::is_convertible_v< + // std::tuple_element_t, + // std::common_type< + // std::tuple_element_t... + // > + // > && ... + // ) auto - transform_array (index::indices, FunctionT &&func, TupleT &&val) + transform_array (std::index_sequence, FunctionT &&func, TupleT &&val) { - using value_type = std::common_type< - std::tuple_element_t... + using value_type = std::common_type_t< + std::invoke_result_t< + FunctionT, + std::tuple_element_t> + >... >; - return std::array> ( - std::invoke (func, std::get (val))... - ); + constexpr auto arity = std::tuple_size_v< + std::remove_cvref_t + >; + + return std::array { { + value_type (std::invoke (func, std::get (val)))... + } }; } } @@ -281,9 +288,14 @@ namespace cruft::tuple::value { auto transform_array (FunctionT &&func, TupleT &&val) { - return transform_array ( + return detail::transform_array ( + std::make_index_sequence< + std::tuple_size_v< + std::remove_cvref_t + > + > {}, std::forward (func), - std::forward (val) + std::forward (val ) ); } }