I just discovered std:optional in C++17

by hedayeton 4/26/2025, 9:17 PMwith 1 comments

by hedayeton 4/26/2025, 9:17 PM

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?