Daily bit(e) of C++ | [[nodiscard]] constructors and types
Daily bit(e) of C++ ♻️176, Marking constructors and types with the [[nodiscard]] attribute.
The typical use case for the [[nodiscard]] attribute is marking functions whose return value shall not be ignored.
However, we can also apply the [[nodiscard]] attribute to constructors and even entire types.
At a minimum, constructors that acquire a resource and types that represent error states should be marked with [[nodiscard]].