I learned about the new range API of std::optional from Steve Downey at CppCon 2025 during his talk about std::optional. To be honest, I found the idea quite strange at first. I wanted to dig deeper to understand the motivation and the implications. The first example I encountered was this: 1 2 3 4 5 6 7 void doSomething(std::string const& data, std::optional logger = {}) { for (auto l : logger) { l.log(data); } return; } This shows that you can iterate over an optional. In fact, iterating ov...| Sandor Dargo’s Blog
If you’re a regular reader of my blog, you know I’ve been sharing what I learn about new C++ language and library features ever since C++20. You probably also read my CppCon 2025 Trip Report. And this post is where the two come together. At CppCon I attended a great talk by Steve Downey about std::optional. Steve is the father of optional references—he co-authored P2988R12 with Peter Sommerlad. Let’s start with a little history. By now — at the end of 2025 — even C++17 feels like ...| Sandor Dargo’s Blog