diff --git a/include/continuable/detail/composition_all.hpp b/include/continuable/detail/composition_all.hpp index c8e2e39..d15b6f5 100644 --- a/include/continuable/detail/composition_all.hpp +++ b/include/continuable/detail/composition_all.hpp @@ -179,7 +179,7 @@ struct all_hint_deducer { template static constexpr auto deduce(hints::signature_hint_tag) { - return std::make_tuple(First{}, Second{}, Args{}...); + return spread_this(First{}, Second{}, Args{}...); } template < @@ -190,8 +190,13 @@ struct all_hint_deducer { } }; -/// Converts the given argument to a tuple if it isn't a tuple already template +struct is_tuple : std::false_type {}; +template +struct is_tuple> : std::true_type {}; + +/// Converts the given argument to a tuple if it isn't a tuple already +template ::value>* = nullptr> constexpr auto tupelize(T&& arg) { return std::make_tuple(std::forward(arg)); } @@ -209,26 +214,23 @@ constexpr auto flatten(T&& tuple) { }); } -struct convert_to_hint { - template - constexpr auto operator()(T...) -> hints::signature_hint_tag; -}; -constexpr auto deduce_from_pack(traits::identity) { - return hints::signature_hint_tag<>{}; -} -template -constexpr auto deduce_from_pack(traits::identity) { - return decltype( - traits::unpack(flatten(std::declval()), convert_to_hint{})){}; -} +constexpr auto deduce_from_pack(traits::identity) + -> hints::signature_hint_tag<>; +template +constexpr auto deduce_from_pack(traits::identity>) + -> hints::signature_hint_tag; +template ::value>* = nullptr> +constexpr auto deduce_from_pack(traits::identity) + -> hints::signature_hint_tag; template -constexpr auto deduce_hint(Composition&& composition) { - using deduced_t = decltype( - map_pack(all_hint_deducer{}, std::forward(composition))); +constexpr auto deduce_hint(Composition&& /*composition*/) { + using deduced_t = + decltype(map_pack(all_hint_deducer{}, std::declval())); + // We must guard deduced_t against to be void since this represents an // empty signature hint. - return deduce_from_pack(traits::identity{}); + return decltype(deduce_from_pack(traits::identity{})){}; } } // namespace all diff --git a/include/continuable/detail/traverse.hpp b/include/continuable/detail/traverse.hpp index 9450c31..5257575 100644 --- a/include/continuable/detail/traverse.hpp +++ b/include/continuable/detail/traverse.hpp @@ -215,6 +215,7 @@ constexpr auto map_spread(C&& callable, T&&... args) -> decltype(apply_spread_impl(is_any_spread_t{}, std::forward(callable), std::forward(args)...)) { + // Check whether any of the args is a detail::flatted_tuple_t, // if not, use the linear called version for better // compilation speed. diff --git a/test/playground/test-playground.cpp b/test/playground/test-playground.cpp index 151cffb..461c865 100644 --- a/test/playground/test-playground.cpp +++ b/test/playground/test-playground.cpp @@ -27,6 +27,7 @@ #include +/* static cti::continuable http_request(std::string url) { return [url = std::move(url)](cti::promise promise) { if (false) { @@ -118,6 +119,7 @@ void old() { // ... }); } +*/ int main(int, char**) { using namespace cti::detail;