-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA12-8-7.cpp
More file actions
47 lines (46 loc) · 777 Bytes
/
A12-8-7.cpp
File metadata and controls
47 lines (46 loc) · 777 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
// Rule: A12-8-7
// Source line: 19337
// Original file: A12-8-7.cpp
// $Id: A12-8-7.cpp 289436 2017-10-04 10:45:23Z michal.szczepankiewicz $
#include <cstdint>
class A
{
public:
A() = default;
A& operator*=(std::int32_t i) // Non-compliant
{
// ...
return *this;
}
};
A F1() noexcept
{
return A{};
}
class B
{
public:
B() = default;
B& operator*=(std::int32_t) & // Compliant
{
// ...
return *this;
}
};
B F2() noexcept
{
return B{};
}
std::int32_t F3() noexcept
{
return 1;
}
int main(int, char**)
{
F1() *= 10; // Temporary result of f1() multiplied by 10. No compile-time
// error.
;
// f2() *= 10; // Compile-time error due to ref-qualifier
;
// f3() *= 10; // Compile-time error on built-in type
}