You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All implementations of or_else in the case of an optional with a reference return optional<T>.
I ran into an issue with that, and when changing all signatures to optional<T&> it was fixed.
Isn't returning an optional<T> in these cases creating a copy of the contained reference?
Example:
struct IF
{
virtual void foo() = 0;
};
struct Impl : IF
{
void foo() override {}
};
Impl instance{};
tl::optional<IF&> test = tl::optional<IF&>{instance}.or_else([]() { std::cout << "bad"; });
The text was updated successfully, but these errors were encountered:
Hi, I ran into the same issue, with a use case similar to OP's. It seems that tl::optional<T&>::or_else should indeed return tl::optional<T&> instead of tl::optional<T>.
There are currently no test cases that would check any of those overloads for optional references.
I suggest changing the return types as described above. Let me know if you want me to create a PR for that.
All implementations of
or_else
in the case of an optional with a reference returnoptional<T>
.I ran into an issue with that, and when changing all signatures to
optional<T&>
it was fixed.Isn't returning an
optional<T>
in these cases creating a copy of the contained reference?Example:
The text was updated successfully, but these errors were encountered: