4 ms·
std::optional<T&> Can't have optional references in C++. Use either std::reference_wrapper, or just a pointer
by Matheus28 2y ago
std::optional<T&>
Can't have optional references in C++. Use either std::reference_wrapper, or just a pointer
- cocoto 2y agoIt is specified previously in the text that support for references would be nice for optionals.
- tialaramex 2y agoAnd 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++