Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wf] Remove recursivity for chain_invoke, proper requirements #21

Closed
GuillaumeDua opened this issue Jan 31, 2022 · 2 comments
Closed

[wf] Remove recursivity for chain_invoke, proper requirements #21

GuillaumeDua opened this issue Jan 31, 2022 · 2 comments
Assignees
Labels
dev - refactoring dev - refactoring enhancement New feature or request

Comments

@GuillaumeDua
Copy link
Owner

[wf] Remove recursivity for chain_invoke

  • Using a dedicated operator so fold expression can replace recursivity, even for dependent expansion

POC : https://godbolt.org/z/8noTGTvqa

namespace details::invocation_literals::eval {
    // detection/evaluation only
    constexpr auto operator>>(auto && args, auto && f)
    noexcept (std::is_nothrow_invocable_v<decltype(f), decltype(fwd(args))>)
    -> std::invoke_result_t<decltype(f), decltype(args)>
    requires (std::invocable<decltype(f), decltype(fwd(args))>)
    ; // for evaluation only, never defined
}
namespace details::invocation_literals {
    // do the job
    constexpr auto operator>>=(auto && args, auto && f)
    noexcept (std::is_nothrow_invocable_v<decltype(f), decltype(fwd(args))>)
    {
        return std::invoke(fwd(f), fwd(args));
    }
}

namespace details::mp {
    template <typename Fs, typename Args>
    struct is_chain_nothrow_invocable {
        constexpr static bool value = []<std::size_t ... indexes>(std::index_sequence<indexes...>) {
            using namespace details::invocation_literals::eval;
            return noexcept((std::declval<Args>() >> ... >> std::get<indexes>(std::declval<Fs>())));
        }(std::make_index_sequence<std::tuple_size_v<std::remove_cvref_t<Fs>>>{});
    };
}
@GuillaumeDua GuillaumeDua added enhancement New feature or request dev - refactoring dev - refactoring labels Jan 31, 2022
@GuillaumeDua GuillaumeDua self-assigned this Jan 31, 2022
@GuillaumeDua
Copy link
Owner Author

GuillaumeDua commented Feb 1, 2022

Cleanup design, integrate csl::wf::invoke : https://godbolt.org/z/4fPcaafes

@GuillaumeDua
Copy link
Owner Author

Fixed with #26 -> #27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev - refactoring dev - refactoring enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

1 participant