Skip to content

Commit 58d6ac7

Browse files
authored
Merge branch 'main' into fsajdak-refactor-of-is
2 parents a9cce82 + d9656a0 commit 58d6ac7

File tree

9 files changed

+169
-177
lines changed

9 files changed

+169
-177
lines changed

include/cpp2util.h

+119-122
Original file line numberDiff line numberDiff line change
@@ -61,180 +61,177 @@
6161
// ... this should approximate "import std;" on those compilers
6262
#else
6363
#include <version>
64-
#include <concepts>
65-
#ifdef __cpp_lib_coroutine
66-
#include <coroutine>
67-
#endif
64+
#include <algorithm>
6865
#include <any>
66+
#include <array>
67+
#include <atomic>
68+
#ifdef __cpp_lib_barrier
69+
#include <barrier>
70+
#endif
71+
#include <bit>
6972
#include <bitset>
73+
#include <cassert>
74+
#include <cctype>
75+
#include <cerrno>
76+
#include <cfenv>
77+
#include <cfloat>
78+
#include <charconv>
7079
#include <chrono>
80+
#include <cinttypes>
81+
#include <climits>
82+
#include <clocale>
83+
#include <cmath>
84+
#include <codecvt>
85+
#include <condition_variable>
7186
#include <compare>
87+
#include <complex>
88+
#include <concepts>
89+
#ifdef __cpp_lib_coroutine
90+
#include <coroutine>
91+
#endif
7292
#include <csetjmp>
7393
#include <csignal>
7494
#include <cstdarg>
7595
#include <cstddef>
76-
#include <cstdlib>
77-
#include <ctime>
78-
#include <functional>
79-
#include <initializer_list>
80-
#include <optional>
81-
#ifdef __cpp_lib_source_location
82-
#include <source_location>
83-
#endif
84-
#include <tuple>
85-
#include <type_traits>
86-
#include <typeindex>
87-
#ifndef CPP2_NO_RTTI
88-
#include <typeinfo>
89-
#endif
90-
#include <utility>
91-
#include <variant>
92-
#include <memory>
93-
#ifdef __cpp_lib_memory_resource
94-
#include <memory_resource>
95-
#endif
96-
#include <new>
97-
#include <scoped_allocator>
98-
#include <cfloat>
99-
#include <cinttypes>
100-
#include <climits>
10196
#include <cstdint>
102-
#include <limits>
103-
#include <cassert>
104-
#include <cerrno>
105-
#ifndef CPP2_NO_EXCEPTIONS
106-
#include <exception>
107-
#endif
108-
#include <stdexcept>
109-
#include <system_error>
110-
#include <cctype>
111-
#include <charconv>
97+
#include <cstdio>
98+
#include <cstdlib>
11299
#include <cstring>
100+
#include <ctime>
113101
#if __has_include(<cuchar>)
114102
#include <cuchar>
115103
#endif
116104
#include <cwchar>
117105
#include <cwctype>
106+
#include <deque>
107+
#ifndef CPP2_NO_EXCEPTIONS
108+
#include <exception>
109+
#endif
110+
// libstdc++ currently has a dependency on linking TBB if <execution> is
111+
// included, and TBB seems to be not automatically installed and linkable
112+
// on some GCC installations, so let's not pull in that little-used header
113+
// in our -pure-cpp2 "import std;" simulation mode... if you need this,
114+
// use mixed mode (not -pure-cpp2) and #include all the headers you need
115+
// including this one
116+
//
117+
// #include <execution>
118+
#include <filesystem>
118119
#if defined(__cpp_lib_format) || (defined(_MSC_VER) && _MSC_VER >= 1929)
119120
#include <format>
120121
#endif
121-
#include <string>
122-
#include <string_view>
123-
#include <array>
124-
#include <deque>
125122
#include <forward_list>
126-
#include <list>
127-
#include <map>
128-
#include <queue>
129-
#include <set>
130-
#include <span>
131-
#include <stack>
132-
#include <unordered_map>
133-
#include <unordered_set>
134-
#include <vector>
135-
#include <iterator>
136-
#include <ranges>
137-
#include <algorithm>
138-
#include <bit>
139-
#include <cfenv>
140-
#include <cmath>
141-
#include <complex>
142-
#include <numbers>
143-
#include <numeric>
144-
#include <random>
145-
#include <ratio>
146-
#include <valarray>
147-
#include <clocale>
148-
#include <codecvt>
149-
#include <locale>
150-
#include <cstdio>
151123
#include <fstream>
124+
#include <functional>
125+
#include <future>
126+
#include <initializer_list>
152127
#include <iomanip>
153128
#include <ios>
154129
#include <iosfwd>
155130
#include <iostream>
131+
#include <iso646.h>
156132
#include <istream>
157-
#include <ostream>
158-
#ifdef __cpp_lib_spanstream
159-
#include <spanstream>
160-
#endif
161-
#include <sstream>
162-
#include <streambuf>
163-
#ifdef __cpp_lib_syncstream
164-
#include <syncstream>
165-
#endif
166-
#include <filesystem>
167-
#include <regex>
168-
#include <atomic>
169-
#ifdef __cpp_lib_barrier
170-
#include <barrier>
171-
#endif
172-
#include <condition_variable>
173-
#include <future>
133+
#include <iterator>
174134
#ifdef __cpp_lib_latch
175135
#include <latch>
176136
#endif
137+
#include <limits>
138+
#include <list>
139+
#include <locale>
140+
#include <map>
141+
#include <memory>
142+
#ifdef __cpp_lib_memory_resource
143+
#include <memory_resource>
144+
#endif
177145
#include <mutex>
146+
#include <new>
147+
#include <numbers>
148+
#include <numeric>
149+
#include <optional>
150+
#include <ostream>
151+
#include <queue>
152+
#include <random>
153+
#include <ranges>
154+
#include <ratio>
155+
#include <regex>
156+
#ifdef __cpp_lib_source_location
157+
#include <source_location>
158+
#endif
159+
#include <scoped_allocator>
178160
#ifdef __cpp_lib_semaphore
179161
#include <semaphore>
180162
#endif
163+
#include <set>
181164
#include <shared_mutex>
165+
#include <span>
166+
#ifdef __cpp_lib_spanstream
167+
#include <spanstream>
168+
#endif
169+
#include <sstream>
170+
#include <stack>
171+
#include <stdexcept>
182172
#ifdef __cpp_lib_jthread
183173
#include <stop_token>
184174
#endif
175+
#include <streambuf>
176+
#include <string>
177+
#include <string_view>
178+
#ifdef __cpp_lib_syncstream
179+
#include <syncstream>
180+
#endif
181+
#include <system_error>
185182
#include <thread>
186-
#include <iso646.h>
187-
188-
// libstdc++ currently has a dependency on linking TBB if <execution> is
189-
// included, and TBB seems to be not automatically installed and linkable
190-
// on some GCC installations, so let's not pull in that little-used header
191-
// in our -pure-cpp2 "import std;" simulation mode... if you need this,
192-
// use mixed mode (not -pure-cpp2) and #include all the headers you need
193-
// including this one
194-
//
195-
// #include <execution>
183+
#include <tuple>
184+
#include <type_traits>
185+
#include <typeindex>
186+
#ifndef CPP2_NO_RTTI
187+
#include <typeinfo>
188+
#endif
189+
#include <unordered_map>
190+
#include <unordered_set>
191+
#include <utility>
192+
#include <valarray>
193+
#include <variant>
194+
#include <vector>
196195
#endif
197196

