C++17 additions
Fallthrough, maybe_unused and nodiscard are the three new attributes in C++ 17 that this lesson talks about.
We'll cover the following
Attributes in C++17
With C++17 we get three more standard attributes:
• [[fallthrough]]
• [[maybe_unused]]
• [[nodiscard]]
Extra Info: The new attributes were specified in P0188 and P0068(reasoning).
Plus three supporting features:
- Attributes for Namespaces and Enumerators
- Ignore Unknown Attributes
- Using Attribute Namespaces Without Repetition
Let’s go through the new attributes first.
Two new attributes
[[fallthrough]] attribute
Indicates that a fall-through in a switch statement is intentional and a warning should not be issued for it.
Example:
Get hands-on with 1400+ tech skills courses.