Skip to content

Commit

Permalink
Sort standard headers, see #692 and #693
Browse files Browse the repository at this point in the history
And misc. cleanup
  • Loading branch information
hsutter committed Sep 25, 2023
1 parent 533b62d commit d9656a0
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 174 deletions.
241 changes: 119 additions & 122 deletions include/cpp2util.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,180 +61,177 @@
// ... this should approximate "import std;" on those compilers
#else
#include <version>
#include <concepts>
#ifdef __cpp_lib_coroutine
#include <coroutine>
#endif
#include <algorithm>
#include <any>
#include <array>
#include <atomic>
#ifdef __cpp_lib_barrier
#include <barrier>
#endif
#include <bit>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfenv>
#include <cfloat>
#include <charconv>
#include <chrono>
#include <cinttypes>
#include <climits>
#include <clocale>
#include <cmath>
#include <codecvt>
#include <condition_variable>
#include <compare>
#include <complex>
#include <concepts>
#ifdef __cpp_lib_coroutine
#include <coroutine>
#endif
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <initializer_list>
#include <optional>
#ifdef __cpp_lib_source_location
#include <source_location>
#endif
#include <tuple>
#include <type_traits>
#include <typeindex>
#ifndef CPP2_NO_RTTI
#include <typeinfo>
#endif
#include <utility>
#include <variant>
#include <memory>
#ifdef __cpp_lib_memory_resource
#include <memory_resource>
#endif
#include <new>
#include <scoped_allocator>
#include <cfloat>
#include <cinttypes>
#include <climits>
#include <cstdint>
#include <limits>
#include <cassert>
#include <cerrno>
#ifndef CPP2_NO_EXCEPTIONS
#include <exception>
#endif
#include <stdexcept>
#include <system_error>
#include <cctype>
#include <charconv>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __has_include(<cuchar>)
#include <cuchar>
#endif
#include <cwchar>
#include <cwctype>
#include <deque>
#ifndef CPP2_NO_EXCEPTIONS
#include <exception>
#endif
// libstdc++ currently has a dependency on linking TBB if <execution> is
// included, and TBB seems to be not automatically installed and linkable
// on some GCC installations, so let's not pull in that little-used header
// in our -pure-cpp2 "import std;" simulation mode... if you need this,
// use mixed mode (not -pure-cpp2) and #include all the headers you need
// including this one
//
// #include <execution>
#include <filesystem>
#if defined(__cpp_lib_format) || (defined(_MSC_VER) && _MSC_VER >= 1929)
#include <format>
#endif
#include <string>
#include <string_view>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <span>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <iterator>
#include <ranges>
#include <algorithm>
#include <bit>
#include <cfenv>
#include <cmath>
#include <complex>
#include <numbers>
#include <numeric>
#include <random>
#include <ratio>
#include <valarray>
#include <clocale>
#include <codecvt>
#include <locale>
#include <cstdio>
#include <fstream>
#include <functional>
#include <future>
#include <initializer_list>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <iso646.h>
#include <istream>
#include <ostream>
#ifdef __cpp_lib_spanstream
#include <spanstream>
#endif
#include <sstream>
#include <streambuf>
#ifdef __cpp_lib_syncstream
#include <syncstream>
#endif
#include <filesystem>
#include <regex>
#include <atomic>
#ifdef __cpp_lib_barrier
#include <barrier>
#endif
#include <condition_variable>
#include <future>
#include <iterator>
#ifdef __cpp_lib_latch
#include <latch>
#endif
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#ifdef __cpp_lib_memory_resource
#include <memory_resource>
#endif
#include <mutex>
#include <new>
#include <numbers>
#include <numeric>
#include <optional>
#include <ostream>
#include <queue>
#include <random>
#include <ranges>
#include <ratio>
#include <regex>
#ifdef __cpp_lib_source_location
#include <source_location>
#endif
#include <scoped_allocator>
#ifdef __cpp_lib_semaphore
#include <semaphore>
#endif
#include <set>
#include <shared_mutex>
#include <span>
#ifdef __cpp_lib_spanstream
#include <spanstream>
#endif
#include <sstream>
#include <stack>
#include <stdexcept>
#ifdef __cpp_lib_jthread
#include <stop_token>
#endif
#include <streambuf>
#include <string>
#include <string_view>
#ifdef __cpp_lib_syncstream
#include <syncstream>
#endif
#include <system_error>
#include <thread>
#include <iso646.h>

// libstdc++ currently has a dependency on linking TBB if <execution> is
// included, and TBB seems to be not automatically installed and linkable
// on some GCC installations, so let's not pull in that little-used header
// in our -pure-cpp2 "import std;" simulation mode... if you need this,
// use mixed mode (not -pure-cpp2) and #include all the headers you need
// including this one
//
// #include <execution>
#include <tuple>
#include <type_traits>
#include <typeindex>
#ifndef CPP2_NO_RTTI
#include <typeinfo>
#endif
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <variant>
#include <vector>
#endif

