-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA12-1-2.cpp
More file actions
59 lines (44 loc) · 964 Bytes
/
A12-1-2.cpp
File metadata and controls
59 lines (44 loc) · 964 Bytes
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Rule: A12-1-2
// Source line: 16997
// Original file: A12-1-2.cpp
// $Id: A12-1-2.cpp 271696 2017-03-23 09:23:09Z piotr.tanski $
#include <cstdint>
#include <utility>
class A
{
public:
A() : i1{0}, i2{0} // Compliant - i1 and i2 are initialized by the
// constructor only. Not compliant with A12-1-3
{}
// Implementation
private:
std::int32_t i1;
std::int32_t i2;
};
class B
{
public:
// Implementation
private:
std::int32_t i1{0};
std::int32_t i2{
0}; // Compliant - both i1 and i2 are initialized by NSDMI only
};
class C
{
public:
C() : i2{0}
// Non-compliant - i1 is initialized by NSDMI, i2 is in
// member in member initializer list
{}
C(C const& oth) : i1{oth.i1}, i2{oth.i2} // Compliant by exception
{}
C(C&& oth)
: i1{std::move(oth.i1)},
i2{std::move(oth.i2)} // Compliant by exception
{}
// Implementation
private:
std::int32_t i1{0};
std::int32_t i2;
};