C++11/14/17 std::optional with functional-style extensions and reference support
Creative Commons Zero v1.0 Universal
859
stars
67
forks
source link
'optional<T&>::and_then(F&& f) &&' calls f with lvalue reference #9
Closed
rollbear closed 6 years ago
This makes sense. The 'optional' is an rvalue, but its contained type remains an lvalue reference. I.e.
int i = 3; optional<int&>{i}.and_then([](int& r){return optional<int&>{++r});
The optional r-value still refers to 'i', which is not an r-value.