propagate_const_helpers.h
3.67 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// A lightweight class, with pointer-like methods, that contains an int
struct X
{
int i_;
constexpr const int &operator*() const { return i_; }
constexpr int &operator*() { return i_; }
constexpr const int *get() const { return &i_; }
constexpr int *get() { return &i_; }
constexpr const int *operator->() const { return &i_; }
constexpr int *operator->() { return &i_; }
constexpr X(int i) : i_(i) {}
};
struct XWithImplicitIntStarConversion
{
int i_;
constexpr const int &operator*() const { return i_; }
constexpr int &operator*() { return i_; }
constexpr const int *get() const { return &i_; }
constexpr int *get() { return &i_; }
constexpr const int *operator->() const { return &i_; }
constexpr int *operator->() { return &i_; }
constexpr operator int* () { return &i_; }
constexpr XWithImplicitIntStarConversion(int i) : i_(i) {}
};
struct XWithImplicitConstIntStarConversion
{
int i_;
constexpr const int &operator*() const { return i_; }
constexpr int &operator*() { return i_; }
constexpr const int *get() const { return &i_; }
constexpr int *get() { return &i_; }
constexpr const int *operator->() const { return &i_; }
constexpr int *operator->() { return &i_; }
constexpr operator const int* () const { return &i_; }
constexpr XWithImplicitConstIntStarConversion(int i) : i_(i) {}
};
struct ExplicitX
{
int i_;
constexpr const int &operator*() const { return i_; }
constexpr int &operator*() { return i_; }
constexpr const int *get() const { return &i_; }
constexpr int *get() { return &i_; }
constexpr const int *operator->() const { return &i_; }
constexpr int *operator->() { return &i_; }
constexpr explicit ExplicitX(int i) : i_(i) {}
};
struct MoveConstructibleFromX
{
int i_;
constexpr const int &operator*() const { return i_; }
constexpr int &operator*() { return i_; }
constexpr const int *get() const { return &i_; }
constexpr int *get() { return &i_; }
constexpr const int *operator->() const { return &i_; }
constexpr int *operator->() { return &i_; }
constexpr MoveConstructibleFromX(int i) : i_(i) {}
constexpr MoveConstructibleFromX(X&& x) : i_(x.i_) {}
};
struct ExplicitMoveConstructibleFromX
{
int i_;
constexpr const int &operator*() const { return i_; }
constexpr int &operator*() { return i_; }
constexpr const int *get() const { return &i_; }
constexpr int *get() { return &i_; }
constexpr const int *operator->() const { return &i_; }
constexpr int *operator->() { return &i_; }
constexpr ExplicitMoveConstructibleFromX(int i) : i_(i) {}
constexpr explicit ExplicitMoveConstructibleFromX(X&& x) : i_(x.i_) {}
};
struct CopyConstructibleFromX
{
int i_;
constexpr const int &operator*() const { return i_; }
constexpr int &operator*() { return i_; }
constexpr const int *get() const { return &i_; }
constexpr int *get() { return &i_; }
constexpr const int *operator->() const { return &i_; }
constexpr int *operator->() { return &i_; }
constexpr CopyConstructibleFromX(int i) : i_(i) {}
constexpr CopyConstructibleFromX(const X& x) : i_(x.i_) {}
};
struct ExplicitCopyConstructibleFromX
{
int i_;
constexpr const int &operator*() const { return i_; }
constexpr int &operator*() { return i_; }
constexpr const int *get() const { return &i_; }
constexpr int *get() { return &i_; }
constexpr const int *operator->() const { return &i_; }
constexpr int *operator->() { return &i_; }
constexpr ExplicitCopyConstructibleFromX(int i) : i_(i) {}
constexpr explicit ExplicitCopyConstructibleFromX(const X& x) : i_(x.i_) {}
};