Closed TartanLlama closed 6 years ago
Thanks to @ThePhD.
struct foo{ int& v() { return i; } int i = 0; }; int& x(int& i) { i = 42; return i;} int main() { tl::optional<foo> f = foo{}; auto v = f.map(&foo::v).map(x); static_assert(std::is_same_v<decltype(v), tl::optional<int&>>); //f.i should be 42 }
Thanks to @ThePhD.