• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  // A lightweight class, with pointer-like methods, that contains an int
2 struct X
3 {
4     int i_;
5 
6     constexpr const int &operator*() const { return i_; }
7     constexpr int &operator*() { return i_; }
getX8     constexpr const int *get() const { return &i_; }
getX9     constexpr int *get() { return &i_; }
10     constexpr const int *operator->() const { return &i_; }
11     constexpr int *operator->() { return &i_; }
12 
XX13     constexpr X(int i) : i_(i) {}
14 };
15 
16 struct XWithImplicitIntStarConversion
17 {
18     int i_;
19 
20     constexpr const int &operator*() const { return i_; }
21     constexpr int &operator*() { return i_; }
getXWithImplicitIntStarConversion22     constexpr const int *get() const { return &i_; }
getXWithImplicitIntStarConversion23     constexpr int *get() { return &i_; }
24     constexpr const int *operator->() const { return &i_; }
25     constexpr int *operator->() { return &i_; }
26     constexpr operator int* () { return &i_; }
27 
XWithImplicitIntStarConversionXWithImplicitIntStarConversion28     constexpr XWithImplicitIntStarConversion(int i) : i_(i) {}
29 };
30 
31 struct XWithImplicitConstIntStarConversion
32 {
33     int i_;
34 
35     constexpr const int &operator*() const { return i_; }
36     constexpr int &operator*() { return i_; }
getXWithImplicitConstIntStarConversion37     constexpr const int *get() const { return &i_; }
getXWithImplicitConstIntStarConversion38     constexpr int *get() { return &i_; }
39     constexpr const int *operator->() const { return &i_; }
40     constexpr int *operator->() { return &i_; }
41     constexpr operator const int* () const { return &i_; }
42 
XWithImplicitConstIntStarConversionXWithImplicitConstIntStarConversion43     constexpr XWithImplicitConstIntStarConversion(int i) : i_(i) {}
44 };
45 
46 struct ExplicitX
47 {
48     int i_;
49 
50     constexpr const int &operator*() const { return i_; }
51     constexpr int &operator*() { return i_; }
getExplicitX52     constexpr const int *get() const { return &i_; }
getExplicitX53     constexpr int *get() { return &i_; }
54     constexpr const int *operator->() const { return &i_; }
55     constexpr int *operator->() { return &i_; }
56 
ExplicitXExplicitX57     constexpr explicit ExplicitX(int i) : i_(i) {}
58 };
59 
60 struct MoveConstructibleFromX
61 {
62     int i_;
63 
64     constexpr const int &operator*() const { return i_; }
65     constexpr int &operator*() { return i_; }
getMoveConstructibleFromX66     constexpr const int *get() const { return &i_; }
getMoveConstructibleFromX67     constexpr int *get() { return &i_; }
68     constexpr const int *operator->() const { return &i_; }
69     constexpr int *operator->() { return &i_; }
70 
MoveConstructibleFromXMoveConstructibleFromX71     constexpr MoveConstructibleFromX(int i) : i_(i) {}
MoveConstructibleFromXMoveConstructibleFromX72     constexpr MoveConstructibleFromX(X&& x) : i_(x.i_) {}
73 };
74 
75 struct ExplicitMoveConstructibleFromX
76 {
77     int i_;
78 
79     constexpr const int &operator*() const { return i_; }
80     constexpr int &operator*() { return i_; }
getExplicitMoveConstructibleFromX81     constexpr const int *get() const { return &i_; }
getExplicitMoveConstructibleFromX82     constexpr int *get() { return &i_; }
83     constexpr const int *operator->() const { return &i_; }
84     constexpr int *operator->() { return &i_; }
85 
ExplicitMoveConstructibleFromXExplicitMoveConstructibleFromX86     constexpr ExplicitMoveConstructibleFromX(int i) : i_(i) {}
ExplicitMoveConstructibleFromXExplicitMoveConstructibleFromX87     constexpr explicit ExplicitMoveConstructibleFromX(X&& x) : i_(x.i_) {}
88 };
89 
90 struct CopyConstructibleFromX
91 {
92     int i_;
93 
94     constexpr const int &operator*() const { return i_; }
95     constexpr int &operator*() { return i_; }
getCopyConstructibleFromX96     constexpr const int *get() const { return &i_; }
getCopyConstructibleFromX97     constexpr int *get() { return &i_; }
98     constexpr const int *operator->() const { return &i_; }
99     constexpr int *operator->() { return &i_; }
100 
CopyConstructibleFromXCopyConstructibleFromX101     constexpr CopyConstructibleFromX(int i) : i_(i) {}
CopyConstructibleFromXCopyConstructibleFromX102     constexpr CopyConstructibleFromX(const X& x) : i_(x.i_) {}
103 };
104 
105 struct ExplicitCopyConstructibleFromX
106 {
107     int i_;
108 
109     constexpr const int &operator*() const { return i_; }
110     constexpr int &operator*() { return i_; }
getExplicitCopyConstructibleFromX111     constexpr const int *get() const { return &i_; }
getExplicitCopyConstructibleFromX112     constexpr int *get() { return &i_; }
113     constexpr const int *operator->() const { return &i_; }
114     constexpr int *operator->() { return &i_; }
115 
ExplicitCopyConstructibleFromXExplicitCopyConstructibleFromX116     constexpr ExplicitCopyConstructibleFromX(int i) : i_(i) {}
ExplicitCopyConstructibleFromXExplicitCopyConstructibleFromX117     constexpr explicit ExplicitCopyConstructibleFromX(const X& x) : i_(x.i_) {}
118 };
119 
120