-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA17-6-1.cpp
More file actions
84 lines (52 loc) · 1.53 KB
/
A17-6-1.cpp
File metadata and controls
84 lines (52 loc) · 1.53 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Rule: A17-6-1
// Source line: 28232
// Original file: A17-6-1.cpp
// $Id: A17-6-1.cpp 305588 2018-01-29 11:07:35Z michal.szczepankiewicz $
#include <cstdint>
#include <limits>
#include <memory>
#include <type_traits>
#include <utility>
namespace std
{
// Non-compliant - An alias definition is added to namespace std.
// This is a compile error in C++17, since std::byte is already defined.
using byte = std::uint8_t;
// Non-compliant - A function definition added to namespace std.
pair<int, int> operator+(pair<int, int> const& x, pair<int, int> const& y)
{
return pair<int, int>(x.first + y.first, x.second + y.second);
}
}
// namespace std
struct MyType
{
int value;
};
namespace std
{
// Non-compliant - std::numeric_limits may not be specialized for
// non-arithmetic types [limits.numeric].
template<>
struct numeric_limits<MyType> : numeric_limits<int>
{};
// Non-compliant - Structures in <type_traits>, except for std::common_type,
// may not be specialized [meta.type.synop].
template<>
struct is_arithmetic<MyType> : true_type
{};
// Compliant - std::hash may be specialized for a user type if the
// specialization fulfills the requirements in [unord.hash].
template<>
struct hash<MyType>
{
using result_type = size_t;
// deprecated in C++17
using argument_type = MyType; // deprecated in C++17
size_t operator()(MyType const& x) const noexcept
{
return hash<int>()(x.value);
}
};
}
// namespace std