3 ms·
In C++ std::optional<T> does the trick, as of version 11, and boost::optional<T> previously. In C ... hrm you could probably wrangle some macros around that st
by sbmassey 12y ago
In C++ std::optional<T> does the trick, as of version 11, and boost::optional<T> previously.
In C ... hrm you could probably wrangle some macros around that struct if you were desperate.
- pbsd 12y agoNitpick: std::optional<T> does not exist in C++11, nor in the recently-approved C++14. It is, nevertheless, in the process of getting into the standard, and is already present in GCC 4.9's libstdc++ as std::experimental::optional.
- whyever 12y agoUnfortunately `std::optional` did not get accepted for C++14, because it's implementation uses some hacks that are undefined behavior by the standard (but work on the major compilers).