C++26: std::optional<T&>

https://www.sandordargo.com/blog/2025/10/01/cpp26-optional-of-reference

Comments

1 points · 2 comments · view on lemmy.world

2 Comments

quilan@lemmy.world · 1 pts · 352d

Phew, having to use reference_wrapper sucked. I hope this will be a bit more ergonomic.

faint_marble_noise@programming.dev · 1 pts · 352d

This allows to use methods of optional (c++23 added a couple of nice ones), as opposed to raw pointer. It seems to be obvious, but there is no mention of it in the discussion behind the link.