-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA14-7-1.cpp
More file actions
70 lines (54 loc) · 1.09 KB
/
A14-7-1.cpp
File metadata and controls
70 lines (54 loc) · 1.09 KB
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
60
61
62
63
64
65
66
67
68
69
70
// Rule: A14-7-1
// Source line: 20947
// Original file: A14-7-1.cpp
// $Id: A14-7-1.cpp 289436 2017-10-04 10:45:23Z michal.szczepankiewicz $
#include <cstdint>
class A
{
public:
void SetProperty(std::int32_t x) noexcept {
property = x;
}
void DoSomething() noexcept {}
private:
std::int32_t property;
};
struct B
{};
class C
{
public:
void DoSomething() noexcept {}
};
template<typename T>
class D
{
public:
void F1() {}
void F2()
{
T t;
t.SetProperty(0);
}
void F3()
{
T t;
t.DoSomething();
}
};
void Fn() noexcept
{
D<A> d1; // Compliant - struct A provides all needed members
d1.F1();
d1.F2();
d1.F3();
D<B> d2; // Non-compliant - struct B does not provide needed members
d2.F1();
// d2.f2(); // Compilation error - no ’property’ in struct B
// d2.f3(); // Compilation error - no member named ’doSomething’ in struct
// B
D<C> d3; // Non-compliant - struct C does not provide property
d3.F1();
// d3.F2(); // Compilation error - no property in struct C
d3.F3();
}