| Start |
|---|
| [[fallthrough]] Whenever a From C++17 on, a standard attribute was introduced to indicate that the warning is not needed when the code is meant to fall through.
Compilers can safely give warnings when a case is ended without See the proposal (opens new window) for more detailed examples on how |
| [[deprecated]] and [[deprecated("reason")]] C++14 introduced a standard way of deprecating functions via attributes. This attribute may be applied to:
(ref. c++14 standard draft (opens new window): 7.6.5 Deprecated attribute) |
| [[nodiscard]] The
Adding the attribute to a type has the same behaviour as adding the attribute to every single function which returns this type. See the proposal (opens new window) for more detailed examples on how Note: The implementation details of |
| [[noreturn]] C++11 introduced the For instance, the function below will always either throw an exception or call This kind of functionality allows the compiler to end a function without a return statement if it knows the code will never be executed. Here, because the call to It is undefined behavior if the function will actually return, so the following is not allowed: Note that the The following standard library functions have this attribute:
|
| [[maybe_unused]] The A typical example of variables which are needed in debug builds while unneeded in production are return values indicating success. In the debug builds, the condition should be asserted, though in production these asserts have been removed. A more complex example are different kind of helper functions which are in an unnamed namespace. If these functions aren't used during compilation, a compiler might give a warning on them. Ideally you would like to guard them with the same preprocessor tags as the caller, though as this might become complex the See the proposal (opens new window) for more detailed examples on how Syntax |
Read Article
https://develop.horje.com/learn/1434/reference