198197
// Otherwise, we're not in -pure-cpp2 and so just #include
199198
// what we need in this header to make this self-contained
200199
#else
201-
#include <type_traits>
202-
#include <new>
203-
#include <memory>
204-
#include <random>
205-
#include <tuple>
206-
#include <string>
207-
#include <string_view>
208-
#include <vector>
209-
#include <span>
210-
#include <iostream>
211-
#include <variant>
212-
#include <any>
213-
#include <optional>
214-
#include <cstddef>
215-
#include <utility>
216-
#include <cstdio>
217-
#include <cstdint>
218200
#include <algorithm>
201+
#include <any>
219202
#include <compare>
220-
#include <iterator>
221203
#include <concepts>
222-
#include <system_error>
223-
#include <limits>
224-
#if defined(__cpp_lib_format) || (defined(_MSC_VER) && _MSC_VER >= 1929)
225-
#include <format>
226-
#endif
227-
204+
#include <cstddef>
205+
#include <cstdint>
206+
#include <cstdio>
228207
#ifndef CPP2_NO_EXCEPTIONS
229208
#include <exception>
230209
#endif
231-
#ifndef CPP2_NO_RTTI
232-
#include <typeinfo>
210+
#if defined(__cpp_lib_format) || (defined(_MSC_VER) && _MSC_VER >= 1929)
211+
#include <format>
233212
#endif
234-
213+
#include <iostream>
214+
#include <iterator>
215+
#include <limits>
216+
#include <memory>
217+
#include <new>
218+
#include <random>
219+
#include <optional>
235220
#if defined(CPP2_USE_SOURCE_LOCATION)
236221
#include <source_location>
237222
#endif
223+
#include <span>
224+
#include <string>
225+
#include <string_view>
226+
#include <system_error>
227+
#include <tuple>
228+
#include <type_traits>
229+
#ifndef CPP2_NO_RTTI
230+
#include <typeinfo>
231+
#endif
232+
#include <utility>
233+
#include <variant>
234+
#include <vector>
238235
#endif
239236

