diff --git a/include/continuable/detail/composition_all.hpp b/include/continuable/detail/composition_all.hpp index cc63beb..c8e2e39 100644 --- a/include/continuable/detail/composition_all.hpp +++ b/include/continuable/detail/composition_all.hpp @@ -209,14 +209,26 @@ 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{})){}; +} + template constexpr auto deduce_hint(Composition&& composition) { - auto deduced = flatten( + using deduced_t = decltype( map_pack(all_hint_deducer{}, std::forward(composition))); - - return traits::unpack(std::move(deduced), [](auto... args) { - return hints::signature_hint_tag{}; - }); + // We must guard deduced_t against to be void since this represents an + // empty signature hint. + return deduce_from_pack(traits::identity{}); } } // namespace all