3 ms·
This the proper place for std::optional<T>.
by ncmncm 5y ago
This the proper place for std::optional<T>.
- PaulDavisThe1st 5y agothat has quite the overhead for something that can be done using a single bit of the actual value. roughly half the programming i do is high-performance real-time constrained. not really appropriate in that context.
- ncmncm 5y agoThere is a proper place for everything, and others for everything else. You can make a zero-overhead analog of optional<int>, for such cases, for clarity and safety. (Unless you are also trying to present a C API for cross-language compatibility...) But it is tricky to determine the exact amount of handholding to provide for such a type, and extra work to remember exactly what it is. We all know how ints work.