240237

regression-tests/test-results/pure2-enum.cpp

+6-15
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class file_attributes;
2424

2525
#line 2 "pure2-enum.cpp2"
2626
class skat_game {
27-
public: static const cpp2::i8 enumeration_count;
2827
private: cpp2::i8 value__; private: constexpr skat_game(auto const& val);
2928

3029
private: constexpr auto operator=(auto const& val) -> skat_game& ;
@@ -56,8 +55,7 @@ class duality {
5655
#line 15 "pure2-enum.cpp2"
5756
public: auto flip(cpp2::in<duality> val) & -> void;
5857

59-
public: static const cpp2::i8 enumeration_count;
60-
private: cpp2::i8 value__; private: constexpr duality(auto const& val);
58+
private: cpp2::i8 value__; private: constexpr duality(auto const& val);
6159

6260
private: constexpr auto operator=(auto const& val) -> duality& ;
6361
public: [[nodiscard]] constexpr auto get_raw_value() const& -> cpp2::i8;
@@ -75,7 +73,6 @@ public: friend auto operator<<(std::ostream& o, cpp2::in<duality> val) -> std::o
7573
};
7674

7775
class file_attributes {
78-
public: static const cpp2::u8 enumeration_count;
7976
private: cpp2::u8 value__; private: constexpr file_attributes(auto const& val);
8077

8178
private: constexpr auto operator=(auto const& val) -> file_attributes& ;
@@ -117,9 +114,7 @@ auto main() -> int;
117114

118115

119116

120-
inline constexpr cpp2::i8 skat_game::enumeration_count = 6;
121-
122-
constexpr skat_game::skat_game(auto const& val)
117+
constexpr skat_game::skat_game(auto const& val)
123118
: value__{ cpp2::unsafe_narrow<cpp2::i8>(val) } { }
124119
constexpr auto skat_game::operator=(auto const& val) -> skat_game& {
125120
value__ = cpp2::unsafe_narrow<cpp2::i8>(val);
@@ -157,7 +152,7 @@ inline constexpr skat_game skat_game::null = 23;
157152
return "invalid skat_game value";
158153
}
159154

160-
[[nodiscard]] auto operator<<(std::ostream& o, cpp2::in<skat_game> val) -> std::ostream&{o << CPP2_UFCS_0(to_string, val);return o; }
155+
auto operator<<(std::ostream& o, cpp2::in<skat_game> val) -> std::ostream&{o << CPP2_UFCS_0(to_string, val);return o; }
161156
#line 15 "pure2-enum.cpp2"
162157
auto duality::flip(cpp2::in<duality> val) & -> void{
163158
if (val == first) {
@@ -169,10 +164,8 @@ inline constexpr skat_game skat_game::null = 23;
169164
}
170165
}
171166

172-
inline constexpr cpp2::i8 duality::enumeration_count = 2;
173-
174167

175-
constexpr duality::duality(auto const& val)
168+
constexpr duality::duality(auto const& val)
176169
: value__{ cpp2::unsafe_narrow<cpp2::i8>(val) } { }
177170

178171
constexpr auto duality::operator=(auto const& val) -> duality& {
@@ -199,9 +192,7 @@ inline constexpr duality duality::second = 1;
199192
return "invalid duality value";
200193
}
201194

202-
[[nodiscard]] auto operator<<(std::ostream& o, cpp2::in<duality> val) -> std::ostream&{o << CPP2_UFCS_0(to_string, val);return o; }
203-
inline constexpr cpp2::u8 file_attributes::enumeration_count = 4;
204-
195+
auto operator<<(std::ostream& o, cpp2::in<duality> val) -> std::ostream&{o << CPP2_UFCS_0(to_string, val);return o; }
205196
constexpr file_attributes::file_attributes(auto const& val)
206197
: value__{ cpp2::unsafe_narrow<cpp2::u8>(val) } { }
207198
constexpr auto file_attributes::operator=(auto const& val) -> file_attributes& {
@@ -250,7 +241,7 @@ inline constexpr file_attributes file_attributes::none = 0;
250241
return ret + ")";
251242
}
252243

253-
[[nodiscard]] auto operator<<(std::ostream& o, cpp2::in<file_attributes> val) -> std::ostream&{o << CPP2_UFCS_0(to_string, val);return o; }
244+
auto operator<<(std::ostream& o, cpp2::in<file_attributes> val) -> std::ostream&{o << CPP2_UFCS_0(to_string, val);return o; }
254245
#line 33 "pure2-enum.cpp2"
255246
auto main() -> int{
256247
auto janus {duality::second};

0 commit comments

Comments
 (0)