Skip to content

Extend std C++ include header list (fix #692) #693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 102 additions & 13 deletions include/cpp2util.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@
#include <clocale>
#include <cmath>
#include <codecvt>
#include <condition_variable>
#include <compare>
#include <complex>
#include <concepts>
#include <condition_variable>
#ifdef __cpp_lib_coroutine
#include <coroutine>
#endif
Expand Down Expand Up @@ -113,7 +113,7 @@
// 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>
#ifdef __cpp_lib_expected
#include <expected>
Expand Down Expand Up @@ -169,15 +169,15 @@
#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>
#ifdef __cpp_lib_source_location
#include <source_location>
#endif
#include <span>
#ifdef __cpp_lib_spanstream
#include <spanstream>
Expand Down Expand Up @@ -220,39 +220,128 @@
// Otherwise, we're not in -pure-cpp2 and so just #include
// what we need in this header to make this self-contained
Comment on lines 220 to 221
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this comment isn't true anymore.

#else
#include <version> // has the _cpp_* preprocessor defs, include first
#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 <compare>
#include <complex>
#include <concepts>
#include <condition_variable>
#ifdef __cpp_lib_coroutine
#include <coroutine>
#endif
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#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
#include <filesystem>
#if defined(__cpp_lib_format) || (defined(_MSC_VER) && _MSC_VER >= 1929)
#include <format>
#endif
#include <forward_list>
#include <fstream>
#include <functional>
#include <future>
#include <initializer_list>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <iso646.h>
#include <istream>
#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 <random>
#include <numbers>
#include <numeric>
#include <optional>
#include <ostream>
#include <queue>
#include <random>
#include <ranges>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#ifdef __cpp_lib_semaphore
#include <semaphore>
#endif
#include <set>
#include <shared_mutex>
#if defined(CPP2_USE_SOURCE_LOCATION)
#include <source_location>
#endif
#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 <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
Expand Down Expand Up @@ -514,7 +603,7 @@ template<typename T>
auto Typeid() -> decltype(auto) {
#ifdef CPP2_NO_RTTI
Type.expects(
!"'any' dynamic casting is disabled with -fno-rtti", // more likely to appear on console
!"'any' dynamic casting is disabled with -fno-rtti", // more likely to appear on console
"'any' dynamic casting is disabled with -fno-rtti" // make message available to hooked handlers
);
#else
Expand Down Expand Up @@ -860,7 +949,7 @@ inline auto to_string(std::string const& s) -> std::string const&

template<typename T>
inline auto to_string(T const& sv) -> std::string
requires (std::is_convertible_v<T, std::string_view>
requires (std::is_convertible_v<T, std::string_view>
&& !std::is_convertible_v<T, const char*>)
{
return std::string{sv};
Expand Down Expand Up @@ -1000,17 +1089,17 @@ auto is( X const& ) -> bool {

template< typename C, typename X >
requires (
( std::is_base_of_v<X, C> ||
( std::is_polymorphic_v<C> && std::is_polymorphic_v<X>)
( std::is_base_of_v<X, C> ||
( std::is_polymorphic_v<C> && std::is_polymorphic_v<X>)
) && !std::is_same_v<C,X>)
auto is( X const& x ) -> bool {
return Dynamic_cast<C const*>(&x) != nullptr;
}

template< typename C, typename X >
requires (
( std::is_base_of_v<X, C> ||
( std::is_polymorphic_v<C> && std::is_polymorphic_v<X>)
( std::is_base_of_v<X, C> ||
( std::is_polymorphic_v<C> && std::is_polymorphic_v<X>)
) && !std::is_same_v<C,X>)
auto is( X const* x ) -> bool {
return Dynamic_cast<C const*>(x) != nullptr;
Expand Down Expand Up @@ -1641,7 +1730,7 @@ constexpr auto unsafe_narrow( X&& x ) noexcept -> decltype(auto)
// Returns a function object that takes a 'value' of the same type as
// 'flags', and evaluates to true if and only if 'value' has set all of
// the bits set in 'flags'
//
//
//-----------------------------------------------------------------------
//
template <typename T>
Expand Down