-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSample1.cpp
44 lines (36 loc) · 1 KB
/
Sample1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* \file Sample1.cpp
* \brief New standard attributes
*
* C++17 introduces three new attributes: [[fallthrough]], [[nodiscard]], [[maybe_unused]]
*/
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
//-------------------------------------------------------------------------------------------------
// Will warn if return of foo() is ignored
[[nodiscard]] int
foo()
{
return 7;
}
//-------------------------------------------------------------------------------------------------
int main(int, char **)
{
const int a {1};
switch (a) {
case 1:
// Indicates that falling through on case 1 is intentional
[[fallthrough]]; // NOTE: the semicolon to indicate the null statement
case 2:
// Indicates that b might be unused, such as on production builds
[[maybe_unused]] int b = foo();
STD_TEST(b > 0);
break;
}
return EXIT_SUCCESS;
}
//-------------------------------------------------------------------------------------------------
#if OUTPUT
// no warnings
#endif