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

optional::transform mandates are too strict - need to allow references #48

Open
steve-downey opened this issue Jul 22, 2024 · 0 comments

Comments

@steve-downey
Copy link
Member

Don't overconstrain the types that can result from transform if optional<T&> is allowed.

https://eel.is/c++draft/optional#monadic-7
Let U be remove_cv_t<invoke_result_t<F, decltype(*val)>>.

https://eel.is/c++draft/optional#monadic-8
Mandates: U is a non-array object type other than in_place_t or nullopt_t. The declaration
U u(invoke(std::forward(f), *val));
is well-formed for some invented variable u.
[Note 1: There is no requirement that U is movable ([dcl.init.general]). — end note]

However, if optional<T&> is allowed, the object type requirement is too strong -- is_object_v<U> will prohibit a reference returning function creating an optional where U is a reference.

Caught by existing test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant