I just discovered std:optional in C++17

3 hedayet 1 4/26/2025, 9:17:19 PM en.cppreference.com ↗

Comments (1)

hedayet · 5d ago
After all these years of returning magic values for “no result,” I finally came across std::optional<T> (added in C++17). It makes representing “maybe there’s a value, maybe not” so much cleaner and safer.

Has anyone else had a “how did I live without this?” moment? What’s your favorite underrated C++ feature?