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

tl::optional<T&> should be constructible from a tl::optional<T>. #57

Open
BenFrantzDale opened this issue Oct 19, 2022 · 0 comments
Open

Comments

@BenFrantzDale
Copy link

To me the biggest use of optional<T&> is in arguments like void foo(optional<const Heavy&>) where the naive void foo1(const optional<Heavy>&) of course means foo1(heavy) has to copy the heavy to a optional<Heavy>. Of course, if I have an optional<Heavy> optHeavy I can call foo1(optHeavy), but if I call foo(optHeavy), tl::optional won't implicitly convert from const optional<Heavy> to optional<const Heavy&>.

That is, I'd like optional<T&> to be constructible from optional<T>. That would let foo(optHeavy) Just Work. (Or maybe just let optional<const T&> construct from const optional<T>&?)

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