@@ -12,10 +12,10 @@ class skat_game;
12
12
13
13
14
14
#line 11 "pure2-enum.cpp2"
15
- class rgb ;
15
+ class duality ;
16
16
17
17
18
- #line 17 "pure2-enum.cpp2"
18
+ #line 26 "pure2-enum.cpp2"
19
19
class file_attributes ;
20
20
21
21
@@ -51,28 +51,27 @@ public: friend auto operator<<(std::ostream& o, cpp2::in<skat_game> val) -> std:
51
51
#line 9 "pure2-enum.cpp2"
52
52
};
53
53
54
- class rgb {
55
- public: static const cpp2::i8 enumeration_count;
56
- private: cpp2::i8 value__; private: constexpr rgb (auto const & val);
54
+ class duality {
55
+
56
+ #line 15 "pure2-enum.cpp2"
57
+ public: auto flip (cpp2::in<duality> val) & -> void;
58
+
59
+ public: static const cpp2::i8 enumeration_count;
60
+ private: cpp2::i8 value__; private: constexpr duality (auto const & val);
57
61
58
- private: constexpr auto operator =(auto const & val) -> rgb & ;
62
+ private: constexpr auto operator =(auto const & val) -> duality & ;
59
63
public: [[nodiscard]] constexpr auto get_raw_value () const & -> cpp2::i8;
60
- public: constexpr rgb (rgb const & that);
61
- public: constexpr auto operator =(rgb const & that) -> rgb& ;
62
- public: constexpr rgb (rgb&& that) noexcept ;
63
- public: constexpr auto operator =(rgb&& that) noexcept -> rgb& ;
64
- public: [[nodiscard]] auto operator <=>(rgb const & that) const & -> std::strong_ordering = default ;
65
- public: static const rgb red;
66
- public: static const rgb green;
67
- public: static const rgb blue;
64
+ public: constexpr duality (duality const & that);
65
+ public: constexpr auto operator =(duality const & that) -> duality& ;
66
+ public: constexpr duality (duality&& that) noexcept ;
67
+ public: constexpr auto operator =(duality&& that) noexcept -> duality& ;
68
+ public: [[nodiscard]] auto operator <=>(duality const & that) const & -> std::strong_ordering = default ;
69
+ public: static const duality first;
70
+ public: static const duality second;
68
71
public: [[nodiscard]] auto to_string () const & -> std::string;
69
- public: friend auto operator <<(std::ostream& o, cpp2::in<rgb > val) -> std::ostream&;
72
+ public: friend auto operator <<(std::ostream& o, cpp2::in<duality > val) -> std::ostream&;
70
73
71
- #line 12 "pure2-enum.cpp2"
72
- // 0
73
- // 1
74
- // 2
75
- #line 15 "pure2-enum.cpp2"
74
+ #line 24 "pure2-enum.cpp2"
76
75
};
77
76
78
77
class file_attributes {
@@ -103,12 +102,12 @@ public: static const file_attributes none;
103
102
public: [[nodiscard]] auto to_string () const & -> std::string;
104
103
public: friend auto operator <<(std::ostream& o, cpp2::in<file_attributes> val) -> std::ostream&;
105
104
106
- #line 18 "pure2-enum.cpp2"
105
+ #line 27 "pure2-enum.cpp2"
107
106
// 1
108
107
// 2
109
108
// 4
110
109
111
- #line 22 "pure2-enum.cpp2"
110
+ #line 31 "pure2-enum.cpp2"
112
111
};
113
112
114
113
auto main () -> int;
@@ -159,38 +158,48 @@ inline constexpr skat_game skat_game::null = 23;
159
158
}
160
159
161
160
[[nodiscard]] auto operator <<(std::ostream& o, cpp2::in<skat_game> val) -> std::ostream&{o << CPP2_UFCS_0 (to_string, val);return o; }
162
- inline constexpr cpp2::i8 rgb::enumeration_count = 3 ;
161
+ #line 15 "pure2-enum.cpp2"
162
+ auto duality::flip (cpp2::in<duality> val) & -> void{
163
+ if (val == first) {
164
+ value__ = second.value__ ;
165
+ }
166
+ else {
167
+ cpp2::Default.expects (value__ == second.value__ , " " );
168
+ value__ = first.value__ ;
169
+ }
170
+ }
163
171
164
- constexpr rgb::rgb (auto const & val)
172
+ inline constexpr cpp2::i8 duality::enumeration_count = 2 ;
173
+
174
+
175
+ constexpr duality::duality (auto const & val)
165
176
: value__{ cpp2::unsafe_narrow<cpp2::i8 >(val) } { }
166
- constexpr auto rgb::operator =(auto const & val) -> rgb& {
177
+
178
+ constexpr auto duality::operator =(auto const & val) -> duality& {
167
179
value__ = cpp2::unsafe_narrow<cpp2::i8 >(val);
168
180
return *this ; }
169
- [[nodiscard]] constexpr auto rgb ::get_raw_value () const & -> cpp2::i8 { return value__; }
170
- constexpr rgb::rgb (rgb const & that)
181
+ [[nodiscard]] constexpr auto duality ::get_raw_value () const & -> cpp2::i8 { return value__; }
182
+ constexpr duality::duality (duality const & that)
171
183
: value__{ that.value__ }{}
172
- constexpr auto rgb ::operator =(rgb const & that) -> rgb & {
184
+ constexpr auto duality ::operator =(duality const & that) -> duality & {
173
185
value__ = that.value__ ;
174
186
return *this ;}
175
- constexpr rgb::rgb (rgb && that) noexcept
187
+ constexpr duality::duality (duality && that) noexcept
176
188
: value__{ std::move (that).value__ }{}
177
- constexpr auto rgb ::operator =(rgb && that) noexcept -> rgb & {
189
+ constexpr auto duality ::operator =(duality && that) noexcept -> duality & {
178
190
value__ = std::move (that).value__ ;
179
191
return *this ;}
180
- inline constexpr rgb rgb::red = 0 ;
192
+ inline constexpr duality duality::first = 0 ;
181
193
182
- inline constexpr rgb rgb::green = 1 ;
194
+ inline constexpr duality duality::second = 1 ;
183
195
184
- inline constexpr rgb rgb::blue = 2 ;
185
-
186
- [[nodiscard]] auto rgb::to_string () const & -> std::string{
187
- if ((*this ) == red) {return " red" ; }
188
- if ((*this ) == green) {return " green" ; }
189
- if ((*this ) == blue) {return " blue" ; }
190
- return " invalid rgb value" ;
196
+ [[nodiscard]] auto duality::to_string () const & -> std::string{
197
+ if ((*this ) == first) {return " first" ; }
198
+ if ((*this ) == second) {return " second" ; }
199
+ return " invalid duality value" ;
191
200
}
192
201
193
- [[nodiscard]] auto operator <<(std::ostream& o, cpp2::in<rgb > val) -> std::ostream&{o << CPP2_UFCS_0 (to_string, val);return o; }
202
+ [[nodiscard]] auto operator <<(std::ostream& o, cpp2::in<duality > val) -> std::ostream&{o << CPP2_UFCS_0 (to_string, val);return o; }
194
203
inline constexpr cpp2::u8 file_attributes::enumeration_count = 4 ;
195
204
196
205
constexpr file_attributes::file_attributes (auto const & val)
@@ -242,8 +251,13 @@ inline constexpr file_attributes file_attributes::none = 0;
242
251
}
243
252
244
253
[[nodiscard]] auto operator <<(std::ostream& o, cpp2::in<file_attributes> val) -> std::ostream&{o << CPP2_UFCS_0 (to_string, val);return o; }
245
- #line 24 "pure2-enum.cpp2"
254
+ #line 33 "pure2-enum.cpp2"
246
255
auto main () -> int{
256
+ auto janus {duality::second};
257
+ std::cout << " janus is initially " + cpp2::to_string (CPP2_UFCS_0 (to_string, janus)) + " \n " ;
258
+ CPP2_UFCS (flip, janus, janus);
259
+ std::cout << " janus is flipped to " + cpp2::to_string (CPP2_UFCS_0 (to_string, std::move (janus))) + " \n " ;
260
+
247
261
// x : skat_game = 9; // error, can't construct skat_game from integer
248
262
249
263
skat_game x {skat_game::clubs};
0 commit comments