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"; });
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 tooptional<T&>
it was fixed. Isn't returning anoptional<T>
in these cases creating a copy of the contained reference?Example: