Summary

Let's summarize this chapter.

To sum up: [[nodiscard]] is an excellent addition to all the important code: public APIs, safety-c​ritical systems, etc. Adding this attribute will at least enforce the code contract, and a compiler will help you detect bugs - at compile time, rather than finding in in the runtime.


Another useful feature at compile time is the if constexpr. We will deal with that next.

Get hands-on with 1400+ tech skills courses.