Remix.run Logo
Matheus28 3 days ago

    std::optional<T&>
Can't have optional references in C++. Use either std::reference_wrapper, or just a pointer
cocoto 3 days ago | parent [-]

It is specified previously in the text that support for references would be nice for optionals.

tialaramex 3 days ago | parent [-]

And unless I'm mistaken C++ 26 gets std::optional<T&> with the preferred representation (ie it's the same size as T& like with Rust's Option<&T> and &T pairing) and the ergonomics are no worse than you'd expect for C++