// Otherwise, we're not in -pure-cpp2 and so just #include
// what we need in this header to make this self-contained
#else
#include <type_traits>
#include <new>
#include <memory>
#include <random>
#include <tuple>
#include <string>
#include <string_view>
#include <vector>
#include <span>
#include <iostream>
#include <variant>
#include <any>
#include <optional>
#include <cstddef>
#include <utility>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <any>
#include <compare>
#include <iterator>
#include <concepts>
#include <system_error>
#include <limits>
#if defined(__cpp_lib_format) || (defined(_MSC_VER) && _MSC_VER >= 1929)
#include <format>
#endif

#include <cstddef>
#include <cstdint>
#include <cstdio>
#ifndef CPP2_NO_EXCEPTIONS
#include <exception>
#endif
#ifndef CPP2_NO_RTTI
#include <typeinfo>
#if defined(__cpp_lib_format) || (defined(_MSC_VER) && _MSC_VER >= 1929)
#include <format>
#endif

#include <iostream>
#include <iterator>
#include <limits>
#include <memory>
#include <new>
#include <random>
#include <optional>
#if defined(CPP2_USE_SOURCE_LOCATION)
#include <source_location>
#endif
#include <span>
#include <string>
#include <string_view>
#include <system_error>
#include <tuple>
#include <type_traits>
#ifndef CPP2_NO_RTTI
#include <typeinfo>
#endif
#include <utility>
#include <variant>
#include <vector>
#endif


Expand Down
15 changes: 3 additions & 12 deletions regression-tests/test-results/pure2-enum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class file_attributes;

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

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

public: static const cpp2::i8 enumeration_count;
private: cpp2::i8 value__; private: constexpr duality(auto const& val);
private: cpp2::i8 value__; private: constexpr duality(auto const& val);

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

class file_attributes {
public: static const cpp2::u8 enumeration_count;
private: cpp2::u8 value__; private: constexpr file_attributes(auto const& val);

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



inline constexpr cpp2::i8 skat_game::enumeration_count = 6;

constexpr skat_game::skat_game(auto const& val)
constexpr skat_game::skat_game(auto const& val)
: value__{ cpp2::unsafe_narrow<cpp2::i8>(val) } { }
constexpr auto skat_game::operator=(auto const& val) -> skat_game& {
value__ = cpp2::unsafe_narrow<cpp2::i8>(val);
Expand Down Expand Up @@ -169,10 +164,8 @@ inline constexpr skat_game skat_game::null = 23;
}
}

inline constexpr cpp2::i8 duality::enumeration_count = 2;


constexpr duality::duality(auto const& val)
constexpr duality::duality(auto const& val)
: value__{ cpp2::unsafe_narrow<cpp2::i8>(val) } { }

constexpr auto duality::operator=(auto const& val) -> duality& {
Expand Down Expand Up @@ -200,8 +193,6 @@ inline constexpr duality duality::second = 1;
}

auto operator<<(std::ostream& o, cpp2::in<duality> val) -> std::ostream&{o << CPP2_UFCS_0(to_string, val);return o; }
inline constexpr cpp2::u8 file_attributes::enumeration_count = 4;

constexpr file_attributes::file_attributes(auto const& val)
: value__{ cpp2::unsafe_narrow<cpp2::u8>(val) } { }
constexpr auto file_attributes::operator=(auto const& val) -> file_attributes& {
Expand Down
10 changes: 5 additions & 5 deletions regression-tests/test-results/pure2-print.cpp2.output
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pure2-print.cpp2...

outer: type =
{
object_alias: <T: type > T requires (true) == 42;
object_alias: <T: type> T requires (true) == 42;
mytype: final type =
{
protected f:() -> move int = 42;
Expand Down Expand Up @@ -78,7 +78,7 @@ outer: type =
return :() -> move std::string = (s + m[0])$;();
}

values: <T: type >(
values: <T: type>(
in this,
in t: T
) throws -> (
Expand Down Expand Up @@ -127,20 +127,20 @@ outer: type =
is _ = "default case";
} << "\n";
}
x: <Ts...: type > type =
x: <Ts...: type> type =
{
tup: std::tuple<Ts...> = ();
}

print: <Args...: type >(
print: <Args...: type>(
inout out: std::ostream,
in args...: Args
) requires (sizeof...(Args) >= 0) =
{
(out << ... << args);
}

all: <Args...: type >(in args...: Args) -> move bool = (... && args);
all: <Args...: type>(in args...: Args) -> move bool = (... && args);
}
ok (all Cpp2, passes safety checks)

Loading

0 comments on commit d9656a0

Please sign in to comment.