boostorg / boostorg/optional

Use std::invoke for monadic interface

Open
#81 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
60
Forks
75
PR merge metrics
No merged PRs in 30d

Description

At the moment the functions `map` and `flat_map` use the function call syntax `f(value())`. This allows "only" global/static functions and function objects to be used. But it is not possible to use a member function of the wrapped type which would require different call syntax. Using `std::invoke(f, value())` instead would lead to a more general interface. This was also proposed in [P0798](http://open-std.org/JTC1/SC22/WG21/docs/papers/2019/p0798r3.html#new-section-monadic-operations-optionalmonadic).
One drawback of this approach would be that (e. g. _non-const_/`const`) overloaded member functions weren't supported since their type couldn't be deferred (I think?). To support all the variations of _no-ref_/`&`/`&&`, `const` and `noexcept`, several new overloads would be needed. And even then, it may not work as expected (?).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.