-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA13-3-1.cpp
More file actions
51 lines (39 loc) · 1.06 KB
/
A13-3-1.cpp
File metadata and controls
51 lines (39 loc) · 1.06 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
// Rule: A13-3-1
// Source line: 19949
// Original file: A13-3-1.cpp
// $Id: A13-3-1.cpp 309903 2018-03-02 12:54:18Z christof.meerwald $
#include <cstdint>
template<typename T>
void F1(T&& t) noexcept(false)
{}
void F1(
std::int32_t&& t) noexcept // Non-compliant - overloading a function with
// forwarding reference
{}
template<typename T>
void F2(T&& t) noexcept(false)
{}
void F2(std::int32_t&) = delete;
// Compliant by exception
class A
{
public:
// Compliant by exception, constrained to not match copy/move ctors
template<typename T,
std::enable_if_t<!std::is_same<std::remove_cv_t<std::
remove_reference_t<T>>, A>::value> * = nullptr>
A(T &&value);
};
int main(int, char**)
{
std::int32_t x = 0;
F1(x);
// Calls f1(T&&) with T = int&
F1(+x); // Calls f1(std::int32_t&&)
F1(0);
// Calls f1(std::int32_t&&)
F1(0U); // Calls f1(T&&) with T = unsigned int
F2(0);
// Calls f2(T&&) with T = int
// f2(x); // Compilation error, the overloading function is deleted
}