Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
I just discovered std:optional in C++17 (cppreference.com)
3 points by hedayet 10 months ago | hide | past | favorite | 1 comment


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?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: