C++ features by examples

fallthrough, nodiscard, maybe_unused More...

Collaboration diagram for New attributes:

Functions

int foo ()
 
void test_attr ()
 

Detailed Description

fallthrough, nodiscard, maybe_unused

Function Documentation

◆ foo()

int foo ( )

Definition at line 373 of file 17.cpp.

373{return 0;}
Here is the caller graph for this function:

◆ test_attr()

void test_attr ( )

Definition at line 374 of file 17.cpp.

375{
376 int a {1};
377 switch (a) {
378 // Indicates that falling through on case 1 is intentional
379 case 1:
380 [[fallthrough]];
381 case 2:
382 // Indicates that b might be unused, such as on production builds
383 [[maybe_unused]] int b = foo();
384 assert(b > 0);
385 break;
386 }
387}
int foo()
Definition: 17.cpp:373
Here is the call graph for this function: