-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA12-1-4.cpp
More file actions
46 lines (40 loc) · 939 Bytes
/
A12-1-4.cpp
File metadata and controls
46 lines (40 loc) · 939 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
// Rule: A12-1-4
// Source line: 17261
// Original file: A12-1-4.cpp
// $Id: A12-1-4.cpp 289436 2017-10-04 10:45:23Z michal.szczepankiewicz $
#include <cstdint>
class A
{
public:
explicit A(std::int32_t number) : x(number) {} // Compliant
A(A const&) = default;
A(A&&) = default;
A& operator=(A const&) = default;
A& operator=(A&&) = default;
private:
std::int32_t x;
};
class B
{
public:
B(std::int32_t number) : x(number) {} // Non-compliant
B(B const&) = default;
B(B&&) = default;
B& operator=(B const&) = default;
B& operator=(B&&) = default;
private:
std::int32_t x;
};
void F1(A a) noexcept
{}
void F2(B b) noexcept
{}
void F3() noexcept
{
F1(A(10));
// f1(10); // Compilation error - because of explicit constructor it is not
// possible to implicitly convert integer
// to type of class A
F2(B(20));
F2(20); // No compilation error - implicit conversion occurs
}