From d7127f0bf463fca0fdd277b15e1bf519295379f2 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Tue, 17 Sep 2024 17:35:33 +0200 Subject: [PATCH] [libc++][C++03] Use `__cxx03/` headers in C++03 mode --- .github/workflows/libcxx-build-and-test.yaml | 1 + libcxx/cmake/caches/cxx03-headers.cmake | 2 + libcxx/include/__config | 6 +- libcxx/include/__configuration/cxx03.h | 21 + libcxx/include/__cxx03/__config | 5 - libcxx/include/__flat_map/sorted_unique.h | 9 +- libcxx/include/algorithm | 361 +++++------- libcxx/include/any | 138 ++--- libcxx/include/array | 130 +++-- libcxx/include/atomic | 80 +-- libcxx/include/barrier | 74 +-- libcxx/include/bit | 78 +-- libcxx/include/bitset | 114 ++-- libcxx/include/cassert | 24 +- libcxx/include/ccomplex | 6 + libcxx/include/cctype | 104 ++-- libcxx/include/cerrno | 21 +- libcxx/include/cfenv | 20 +- libcxx/include/cfloat | 20 +- libcxx/include/charconv | 88 +-- libcxx/include/chrono | 149 ++--- libcxx/include/cinttypes | 22 +- libcxx/include/ciso646 | 14 +- libcxx/include/climits | 16 +- libcxx/include/clocale | 22 +- libcxx/include/cmath | 64 ++- libcxx/include/codecvt | 69 ++- libcxx/include/compare | 74 +-- libcxx/include/complex | 90 +-- libcxx/include/complex.h | 28 +- libcxx/include/concepts | 86 +-- libcxx/include/condition_variable | 92 +-- libcxx/include/coroutine | 40 +- libcxx/include/csetjmp | 24 +- libcxx/include/csignal | 24 +- libcxx/include/cstdarg | 24 +- libcxx/include/cstdbool | 18 +- libcxx/include/cstddef | 32 +- libcxx/include/cstdint | 24 +- libcxx/include/cstdio | 26 +- libcxx/include/cstdlib | 34 +- libcxx/include/cstring | 24 +- libcxx/include/ctgmath | 18 +- libcxx/include/ctime | 34 +- libcxx/include/ctype.h | 62 +- libcxx/include/cuchar | 30 +- libcxx/include/cwchar | 60 +- libcxx/include/cwctype | 26 +- libcxx/include/deque | 350 +++++------ libcxx/include/errno.h | 542 ++++++++--------- libcxx/include/exception | 38 +- libcxx/include/execution | 42 +- libcxx/include/expected | 46 +- libcxx/include/fenv.h | 90 +-- libcxx/include/filesystem | 78 +-- libcxx/include/float.h | 36 +- libcxx/include/format | 134 ++--- libcxx/include/forward_list | 286 ++++----- libcxx/include/fstream | 278 ++++----- libcxx/include/functional | 133 ++--- libcxx/include/future | 222 +++---- libcxx/include/initializer_list | 20 +- libcxx/include/inttypes.h | 36 +- libcxx/include/iomanip | 62 +- libcxx/include/ios | 126 ++-- libcxx/include/iosfwd | 56 +- libcxx/include/iostream | 28 +- libcxx/include/istream | 258 +++++---- libcxx/include/iterator | 140 ++--- libcxx/include/latch | 44 +- libcxx/include/limits | 60 +- libcxx/include/list | 332 +++++------ libcxx/include/locale | 326 +++++------ libcxx/include/map | 298 +++++----- libcxx/include/math.h | 170 +++--- libcxx/include/mdspan | 58 +- libcxx/include/memory | 110 ++-- libcxx/include/memory_resource | 64 ++- libcxx/include/mutex | 98 ++-- libcxx/include/new | 180 +++--- libcxx/include/numbers | 30 +- libcxx/include/numeric | 100 ++-- libcxx/include/optional | 198 +++---- libcxx/include/ostream | 54 +- libcxx/include/print | 132 +++-- libcxx/include/queue | 184 +++--- libcxx/include/random | 120 ++-- libcxx/include/ranges | 146 ++--- libcxx/include/ratio | 58 +- libcxx/include/regex | 314 +++++----- libcxx/include/scoped_allocator | 90 +-- libcxx/include/semaphore | 60 +- libcxx/include/set | 314 +++++----- libcxx/include/shared_mutex | 62 +- libcxx/include/source_location | 22 +- libcxx/include/span | 172 +++--- libcxx/include/sstream | 198 +++---- libcxx/include/stack | 104 ++-- libcxx/include/stdatomic.h | 44 +- libcxx/include/stdbool.h | 40 +- libcxx/include/stddef.h | 24 +- libcxx/include/stdexcept | 122 ++-- libcxx/include/stdint.h | 131 +++++ libcxx/include/stdio.h | 38 +- libcxx/include/stdlib.h | 72 +-- libcxx/include/stop_token | 36 +- libcxx/include/streambuf | 54 +- libcxx/include/string | 544 +++++++++--------- libcxx/include/string.h | 31 +- libcxx/include/string_view | 188 +++--- libcxx/include/strstream | 54 +- libcxx/include/syncstream | 94 +-- libcxx/include/system_error | 44 +- libcxx/include/tgmath.h | 36 +- libcxx/include/thread | 68 ++- libcxx/include/tuple | 212 +++---- libcxx/include/type_traits | 208 ++++--- libcxx/include/typeindex | 40 +- libcxx/include/typeinfo | 116 ++-- libcxx/include/uchar.h | 32 +- libcxx/include/unordered_map | 360 ++++++------ libcxx/include/unordered_set | 296 +++++----- libcxx/include/utility | 106 ++-- libcxx/include/valarray | 212 +++---- libcxx/include/variant | 408 ++++++------- libcxx/include/vector | 102 ++-- libcxx/include/wchar.h | 62 +- libcxx/include/wctype.h | 68 ++- libcxx/utils/ci/run-buildbot | 6 + .../generate_feature_test_macro_components.py | 6 + libcxx/utils/libcxx/test/params.py | 7 + 131 files changed, 7141 insertions(+), 6347 deletions(-) create mode 100644 libcxx/cmake/caches/cxx03-headers.cmake create mode 100644 libcxx/include/__configuration/cxx03.h create mode 100644 libcxx/include/stdint.h diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml index 184fed2268e8180..cd530c723b26c80 100644 --- a/.github/workflows/libcxx-build-and-test.yaml +++ b/.github/workflows/libcxx-build-and-test.yaml @@ -55,6 +55,7 @@ jobs: fail-fast: false matrix: config: [ + 'cxx03-main-headers', 'generic-cxx03', 'generic-cxx26', 'generic-modules' diff --git a/libcxx/cmake/caches/cxx03-headers.cmake b/libcxx/cmake/caches/cxx03-headers.cmake new file mode 100644 index 000000000000000..76a52246a8812f1 --- /dev/null +++ b/libcxx/cmake/caches/cxx03-headers.cmake @@ -0,0 +1,2 @@ +set(LIBCXX_TEST_PARAMS "std=c++03;test-cxx03-headers=True" CACHE STRING "") +set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "") diff --git a/libcxx/include/__config b/libcxx/include/__config index 1cf80a46686ab91..e9e95ba3598e356 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -14,6 +14,7 @@ #include <__configuration/abi.h> #include <__configuration/availability.h> #include <__configuration/compiler.h> +#include <__configuration/cxx03.h> #include <__configuration/platform.h> #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER @@ -151,11 +152,6 @@ _LIBCPP_HARDENING_MODE_DEBUG # define _LIBCPP_TOSTRING2(x) #x # define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) -// NOLINTNEXTLINE(libcpp-cpp-version-check) -# if __cplusplus < 201103L -# define _LIBCPP_CXX03_LANG -# endif - # ifndef __has_constexpr_builtin # define __has_constexpr_builtin(x) 0 # endif diff --git a/libcxx/include/__configuration/cxx03.h b/libcxx/include/__configuration/cxx03.h new file mode 100644 index 000000000000000..606de3d2c735f00 --- /dev/null +++ b/libcxx/include/__configuration/cxx03.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CONFIGURATION_CXX03_H +#define _LIBCPP___CONFIGURATION_CXX03_H + +#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER +# pragma GCC system_header +#endif + +// NOLINTNEXTLINE(libcpp-cpp-version-check) +# if __cplusplus < 201103L +# define _LIBCPP_CXX03_LANG +# endif + +#endif // _LIBCPP___CONFIGURATION_CXX03_H diff --git a/libcxx/include/__cxx03/__config b/libcxx/include/__cxx03/__config index 935fa4cc404f4ee..965ac4f1e6ffffb 100644 --- a/libcxx/include/__cxx03/__config +++ b/libcxx/include/__cxx03/__config @@ -157,11 +157,6 @@ _LIBCPP_HARDENING_MODE_DEBUG # define _LIBCPP_TOSTRING2(x) #x # define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) -// NOLINTNEXTLINE(libcpp-cpp-version-check) -# if __cplusplus < 201103L -# define _LIBCPP_CXX03_LANG -# endif - # ifndef __has_constexpr_builtin # define __has_constexpr_builtin(x) 0 # endif diff --git a/libcxx/include/__flat_map/sorted_unique.h b/libcxx/include/__flat_map/sorted_unique.h index 0189a5ff1d56843..cf39208d18b1ed9 100644 --- a/libcxx/include/__flat_map/sorted_unique.h +++ b/libcxx/include/__flat_map/sorted_unique.h @@ -9,11 +9,12 @@ #ifndef _LIBCPP___FLAT_MAP_SORTED_UNIQUE_H #define _LIBCPP___FLAT_MAP_SORTED_UNIQUE_H -#include <__config> +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/locale.h> +#else +# include <__config> #if _LIBCPP_STD_VER >= 23 diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm index 14355d63f2901ca..592c317cf288098 100644 --- a/libcxx/include/algorithm +++ b/libcxx/include/algorithm @@ -1827,232 +1827,147 @@ template */ -#include <__config> - -#include <__algorithm/adjacent_find.h> -#include <__algorithm/all_of.h> -#include <__algorithm/any_of.h> -#include <__algorithm/binary_search.h> -#include <__algorithm/copy.h> -#include <__algorithm/copy_backward.h> -#include <__algorithm/copy_if.h> -#include <__algorithm/copy_n.h> -#include <__algorithm/count.h> -#include <__algorithm/count_if.h> -#include <__algorithm/equal.h> -#include <__algorithm/equal_range.h> -#include <__algorithm/fill.h> -#include <__algorithm/fill_n.h> -#include <__algorithm/find.h> -#include <__algorithm/find_end.h> -#include <__algorithm/find_first_of.h> -#include <__algorithm/find_if.h> -#include <__algorithm/find_if_not.h> -#include <__algorithm/for_each.h> -#include <__algorithm/generate.h> -#include <__algorithm/generate_n.h> -#include <__algorithm/includes.h> -#include <__algorithm/inplace_merge.h> -#include <__algorithm/is_heap.h> -#include <__algorithm/is_heap_until.h> -#include <__algorithm/is_partitioned.h> -#include <__algorithm/is_permutation.h> -#include <__algorithm/is_sorted.h> -#include <__algorithm/is_sorted_until.h> -#include <__algorithm/iter_swap.h> -#include <__algorithm/lexicographical_compare.h> -#include <__algorithm/lower_bound.h> -#include <__algorithm/make_heap.h> -#include <__algorithm/max.h> -#include <__algorithm/max_element.h> -#include <__algorithm/merge.h> -#include <__algorithm/min.h> -#include <__algorithm/min_element.h> -#include <__algorithm/minmax.h> -#include <__algorithm/minmax_element.h> -#include <__algorithm/mismatch.h> -#include <__algorithm/move.h> -#include <__algorithm/move_backward.h> -#include <__algorithm/next_permutation.h> -#include <__algorithm/none_of.h> -#include <__algorithm/nth_element.h> -#include <__algorithm/partial_sort.h> -#include <__algorithm/partial_sort_copy.h> -#include <__algorithm/partition.h> -#include <__algorithm/partition_copy.h> -#include <__algorithm/partition_point.h> -#include <__algorithm/pop_heap.h> -#include <__algorithm/prev_permutation.h> -#include <__algorithm/push_heap.h> -#include <__algorithm/remove.h> -#include <__algorithm/remove_copy.h> -#include <__algorithm/remove_copy_if.h> -#include <__algorithm/remove_if.h> -#include <__algorithm/replace.h> -#include <__algorithm/replace_copy.h> -#include <__algorithm/replace_copy_if.h> -#include <__algorithm/replace_if.h> -#include <__algorithm/reverse.h> -#include <__algorithm/reverse_copy.h> -#include <__algorithm/rotate.h> -#include <__algorithm/rotate_copy.h> -#include <__algorithm/search.h> -#include <__algorithm/search_n.h> -#include <__algorithm/set_difference.h> -#include <__algorithm/set_intersection.h> -#include <__algorithm/set_symmetric_difference.h> -#include <__algorithm/set_union.h> -#include <__algorithm/shuffle.h> -#include <__algorithm/sort.h> -#include <__algorithm/sort_heap.h> -#include <__algorithm/stable_partition.h> -#include <__algorithm/stable_sort.h> -#include <__algorithm/swap_ranges.h> -#include <__algorithm/transform.h> -#include <__algorithm/unique.h> -#include <__algorithm/unique_copy.h> -#include <__algorithm/upper_bound.h> - -#if _LIBCPP_STD_VER >= 17 -# include <__algorithm/clamp.h> -# include <__algorithm/for_each_n.h> -# include <__algorithm/pstl.h> -# include <__algorithm/sample.h> -#endif // _LIBCPP_STD_VER >= 17 - -#if _LIBCPP_STD_VER >= 20 -# include <__algorithm/in_found_result.h> -# include <__algorithm/in_fun_result.h> -# include <__algorithm/in_in_out_result.h> -# include <__algorithm/in_in_result.h> -# include <__algorithm/in_out_out_result.h> -# include <__algorithm/in_out_result.h> -# include <__algorithm/lexicographical_compare_three_way.h> -# include <__algorithm/min_max_result.h> -# include <__algorithm/ranges_adjacent_find.h> -# include <__algorithm/ranges_all_of.h> -# include <__algorithm/ranges_any_of.h> -# include <__algorithm/ranges_binary_search.h> -# include <__algorithm/ranges_clamp.h> -# include <__algorithm/ranges_contains.h> -# include <__algorithm/ranges_copy.h> -# include <__algorithm/ranges_copy_backward.h> -# include <__algorithm/ranges_copy_if.h> -# include <__algorithm/ranges_copy_n.h> -# include <__algorithm/ranges_count.h> -# include <__algorithm/ranges_count_if.h> -# include <__algorithm/ranges_equal.h> -# include <__algorithm/ranges_equal_range.h> -# include <__algorithm/ranges_fill.h> -# include <__algorithm/ranges_fill_n.h> -# include <__algorithm/ranges_find.h> -# include <__algorithm/ranges_find_end.h> -# include <__algorithm/ranges_find_first_of.h> -# include <__algorithm/ranges_find_if.h> -# include <__algorithm/ranges_find_if_not.h> -# include <__algorithm/ranges_for_each.h> -# include <__algorithm/ranges_for_each_n.h> -# include <__algorithm/ranges_generate.h> -# include <__algorithm/ranges_generate_n.h> -# include <__algorithm/ranges_includes.h> -# include <__algorithm/ranges_inplace_merge.h> -# include <__algorithm/ranges_is_heap.h> -# include <__algorithm/ranges_is_heap_until.h> -# include <__algorithm/ranges_is_partitioned.h> -# include <__algorithm/ranges_is_permutation.h> -# include <__algorithm/ranges_is_sorted.h> -# include <__algorithm/ranges_is_sorted_until.h> -# include <__algorithm/ranges_lexicographical_compare.h> -# include <__algorithm/ranges_lower_bound.h> -# include <__algorithm/ranges_make_heap.h> -# include <__algorithm/ranges_max.h> -# include <__algorithm/ranges_max_element.h> -# include <__algorithm/ranges_merge.h> -# include <__algorithm/ranges_min.h> -# include <__algorithm/ranges_min_element.h> -# include <__algorithm/ranges_minmax.h> -# include <__algorithm/ranges_minmax_element.h> -# include <__algorithm/ranges_mismatch.h> -# include <__algorithm/ranges_move.h> -# include <__algorithm/ranges_move_backward.h> -# include <__algorithm/ranges_next_permutation.h> -# include <__algorithm/ranges_none_of.h> -# include <__algorithm/ranges_nth_element.h> -# include <__algorithm/ranges_partial_sort.h> -# include <__algorithm/ranges_partial_sort_copy.h> -# include <__algorithm/ranges_partition.h> -# include <__algorithm/ranges_partition_copy.h> -# include <__algorithm/ranges_partition_point.h> -# include <__algorithm/ranges_pop_heap.h> -# include <__algorithm/ranges_prev_permutation.h> -# include <__algorithm/ranges_push_heap.h> -# include <__algorithm/ranges_remove.h> -# include <__algorithm/ranges_remove_copy.h> -# include <__algorithm/ranges_remove_copy_if.h> -# include <__algorithm/ranges_remove_if.h> -# include <__algorithm/ranges_replace.h> -# include <__algorithm/ranges_replace_copy.h> -# include <__algorithm/ranges_replace_copy_if.h> -# include <__algorithm/ranges_replace_if.h> -# include <__algorithm/ranges_reverse.h> -# include <__algorithm/ranges_reverse_copy.h> -# include <__algorithm/ranges_rotate.h> -# include <__algorithm/ranges_rotate_copy.h> -# include <__algorithm/ranges_sample.h> -# include <__algorithm/ranges_search.h> -# include <__algorithm/ranges_search_n.h> -# include <__algorithm/ranges_set_difference.h> -# include <__algorithm/ranges_set_intersection.h> -# include <__algorithm/ranges_set_symmetric_difference.h> -# include <__algorithm/ranges_set_union.h> -# include <__algorithm/ranges_shuffle.h> -# include <__algorithm/ranges_sort.h> -# include <__algorithm/ranges_sort_heap.h> -# include <__algorithm/ranges_stable_partition.h> -# include <__algorithm/ranges_stable_sort.h> -# include <__algorithm/ranges_swap_ranges.h> -# include <__algorithm/ranges_transform.h> -# include <__algorithm/ranges_unique.h> -# include <__algorithm/ranges_unique_copy.h> -# include <__algorithm/ranges_upper_bound.h> -# include <__algorithm/shift_left.h> -# include <__algorithm/shift_right.h> -#endif - -#if _LIBCPP_STD_VER >= 23 -# include <__algorithm/ranges_contains_subrange.h> -# include <__algorithm/ranges_ends_with.h> -# include <__algorithm/ranges_find_last.h> -# include <__algorithm/ranges_fold.h> -# include <__algorithm/ranges_starts_with.h> -#endif // _LIBCPP_STD_VER >= 23 - -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/algorithm> +#else +# include <__config> + +# include <__algorithm/adjacent_find.h> +# include <__algorithm/all_of.h> +# include <__algorithm/any_of.h> +# include <__algorithm/binary_search.h> +# include <__algorithm/copy.h> +# include <__algorithm/copy_backward.h> +# include <__algorithm/copy_if.h> +# include <__algorithm/copy_n.h> +# include <__algorithm/count.h> +# include <__algorithm/count_if.h> +# include <__algorithm/equal.h> +# include <__algorithm/equal_range.h> +# include <__algorithm/fill.h> +# include <__algorithm/fill_n.h> +# include <__algorithm/find.h> +# include <__algorithm/find_end.h> +# include <__algorithm/find_first_of.h> +# include <__algorithm/find_if.h> +# include <__algorithm/find_if_not.h> +# include <__algorithm/for_each.h> +# include <__algorithm/generate.h> +# include <__algorithm/generate_n.h> +# include <__algorithm/includes.h> +# include <__algorithm/inplace_merge.h> +# include <__algorithm/is_heap.h> +# include <__algorithm/is_heap_until.h> +# include <__algorithm/is_partitioned.h> +# include <__algorithm/is_permutation.h> +# include <__algorithm/is_sorted.h> +# include <__algorithm/is_sorted_until.h> +# include <__algorithm/iter_swap.h> +# include <__algorithm/lexicographical_compare.h> +# include <__algorithm/lower_bound.h> +# include <__algorithm/make_heap.h> +# include <__algorithm/max.h> +# include <__algorithm/max_element.h> +# include <__algorithm/merge.h> +# include <__algorithm/min.h> +# include <__algorithm/min_element.h> +# include <__algorithm/minmax.h> +# include <__algorithm/minmax_element.h> +# include <__algorithm/mismatch.h> +# include <__algorithm/move.h> +# include <__algorithm/move_backward.h> +# include <__algorithm/next_permutation.h> +# include <__algorithm/none_of.h> +# include <__algorithm/nth_element.h> +# include <__algorithm/partial_sort.h> +# include <__algorithm/partial_sort_copy.h> +# include <__algorithm/partition.h> +# include <__algorithm/partition_copy.h> +# include <__algorithm/partition_point.h> +# include <__algorithm/pop_heap.h> +# include <__algorithm/prev_permutation.h> +# include <__algorithm/push_heap.h> +# include <__algorithm/remove.h> +# include <__algorithm/remove_copy.h> +# include <__algorithm/remove_copy_if.h> +# include <__algorithm/remove_if.h> +# include <__algorithm/replace.h> +# include <__algorithm/replace_copy.h> +# include <__algorithm/replace_copy_if.h> +# include <__algorithm/replace_if.h> +# include <__algorithm/reverse.h> +# include <__algorithm/reverse_copy.h> +# include <__algorithm/rotate.h> +# include <__algorithm/rotate_copy.h> +# include <__algorithm/search.h> +# include <__algorithm/search_n.h> +# include <__algorithm/set_difference.h> +# include <__algorithm/set_intersection.h> +# include <__algorithm/set_symmetric_difference.h> +# include <__algorithm/set_union.h> +# include <__algorithm/shuffle.h> +# include <__algorithm/sort.h> +# include <__algorithm/sort_heap.h> +# include <__algorithm/stable_partition.h> +# include <__algorithm/stable_sort.h> +# include <__algorithm/swap_ranges.h> +# include <__algorithm/transform.h> +# include <__algorithm/unique.h> +# include <__algorithm/unique_copy.h> +# include <__algorithm/upper_bound.h> + +# if _LIBCPP_STD_VER >= 17 +# include <__algorithm/clamp.h> +# include <__algorithm/for_each_n.h> +# include <__algorithm/pstl.h> +# include <__algorithm/sample.h> +# endif // _LIBCPP_STD_VER >= 17 + +# if _LIBCPP_STD_VER >= 23 +# include <__algorithm/ranges_contains_subrange.h> +# include <__algorithm/ranges_ends_with.h> +# include <__algorithm/ranges_find_last.h> +# include <__algorithm/ranges_fold.h> +# include <__algorithm/ranges_starts_with.h> +# endif // _LIBCPP_STD_VER >= 23 + +# if _LIBCPP_STD_VER >= 23 +# include <__algorithm/fold.h> +# include <__algorithm/ranges_contains_subrange.h> +# include <__algorithm/ranges_ends_with.h> +# include <__algorithm/ranges_find_last.h> +# include <__algorithm/ranges_starts_with.h> +# endif // _LIBCPP_STD_VER >= 23 + +# include // standard-mandated includes // [algorithm.syn] -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 14 -# include -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 14 +# include +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_ALGORITHM diff --git a/libcxx/include/any b/libcxx/include/any index e32aa7f8e8a4209..9b9ca3b6e0f5003 100644 --- a/libcxx/include/any +++ b/libcxx/include/any @@ -80,41 +80,46 @@ namespace std { */ -#include <__config> -#include <__memory/allocator.h> -#include <__memory/allocator_destructor.h> -#include <__memory/allocator_traits.h> -#include <__memory/unique_ptr.h> -#include <__type_traits/add_const.h> -#include <__type_traits/add_pointer.h> -#include <__type_traits/aligned_storage.h> -#include <__type_traits/conditional.h> -#include <__type_traits/decay.h> -#include <__type_traits/enable_if.h> -#include <__type_traits/is_constructible.h> -#include <__type_traits/is_function.h> -#include <__type_traits/is_nothrow_constructible.h> -#include <__type_traits/is_reference.h> -#include <__type_traits/is_same.h> -#include <__type_traits/is_void.h> -#include <__type_traits/remove_cv.h> -#include <__type_traits/remove_cvref.h> -#include <__type_traits/remove_reference.h> -#include <__utility/forward.h> -#include <__utility/in_place.h> -#include <__utility/move.h> -#include <__utility/unreachable.h> -#include <__verbose_abort> -#include -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/any> +#else +# include <__config> +# include <__memory/allocator.h> +# include <__memory/allocator_destructor.h> +# include <__memory/allocator_traits.h> +# include <__memory/unique_ptr.h> +# include <__type_traits/add_const.h> +# include <__type_traits/add_pointer.h> +# include <__type_traits/aligned_storage.h> +# include <__type_traits/conditional.h> +# include <__type_traits/decay.h> +# include <__type_traits/enable_if.h> +# include <__type_traits/is_constructible.h> +# include <__type_traits/is_function.h> +# include <__type_traits/is_nothrow_constructible.h> +# include <__type_traits/is_reference.h> +# include <__type_traits/is_same.h> +# include <__type_traits/is_void.h> +# include <__type_traits/remove_cv.h> +# include <__type_traits/remove_cvref.h> +# include <__type_traits/remove_reference.h> +# include <__utility/forward.h> +# include <__utility/in_place.h> +# include <__utility/move.h> +# include <__utility/unreachable.h> +# include <__verbose_abort> +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> namespace std { class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast { @@ -125,14 +130,14 @@ public: _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 [[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void __throw_bad_any_cast() { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw bad_any_cast(); -# else +# else _LIBCPP_VERBOSE_ABORT("bad_any_cast was thrown in -fno-exceptions mode"); -# endif +# endif } // Forward declarations @@ -176,10 +181,10 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr const void* __get_fallback_typeid() { template inline _LIBCPP_HIDE_FROM_ABI bool __compare_typeid(type_info const* __id, const void* __fallback_id) { -# if _LIBCPP_HAS_RTTI +# if _LIBCPP_HAS_RTTI if (__id && *__id == typeid(_Tp)) return true; -# endif +# endif return !__id && __fallback_id == __any_imp::__get_fallback_typeid<_Tp>(); } @@ -266,7 +271,7 @@ public: // 6.3.4 any observers _LIBCPP_HIDE_FROM_ABI bool has_value() const _NOEXCEPT { return __h_ != nullptr; } -# if _LIBCPP_HAS_RTTI +# if _LIBCPP_HAS_RTTI _LIBCPP_HIDE_FROM_ABI const type_info& type() const _NOEXCEPT { if (__h_) { return *static_cast(this->__call(_Action::_TypeInfo)); @@ -274,7 +279,7 @@ public: return typeid(void); } } -# endif +# endif private: typedef __any_imp::_Action _Action; @@ -372,11 +377,11 @@ private: } _LIBCPP_HIDE_FROM_ABI static void* __type_info() { -# if _LIBCPP_HAS_RTTI +# if _LIBCPP_HAS_RTTI return const_cast(static_cast(&typeid(_Tp))); -# else +# else return nullptr; -# endif +# endif } }; @@ -444,11 +449,11 @@ private: } _LIBCPP_HIDE_FROM_ABI static void* __type_info() { -# if _LIBCPP_HAS_RTTI +# if _LIBCPP_HAS_RTTI return const_cast(static_cast(&typeid(_Tp))); -# else +# else return nullptr; -# endif +# endif } }; @@ -579,37 +584,38 @@ _LIBCPP_HIDE_FROM_ABI add_pointer_t<_ValueType> any_cast(any* __any) _NOEXCEPT { void* __p = __any->__call( _Action::_Get, nullptr, -# if _LIBCPP_HAS_RTTI +# if _LIBCPP_HAS_RTTI &typeid(_ValueType), -# else +# else nullptr, -# endif +# endif __any_imp::__get_fallback_typeid<_ValueType>()); return std::__pointer_or_func_cast<_ReturnType>(__p, is_function<_ValueType>{}); } return nullptr; } -#endif // _LIBCPP_STD_VER >= 17 +# endif // _LIBCPP_STD_VER >= 17 _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 -# include -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 +# include +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_ANY diff --git a/libcxx/include/array b/libcxx/include/array index 0e9af4198632d1b..d4f0a7922f9fbb3 100644 --- a/libcxx/include/array +++ b/libcxx/include/array @@ -111,58 +111,63 @@ template const T&& get(const array&&) noexce */ -#include <__algorithm/equal.h> -#include <__algorithm/fill_n.h> -#include <__algorithm/lexicographical_compare.h> -#include <__algorithm/lexicographical_compare_three_way.h> -#include <__algorithm/swap_ranges.h> -#include <__assert> -#include <__config> -#include <__fwd/array.h> -#include <__iterator/reverse_iterator.h> -#include <__iterator/wrap_iter.h> -#include <__tuple/sfinae_helpers.h> -#include <__type_traits/conditional.h> -#include <__type_traits/conjunction.h> -#include <__type_traits/enable_if.h> -#include <__type_traits/is_array.h> -#include <__type_traits/is_const.h> -#include <__type_traits/is_constructible.h> -#include <__type_traits/is_nothrow_constructible.h> -#include <__type_traits/is_same.h> -#include <__type_traits/is_swappable.h> -#include <__type_traits/is_trivially_relocatable.h> -#include <__type_traits/remove_cv.h> -#include <__utility/empty.h> -#include <__utility/integer_sequence.h> -#include <__utility/move.h> -#include <__utility/unreachable.h> -#include -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/array> +#else +# include <__algorithm/equal.h> +# include <__algorithm/fill_n.h> +# include <__algorithm/lexicographical_compare.h> +# include <__algorithm/lexicographical_compare_three_way.h> +# include <__algorithm/swap_ranges.h> +# include <__assert> +# include <__config> +# include <__fwd/array.h> +# include <__iterator/reverse_iterator.h> +# include <__iterator/wrap_iter.h> +# include <__tuple/sfinae_helpers.h> +# include <__type_traits/conditional.h> +# include <__type_traits/conjunction.h> +# include <__type_traits/enable_if.h> +# include <__type_traits/is_array.h> +# include <__type_traits/is_const.h> +# include <__type_traits/is_constructible.h> +# include <__type_traits/is_nothrow_constructible.h> +# include <__type_traits/is_same.h> +# include <__type_traits/is_swappable.h> +# include <__type_traits/is_trivially_relocatable.h> +# include <__type_traits/remove_cv.h> +# include <__utility/empty.h> +# include <__utility/integer_sequence.h> +# include <__utility/move.h> +# include <__utility/unreachable.h> +# include +# include // standard-mandated includes // [iterator.range] -#include <__iterator/access.h> -#include <__iterator/data.h> -#include <__iterator/empty.h> -#include <__iterator/reverse_access.h> -#include <__iterator/size.h> +# include <__iterator/access.h> +# include <__iterator/data.h> +# include <__iterator/empty.h> +# include <__iterator/reverse_access.h> +# include <__iterator/size.h> // [array.syn] -#include -#include +# include +# include // [tuple.helper] -#include <__tuple/tuple_element.h> -#include <__tuple/tuple_size.h> +# include <__tuple/tuple_element.h> +# include <__tuple/tuple_size.h> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -177,13 +182,13 @@ struct _LIBCPP_TEMPLATE_VIS array { using const_reference = const value_type&; using pointer = value_type*; using const_pointer = const value_type*; -#if defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY) +# if defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY) using iterator = __wrap_iter; using const_iterator = __wrap_iter; -#else +# else using iterator = pointer; using const_iterator = const_pointer; -#endif +# endif using size_type = size_t; using difference_type = ptrdiff_t; using reverse_iterator = std::reverse_iterator; @@ -277,13 +282,13 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> { using const_reference = const value_type&; using pointer = value_type*; using const_pointer = const value_type*; -#if defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY) +# if defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY) using iterator = __wrap_iter; using const_iterator = __wrap_iter; -#else +# else using iterator = pointer; using const_iterator = const_pointer; -#endif +# endif using size_type = size_t; using difference_type = ptrdiff_t; using reverse_iterator = std::reverse_iterator; @@ -385,10 +390,10 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> { } }; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template ::value...>::value> > array(_Tp, _Args...) -> array<_Tp, 1 + sizeof...(_Args)>; -#endif +# endif template inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool @@ -396,7 +401,7 @@ operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { return std::equal(__x.begin(), __x.end(), __y.begin()); } -#if _LIBCPP_STD_VER <= 17 +# if _LIBCPP_STD_VER <= 17 template inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -423,7 +428,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const array<_Tp, _Size>& __x, const return !(__x < __y); } -#else // _LIBCPP_STD_VER <= 17 +# else // _LIBCPP_STD_VER <= 17 template _LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp> @@ -431,7 +436,7 @@ operator<=>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); } -#endif // _LIBCPP_STD_VER <= 17 +# endif // _LIBCPP_STD_VER <= 17 template , int> = 0> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y) @@ -472,7 +477,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const return std::move(__a.__elems_[_Ip]); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template _LIBCPP_HIDE_FROM_ABI constexpr array, _Size> @@ -502,19 +507,20 @@ to_array(_Tp (&&__arr)[_Size]) noexcept(is_nothrow_move_constructible_v<_Tp>) { return std::__to_array_rvalue_impl(std::move(__arr), make_index_sequence<_Size>()); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_ARRAY diff --git a/libcxx/include/atomic b/libcxx/include/atomic index ebd46238eec9860..31ac8ebcef0644e 100644 --- a/libcxx/include/atomic +++ b/libcxx/include/atomic @@ -587,42 +587,48 @@ template */ -#include <__config> - -#include <__atomic/aliases.h> -#include <__atomic/atomic.h> -#include <__atomic/atomic_base.h> -#include <__atomic/atomic_flag.h> -#include <__atomic/atomic_init.h> -#include <__atomic/atomic_lock_free.h> -#include <__atomic/atomic_sync.h> -#include <__atomic/check_memory_order.h> -#include <__atomic/contention_t.h> -#include <__atomic/cxx_atomic_impl.h> -#include <__atomic/fence.h> -#include <__atomic/is_always_lock_free.h> -#include <__atomic/kill_dependency.h> -#include <__atomic/memory_order.h> -#include - -#if _LIBCPP_STD_VER >= 20 -# include <__atomic/atomic_ref.h> -#endif - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !_LIBCPP_HAS_ATOMIC_HEADER -# error is not implemented -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/algorithm> +#else +# include <__config> + +# include <__atomic/aliases.h> +# include <__atomic/atomic.h> +# include <__atomic/atomic_base.h> +# include <__atomic/atomic_flag.h> +# include <__atomic/atomic_init.h> +# include <__atomic/atomic_lock_free.h> +# include <__atomic/atomic_sync.h> +# include <__atomic/check_memory_order.h> +# include <__atomic/contention_t.h> +# include <__atomic/cxx_atomic_impl.h> +# include <__atomic/fence.h> +# include <__atomic/is_always_lock_free.h> +# include <__atomic/kill_dependency.h> +# include <__atomic/memory_order.h> +# include + +# if _LIBCPP_STD_VER >= 20 +# include <__atomic/atomic_ref.h> +# endif + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !_LIBCPP_HAS_ATOMIC_HEADER +# error is not implemented +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_ATOMIC diff --git a/libcxx/include/barrier b/libcxx/include/barrier index abc014e8aaf5c06..619b93855eca931 100644 --- a/libcxx/include/barrier +++ b/libcxx/include/barrier @@ -45,30 +45,35 @@ namespace std */ -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_THREADS) - -# include <__assert> -# include <__atomic/atomic_base.h> -# include <__atomic/memory_order.h> -# include <__memory/unique_ptr.h> -# include <__thread/poll_with_backoff.h> -# include <__thread/timed_backoff_policy.h> -# include <__utility/move.h> -# include -# include -# include -# include - -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/barrier> +#else +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_THREADS) + +# include <__assert> +# include <__atomic/atomic_base.h> +# include <__atomic/memory_order.h> +# include <__memory/unique_ptr.h> +# include <__thread/poll_with_backoff.h> +# include <__thread/timed_backoff_policy.h> +# include <__utility/move.h> +# include +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -# include <__undef_macros> +# include <__undef_macros> -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_BEGIN_NAMESPACE_STD @@ -76,7 +81,7 @@ struct __empty_completion { inline _LIBCPP_HIDE_FROM_ABI void operator()() noexcept {} }; -# ifndef _LIBCPP_HAS_NO_TREE_BARRIER +# ifndef _LIBCPP_HAS_NO_TREE_BARRIER /* @@ -150,7 +155,7 @@ public: } }; -# else +# else /* @@ -251,7 +256,7 @@ public: } }; -# endif // !_LIBCPP_HAS_NO_TREE_BARRIER +# endif // !_LIBCPP_HAS_NO_TREE_BARRIER template class barrier { @@ -290,19 +295,20 @@ public: _LIBCPP_END_NAMESPACE_STD -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_POP_MACROS -#endif // !defined(_LIBCPP_HAS_NO_THREADS) +# endif // !defined(_LIBCPP_HAS_NO_THREADS) -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_BARRIER diff --git a/libcxx/include/bit b/libcxx/include/bit index 94387d101a398f0..8a856754409832c 100644 --- a/libcxx/include/bit +++ b/libcxx/include/bit @@ -61,41 +61,47 @@ namespace std { */ -#include <__config> - -#if _LIBCPP_STD_VER >= 20 -# include <__bit/bit_cast.h> -# include <__bit/bit_ceil.h> -# include <__bit/bit_floor.h> -# include <__bit/bit_log2.h> -# include <__bit/bit_width.h> -# include <__bit/countl.h> -# include <__bit/countr.h> -# include <__bit/endian.h> -# include <__bit/has_single_bit.h> -# include <__bit/popcount.h> -# include <__bit/rotate.h> -#endif - -#if _LIBCPP_STD_VER >= 23 -# include <__bit/byteswap.h> -#endif - -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 -# include -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/bit> +#else +# include <__config> + +# if _LIBCPP_STD_VER >= 20 +# include <__bit/bit_cast.h> +# include <__bit/bit_ceil.h> +# include <__bit/bit_floor.h> +# include <__bit/bit_log2.h> +# include <__bit/bit_width.h> +# include <__bit/countl.h> +# include <__bit/countr.h> +# include <__bit/endian.h> +# include <__bit/has_single_bit.h> +# include <__bit/popcount.h> +# include <__bit/rotate.h> +# endif + +# if _LIBCPP_STD_VER >= 23 +# include <__bit/byteswap.h> +# endif + +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 +# include +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_BIT diff --git a/libcxx/include/bitset b/libcxx/include/bitset index 645c172f3be499c..2f777b8a407e0cf 100644 --- a/libcxx/include/bitset +++ b/libcxx/include/bitset @@ -126,33 +126,38 @@ template struct hash>; // clang-format on -#include <__algorithm/count.h> -#include <__algorithm/fill.h> -#include <__algorithm/fill_n.h> -#include <__algorithm/find.h> -#include <__bit_reference> -#include <__config> -#include <__functional/hash.h> -#include <__functional/unary_function.h> -#include <__type_traits/is_char_like_type.h> -#include -#include -#include -#include -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/bitest> +#else +# include <__algorithm/count.h> +# include <__algorithm/fill.h> +# include <__algorithm/fill_n.h> +# include <__algorithm/find.h> +# include <__bit_reference> +# include <__config> +# include <__functional/hash.h> +# include <__functional/unary_function.h> +# include <__type_traits/is_char_like_type.h> +# include +# include +# include +# include +# include // standard-mandated includes // [bitset.syn] -#include -#include +# include +# include -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -223,10 +228,10 @@ protected: _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT; private: -#ifdef _LIBCPP_CXX03_LANG +# ifdef _LIBCPP_CXX03_LANG void __init(unsigned long long __v, false_type) _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI void __init(unsigned long long __v, true_type) _NOEXCEPT; -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong(false_type) const; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong(true_type) const; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(false_type) const; @@ -237,16 +242,16 @@ private: template inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset() _NOEXCEPT -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG : __first_{0} -#endif +# endif { -#ifdef _LIBCPP_CXX03_LANG +# ifdef _LIBCPP_CXX03_LANG std::fill_n(__first_, _N_words, __storage_type(0)); -#endif +# endif } -#ifdef _LIBCPP_CXX03_LANG +# ifdef _LIBCPP_CXX03_LANG template void __bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT { @@ -272,27 +277,27 @@ inline _LIBCPP_HIDE_FROM_ABI void __bitset<_N_words, _Size>::__init(unsigned lon std::fill(__first_ + 1, __first_ + sizeof(__first_) / sizeof(__first_[0]), __storage_type(0)); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT -#ifndef _LIBCPP_CXX03_LANG -# if __SIZEOF_SIZE_T__ == 8 +# ifndef _LIBCPP_CXX03_LANG +# if __SIZEOF_SIZE_T__ == 8 : __first_{__v} -# elif __SIZEOF_SIZE_T__ == 4 +# elif __SIZEOF_SIZE_T__ == 4 : __first_{static_cast<__storage_type>(__v), _Size >= 2 * __bits_per_word ? static_cast<__storage_type>(__v >> __bits_per_word) : static_cast<__storage_type>((__v >> __bits_per_word) & (__storage_type(1) << (_Size - __bits_per_word)) - 1)} -# else -# error This constructor has not been ported to this platform +# else +# error This constructor has not been ported to this platform +# endif # endif -#endif { -#ifdef _LIBCPP_CXX03_LANG - __init(__v, integral_constant()); -#endif +# ifdef _LIBCPP_CXX03_LANG + __init(__v, integral_constant < bool, sizeof(unsigned long long) == sizeof(__storage_type) > ()); +# endif } template @@ -624,18 +629,18 @@ public: template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset( const _CharT* __str, -#if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 typename basic_string_view<_CharT>::size_type __n = basic_string_view<_CharT>::npos, -#else +# else typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos, -#endif +# endif _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) { size_t __rlen = std::min(__n, char_traits<_CharT>::length(__str)); __init_from_string_view(basic_string_view<_CharT>(__str, __rlen), __zero, __one); } -#if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template _LIBCPP_HIDE_FROM_ABI constexpr explicit bitset( basic_string_view<_CharT, _Traits> __str, @@ -649,7 +654,7 @@ public: size_t __rlen = std::min(__n, __str.size() - __pos); __init_from_string_view(basic_string_view<_CharT, _Traits>(__str.data() + __pos, __rlen), __zero, __one); } -#endif +# endif template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset( const basic_string<_CharT, _Traits, _Allocator>& __str, @@ -680,13 +685,13 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& flip(size_t __pos); // element access: -#ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL +# ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator[](size_t __p) const { return __base::__make_ref(__p); } -#else +# else _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const { return __base::__make_ref(__p); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference operator[](size_t __p) { return __base::__make_ref(__p); } @@ -706,9 +711,9 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t count() const _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT { return _Size; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const bitset& __rhs) const _NOEXCEPT; -#if _LIBCPP_STD_VER <= 17 +# if _LIBCPP_STD_VER <= 17 _LIBCPP_HIDE_FROM_ABI bool operator!=(const bitset& __rhs) const _NOEXCEPT; -#endif +# endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool test(size_t __pos) const; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT; @@ -881,14 +886,14 @@ bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT { return std::equal(__base::__make_iter(0), __base::__make_iter(_Size), __rhs.__make_iter(0)); } -#if _LIBCPP_STD_VER <= 17 +# if _LIBCPP_STD_VER <= 17 template inline _LIBCPP_HIDE_FROM_ABI bool bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT { return !(*this == __rhs); } -#endif +# endif template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::test(size_t __pos) const { @@ -965,10 +970,11 @@ _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_BITSET diff --git a/libcxx/include/cassert b/libcxx/include/cassert index 6fec37dc637610b..e76e2e7dca80083 100644 --- a/libcxx/include/cassert +++ b/libcxx/include/cassert @@ -16,16 +16,22 @@ Macros: */ -#include <__config> +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/cassert> +#else +# include <__config> // is not provided by libc++ -#if __has_include() -# include -# ifdef _LIBCPP_ASSERT_H -# error "If libc++ starts defining , the __has_include check should move to libc++'s " +# if __has_include() +# include +# ifdef _LIBCPP_ASSERT_H +# error "If libc++ starts defining , the __has_include check should move to libc++'s " +# endif # endif -#endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif +#endif // _LIBCPP_CXX03_LANG diff --git a/libcxx/include/ccomplex b/libcxx/include/ccomplex index d379c9e7f0174a9..9d8464ee1f54871 100644 --- a/libcxx/include/ccomplex +++ b/libcxx/include/ccomplex @@ -17,11 +17,17 @@ */ +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/ccomplex> +#else #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif +#endif // _LIBCPP_CXX03_LANG #if _LIBCPP_STD_VER >= 20 diff --git a/libcxx/include/cctype b/libcxx/include/cctype index d7af7e084aa23a9..bf8768f1a4e8777 100644 --- a/libcxx/include/cctype +++ b/libcxx/include/cctype @@ -34,78 +34,83 @@ int toupper(int c); } // std */ -#include <__config> +#include <__configuration/cxx03.h> -#include +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/cctype> +#else +# include <__config> -#ifndef _LIBCPP_CTYPE_H +# include + +# ifndef _LIBCPP_CTYPE_H # error tried including but didn't find libc++'s header. \ This usually means that your header search paths are not configured properly. \ The header search paths should contain the C++ Standard Library headers before \ any C Standard Library. -#endif +# endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD -#ifdef isalnum -# undef isalnum -#endif +# ifdef isalnum +# undef isalnum +# endif -#ifdef isalpha -# undef isalpha -#endif +# ifdef isalpha +# undef isalpha +# endif -#ifdef isblank -# undef isblank -#endif +# ifdef isblank +# undef isblank +# endif -#ifdef iscntrl -# undef iscntrl -#endif +# ifdef iscntrl +# undef iscntrl +# endif -#ifdef isdigit -# undef isdigit -#endif +# ifdef isdigit +# undef isdigit +# endif -#ifdef isgraph -# undef isgraph -#endif +# ifdef isgraph +# undef isgraph +# endif -#ifdef islower -# undef islower -#endif +# ifdef islower +# undef islower +# endif -#ifdef isprint -# undef isprint -#endif +# ifdef isprint +# undef isprint +# endif -#ifdef ispunct -# undef ispunct -#endif +# ifdef ispunct +# undef ispunct +# endif -#ifdef isspace -# undef isspace -#endif +# ifdef isspace +# undef isspace +# endif -#ifdef isupper -# undef isupper -#endif +# ifdef isupper +# undef isupper +# endif -#ifdef isxdigit -# undef isxdigit -#endif +# ifdef isxdigit +# undef isxdigit +# endif -#ifdef tolower -# undef tolower -#endif +# ifdef tolower +# undef tolower +# endif -#ifdef toupper -# undef toupper -#endif +# ifdef toupper +# undef toupper +# endif using ::isalnum _LIBCPP_USING_IF_EXISTS; using ::isalpha _LIBCPP_USING_IF_EXISTS; @@ -123,5 +128,6 @@ using ::tolower _LIBCPP_USING_IF_EXISTS; using ::toupper _LIBCPP_USING_IF_EXISTS; _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CCTYPE diff --git a/libcxx/include/cerrno b/libcxx/include/cerrno index f1295680fed6c85..4e6fba9fd54f2ed 100644 --- a/libcxx/include/cerrno +++ b/libcxx/include/cerrno @@ -22,21 +22,26 @@ Macros: */ -#include <__config> +#include <__configuration/cxx03.h> -#include +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/cerrno> +#else +# include <__config> -#ifndef _LIBCPP_ERRNO_H +# include + +# ifndef _LIBCPP_ERRNO_H # error tried including but didn't find libc++'s header. \ This usually means that your header search paths are not configured properly. \ The header search paths should contain the C++ Standard Library headers before \ any C Standard Library, and you are probably using compiler flags that make that \ not be the case. -#endif +# endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif // LWG3869 Deprecate std::errc constants related to UNIX STREAMS // @@ -45,4 +50,6 @@ Macros: // Based on the post commit feedback the macro are no longer deprecated. // Instead libc++ leaves the deprecation to the provider of errno.h. +#endif // _LIBCPP_CXX03_LANG + #endif // _LIBCPP_CERRNO diff --git a/libcxx/include/cfenv b/libcxx/include/cfenv index f8cacd562f76bd2..e316177812f8948 100644 --- a/libcxx/include/cfenv +++ b/libcxx/include/cfenv @@ -52,21 +52,26 @@ int feupdateenv(const fenv_t* envp); } // std */ -#include <__config> +#include <__configuration/cxx03.h> -#include +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/algorithm> +#else +# include <__config> -#ifndef _LIBCPP_FENV_H +# include + +# ifndef _LIBCPP_FENV_H # error tried including but didn't find libc++'s header. \ This usually means that your header search paths are not configured properly. \ The header search paths should contain the C++ Standard Library headers before \ any C Standard Library, and you are probably using compiler flags that make that \ not be the case. -#endif +# endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -86,5 +91,6 @@ using ::fesetenv _LIBCPP_USING_IF_EXISTS; using ::feupdateenv _LIBCPP_USING_IF_EXISTS; _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CFENV diff --git a/libcxx/include/cfloat b/libcxx/include/cfloat index 5d1b38c557dcada..23b7a034d7bc410 100644 --- a/libcxx/include/cfloat +++ b/libcxx/include/cfloat @@ -69,20 +69,26 @@ Macros: LDBL_TRUE_MIN // C11 */ -#include <__config> +#include <__configuration/cxx03.h> -#include +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/cfloat> +#else +# include <__config> -#ifndef _LIBCPP_FLOAT_H +# include + +# ifndef _LIBCPP_FLOAT_H # error tried including but didn't find libc++'s header. \ This usually means that your header search paths are not configured properly. \ The header search paths should contain the C++ Standard Library headers before \ any C Standard Library, and you are probably using compiler flags that make that \ not be the case. -#endif +# endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CFLOAT diff --git a/libcxx/include/charconv b/libcxx/include/charconv index 29c6875008abb45..399fba7f42f991e 100644 --- a/libcxx/include/charconv +++ b/libcxx/include/charconv @@ -75,48 +75,50 @@ namespace std { */ -#include <__config> - -#if _LIBCPP_STD_VER >= 17 -# include <__charconv/chars_format.h> -# include <__charconv/from_chars_floating_point.h> -# include <__charconv/from_chars_integral.h> -# include <__charconv/from_chars_result.h> -# include <__charconv/tables.h> -# include <__charconv/to_chars.h> -# include <__charconv/to_chars_base_10.h> -# include <__charconv/to_chars_floating_point.h> -# include <__charconv/to_chars_integral.h> -# include <__charconv/to_chars_result.h> -# include <__charconv/traits.h> -#endif // _LIBCPP_STD_VER >= 17 - -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -_LIBCPP_END_NAMESPACE_STD - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 -# include -# include -# include -# include -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/charconv> +#else +# include <__config> + +# if _LIBCPP_STD_VER >= 17 +# include <__charconv/chars_format.h> +# include <__charconv/from_chars_floating_point.h> +# include <__charconv/from_chars_integral.h> +# include <__charconv/from_chars_result.h> +# include <__charconv/tables.h> +# include <__charconv/to_chars.h> +# include <__charconv/to_chars_base_10.h> +# include <__charconv/to_chars_floating_point.h> +# include <__charconv/to_chars_integral.h> +# include <__charconv/to_chars_result.h> +# include <__charconv/traits.h> +# endif // _LIBCPP_STD_VER >= 17 + +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 +# include +# include +# include +# include +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CHARCONV diff --git a/libcxx/include/chrono b/libcxx/include/chrono index 0f4223270c9d29b..a1dbb93a1dc55b0 100644 --- a/libcxx/include/chrono +++ b/libcxx/include/chrono @@ -939,85 +939,90 @@ constexpr chrono::year operator ""y(unsigned lo // clang-format on -#include <__config> - -#include <__chrono/duration.h> -#include <__chrono/file_clock.h> -#include <__chrono/high_resolution_clock.h> -#include <__chrono/steady_clock.h> -#include <__chrono/system_clock.h> -#include <__chrono/time_point.h> - -#if _LIBCPP_STD_VER >= 20 -# include <__chrono/calendar.h> -# include <__chrono/day.h> -# include <__chrono/exception.h> -# include <__chrono/hh_mm_ss.h> -# include <__chrono/literals.h> -# include <__chrono/local_info.h> -# include <__chrono/month.h> -# include <__chrono/month_weekday.h> -# include <__chrono/monthday.h> -# include <__chrono/sys_info.h> -# include <__chrono/weekday.h> -# include <__chrono/year.h> -# include <__chrono/year_month.h> -# include <__chrono/year_month_day.h> -# include <__chrono/year_month_weekday.h> - -# if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include <__chrono/formatter.h> -# include <__chrono/ostream.h> -# include <__chrono/parser_std_format_spec.h> -# include <__chrono/statically_widen.h> -# endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/chrono> +#else +# include <__config> + +# include <__chrono/duration.h> +# include <__chrono/file_clock.h> +# include <__chrono/high_resolution_clock.h> +# include <__chrono/steady_clock.h> +# include <__chrono/system_clock.h> +# include <__chrono/time_point.h> + +# if _LIBCPP_STD_VER >= 20 +# include <__chrono/calendar.h> +# include <__chrono/day.h> +# include <__chrono/exception.h> +# include <__chrono/hh_mm_ss.h> +# include <__chrono/literals.h> +# include <__chrono/local_info.h> +# include <__chrono/month.h> +# include <__chrono/month_weekday.h> +# include <__chrono/monthday.h> +# include <__chrono/sys_info.h> +# include <__chrono/weekday.h> +# include <__chrono/year.h> +# include <__chrono/year_month.h> +# include <__chrono/year_month_day.h> +# include <__chrono/year_month_weekday.h> + +# if !defined(_LIBCPP_HAS_NO_LOCALIZATION) +# include <__chrono/formatter.h> +# include <__chrono/ostream.h> +# include <__chrono/parser_std_format_spec.h> +# include <__chrono/statically_widen.h> +# endif + +# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ + !defined(_LIBCPP_HAS_NO_LOCALIZATION) +# include <__chrono/leap_second.h> +# include <__chrono/time_zone.h> +# include <__chrono/time_zone_link.h> +# include <__chrono/tzdb.h> +# include <__chrono/tzdb_list.h> +# include <__chrono/zoned_time.h> +# endif -# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ - !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include <__chrono/leap_second.h> -# include <__chrono/time_zone.h> -# include <__chrono/time_zone_link.h> -# include <__chrono/tzdb.h> -# include <__chrono/tzdb_list.h> -# include <__chrono/zoned_time.h> # endif -#endif - -#include +# include // standard-mandated includes // [time.syn] -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 -# include -# include -# include -# include -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 20 -# include -# if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include -# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 +# include +# include +# include +# include +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 20 +# include +# if !defined(_LIBCPP_HAS_NO_LOCALIZATION) +# include +# include +# endif # endif -#endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CHRONO diff --git a/libcxx/include/cinttypes b/libcxx/include/cinttypes index 52663a4f35fad5f..d31a3c463136784 100644 --- a/libcxx/include/cinttypes +++ b/libcxx/include/cinttypes @@ -234,26 +234,31 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int } // std */ -#include <__config> +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/cinttypes> +#else +# include <__config> // standard-mandated includes // [cinttypes.syn] -#include +# include -#include +# include -#ifndef _LIBCPP_INTTYPES_H +# ifndef _LIBCPP_INTTYPES_H # error tried including but didn't find libc++'s header. \ This usually means that your header search paths are not configured properly. \ The header search paths should contain the C++ Standard Library headers before \ any C Standard Library, and you are probably using compiler flags that make that \ not be the case. -#endif +# endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -266,5 +271,6 @@ using ::wcstoimax _LIBCPP_USING_IF_EXISTS; using ::wcstoumax _LIBCPP_USING_IF_EXISTS; _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CINTTYPES diff --git a/libcxx/include/ciso646 b/libcxx/include/ciso646 index 5fcac79e38a7f2f..2f98bf3ad614370 100644 --- a/libcxx/include/ciso646 +++ b/libcxx/include/ciso646 @@ -15,11 +15,17 @@ */ -#include <__config> +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/ciso646> +#else +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif +#endif // _LIBCPP_CXX03_LANG #if _LIBCPP_STD_VER >= 20 diff --git a/libcxx/include/climits b/libcxx/include/climits index bcd8b4a56a073c1..f3fce1ab045c48b 100644 --- a/libcxx/include/climits +++ b/libcxx/include/climits @@ -37,12 +37,18 @@ Macros: */ -#include <__config> +#include <__configuration/cxx03.h> -#include +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/climits> +#else +# include <__config> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CLIMITS diff --git a/libcxx/include/clocale b/libcxx/include/clocale index 4d53aa7eb29b293..a9bb03114ac9fc6 100644 --- a/libcxx/include/clocale +++ b/libcxx/include/clocale @@ -36,11 +36,24 @@ lconv* localeconv(); #include <__config> -#include +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/clocale> +#else +# include + +# ifndef _LIBCPP_LOCALE_H +# error tried including but didn't find libc++'s header. \ + This usually means that your header search paths are not configured properly. \ + The header search paths should contain the C++ Standard Library headers before \ + any C Standard Library, and you are probably using compiler flags that make that \ + not be the case. +# endif + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -49,5 +62,6 @@ using ::setlocale _LIBCPP_USING_IF_EXISTS; using ::localeconv _LIBCPP_USING_IF_EXISTS; _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CLOCALE diff --git a/libcxx/include/cmath b/libcxx/include/cmath index 5d30b151870e0d6..e6be2926597155c 100644 --- a/libcxx/include/cmath +++ b/libcxx/include/cmath @@ -312,35 +312,40 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept */ -#include <__config> -#include <__math/hypot.h> -#include <__type_traits/enable_if.h> -#include <__type_traits/is_arithmetic.h> -#include <__type_traits/is_constant_evaluated.h> -#include <__type_traits/is_floating_point.h> -#include <__type_traits/is_same.h> -#include <__type_traits/promote.h> -#include <__type_traits/remove_cv.h> -#include -#include - -#include <__math/special_functions.h> -#include - -#ifndef _LIBCPP_MATH_H +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/cmath> +#else +# include <__config> +# include <__math/hypot.h> +# include <__type_traits/enable_if.h> +# include <__type_traits/is_arithmetic.h> +# include <__type_traits/is_constant_evaluated.h> +# include <__type_traits/is_floating_point.h> +# include <__type_traits/is_same.h> +# include <__type_traits/promote.h> +# include <__type_traits/remove_cv.h> +# include +# include + +# include <__math/special_functions.h> +# include + +# ifndef _LIBCPP_MATH_H # error tried including but didn't find libc++'s header. \ This usually means that your header search paths are not configured properly. \ The header search paths should contain the C++ Standard Library headers before \ any C Standard Library, and you are probably using compiler flags that make that \ not be the case. -#endif +# endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -556,11 +561,11 @@ using ::truncl _LIBCPP_USING_IF_EXISTS; template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isinf(_A1 __lcpp_x) _NOEXCEPT { -#if __has_builtin(__builtin_isinf) +# if __has_builtin(__builtin_isinf) return __builtin_isinf(__lcpp_x); -#else +# else return isinf(__lcpp_x); -#endif +# endif } template ::value, int> = 0> @@ -568,7 +573,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isinf(_A1 __lcpp_x) _NO return std::isinf(__lcpp_x); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template _LIBCPP_HIDE_FROM_ABI constexpr _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept { if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0)) @@ -605,14 +610,15 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr _IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && _IsSame<_A3, __result_type>::value)); return std::__lerp((__result_type)__a, (__result_type)__b, (__result_type)__t); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CMATH diff --git a/libcxx/include/codecvt b/libcxx/include/codecvt index 65cd752d69460e7..c8aff8d00006196 100644 --- a/libcxx/include/codecvt +++ b/libcxx/include/codecvt @@ -54,15 +54,20 @@ class codecvt_utf8_utf16 */ -#include <__config> -#include <__locale> -#include +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/codecvt> +#else +# include <__config> +# include <__locale> +# include -#if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT) +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT) _LIBCPP_BEGIN_NAMESPACE_STD @@ -73,7 +78,7 @@ enum _LIBCPP_DEPRECATED_IN_CXX17 codecvt_mode { consume_header = 4, generate_hea template class __codecvt_utf8; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8 : public codecvt { unsigned long __maxcode_; @@ -112,7 +117,7 @@ protected: int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; int do_max_length() const _NOEXCEPT override; }; -# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS +# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> @@ -203,7 +208,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP template class __codecvt_utf16; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16 : public codecvt { unsigned long __maxcode_; @@ -281,7 +286,7 @@ protected: int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; int do_max_length() const _NOEXCEPT override; }; -# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS +# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> @@ -437,7 +442,8 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16 : public __codecvt_utf16<_Elem, _Mode & little_endian> { public: _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf16(size_t __refs = 0) - : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {} + : __codecvt_utf16 < _Elem, + _Mode & little_endian > (__refs, _Maxcode, _Mode) {} _LIBCPP_HIDE_FROM_ABI ~codecvt_utf16() {} }; @@ -448,7 +454,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP template class __codecvt_utf8_utf16; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8_utf16 : public codecvt { unsigned long __maxcode_; @@ -487,7 +493,7 @@ protected: int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; int do_max_length() const _NOEXCEPT override; }; -# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS +# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> @@ -576,22 +582,23 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT) - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif +# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT) + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CODECVT diff --git a/libcxx/include/compare b/libcxx/include/compare index 8a41835b148978c..98cbe0e29131015 100644 --- a/libcxx/include/compare +++ b/libcxx/include/compare @@ -140,39 +140,45 @@ namespace std { } */ -#include <__config> - -#if _LIBCPP_STD_VER >= 20 -# include <__compare/common_comparison_category.h> -# include <__compare/compare_partial_order_fallback.h> -# include <__compare/compare_strong_order_fallback.h> -# include <__compare/compare_three_way.h> -# include <__compare/compare_three_way_result.h> -# include <__compare/compare_weak_order_fallback.h> -# include <__compare/is_eq.h> -# include <__compare/ordering.h> -# include <__compare/partial_order.h> -# include <__compare/strong_order.h> -# include <__compare/synth_three_way.h> -# include <__compare/three_way_comparable.h> -# include <__compare/weak_order.h> -#endif // _LIBCPP_STD_VER >= 20 - -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 -# include -# include -# include -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/compare> +#else +# include <__config> + +# if _LIBCPP_STD_VER >= 20 +# include <__compare/common_comparison_category.h> +# include <__compare/compare_partial_order_fallback.h> +# include <__compare/compare_strong_order_fallback.h> +# include <__compare/compare_three_way.h> +# include <__compare/compare_three_way_result.h> +# include <__compare/compare_weak_order_fallback.h> +# include <__compare/is_eq.h> +# include <__compare/ordering.h> +# include <__compare/partial_order.h> +# include <__compare/strong_order.h> +# include <__compare/synth_three_way.h> +# include <__compare/three_way_comparable.h> +# include <__compare/weak_order.h> +# endif // _LIBCPP_STD_VER >= 20 + +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 +# include +# include +# include +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_COMPARE diff --git a/libcxx/include/complex b/libcxx/include/complex index 15e42800fbfa0a6..e883b710e19169f 100644 --- a/libcxx/include/complex +++ b/libcxx/include/complex @@ -256,26 +256,31 @@ template complex tanh (const complex&); */ -#include <__config> -#include <__fwd/complex.h> -#include <__fwd/tuple.h> -#include <__tuple/tuple_element.h> -#include <__tuple/tuple_size.h> -#include <__type_traits/conditional.h> -#include <__utility/move.h> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include // for std::basic_ostringstream -#endif - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/complex> +#else +# include <__config> +# include <__fwd/complex.h> +# include <__fwd/tuple.h> +# include <__tuple/tuple_element.h> +# include <__tuple/tuple_size.h> +# include <__type_traits/conditional.h> +# include <__utility/move.h> +# include +# include + +# if !defined(_LIBCPP_HAS_NO_LOCALIZATION) +# include // for std::basic_ostringstream +# endif + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -374,7 +379,7 @@ public: return *this; } -#if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept; @@ -386,7 +391,7 @@ public: template friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept; -#endif +# endif }; template <> @@ -404,11 +409,11 @@ using __complex_t = template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __complex_t<_Tp> __make_complex(_Tp __re, _Tp __im) { -#if __has_builtin(__builtin_complex) +# if __has_builtin(__builtin_complex) return __builtin_complex(__re, __im); -#else +# else return __complex_t<_Tp>{__re, __im}; -#endif +# endif } template <> @@ -493,7 +498,7 @@ public: return *this; } -#if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept; @@ -505,7 +510,7 @@ public: template friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept; -#endif +# endif }; template <> @@ -593,7 +598,7 @@ public: return *this; } -#if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept; @@ -605,7 +610,7 @@ public: template friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept; -#endif +# endif }; template <> @@ -694,7 +699,7 @@ public: return *this; } -#if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept; @@ -706,7 +711,7 @@ public: template friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept; -#endif +# endif }; inline _LIBCPP_CONSTEXPR complex::complex(const complex& __c) : __re_(__c.real()), __im_(__c.imag()) {} @@ -861,7 +866,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator==(const return __x.real() == __y && __x.imag() == 0; } -#if _LIBCPP_STD_VER <= 17 +# if _LIBCPP_STD_VER <= 17 template inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator==(const _Tp& __x, const complex<_Tp>& __y) { @@ -884,7 +889,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator!=(const return !(__x == __y); } -#endif +# endif // 26.3.7 values: @@ -1322,7 +1327,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> tan(const complex<_Tp>& __x) { return complex<_Tp>(__z.imag(), -__z.real()); } -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) +# if !defined(_LIBCPP_HAS_NO_LOCALIZATION) template _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) { @@ -1379,9 +1384,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) { __s << '(' << __x.real() << ',' << __x.imag() << ')'; return __os << __s.str(); } -#endif // !_LIBCPP_HAS_NO_LOCALIZATION +# endif // !_LIBCPP_HAS_NO_LOCALIZATION -#if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 // [complex.tuple], tuple interface @@ -1434,9 +1439,9 @@ _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&& __z) noexce } } -#endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 // Literal suffix for complex number literals [complex.literals] inline namespace literals { inline namespace complex_literals { @@ -1463,16 +1468,17 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr complex operator""if(unsigned long } } // namespace complex_literals } // namespace literals -#endif +# endif _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_COMPLEX diff --git a/libcxx/include/complex.h b/libcxx/include/complex.h index 89595ae2068a641..4c8518a66dd04ca 100644 --- a/libcxx/include/complex.h +++ b/libcxx/include/complex.h @@ -17,16 +17,22 @@ */ -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#ifdef __cplusplus -# include -#elif __has_include_next() -# include_next -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/complex.h> +#else +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# ifdef __cplusplus +# include +# elif __has_include_next() +# include_next +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_COMPLEX_H diff --git a/libcxx/include/concepts b/libcxx/include/concepts index e89d216a593725f..ed7991adaf86494 100644 --- a/libcxx/include/concepts +++ b/libcxx/include/concepts @@ -129,45 +129,51 @@ namespace std { */ -#include <__config> - -#if _LIBCPP_STD_VER >= 20 -# include <__concepts/arithmetic.h> -# include <__concepts/assignable.h> -# include <__concepts/boolean_testable.h> -# include <__concepts/class_or_enum.h> -# include <__concepts/common_reference_with.h> -# include <__concepts/common_with.h> -# include <__concepts/constructible.h> -# include <__concepts/convertible_to.h> -# include <__concepts/copyable.h> -# include <__concepts/derived_from.h> -# include <__concepts/destructible.h> -# include <__concepts/different_from.h> -# include <__concepts/equality_comparable.h> -# include <__concepts/invocable.h> -# include <__concepts/movable.h> -# include <__concepts/predicate.h> -# include <__concepts/regular.h> -# include <__concepts/relation.h> -# include <__concepts/same_as.h> -# include <__concepts/semiregular.h> -# include <__concepts/swappable.h> -# include <__concepts/totally_ordered.h> -#endif // _LIBCPP_STD_VER >= 20 - -#include - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 -# include -#endif - -#if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) -# include -#endif - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/algorithm> +#else +# include <__config> + +# if _LIBCPP_STD_VER >= 20 +# include <__concepts/arithmetic.h> +# include <__concepts/assignable.h> +# include <__concepts/boolean_testable.h> +# include <__concepts/class_or_enum.h> +# include <__concepts/common_reference_with.h> +# include <__concepts/common_with.h> +# include <__concepts/constructible.h> +# include <__concepts/convertible_to.h> +# include <__concepts/copyable.h> +# include <__concepts/derived_from.h> +# include <__concepts/destructible.h> +# include <__concepts/different_from.h> +# include <__concepts/equality_comparable.h> +# include <__concepts/invocable.h> +# include <__concepts/movable.h> +# include <__concepts/predicate.h> +# include <__concepts/regular.h> +# include <__concepts/relation.h> +# include <__concepts/same_as.h> +# include <__concepts/semiregular.h> +# include <__concepts/swappable.h> +# include <__concepts/totally_ordered.h> +# endif // _LIBCPP_STD_VER >= 20 + +# include + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 +# include +# endif + +# if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) +# include +# endif + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CONCEPTS diff --git a/libcxx/include/condition_variable b/libcxx/include/condition_variable index 229a2ce103b5edb..afdbe154f5f7a81 100644 --- a/libcxx/include/condition_variable +++ b/libcxx/include/condition_variable @@ -118,29 +118,34 @@ public: */ -#include <__chrono/duration.h> -#include <__chrono/steady_clock.h> -#include <__chrono/time_point.h> -#include <__condition_variable/condition_variable.h> -#include <__config> -#include <__memory/shared_ptr.h> -#include <__mutex/lock_guard.h> -#include <__mutex/mutex.h> -#include <__mutex/tag_types.h> -#include <__mutex/unique_lock.h> -#include <__stop_token/stop_callback.h> -#include <__stop_token/stop_token.h> -#include <__utility/move.h> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/condition_variable> +#else +# include <__chrono/duration.h> +# include <__chrono/steady_clock.h> +# include <__chrono/time_point.h> +# include <__condition_variable/condition_variable.h> +# include <__config> +# include <__memory/shared_ptr.h> +# include <__mutex/lock_guard.h> +# include <__mutex/mutex.h> +# include <__mutex/tag_types.h> +# include <__mutex/unique_lock.h> +# include <__stop_token/stop_callback.h> +# include <__stop_token/stop_token.h> +# include <__utility/move.h> +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> -#ifndef _LIBCPP_HAS_NO_THREADS +# ifndef _LIBCPP_HAS_NO_THREADS _LIBCPP_BEGIN_NAMESPACE_STD @@ -173,7 +178,7 @@ public: template bool _LIBCPP_HIDE_FROM_ABI wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred); -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool wait(_Lock& __lock, stop_token __stoken, _Predicate __pred); @@ -186,18 +191,22 @@ public: _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool wait_for(_Lock& __lock, stop_token __stoken, const chrono::duration<_Rep, _Period>& __rel_time, _Predicate __pred); -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 }; inline condition_variable_any::condition_variable_any() : __mut_(make_shared()) {} inline void condition_variable_any::notify_one() _NOEXCEPT { - { lock_guard __lx(*__mut_); } + { + lock_guard __lx(*__mut_); + } __cv_.notify_one(); } inline void condition_variable_any::notify_all() _NOEXCEPT { - { lock_guard __lx(*__mut_); } + { + lock_guard __lx(*__mut_); + } __cv_.notify_all(); } @@ -260,7 +269,7 @@ condition_variable_any::wait_for(_Lock& __lock, const chrono::duration<_Rep, _Pe return wait_until(__lock, chrono::steady_clock::now() + __d, std::move(__pred)); } -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template bool condition_variable_any::wait(_Lock& __user_lock, stop_token __stoken, _Predicate __pred) { @@ -341,29 +350,30 @@ bool condition_variable_any::wait_for( return wait_until(__lock, std::move(__stoken), chrono::steady_clock::now() + __rel_time, std::move(__pred)); } -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_EXPORTED_FROM_ABI void notify_all_at_thread_exit(condition_variable&, unique_lock); _LIBCPP_END_NAMESPACE_STD -#endif // !_LIBCPP_HAS_NO_THREADS +# endif // !_LIBCPP_HAS_NO_THREADS _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CONDITION_VARIABLE diff --git a/libcxx/include/coroutine b/libcxx/include/coroutine index ee54388ad5aaf85..c75e9ca0c515757 100644 --- a/libcxx/include/coroutine +++ b/libcxx/include/coroutine @@ -38,30 +38,36 @@ struct suspend_always; */ -#include <__config> +#include <__configuration/cxx03.h> -#if _LIBCPP_STD_VER >= 20 -# include <__coroutine/coroutine_handle.h> -# include <__coroutine/coroutine_traits.h> -# include <__coroutine/noop_coroutine_handle.h> -# include <__coroutine/trivial_awaitables.h> -#endif // _LIBCPP_STD_VER >= 20 +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/coroutine> +#else +# include <__config> -#include +# if _LIBCPP_STD_VER >= 20 +# include <__coroutine/coroutine_handle.h> +# include <__coroutine/coroutine_traits.h> +# include <__coroutine/noop_coroutine_handle.h> +# include <__coroutine/trivial_awaitables.h> +# endif // _LIBCPP_STD_VER >= 20 + +# include // standard-mandated includes // [coroutine.syn] -#include +# include -#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -# pragma GCC system_header -#endif +# ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER +# pragma GCC system_header +# endif -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_COROUTINE diff --git a/libcxx/include/csetjmp b/libcxx/include/csetjmp index 7ba90068710aea5..c731e523ef39ae5 100644 --- a/libcxx/include/csetjmp +++ b/libcxx/include/csetjmp @@ -30,19 +30,24 @@ void longjmp(jmp_buf env, int val); */ -#include <__config> +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/csetjmp> +#else +# include <__config> // is not provided by libc++ -#if __has_include() -# include -# ifdef _LIBCPP_SETJMP_H -# error "If libc++ starts defining , the __has_include check should move to libc++'s " +# if __has_include() +# include +# ifdef _LIBCPP_SETJMP_H +# error "If libc++ starts defining , the __has_include check should move to libc++'s " +# endif # endif -#endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -50,5 +55,6 @@ using ::jmp_buf _LIBCPP_USING_IF_EXISTS; using ::longjmp _LIBCPP_USING_IF_EXISTS; _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CSETJMP diff --git a/libcxx/include/csignal b/libcxx/include/csignal index 804a7f95ae9682d..22f98867fa95f86 100644 --- a/libcxx/include/csignal +++ b/libcxx/include/csignal @@ -39,19 +39,24 @@ int raise(int sig); */ -#include <__config> +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/csignal> +#else +# include <__config> // is not provided by libc++ -#if __has_include() -# include -# ifdef _LIBCPP_SIGNAL_H -# error "If libc++ starts defining , the __has_include check should move to libc++'s " +# if __has_include() +# include +# ifdef _LIBCPP_SIGNAL_H +# error "If libc++ starts defining , the __has_include check should move to libc++'s " +# endif # endif -#endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -60,5 +65,6 @@ using ::signal _LIBCPP_USING_IF_EXISTS; using ::raise _LIBCPP_USING_IF_EXISTS; _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CSIGNAL diff --git a/libcxx/include/cstdarg b/libcxx/include/cstdarg index 4642eb7b5258ca8..675a19f601e8c92 100644 --- a/libcxx/include/cstdarg +++ b/libcxx/include/cstdarg @@ -31,24 +31,30 @@ Types: */ -#include <__config> +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/cstdarg> +#else +# include <__config> // is not provided by libc++ -#if __has_include() -# include -# ifdef _LIBCPP_STDARG_H -# error "If libc++ starts defining , the __has_include check should move to libc++'s " +# if __has_include() +# include +# ifdef _LIBCPP_STDARG_H +# error "If libc++ starts defining , the __has_include check should move to libc++'s " +# endif # endif -#endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD using ::va_list _LIBCPP_USING_IF_EXISTS; _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CSTDARG diff --git a/libcxx/include/cstdbool b/libcxx/include/cstdbool index 1d627258e10c094..3e27f68d821239e 100644 --- a/libcxx/include/cstdbool +++ b/libcxx/include/cstdbool @@ -19,14 +19,20 @@ Macros: */ -#include <__config> +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/cstdbool> +#else +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif -#undef __bool_true_false_are_defined -#define __bool_true_false_are_defined 1 +# undef __bool_true_false_are_defined +# define __bool_true_false_are_defined 1 +#endif // _LIBCPP_CXX03_LANG #if _LIBCPP_STD_VER >= 20 diff --git a/libcxx/include/cstddef b/libcxx/include/cstddef index 2b138d9690393f8..0a18ed24c61039c 100644 --- a/libcxx/include/cstddef +++ b/libcxx/include/cstddef @@ -33,27 +33,33 @@ Types: */ -#include <__config> -#include +#include <__configuration/cxx03.h> -#include +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/cstddef> +#else +# include <__config> +# include -#ifndef _LIBCPP_STDDEF_H +# include + +# ifndef _LIBCPP_STDDEF_H # error tried including but didn't find libc++'s header. \ This usually means that your header search paths are not configured properly. \ The header search paths should contain the C++ Standard Library headers before \ any C Standard Library, and you are probably using compiler flags that make that \ not be the case. -#endif +# endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif -#include <__cstddef/byte.h> -#include <__cstddef/max_align_t.h> -#include <__cstddef/nullptr_t.h> -#include <__cstddef/ptrdiff_t.h> -#include <__cstddef/size_t.h> +# include <__cstddef/byte.h> +# include <__cstddef/max_align_t.h> +# include <__cstddef/nullptr_t.h> +# include <__cstddef/ptrdiff_t.h> +# include <__cstddef/size_t.h> +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CSTDDEF diff --git a/libcxx/include/cstdint b/libcxx/include/cstdint index 9c9b2323d06ea92..1a3004daec25e50 100644 --- a/libcxx/include/cstdint +++ b/libcxx/include/cstdint @@ -140,13 +140,26 @@ Types: } // std */ -#include <__config> +#include <__configuration/cxx03.h> -#include +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/cstdint> +#else +# include <__config> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# include + +# ifndef _LIBCPP_STDINT_H +# error tried including but didn't find libc++'s header. \ + This usually means that your header search paths are not configured properly. \ + The header search paths should contain the C++ Standard Library headers before \ + any C Standard Library, and you are probably using compiler flags that make that \ + not be the case. +# endif + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -187,5 +200,6 @@ using ::intmax_t _LIBCPP_USING_IF_EXISTS; using ::uintmax_t _LIBCPP_USING_IF_EXISTS; _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CSTDINT diff --git a/libcxx/include/cstdio b/libcxx/include/cstdio index a461c24dcc01930..763b3e7a4bf7c4e 100644 --- a/libcxx/include/cstdio +++ b/libcxx/include/cstdio @@ -95,22 +95,27 @@ void perror(const char* s); } // std */ -#include <__config> -#include <__cstddef/size_t.h> +#include <__configuration/cxx03.h> -#include +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/cstdio> +#else +# include <__config> +# include <__cstddef/size_t.h> -#ifndef _LIBCPP_STDIO_H +# include + +# ifndef _LIBCPP_STDIO_H # error tried including but didn't find libc++'s header. \ This usually means that your header search paths are not configured properly. \ The header search paths should contain the C++ Standard Library headers before \ any C Standard Library, and you are probably using compiler flags that make that \ not be the case. -#endif +# endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -158,9 +163,9 @@ using ::tmpfile _LIBCPP_USING_IF_EXISTS; using ::tmpnam _LIBCPP_USING_IF_EXISTS; using ::getchar _LIBCPP_USING_IF_EXISTS; -#if _LIBCPP_STD_VER <= 11 +# if _LIBCPP_STD_VER <= 11 using ::gets _LIBCPP_USING_IF_EXISTS; -#endif +# endif using ::scanf _LIBCPP_USING_IF_EXISTS; using ::vscanf _LIBCPP_USING_IF_EXISTS; @@ -170,5 +175,6 @@ using ::puts _LIBCPP_USING_IF_EXISTS; using ::vprintf _LIBCPP_USING_IF_EXISTS; _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CSTDIO diff --git a/libcxx/include/cstdlib b/libcxx/include/cstdlib index 1ecdd3a6d0328cd..573c0defb3ac8b1 100644 --- a/libcxx/include/cstdlib +++ b/libcxx/include/cstdlib @@ -81,22 +81,27 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 */ -#include <__config> -#include <__cstddef/size_t.h> +#include <__configuration/cxx03.h> -#include +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/cstdlib> +#else +# include <__config> +# include <__cstddef/size_t.h> -#ifndef _LIBCPP_STDLIB_H +# include + +# ifndef _LIBCPP_STDLIB_H # error tried including but didn't find libc++'s header. \ This usually means that your header search paths are not configured properly. \ The header search paths should contain the C++ Standard Library headers before \ any C Standard Library, and you are probably using compiler flags that make that \ not be the case. -#endif +# endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -135,20 +140,21 @@ using ::div _LIBCPP_USING_IF_EXISTS; using ::ldiv _LIBCPP_USING_IF_EXISTS; using ::lldiv _LIBCPP_USING_IF_EXISTS; using ::mblen _LIBCPP_USING_IF_EXISTS; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using ::mbtowc _LIBCPP_USING_IF_EXISTS; using ::wctomb _LIBCPP_USING_IF_EXISTS; using ::mbstowcs _LIBCPP_USING_IF_EXISTS; using ::wcstombs _LIBCPP_USING_IF_EXISTS; -#endif -#if !defined(_LIBCPP_CXX03_LANG) +# endif +# if !defined(_LIBCPP_CXX03_LANG) using ::at_quick_exit _LIBCPP_USING_IF_EXISTS; using ::quick_exit _LIBCPP_USING_IF_EXISTS; -#endif -#if _LIBCPP_STD_VER >= 17 +# endif +# if _LIBCPP_STD_VER >= 17 using ::aligned_alloc _LIBCPP_USING_IF_EXISTS; -#endif +# endif _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CSTDLIB diff --git a/libcxx/include/cstring b/libcxx/include/cstring index 5bb6e3e10628f21..9d2b4d2ec06a25e 100644 --- a/libcxx/include/cstring +++ b/libcxx/include/cstring @@ -56,23 +56,28 @@ size_t strlen(const char* s); */ -#include <__config> -#include <__cstddef/size_t.h> -#include <__type_traits/is_constant_evaluated.h> +#include <__configuration/cxx03.h> -#include +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/cstring> +#else +# include <__config> +# include <__cstddef/size_t.h> +# include <__type_traits/is_constant_evaluated.h> -#ifndef _LIBCPP_STRING_H +# include + +# ifndef _LIBCPP_STRING_H # error tried including but didn't find libc++'s header. \ This usually means that your header search paths are not configured properly. \ The header search paths should contain the C++ Standard Library headers before \ any C Standard Library, and you are probably using compiler flags that make that \ not be the case. -#endif +# endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -100,5 +105,6 @@ using ::strerror _LIBCPP_USING_IF_EXISTS; using ::strlen _LIBCPP_USING_IF_EXISTS; _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CSTRING diff --git a/libcxx/include/ctgmath b/libcxx/include/ctgmath index 7dbe952f021b74f..3b25be50712ffd7 100644 --- a/libcxx/include/ctgmath +++ b/libcxx/include/ctgmath @@ -18,12 +18,18 @@ */ -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/ctgmath> +#else +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif +#endif // _LIBCPP_CXX03_LANG #if _LIBCPP_STD_VER >= 20 diff --git a/libcxx/include/ctime b/libcxx/include/ctime index d2d2470f2fa60b4..dc1f8fb23c77bf9 100644 --- a/libcxx/include/ctime +++ b/libcxx/include/ctime @@ -45,29 +45,34 @@ int timespec_get( struct timespec *ts, int base); // C++17 */ -#include <__config> -#include <__cstddef/size_t.h> +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/ctime> +#else +# include <__config> +# include <__cstddef/size_t.h> // is not provided by libc++ -#if __has_include() -# include -# ifdef _LIBCPP_TIME_H -# error "If libc++ starts defining , the __has_include check should move to libc++'s " +# if __has_include() +# include +# ifdef _LIBCPP_TIME_H +# error "If libc++ starts defining , the __has_include check should move to libc++'s " +# endif # endif -#endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD using ::clock_t _LIBCPP_USING_IF_EXISTS; using ::time_t _LIBCPP_USING_IF_EXISTS; using ::tm _LIBCPP_USING_IF_EXISTS; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 using ::timespec _LIBCPP_USING_IF_EXISTS; -#endif +# endif using ::clock _LIBCPP_USING_IF_EXISTS; using ::difftime _LIBCPP_USING_IF_EXISTS; using ::mktime _LIBCPP_USING_IF_EXISTS; @@ -77,10 +82,11 @@ using ::ctime _LIBCPP_USING_IF_EXISTS; using ::gmtime _LIBCPP_USING_IF_EXISTS; using ::localtime _LIBCPP_USING_IF_EXISTS; using ::strftime _LIBCPP_USING_IF_EXISTS; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 using ::timespec_get _LIBCPP_USING_IF_EXISTS; -#endif +# endif _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CTIME diff --git a/libcxx/include/ctype.h b/libcxx/include/ctype.h index 448e4410c554f14..a10f3b7ca532133 100644 --- a/libcxx/include/ctype.h +++ b/libcxx/include/ctype.h @@ -29,33 +29,39 @@ int tolower(int c); int toupper(int c); */ -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if __has_include_next() -# include_next -#endif - -#ifdef __cplusplus - -# undef isalnum -# undef isalpha -# undef isblank -# undef iscntrl -# undef isdigit -# undef isgraph -# undef islower -# undef isprint -# undef ispunct -# undef isspace -# undef isupper -# undef isxdigit -# undef tolower -# undef toupper - -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/ctype.h> +#else +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if __has_include_next() +# include_next +# endif + +# ifdef __cplusplus + +# undef isalnum +# undef isalpha +# undef isblank +# undef iscntrl +# undef isdigit +# undef isgraph +# undef islower +# undef isprint +# undef ispunct +# undef isspace +# undef isupper +# undef isxdigit +# undef tolower +# undef toupper + +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CTYPE_H diff --git a/libcxx/include/cuchar b/libcxx/include/cuchar index 1d156eb7aaaf35e..76660e1745c64ad 100644 --- a/libcxx/include/cuchar +++ b/libcxx/include/cuchar @@ -36,40 +36,46 @@ size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps); */ -#include <__config> -#include <__cstddef/size_t.h> +#include <__configuration/cxx03.h> -#include +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/cuchar> +#else +# include <__config> +# include <__cstddef/size_t.h> -#ifndef _LIBCPP_UCHAR_H +# include + +# ifndef _LIBCPP_UCHAR_H # error tried including but didn't find libc++'s header. \ This usually means that your header search paths are not configured properly. \ The header search paths should contain the C++ Standard Library headers before \ any C Standard Library, and you are probably using compiler flags that make that \ not be the case. -#endif +# endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_CXX03_LANG) +# if !defined(_LIBCPP_CXX03_LANG) using ::mbstate_t _LIBCPP_USING_IF_EXISTS; -# if _LIBCPP_HAS_C8RTOMB_MBRTOC8 +# if _LIBCPP_HAS_C8RTOMB_MBRTOC8 using ::mbrtoc8 _LIBCPP_USING_IF_EXISTS; using ::c8rtomb _LIBCPP_USING_IF_EXISTS; -# endif +# endif using ::mbrtoc16 _LIBCPP_USING_IF_EXISTS; using ::c16rtomb _LIBCPP_USING_IF_EXISTS; using ::mbrtoc32 _LIBCPP_USING_IF_EXISTS; using ::c32rtomb _LIBCPP_USING_IF_EXISTS; -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CUCHAR diff --git a/libcxx/include/cwchar b/libcxx/include/cwchar index f5a26664c1c3e4a..17f1d1a41511c1f 100644 --- a/libcxx/include/cwchar +++ b/libcxx/include/cwchar @@ -102,28 +102,33 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, */ -#include <__config> -#include <__cstddef/size_t.h> -#include <__type_traits/copy_cv.h> -#include <__type_traits/is_constant_evaluated.h> -#include <__type_traits/is_equality_comparable.h> -#include <__type_traits/is_same.h> -#include <__type_traits/remove_cv.h> -#include +#include <__configuration/cxx03.h> -#include +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/cwchar> +#else +# include <__config> +# include <__cstddef/size_t.h> +# include <__type_traits/copy_cv.h> +# include <__type_traits/is_constant_evaluated.h> +# include <__type_traits/is_equality_comparable.h> +# include <__type_traits/is_same.h> +# include <__type_traits/remove_cv.h> +# include + +# include -#ifndef _LIBCPP_WCHAR_H +# ifndef _LIBCPP_WCHAR_H # error tried including but didn't find libc++'s header. \ This usually means that your header search paths are not configured properly. \ The header search paths should contain the C++ Standard Library headers before \ any C Standard Library, and you are probably using compiler flags that make that \ not be the case. -#endif +# endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -194,9 +199,9 @@ using ::vwprintf _LIBCPP_USING_IF_EXISTS; using ::wprintf _LIBCPP_USING_IF_EXISTS; inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_wcslen(const wchar_t* __str) { -#if __has_builtin(__builtin_wcslen) +# if __has_builtin(__builtin_wcslen) return __builtin_wcslen(__str); -#else +# else if (!__libcpp_is_constant_evaluated()) return std::wcslen(__str); @@ -204,14 +209,14 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_wc for (; *__str != L'\0'; ++__str) ++__len; return __len; -#endif +# endif } inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __constexpr_wmemcmp(const wchar_t* __lhs, const wchar_t* __rhs, size_t __count) { -#if __has_builtin(__builtin_wmemcmp) +# if __has_builtin(__builtin_wmemcmp) return __builtin_wmemcmp(__lhs, __rhs, __count); -#else +# else if (!__libcpp_is_constant_evaluated()) return std::wmemcmp(__lhs, __rhs, __count); @@ -222,7 +227,7 @@ __constexpr_wmemcmp(const wchar_t* __lhs, const wchar_t* __rhs, size_t __count) return 1; } return 0; -#endif +# endif } template @@ -231,18 +236,18 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp __libcpp_is_trivially_equality_comparable<_Tp, _Tp>::value, "Calling wmemchr on non-trivially equality comparable types is unsafe."); -#if __has_builtin(__builtin_wmemchr) +# if __has_builtin(__builtin_wmemchr) if (!__libcpp_is_constant_evaluated()) { wchar_t __value_buffer = 0; __builtin_memcpy(&__value_buffer, &__value, sizeof(wchar_t)); return reinterpret_cast<_Tp*>( __builtin_wmemchr(reinterpret_cast<__copy_cv_t<_Tp, wchar_t>*>(__str), __value_buffer, __count)); } -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 else if constexpr (is_same_v, wchar_t>) return __builtin_wmemchr(__str, __value, __count); -# endif -#endif // __has_builtin(__builtin_wmemchr) +# endif +# endif // __has_builtin(__builtin_wmemchr) for (; __count; --__count) { if (*__str == __value) @@ -254,8 +259,9 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp _LIBCPP_END_NAMESPACE_STD -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CWCHAR diff --git a/libcxx/include/cwctype b/libcxx/include/cwctype index 04abfabef579337..6de0c5fb4532f21 100644 --- a/libcxx/include/cwctype +++ b/libcxx/include/cwctype @@ -49,26 +49,31 @@ wctrans_t wctrans(const char* property); */ -#include <__config> -#include +#include <__configuration/cxx03.h> -#include +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/cwctype> +#else +# include <__config> +# include -#ifndef _LIBCPP_WCTYPE_H +# include + +# ifndef _LIBCPP_WCTYPE_H # error tried including but didn't find libc++'s header. \ This usually means that your header search paths are not configured properly. \ The header search paths should contain the C++ Standard Library headers before \ any C Standard Library, and you are probably using compiler flags that make that \ not be the case. -#endif +# endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD -#if defined(_LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H) +# if defined(_LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H) using ::wint_t _LIBCPP_USING_IF_EXISTS; using ::wctrans_t _LIBCPP_USING_IF_EXISTS; using ::wctype_t _LIBCPP_USING_IF_EXISTS; @@ -90,8 +95,9 @@ using ::towlower _LIBCPP_USING_IF_EXISTS; using ::towupper _LIBCPP_USING_IF_EXISTS; using ::towctrans _LIBCPP_USING_IF_EXISTS; using ::wctrans _LIBCPP_USING_IF_EXISTS; -#endif // _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H +# endif // _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_CWCTYPE diff --git a/libcxx/include/deque b/libcxx/include/deque index 11219d1a99244ee..8358b986bc0a82b 100644 --- a/libcxx/include/deque +++ b/libcxx/include/deque @@ -177,87 +177,92 @@ template */ -#include <__algorithm/copy.h> -#include <__algorithm/copy_backward.h> -#include <__algorithm/copy_n.h> -#include <__algorithm/equal.h> -#include <__algorithm/fill_n.h> -#include <__algorithm/lexicographical_compare.h> -#include <__algorithm/lexicographical_compare_three_way.h> -#include <__algorithm/max.h> -#include <__algorithm/min.h> -#include <__algorithm/move.h> -#include <__algorithm/move_backward.h> -#include <__algorithm/remove.h> -#include <__algorithm/remove_if.h> -#include <__algorithm/unwrap_iter.h> -#include <__assert> -#include <__config> -#include <__debug_utils/sanitizers.h> -#include <__format/enable_insertable.h> -#include <__fwd/deque.h> -#include <__iterator/distance.h> -#include <__iterator/iterator_traits.h> -#include <__iterator/move_iterator.h> -#include <__iterator/next.h> -#include <__iterator/prev.h> -#include <__iterator/reverse_iterator.h> -#include <__iterator/segmented_iterator.h> -#include <__memory/addressof.h> -#include <__memory/allocator.h> -#include <__memory/allocator_destructor.h> -#include <__memory/allocator_traits.h> -#include <__memory/compressed_pair.h> -#include <__memory/pointer_traits.h> -#include <__memory/swap_allocator.h> -#include <__memory/temp_value.h> -#include <__memory/unique_ptr.h> -#include <__memory_resource/polymorphic_allocator.h> -#include <__ranges/access.h> -#include <__ranges/concepts.h> -#include <__ranges/container_compatible_range.h> -#include <__ranges/from_range.h> -#include <__ranges/size.h> -#include <__split_buffer> -#include <__type_traits/conditional.h> -#include <__type_traits/container_traits.h> -#include <__type_traits/disjunction.h> -#include <__type_traits/enable_if.h> -#include <__type_traits/is_allocator.h> -#include <__type_traits/is_convertible.h> -#include <__type_traits/is_nothrow_assignable.h> -#include <__type_traits/is_nothrow_constructible.h> -#include <__type_traits/is_same.h> -#include <__type_traits/is_swappable.h> -#include <__type_traits/is_trivially_relocatable.h> -#include <__type_traits/type_identity.h> -#include <__utility/forward.h> -#include <__utility/move.h> -#include <__utility/pair.h> -#include <__utility/swap.h> -#include -#include -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/deque> +#else +# include <__algorithm/copy.h> +# include <__algorithm/copy_backward.h> +# include <__algorithm/copy_n.h> +# include <__algorithm/equal.h> +# include <__algorithm/fill_n.h> +# include <__algorithm/lexicographical_compare.h> +# include <__algorithm/lexicographical_compare_three_way.h> +# include <__algorithm/max.h> +# include <__algorithm/min.h> +# include <__algorithm/move.h> +# include <__algorithm/move_backward.h> +# include <__algorithm/remove.h> +# include <__algorithm/remove_if.h> +# include <__algorithm/unwrap_iter.h> +# include <__assert> +# include <__config> +# include <__debug_utils/sanitizers.h> +# include <__format/enable_insertable.h> +# include <__fwd/deque.h> +# include <__iterator/distance.h> +# include <__iterator/iterator_traits.h> +# include <__iterator/move_iterator.h> +# include <__iterator/next.h> +# include <__iterator/prev.h> +# include <__iterator/reverse_iterator.h> +# include <__iterator/segmented_iterator.h> +# include <__memory/addressof.h> +# include <__memory/allocator.h> +# include <__memory/allocator_destructor.h> +# include <__memory/allocator_traits.h> +# include <__memory/compressed_pair.h> +# include <__memory/pointer_traits.h> +# include <__memory/swap_allocator.h> +# include <__memory/temp_value.h> +# include <__memory/unique_ptr.h> +# include <__memory_resource/polymorphic_allocator.h> +# include <__ranges/access.h> +# include <__ranges/concepts.h> +# include <__ranges/container_compatible_range.h> +# include <__ranges/from_range.h> +# include <__ranges/size.h> +# include <__split_buffer> +# include <__type_traits/conditional.h> +# include <__type_traits/container_traits.h> +# include <__type_traits/disjunction.h> +# include <__type_traits/enable_if.h> +# include <__type_traits/is_allocator.h> +# include <__type_traits/is_convertible.h> +# include <__type_traits/is_nothrow_assignable.h> +# include <__type_traits/is_nothrow_constructible.h> +# include <__type_traits/is_same.h> +# include <__type_traits/is_swappable.h> +# include <__type_traits/is_trivially_relocatable.h> +# include <__type_traits/type_identity.h> +# include <__utility/forward.h> +# include <__utility/move.h> +# include <__utility/pair.h> +# include <__utility/swap.h> +# include +# include +# include // standard-mandated includes // [iterator.range] -#include <__iterator/access.h> -#include <__iterator/data.h> -#include <__iterator/empty.h> -#include <__iterator/reverse_access.h> -#include <__iterator/size.h> +# include <__iterator/access.h> +# include <__iterator/data.h> +# include <__iterator/empty.h> +# include <__iterator/reverse_access.h> +# include <__iterator/size.h> // [deque.syn] -#include -#include +# include +# include -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -272,13 +277,13 @@ template ::value -#endif +# endif > class _LIBCPP_TEMPLATE_VIS __deque_iterator { typedef _MapPointer __map_iterator; @@ -299,10 +304,10 @@ public: typedef _Reference reference; _LIBCPP_HIDE_FROM_ABI __deque_iterator() _NOEXCEPT -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 : __m_iter_(nullptr), __ptr_(nullptr) -#endif +# endif { } @@ -391,7 +396,7 @@ public: return __x.__ptr_ == __y.__ptr_; } -#if _LIBCPP_STD_VER <= 17 +# if _LIBCPP_STD_VER <= 17 _LIBCPP_HIDE_FROM_ABI friend bool operator!=(const __deque_iterator& __x, const __deque_iterator& __y) { return !(__x == __y); } @@ -411,7 +416,7 @@ public: return !(__x < __y); } -#else +# else _LIBCPP_HIDE_FROM_ABI friend strong_ordering operator<=>(const __deque_iterator& __x, const __deque_iterator& __y) { if (__x.__m_iter_ < __y.__m_iter_) @@ -433,7 +438,7 @@ public: return strong_ordering::greater; } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 private: _LIBCPP_HIDE_FROM_ABI explicit __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT @@ -621,9 +626,9 @@ public: } explicit _LIBCPP_HIDE_FROM_ABI deque(size_type __n); -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 explicit _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const _Allocator& __a); -#endif +# endif _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v); template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> @@ -639,7 +644,7 @@ public: template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI deque(_InputIter __f, _InputIter __l, const allocator_type& __a); -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> _LIBCPP_HIDE_FROM_ABI deque(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) { @@ -652,14 +657,14 @@ public: } } } -#endif +# endif _LIBCPP_HIDE_FROM_ABI deque(const deque& __c); _LIBCPP_HIDE_FROM_ABI deque(const deque& __c, const __type_identity_t& __a); _LIBCPP_HIDE_FROM_ABI deque& operator=(const deque& __c); -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI deque(initializer_list __il); _LIBCPP_HIDE_FROM_ABI deque(initializer_list __il, const allocator_type& __a); @@ -675,7 +680,7 @@ public: is_nothrow_move_assignable::value); _LIBCPP_HIDE_FROM_ABI void assign(initializer_list __il) { assign(__il.begin(), __il.end()); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template ::value && @@ -685,7 +690,7 @@ public: template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI void assign(_RAIter __f, _RAIter __l); -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) { if constexpr (ranges::random_access_range<_Range>) { @@ -700,7 +705,7 @@ public: __assign_with_sentinel(ranges::begin(__range), ranges::end(__range)); } } -#endif +# endif _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v); @@ -769,25 +774,25 @@ public: // 23.2.2.3 modifiers: _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __v); _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __v); -#ifndef _LIBCPP_CXX03_LANG -# if _LIBCPP_STD_VER >= 17 +# ifndef _LIBCPP_CXX03_LANG +# if _LIBCPP_STD_VER >= 17 template _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args); template _LIBCPP_HIDE_FROM_ABI reference emplace_back(_Args&&... __args); -# else +# else template _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args); template _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args); -# endif +# endif template _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __p, _Args&&... __args); _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __v); _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __v); -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) { insert_range(begin(), std::forward<_Range>(__range)); @@ -797,14 +802,14 @@ public: _LIBCPP_HIDE_FROM_ABI void append_range(_Range&& __range) { insert_range(end(), std::forward<_Range>(__range)); } -# endif +# endif _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v); _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, initializer_list __il) { return insert(__p, __il.begin(), __il.end()); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v); _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __v); template ::value, int> = 0> @@ -815,7 +820,7 @@ public: template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _BiIter __f, _BiIter __l); -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> _LIBCPP_HIDE_FROM_ABI iterator insert_range(const_iterator __position, _Range&& __range) { if constexpr (ranges::bidirectional_range<_Range>) { @@ -830,7 +835,7 @@ public: return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range)); } } -#endif +# endif _LIBCPP_HIDE_FROM_ABI void pop_front(); _LIBCPP_HIDE_FROM_ABI void pop_back(); @@ -838,11 +843,11 @@ public: _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l); _LIBCPP_HIDE_FROM_ABI void swap(deque& __c) -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 _NOEXCEPT; -#else +# else _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v); -#endif +# endif _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI bool __invariants() const { @@ -920,7 +925,7 @@ private: (void)__end; (void)__annotation_type; (void)__place; -#if _LIBCPP_HAS_ASAN +# if _LIBCPP_HAS_ASAN // __beg - index of the first item to annotate // __end - index behind the last item to annotate (so last item + 1) // __annotation_type - __asan_unposion or __asan_poison @@ -1013,23 +1018,23 @@ private: std::__annotate_double_ended_contiguous_container<_Allocator>( __mem_beg, __mem_end, __old_beg, __old_end, __new_beg, __new_end); } -#endif // _LIBCPP_HAS_ASAN +# endif // _LIBCPP_HAS_ASAN } _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT { (void)__current_size; -#if _LIBCPP_HAS_ASAN +# if _LIBCPP_HAS_ASAN if (__current_size == 0) __annotate_from_to(0, __map_.size() * __block_size, __asan_poison, __asan_back_moved); else { __annotate_from_to(0, __start_, __asan_poison, __asan_front_moved); __annotate_from_to(__start_ + __current_size, __map_.size() * __block_size, __asan_poison, __asan_back_moved); } -#endif // _LIBCPP_HAS_ASAN +# endif // _LIBCPP_HAS_ASAN } _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT { -#if _LIBCPP_HAS_ASAN +# if _LIBCPP_HAS_ASAN if (empty()) { for (size_t __i = 0; __i < __map_.size(); ++__i) { __annotate_whole_block(__i, __asan_unposion); @@ -1038,37 +1043,37 @@ private: __annotate_from_to(0, __start_, __asan_unposion, __asan_front_moved); __annotate_from_to(__start_ + size(), __map_.size() * __block_size, __asan_unposion, __asan_back_moved); } -#endif // _LIBCPP_HAS_ASAN +# endif // _LIBCPP_HAS_ASAN } _LIBCPP_HIDE_FROM_ABI void __annotate_increase_front(size_type __n) const _NOEXCEPT { (void)__n; -#if _LIBCPP_HAS_ASAN +# if _LIBCPP_HAS_ASAN __annotate_from_to(__start_ - __n, __start_, __asan_unposion, __asan_front_moved); -#endif +# endif } _LIBCPP_HIDE_FROM_ABI void __annotate_increase_back(size_type __n) const _NOEXCEPT { (void)__n; -#if _LIBCPP_HAS_ASAN +# if _LIBCPP_HAS_ASAN __annotate_from_to(__start_ + size(), __start_ + size() + __n, __asan_unposion, __asan_back_moved); -#endif +# endif } _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_front(size_type __old_size, size_type __old_start) const _NOEXCEPT { (void)__old_size; (void)__old_start; -#if _LIBCPP_HAS_ASAN +# if _LIBCPP_HAS_ASAN __annotate_from_to(__old_start, __old_start + (__old_size - size()), __asan_poison, __asan_front_moved); -#endif +# endif } _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_back(size_type __old_size, size_type __old_start) const _NOEXCEPT { (void)__old_size; (void)__old_start; -#if _LIBCPP_HAS_ASAN +# if _LIBCPP_HAS_ASAN __annotate_from_to(__old_start + size(), __old_start + __old_size, __asan_poison, __asan_back_moved); -#endif +# endif } _LIBCPP_HIDE_FROM_ABI void __annotate_poison_block(const void* __beginning, const void* __end) const _NOEXCEPT { @@ -1079,7 +1084,7 @@ private: __annotate_whole_block(size_t __block_index, __asan_annotation_type __annotation_type) const _NOEXCEPT { (void)__block_index; (void)__annotation_type; -#if _LIBCPP_HAS_ASAN +# if _LIBCPP_HAS_ASAN __map_const_iterator __block_it = __map_.begin() + __block_index; const void* __block_start = std::__to_address(*__block_it); const void* __block_end = std::__to_address(*__block_it + __block_size); @@ -1090,9 +1095,9 @@ private: std::__annotate_double_ended_contiguous_container<_Allocator>( __block_start, __block_end, __block_start, __block_start, __block_start, __block_end); } -#endif +# endif } -#if _LIBCPP_HAS_ASAN +# if _LIBCPP_HAS_ASAN public: _LIBCPP_HIDE_FROM_ABI bool __verify_asan_annotations() const _NOEXCEPT { @@ -1154,7 +1159,7 @@ public: } private: -#endif // _LIBCPP_HAS_ASAN +# endif // _LIBCPP_HAS_ASAN _LIBCPP_HIDE_FROM_ABI bool __maybe_remove_front_spare(bool __keep_one = true) { if (__front_spare_blocks() >= 2 || (!__keep_one && __front_spare_blocks())) { __annotate_whole_block(0, __asan_unposion); @@ -1244,7 +1249,7 @@ template _LIBCPP_CONSTEXPR const typename allocator_traits<_Alloc>::difference_type deque<_Tp, _Alloc>::__block_size = __deque_block_size::value; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template >, class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, @@ -1256,14 +1261,14 @@ template ::value>, class = enable_if_t<__is_allocator<_Alloc>::value> > deque(_InputIterator, _InputIterator, _Alloc) -> deque<__iter_value_type<_InputIterator>, _Alloc>; -#endif +# endif -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template >, class = enable_if_t<__is_allocator<_Alloc>::value> > deque(from_range_t, _Range&&, _Alloc = _Alloc()) -> deque, _Alloc>; -#endif +# endif template deque<_Tp, _Allocator>::deque(size_type __n) : __start_(0), __size_(0) { @@ -1272,7 +1277,7 @@ deque<_Tp, _Allocator>::deque(size_type __n) : __start_(0), __size_(0) { __append(__n); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a) : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) { @@ -1280,7 +1285,7 @@ deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a) if (__n > 0) __append(__n); } -#endif +# endif template deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v) : __start_(0), __size_(0) { @@ -1330,7 +1335,7 @@ deque<_Tp, _Allocator>& deque<_Tp, _Allocator>::operator=(const deque& __c) { return *this; } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template deque<_Tp, _Allocator>::deque(initializer_list __il) : __start_(0), __size_(0) { @@ -1398,7 +1403,7 @@ void deque<_Tp, _Allocator>::__move_assign(deque& __c, __move_assign(__c); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template template ::push_front(const value_type& __v) { ++__size(); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template void deque<_Tp, _Allocator>::push_back(value_type&& __v) { allocator_type& __a = __alloc(); @@ -1600,11 +1605,11 @@ void deque<_Tp, _Allocator>::push_back(value_type&& __v) { template template -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 typename deque<_Tp, _Allocator>::reference -# else +# else void -# endif +# endif deque<_Tp, _Allocator>::emplace_back(_Args&&... __args) { allocator_type& __a = __alloc(); if (__back_spare() == 0) @@ -1613,9 +1618,9 @@ deque<_Tp, _Allocator>::emplace_back(_Args&&... __args) { __annotate_increase_back(1); __alloc_traits::construct(__a, std::addressof(*end()), std::forward<_Args>(__args)...); ++__size(); -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 return *--end(); -# endif +# endif } template @@ -1632,11 +1637,11 @@ void deque<_Tp, _Allocator>::push_front(value_type&& __v) { template template -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 typename deque<_Tp, _Allocator>::reference -# else +# else void -# endif +# endif deque<_Tp, _Allocator>::emplace_front(_Args&&... __args) { allocator_type& __a = __alloc(); if (__front_spare() == 0) @@ -1646,9 +1651,9 @@ deque<_Tp, _Allocator>::emplace_front(_Args&&... __args) { __alloc_traits::construct(__a, std::addressof(*--begin()), std::forward<_Args>(__args)...); --__start_; ++__size(); -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 return *begin(); -# endif +# endif } template @@ -1746,7 +1751,7 @@ typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::emplace(const_ return begin() + __pos; } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::insert(const_iterator __p, const value_type& __v) { @@ -1969,11 +1974,11 @@ template template _LIBCPP_HIDE_FROM_ABI void deque<_Tp, _Allocator>::__append_with_sentinel(_InputIterator __f, _Sentinel __l) { for (; __f != __l; ++__f) -#ifdef _LIBCPP_CXX03_LANG +# ifdef _LIBCPP_CXX03_LANG push_back(*__f); -#else +# else emplace_back(*__f); -#endif +# endif } template @@ -2125,22 +2130,22 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) { size_type __ds = (__nb + __back_capacity) * __block_size - __map_.empty(); __split_buffer __buf( std::max(2 * __map_.capacity(), __nb + __map_.size()), 0, __map_.__alloc()); -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS for (; __nb > 0; --__nb) { __buf.push_back(__alloc_traits::allocate(__a, __block_size)); // ASan: this is empty container, we have to poison whole block __annotate_poison_block(std::__to_address(__buf.back()), std::__to_address(__buf.back() + __block_size)); } -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __annotate_delete(); for (__map_pointer __i = __buf.begin(); __i != __buf.end(); ++__i) __alloc_traits::deallocate(__a, *__i, __block_size); throw; } -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS for (; __back_capacity > 0; --__back_capacity) { __buf.push_back(__map_.back()); __map_.pop_back(); @@ -2250,22 +2255,22 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) { std::max(2 * __map_.capacity(), __nb + __map_.size()), __map_.size() - __front_capacity, __map_.__alloc()); -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS for (; __nb > 0; --__nb) { __buf.push_back(__alloc_traits::allocate(__a, __block_size)); // ASan: this is an empty container, we have to poison the whole block __annotate_poison_block(std::__to_address(__buf.back()), std::__to_address(__buf.back() + __block_size)); } -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __annotate_delete(); for (__map_pointer __i = __buf.begin(); __i != __buf.end(); ++__i) __alloc_traits::deallocate(__a, *__i, __block_size); throw; } -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS for (; __front_capacity > 0; --__front_capacity) { __buf.push_back(__map_.front()); __map_.pop_front(); @@ -2502,11 +2507,11 @@ void deque<_Tp, _Allocator>::__erase_to_end(const_iterator __f) { template inline void deque<_Tp, _Allocator>::swap(deque& __c) -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 _NOEXCEPT -#else +# else _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v) -#endif +# endif { __map_.swap(__c.__map_); std::swap(__start_, __c.__start_); @@ -2542,7 +2547,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator==(const deque<_Tp, _Allocator>& __x, return __sz == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); } -#if _LIBCPP_STD_VER <= 17 +# if _LIBCPP_STD_VER <= 17 template inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2569,7 +2574,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const deque<_Tp, _Allocator>& __x, return !(__y < __x); } -#else // _LIBCPP_STD_VER <= 17 +# else // _LIBCPP_STD_VER <= 17 template _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> @@ -2577,7 +2582,7 @@ operator<=>(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); } -#endif // _LIBCPP_STD_VER <= 17 +# endif // _LIBCPP_STD_VER <= 17 template inline _LIBCPP_HIDE_FROM_ABI void swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y) @@ -2585,7 +2590,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _ __x.swap(__y); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI typename deque<_Tp, _Allocator>::size_type erase(deque<_Tp, _Allocator>& __c, const _Up& __v) { @@ -2604,12 +2609,12 @@ erase_if(deque<_Tp, _Allocator>& __c, _Predicate __pred) { template <> inline constexpr bool __format::__enable_insertable> = true; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> inline constexpr bool __format::__enable_insertable> = true; -# endif +# endif -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 template struct __container_traits > { @@ -2624,27 +2629,28 @@ struct __container_traits > { _LIBCPP_END_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_BEGIN_NAMESPACE_STD namespace pmr { template using deque _LIBCPP_AVAILABILITY_PMR = std::deque<_ValueT, polymorphic_allocator<_ValueT>>; } // namespace pmr _LIBCPP_END_NAMESPACE_STD -#endif +# endif _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_DEQUE diff --git a/libcxx/include/errno.h b/libcxx/include/errno.h index e657ad84ff44bbf..2422bebf5136611 100644 --- a/libcxx/include/errno.h +++ b/libcxx/include/errno.h @@ -22,378 +22,384 @@ */ -#include <__config> +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/errno.h> +#else +# include <__config> -#if __has_include_next() -# include_next -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if __has_include_next() +# include_next +# endif -#ifdef __cplusplus +# ifdef __cplusplus -# if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) +# if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) -# ifdef ELAST +# ifdef ELAST static const int __elast1 = ELAST + 1; static const int __elast2 = ELAST + 2; -# else +# else static const int __elast1 = 104; static const int __elast2 = 105; -# endif +# endif -# ifdef ENOTRECOVERABLE +# ifdef ENOTRECOVERABLE -# define EOWNERDEAD __elast1 +# define EOWNERDEAD __elast1 -# ifdef ELAST -# undef ELAST -# define ELAST EOWNERDEAD -# endif +# ifdef ELAST +# undef ELAST +# define ELAST EOWNERDEAD +# endif -# elif defined(EOWNERDEAD) +# elif defined(EOWNERDEAD) -# define ENOTRECOVERABLE __elast1 -# ifdef ELAST -# undef ELAST -# define ELAST ENOTRECOVERABLE -# endif +# define ENOTRECOVERABLE __elast1 +# ifdef ELAST +# undef ELAST +# define ELAST ENOTRECOVERABLE +# endif -# else // defined(EOWNERDEAD) +# else // defined(EOWNERDEAD) -# define EOWNERDEAD __elast1 -# define ENOTRECOVERABLE __elast2 -# ifdef ELAST -# undef ELAST -# define ELAST ENOTRECOVERABLE -# endif +# define EOWNERDEAD __elast1 +# define ENOTRECOVERABLE __elast2 +# ifdef ELAST +# undef ELAST +# define ELAST ENOTRECOVERABLE +# endif -# endif // defined(EOWNERDEAD) +# endif // defined(EOWNERDEAD) -# endif // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) +# endif // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) // supply errno values likely to be missing, particularly on Windows -# ifndef EAFNOSUPPORT -# define EAFNOSUPPORT 9901 -# endif +# ifndef EAFNOSUPPORT +# define EAFNOSUPPORT 9901 +# endif -# ifndef EADDRINUSE -# define EADDRINUSE 9902 -# endif +# ifndef EADDRINUSE +# define EADDRINUSE 9902 +# endif -# ifndef EADDRNOTAVAIL -# define EADDRNOTAVAIL 9903 -# endif +# ifndef EADDRNOTAVAIL +# define EADDRNOTAVAIL 9903 +# endif -# ifndef EISCONN -# define EISCONN 9904 -# endif +# ifndef EISCONN +# define EISCONN 9904 +# endif -# ifndef EBADMSG -# define EBADMSG 9905 -# endif +# ifndef EBADMSG +# define EBADMSG 9905 +# endif -# ifndef ECONNABORTED -# define ECONNABORTED 9906 -# endif +# ifndef ECONNABORTED +# define ECONNABORTED 9906 +# endif -# ifndef EALREADY -# define EALREADY 9907 -# endif +# ifndef EALREADY +# define EALREADY 9907 +# endif -# ifndef ECONNREFUSED -# define ECONNREFUSED 9908 -# endif +# ifndef ECONNREFUSED +# define ECONNREFUSED 9908 +# endif -# ifndef ECONNRESET -# define ECONNRESET 9909 -# endif +# ifndef ECONNRESET +# define ECONNRESET 9909 +# endif -# ifndef EDESTADDRREQ -# define EDESTADDRREQ 9910 -# endif +# ifndef EDESTADDRREQ +# define EDESTADDRREQ 9910 +# endif -# ifndef EHOSTUNREACH -# define EHOSTUNREACH 9911 -# endif +# ifndef EHOSTUNREACH +# define EHOSTUNREACH 9911 +# endif -# ifndef EIDRM -# define EIDRM 9912 -# endif +# ifndef EIDRM +# define EIDRM 9912 +# endif -# ifndef EMSGSIZE -# define EMSGSIZE 9913 -# endif +# ifndef EMSGSIZE +# define EMSGSIZE 9913 +# endif -# ifndef ENETDOWN -# define ENETDOWN 9914 -# endif +# ifndef ENETDOWN +# define ENETDOWN 9914 +# endif -# ifndef ENETRESET -# define ENETRESET 9915 -# endif +# ifndef ENETRESET +# define ENETRESET 9915 +# endif -# ifndef ENETUNREACH -# define ENETUNREACH 9916 -# endif +# ifndef ENETUNREACH +# define ENETUNREACH 9916 +# endif -# ifndef ENOBUFS -# define ENOBUFS 9917 -# endif +# ifndef ENOBUFS +# define ENOBUFS 9917 +# endif -# ifndef ENOLINK -# define ENOLINK 9918 -# endif +# ifndef ENOLINK +# define ENOLINK 9918 +# endif -# ifndef ENODATA -# define ENODATA 9919 -# endif +# ifndef ENODATA +# define ENODATA 9919 +# endif -# ifndef ENOMSG -# define ENOMSG 9920 -# endif +# ifndef ENOMSG +# define ENOMSG 9920 +# endif -# ifndef ENOPROTOOPT -# define ENOPROTOOPT 9921 -# endif +# ifndef ENOPROTOOPT +# define ENOPROTOOPT 9921 +# endif -# ifndef ENOSR -# define ENOSR 9922 -# endif +# ifndef ENOSR +# define ENOSR 9922 +# endif -# ifndef ENOTSOCK -# define ENOTSOCK 9923 -# endif +# ifndef ENOTSOCK +# define ENOTSOCK 9923 +# endif -# ifndef ENOSTR -# define ENOSTR 9924 -# endif +# ifndef ENOSTR +# define ENOSTR 9924 +# endif -# ifndef ENOTCONN -# define ENOTCONN 9925 -# endif +# ifndef ENOTCONN +# define ENOTCONN 9925 +# endif -# ifndef ENOTSUP -# define ENOTSUP 9926 -# endif +# ifndef ENOTSUP +# define ENOTSUP 9926 +# endif -# ifndef ECANCELED -# define ECANCELED 9927 -# endif +# ifndef ECANCELED +# define ECANCELED 9927 +# endif -# ifndef EINPROGRESS -# define EINPROGRESS 9928 -# endif +# ifndef EINPROGRESS +# define EINPROGRESS 9928 +# endif -# ifndef EOPNOTSUPP -# define EOPNOTSUPP 9929 -# endif +# ifndef EOPNOTSUPP +# define EOPNOTSUPP 9929 +# endif -# ifndef EWOULDBLOCK -# define EWOULDBLOCK 9930 -# endif +# ifndef EWOULDBLOCK +# define EWOULDBLOCK 9930 +# endif -# ifndef EOWNERDEAD -# define EOWNERDEAD 9931 -# endif +# ifndef EOWNERDEAD +# define EOWNERDEAD 9931 +# endif -# ifndef EPROTO -# define EPROTO 9932 -# endif +# ifndef EPROTO +# define EPROTO 9932 +# endif -# ifndef EPROTONOSUPPORT -# define EPROTONOSUPPORT 9933 -# endif +# ifndef EPROTONOSUPPORT +# define EPROTONOSUPPORT 9933 +# endif -# ifndef ENOTRECOVERABLE -# define ENOTRECOVERABLE 9934 -# endif +# ifndef ENOTRECOVERABLE +# define ENOTRECOVERABLE 9934 +# endif -# ifndef ETIME -# define ETIME 9935 -# endif +# ifndef ETIME +# define ETIME 9935 +# endif -# ifndef ETXTBSY -# define ETXTBSY 9936 -# endif +# ifndef ETXTBSY +# define ETXTBSY 9936 +# endif -# ifndef ETIMEDOUT -# define ETIMEDOUT 9938 -# endif +# ifndef ETIMEDOUT +# define ETIMEDOUT 9938 +# endif -# ifndef ELOOP -# define ELOOP 9939 -# endif +# ifndef ELOOP +# define ELOOP 9939 +# endif -# ifndef EOVERFLOW -# define EOVERFLOW 9940 -# endif +# ifndef EOVERFLOW +# define EOVERFLOW 9940 +# endif -# ifndef EPROTOTYPE -# define EPROTOTYPE 9941 -# endif +# ifndef EPROTOTYPE +# define EPROTOTYPE 9941 +# endif -# ifndef ENOSYS -# define ENOSYS 9942 -# endif +# ifndef ENOSYS +# define ENOSYS 9942 +# endif -# ifndef EINVAL -# define EINVAL 9943 -# endif +# ifndef EINVAL +# define EINVAL 9943 +# endif -# ifndef ERANGE -# define ERANGE 9944 -# endif +# ifndef ERANGE +# define ERANGE 9944 +# endif -# ifndef EILSEQ -# define EILSEQ 9945 -# endif +# ifndef EILSEQ +# define EILSEQ 9945 +# endif // Windows Mobile doesn't appear to define these: -# ifndef E2BIG -# define E2BIG 9946 -# endif +# ifndef E2BIG +# define E2BIG 9946 +# endif -# ifndef EDOM -# define EDOM 9947 -# endif +# ifndef EDOM +# define EDOM 9947 +# endif -# ifndef EFAULT -# define EFAULT 9948 -# endif +# ifndef EFAULT +# define EFAULT 9948 +# endif -# ifndef EBADF -# define EBADF 9949 -# endif +# ifndef EBADF +# define EBADF 9949 +# endif -# ifndef EPIPE -# define EPIPE 9950 -# endif +# ifndef EPIPE +# define EPIPE 9950 +# endif -# ifndef EXDEV -# define EXDEV 9951 -# endif +# ifndef EXDEV +# define EXDEV 9951 +# endif -# ifndef EBUSY -# define EBUSY 9952 -# endif +# ifndef EBUSY +# define EBUSY 9952 +# endif -# ifndef ENOTEMPTY -# define ENOTEMPTY 9953 -# endif +# ifndef ENOTEMPTY +# define ENOTEMPTY 9953 +# endif -# ifndef ENOEXEC -# define ENOEXEC 9954 -# endif +# ifndef ENOEXEC +# define ENOEXEC 9954 +# endif -# ifndef EEXIST -# define EEXIST 9955 -# endif +# ifndef EEXIST +# define EEXIST 9955 +# endif -# ifndef EFBIG -# define EFBIG 9956 -# endif +# ifndef EFBIG +# define EFBIG 9956 +# endif -# ifndef ENAMETOOLONG -# define ENAMETOOLONG 9957 -# endif +# ifndef ENAMETOOLONG +# define ENAMETOOLONG 9957 +# endif -# ifndef ENOTTY -# define ENOTTY 9958 -# endif +# ifndef ENOTTY +# define ENOTTY 9958 +# endif -# ifndef EINTR -# define EINTR 9959 -# endif +# ifndef EINTR +# define EINTR 9959 +# endif -# ifndef ESPIPE -# define ESPIPE 9960 -# endif +# ifndef ESPIPE +# define ESPIPE 9960 +# endif -# ifndef EIO -# define EIO 9961 -# endif +# ifndef EIO +# define EIO 9961 +# endif -# ifndef EISDIR -# define EISDIR 9962 -# endif +# ifndef EISDIR +# define EISDIR 9962 +# endif -# ifndef ECHILD -# define ECHILD 9963 -# endif +# ifndef ECHILD +# define ECHILD 9963 +# endif -# ifndef ENOLCK -# define ENOLCK 9964 -# endif +# ifndef ENOLCK +# define ENOLCK 9964 +# endif -# ifndef ENOSPC -# define ENOSPC 9965 -# endif +# ifndef ENOSPC +# define ENOSPC 9965 +# endif -# ifndef ENXIO -# define ENXIO 9966 -# endif +# ifndef ENXIO +# define ENXIO 9966 +# endif -# ifndef ENODEV -# define ENODEV 9967 -# endif +# ifndef ENODEV +# define ENODEV 9967 +# endif -# ifndef ENOENT -# define ENOENT 9968 -# endif +# ifndef ENOENT +# define ENOENT 9968 +# endif -# ifndef ESRCH -# define ESRCH 9969 -# endif +# ifndef ESRCH +# define ESRCH 9969 +# endif -# ifndef ENOTDIR -# define ENOTDIR 9970 -# endif +# ifndef ENOTDIR +# define ENOTDIR 9970 +# endif -# ifndef ENOMEM -# define ENOMEM 9971 -# endif +# ifndef ENOMEM +# define ENOMEM 9971 +# endif -# ifndef EPERM -# define EPERM 9972 -# endif +# ifndef EPERM +# define EPERM 9972 +# endif -# ifndef EACCES -# define EACCES 9973 -# endif +# ifndef EACCES +# define EACCES 9973 +# endif -# ifndef EROFS -# define EROFS 9974 -# endif +# ifndef EROFS +# define EROFS 9974 +# endif -# ifndef EDEADLK -# define EDEADLK 9975 -# endif +# ifndef EDEADLK +# define EDEADLK 9975 +# endif -# ifndef EAGAIN -# define EAGAIN 9976 -# endif +# ifndef EAGAIN +# define EAGAIN 9976 +# endif -# ifndef ENFILE -# define ENFILE 9977 -# endif +# ifndef ENFILE +# define ENFILE 9977 +# endif -# ifndef EMFILE -# define EMFILE 9978 -# endif +# ifndef EMFILE +# define EMFILE 9978 +# endif -# ifndef EMLINK -# define EMLINK 9979 -# endif +# ifndef EMLINK +# define EMLINK 9979 +# endif -#endif // __cplusplus +# endif // __cplusplus +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_ERRNO_H diff --git a/libcxx/include/exception b/libcxx/include/exception index 64463e02cb16aa4..9bad660ecfaf919 100644 --- a/libcxx/include/exception +++ b/libcxx/include/exception @@ -76,21 +76,27 @@ template void rethrow_if_nested(const E& e); */ -#include <__config> -#include <__exception/exception.h> -#include <__exception/exception_ptr.h> -#include <__exception/nested_exception.h> -#include <__exception/operations.h> -#include <__exception/terminate.h> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/exception> +#else +# include <__config> +# include <__exception/exception.h> +# include <__exception/exception_ptr.h> +# include <__exception/nested_exception.h> +# include <__exception/operations.h> +# include <__exception/terminate.h> +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_EXCEPTION diff --git a/libcxx/include/execution b/libcxx/include/execution index 94d434b2e4603ed..d253d13bbf68198 100644 --- a/libcxx/include/execution +++ b/libcxx/include/execution @@ -32,17 +32,22 @@ namespace std { } */ -#include <__config> -#include <__type_traits/is_execution_policy.h> -#include <__type_traits/is_same.h> -#include <__type_traits/remove_cvref.h> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/execution> +#else +# include <__config> +# include <__type_traits/is_execution_policy.h> +# include <__type_traits/is_same.h> +# include <__type_traits/remove_cvref.h> +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif -#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 +# if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 _LIBCPP_BEGIN_NAMESPACE_STD @@ -79,7 +84,7 @@ struct __unsequenced_policy { constexpr __unsequenced_policy __unseq{__disable_user_instantiations_tag{}}; -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 struct unsequenced_policy { _LIBCPP_HIDE_FROM_ABI constexpr explicit unsequenced_policy(__disable_user_instantiations_tag) {} @@ -89,7 +94,7 @@ struct unsequenced_policy { inline constexpr unsequenced_policy unseq{__disable_user_instantiations_tag{}}; -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 } // namespace execution @@ -117,14 +122,14 @@ inline constexpr bool __is_unsequenced_execution_policy_impl inline constexpr bool __is_unsequenced_execution_policy_impl = true; -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template <> inline constexpr bool is_execution_policy_v = true; template <> inline constexpr bool __is_unsequenced_execution_policy_impl = true; -# endif +# endif template struct is_execution_policy : bool_constant> {}; @@ -140,10 +145,11 @@ _LIBCPP_HIDE_FROM_ABI auto __remove_parallel_policy(const _ExecutionPolicy&) { _LIBCPP_END_NAMESPACE_STD -#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 +# endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_EXECUTION diff --git a/libcxx/include/expected b/libcxx/include/expected index 6a2f12f2bf3b5d4..9679e01fb97d277 100644 --- a/libcxx/include/expected +++ b/libcxx/include/expected @@ -38,25 +38,31 @@ namespace std { */ -#include <__config> - -#if _LIBCPP_STD_VER >= 23 -# include <__expected/bad_expected_access.h> -# include <__expected/expected.h> -# include <__expected/unexpect.h> -# include <__expected/unexpected.h> -#endif - -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/expected> +#else +# include <__config> + +# if _LIBCPP_STD_VER >= 23 +# include <__expected/bad_expected_access.h> +# include <__expected/expected.h> +# include <__expected/unexpect.h> +# include <__expected/unexpected.h> +# endif + +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_EXPECTED diff --git a/libcxx/include/fenv.h b/libcxx/include/fenv.h index 5647f2b339555d9..7c8f29dab501faa 100644 --- a/libcxx/include/fenv.h +++ b/libcxx/include/fenv.h @@ -49,66 +49,72 @@ int feupdateenv(const fenv_t* envp); */ -#include <__config> +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/fenv.h> +#else +# include <__config> -#if __has_include_next() -# include_next -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if __has_include_next() +# include_next +# endif -#ifdef __cplusplus +# ifdef __cplusplus extern "C++" { -# ifdef feclearexcept -# undef feclearexcept -# endif +# ifdef feclearexcept +# undef feclearexcept +# endif -# ifdef fegetexceptflag -# undef fegetexceptflag -# endif +# ifdef fegetexceptflag +# undef fegetexceptflag +# endif -# ifdef feraiseexcept -# undef feraiseexcept -# endif +# ifdef feraiseexcept +# undef feraiseexcept +# endif -# ifdef fesetexceptflag -# undef fesetexceptflag -# endif +# ifdef fesetexceptflag +# undef fesetexceptflag +# endif -# ifdef fetestexcept -# undef fetestexcept -# endif +# ifdef fetestexcept +# undef fetestexcept +# endif -# ifdef fegetround -# undef fegetround -# endif +# ifdef fegetround +# undef fegetround +# endif -# ifdef fesetround -# undef fesetround -# endif +# ifdef fesetround +# undef fesetround +# endif -# ifdef fegetenv -# undef fegetenv -# endif +# ifdef fegetenv +# undef fegetenv +# endif -# ifdef feholdexcept -# undef feholdexcept -# endif +# ifdef feholdexcept +# undef feholdexcept +# endif -# ifdef fesetenv -# undef fesetenv -# endif +# ifdef fesetenv +# undef fesetenv +# endif -# ifdef feupdateenv -# undef feupdateenv -# endif +# ifdef feupdateenv +# undef feupdateenv +# endif } // extern "C++" -#endif // defined(__cplusplus) +# endif // defined(__cplusplus) +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_FENV_H diff --git a/libcxx/include/filesystem b/libcxx/include/filesystem index 6ea04df0a089b0a..1c5ec2fa9a62ed6 100644 --- a/libcxx/include/filesystem +++ b/libcxx/include/filesystem @@ -533,45 +533,51 @@ inline constexpr bool std::ranges::enable_view - -#if _LIBCPP_STD_VER >= 17 -# include <__filesystem/copy_options.h> -# include <__filesystem/directory_entry.h> -# include <__filesystem/directory_iterator.h> -# include <__filesystem/directory_options.h> -# include <__filesystem/file_status.h> -# include <__filesystem/file_time_type.h> -# include <__filesystem/file_type.h> -# include <__filesystem/filesystem_error.h> -# include <__filesystem/operations.h> -# include <__filesystem/path.h> -# include <__filesystem/path_iterator.h> -# include <__filesystem/perm_options.h> -# include <__filesystem/perms.h> -# include <__filesystem/recursive_directory_iterator.h> -# include <__filesystem/space_info.h> -# include <__filesystem/u8path.h> -#endif - -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/filesystem> +#else +# include <__config> + +# if _LIBCPP_STD_VER >= 17 +# include <__filesystem/copy_options.h> +# include <__filesystem/directory_entry.h> +# include <__filesystem/directory_iterator.h> +# include <__filesystem/directory_options.h> +# include <__filesystem/file_status.h> +# include <__filesystem/file_time_type.h> +# include <__filesystem/file_type.h> +# include <__filesystem/filesystem_error.h> +# include <__filesystem/operations.h> +# include <__filesystem/path.h> +# include <__filesystem/path_iterator.h> +# include <__filesystem/perm_options.h> +# include <__filesystem/perms.h> +# include <__filesystem/recursive_directory_iterator.h> +# include <__filesystem/space_info.h> +# include <__filesystem/u8path.h> +# endif + +# include // standard-mandated includes // [fs.filesystem.syn] -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -#endif +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_FILESYSTEM diff --git a/libcxx/include/float.h b/libcxx/include/float.h index d572866c1358be2..fe7a386562bf711 100644 --- a/libcxx/include/float.h +++ b/libcxx/include/float.h @@ -70,26 +70,32 @@ */ -#include <__config> +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/float.h> +#else +# include <__config> -#if __has_include_next() -# include_next -#endif - -#ifdef __cplusplus - -# ifndef FLT_EVAL_METHOD -# define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header # endif -# ifndef DECIMAL_DIG -# define DECIMAL_DIG __DECIMAL_DIG__ +# if __has_include_next() +# include_next # endif -#endif // __cplusplus +# ifdef __cplusplus + +# ifndef FLT_EVAL_METHOD +# define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ +# endif + +# ifndef DECIMAL_DIG +# define DECIMAL_DIG __DECIMAL_DIG__ +# endif + +# endif // __cplusplus +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_FLOAT_H diff --git a/libcxx/include/format b/libcxx/include/format index 449e6f0bf3fb63d..dbd1498e7b3000c 100644 --- a/libcxx/include/format +++ b/libcxx/include/format @@ -191,70 +191,76 @@ namespace std { */ -#include <__config> - -#if _LIBCPP_STD_VER >= 20 -# include <__format/buffer.h> -# include <__format/concepts.h> -# include <__format/container_adaptor.h> -# include <__format/enable_insertable.h> -# include <__format/escaped_output_table.h> -# include <__format/extended_grapheme_cluster_table.h> -# include <__format/format_arg.h> -# include <__format/format_arg_store.h> -# include <__format/format_args.h> -# include <__format/format_context.h> -# include <__format/format_error.h> -# include <__format/format_functions.h> -# include <__format/format_parse_context.h> -# include <__format/format_string.h> -# include <__format/format_to_n_result.h> -# include <__format/formatter.h> -# include <__format/formatter_bool.h> -# include <__format/formatter_char.h> -# include <__format/formatter_floating_point.h> -# include <__format/formatter_integer.h> -# include <__format/formatter_pointer.h> -# include <__format/formatter_string.h> -# include <__format/formatter_tuple.h> -# include <__format/parser_std_format_spec.h> -# include <__format/range_default_formatter.h> -# include <__format/range_formatter.h> -# include <__format/unicode.h> -# include <__fwd/format.h> -#endif - -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include - -# if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) -# include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/format> +#else +# include <__config> + +# if _LIBCPP_STD_VER >= 20 +# include <__format/buffer.h> +# include <__format/concepts.h> +# include <__format/container_adaptor.h> +# include <__format/enable_insertable.h> +# include <__format/escaped_output_table.h> +# include <__format/extended_grapheme_cluster_table.h> +# include <__format/format_arg.h> +# include <__format/format_arg_store.h> +# include <__format/format_args.h> +# include <__format/format_context.h> +# include <__format/format_error.h> +# include <__format/format_functions.h> +# include <__format/format_parse_context.h> +# include <__format/format_string.h> +# include <__format/format_to_n_result.h> +# include <__format/formatter.h> +# include <__format/formatter_bool.h> +# include <__format/formatter_char.h> +# include <__format/formatter_floating_point.h> +# include <__format/formatter_integer.h> +# include <__format/formatter_pointer.h> +# include <__format/formatter_string.h> +# include <__format/formatter_tuple.h> +# include <__format/parser_std_format_spec.h> +# include <__format/range_default_formatter.h> +# include <__format/range_formatter.h> +# include <__format/unicode.h> +# include <__fwd/format.h> # endif -#endif + +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) +# include +# endif +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_FORMAT diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list index 04466d9a673fc64..5ff8a3ca1b5ec81 100644 --- a/libcxx/include/forward_list +++ b/libcxx/include/forward_list @@ -195,65 +195,70 @@ template */ -#include <__algorithm/comp.h> -#include <__algorithm/lexicographical_compare.h> -#include <__algorithm/lexicographical_compare_three_way.h> -#include <__algorithm/min.h> -#include <__config> -#include <__iterator/distance.h> -#include <__iterator/iterator_traits.h> -#include <__iterator/move_iterator.h> -#include <__iterator/next.h> -#include <__memory/addressof.h> -#include <__memory/allocation_guard.h> -#include <__memory/allocator.h> -#include <__memory/allocator_traits.h> -#include <__memory/compressed_pair.h> -#include <__memory/construct_at.h> -#include <__memory/pointer_traits.h> -#include <__memory/swap_allocator.h> -#include <__memory_resource/polymorphic_allocator.h> -#include <__ranges/access.h> -#include <__ranges/concepts.h> -#include <__ranges/container_compatible_range.h> -#include <__ranges/from_range.h> -#include <__type_traits/conditional.h> -#include <__type_traits/container_traits.h> -#include <__type_traits/enable_if.h> -#include <__type_traits/is_allocator.h> -#include <__type_traits/is_const.h> -#include <__type_traits/is_nothrow_assignable.h> -#include <__type_traits/is_nothrow_constructible.h> -#include <__type_traits/is_pointer.h> -#include <__type_traits/is_same.h> -#include <__type_traits/is_swappable.h> -#include <__type_traits/type_identity.h> -#include <__utility/forward.h> -#include <__utility/move.h> -#include <__utility/swap.h> -#include -#include // __launder -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/forward_list> +#else +# include <__algorithm/comp.h> +# include <__algorithm/lexicographical_compare.h> +# include <__algorithm/lexicographical_compare_three_way.h> +# include <__algorithm/min.h> +# include <__config> +# include <__iterator/distance.h> +# include <__iterator/iterator_traits.h> +# include <__iterator/move_iterator.h> +# include <__iterator/next.h> +# include <__memory/addressof.h> +# include <__memory/allocation_guard.h> +# include <__memory/allocator.h> +# include <__memory/allocator_traits.h> +# include <__memory/compressed_pair.h> +# include <__memory/construct_at.h> +# include <__memory/pointer_traits.h> +# include <__memory/swap_allocator.h> +# include <__memory_resource/polymorphic_allocator.h> +# include <__ranges/access.h> +# include <__ranges/concepts.h> +# include <__ranges/container_compatible_range.h> +# include <__ranges/from_range.h> +# include <__type_traits/conditional.h> +# include <__type_traits/container_traits.h> +# include <__type_traits/enable_if.h> +# include <__type_traits/is_allocator.h> +# include <__type_traits/is_const.h> +# include <__type_traits/is_nothrow_assignable.h> +# include <__type_traits/is_nothrow_constructible.h> +# include <__type_traits/is_pointer.h> +# include <__type_traits/is_same.h> +# include <__type_traits/is_swappable.h> +# include <__type_traits/type_identity.h> +# include <__utility/forward.h> +# include <__utility/move.h> +# include <__utility/swap.h> +# include +# include // __launder +# include // standard-mandated includes // [iterator.range] -#include <__iterator/access.h> -#include <__iterator/data.h> -#include <__iterator/empty.h> -#include <__iterator/reverse_access.h> -#include <__iterator/size.h> +# include <__iterator/access.h> +# include <__iterator/data.h> +# include <__iterator/empty.h> +# include <__iterator/reverse_access.h> +# include <__iterator/size.h> // [forward.list.syn] -#include -#include +# include +# include -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -280,7 +285,7 @@ struct __forward_node_traits { typedef __rebind_pointer_t<_NodePtr, void> __void_pointer; // TODO(LLVM 22): Remove this check -#ifndef _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB +# ifndef _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB static_assert(sizeof(__begin_node_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__begin_node_pointer) == _LIBCPP_ALIGNOF(__node_pointer), "It looks like you are using std::forward_list with a fancy pointer type that thas a different " @@ -288,7 +293,7 @@ struct __forward_node_traits { "pointer (both of which are implementation details of the standard library). This means that your ABI " "is being broken between LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define " "the _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic."); -#endif +# endif _LIBCPP_HIDE_FROM_ABI static __begin_node_pointer __as_iter_node(__begin_node_pointer __p) { return __p; } _LIBCPP_HIDE_FROM_ABI static __begin_node_pointer __as_iter_node(__node_pointer __p) { @@ -322,7 +327,7 @@ struct __forward_list_node : public __begin_node_of<_Tp, _VoidPtr> { // We allow starting the lifetime of nodes without initializing the value held by the node, // since that is handled by the list itself in order to be allocator-aware. -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG private: union { @@ -331,14 +336,14 @@ private: public: _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; } -#else +# else private: _ALIGNAS_TYPE(_Tp) char __buffer_[sizeof(_Tp)]; public: _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI explicit __forward_list_node(_NodePtr __next) : _Base(__next) {} _LIBCPP_HIDE_FROM_ABI ~__forward_list_node() {} @@ -516,11 +521,11 @@ protected: : __before_begin_(__begin_node()), __alloc_(__a) {} public: -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI __forward_list_base(__forward_list_base&& __x) noexcept(is_nothrow_move_constructible<__node_allocator>::value); _LIBCPP_HIDE_FROM_ABI __forward_list_base(__forward_list_base&& __x, const allocator_type& __a); -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG __forward_list_base(const __forward_list_base&) = delete; __forward_list_base& operator=(const __forward_list_base&) = delete; @@ -566,11 +571,11 @@ protected: public: _LIBCPP_HIDE_FROM_ABI void swap(__forward_list_base& __x) -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 _NOEXCEPT; -#else +# else _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>); -#endif +# endif protected: _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT; @@ -590,7 +595,7 @@ private: } }; -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x) noexcept( @@ -608,7 +613,7 @@ inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base } } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template __forward_list_base<_Tp, _Alloc>::~__forward_list_base() { @@ -617,11 +622,11 @@ __forward_list_base<_Tp, _Alloc>::~__forward_list_base() { template inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x) -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 _NOEXCEPT -#else +# else _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>) -#endif +# endif { std::__swap_allocator(__alloc(), __x.__alloc()); using std::swap; @@ -668,19 +673,19 @@ public: typedef typename __base::iterator iterator; typedef typename __base::const_iterator const_iterator; -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 typedef size_type __remove_return_type; -#else +# else typedef void __remove_return_type; -#endif +# endif _LIBCPP_HIDE_FROM_ABI forward_list() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) { } // = default; _LIBCPP_HIDE_FROM_ABI explicit forward_list(const allocator_type& __a); _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n); -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n, const allocator_type& __a); -#endif +# endif _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v); template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0> @@ -694,20 +699,20 @@ public: template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a); -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> _LIBCPP_HIDE_FROM_ABI forward_list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) : __base(__a) { prepend_range(std::forward<_Range>(__range)); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI forward_list(const forward_list& __x); _LIBCPP_HIDE_FROM_ABI forward_list(const forward_list& __x, const __type_identity_t& __a); _LIBCPP_HIDE_FROM_ABI forward_list& operator=(const forward_list& __x); -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x) noexcept(is_nothrow_move_constructible<__base>::value) : __base(std::move(__x)) {} _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x, const __type_identity_t& __a); @@ -722,19 +727,19 @@ public: _LIBCPP_HIDE_FROM_ABI forward_list& operator=(initializer_list __il); _LIBCPP_HIDE_FROM_ABI void assign(initializer_list __il); -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG // ~forward_list() = default; template ::value, int> = 0> void _LIBCPP_HIDE_FROM_ABI assign(_InputIterator __f, _InputIterator __l); -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) { __assign_with_sentinel(ranges::begin(__range), ranges::end(__range)); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v); @@ -770,28 +775,28 @@ public: _LIBCPP_HIDE_FROM_ABI reference front() { return __base::__before_begin()->__next_->__get_value(); } _LIBCPP_HIDE_FROM_ABI const_reference front() const { return __base::__before_begin()->__next_->__get_value(); } -#ifndef _LIBCPP_CXX03_LANG -# if _LIBCPP_STD_VER >= 17 +# ifndef _LIBCPP_CXX03_LANG +# if _LIBCPP_STD_VER >= 17 template _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args); -# else +# else template _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args); -# endif +# endif _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __v); -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __v); -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) { insert_range_after(cbefore_begin(), std::forward<_Range>(__range)); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI void pop_front(); -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template _LIBCPP_HIDE_FROM_ABI iterator emplace_after(const_iterator __p, _Args&&... __args); @@ -799,18 +804,18 @@ public: _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, initializer_list __il) { return insert_after(__p, __il.begin(), __il.end()); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, const value_type& __v); _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, size_type __n, const value_type& __v); template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l); -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> _LIBCPP_HIDE_FROM_ABI iterator insert_range_after(const_iterator __position, _Range&& __range) { return __insert_after_with_sentinel(__position, ranges::begin(__range), ranges::end(__range)); } -#endif +# endif template _LIBCPP_HIDE_FROM_ABI iterator __insert_after_with_sentinel(const_iterator __p, _InputIterator __f, _Sentinel __l); @@ -819,11 +824,11 @@ public: _LIBCPP_HIDE_FROM_ABI iterator erase_after(const_iterator __f, const_iterator __l); _LIBCPP_HIDE_FROM_ABI void swap(forward_list& __x) -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 _NOEXCEPT -#else +# else _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>) -#endif +# endif { __base::swap(__x); } @@ -846,13 +851,13 @@ public: _LIBCPP_HIDE_FROM_ABI __remove_return_type unique() { return unique(__equal_to()); } template _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPredicate __binary_pred); -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI void merge(forward_list&& __x) { merge(__x, __less<>()); } template _LIBCPP_HIDE_FROM_ABI void merge(forward_list&& __x, _Compare __comp) { merge(__x, std::move(__comp)); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI void merge(forward_list& __x) { merge(__x, __less<>()); } template _LIBCPP_HIDE_FROM_ABI void merge(forward_list& __x, _Compare __comp); @@ -862,11 +867,11 @@ public: _LIBCPP_HIDE_FROM_ABI void reverse() _NOEXCEPT; private: -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI void __move_assign(forward_list& __x, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value); _LIBCPP_HIDE_FROM_ABI void __move_assign(forward_list& __x, false_type); -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iter __f, _Sent __l); @@ -879,7 +884,7 @@ private: static _LIBCPP_HIDDEN __node_pointer __sort(__node_pointer __f, difference_type __sz, _Compare& __comp); }; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template >, class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, @@ -891,14 +896,14 @@ template ::value>, class = enable_if_t<__is_allocator<_Alloc>::value> > forward_list(_InputIterator, _InputIterator, _Alloc) -> forward_list<__iter_value_type<_InputIterator>, _Alloc>; -#endif +# endif -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template >, class = enable_if_t<__is_allocator<_Alloc>::value> > forward_list(from_range_t, _Range&&, _Alloc = _Alloc()) -> forward_list, _Alloc>; -#endif +# endif template inline forward_list<_Tp, _Alloc>::forward_list(const allocator_type& __a) : __base(__a) {} @@ -912,7 +917,7 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n) { } } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __base_alloc) : __base(__base_alloc) { if (__n > 0) { @@ -921,7 +926,7 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __b } } } -#endif +# endif template forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) { @@ -962,7 +967,7 @@ forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(const forward_li return *this; } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x, const __type_identity_t& __a) : __base(std::move(__x), __a) { @@ -1014,7 +1019,7 @@ inline forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(initializ return *this; } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template template ::value, int> > @@ -1049,7 +1054,7 @@ void forward_list<_Tp, _Alloc>::assign(size_type __n, const value_type& __v) { erase_after(__i, __e); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template inline void forward_list<_Tp, _Alloc>::assign(initializer_list __il) { @@ -1058,17 +1063,17 @@ inline void forward_list<_Tp, _Alloc>::assign(initializer_list __il) template template -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 typename forward_list<_Tp, _Alloc>::reference -# else +# else void -# endif +# endif forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args) { __base::__before_begin()->__next_ = this->__create_node(/* next = */ __base::__before_begin()->__next_, std::forward<_Args>(__args)...); -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 return __base::__before_begin()->__next_->__get_value(); -# endif +# endif } template @@ -1077,7 +1082,7 @@ void forward_list<_Tp, _Alloc>::push_front(value_type&& __v) { this->__create_node(/* next = */ __base::__before_begin()->__next_, std::move(__v)); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template void forward_list<_Tp, _Alloc>::push_front(const value_type& __v) { @@ -1091,7 +1096,7 @@ void forward_list<_Tp, _Alloc>::pop_front() { this->__delete_node(__p); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template template @@ -1110,7 +1115,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v) { return iterator(__r->__next_); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template typename forward_list<_Tp, _Alloc>::iterator @@ -1127,13 +1132,13 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const if (__n > 0) { __node_pointer __first = this->__create_node(/* next = */ nullptr, __v); __node_pointer __last = __first; -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS for (--__n; __n != 0; --__n, __last = __last->__next_) { __last->__next_ = this->__create_node(/* next = */ nullptr, __v); } -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { while (__first != nullptr) { __node_pointer __next = __first->__next_; @@ -1142,7 +1147,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const } throw; } -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __last->__next_ = __r->__next_; __r->__next_ = __first; __r = static_cast<__begin_node_pointer>(__last); @@ -1167,13 +1172,13 @@ forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _Inp __node_pointer __first = this->__create_node(/* next = */ nullptr, *__f); __node_pointer __last = __first; -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS for (++__f; __f != __l; ++__f, ((void)(__last = __last->__next_))) { __last->__next_ = this->__create_node(/* next = */ nullptr, *__f); } -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { while (__first != nullptr) { __node_pointer __next = __first->__next_; @@ -1182,7 +1187,7 @@ forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _Inp } throw; } -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __last->__next_ = __r->__next_; __r->__next_ = __first; @@ -1488,7 +1493,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const forward_list<_Tp, _Alloc>& __x, cons return (__ix == __ex) == (__iy == __ey); } -#if _LIBCPP_STD_VER <= 17 +# if _LIBCPP_STD_VER <= 17 template inline _LIBCPP_HIDE_FROM_ABI bool @@ -1520,7 +1525,7 @@ operator<=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc> return !(__y < __x); } -#else // #if _LIBCPP_STD_VER <= 17 +# else // #if _LIBCPP_STD_VER <= 17 template _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> @@ -1528,7 +1533,7 @@ operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _A return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); } -#endif // #if _LIBCPP_STD_VER <= 17 +# endif // #if _LIBCPP_STD_VER <= 17 template inline _LIBCPP_HIDE_FROM_ABI void swap(forward_list<_Tp, _Alloc>& __x, forward_list<_Tp, _Alloc>& __y) @@ -1536,7 +1541,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(forward_list<_Tp, _Alloc>& __x, forward_l __x.swap(__y); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Allocator>::size_type erase_if(forward_list<_Tp, _Allocator>& __c, _Predicate __pred) { @@ -1548,7 +1553,7 @@ inline _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Allocator>::size_type erase(forward_list<_Tp, _Allocator>& __c, const _Up& __v) { return std::erase_if(__c, [&](auto& __elem) { return __elem == __v; }); } -#endif +# endif template struct __container_traits > { @@ -1563,30 +1568,31 @@ struct __container_traits > { _LIBCPP_END_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_BEGIN_NAMESPACE_STD namespace pmr { template using forward_list _LIBCPP_AVAILABILITY_PMR = std::forward_list<_ValueT, polymorphic_allocator<_ValueT>>; } // namespace pmr _LIBCPP_END_NAMESPACE_STD -#endif +# endif _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_FORWARD_LIST diff --git a/libcxx/include/fstream b/libcxx/include/fstream index dce0efc71d8e5f7..9727eddca26167c 100644 --- a/libcxx/include/fstream +++ b/libcxx/include/fstream @@ -186,44 +186,49 @@ typedef basic_fstream wfstream; */ -#include <__algorithm/max.h> -#include <__assert> -#include <__config> -#include <__filesystem/path.h> -#include <__fwd/fstream.h> -#include <__locale> -#include <__memory/addressof.h> -#include <__type_traits/enable_if.h> -#include <__type_traits/is_same.h> -#include <__utility/move.h> -#include <__utility/swap.h> -#include <__utility/unreachable.h> -#include -#include -#include -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/fstream> +#else +# include <__algorithm/max.h> +# include <__assert> +# include <__config> +# include <__filesystem/path.h> +# include <__fwd/fstream.h> +# include <__locale> +# include <__memory/addressof.h> +# include <__type_traits/enable_if.h> +# include <__type_traits/is_same.h> +# include <__utility/move.h> +# include <__utility/swap.h> +# include <__utility/unreachable.h> +# include +# include +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> -#if !defined(_LIBCPP_MSVCRT) && !defined(_NEWLIB_VERSION) -# define _LIBCPP_HAS_OFF_T_FUNCTIONS 1 -#else -# define _LIBCPP_HAS_OFF_T_FUNCTIONS 0 -#endif +# if !defined(_LIBCPP_MSVCRT) && !defined(_NEWLIB_VERSION) +# define _LIBCPP_HAS_OFF_T_FUNCTIONS 1 +# else +# define _LIBCPP_HAS_OFF_T_FUNCTIONS 0 +# endif -#if !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) +# if !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) _LIBCPP_BEGIN_NAMESPACE_STD -# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_WIN32API) +# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_WIN32API) _LIBCPP_EXPORTED_FROM_ABI void* __filebuf_windows_native_handle(FILE* __file) noexcept; -# endif +# endif template class _LIBCPP_TEMPLATE_VIS basic_filebuf : public basic_streambuf<_CharT, _Traits> { @@ -234,15 +239,15 @@ public: typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; typedef typename traits_type::state_type state_type; -# if _LIBCPP_STD_VER >= 26 -# if defined(_LIBCPP_WIN32API) +# if _LIBCPP_STD_VER >= 26 +# if defined(_LIBCPP_WIN32API) using native_handle_type = void*; // HANDLE -# elif __has_include() +# elif __has_include() using native_handle_type = int; // POSIX file descriptor -# else -# error "Provide a native file handle!" +# else +# error "Provide a native file handle!" +# endif # endif -# endif // 27.9.1.2 Constructors/destructor: basic_filebuf(); @@ -256,36 +261,36 @@ public: // 27.9.1.4 Members: _LIBCPP_HIDE_FROM_ABI bool is_open() const; basic_filebuf* open(const char* __s, ios_base::openmode __mode); -# if _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR basic_filebuf* open(const wchar_t* __s, ios_base::openmode __mode); -# endif +# endif _LIBCPP_HIDE_FROM_ABI basic_filebuf* open(const string& __s, ios_base::openmode __mode); -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI basic_filebuf* open(const filesystem::path& __p, ios_base::openmode __mode) { return open(__p.c_str(), __mode); } -# endif +# endif _LIBCPP_HIDE_FROM_ABI basic_filebuf* __open(int __fd, ios_base::openmode __mode); basic_filebuf* close(); -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { _LIBCPP_ASSERT_UNCATEGORIZED(this->is_open(), "File must be opened"); -# if defined(_LIBCPP_WIN32API) +# if defined(_LIBCPP_WIN32API) return std::__filebuf_windows_native_handle(__file_); -# elif __has_include() +# elif __has_include() return fileno(__file_); -# else -# error "Provide a way to determine the file native handle!" -# endif +# else +# error "Provide a way to determine the file native handle!" +# endif } -# endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 _LIBCPP_HIDE_FROM_ABI inline static const char* __make_mdstring(ios_base::openmode __mode) _NOEXCEPT; -# if _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR _LIBCPP_HIDE_FROM_ABI inline static const wchar_t* __make_mdwstring(ios_base::openmode __mode) _NOEXCEPT; -# endif +# endif protected: // 27.9.1.5 Overridden virtual functions: @@ -487,14 +492,14 @@ inline basic_filebuf<_CharT, _Traits>& basic_filebuf<_CharT, _Traits>::operator= template basic_filebuf<_CharT, _Traits>::~basic_filebuf() { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS close(); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS if (__owns_eb_) delete[] __extbuf_; if (__owns_ib_) @@ -614,7 +619,7 @@ const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(ios_base::openmode _ case ios_base::in | ios_base::out | ios_base::app | ios_base::binary: case ios_base::in | ios_base::app | ios_base::binary: return "a+b" _LIBCPP_FOPEN_CLOEXEC_MODE; -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 case ios_base::out | ios_base::noreplace: case ios_base::out | ios_base::trunc | ios_base::noreplace: return "wx" _LIBCPP_FOPEN_CLOEXEC_MODE; @@ -625,14 +630,14 @@ const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(ios_base::openmode _ return "wbx" _LIBCPP_FOPEN_CLOEXEC_MODE; case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary | ios_base::noreplace: return "w+bx" _LIBCPP_FOPEN_CLOEXEC_MODE; -# endif // _LIBCPP_STD_VER >= 23 +# endif // _LIBCPP_STD_VER >= 23 default: return nullptr; } __libcpp_unreachable(); } -# if _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR template const wchar_t* basic_filebuf<_CharT, _Traits>::__make_mdwstring(ios_base::openmode __mode) _NOEXCEPT { switch (__mode & ~ios_base::ate) { @@ -666,7 +671,7 @@ const wchar_t* basic_filebuf<_CharT, _Traits>::__make_mdwstring(ios_base::openmo case ios_base::in | ios_base::out | ios_base::app | ios_base::binary: case ios_base::in | ios_base::app | ios_base::binary: return L"a+b"; -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 case ios_base::out | ios_base::noreplace: case ios_base::out | ios_base::trunc | ios_base::noreplace: return L"wx"; @@ -677,13 +682,13 @@ const wchar_t* basic_filebuf<_CharT, _Traits>::__make_mdwstring(ios_base::openmo return L"wbx"; case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary | ios_base::noreplace: return L"w+bx"; -# endif // _LIBCPP_STD_VER >= 23 +# endif // _LIBCPP_STD_VER >= 23 default: return nullptr; } __libcpp_unreachable(); } -# endif +# endif template basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) { @@ -707,7 +712,7 @@ inline basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::__open(in return __do_open(fdopen(__fd, __mdstr), __mode); } -# if _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR // This is basically the same as the char* overload except that it uses _wfopen // and long mode strings. template @@ -720,7 +725,7 @@ basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const wchar return __do_open(_wfopen(__s, __mdstr), __mode); } -# endif +# endif template inline basic_filebuf<_CharT, _Traits>* @@ -931,15 +936,15 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way, default: return pos_type(off_type(-1)); } -# if !_LIBCPP_HAS_OFF_T_FUNCTIONS +# if !_LIBCPP_HAS_OFF_T_FUNCTIONS if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence)) return pos_type(off_type(-1)); pos_type __r = ftell(__file_); -# else +# else if (::fseeko(__file_, __width > 0 ? __width * __off : 0, __whence)) return pos_type(off_type(-1)); pos_type __r = ftello(__file_); -# endif +# endif __r.state(__st_); return __r; } @@ -949,13 +954,13 @@ typename basic_filebuf<_CharT, _Traits>::pos_type basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode) { if (__file_ == nullptr || sync()) return pos_type(off_type(-1)); -# if !_LIBCPP_HAS_OFF_T_FUNCTIONS +# if !_LIBCPP_HAS_OFF_T_FUNCTIONS if (fseek(__file_, __sp, SEEK_SET)) return pos_type(off_type(-1)); -# else +# else if (::fseeko(__file_, __sp, SEEK_SET)) return pos_type(off_type(-1)); -# endif +# endif __st_ = __sp.state(); return __sp; } @@ -1002,13 +1007,13 @@ int basic_filebuf<_CharT, _Traits>::sync() { } } } -# if !_LIBCPP_HAS_OFF_T_FUNCTIONS +# if !_LIBCPP_HAS_OFF_T_FUNCTIONS if (fseek(__file_, -__c, SEEK_CUR)) return -1; -# else +# else if (::fseeko(__file_, -__c, SEEK_CUR)) return -1; -# endif +# endif if (__update_st) __st_ = __state; __extbufnext_ = __extbufend_ = __extbuf_; @@ -1094,42 +1099,42 @@ public: typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 using native_handle_type = typename basic_filebuf<_CharT, _Traits>::native_handle_type; -# endif +# endif _LIBCPP_HIDE_FROM_ABI basic_ifstream(); _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in); -# if _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in); -# endif +# endif _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in); -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template >> _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const _Tp& __p, ios_base::openmode __mode = ios_base::in) : basic_ifstream(__p.c_str(), __mode) {} -# endif // _LIBCPP_STD_VER >= 17 +# endif // _LIBCPP_STD_VER >= 17 _LIBCPP_HIDE_FROM_ABI basic_ifstream(basic_ifstream&& __rhs); _LIBCPP_HIDE_FROM_ABI basic_ifstream& operator=(basic_ifstream&& __rhs); _LIBCPP_HIDE_FROM_ABI void swap(basic_ifstream& __rhs); _LIBCPP_HIDE_FROM_ABI basic_filebuf* rdbuf() const; -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { return rdbuf()->native_handle(); } -# endif +# endif _LIBCPP_HIDE_FROM_ABI bool is_open() const; void open(const char* __s, ios_base::openmode __mode = ios_base::in); -# if _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in); -# endif +# endif void open(const string& __s, ios_base::openmode __mode = ios_base::in); -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in) { return open(__p.c_str(), __mode); } -# endif // _LIBCPP_STD_VER >= 17 +# endif // _LIBCPP_STD_VER >= 17 _LIBCPP_HIDE_FROM_ABI void __open(int __fd, ios_base::openmode __mode); _LIBCPP_HIDE_FROM_ABI void close(); @@ -1149,14 +1154,14 @@ inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base this->setstate(ios_base::failbit); } -# if _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR template inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const wchar_t* __s, ios_base::openmode __mode) : basic_istream(std::addressof(__sb_)) { if (__sb_.open(__s, __mode | ios_base::in) == nullptr) this->setstate(ios_base::failbit); } -# endif +# endif // extension template @@ -1208,7 +1213,7 @@ void basic_ifstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode _ this->setstate(ios_base::failbit); } -# if _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR template void basic_ifstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) { if (__sb_.open(__s, __mode | ios_base::in)) @@ -1216,7 +1221,7 @@ void basic_ifstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmod else this->setstate(ios_base::failbit); } -# endif +# endif template void basic_ifstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode) { @@ -1250,45 +1255,45 @@ public: typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 using native_handle_type = typename basic_filebuf<_CharT, _Traits>::native_handle_type; -# endif +# endif _LIBCPP_HIDE_FROM_ABI basic_ofstream(); _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out); -# if _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::out); -# endif +# endif _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out); -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template >> _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const _Tp& __p, ios_base::openmode __mode = ios_base::out) : basic_ofstream(__p.c_str(), __mode) {} -# endif // _LIBCPP_STD_VER >= 17 +# endif // _LIBCPP_STD_VER >= 17 _LIBCPP_HIDE_FROM_ABI basic_ofstream(basic_ofstream&& __rhs); _LIBCPP_HIDE_FROM_ABI basic_ofstream& operator=(basic_ofstream&& __rhs); _LIBCPP_HIDE_FROM_ABI void swap(basic_ofstream& __rhs); _LIBCPP_HIDE_FROM_ABI basic_filebuf* rdbuf() const; -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { return rdbuf()->native_handle(); } -# endif +# endif _LIBCPP_HIDE_FROM_ABI bool is_open() const; void open(const char* __s, ios_base::openmode __mode = ios_base::out); -# if _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::out); -# endif +# endif void open(const string& __s, ios_base::openmode __mode = ios_base::out); -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out) { return open(__p.c_str(), __mode); } -# endif // _LIBCPP_STD_VER >= 17 +# endif // _LIBCPP_STD_VER >= 17 _LIBCPP_HIDE_FROM_ABI void __open(int __fd, ios_base::openmode __mode); _LIBCPP_HIDE_FROM_ABI void close(); @@ -1308,14 +1313,14 @@ inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base this->setstate(ios_base::failbit); } -# if _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR template inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const wchar_t* __s, ios_base::openmode __mode) : basic_ostream(std::addressof(__sb_)) { if (__sb_.open(__s, __mode | ios_base::out) == nullptr) this->setstate(ios_base::failbit); } -# endif +# endif // extension template @@ -1367,7 +1372,7 @@ void basic_ofstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode _ this->setstate(ios_base::failbit); } -# if _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR template void basic_ofstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) { if (__sb_.open(__s, __mode | ios_base::out)) @@ -1375,7 +1380,7 @@ void basic_ofstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmod else this->setstate(ios_base::failbit); } -# endif +# endif template void basic_ofstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode) { @@ -1409,26 +1414,26 @@ public: typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 using native_handle_type = typename basic_filebuf<_CharT, _Traits>::native_handle_type; -# endif +# endif _LIBCPP_HIDE_FROM_ABI basic_fstream(); _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); -# if _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); -# endif +# endif _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out); -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template >> _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_fstream( const _Tp& __p, ios_base::openmode __mode = ios_base::in | ios_base::out) : basic_fstream(__p.c_str(), __mode) {} -# endif // _LIBCPP_STD_VER >= 17 +# endif // _LIBCPP_STD_VER >= 17 _LIBCPP_HIDE_FROM_ABI basic_fstream(basic_fstream&& __rhs); @@ -1437,22 +1442,22 @@ public: _LIBCPP_HIDE_FROM_ABI void swap(basic_fstream& __rhs); _LIBCPP_HIDE_FROM_ABI basic_filebuf* rdbuf() const; -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { return rdbuf()->native_handle(); } -# endif +# endif _LIBCPP_HIDE_FROM_ABI bool is_open() const; _LIBCPP_HIDE_FROM_ABI void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); -# if _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); -# endif +# endif _LIBCPP_HIDE_FROM_ABI void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out); -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in | ios_base::out) { return open(__p.c_str(), __mode); } -# endif // _LIBCPP_STD_VER >= 17 +# endif // _LIBCPP_STD_VER >= 17 _LIBCPP_HIDE_FROM_ABI void close(); @@ -1471,14 +1476,14 @@ inline basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base:: this->setstate(ios_base::failbit); } -# if _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR template inline basic_fstream<_CharT, _Traits>::basic_fstream(const wchar_t* __s, ios_base::openmode __mode) : basic_iostream(std::addressof(__sb_)) { if (__sb_.open(__s, __mode) == nullptr) this->setstate(ios_base::failbit); } -# endif +# endif template inline basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openmode __mode) @@ -1530,7 +1535,7 @@ void basic_fstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __ this->setstate(ios_base::failbit); } -# if _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR template void basic_fstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) { if (__sb_.open(__s, __mode)) @@ -1538,7 +1543,7 @@ void basic_fstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode else this->setstate(ios_base::failbit); } -# endif +# endif template void basic_fstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode) { @@ -1554,32 +1559,33 @@ inline void basic_fstream<_CharT, _Traits>::close() { this->setstate(ios_base::failbit); } -# if _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 +# if _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ifstream; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ofstream; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf; -# endif +# endif _LIBCPP_END_NAMESPACE_STD -#endif // !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) +# endif // !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23 -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23 +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_FSTREAM diff --git a/libcxx/include/functional b/libcxx/include/functional index 55b50eea84b7328..dd76d80b184a5c2 100644 --- a/libcxx/include/functional +++ b/libcxx/include/functional @@ -527,72 +527,73 @@ POLICY: For non-variadic implementations, the number of arguments is limited */ -#include <__config> - -#include <__functional/binary_function.h> -#include <__functional/binary_negate.h> -#include <__functional/bind.h> -#include <__functional/binder1st.h> -#include <__functional/binder2nd.h> -#include <__functional/hash.h> -#include <__functional/mem_fn.h> // TODO: deprecate -#include <__functional/mem_fun_ref.h> -#include <__functional/operations.h> -#include <__functional/pointer_to_binary_function.h> -#include <__functional/pointer_to_unary_function.h> -#include <__functional/reference_wrapper.h> -#include <__functional/unary_function.h> -#include <__functional/unary_negate.h> - -#ifndef _LIBCPP_CXX03_LANG -# include <__functional/function.h> -#endif - -#if _LIBCPP_STD_VER >= 17 -# include <__functional/boyer_moore_searcher.h> -# include <__functional/default_searcher.h> -# include <__functional/invoke.h> -# include <__functional/not_fn.h> -#endif - -#if _LIBCPP_STD_VER >= 20 -# include <__functional/bind_back.h> -# include <__functional/bind_front.h> -# include <__functional/identity.h> -# include <__functional/ranges_operations.h> -# include <__type_traits/unwrap_ref.h> -#endif - -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && defined(_LIBCPP_CXX03_LANG) -# include -# include -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 -# include -# include -# include -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/functional> +#else +# include <__config> + +# include <__functional/binary_function.h> +# include <__functional/binary_negate.h> +# include <__functional/bind.h> +# include <__functional/binder1st.h> +# include <__functional/binder2nd.h> +# include <__functional/hash.h> +# include <__functional/mem_fn.h> // TODO: deprecate +# include <__functional/mem_fun_ref.h> +# include <__functional/operations.h> +# include <__functional/pointer_to_binary_function.h> +# include <__functional/pointer_to_unary_function.h> +# include <__functional/reference_wrapper.h> +# include <__functional/unary_function.h> +# include <__functional/unary_negate.h> + +# ifndef _LIBCPP_CXX03_LANG +# include <__functional/function.h> +# endif + +# if _LIBCPP_STD_VER >= 17 +# include <__functional/boyer_moore_searcher.h> +# include <__functional/default_searcher.h> +# include <__functional/invoke.h> +# include <__functional/not_fn.h> +# endif + +# if _LIBCPP_STD_VER >= 20 +# include <__functional/bind_back.h> +# include <__functional/bind_front.h> +# include <__functional/identity.h> +# include <__functional/ranges_operations.h> +# include <__type_traits/unwrap_ref.h> +# endif + +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 +# include +# include +# include +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif #endif #endif // _LIBCPP_FUNCTIONAL diff --git a/libcxx/include/future b/libcxx/include/future index f16f4234c489660..b459b5108157e96 100644 --- a/libcxx/include/future +++ b/libcxx/include/future @@ -362,50 +362,55 @@ template struct uses_allocator, Alloc>; */ -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_THREADS) - -# include <__assert> -# include <__chrono/duration.h> -# include <__chrono/time_point.h> -# include <__condition_variable/condition_variable.h> -# include <__exception/exception_ptr.h> -# include <__memory/addressof.h> -# include <__memory/allocator.h> -# include <__memory/allocator_arg_t.h> -# include <__memory/allocator_destructor.h> -# include <__memory/allocator_traits.h> -# include <__memory/compressed_pair.h> -# include <__memory/pointer_traits.h> -# include <__memory/shared_ptr.h> -# include <__memory/unique_ptr.h> -# include <__memory/uses_allocator.h> -# include <__system_error/error_category.h> -# include <__system_error/error_code.h> -# include <__system_error/error_condition.h> -# include <__type_traits/add_lvalue_reference.h> -# include <__type_traits/aligned_storage.h> -# include <__type_traits/conditional.h> -# include <__type_traits/decay.h> -# include <__type_traits/enable_if.h> -# include <__type_traits/strip_signature.h> -# include <__type_traits/underlying_type.h> -# include <__utility/auto_cast.h> -# include <__utility/forward.h> -# include <__utility/move.h> -# include -# include -# include -# include -# include - -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/future> +#else +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_THREADS) + +# include <__assert> +# include <__chrono/duration.h> +# include <__chrono/time_point.h> +# include <__condition_variable/condition_variable.h> +# include <__exception/exception_ptr.h> +# include <__memory/addressof.h> +# include <__memory/allocator.h> +# include <__memory/allocator_arg_t.h> +# include <__memory/allocator_destructor.h> +# include <__memory/allocator_traits.h> +# include <__memory/compressed_pair.h> +# include <__memory/pointer_traits.h> +# include <__memory/shared_ptr.h> +# include <__memory/unique_ptr.h> +# include <__memory/uses_allocator.h> +# include <__system_error/error_category.h> +# include <__system_error/error_code.h> +# include <__system_error/error_condition.h> +# include <__type_traits/add_lvalue_reference.h> +# include <__type_traits/aligned_storage.h> +# include <__type_traits/conditional.h> +# include <__type_traits/decay.h> +# include <__type_traits/enable_if.h> +# include <__type_traits/strip_signature.h> +# include <__type_traits/underlying_type.h> +# include <__utility/auto_cast.h> +# include <__utility/forward.h> +# include <__utility/move.h> +# include +# include +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -# include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -417,16 +422,16 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc) template <> struct _LIBCPP_TEMPLATE_VIS is_error_code_enum : public true_type {}; -# ifdef _LIBCPP_CXX03_LANG +# ifdef _LIBCPP_CXX03_LANG template <> struct _LIBCPP_TEMPLATE_VIS is_error_code_enum : public true_type {}; -# endif +# endif // enum class launch _LIBCPP_DECLARE_STRONG_ENUM(launch){async = 1, deferred = 2, any = async | deferred}; _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch) -# ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG typedef underlying_type::type __launch_underlying_type; @@ -461,7 +466,7 @@ inline _LIBCPP_HIDE_FROM_ABI launch& operator^=(launch& __x, launch __y) { return __x; } -# endif // !_LIBCPP_CXX03_LANG +# endif // !_LIBCPP_CXX03_LANG // enum class future_status _LIBCPP_DECLARE_STRONG_ENUM(future_status){ready, timeout, deferred}; @@ -488,9 +493,9 @@ class _LIBCPP_EXPORTED_FROM_ABI future_error : public logic_error { friend class promise; public: -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_HIDE_FROM_ABI explicit future_error(future_errc __ec) : future_error(std::make_error_code(__ec)) {} -# endif +# endif _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; } @@ -500,12 +505,12 @@ public: // Declared above std::future_error void __throw_future_error(future_errc __ev) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw future_error(make_error_code(__ev)); -# else +# else (void)__ev; _LIBCPP_VERBOSE_ABORT("future_error was thrown in -fno-exceptions mode"); -# endif +# endif } class _LIBCPP_EXPORTED_FROM_ABI __assoc_sub_state : public __shared_count { @@ -779,15 +784,15 @@ inline __deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f) : __f template void __deferred_assoc_state<_Rp, _Fp>::__execute() { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS this->set_value(__func_()); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -809,16 +814,16 @@ inline __deferred_assoc_state::__deferred_assoc_state(_Fp&& __f) : __ template void __deferred_assoc_state::__execute() { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __func_(); this->set_value(); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -840,15 +845,15 @@ inline __async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f) : __func_(s template void __async_assoc_state<_Rp, _Fp>::__execute() { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS this->set_value(__func_()); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -876,16 +881,16 @@ inline __async_assoc_state::__async_assoc_state(_Fp&& __f) : __func_( template void __async_assoc_state::__execute() { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __func_(); this->set_value(); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -1613,11 +1618,11 @@ public: template , packaged_task>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI explicit packaged_task(_Fp&& __f) : __f_(std::forward<_Fp>(__f)) {} -# if _LIBCPP_STD_VER <= 14 +# if _LIBCPP_STD_VER <= 14 template , packaged_task>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) : __f_(allocator_arg_t(), __a, std::forward<_Fp>(__f)), __p_(allocator_arg_t(), __a) {} -# endif +# endif // ~packaged_task() = default; // no copy @@ -1656,15 +1661,15 @@ void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) { __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __p_.set_value(__f_(std::forward<_ArgTypes>(__args)...)); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __p_.set_exception(current_exception()); } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -1673,15 +1678,15 @@ void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __ __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __p_.set_value_at_thread_exit(__f_(std::forward<_ArgTypes>(__args)...)); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __p_.set_exception_at_thread_exit(current_exception()); } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -1705,11 +1710,11 @@ public: _LIBCPP_HIDE_FROM_ABI packaged_task() _NOEXCEPT : __p_(nullptr) {} template , packaged_task>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI explicit packaged_task(_Fp&& __f) : __f_(std::forward<_Fp>(__f)) {} -# if _LIBCPP_STD_VER <= 14 +# if _LIBCPP_STD_VER <= 14 template , packaged_task>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) : __f_(allocator_arg_t(), __a, std::forward<_Fp>(__f)), __p_(allocator_arg_t(), __a) {} -# endif +# endif // ~packaged_task() = default; // no copy @@ -1742,7 +1747,7 @@ public: _LIBCPP_HIDE_FROM_ABI void reset(); }; -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template packaged_task(_Rp (*)(_Args...)) -> packaged_task<_Rp(_Args...)>; @@ -1750,7 +1755,7 @@ packaged_task(_Rp (*)(_Args...)) -> packaged_task<_Rp(_Args...)>; template ::type> packaged_task(_Fp) -> packaged_task<_Stripped>; -# endif +# endif template void packaged_task::operator()(_ArgTypes... __args) { @@ -1758,16 +1763,16 @@ void packaged_task::operator()(_ArgTypes... __args) { __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __f_(std::forward<_ArgTypes>(__args)...); __p_.set_value(); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __p_.set_exception(current_exception()); } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -1776,16 +1781,16 @@ void packaged_task::make_ready_at_thread_exit(_ArgTypes... _ __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __f_(std::forward<_ArgTypes>(__args)...); __p_.set_value_at_thread_exit(); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __p_.set_exception_at_thread_exit(current_exception()); } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -1801,10 +1806,10 @@ swap(packaged_task<_Rp(_ArgTypes...)>& __x, packaged_task<_Rp(_ArgTypes...)>& __ __x.swap(__y); } -# if _LIBCPP_STD_VER <= 14 +# if _LIBCPP_STD_VER <= 14 template struct _LIBCPP_TEMPLATE_VIS uses_allocator, _Alloc> : public true_type {}; -# endif +# endif template _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_deferred_assoc_state(_Fp&& __f) { @@ -1821,7 +1826,7 @@ _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f) { return future<_Rp>(__h.get()); } -# ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template class _LIBCPP_HIDDEN __async_func { @@ -1857,18 +1862,18 @@ async(launch __policy, _Fp&& __f, _Args&&... __args) { typedef __async_func<__decay_t<_Fp>, __decay_t<_Args>...> _BF; typedef typename _BF::_Rp _Rp; -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif +# endif if (__does_policy_contain(__policy, launch::async)) return std::__make_async_assoc_state<_Rp>( _BF(_LIBCPP_AUTO_CAST(std::forward<_Fp>(__f)), _LIBCPP_AUTO_CAST(std::forward<_Args>(__args))...)); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { if (__policy == launch::async) throw; } -# endif +# endif if (__does_policy_contain(__policy, launch::deferred)) return std::__make_deferred_assoc_state<_Rp>( @@ -1882,7 +1887,7 @@ async(_Fp&& __f, _Args&&... __args) { return std::async(launch::any, std::forward<_Fp>(__f), std::forward<_Args>(__args)...); } -# endif // C++03 +# endif // C++03 // shared_future @@ -2059,18 +2064,19 @@ _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#endif // !defined(_LIBCPP_HAS_NO_THREADS) +# endif // !defined(_LIBCPP_HAS_NO_THREADS) -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 +# include +# endif -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_FUTURE diff --git a/libcxx/include/initializer_list b/libcxx/include/initializer_list index 680ca1cd20d5501..aa5583c6e47852a 100644 --- a/libcxx/include/initializer_list +++ b/libcxx/include/initializer_list @@ -42,17 +42,22 @@ template const E* end(initializer_list il) noexcept; // constexpr in */ -#include <__config> -#include +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/initializer_list> +#else +# include <__config> +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif namespace std // purposefully not versioned { -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template class _LIBCPP_TEMPLATE_VIS initializer_list { @@ -91,8 +96,9 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* end(initia return __il.end(); } -#endif // !defined(_LIBCPP_CXX03_LANG) +# endif // !defined(_LIBCPP_CXX03_LANG) } // namespace std +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_INITIALIZER_LIST diff --git a/libcxx/include/inttypes.h b/libcxx/include/inttypes.h index 8664412bd52ffce..202f774343a9b30 100644 --- a/libcxx/include/inttypes.h +++ b/libcxx/include/inttypes.h @@ -235,30 +235,36 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int */ -#include <__config> +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/inttypes.h> +#else +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif /* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed for C++11 unless __STDC_FORMAT_MACROS is defined */ -#if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS) -# define __STDC_FORMAT_MACROS -#endif +# if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS) +# define __STDC_FORMAT_MACROS +# endif -#if __has_include_next() -# include_next -#endif +# if __has_include_next() +# include_next +# endif -#ifdef __cplusplus +# ifdef __cplusplus -# include +# include -# undef imaxabs -# undef imaxdiv +# undef imaxabs +# undef imaxdiv -#endif // __cplusplus +# endif // __cplusplus +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_INTTYPES_H diff --git a/libcxx/include/iomanip b/libcxx/include/iomanip index 538fc413bb8ee24..6b01bfc76d61be4 100644 --- a/libcxx/include/iomanip +++ b/libcxx/include/iomanip @@ -42,18 +42,23 @@ template */ -#include <__config> +#include <__configuration/cxx03.h> -#ifndef _LIBCPP_HAS_NO_LOCALIZATION +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/iomanip> +#else +# include <__config> -# include <__ostream/basic_ostream.h> -# include -# include -# include +# ifndef _LIBCPP_HAS_NO_LOCALIZATION -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +# include <__ostream/basic_ostream.h> +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -236,9 +241,9 @@ public: template _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS typename basic_istream<_CharT, _Traits>::sentry __s(__is); if (__s) { typedef istreambuf_iterator<_CharT, _Traits> _Ip; @@ -248,11 +253,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x) { __mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_); __is.setstate(__err); } -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __is.__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return __is; } @@ -285,9 +290,9 @@ public: template _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS typename basic_ostream<_CharT, _Traits>::sentry __s(__os); if (__s) { typedef ostreambuf_iterator<_CharT, _Traits> _Op; @@ -296,11 +301,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x) { if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed()) __os.setstate(ios_base::badbit); } -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __os.__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return __os; } @@ -333,9 +338,9 @@ public: template _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS typename basic_istream<_CharT, _Traits>::sentry __s(__is); if (__s) { typedef istreambuf_iterator<_CharT, _Traits> _Ip; @@ -345,11 +350,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x) { __tf.get(_Ip(__is), _Ip(), __is, __err, __x.__tm_, __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_)); __is.setstate(__err); } -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __is.__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return __is; } @@ -382,9 +387,9 @@ public: template _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS typename basic_ostream<_CharT, _Traits>::sentry __s(__os); if (__s) { typedef ostreambuf_iterator<_CharT, _Traits> _Op; @@ -394,11 +399,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x) { .failed()) __os.setstate(ios_base::badbit); } -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __os.__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return __os; } @@ -510,7 +515,7 @@ __quoted(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT return __quoted_proxy<_CharT, _Traits, _Allocator>(__s, __delim, __escape); } -# if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template _LIBCPP_HIDE_FROM_ABI auto quoted(const _CharT* __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) { @@ -540,10 +545,11 @@ quoted(basic_string_view<_CharT, _Traits> __sv, _CharT __delim = _CharT('"'), _C return __quoted_output_proxy<_CharT, _Traits>(__sv.data(), __sv.data() + __sv.size(), __delim, __escape); } -# endif // _LIBCPP_STD_VER >= 14 +# endif // _LIBCPP_STD_VER >= 14 _LIBCPP_END_NAMESPACE_STD -#endif // !_LIBCPP_HAS_NO_LOCALIZATION +# endif // !_LIBCPP_HAS_NO_LOCALIZATION +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_IOMANIP diff --git a/libcxx/include/ios b/libcxx/include/ios index 546c5462f222dbd..fbd796f29ce961d 100644 --- a/libcxx/include/ios +++ b/libcxx/include/ios @@ -211,37 +211,42 @@ storage-class-specifier const error_category& iostream_category() noexcept; */ -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) - -# include <__fwd/ios.h> -# include <__ios/fpos.h> -# include <__locale> -# include <__memory/addressof.h> -# include <__system_error/error_category.h> -# include <__system_error/error_code.h> -# include <__system_error/error_condition.h> -# include <__system_error/system_error.h> -# include <__utility/swap.h> -# include <__verbose_abort> -# include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/ios> +#else +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +# include <__fwd/ios.h> +# include <__ios/fpos.h> +# include <__locale> +# include <__memory/addressof.h> +# include <__system_error/error_category.h> +# include <__system_error/error_code.h> +# include <__system_error/error_condition.h> +# include <__system_error/system_error.h> +# include <__utility/swap.h> +# include <__verbose_abort> +# include // standard-mandated includes // [ios.syn] -# include +# include -# if _LIBCPP_HAS_ATOMIC_HEADER -# include <__atomic/atomic.h> // for __xindex_ -# endif +# if _LIBCPP_HAS_ATOMIC_HEADER +# include <__atomic/atomic.h> // for __xindex_ +# endif -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -# include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -284,20 +289,20 @@ public: static const openmode in = 0x08; static const openmode out = 0x10; static const openmode trunc = 0x20; -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 static const openmode noreplace = 0x40; -# endif +# endif enum seekdir { beg, cur, end }; -# if _LIBCPP_STD_VER <= 14 +# if _LIBCPP_STD_VER <= 14 typedef iostate io_state; typedef openmode open_mode; typedef seekdir seek_dir; typedef std::streamoff streamoff; typedef std::streampos streampos; -# endif +# endif class _LIBCPP_EXPORTED_FROM_ABI Init; @@ -397,11 +402,11 @@ private: size_t __event_cap_; // TODO(EricWF): Enable this for both Clang and GCC. Currently it is only // enabled with clang. -# if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) +# if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) static atomic __xindex_; -# else +# else static int __xindex_; -# endif +# endif long* __iarray_; size_t __iarray_size_; size_t __iarray_cap_; @@ -417,10 +422,10 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) template <> struct _LIBCPP_TEMPLATE_VIS is_error_code_enum : public true_type {}; -# ifdef _LIBCPP_CXX03_LANG +# ifdef _LIBCPP_CXX03_LANG template <> struct _LIBCPP_TEMPLATE_VIS is_error_code_enum : public true_type {}; -# endif +# endif _LIBCPP_EXPORTED_FROM_ABI const error_category& iostream_category() _NOEXCEPT; @@ -441,11 +446,11 @@ public: }; [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_failure(char const* __msg) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw ios_base::failure(__msg); -# else +# else _LIBCPP_VERBOSE_ABORT("ios_base::failure was thrown in -fno-exceptions mode with message \"%s\"", __msg); -# endif +# endif } class _LIBCPP_EXPORTED_FROM_ABI ios_base::Init { @@ -569,13 +574,13 @@ public: static_assert(is_same<_CharT, typename traits_type::char_type>::value, "traits_type::char_type must be the same type as CharT"); -# ifdef _LIBCPP_CXX03_LANG +# ifdef _LIBCPP_CXX03_LANG // Preserve the ability to compare with literal 0, // and implicitly convert to bool, but not implicitly convert to int. _LIBCPP_HIDE_FROM_ABI operator void*() const { return fail() ? nullptr : (void*)this; } -# else +# else _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return !fail(); } -# endif +# endif _LIBCPP_HIDE_FROM_ABI bool operator!() const { return fail(); } _LIBCPP_HIDE_FROM_ABI iostate rdstate() const { return ios_base::rdstate(); } @@ -625,11 +630,11 @@ protected: private: basic_ostream* __tie_; -# if defined(_LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE) +# if defined(_LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE) using _FillType = _FillHelper; -# else +# else using _FillType = _SentinelValueFill; -# endif +# endif mutable _FillType __fill_; }; @@ -744,9 +749,9 @@ inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::set_rdbuf(basic_st extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios; -# endif +# endif _LIBCPP_HIDE_FROM_ABI inline ios_base& boolalpha(ios_base& __str) { __str.setf(ios_base::boolalpha); @@ -872,22 +877,23 @@ _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif +# endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_IOS diff --git a/libcxx/include/iosfwd b/libcxx/include/iosfwd index 9079ce21512f905..e5f52d6c7f3dc29 100644 --- a/libcxx/include/iosfwd +++ b/libcxx/include/iosfwd @@ -105,21 +105,26 @@ using wosyncstream = basic_osyncstream; // C++20 */ -#include <__config> -#include <__fwd/fstream.h> -#include <__fwd/ios.h> -#include <__fwd/istream.h> -#include <__fwd/memory.h> -#include <__fwd/ostream.h> -#include <__fwd/sstream.h> -#include <__fwd/streambuf.h> -#include <__fwd/string.h> -#include <__std_mbstate_t.h> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/iosfwd> +#else +# include <__config> +# include <__fwd/fstream.h> +# include <__fwd/ios.h> +# include <__fwd/istream.h> +# include <__fwd/memory.h> +# include <__fwd/ostream.h> +# include <__fwd/sstream.h> +# include <__fwd/streambuf.h> +# include <__fwd/string.h> +# include <__std_mbstate_t.h> +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -131,34 +136,34 @@ class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator; template class _LIBCPP_TEMPLATE_VIS fpos; typedef fpos streampos; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS typedef fpos wstreampos; -#endif -#if _LIBCPP_HAS_CHAR8_T +# endif +# if _LIBCPP_HAS_CHAR8_T typedef fpos u8streampos; -#endif +# endif typedef fpos u16streampos; typedef fpos u32streampos; -#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) +# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) template , class _Allocator = allocator<_CharT>> class basic_syncbuf; using syncbuf = basic_syncbuf; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using wsyncbuf = basic_syncbuf; -# endif +# endif template , class _Allocator = allocator<_CharT>> class basic_osyncstream; using osyncstream = basic_osyncstream; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using wosyncstream = basic_osyncstream; -# endif +# endif -#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) +# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) template class __save_flags { @@ -182,5 +187,6 @@ public: }; _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_IOSFWD diff --git a/libcxx/include/iostream b/libcxx/include/iostream index 5df45c6d3f78e74..c60af72bbcd6fea 100644 --- a/libcxx/include/iostream +++ b/libcxx/include/iostream @@ -33,20 +33,25 @@ extern wostream wclog; */ -#include <__config> -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/iostream> +#else +# include <__config> +# include // standard-mandated includes // [iostream.syn] -#include -#include -#include -#include +# include +# include +# include +# include -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -55,13 +60,14 @@ extern _LIBCPP_EXPORTED_FROM_ABI ostream cout; extern _LIBCPP_EXPORTED_FROM_ABI ostream cerr; extern _LIBCPP_EXPORTED_FROM_ABI ostream clog; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern _LIBCPP_EXPORTED_FROM_ABI wistream wcin; extern _LIBCPP_EXPORTED_FROM_ABI wostream wcout; extern _LIBCPP_EXPORTED_FROM_ABI wostream wcerr; extern _LIBCPP_EXPORTED_FROM_ABI wostream wclog; -#endif +# endif _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_IOSTREAM diff --git a/libcxx/include/istream b/libcxx/include/istream index 45ca95369c51d3c..a19dcf0ebb1afe2 100644 --- a/libcxx/include/istream +++ b/libcxx/include/istream @@ -158,30 +158,35 @@ template */ -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) - -# include <__fwd/istream.h> -# include <__iterator/istreambuf_iterator.h> -# include <__ostream/basic_ostream.h> -# include <__type_traits/conjunction.h> -# include <__type_traits/enable_if.h> -# include <__type_traits/is_base_of.h> -# include <__type_traits/make_unsigned.h> -# include <__utility/declval.h> -# include <__utility/forward.h> -# include -# include -# include -# include - -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/istream> +#else +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +# include <__fwd/istream.h> +# include <__iterator/istreambuf_iterator.h> +# include <__ostream/basic_ostream.h> +# include <__type_traits/conjunction.h> +# include <__type_traits/enable_if.h> +# include <__type_traits/is_base_of.h> +# include <__type_traits/make_unsigned.h> +# include <__utility/declval.h> +# include <__utility/forward.h> +# include +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -# include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -357,13 +362,13 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) { ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __s(__is); if (__s) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS typedef istreambuf_iterator<_CharT, _Traits> _Ip; typedef num_get<_CharT, _Ip> _Fp; std::use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __n); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -371,7 +376,7 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) { throw; } } -# endif +# endif __is.setstate(__state); } return __is; @@ -438,9 +443,9 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __s(__is); if (__s) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS typedef istreambuf_iterator<_CharT, _Traits> _Ip; typedef num_get<_CharT, _Ip> _Fp; long __temp; @@ -454,7 +459,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp } else { __n = static_cast<_Tp>(__temp); } -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -462,7 +467,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp throw; } } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __is.setstate(__state); } return __is; @@ -484,9 +489,9 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n) ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif +# endif _CharT* __s = __p; const ctype<_CharT>& __ct = std::use_facet >(__is.getloc()); while (__s != __p + (__n - 1)) { @@ -505,7 +510,7 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n) __is.width(0); if (__s == __p) __state |= ios_base::failbit; -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -513,13 +518,13 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n) throw; } } -# endif +# endif __is.setstate(__state); } return __is; } -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& @@ -542,7 +547,7 @@ operator>>(basic_istream& __is, signed char (&__buf)[_Np]) { return __is >> (char(&)[_Np])__buf; } -# else +# else template inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& @@ -565,22 +570,22 @@ operator>>(basic_istream& __is, signed char* __s) { return __is >> (char*)__s; } -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 template _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c) { ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif +# endif typename _Traits::int_type __i = __is.rdbuf()->sbumpc(); if (_Traits::eq_int_type(__i, _Traits::eof())) __state |= ios_base::eofbit | ios_base::failbit; else __c = _Traits::to_char_type(__i); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -588,7 +593,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_ throw; } } -# endif +# endif __is.setstate(__state); } return __is; @@ -614,9 +619,9 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambufrdbuf()->sgetc(); if (traits_type::eq_int_type(__i, _Traits::eof())) { @@ -630,7 +635,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf::operator>>(basic_streambuf::int_type basic_istream<_CharT, _Traits> int_type __r = traits_type::eof(); sentry __s(*this, true); if (__s) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif +# endif __r = this->rdbuf()->sbumpc(); if (traits_type::eq_int_type(__r, traits_type::eof())) __state |= ios_base::failbit | ios_base::eofbit; else __gc_ = 1; -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__setstate_nothrow(this->rdstate() | ios_base::badbit); if (this->exceptions() & ios_base::badbit) { throw; } } -# endif +# endif this->setstate(__state); } return __r; @@ -685,9 +690,9 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _ sentry __sen(*this, true); if (__sen) { if (__n > 0) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif +# endif while (__gc_ < __n - 1) { int_type __i = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__i, traits_type::eof())) { @@ -703,7 +708,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _ } if (__gc_ == 0) __state |= ios_base::failbit; -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -713,7 +718,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _ throw; } } -# endif +# endif } else { __state |= ios_base::failbit; } @@ -734,9 +739,9 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf& __s __gc_ = 0; sentry __sen(*this, true); if (__sen) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS while (true) { typename traits_type::int_type __i = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__i, traits_type::eof())) { @@ -751,12 +756,12 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf& __s __inc_gcount(); this->rdbuf()->sbumpc(); } -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; // according to the spec, exceptions here are caught but not rethrown } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS if (__gc_ == 0) __state |= ios_base::failbit; this->setstate(__state); @@ -771,9 +776,9 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ __gc_ = 0; sentry __sen(*this, true); if (__sen) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS while (true) { typename traits_type::int_type __i = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__i, traits_type::eof())) { @@ -794,7 +799,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ this->rdbuf()->sbumpc(); __inc_gcount(); } -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -806,7 +811,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ throw; } } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } if (__n > 0) *__s = char_type(); @@ -822,9 +827,9 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz __gc_ = 0; sentry __sen(*this, true); if (__sen) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS if (__n == numeric_limits::max()) { while (true) { typename traits_type::int_type __i = this->rdbuf()->sbumpc(); @@ -848,7 +853,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz break; } } -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -856,7 +861,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz throw; } } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS this->setstate(__state); } return *this; @@ -869,13 +874,13 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits> int_type __r = traits_type::eof(); sentry __sen(*this, true); if (__sen) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __r = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__r, traits_type::eof())) __state |= ios_base::eofbit; -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -883,7 +888,7 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits> throw; } } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS this->setstate(__state); } return __r; @@ -895,13 +900,13 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::read(char_type* __gc_ = 0; sentry __sen(*this, true); if (__sen) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __gc_ = this->rdbuf()->sgetn(__s, __n); if (__gc_ != __n) __state |= ios_base::failbit | ios_base::eofbit; -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -909,7 +914,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::read(char_type* throw; } } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } else { __state |= ios_base::failbit; } @@ -923,9 +928,9 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _ __gc_ = 0; sentry __sen(*this, true); if (__sen) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS streamsize __c = this->rdbuf()->in_avail(); switch (__c) { case -1: @@ -940,7 +945,7 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _ __state |= ios_base::failbit | ios_base::eofbit; break; } -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -948,7 +953,7 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _ throw; } } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } else { __state |= ios_base::failbit; } @@ -963,12 +968,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::putback(char_typ this->clear(__state); sentry __sen(*this, true); if (__sen) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS if (this->rdbuf() == nullptr || this->rdbuf()->sputbackc(__c) == traits_type::eof()) __state |= ios_base::badbit; -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -976,7 +981,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::putback(char_typ throw; } } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } else { __state |= ios_base::failbit; } @@ -991,12 +996,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() { this->clear(__state); sentry __sen(*this, true); if (__sen) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS if (this->rdbuf() == nullptr || this->rdbuf()->sungetc() == traits_type::eof()) __state |= ios_base::badbit; -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -1004,7 +1009,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() { throw; } } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } else { __state |= ios_base::failbit; } @@ -1021,14 +1026,14 @@ int basic_istream<_CharT, _Traits>::sync() { int __r = 0; if (__sen) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS if (this->rdbuf()->pubsync() == -1) { __state |= ios_base::badbit; __r = -1; } -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -1036,7 +1041,7 @@ int basic_istream<_CharT, _Traits>::sync() { throw; } } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS this->setstate(__state); } return __r; @@ -1048,11 +1053,11 @@ typename basic_istream<_CharT, _Traits>::pos_type basic_istream<_CharT, _Traits> pos_type __r(-1); sentry __sen(*this, true); if (__sen) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -1060,7 +1065,7 @@ typename basic_istream<_CharT, _Traits>::pos_type basic_istream<_CharT, _Traits> throw; } } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS this->setstate(__state); } return __r; @@ -1072,12 +1077,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(pos_type _ this->clear(__state); sentry __sen(*this, true); if (__sen) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1)) __state |= ios_base::failbit; -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -1085,7 +1090,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(pos_type _ throw; } } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS this->setstate(__state); } return *this; @@ -1097,12 +1102,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(off_type _ this->clear(__state); sentry __sen(*this, true); if (__sen) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1)) __state |= ios_base::failbit; -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -1110,7 +1115,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(off_type _ throw; } } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS this->setstate(__state); } return *this; @@ -1121,9 +1126,9 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _ ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); if (__sen) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS const ctype<_CharT>& __ct = std::use_facet >(__is.getloc()); while (true) { typename _Traits::int_type __i = __is.rdbuf()->sgetc(); @@ -1135,7 +1140,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _ break; __is.rdbuf()->sbumpc(); } -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -1143,7 +1148,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _ throw; } } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __is.setstate(__state); } return __is; @@ -1211,9 +1216,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _ ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif +# endif __str.clear(); using _Size = typename basic_string<_CharT, _Traits, _Allocator>::size_type; streamsize const __width = __is.width(); @@ -1243,7 +1248,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _ __is.width(0); if (__c == 0) __state |= ios_base::failbit; -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -1251,7 +1256,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _ throw; } } -# endif +# endif __is.setstate(__state); } return __is; @@ -1263,9 +1268,9 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); if (__sen) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif +# endif __str.clear(); streamsize __extr = 0; while (true) { @@ -1286,7 +1291,7 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All } if (__extr == 0) __state |= ios_base::failbit; -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -1294,7 +1299,7 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All throw; } } -# endif +# endif __is.setstate(__state); } return __is; @@ -1324,9 +1329,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) { ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif +# endif basic_string<_CharT, _Traits> __str; const ctype<_CharT>& __ct = std::use_facet >(__is.getloc()); size_t __c = 0; @@ -1348,7 +1353,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) { __x = bitset<_Size>(__str); if (_Size > 0 && __c == 0) __state |= ios_base::failbit; -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -1356,29 +1361,30 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) { throw; } } -# endif +# endif __is.setstate(__state); } return __is; } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream; -# endif +# endif extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream; _LIBCPP_END_NAMESPACE_STD -#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) +# endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# endif _LIBCPP_POP_MACROS +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_ISTREAM diff --git a/libcxx/include/iterator b/libcxx/include/iterator index fca75f0a19ed1b9..3d10778b012c941 100644 --- a/libcxx/include/iterator +++ b/libcxx/include/iterator @@ -679,76 +679,82 @@ template constexpr const E* data(initializer_list il) noexcept; */ -#include <__config> -#include <__iterator/access.h> -#include <__iterator/advance.h> -#include <__iterator/back_insert_iterator.h> -#include <__iterator/distance.h> -#include <__iterator/front_insert_iterator.h> -#include <__iterator/insert_iterator.h> -#include <__iterator/istream_iterator.h> -#include <__iterator/istreambuf_iterator.h> -#include <__iterator/iterator.h> -#include <__iterator/iterator_traits.h> -#include <__iterator/move_iterator.h> -#include <__iterator/next.h> -#include <__iterator/ostream_iterator.h> -#include <__iterator/ostreambuf_iterator.h> -#include <__iterator/prev.h> -#include <__iterator/reverse_iterator.h> -#include <__iterator/wrap_iter.h> - -#if _LIBCPP_STD_VER >= 14 -# include <__iterator/reverse_access.h> -#endif - -#if _LIBCPP_STD_VER >= 17 -# include <__iterator/data.h> -# include <__iterator/empty.h> -# include <__iterator/size.h> -#endif - -#if _LIBCPP_STD_VER >= 20 -# include <__iterator/common_iterator.h> -# include <__iterator/concepts.h> -# include <__iterator/counted_iterator.h> -# include <__iterator/default_sentinel.h> -# include <__iterator/incrementable_traits.h> -# include <__iterator/indirectly_comparable.h> -# include <__iterator/iter_move.h> -# include <__iterator/iter_swap.h> -# include <__iterator/mergeable.h> -# include <__iterator/move_sentinel.h> -# include <__iterator/permutable.h> -# include <__iterator/projected.h> -# include <__iterator/readable_traits.h> -# include <__iterator/sortable.h> -# include <__iterator/unreachable_sentinel.h> -#endif - -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/iterator> +#else +# include <__config> +# include <__iterator/access.h> +# include <__iterator/advance.h> +# include <__iterator/back_insert_iterator.h> +# include <__iterator/distance.h> +# include <__iterator/front_insert_iterator.h> +# include <__iterator/insert_iterator.h> +# include <__iterator/istream_iterator.h> +# include <__iterator/istreambuf_iterator.h> +# include <__iterator/iterator.h> +# include <__iterator/iterator_traits.h> +# include <__iterator/move_iterator.h> +# include <__iterator/next.h> +# include <__iterator/ostream_iterator.h> +# include <__iterator/ostreambuf_iterator.h> +# include <__iterator/prev.h> +# include <__iterator/reverse_iterator.h> +# include <__iterator/wrap_iter.h> + +# if _LIBCPP_STD_VER >= 14 +# include <__iterator/reverse_access.h> +# endif + +# if _LIBCPP_STD_VER >= 17 +# include <__iterator/data.h> +# include <__iterator/empty.h> +# include <__iterator/size.h> +# endif + +# if _LIBCPP_STD_VER >= 20 +# include <__iterator/common_iterator.h> +# include <__iterator/concepts.h> +# include <__iterator/counted_iterator.h> +# include <__iterator/default_sentinel.h> +# include <__iterator/incrementable_traits.h> +# include <__iterator/indirectly_comparable.h> +# include <__iterator/iter_move.h> +# include <__iterator/iter_swap.h> +# include <__iterator/mergeable.h> +# include <__iterator/move_sentinel.h> +# include <__iterator/permutable.h> +# include <__iterator/projected.h> +# include <__iterator/readable_traits.h> +# include <__iterator/sortable.h> +# include <__iterator/unreachable_sentinel.h> +# endif + +# include // standard-mandated includes // [iterator.synopsis] -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 -# include -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -#endif +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 +# include +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_ITERATOR diff --git a/libcxx/include/latch b/libcxx/include/latch index b56e49bc768bf92..c80b906328c4a2d 100644 --- a/libcxx/include/latch +++ b/libcxx/include/latch @@ -40,26 +40,31 @@ namespace std */ -#include <__config> +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_THREADS) +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/latch> +#else +# include <__config> -# include <__assert> -# include <__atomic/atomic_base.h> -# include <__atomic/atomic_sync.h> -# include <__atomic/memory_order.h> -# include -# include -# include +# if !defined(_LIBCPP_HAS_NO_THREADS) -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +# include <__assert> +# include <__atomic/atomic_base.h> +# include <__atomic/atomic_sync.h> +# include <__atomic/memory_order.h> +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -# include <__undef_macros> +# include <__undef_macros> -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_BEGIN_NAMESPACE_STD @@ -116,14 +121,15 @@ private: _LIBCPP_END_NAMESPACE_STD -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_POP_MACROS -#endif // !defined(_LIBCPP_HAS_NO_THREADS) +# endif // !defined(_LIBCPP_HAS_NO_THREADS) -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_LATCH diff --git a/libcxx/include/limits b/libcxx/include/limits index b85c66257d27b7b..99dd411b54286e0 100644 --- a/libcxx/include/limits +++ b/libcxx/include/limits @@ -102,18 +102,23 @@ template<> class numeric_limits; */ -#include <__config> -#include <__type_traits/is_arithmetic.h> -#include <__type_traits/is_signed.h> -#include <__type_traits/remove_cv.h> +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/limits> +#else +# include <__config> +# include <__type_traits/is_arithmetic.h> +# include <__type_traits/is_signed.h> +# include <__type_traits/remove_cv.h> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> -#include +# include <__undef_macros> +# include _LIBCPP_BEGIN_NAMESPACE_STD @@ -227,11 +232,11 @@ protected: static _LIBCPP_CONSTEXPR const bool is_bounded = true; static _LIBCPP_CONSTEXPR const bool is_modulo = !std::is_signed<_Tp>::value; -#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || defined(__wasm__) +# if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || defined(__wasm__) static _LIBCPP_CONSTEXPR const bool traps = true; -#else +# else static _LIBCPP_CONSTEXPR const bool traps = false; -#endif +# endif static _LIBCPP_CONSTEXPR const bool tinyness_before = false; static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero; }; @@ -332,11 +337,11 @@ protected: static _LIBCPP_CONSTEXPR const bool is_modulo = false; static _LIBCPP_CONSTEXPR const bool traps = false; -#if (defined(__arm__) || defined(__aarch64__)) +# if (defined(__arm__) || defined(__aarch64__)) static _LIBCPP_CONSTEXPR const bool tinyness_before = true; -#else +# else static _LIBCPP_CONSTEXPR const bool tinyness_before = false; -#endif +# endif static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest; }; @@ -389,11 +394,11 @@ protected: static _LIBCPP_CONSTEXPR const bool is_modulo = false; static _LIBCPP_CONSTEXPR const bool traps = false; -#if (defined(__arm__) || defined(__aarch64__)) +# if (defined(__arm__) || defined(__aarch64__)) static _LIBCPP_CONSTEXPR const bool tinyness_before = true; -#else +# else static _LIBCPP_CONSTEXPR const bool tinyness_before = false; -#endif +# endif static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest; }; @@ -441,20 +446,20 @@ protected: return __LDBL_DENORM_MIN__; } -#if defined(__powerpc__) && defined(__LONG_DOUBLE_IBM128__) +# if defined(__powerpc__) && defined(__LONG_DOUBLE_IBM128__) static _LIBCPP_CONSTEXPR const bool is_iec559 = false; -#else +# else static _LIBCPP_CONSTEXPR const bool is_iec559 = true; -#endif +# endif static _LIBCPP_CONSTEXPR const bool is_bounded = true; static _LIBCPP_CONSTEXPR const bool is_modulo = false; static _LIBCPP_CONSTEXPR const bool traps = false; -#if (defined(__arm__) || defined(__aarch64__)) +# if (defined(__arm__) || defined(__aarch64__)) static _LIBCPP_CONSTEXPR const bool tinyness_before = true; -#else +# else static _LIBCPP_CONSTEXPR const bool tinyness_before = false; -#endif +# endif static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest; }; @@ -577,8 +582,9 @@ _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_LIMITS diff --git a/libcxx/include/list b/libcxx/include/list index 953027542712260..a8a5f3088e9bb76 100644 --- a/libcxx/include/list +++ b/libcxx/include/list @@ -197,69 +197,74 @@ template */ -#include <__algorithm/comp.h> -#include <__algorithm/equal.h> -#include <__algorithm/lexicographical_compare.h> -#include <__algorithm/lexicographical_compare_three_way.h> -#include <__algorithm/min.h> -#include <__assert> -#include <__config> -#include <__format/enable_insertable.h> -#include <__iterator/distance.h> -#include <__iterator/iterator_traits.h> -#include <__iterator/move_iterator.h> -#include <__iterator/next.h> -#include <__iterator/prev.h> -#include <__iterator/reverse_iterator.h> -#include <__memory/addressof.h> -#include <__memory/allocation_guard.h> -#include <__memory/allocator.h> -#include <__memory/allocator_traits.h> -#include <__memory/compressed_pair.h> -#include <__memory/construct_at.h> -#include <__memory/pointer_traits.h> -#include <__memory/swap_allocator.h> -#include <__memory_resource/polymorphic_allocator.h> -#include <__ranges/access.h> -#include <__ranges/concepts.h> -#include <__ranges/container_compatible_range.h> -#include <__ranges/from_range.h> -#include <__type_traits/conditional.h> -#include <__type_traits/container_traits.h> -#include <__type_traits/enable_if.h> -#include <__type_traits/is_allocator.h> -#include <__type_traits/is_nothrow_assignable.h> -#include <__type_traits/is_nothrow_constructible.h> -#include <__type_traits/is_pointer.h> -#include <__type_traits/is_same.h> -#include <__type_traits/type_identity.h> -#include <__utility/forward.h> -#include <__utility/move.h> -#include <__utility/swap.h> -#include -#include -#include // __launder -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/list> +#else +# include <__algorithm/comp.h> +# include <__algorithm/equal.h> +# include <__algorithm/lexicographical_compare.h> +# include <__algorithm/lexicographical_compare_three_way.h> +# include <__algorithm/min.h> +# include <__assert> +# include <__config> +# include <__format/enable_insertable.h> +# include <__iterator/distance.h> +# include <__iterator/iterator_traits.h> +# include <__iterator/move_iterator.h> +# include <__iterator/next.h> +# include <__iterator/prev.h> +# include <__iterator/reverse_iterator.h> +# include <__memory/addressof.h> +# include <__memory/allocation_guard.h> +# include <__memory/allocator.h> +# include <__memory/allocator_traits.h> +# include <__memory/compressed_pair.h> +# include <__memory/construct_at.h> +# include <__memory/pointer_traits.h> +# include <__memory/swap_allocator.h> +# include <__memory_resource/polymorphic_allocator.h> +# include <__ranges/access.h> +# include <__ranges/concepts.h> +# include <__ranges/container_compatible_range.h> +# include <__ranges/from_range.h> +# include <__type_traits/conditional.h> +# include <__type_traits/container_traits.h> +# include <__type_traits/enable_if.h> +# include <__type_traits/is_allocator.h> +# include <__type_traits/is_nothrow_assignable.h> +# include <__type_traits/is_nothrow_constructible.h> +# include <__type_traits/is_pointer.h> +# include <__type_traits/is_same.h> +# include <__type_traits/type_identity.h> +# include <__utility/forward.h> +# include <__utility/move.h> +# include <__utility/swap.h> +# include +# include +# include // __launder +# include // standard-mandated includes // [iterator.range] -#include <__iterator/access.h> -#include <__iterator/data.h> -#include <__iterator/empty.h> -#include <__iterator/reverse_access.h> -#include <__iterator/size.h> +# include <__iterator/access.h> +# include <__iterator/data.h> +# include <__iterator/empty.h> +# include <__iterator/reverse_access.h> +# include <__iterator/size.h> // [list.syn] -#include -#include +# include +# include -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -274,7 +279,7 @@ struct __list_node_pointer_traits { typedef __rebind_pointer_t<_VoidPtr, __list_node_base<_Tp, _VoidPtr> > __base_pointer; // TODO(LLVM 22): Remove this check -#ifndef _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB +# ifndef _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB static_assert(sizeof(__node_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__base_pointer) == _LIBCPP_ALIGNOF(__node_pointer), "It looks like you are using std::list with a fancy pointer type that thas a different representation " @@ -282,7 +287,7 @@ struct __list_node_pointer_traits { "implementation details of the standard library). This means that your ABI is being broken between " "LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define the " "_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic."); -#endif +# endif static _LIBCPP_HIDE_FROM_ABI __base_pointer __unsafe_link_pointer_cast(__base_pointer __p) { return __p; } @@ -314,7 +319,7 @@ template struct __list_node : public __list_node_base<_Tp, _VoidPtr> { // We allow starting the lifetime of nodes without initializing the value held by the node, // since that is handled by the list itself in order to be allocator-aware. -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG private: union { @@ -323,14 +328,14 @@ private: public: _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; } -#else +# else private: _ALIGNAS_TYPE(_Tp) char __buffer_[sizeof(_Tp)]; public: _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); } -#endif +# endif typedef __list_node_base<_Tp, _VoidPtr> __base; typedef typename __base::__base_pointer __base_pointer; @@ -517,9 +522,9 @@ protected: _LIBCPP_HIDE_FROM_ABI __list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value); _LIBCPP_HIDE_FROM_ABI __list_imp(const allocator_type& __a); _LIBCPP_HIDE_FROM_ABI __list_imp(const __node_allocator& __a); -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI __list_imp(__node_allocator&& __a) _NOEXCEPT; -#endif +# endif _LIBCPP_HIDE_FROM_ABI ~__list_imp(); _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __sz() == 0; } @@ -530,11 +535,11 @@ protected: _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(__end_as_link()); } _LIBCPP_HIDE_FROM_ABI void swap(__list_imp& __c) -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 _NOEXCEPT; -#else +# else _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v); -#endif +# endif _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c) { __copy_assign_alloc( @@ -610,12 +615,12 @@ inline __list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a) template inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a) : __size_(0), __node_alloc_(__a) {} -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT : __size_(0), __node_alloc_(std::move(__a)) {} -#endif +# endif template __list_imp<_Tp, _Alloc>::~__list_imp() { @@ -639,11 +644,11 @@ void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT { template void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 _NOEXCEPT -#else +# else _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v) -#endif +# endif { _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR( __alloc_traits::propagate_on_container_swap::value || this->__node_alloc() == __c.__node_alloc(), @@ -690,18 +695,18 @@ public: typedef typename __base::const_iterator const_iterator; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 typedef size_type __remove_return_type; -#else +# else typedef void __remove_return_type; -#endif +# endif _LIBCPP_HIDE_FROM_ABI list() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {} _LIBCPP_HIDE_FROM_ABI explicit list(const allocator_type& __a) : __base(__a) {} _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n); -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n, const allocator_type& __a); -#endif +# endif _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x); template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x, const allocator_type& __a) : __base(__a) { @@ -715,18 +720,18 @@ public: template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l, const allocator_type& __a); -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> _LIBCPP_HIDE_FROM_ABI list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) : __base(__a) { prepend_range(std::forward<_Range>(__range)); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI list(const list& __c); _LIBCPP_HIDE_FROM_ABI list(const list& __c, const __type_identity_t& __a); _LIBCPP_HIDE_FROM_ABI list& operator=(const list& __c); -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI list(initializer_list __il); _LIBCPP_HIDE_FROM_ABI list(initializer_list __il, const allocator_type& __a); @@ -742,17 +747,17 @@ public: } _LIBCPP_HIDE_FROM_ABI void assign(initializer_list __il) { assign(__il.begin(), __il.end()); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI void assign(_InpIter __f, _InpIter __l); -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) { __assign_with_sentinel(ranges::begin(__range), ranges::end(__range)); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __x); @@ -795,11 +800,11 @@ public: return __base::__end_.__prev_->__as_node()->__get_value(); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x); _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x); -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) { insert_range(begin(), std::forward<_Range>(__range)); @@ -809,20 +814,20 @@ public: _LIBCPP_HIDE_FROM_ABI void append_range(_Range&& __range) { insert_range(end(), std::forward<_Range>(__range)); } -# endif +# endif template -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args); -# else +# else _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args); -# endif +# endif template -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_HIDE_FROM_ABI reference emplace_back(_Args&&... __args); -# else +# else _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args); -# endif +# endif template _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __p, _Args&&... __args); @@ -831,19 +836,19 @@ public: _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, initializer_list __il) { return insert(__p, __il.begin(), __il.end()); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __x); _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __x); -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template _LIBCPP_HIDE_FROM_ABI void __emplace_back(_Arg&& __arg) { emplace_back(std::forward<_Arg>(__arg)); } -#else +# else _LIBCPP_HIDE_FROM_ABI void __emplace_back(value_type const& __arg) { push_back(__arg); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x); _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __x); @@ -851,19 +856,19 @@ public: template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InpIter __f, _InpIter __l); -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> _LIBCPP_HIDE_FROM_ABI iterator insert_range(const_iterator __position, _Range&& __range) { return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range)); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI void swap(list& __c) -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 _NOEXCEPT -#else +# else _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>) -#endif +# endif { __base::swap(__c); } @@ -879,13 +884,13 @@ public: _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __x); _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c); -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c) { splice(__p, __c); } _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __i) { splice(__p, __c, __i); } _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __f, const_iterator __l) { splice(__p, __c, __f, __l); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __i); _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l); @@ -896,14 +901,14 @@ public: template _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPred __binary_pred); _LIBCPP_HIDE_FROM_ABI void merge(list& __c); -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI void merge(list&& __c) { merge(__c); } template _LIBCPP_HIDE_FROM_ABI void merge(list&& __c, _Comp __comp) { merge(__c, __comp); } -#endif +# endif template _LIBCPP_HIDE_FROM_ABI void merge(list& __c, _Comp __comp); @@ -935,7 +940,7 @@ private: _LIBCPP_HIDE_FROM_ABI void __move_assign(list& __c, false_type); }; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template >, class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, @@ -947,14 +952,14 @@ template ::value>, class = enable_if_t<__is_allocator<_Alloc>::value> > list(_InputIterator, _InputIterator, _Alloc) -> list<__iter_value_type<_InputIterator>, _Alloc>; -#endif +# endif -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template >, class = enable_if_t<__is_allocator<_Alloc>::value> > list(from_range_t, _Range&&, _Alloc = _Alloc()) -> list, _Alloc>; -#endif +# endif // Link in nodes [__f, __l] just prior to __p template @@ -991,20 +996,20 @@ inline typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::__iterator(size_t template list<_Tp, _Alloc>::list(size_type __n) { for (; __n > 0; --__n) -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG emplace_back(); -#else +# else push_back(value_type()); -#endif +# endif } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : __base(__a) { for (; __n > 0; --__n) emplace_back(); } -#endif +# endif template list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) { @@ -1039,7 +1044,7 @@ list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t push_back(*__i); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template list<_Tp, _Alloc>::list(initializer_list __il, const allocator_type& __a) : __base(__a) { @@ -1094,7 +1099,7 @@ void list<_Tp, _Alloc>::__move_assign(list& __c, splice(end(), __c); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) { @@ -1159,13 +1164,13 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ ++__ds; __r = iterator(__node->__as_link()); iterator __e = __r; -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS for (--__n; __n != 0; --__n, (void)++__e, ++__ds) { __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, __x)->__as_link(); } -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { while (true) { __base_pointer __prev = __e.__ptr_->__prev_; @@ -1177,7 +1182,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ } throw; } -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_); __base::__sz() += __ds; } @@ -1201,13 +1206,13 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se ++__ds; __r = iterator(__node->__as_link()); iterator __e = __r; -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS for (++__f; __f != __l; ++__f, (void)++__e, ++__ds) { __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, *__f)->__as_link(); } -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { while (true) { __base_pointer __prev = __e.__ptr_->__prev_; @@ -1219,7 +1224,7 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se } throw; } -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_); __base::__sz() += __ds; } @@ -1242,7 +1247,7 @@ void list<_Tp, _Alloc>::push_back(const value_type& __x) { ++__base::__sz(); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template void list<_Tp, _Alloc>::push_front(value_type&& __x) { @@ -1262,38 +1267,38 @@ void list<_Tp, _Alloc>::push_back(value_type&& __x) { template template -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 typename list<_Tp, _Alloc>::reference -# else +# else void -# endif +# endif list<_Tp, _Alloc>::emplace_front(_Args&&... __args) { __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...); __base_pointer __nl = __node->__as_link(); __link_nodes_at_front(__nl, __nl); ++__base::__sz(); -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 return __node->__get_value(); -# endif +# endif } template template -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 typename list<_Tp, _Alloc>::reference -# else +# else void -# endif +# endif list<_Tp, _Alloc>::emplace_back(_Args&&... __args) { __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...); __base_pointer __nl = __node->__as_link(); __link_nodes_at_back(__nl, __nl); ++__base::__sz(); -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 return __node->__get_value(); -# endif +# endif } template @@ -1316,7 +1321,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __ return iterator(__nl); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template void list<_Tp, _Alloc>::pop_front() { @@ -1372,13 +1377,13 @@ void list<_Tp, _Alloc>::resize(size_type __n) { ++__ds; iterator __r = iterator(__node->__as_link()); iterator __e = __r; -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS for (--__n; __n != 0; --__n, (void)++__e, ++__ds) { __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr)->__as_link(); } -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { while (true) { __base_pointer __prev = __e.__ptr_->__prev_; @@ -1390,7 +1395,7 @@ void list<_Tp, _Alloc>::resize(size_type __n) { } throw; } -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __link_nodes_at_back(__r.__ptr_, __e.__ptr_); __base::__sz() += __ds; } @@ -1408,13 +1413,13 @@ void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) { __base_pointer __nl = __node->__as_link(); iterator __r = iterator(__nl); iterator __e = __r; -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS for (--__n; __n != 0; --__n, (void)++__e, ++__ds) { __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, __x)->__as_link(); } -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { while (true) { __base_pointer __prev = __e.__ptr_->__prev_; @@ -1426,7 +1431,7 @@ void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) { } throw; } -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __link_nodes(__base::__end_as_link(), __r.__ptr_, __e.__ptr_); __base::__sz() += __ds; } @@ -1652,7 +1657,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator==(const list<_Tp, _Alloc>& __x, const return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); } -#if _LIBCPP_STD_VER <= 17 +# if _LIBCPP_STD_VER <= 17 template inline _LIBCPP_HIDE_FROM_ABI bool operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { @@ -1679,7 +1684,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const list<_Tp, _Alloc>& __x, const return !(__y < __x); } -#else // _LIBCPP_STD_VER <= 17 +# else // _LIBCPP_STD_VER <= 17 template _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> @@ -1687,7 +1692,7 @@ operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); } -#endif // _LIBCPP_STD_VER <= 17 +# endif // _LIBCPP_STD_VER <= 17 template inline _LIBCPP_HIDE_FROM_ABI void swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y) @@ -1695,7 +1700,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc> __x.swap(__y); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Allocator>::size_type erase_if(list<_Tp, _Allocator>& __c, _Predicate __pred) { @@ -1710,12 +1715,12 @@ erase(list<_Tp, _Allocator>& __c, const _Up& __v) { template <> inline constexpr bool __format::__enable_insertable> = true; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> inline constexpr bool __format::__enable_insertable> = true; -# endif +# endif -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 template struct __container_traits > { @@ -1730,29 +1735,30 @@ struct __container_traits > { _LIBCPP_END_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_BEGIN_NAMESPACE_STD namespace pmr { template using list _LIBCPP_AVAILABILITY_PMR = std::list<_ValueT, polymorphic_allocator<_ValueT>>; } // namespace pmr _LIBCPP_END_NAMESPACE_STD -#endif +# endif _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_LIST diff --git a/libcxx/include/locale b/libcxx/include/locale index 782475ea7e0eb84..ce7f3162748e44c 100644 --- a/libcxx/include/locale +++ b/libcxx/include/locale @@ -187,78 +187,83 @@ template class messages_byname; */ -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) - -# include <__algorithm/copy.h> -# include <__algorithm/equal.h> -# include <__algorithm/find.h> -# include <__algorithm/max.h> -# include <__algorithm/reverse.h> -# include <__algorithm/unwrap_iter.h> -# include <__assert> -# include <__iterator/access.h> -# include <__iterator/back_insert_iterator.h> -# include <__iterator/istreambuf_iterator.h> -# include <__iterator/ostreambuf_iterator.h> -# include <__locale> -# include <__memory/unique_ptr.h> -# include <__type_traits/make_unsigned.h> -# include -# include -# include -# include -# include -# include -# include -# include -# include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/locale> +#else +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +# include <__algorithm/copy.h> +# include <__algorithm/equal.h> +# include <__algorithm/find.h> +# include <__algorithm/max.h> +# include <__algorithm/reverse.h> +# include <__algorithm/unwrap_iter.h> +# include <__assert> +# include <__iterator/access.h> +# include <__iterator/back_insert_iterator.h> +# include <__iterator/istreambuf_iterator.h> +# include <__iterator/ostreambuf_iterator.h> +# include <__locale> +# include <__memory/unique_ptr.h> +# include <__type_traits/make_unsigned.h> +# include +# include +# include +# include +# include +# include +# include +# include +# include // TODO: Fix __bsd_locale_defaults.h // NOLINTBEGIN(libcpp-robust-against-adl) -# if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) +# if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) // Most unix variants have catopen. These are the specific ones that don't. -# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__) -# define _LIBCPP_HAS_CATOPEN 1 -# include +# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__) +# define _LIBCPP_HAS_CATOPEN 1 +# include +# else +# define _LIBCPP_HAS_CATOPEN 0 +# endif # else # define _LIBCPP_HAS_CATOPEN 0 # endif -# else -# define _LIBCPP_HAS_CATOPEN 0 -# endif -# ifdef _LIBCPP_LOCALE__L_EXTENSIONS -# include <__locale_dir/locale_base_api/bsd_locale_defaults.h> -# else -# include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h> -# endif +# ifdef _LIBCPP_LOCALE__L_EXTENSIONS +# include <__locale_dir/locale_base_api/bsd_locale_defaults.h> +# else +# include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h> +# endif -# if defined(__APPLE__) || defined(__FreeBSD__) -# include -# endif +# if defined(__APPLE__) || defined(__FreeBSD__) +# include +# endif -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -# include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD -# if defined(__APPLE__) || defined(__FreeBSD__) -# define _LIBCPP_GET_C_LOCALE 0 -# elif defined(__NetBSD__) -# define _LIBCPP_GET_C_LOCALE LC_C_LOCALE -# else -# define _LIBCPP_GET_C_LOCALE __cloc() +# if defined(__APPLE__) || defined(__FreeBSD__) +# define _LIBCPP_GET_C_LOCALE 0 +# elif defined(__NetBSD__) +# define _LIBCPP_GET_C_LOCALE LC_C_LOCALE +# else +# define _LIBCPP_GET_C_LOCALE __cloc() // Get the C locale object _LIBCPP_EXPORTED_FROM_ABI locale_t __cloc(); -# define __cloc_defined -# endif +# define __cloc_defined +# endif // __scan_keyword // Scans [__b, __e) until a match is found in the basic_strings range @@ -406,7 +411,7 @@ struct __num_get : protected __num_get_base { unsigned*& __g_end, unsigned& __dc, _CharT* __atoms); -# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET +# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep); static int __stage2_int_loop( _CharT __ct, @@ -420,7 +425,7 @@ struct __num_get : protected __num_get_base { unsigned*& __g_end, _CharT* __atoms); -# else +# else static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep) { locale __loc = __iob.getloc(); const numpunct<_CharT>& __np = use_facet >(__loc); @@ -455,10 +460,10 @@ private: (void)__atoms; return __src; } -# endif +# endif }; -# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET +# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET template string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep) { locale __loc = __iob.getloc(); @@ -467,7 +472,7 @@ string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _C __thousands_sep = __np.thousands_sep(); return __np.grouping(); } -# endif +# endif template string __num_get<_CharT>::__stage2_float_prep( @@ -482,16 +487,16 @@ string __num_get<_CharT>::__stage2_float_prep( template int -# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET +# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end, unsigned& __dc, _CharT __thousands_sep, const string& __grouping, unsigned* __g, unsigned*& __g_end, _CharT* __atoms) -# else +# else __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end, unsigned& __dc, _CharT __thousands_sep, const string& __grouping, unsigned* __g, unsigned*& __g_end, const _CharT* __atoms) -# endif +# endif { if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25])) { *__a_end++ = __ct == __atoms[24] ? '+' : '-'; @@ -590,9 +595,9 @@ int __num_get<_CharT>::__stage2_float_loop( } extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get; -# endif +# endif template > class _LIBCPP_TEMPLATE_VIS num_get : public locale::facet, private __num_get<_CharT> { @@ -862,14 +867,14 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_signed( // Stage 2 char_type __thousands_sep; const int __atoms_size = __num_get_base::__int_chr_cnt; -# ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET +# ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET char_type __atoms1[__atoms_size]; const char_type* __atoms = this->__do_widen(__iob, __atoms1); string __grouping = this->__stage2_int_prep(__iob, __thousands_sep); -# else +# else char_type __atoms[__atoms_size]; string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); -# endif +# endif string __buf; __buf.resize(__buf.capacity()); char* __a = &__buf[0]; @@ -911,14 +916,14 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_unsigned( // Stage 2 char_type __thousands_sep; const int __atoms_size = __num_get_base::__int_chr_cnt; -# ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET +# ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET char_type __atoms1[__atoms_size]; const char_type* __atoms = this->__do_widen(__iob, __atoms1); string __grouping = this->__stage2_int_prep(__iob, __thousands_sep); -# else +# else char_type __atoms[__atoms_size]; string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); -# endif +# endif string __buf; __buf.resize(__buf.capacity()); char* __a = &__buf[0]; @@ -1061,9 +1066,9 @@ _InputIterator num_get<_CharT, _InputIterator>::do_get( } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get; -# endif +# endif struct _LIBCPP_EXPORTED_FROM_ABI __num_put_base { protected: @@ -1179,9 +1184,9 @@ void __num_put<_CharT>::__widen_and_group_float( } extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put; -# endif +# endif template > class _LIBCPP_TEMPLATE_VIS num_put : public locale::facet, private __num_put<_CharT> { @@ -1466,9 +1471,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_ty } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put; -# endif +# endif template _LIBCPP_HIDE_FROM_ABI int __get_up_to_n_digits( @@ -1533,7 +1538,7 @@ _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage::__x() const; template <> _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage::__X() const; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> _LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage::__weeks() const; template <> @@ -1548,7 +1553,7 @@ template <> _LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage::__x() const; template <> _LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage::__X() const; -# endif +# endif template > class _LIBCPP_TEMPLATE_VIS time_get : public locale::facet, public time_base, private __time_get_c_storage<_CharT> { @@ -2002,9 +2007,9 @@ _InputIterator time_get<_CharT, _InputIterator>::do_get( } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get; -# endif +# endif class _LIBCPP_EXPORTED_FROM_ABI __time_get { protected: @@ -2040,32 +2045,32 @@ private: string_type __analyze(char __fmt, const ctype<_CharT>&); }; -# define _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(_CharT) \ - template <> \ - _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \ - template <> \ - _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ - template <> \ - _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ - template <> \ - _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ - template <> \ - _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze( \ - char, const ctype<_CharT>&); \ - extern template _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() \ - const; \ - extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ - extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ - extern template _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ - extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type \ - __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); \ - /**/ +# define _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(_CharT) \ + template <> \ + _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \ + template <> \ + _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ + template <> \ + _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ + template <> \ + _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ + template <> \ + _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze( \ + char, const ctype<_CharT>&); \ + extern template _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() \ + const; \ + extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ + extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ + extern template _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ + extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type \ + __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); \ + /**/ _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char) -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(wchar_t) -# endif -# undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION +# endif +# undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION template > class _LIBCPP_TEMPLATE_VIS time_get_byname @@ -2098,9 +2103,9 @@ private: }; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname; -# endif +# endif class _LIBCPP_EXPORTED_FROM_ABI __time_put { locale_t __loc_; @@ -2111,9 +2116,9 @@ protected: __time_put(const string& __nm); ~__time_put(); void __do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, char __mod) const; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __fmt, char __mod) const; -# endif +# endif }; template > @@ -2187,9 +2192,9 @@ _OutputIterator time_put<_CharT, _OutputIterator>::do_put( } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put; -# endif +# endif template > class _LIBCPP_TEMPLATE_VIS time_put_byname : public time_put<_CharT, _OutputIterator> { @@ -2205,9 +2210,9 @@ protected: }; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname; -# endif +# endif // money_base @@ -2272,10 +2277,10 @@ const bool moneypunct<_CharT, _International>::intl; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct; -# endif +# endif // moneypunct_byname @@ -2330,14 +2335,14 @@ _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname::init(const char*); extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname::init(const char*); template <> _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname::init(const char*); extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname; -# endif +# endif // money_get @@ -2398,9 +2403,9 @@ void __money_get<_CharT>::__gather_info( } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get; -# endif +# endif template > class _LIBCPP_TEMPLATE_VIS money_get : public locale::facet, private __money_get<_CharT> { @@ -2708,9 +2713,9 @@ _InputIterator money_get<_CharT, _InputIterator>::do_get( } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get; -# endif +# endif // money_put @@ -2886,9 +2891,9 @@ void __money_put<_CharT>::__format( } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put; -# endif +# endif template > class _LIBCPP_TEMPLATE_VIS money_put : public locale::facet, private __money_put<_CharT> { @@ -3032,9 +3037,9 @@ _OutputIterator money_put<_CharT, _OutputIterator>::do_put( } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put; -# endif +# endif // messages @@ -3078,18 +3083,18 @@ locale::id messages<_CharT>::id; template typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string& __nm, const locale&) const { -# if _LIBCPP_HAS_CATOPEN +# if _LIBCPP_HAS_CATOPEN return (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE); -# else // !_LIBCPP_HAS_CATOPEN +# else // !_LIBCPP_HAS_CATOPEN (void)__nm; return -1; -# endif // _LIBCPP_HAS_CATOPEN +# endif // _LIBCPP_HAS_CATOPEN } template typename messages<_CharT>::string_type messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& __dflt) const { -# if _LIBCPP_HAS_CATOPEN +# if _LIBCPP_HAS_CATOPEN string __ndflt; __narrow_to_utf8()( std::back_inserter(__ndflt), __dflt.c_str(), __dflt.c_str() + __dflt.size()); @@ -3099,27 +3104,27 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& string_type __w; __widen_from_utf8()(std::back_inserter(__w), __n, __n + std::strlen(__n)); return __w; -# else // !_LIBCPP_HAS_CATOPEN +# else // !_LIBCPP_HAS_CATOPEN (void)__c; (void)__set; (void)__msgid; return __dflt; -# endif // _LIBCPP_HAS_CATOPEN +# endif // _LIBCPP_HAS_CATOPEN } template void messages<_CharT>::do_close(catalog __c) const { -# if _LIBCPP_HAS_CATOPEN +# if _LIBCPP_HAS_CATOPEN catclose((nl_catd)__c); -# else // !_LIBCPP_HAS_CATOPEN +# else // !_LIBCPP_HAS_CATOPEN (void)__c; -# endif // _LIBCPP_HAS_CATOPEN +# endif // _LIBCPP_HAS_CATOPEN } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages; -# endif +# endif template class _LIBCPP_TEMPLATE_VIS messages_byname : public messages<_CharT> { @@ -3136,11 +3141,11 @@ protected: }; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname; -# endif +# endif -# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) +# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) template ::wstring_convert( __cvtptr_ = new _Codecvt; } -# ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(wstring_convert&& __wc) @@ -3230,7 +3235,7 @@ inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert __wc.__cvtptr_ = nullptr; } -# endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_SUPPRESS_DEPRECATED_PUSH template @@ -3384,14 +3389,14 @@ private: bool __always_noconv_; public: -# ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI wbuffer_convert() : wbuffer_convert(nullptr) {} explicit _LIBCPP_HIDE_FROM_ABI wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); -# else +# else _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI wbuffer_convert(streambuf* __bytebuf = nullptr, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); -# endif +# endif _LIBCPP_HIDE_FROM_ABI ~wbuffer_convert(); @@ -3747,7 +3752,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::__ _LIBCPP_SUPPRESS_DEPRECATED_POP -# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) +# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) _LIBCPP_END_NAMESPACE_STD @@ -3755,17 +3760,18 @@ _LIBCPP_POP_MACROS // NOLINTEND(libcpp-robust-against-adl) -#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -#endif +# endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_LOCALE diff --git a/libcxx/include/map b/libcxx/include/map index fabf39512ab75fa..47a909390ed87ad 100644 --- a/libcxx/include/map +++ b/libcxx/include/map @@ -571,6 +571,11 @@ erase_if(multimap& c, Predicate pred); // C++20 */ +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/map> +#else #include <__algorithm/equal.h> #include <__algorithm/lexicographical_compare.h> #include <__algorithm/lexicographical_compare_three_way.h> @@ -610,22 +615,22 @@ erase_if(multimap& c, Predicate pred); // C++20 // standard-mandated includes // [iterator.range] -#include <__iterator/access.h> -#include <__iterator/data.h> -#include <__iterator/empty.h> -#include <__iterator/reverse_access.h> -#include <__iterator/size.h> +# include <__iterator/access.h> +# include <__iterator/data.h> +# include <__iterator/empty.h> +# include <__iterator/reverse_access.h> +# include <__iterator/size.h> // [associative.map.syn] -#include -#include +# include +# include -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -654,7 +659,7 @@ public: swap(static_cast<_Compare&>(*this), static_cast<_Compare&>(__y)); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const { return static_cast(*this)(__x, __y.__get_value().first); @@ -664,7 +669,7 @@ public: _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const { return static_cast(*this)(__x.__get_value().first, __y); } -#endif +# endif }; template @@ -692,7 +697,7 @@ public: swap(__comp_, __y.__comp_); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const { return __comp_(__x, __y.__get_value().first); @@ -702,7 +707,7 @@ public: _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const { return __comp_(__x.__get_value().first, __y); } -#endif +# endif }; template @@ -732,14 +737,14 @@ public: __first_constructed(false), __second_constructed(false) {} -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI __map_node_destructor(__tree_node_destructor&& __x) _NOEXCEPT : __na_(__x.__na_), __first_constructed(__x.__value_constructed), __second_constructed(__x.__value_constructed) { __x.__value_constructed = false; } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG __map_node_destructor& operator=(const __map_node_destructor&) = delete; @@ -760,7 +765,7 @@ class multimap; template class __map_const_iterator; -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template struct _LIBCPP_STANDALONE_DEBUG __value_type { @@ -775,19 +780,19 @@ private: public: _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 return *std::launder(std::addressof(__cc_)); -# else +# else return __cc_; -# endif +# endif } _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 return *std::launder(std::addressof(__cc_)); -# else +# else return __cc_; -# endif +# endif } _LIBCPP_HIDE_FROM_ABI __nc_ref_pair_type __ref() { @@ -822,7 +827,7 @@ public: __value_type(__value_type&&) = delete; }; -#else +# else template struct __value_type { @@ -843,7 +848,7 @@ public: ~__value_type() = delete; }; -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template struct __extract_key_value_types; @@ -1019,10 +1024,10 @@ public: typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 typedef __map_node_handle node_type; typedef __insert_return_type insert_return_type; -#endif +# endif template friend class _LIBCPP_TEMPLATE_VIS map; @@ -1054,7 +1059,7 @@ public: insert(__f, __l); } -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange _Range> _LIBCPP_HIDE_FROM_ABI map(from_range_t, @@ -1064,37 +1069,37 @@ public: : __tree_(__vc(__comp), typename __base::allocator_type(__a)) { insert_range(std::forward<_Range>(__range)); } -#endif +# endif -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template _LIBCPP_HIDE_FROM_ABI map(_InputIterator __f, _InputIterator __l, const allocator_type& __a) : map(__f, __l, key_compare(), __a) {} -#endif +# endif -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange _Range> _LIBCPP_HIDE_FROM_ABI map(from_range_t, _Range&& __range, const allocator_type& __a) : map(from_range, std::forward<_Range>(__range), key_compare(), __a) {} -#endif +# endif _LIBCPP_HIDE_FROM_ABI map(const map& __m) : __tree_(__m.__tree_) { insert(__m.begin(), __m.end()); } _LIBCPP_HIDE_FROM_ABI map& operator=(const map& __m) { -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG __tree_ = __m.__tree_; -#else +# else if (this != std::addressof(__m)) { __tree_.clear(); __tree_.value_comp() = __m.__tree_.value_comp(); __tree_.__copy_assign_alloc(__m.__tree_); insert(__m.begin(), __m.end()); } -#endif +# endif return *this; } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI map(map&& __m) noexcept(is_nothrow_move_constructible<__base>::value) : __tree_(std::move(__m.__tree_)) {} @@ -1116,17 +1121,17 @@ public: insert(__il.begin(), __il.end()); } -# if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 _LIBCPP_HIDE_FROM_ABI map(initializer_list __il, const allocator_type& __a) : map(__il, key_compare(), __a) {} -# endif +# endif _LIBCPP_HIDE_FROM_ABI map& operator=(initializer_list __il) { __tree_.__assign_unique(__il.begin(), __il.end()); return *this; } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI explicit map(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {} @@ -1157,9 +1162,9 @@ public: _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __k); -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __k); -#endif +# endif _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __k); _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const; @@ -1168,7 +1173,7 @@ public: _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); } _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__tree_.value_comp().key_comp()); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template _LIBCPP_HIDE_FROM_ABI pair emplace(_Args&&... __args) { return __tree_.__emplace_unique(std::forward<_Args>(__args)...); @@ -1189,7 +1194,7 @@ public: return __tree_.__insert_unique(__pos.__i_, std::forward<_Pp>(__p)); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI pair insert(const value_type& __v) { return __tree_.__insert_unique(__v); } @@ -1197,7 +1202,7 @@ public: return __tree_.__insert_unique(__p.__i_, __v); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI pair insert(value_type&& __v) { return __tree_.__insert_unique(std::move(__v)); } @@ -1207,7 +1212,7 @@ public: } _LIBCPP_HIDE_FROM_ABI void insert(initializer_list __il) { insert(__il.begin(), __il.end()); } -#endif +# endif template _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) { @@ -1215,7 +1220,7 @@ public: insert(__e.__i_, *__f); } -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange _Range> _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { const_iterator __end = cend(); @@ -1223,9 +1228,9 @@ public: insert(__end.__i_, std::forward(__element)); } } -#endif +# endif -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template _LIBCPP_HIDE_FROM_ABI pair try_emplace(const key_type& __k, _Args&&... __args) { @@ -1310,7 +1315,7 @@ public: return __r; } -#endif // _LIBCPP_STD_VER >= 17 +# endif // _LIBCPP_STD_VER >= 17 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p.__i_); } _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __tree_.erase(__p.__i_); } @@ -1320,7 +1325,7 @@ public: } _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); } -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) { _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(), "node_type with incompatible allocator passed to map::insert()"); @@ -1361,13 +1366,13 @@ public: __source.get_allocator() == get_allocator(), "merging container with incompatible allocator"); __tree_.__node_handle_merge_unique(__source.__tree_); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI void swap(map& __m) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__m.__tree_); } _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { return __tree_.find(__k); @@ -1376,27 +1381,27 @@ public: _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { return __tree_.find(__k); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { return __tree_.__count_multi(__k); } -#endif +# endif -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } template , int> = 0> _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { return find(__k) != end(); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { return __tree_.lower_bound(__k); @@ -1406,11 +1411,11 @@ public: _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { return __tree_.lower_bound(__k); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { return __tree_.upper_bound(__k); @@ -1419,7 +1424,7 @@ public: _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { return __tree_.upper_bound(__k); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI pair equal_range(const key_type& __k) { return __tree_.__equal_range_unique(__k); @@ -1427,7 +1432,7 @@ public: _LIBCPP_HIDE_FROM_ABI pair equal_range(const key_type& __k) const { return __tree_.__equal_range_unique(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI pair equal_range(const _K2& __k) { return __tree_.__equal_range_multi(__k); @@ -1436,7 +1441,7 @@ public: _LIBCPP_HIDE_FROM_ABI pair equal_range(const _K2& __k) const { return __tree_.__equal_range_multi(__k); } -#endif +# endif private: typedef typename __base::__node __node; @@ -1448,12 +1453,12 @@ private: typedef __map_node_destructor<__node_allocator> _Dp; typedef unique_ptr<__node, _Dp> __node_holder; -#ifdef _LIBCPP_CXX03_LANG +# ifdef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node_with_key(const key_type& __k); -#endif +# endif }; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template >, class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, @@ -1463,7 +1468,7 @@ template map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>; -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template >, class _Allocator = allocator<__range_to_alloc_type<_Range>>, @@ -1471,7 +1476,7 @@ template ::value, void>> map(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> map<__range_key_type<_Range>, __range_mapped_type<_Range>, _Compare, _Allocator>; -# endif +# endif template >, class = enable_if_t::value, void>, class = enable_if_t<__is_allocator<_Allocator>::value, void>> -map(initializer_list>, - _Compare = _Compare(), - _Allocator = _Allocator()) -> map, _Tp, _Compare, _Allocator>; +map(initializer_list>, _Compare = _Compare(), _Allocator = _Allocator()) + -> map, _Tp, _Compare, _Allocator>; template >, _Allocator>; -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template ::value, void>> map(from_range_t, _Range&&, _Allocator) -> map<__range_key_type<_Range>, __range_mapped_type<_Range>, less<__range_key_type<_Range>>, _Allocator>; -# endif +# endif template ::value, void>> -map(initializer_list>, - _Allocator) -> map, _Tp, less>, _Allocator>; -#endif +map(initializer_list>, _Allocator) + -> map, _Tp, less>, _Allocator>; +# endif -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a) : __tree_(std::move(__m.__tree_), typename __base::allocator_type(__a)) { @@ -1535,7 +1539,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) { // NOLINTEND(bugprone-use-after-move) } -#else // _LIBCPP_CXX03_LANG +# else // _LIBCPP_CXX03_LANG template typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder @@ -1562,7 +1566,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) { return __r->__value_.__get_value().second; } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) { @@ -1588,7 +1592,7 @@ operator==(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); } -#if _LIBCPP_STD_VER <= 17 +# if _LIBCPP_STD_VER <= 17 template inline _LIBCPP_HIDE_FROM_ABI bool @@ -1620,7 +1624,7 @@ operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, return !(__y < __x); } -#else // #if _LIBCPP_STD_VER <= 17 +# else // #if _LIBCPP_STD_VER <= 17 template _LIBCPP_HIDE_FROM_ABI __synth_three_way_result> @@ -1628,7 +1632,7 @@ operator<=>(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); } -#endif // #if _LIBCPP_STD_VER <= 17 +# endif // #if _LIBCPP_STD_VER <= 17 template inline _LIBCPP_HIDE_FROM_ABI void @@ -1637,13 +1641,13 @@ swap(map<_Key, _Tp, _Compare, _Allocator>& __x, map<_Key, _Tp, _Compare, _Alloca __x.swap(__y); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI typename map<_Key, _Tp, _Compare, _Allocator>::size_type erase_if(map<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) { return std::__libcpp_erase_if_container(__c, __pred); } -#endif +# endif template struct __container_traits > { @@ -1703,9 +1707,9 @@ public: typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 typedef __map_node_handle node_type; -#endif +# endif template friend class _LIBCPP_TEMPLATE_VIS map; @@ -1737,7 +1741,7 @@ public: insert(__f, __l); } -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange _Range> _LIBCPP_HIDE_FROM_ABI multimap(from_range_t, @@ -1747,19 +1751,19 @@ public: : __tree_(__vc(__comp), typename __base::allocator_type(__a)) { insert_range(std::forward<_Range>(__range)); } -#endif +# endif -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template _LIBCPP_HIDE_FROM_ABI multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a) : multimap(__f, __l, key_compare(), __a) {} -#endif +# endif -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange _Range> _LIBCPP_HIDE_FROM_ABI multimap(from_range_t, _Range&& __range, const allocator_type& __a) : multimap(from_range, std::forward<_Range>(__range), key_compare(), __a) {} -#endif +# endif _LIBCPP_HIDE_FROM_ABI multimap(const multimap& __m) : __tree_(__m.__tree_.value_comp(), @@ -1768,20 +1772,20 @@ public: } _LIBCPP_HIDE_FROM_ABI multimap& operator=(const multimap& __m) { -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG __tree_ = __m.__tree_; -#else +# else if (this != std::addressof(__m)) { __tree_.clear(); __tree_.value_comp() = __m.__tree_.value_comp(); __tree_.__copy_assign_alloc(__m.__tree_); insert(__m.begin(), __m.end()); } -#endif +# endif return *this; } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m) noexcept(is_nothrow_move_constructible<__base>::value) : __tree_(std::move(__m.__tree_)) {} @@ -1804,17 +1808,17 @@ public: insert(__il.begin(), __il.end()); } -# if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 _LIBCPP_HIDE_FROM_ABI multimap(initializer_list __il, const allocator_type& __a) : multimap(__il, key_compare(), __a) {} -# endif +# endif _LIBCPP_HIDE_FROM_ABI multimap& operator=(initializer_list __il) { __tree_.__assign_multi(__il.begin(), __il.end()); return *this; } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI explicit multimap(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {} @@ -1848,7 +1852,7 @@ public: _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); } _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__tree_.value_comp().key_comp()); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) { @@ -1878,7 +1882,7 @@ public: _LIBCPP_HIDE_FROM_ABI void insert(initializer_list __il) { insert(__il.begin(), __il.end()); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__insert_multi(__v); } @@ -1892,7 +1896,7 @@ public: __tree_.__insert_multi(__e.__i_, *__f); } -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange _Range> _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { const_iterator __end = cend(); @@ -1900,7 +1904,7 @@ public: __tree_.__insert_multi(__end.__i_, std::forward(__element)); } } -#endif +# endif _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p.__i_); } _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __tree_.erase(__p.__i_); } @@ -1909,7 +1913,7 @@ public: return __tree_.erase(__f.__i_, __l.__i_); } -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) { _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(), "node_type with incompatible allocator passed to multimap::insert()"); @@ -1950,7 +1954,7 @@ public: __source.get_allocator() == get_allocator(), "merging container with incompatible allocator"); return __tree_.__node_handle_merge_multi(__source.__tree_); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); } @@ -1960,7 +1964,7 @@ public: _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { return __tree_.find(__k); @@ -1969,27 +1973,27 @@ public: _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { return __tree_.find(__k); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { return __tree_.__count_multi(__k); } -#endif +# endif -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } template , int> = 0> _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { return find(__k) != end(); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { return __tree_.lower_bound(__k); @@ -1999,11 +2003,11 @@ public: _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { return __tree_.lower_bound(__k); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { return __tree_.upper_bound(__k); @@ -2012,7 +2016,7 @@ public: _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { return __tree_.upper_bound(__k); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI pair equal_range(const key_type& __k) { return __tree_.__equal_range_multi(__k); @@ -2020,7 +2024,7 @@ public: _LIBCPP_HIDE_FROM_ABI pair equal_range(const key_type& __k) const { return __tree_.__equal_range_multi(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI pair equal_range(const _K2& __k) { return __tree_.__equal_range_multi(__k); @@ -2029,7 +2033,7 @@ public: _LIBCPP_HIDE_FROM_ABI pair equal_range(const _K2& __k) const { return __tree_.__equal_range_multi(__k); } -#endif +# endif private: typedef typename __base::__node __node; @@ -2040,7 +2044,7 @@ private: typedef unique_ptr<__node, _Dp> __node_holder; }; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template >, class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, @@ -2050,7 +2054,7 @@ template multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>; -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template >, class _Allocator = allocator<__range_to_alloc_type<_Range>>, @@ -2058,7 +2062,7 @@ template ::value, void>> multimap(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, _Compare, _Allocator>; -# endif +# endif template >, class = enable_if_t::value, void>, class = enable_if_t<__is_allocator<_Allocator>::value, void>> -multimap(initializer_list>, - _Compare = _Compare(), - _Allocator = _Allocator()) -> multimap, _Tp, _Compare, _Allocator>; +multimap(initializer_list>, _Compare = _Compare(), _Allocator = _Allocator()) + -> multimap, _Tp, _Compare, _Allocator>; template >, _Allocator>; -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template ::value, void>> multimap(from_range_t, _Range&&, _Allocator) -> multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, less<__range_key_type<_Range>>, _Allocator>; -# endif +# endif template ::value, void>> -multimap(initializer_list>, - _Allocator) -> multimap, _Tp, less>, _Allocator>; -#endif +multimap(initializer_list>, _Allocator) + -> multimap, _Tp, less>, _Allocator>; +# endif -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a) : __tree_(std::move(__m.__tree_), typename __base::allocator_type(__a)) { @@ -2101,7 +2104,7 @@ multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const alloca __tree_.__insert_multi(__e.__i_, std::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__move())); } } -#endif +# endif template inline _LIBCPP_HIDE_FROM_ABI bool @@ -2109,7 +2112,7 @@ operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap< return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); } -#if _LIBCPP_STD_VER <= 17 +# if _LIBCPP_STD_VER <= 17 template inline _LIBCPP_HIDE_FROM_ABI bool @@ -2141,7 +2144,7 @@ operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap< return !(__y < __x); } -#else // #if _LIBCPP_STD_VER <= 17 +# else // #if _LIBCPP_STD_VER <= 17 template _LIBCPP_HIDE_FROM_ABI __synth_three_way_result> @@ -2150,7 +2153,7 @@ operator<=>(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way); } -#endif // #if _LIBCPP_STD_VER <= 17 +# endif // #if _LIBCPP_STD_VER <= 17 template inline _LIBCPP_HIDE_FROM_ABI void @@ -2159,13 +2162,13 @@ swap(multimap<_Key, _Tp, _Compare, _Allocator>& __x, multimap<_Key, _Tp, _Compar __x.swap(__y); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI typename multimap<_Key, _Tp, _Compare, _Allocator>::size_type erase_if(multimap<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) { return std::__libcpp_erase_if_container(__c, __pred); } -#endif +# endif template struct __container_traits > { @@ -2177,7 +2180,7 @@ struct __container_traits > { _LIBCPP_END_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_BEGIN_NAMESPACE_STD namespace pmr { template > @@ -2189,17 +2192,18 @@ using multimap _LIBCPP_AVAILABILITY_PMR = std::multimap<_KeyT, _ValueT, _CompareT, polymorphic_allocator>>; } // namespace pmr _LIBCPP_END_NAMESPACE_STD -#endif +# endif _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_MAP diff --git a/libcxx/include/math.h b/libcxx/include/math.h index 509ecc46184da1f..a9e3030d3b0e750 100644 --- a/libcxx/include/math.h +++ b/libcxx/include/math.h @@ -291,93 +291,98 @@ long double truncl(long double x); */ -# include <__config> +# include <__configuration/cxx03.h> -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif - -# if __has_include_next() -# include_next -# endif - -# ifdef __cplusplus - -// We support including .h headers inside 'extern "C"' contexts, so switch -// back to C++ linkage before including these C++ headers. -extern "C++" { - -# ifdef fpclassify -# undef fpclassify -# endif - -# ifdef signbit -# undef signbit -# endif - -# ifdef isfinite -# undef isfinite -# endif +# if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/math.h> +# else +# include <__config> -# ifdef isinf -# undef isinf +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header # endif -# ifdef isnan -# undef isnan +# if __has_include_next() +# include_next # endif -# ifdef isnormal -# undef isnormal -# endif - -# ifdef isgreater -# undef isgreater -# endif - -# ifdef isgreaterequal -# undef isgreaterequal -# endif - -# ifdef isless -# undef isless -# endif +# ifdef __cplusplus -# ifdef islessequal -# undef islessequal -# endif - -# ifdef islessgreater -# undef islessgreater -# endif - -# ifdef isunordered -# undef isunordered -# endif +// We support including .h headers inside 'extern "C"' contexts, so switch +// back to C++ linkage before including these C++ headers. +extern "C++" { -# include <__math/abs.h> -# include <__math/copysign.h> -# include <__math/error_functions.h> -# include <__math/exponential_functions.h> -# include <__math/fdim.h> -# include <__math/fma.h> -# include <__math/gamma.h> -# include <__math/hyperbolic_functions.h> -# include <__math/hypot.h> -# include <__math/inverse_hyperbolic_functions.h> -# include <__math/inverse_trigonometric_functions.h> -# include <__math/logarithms.h> -# include <__math/min_max.h> -# include <__math/modulo.h> -# include <__math/remainder.h> -# include <__math/roots.h> -# include <__math/rounding_functions.h> -# include <__math/traits.h> -# include <__math/trigonometric_functions.h> -# include <__type_traits/enable_if.h> -# include <__type_traits/is_floating_point.h> -# include <__type_traits/is_integral.h> -# include +# ifdef fpclassify +# undef fpclassify +# endif + +# ifdef signbit +# undef signbit +# endif + +# ifdef isfinite +# undef isfinite +# endif + +# ifdef isinf +# undef isinf +# endif + +# ifdef isnan +# undef isnan +# endif + +# ifdef isnormal +# undef isnormal +# endif + +# ifdef isgreater +# undef isgreater +# endif + +# ifdef isgreaterequal +# undef isgreaterequal +# endif + +# ifdef isless +# undef isless +# endif + +# ifdef islessequal +# undef islessequal +# endif + +# ifdef islessgreater +# undef islessgreater +# endif + +# ifdef isunordered +# undef isunordered +# endif + +# include <__math/abs.h> +# include <__math/copysign.h> +# include <__math/error_functions.h> +# include <__math/exponential_functions.h> +# include <__math/fdim.h> +# include <__math/fma.h> +# include <__math/gamma.h> +# include <__math/hyperbolic_functions.h> +# include <__math/hypot.h> +# include <__math/inverse_hyperbolic_functions.h> +# include <__math/inverse_trigonometric_functions.h> +# include <__math/logarithms.h> +# include <__math/min_max.h> +# include <__math/modulo.h> +# include <__math/remainder.h> +# include <__math/roots.h> +# include <__math/rounding_functions.h> +# include <__math/traits.h> +# include <__math/trigonometric_functions.h> +# include <__type_traits/enable_if.h> +# include <__type_traits/is_floating_point.h> +# include <__type_traits/is_integral.h> +# include // fpclassify relies on implementation-defined constants, so we can't move it to a detail header _LIBCPP_BEGIN_NAMESPACE_STD @@ -415,7 +420,7 @@ using std::__math::fpclassify; using std::__math::signbit; // The MSVC runtime already provides these functions as templates -# ifndef _LIBCPP_MSVCRT +# ifndef _LIBCPP_MSVCRT using std::__math::isfinite; using std::__math::isgreater; using std::__math::isgreaterequal; @@ -426,7 +431,7 @@ using std::__math::islessgreater; using std::__math::isnan; using std::__math::isnormal; using std::__math::isunordered; -# endif // _LIBCPP_MSVCRT +# endif // _LIBCPP_MSVCRT // abs // @@ -501,7 +506,8 @@ using std::__math::trunc; } // extern "C++" -# endif // __cplusplus +# endif // __cplusplus +# endif // _LIBCPP_CXX03_LANG #else // _LIBCPP_MATH_H diff --git a/libcxx/include/mdspan b/libcxx/include/mdspan index 29190e4a9953ed0..277763873d0a808 100644 --- a/libcxx/include/mdspan +++ b/libcxx/include/mdspan @@ -408,31 +408,37 @@ namespace std { #ifndef _LIBCPP_MDSPAN #define _LIBCPP_MDSPAN -#include <__config> - -#if _LIBCPP_STD_VER >= 23 -# include <__fwd/mdspan.h> -# include <__mdspan/default_accessor.h> -# include <__mdspan/extents.h> -# include <__mdspan/layout_left.h> -# include <__mdspan/layout_right.h> -# include <__mdspan/layout_stride.h> -# include <__mdspan/mdspan.h> -#endif - -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/mdspan> +#else +# include <__config> + +# if _LIBCPP_STD_VER >= 23 +# include <__fwd/mdspan.h> +# include <__mdspan/default_accessor.h> +# include <__mdspan/extents.h> +# include <__mdspan/layout_left.h> +# include <__mdspan/layout_right.h> +# include <__mdspan/layout_stride.h> +# include <__mdspan/mdspan.h> +# endif + +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_MDSPAN diff --git a/libcxx/include/memory b/libcxx/include/memory index db3386cca480092..fd0e36b91d46800 100644 --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -934,65 +934,71 @@ template // clang-format on -#include <__config> -#include <__memory/addressof.h> -#include <__memory/align.h> -#include <__memory/allocator.h> -#include <__memory/allocator_arg_t.h> -#include <__memory/allocator_traits.h> -#include <__memory/auto_ptr.h> -#include <__memory/inout_ptr.h> -#include <__memory/out_ptr.h> -#include <__memory/pointer_traits.h> -#include <__memory/raw_storage_iterator.h> -#include <__memory/shared_ptr.h> -#include <__memory/temporary_buffer.h> -#include <__memory/uninitialized_algorithms.h> -#include <__memory/unique_ptr.h> -#include <__memory/uses_allocator.h> +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/memory> +#else +# include <__config> +# include <__memory/addressof.h> +# include <__memory/align.h> +# include <__memory/allocator.h> +# include <__memory/allocator_arg_t.h> +# include <__memory/allocator_traits.h> +# include <__memory/auto_ptr.h> +# include <__memory/inout_ptr.h> +# include <__memory/out_ptr.h> +# include <__memory/pointer_traits.h> +# include <__memory/raw_storage_iterator.h> +# include <__memory/shared_ptr.h> +# include <__memory/temporary_buffer.h> +# include <__memory/uninitialized_algorithms.h> +# include <__memory/unique_ptr.h> +# include <__memory/uses_allocator.h> // standard-mandated includes -#if _LIBCPP_STD_VER >= 17 -# include <__memory/construct_at.h> -#endif +# if _LIBCPP_STD_VER >= 17 +# include <__memory/construct_at.h> +# endif -#if _LIBCPP_STD_VER >= 20 -# include <__memory/assume_aligned.h> -# include <__memory/concepts.h> -# include <__memory/ranges_construct_at.h> -# include <__memory/ranges_uninitialized_algorithms.h> -# include <__memory/uses_allocator_construction.h> -#endif +# if _LIBCPP_STD_VER >= 20 +# include <__memory/assume_aligned.h> +# include <__memory/concepts.h> +# include <__memory/ranges_construct_at.h> +# include <__memory/ranges_uninitialized_algorithms.h> +# include <__memory/uses_allocator_construction.h> +# endif -#if _LIBCPP_STD_VER >= 23 -# include <__memory/allocate_at_least.h> -#endif +# if _LIBCPP_STD_VER >= 23 +# include <__memory/allocate_at_least.h> +# endif -#include +# include // [memory.syn] -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_MEMORY diff --git a/libcxx/include/memory_resource b/libcxx/include/memory_resource index e98ca20aa058c33..a4932a6d2687089 100644 --- a/libcxx/include/memory_resource +++ b/libcxx/include/memory_resource @@ -49,34 +49,40 @@ namespace std::pmr { */ -#include <__config> - -#if _LIBCPP_STD_VER >= 17 -# include <__memory_resource/memory_resource.h> -# include <__memory_resource/monotonic_buffer_resource.h> -# include <__memory_resource/polymorphic_allocator.h> -# include <__memory_resource/pool_options.h> -# include <__memory_resource/synchronized_pool_resource.h> -# include <__memory_resource/unsynchronized_pool_resource.h> -#endif - -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 -# include -# include -# include -# include -# include -# include -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/memory_resource> +#else +# include <__config> + +# if _LIBCPP_STD_VER >= 17 +# include <__memory_resource/memory_resource.h> +# include <__memory_resource/monotonic_buffer_resource.h> +# include <__memory_resource/polymorphic_allocator.h> +# include <__memory_resource/pool_options.h> +# include <__memory_resource/synchronized_pool_resource.h> +# include <__memory_resource/unsynchronized_pool_resource.h> +# endif + +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 +# include +# include +# include +# include +# include +# include +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif /* _LIBCPP_MEMORY_RESOURCE */ diff --git a/libcxx/include/mutex b/libcxx/include/mutex index 02c52dd72f02b07..e1b6fd37c843a7b 100644 --- a/libcxx/include/mutex +++ b/libcxx/include/mutex @@ -186,36 +186,41 @@ template */ -#include <__chrono/steady_clock.h> -#include <__chrono/time_point.h> -#include <__condition_variable/condition_variable.h> -#include <__config> -#include <__memory/shared_ptr.h> -#include <__mutex/lock_guard.h> -#include <__mutex/mutex.h> -#include <__mutex/once_flag.h> -#include <__mutex/tag_types.h> -#include <__mutex/unique_lock.h> -#include <__thread/id.h> -#include <__thread/support.h> -#include <__utility/forward.h> -#include -#include -#ifndef _LIBCPP_CXX03_LANG -# include -#endif -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/mutex> +#else +# include <__chrono/steady_clock.h> +# include <__chrono/time_point.h> +# include <__condition_variable/condition_variable.h> +# include <__config> +# include <__memory/shared_ptr.h> +# include <__mutex/lock_guard.h> +# include <__mutex/mutex.h> +# include <__mutex/once_flag.h> +# include <__mutex/tag_types.h> +# include <__mutex/unique_lock.h> +# include <__thread/id.h> +# include <__thread/support.h> +# include <__utility/forward.h> +# include +# include +# ifndef _LIBCPP_CXX03_LANG +# include +# endif +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD -#ifndef _LIBCPP_HAS_NO_THREADS +# ifndef _LIBCPP_HAS_NO_THREADS class _LIBCPP_EXPORTED_FROM_ABI recursive_mutex { __libcpp_recursive_mutex_t __m_; @@ -335,7 +340,7 @@ _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1) { return 0; } -# ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) { @@ -351,7 +356,7 @@ _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3 return __r; } -# endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1) { @@ -375,7 +380,7 @@ _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1) { } } -# ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template void __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) { @@ -418,9 +423,9 @@ inline _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... std::__lock_first(0, __l0, __l1, __l2, __l3...); } -# endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template class _LIBCPP_TEMPLATE_VIS scoped_lock; @@ -491,26 +496,27 @@ private: }; _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(scoped_lock); -# endif // _LIBCPP_STD_VER >= 17 -#endif // !_LIBCPP_HAS_NO_THREADS +# endif // _LIBCPP_STD_VER >= 17 +# endif // !_LIBCPP_HAS_NO_THREADS _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_MUTEX diff --git a/libcxx/include/new b/libcxx/include/new index 75e2b8742df6bde..4ae8f00a154065f 100644 --- a/libcxx/include/new +++ b/libcxx/include/new @@ -86,45 +86,46 @@ void operator delete[](void* ptr, void*) noexcept; */ -#include <__config> -#include <__exception/exception.h> -#include <__type_traits/is_function.h> -#include <__type_traits/is_same.h> -#include <__type_traits/remove_cv.h> -#include <__verbose_abort> -#include -#include - -#if defined(_LIBCPP_ABI_VCRUNTIME) -# include -#endif - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L -# define _LIBCPP_HAS_LANGUAGE_SIZED_DEALLOCATION 1 -#else -# define _LIBCPP_HAS_LANGUAGE_SIZED_DEALLOCATION 0 -#endif +#include <__configuration/cxx03.h> -#if _LIBCPP_STD_VER >= 14 || _LIBCPP_HAS_LANGUAGE_SIZED_DEALLOCATION -# define _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION 1 +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/new> #else -# define _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION 0 -#endif +# include <__config> +# include <__exception/exception.h> +# include <__type_traits/is_function.h> +# include <__type_traits/is_same.h> +# include <__type_traits/remove_cv.h> +# include <__verbose_abort> +# include +# include + +# if defined(_LIBCPP_ABI_VCRUNTIME) +# include +# endif -#if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION && _LIBCPP_HAS_LANGUAGE_SIZED_DEALLOCATION -# define _LIBCPP_HAS_SIZED_DEALLOCATION 1 -#else -# define _LIBCPP_HAS_SIZED_DEALLOCATION 0 -#endif +# if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L +# define _LIBCPP_HAS_LANGUAGE_SIZED_DEALLOCATION 1 +# else +# define _LIBCPP_HAS_LANGUAGE_SIZED_DEALLOCATION 0 +# endif + +# if _LIBCPP_STD_VER >= 14 || _LIBCPP_HAS_LANGUAGE_SIZED_DEALLOCATION +# define _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION 1 +# else +# define _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION 0 +# endif + +# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION && _LIBCPP_HAS_LANGUAGE_SIZED_DEALLOCATION +# define _LIBCPP_HAS_SIZED_DEALLOCATION 1 +# else +# define _LIBCPP_HAS_SIZED_DEALLOCATION 0 +# endif namespace std // purposefully not using versioning namespace { -#if !defined(_LIBCPP_ABI_VCRUNTIME) +# if !defined(_LIBCPP_ABI_VCRUNTIME) struct _LIBCPP_EXPORTED_FROM_ABI nothrow_t { explicit nothrow_t() = default; }; @@ -152,7 +153,7 @@ typedef void (*new_handler)(); _LIBCPP_EXPORTED_FROM_ABI new_handler set_new_handler(new_handler) _NOEXCEPT; _LIBCPP_EXPORTED_FROM_ABI new_handler get_new_handler() _NOEXCEPT; -#elif defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0 // !_LIBCPP_ABI_VCRUNTIME +# elif defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0 // !_LIBCPP_ABI_VCRUNTIME // When _HAS_EXCEPTIONS == 0, these complete definitions are needed, // since they would normally be provided in vcruntime_exception.h @@ -170,72 +171,72 @@ class bad_array_new_length : public bad_alloc { public: bad_array_new_length() noexcept : bad_alloc("bad array new length") {} }; -#endif // defined(_LIBCPP_ABI_VCRUNTIME) && defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0 +# endif // defined(_LIBCPP_ABI_VCRUNTIME) && defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0 [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_bad_alloc(); // not in C++ spec [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_array_new_length() { -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw bad_array_new_length(); -#else +# else _LIBCPP_VERBOSE_ABORT("bad_array_new_length was thrown in -fno-exceptions mode"); -#endif +# endif } -#if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION && !defined(_LIBCPP_ABI_VCRUNTIME) -# ifndef _LIBCPP_CXX03_LANG +# if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION && !defined(_LIBCPP_ABI_VCRUNTIME) +# ifndef _LIBCPP_CXX03_LANG enum class align_val_t : size_t {}; -# else +# else enum align_val_t { __zero = 0, __max = (size_t)-1 }; +# endif # endif -#endif -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 // Enable the declaration even if the compiler doesn't support the language // feature. struct destroying_delete_t { explicit destroying_delete_t() = default; }; inline constexpr destroying_delete_t destroying_delete{}; -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 } // namespace std -#if defined(_LIBCPP_CXX03_LANG) -# define _THROW_BAD_ALLOC throw(std::bad_alloc) -#else -# define _THROW_BAD_ALLOC -#endif +# if defined(_LIBCPP_CXX03_LANG) +# define _THROW_BAD_ALLOC throw(std::bad_alloc) +# else +# define _THROW_BAD_ALLOC +# endif -#if !defined(_LIBCPP_ABI_VCRUNTIME) +# if !defined(_LIBCPP_ABI_VCRUNTIME) [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC; [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT; -# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION +# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT; -# endif +# endif [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC; [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT; -# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION +# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT; -# endif +# endif -# if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION +# if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; -# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION +# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; -# endif +# endif [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; @@ -243,10 +244,10 @@ operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; -# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION +# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; +# endif # endif -# endif [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void* operator new(std::size_t, void* __p) _NOEXCEPT { @@ -259,43 +260,43 @@ operator new[](std::size_t, void* __p) _NOEXCEPT { inline _LIBCPP_HIDE_FROM_ABI void operator delete(void*, void*) _NOEXCEPT {} inline _LIBCPP_HIDE_FROM_ABI void operator delete[](void*, void*) _NOEXCEPT {} -#endif // !_LIBCPP_ABI_VCRUNTIME +# endif // !_LIBCPP_ABI_VCRUNTIME _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI bool __is_overaligned_for_new(size_t __align) _NOEXCEPT { -#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__ +# ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__ return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__; -#else +# else return __align > _LIBCPP_ALIGNOF(max_align_t); -#endif +# endif } template _LIBCPP_HIDE_FROM_ABI void* __libcpp_operator_new(_Args... __args) { -#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete) +# if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete) return __builtin_operator_new(__args...); -#else +# else return ::operator new(__args...); -#endif +# endif } template _LIBCPP_HIDE_FROM_ABI void __libcpp_operator_delete(_Args... __args) _NOEXCEPT { -#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete) +# if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete) __builtin_operator_delete(__args...); -#else +# else ::operator delete(__args...); -#endif +# endif } inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_allocate(size_t __size, size_t __align) { -#if _LIBCPP_HAS_ALIGNED_ALLOCATION +# if _LIBCPP_HAS_ALIGNED_ALLOCATION if (__is_overaligned_for_new(__align)) { const align_val_t __align_val = static_cast(__align); return __libcpp_operator_new(__size, __align_val); } -#endif +# endif (void)__align; return __libcpp_operator_new(__size); @@ -303,40 +304,40 @@ inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_allocate(size_t __size, size_t __ali template _LIBCPP_HIDE_FROM_ABI void __do_deallocate_handle_size(void* __ptr, size_t __size, _Args... __args) _NOEXCEPT { -#if !_LIBCPP_HAS_SIZED_DEALLOCATION +# if !_LIBCPP_HAS_SIZED_DEALLOCATION (void)__size; return std::__libcpp_operator_delete(__ptr, __args...); -#else +# else return std::__libcpp_operator_delete(__ptr, __size, __args...); -#endif +# endif } inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) _NOEXCEPT { -#if !_LIBCPP_HAS_ALIGNED_ALLOCATION +# if !_LIBCPP_HAS_ALIGNED_ALLOCATION (void)__align; return __do_deallocate_handle_size(__ptr, __size); -#else +# else if (__is_overaligned_for_new(__align)) { const align_val_t __align_val = static_cast(__align); return __do_deallocate_handle_size(__ptr, __size, __align_val); } else { return __do_deallocate_handle_size(__ptr, __size); } -#endif +# endif } inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized(void* __ptr, size_t __align) _NOEXCEPT { -#if !_LIBCPP_HAS_ALIGNED_ALLOCATION +# if !_LIBCPP_HAS_ALIGNED_ALLOCATION (void)__align; return __libcpp_operator_delete(__ptr); -#else +# else if (__is_overaligned_for_new(__align)) { const align_val_t __align_val = static_cast(__align); return __libcpp_operator_delete(__ptr, __align_val); } else { return __libcpp_operator_delete(__ptr); } -#endif +# endif } template @@ -346,29 +347,30 @@ template return __builtin_launder(__p); } -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp* launder(_Tp* __p) noexcept { return std::__launder(__p); } -#endif +# endif -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 -# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) +# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) inline constexpr size_t hardware_destructive_interference_size = __GCC_DESTRUCTIVE_SIZE; inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUCTIVE_SIZE; -# endif // defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) +# endif // defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) -#endif // _LIBCPP_STD_VER >= 17 +# endif // _LIBCPP_STD_VER >= 17 _LIBCPP_END_NAMESPACE_STD -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_NEW diff --git a/libcxx/include/numbers b/libcxx/include/numbers index f48ba4baf38ffd0..8556e20ed105d3e 100644 --- a/libcxx/include/numbers +++ b/libcxx/include/numbers @@ -58,15 +58,20 @@ namespace std::numbers { } */ -#include <__concepts/arithmetic.h> -#include <__config> -#include +#include <__configuration/cxx03.h> -#if _LIBCPP_STD_VER >= 20 +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/numbers> +#else +# include <__concepts/arithmetic.h> +# include <__config> +# include -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +# if _LIBCPP_STD_VER >= 20 + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -154,11 +159,12 @@ inline constexpr double phi = phi_v; _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_NUMBERS diff --git a/libcxx/include/numeric b/libcxx/include/numeric index 6b92ce3a0712376..4fb6628f7ede2d7 100644 --- a/libcxx/include/numeric +++ b/libcxx/include/numeric @@ -156,52 +156,58 @@ constexpr T saturate_cast(U x) noexcept; // freestanding, Sin */ -#include <__config> - -#include <__numeric/accumulate.h> -#include <__numeric/adjacent_difference.h> -#include <__numeric/inner_product.h> -#include <__numeric/iota.h> -#include <__numeric/partial_sum.h> - -#if _LIBCPP_STD_VER >= 17 -# include <__numeric/exclusive_scan.h> -# include <__numeric/gcd_lcm.h> -# include <__numeric/inclusive_scan.h> -# include <__numeric/pstl.h> -# include <__numeric/reduce.h> -# include <__numeric/transform_exclusive_scan.h> -# include <__numeric/transform_inclusive_scan.h> -# include <__numeric/transform_reduce.h> -#endif - -#if _LIBCPP_STD_VER >= 20 -# include <__numeric/midpoint.h> -# include <__numeric/saturation_arithmetic.h> -#endif - -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 -# include -# include -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/numeric> +#else +# include <__config> + +# include <__numeric/accumulate.h> +# include <__numeric/adjacent_difference.h> +# include <__numeric/inner_product.h> +# include <__numeric/iota.h> +# include <__numeric/partial_sum.h> + +# if _LIBCPP_STD_VER >= 17 +# include <__numeric/exclusive_scan.h> +# include <__numeric/gcd_lcm.h> +# include <__numeric/inclusive_scan.h> +# include <__numeric/pstl.h> +# include <__numeric/reduce.h> +# include <__numeric/transform_exclusive_scan.h> +# include <__numeric/transform_inclusive_scan.h> +# include <__numeric/transform_reduce.h> +# endif + +# if _LIBCPP_STD_VER >= 20 +# include <__numeric/midpoint.h> +# include <__numeric/saturation_arithmetic.h> +# endif + +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 +# include +# include +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_NUMERIC diff --git a/libcxx/include/optional b/libcxx/include/optional index b9dcf9053633f06..4e286415e846c7e 100644 --- a/libcxx/include/optional +++ b/libcxx/include/optional @@ -177,67 +177,72 @@ namespace std { */ -#include <__assert> -#include <__compare/compare_three_way_result.h> -#include <__compare/ordering.h> -#include <__compare/three_way_comparable.h> -#include <__concepts/invocable.h> -#include <__config> -#include <__exception/exception.h> -#include <__functional/hash.h> -#include <__functional/invoke.h> -#include <__functional/unary_function.h> -#include <__fwd/functional.h> -#include <__memory/addressof.h> -#include <__memory/construct_at.h> -#include <__tuple/sfinae_helpers.h> -#include <__type_traits/add_pointer.h> -#include <__type_traits/conditional.h> -#include <__type_traits/conjunction.h> -#include <__type_traits/decay.h> -#include <__type_traits/disjunction.h> -#include <__type_traits/enable_if.h> -#include <__type_traits/invoke.h> -#include <__type_traits/is_array.h> -#include <__type_traits/is_assignable.h> -#include <__type_traits/is_constructible.h> -#include <__type_traits/is_convertible.h> -#include <__type_traits/is_destructible.h> -#include <__type_traits/is_nothrow_assignable.h> -#include <__type_traits/is_nothrow_constructible.h> -#include <__type_traits/is_object.h> -#include <__type_traits/is_reference.h> -#include <__type_traits/is_scalar.h> -#include <__type_traits/is_swappable.h> -#include <__type_traits/is_trivially_assignable.h> -#include <__type_traits/is_trivially_constructible.h> -#include <__type_traits/is_trivially_destructible.h> -#include <__type_traits/is_trivially_relocatable.h> -#include <__type_traits/negation.h> -#include <__type_traits/remove_const.h> -#include <__type_traits/remove_cvref.h> -#include <__type_traits/remove_reference.h> -#include <__utility/declval.h> -#include <__utility/forward.h> -#include <__utility/in_place.h> -#include <__utility/move.h> -#include <__utility/swap.h> -#include <__verbose_abort> -#include -#include -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/optional> +#else +# include <__assert> +# include <__compare/compare_three_way_result.h> +# include <__compare/ordering.h> +# include <__compare/three_way_comparable.h> +# include <__concepts/invocable.h> +# include <__config> +# include <__exception/exception.h> +# include <__functional/hash.h> +# include <__functional/invoke.h> +# include <__functional/unary_function.h> +# include <__fwd/functional.h> +# include <__memory/addressof.h> +# include <__memory/construct_at.h> +# include <__tuple/sfinae_helpers.h> +# include <__type_traits/add_pointer.h> +# include <__type_traits/conditional.h> +# include <__type_traits/conjunction.h> +# include <__type_traits/decay.h> +# include <__type_traits/disjunction.h> +# include <__type_traits/enable_if.h> +# include <__type_traits/invoke.h> +# include <__type_traits/is_array.h> +# include <__type_traits/is_assignable.h> +# include <__type_traits/is_constructible.h> +# include <__type_traits/is_convertible.h> +# include <__type_traits/is_destructible.h> +# include <__type_traits/is_nothrow_assignable.h> +# include <__type_traits/is_nothrow_constructible.h> +# include <__type_traits/is_object.h> +# include <__type_traits/is_reference.h> +# include <__type_traits/is_scalar.h> +# include <__type_traits/is_swappable.h> +# include <__type_traits/is_trivially_assignable.h> +# include <__type_traits/is_trivially_constructible.h> +# include <__type_traits/is_trivially_destructible.h> +# include <__type_traits/is_trivially_relocatable.h> +# include <__type_traits/negation.h> +# include <__type_traits/remove_const.h> +# include <__type_traits/remove_cvref.h> +# include <__type_traits/remove_reference.h> +# include <__utility/declval.h> +# include <__utility/forward.h> +# include <__utility/in_place.h> +# include <__utility/move.h> +# include <__utility/swap.h> +# include <__verbose_abort> +# include +# include +# include // standard-mandated includes // [optional.syn] -#include +# include -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> namespace std // purposefully not using versioning namespace { @@ -254,17 +259,17 @@ public: } // namespace std -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_BEGIN_NAMESPACE_STD [[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS void __throw_bad_optional_access() { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw bad_optional_access(); -# else +# else _LIBCPP_VERBOSE_ABORT("bad_optional_access was thrown in -fno-exceptions mode"); -# endif +# endif } struct nullopt_t { @@ -302,12 +307,12 @@ struct __optional_destruct_base<_Tp, false> { _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base(in_place_t, _Args&&... __args) : __val_(std::forward<_Args>(__args)...), __engaged_(true) {} -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base( __optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args) : __val_(std::invoke(std::forward<_Fp>(__f), std::forward<_Args>(__args)...)), __engaged_(true) {} -# endif +# endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept { if (__engaged_) { @@ -333,12 +338,12 @@ struct __optional_destruct_base<_Tp, true> { _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base(in_place_t, _Args&&... __args) : __val_(std::forward<_Args>(__args)...), __engaged_(true) {} -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template _LIBCPP_HIDE_FROM_ABI constexpr __optional_destruct_base( __optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args) : __val_(std::invoke(std::forward<_Fp>(__f), std::forward<_Args>(__args)...)), __engaged_(true) {} -# endif +# endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept { if (__engaged_) { @@ -562,12 +567,12 @@ using __optional_sfinae_assign_base_t = template class optional; -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template concept __is_derived_from_optional = requires(const _Tp& __t) { [](const optional<_Up>&) {}(__t); }; -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 template struct __is_std_optional : false_type {}; @@ -709,14 +714,14 @@ public: this->__construct_from(std::move(__v)); } -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Tag, _Fp&& __f, _Args&&... __args) : __base(__optional_construct_from_invoke_tag{}, std::forward<_Fp>(__f), std::forward<_Args>(__args)...) {} -# endif +# endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(nullopt_t) noexcept { reset(); @@ -862,7 +867,7 @@ public: return this->has_value() ? std::move(this->__get()) : static_cast(std::forward<_Up>(__v)); } -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto and_then(_Func&& __f) & { using _Up = invoke_result_t<_Func, value_type&>; @@ -972,15 +977,15 @@ public: return std::move(*this); return std::forward<_Func>(__f)(); } -# endif // _LIBCPP_STD_VER >= 23 +# endif // _LIBCPP_STD_VER >= 23 using __base::reset; }; -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template optional(_Tp) -> optional<_Tp>; -# endif +# endif // Comparisons between optionals template @@ -1055,7 +1060,7 @@ operator>=(const optional<_Tp>& __x, const optional<_Up>& __y) { return *__x >= *__y; } -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template _Up> _LIBCPP_HIDE_FROM_ABI constexpr compare_three_way_result_t<_Tp, _Up> @@ -1065,7 +1070,7 @@ operator<=>(const optional<_Tp>& __x, const optional<_Up>& __y) { return __x.has_value() <=> __y.has_value(); } -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 // Comparisons with nullopt template @@ -1073,7 +1078,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, nullop return !static_cast(__x); } -# if _LIBCPP_STD_VER <= 17 +# if _LIBCPP_STD_VER <= 17 template _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(nullopt_t, const optional<_Tp>& __x) noexcept { @@ -1130,14 +1135,14 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(nullopt_t, const optional<_Tp>& return !static_cast(__x); } -# else // _LIBCPP_STD_VER <= 17 +# else // _LIBCPP_STD_VER <= 17 template _LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const optional<_Tp>& __x, nullopt_t) noexcept { return __x.has_value() <=> false; } -# endif // _LIBCPP_STD_VER <= 17 +# endif // _LIBCPP_STD_VER <= 17 // Comparisons with T template @@ -1236,7 +1241,7 @@ operator>=(const _Tp& __v, const optional<_Up>& __x) { return static_cast(__x) ? __v >= *__x : true; } -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template requires(!__is_derived_from_optional<_Up>) && three_way_comparable_with<_Tp, _Up> @@ -1245,7 +1250,7 @@ operator<=>(const optional<_Tp>& __x, const _Up& __v) { return __x.has_value() ? *__x <=> __v : strong_ordering::less; } -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI @@ -1271,10 +1276,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr optional<_Tp> make_optional(initializer_list<_Up template struct _LIBCPP_TEMPLATE_VIS hash< __enable_hash_helper, remove_const_t<_Tp>> > { -# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) +# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) _LIBCPP_DEPRECATED_IN_CXX17 typedef optional<_Tp> argument_type; _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; -# endif +# endif _LIBCPP_HIDE_FROM_ABI size_t operator()(const optional<_Tp>& __opt) const { return static_cast(__opt) ? hash>()(*__opt) : 0; @@ -1283,25 +1288,26 @@ struct _LIBCPP_TEMPLATE_VIS hash< __enable_hash_helper, remove_con _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP_STD_VER >= 17 +# endif // _LIBCPP_STD_VER >= 17 _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_OPTIONAL diff --git a/libcxx/include/ostream b/libcxx/include/ostream index 83742882f7bb670..10eb6fde6e80653 100644 --- a/libcxx/include/ostream +++ b/libcxx/include/ostream @@ -172,35 +172,41 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args); */ -#include <__config> +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/ostream> +#else +# include <__config> -# include <__ostream/basic_ostream.h> +# if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# if _LIBCPP_STD_VER >= 23 -# include <__ostream/print.h> -# endif +# include <__ostream/basic_ostream.h> -# include +# if _LIBCPP_STD_VER >= 23 +# include <__ostream/print.h> +# endif -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif -#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif +# endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_OSTREAM diff --git a/libcxx/include/print b/libcxx/include/print index 2798a6bda262624..fabfc774c5a6685 100644 --- a/libcxx/include/print +++ b/libcxx/include/print @@ -33,28 +33,33 @@ namespace std { } */ -#include <__assert> -#include <__concepts/same_as.h> -#include <__config> -#include <__system_error/system_error.h> -#include <__utility/forward.h> -#include -#include -#include -#include -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/print> +#else +# include <__assert> +# include <__concepts/same_as.h> +# include <__config> +# include <__system_error/system_error.h> +# include <__utility/forward.h> +# include +# include +# include +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD -#ifdef _LIBCPP_WIN32API +# ifdef _LIBCPP_WIN32API _LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream); -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS // A wrapper for WriteConsoleW which is used to write to the Windows // console. This function is in the dylib to avoid pulling in windows.h // in the library headers. The function itself uses some private parts @@ -65,14 +70,14 @@ _LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream); // // Note the function is only implemented on the Windows platform. _LIBCPP_EXPORTED_FROM_ABI void __write_to_windows_console(FILE* __stream, wstring_view __view); -# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS -#elif __has_include() +# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS +# elif __has_include() _LIBCPP_EXPORTED_FROM_ABI bool __is_posix_terminal(FILE* __stream); -#endif // _LIBCPP_WIN32API +# endif // _LIBCPP_WIN32API -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 -# ifndef _LIBCPP_HAS_NO_UNICODE +# ifndef _LIBCPP_HAS_NO_UNICODE // This is the code to transcode UTF-8 to UTF-16. This is used on // Windows for the native Unicode API. The code is modeled to make it // easier to extend to @@ -86,27 +91,27 @@ namespace __unicode { // The names of these concepts are modelled after P2728R0, but the // implementation is not. char16_t may contain 32-bits so depending on the // number of bits is an issue. -# ifdef _LIBCPP_SHORT_WCHAR +# ifdef _LIBCPP_SHORT_WCHAR template concept __utf16_code_unit = same_as<_Tp, char16_t> -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS || same_as<_Tp, wchar_t> -# endif +# endif ; template concept __utf32_code_unit = same_as<_Tp, char32_t>; -# else // _LIBCPP_SHORT_WCHAR +# else // _LIBCPP_SHORT_WCHAR template concept __utf16_code_unit = same_as<_Tp, char16_t>; template concept __utf32_code_unit = same_as<_Tp, char32_t> -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS || same_as<_Tp, wchar_t> -# endif +# endif ; -# endif // _LIBCPP_SHORT_WCHAR +# endif // _LIBCPP_SHORT_WCHAR // Pass by reference since an output_iterator may not be copyable. template @@ -164,7 +169,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _OutIt __transcode(_InIt __first, _InIt __last, } // namespace __unicode -# endif // _LIBCPP_HAS_NO_UNICODE +# endif // _LIBCPP_HAS_NO_UNICODE namespace __print { @@ -184,30 +189,30 @@ namespace __print { // (note at the time of writing Clang is hard-coded to UTF-8.) // -# ifdef _LIBCPP_HAS_NO_UNICODE +# ifdef _LIBCPP_HAS_NO_UNICODE inline constexpr bool __use_unicode_execution_charset = false; -# elif defined(_MSVC_EXECUTION_CHARACTER_SET) +# elif defined(_MSVC_EXECUTION_CHARACTER_SET) // This is the same test MSVC STL uses in their implementation of // See: https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers inline constexpr bool __use_unicode_execution_charset = _MSVC_EXECUTION_CHARACTER_SET == 65001; -# else +# else inline constexpr bool __use_unicode_execution_charset = true; -# endif +# endif _LIBCPP_HIDE_FROM_ABI inline bool __is_terminal([[maybe_unused]] FILE* __stream) { // The macro _LIBCPP_TESTING_PRINT_IS_TERMINAL is used to change // the behavior in the test. This is not part of the public API. -# ifdef _LIBCPP_TESTING_PRINT_IS_TERMINAL +# ifdef _LIBCPP_TESTING_PRINT_IS_TERMINAL return _LIBCPP_TESTING_PRINT_IS_TERMINAL(__stream); -# elif _LIBCPP_AVAILABILITY_HAS_PRINT == 0 || defined(_LIBCPP_HAS_NO_TERMINAL) +# elif _LIBCPP_AVAILABILITY_HAS_PRINT == 0 || defined(_LIBCPP_HAS_NO_TERMINAL) return false; -# elif defined(_LIBCPP_WIN32API) +# elif defined(_LIBCPP_WIN32API) return std::__is_windows_terminal(__stream); -# elif __has_include() +# elif __has_include() return std::__is_posix_terminal(__stream); -# else -# error "Provide a way to determine whether a FILE* is a terminal" -# endif +# else +# error "Provide a way to determine whether a FILE* is a terminal" +# endif } template // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). @@ -226,7 +231,7 @@ __vprint_nonunicode(FILE* __stream, string_view __fmt, format_args __args, bool } } -# ifndef _LIBCPP_HAS_NO_UNICODE +# ifndef _LIBCPP_HAS_NO_UNICODE // Note these helper functions are mainly used to aid testing. // On POSIX systems and Windows the output is no longer considered a @@ -243,7 +248,7 @@ __vprint_unicode_posix(FILE* __stream, string_view __fmt, format_args __args, bo __print::__vprint_nonunicode(__stream, __fmt, __args, __write_nl); } -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). _LIBCPP_HIDE_FROM_ABI inline void __vprint_unicode_windows(FILE* __stream, string_view __fmt, format_args __args, bool __write_nl, bool __is_terminal) { @@ -272,16 +277,16 @@ __vprint_unicode_windows(FILE* __stream, string_view __fmt, format_args __args, // The macro _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION is used to change // the behavior in the test. This is not part of the public API. -# ifdef _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION +# ifdef _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION(__stream, __view); -# elif defined(_LIBCPP_WIN32API) +# elif defined(_LIBCPP_WIN32API) std::__write_to_windows_console(__stream, __view); -# else +# else std::__throw_runtime_error("No defintion of _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION and " "__write_to_windows_console is not available."); -# endif +# endif } -# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS +# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS template // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). _LIBCPP_HIDE_FROM_ABI inline void @@ -312,29 +317,29 @@ __vprint_unicode([[maybe_unused]] FILE* __stream, // so there the call can be forwarded to the non_unicode API. On // Windows there is a different API. This API requires transcoding. -# ifndef _LIBCPP_WIN32API +# ifndef _LIBCPP_WIN32API __print::__vprint_unicode_posix(__stream, __fmt, __args, __write_nl, __print::__is_terminal(__stream)); -# elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) +# elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) __print::__vprint_unicode_windows(__stream, __fmt, __args, __write_nl, __print::__is_terminal(__stream)); -# else -# error "Windows builds with wchar_t disabled are not supported." -# endif +# else +# error "Windows builds with wchar_t disabled are not supported." +# endif } -# endif // _LIBCPP_HAS_NO_UNICODE +# endif // _LIBCPP_HAS_NO_UNICODE } // namespace __print template _LIBCPP_HIDE_FROM_ABI void print(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args) { -# ifndef _LIBCPP_HAS_NO_UNICODE +# ifndef _LIBCPP_HAS_NO_UNICODE if constexpr (__print::__use_unicode_execution_charset) __print::__vprint_unicode(__stream, __fmt.get(), std::make_format_args(__args...), false); else __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), false); -# else // _LIBCPP_HAS_NO_UNICODE +# else // _LIBCPP_HAS_NO_UNICODE __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), false); -# endif // _LIBCPP_HAS_NO_UNICODE +# endif // _LIBCPP_HAS_NO_UNICODE } template @@ -344,7 +349,7 @@ _LIBCPP_HIDE_FROM_ABI void print(format_string<_Args...> __fmt, _Args&&... __arg template _LIBCPP_HIDE_FROM_ABI void println(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args) { -# ifndef _LIBCPP_HAS_NO_UNICODE +# ifndef _LIBCPP_HAS_NO_UNICODE // Note the wording in the Standard is inefficient. The output of // std::format is a std::string which is then copied. This solution // just appends a newline at the end of the output. @@ -352,9 +357,9 @@ _LIBCPP_HIDE_FROM_ABI void println(FILE* __stream, format_string<_Args...> __fmt __print::__vprint_unicode(__stream, __fmt.get(), std::make_format_args(__args...), true); else __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), true); -# else // _LIBCPP_HAS_NO_UNICODE +# else // _LIBCPP_HAS_NO_UNICODE __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), true); -# endif // _LIBCPP_HAS_NO_UNICODE +# endif // _LIBCPP_HAS_NO_UNICODE } template // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). @@ -372,7 +377,7 @@ _LIBCPP_HIDE_FROM_ABI void println(format_string<_Args...> __fmt, _Args&&... __a std::println(stdout, __fmt, std::forward<_Args>(__args)...); } -# ifndef _LIBCPP_HAS_NO_UNICODE +# ifndef _LIBCPP_HAS_NO_UNICODE template // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). _LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(FILE* __stream, string_view __fmt, format_args __args) { __print::__vprint_unicode(__stream, __fmt, __args, false); @@ -383,7 +388,7 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(string_view __fmt, format_args std::vprint_unicode(stdout, __fmt, __args); } -# endif // _LIBCPP_HAS_NO_UNICODE +# endif // _LIBCPP_HAS_NO_UNICODE template // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). _LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(FILE* __stream, string_view __fmt, format_args __args) { @@ -395,8 +400,9 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(string_view __fmt, format_ar std::vprint_nonunicode(stdout, __fmt, __args); } -#endif // _LIBCPP_STD_VER >= 23 +# endif // _LIBCPP_STD_VER >= 23 _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_PRINT diff --git a/libcxx/include/queue b/libcxx/include/queue index db9ad26eaeddfb1..6c87040af514883 100644 --- a/libcxx/include/queue +++ b/libcxx/include/queue @@ -254,38 +254,43 @@ template */ -#include <__algorithm/make_heap.h> -#include <__algorithm/pop_heap.h> -#include <__algorithm/push_heap.h> -#include <__algorithm/ranges_copy.h> -#include <__config> -#include <__functional/operations.h> -#include <__fwd/deque.h> -#include <__fwd/queue.h> -#include <__iterator/back_insert_iterator.h> -#include <__iterator/iterator_traits.h> -#include <__memory/uses_allocator.h> -#include <__ranges/access.h> -#include <__ranges/concepts.h> -#include <__ranges/container_compatible_range.h> -#include <__ranges/from_range.h> -#include <__utility/forward.h> -#include -#include -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/queue> +#else +# include <__algorithm/make_heap.h> +# include <__algorithm/pop_heap.h> +# include <__algorithm/push_heap.h> +# include <__algorithm/ranges_copy.h> +# include <__config> +# include <__functional/operations.h> +# include <__fwd/deque.h> +# include <__fwd/queue.h> +# include <__iterator/back_insert_iterator.h> +# include <__iterator/iterator_traits.h> +# include <__memory/uses_allocator.h> +# include <__ranges/access.h> +# include <__ranges/concepts.h> +# include <__ranges/container_compatible_range.h> +# include <__ranges/from_range.h> +# include <__utility/forward.h> +# include +# include +# include // standard-mandated includes // [queue.syn] -#include -#include +# include +# include -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -313,7 +318,7 @@ public: _LIBCPP_HIDE_FROM_ABI queue(const queue& __q) : c(__q.c) {} -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} @@ -333,14 +338,14 @@ public: _LIBCPP_HIDE_FROM_ABI queue(from_range_t, _Range&& __range, const _Alloc& __alloc) : c(from_range, std::forward<_Range>(__range), __alloc) {} -#endif +# endif _LIBCPP_HIDE_FROM_ABI queue& operator=(const queue& __q) { c = __q.c; return *this; } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI queue(queue&& __q) noexcept(is_nothrow_move_constructible::value) : c(std::move(__q.c)) {} @@ -348,12 +353,12 @@ public: c = std::move(__q.c); return *this; } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI explicit queue(const container_type& __c) : c(__c) {} -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI explicit queue(container_type&& __c) : c(std::move(__c)) {} -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI explicit queue(const _Alloc& __a) : c(__a) {} @@ -364,13 +369,13 @@ public: template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI queue(const container_type& __c, const _Alloc& __a) : c(__c, __a) {} -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI queue(container_type&& __c, const _Alloc& __a) : c(std::move(__c), __a) {} template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI queue(queue&& __q, const _Alloc& __a) : c(std::move(__q.c), __a) {} -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } @@ -381,10 +386,10 @@ public: _LIBCPP_HIDE_FROM_ABI const_reference back() const { return c.back(); } _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v) { c.push_back(std::move(__v)); } -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) { if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) { @@ -393,22 +398,22 @@ public: ranges::copy(std::forward<_Range>(__range), std::back_inserter(c)); } } -# endif +# endif template _LIBCPP_HIDE_FROM_ABI -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 decltype(auto) emplace(_Args&&... __args) { return c.emplace_back(std::forward<_Args>(__args)...); } -# else +# else void emplace(_Args&&... __args) { c.emplace_back(std::forward<_Args>(__args)...); } -# endif -#endif // _LIBCPP_CXX03_LANG +# endif +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_front(); } _LIBCPP_HIDE_FROM_ABI void swap(queue& __q) _NOEXCEPT_(__is_nothrow_swappable_v) { @@ -427,7 +432,7 @@ public: operator<(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y); }; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template ::value> > queue(_Container) -> queue; @@ -436,9 +441,9 @@ template ::value>, class = enable_if_t::value> > queue(_Container, _Alloc) -> queue; -#endif +# endif -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template ::value, int> = 0> queue(_InputIterator, _InputIterator) -> queue<__iter_value_type<_InputIterator>>; @@ -449,15 +454,13 @@ template ::value, int> = 0, __enable_if_t<__is_allocator<_Alloc>::value, int> = 0> -queue(_InputIterator, - _InputIterator, - _Alloc) -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; +queue(_InputIterator, _InputIterator, _Alloc) + -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; template ::value, int> = 0> -queue(from_range_t, - _Range&&, - _Alloc) -> queue, deque, _Alloc>>; -#endif +queue(from_range_t, _Range&&, _Alloc) + -> queue, deque, _Alloc>>; +# endif template inline _LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { @@ -489,7 +492,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const queue<_Tp, _Container>& __x, return !(__y < __x); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template _LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container> @@ -498,7 +501,7 @@ operator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y return __x.__get_container() <=> __y.__get_container(); } -#endif +# endif template , int> = 0> inline _LIBCPP_HIDE_FROM_ABI void swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) @@ -538,7 +541,7 @@ public: return *this; } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q) noexcept( is_nothrow_move_constructible::value && is_nothrow_move_constructible::value) : c(std::move(__q.c)), comp(std::move(__q.comp)) {} @@ -549,13 +552,13 @@ public: comp = std::move(__q.comp); return *this; } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const value_compare& __comp) : c(), comp(__comp) {} _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c); -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c); -#endif +# endif template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp = value_compare()); @@ -563,19 +566,19 @@ public: _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c); -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c); -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const value_compare& __comp = value_compare()) : c(from_range, std::forward<_Range>(__range)), comp(__comp) { std::make_heap(c.begin(), c.end(), comp); } -#endif +# endif template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const _Alloc& __a); @@ -589,13 +592,13 @@ public: template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q, const _Alloc& __a); -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c, const _Alloc& __a); template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q, const _Alloc& __a); -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template < class _InputIter, @@ -619,7 +622,7 @@ public: _LIBCPP_HIDE_FROM_ABI priority_queue( _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a); -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template < class _InputIter, class _Alloc, @@ -627,9 +630,9 @@ public: int> = 0> _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a); -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range, class _Alloc, @@ -647,17 +650,17 @@ public: std::make_heap(c.begin(), c.end(), comp); } -#endif +# endif [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); } _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v); -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v); -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) { if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) { @@ -668,11 +671,11 @@ public: std::make_heap(c.begin(), c.end(), comp); } -# endif +# endif template _LIBCPP_HIDE_FROM_ABI void emplace(_Args&&... __args); -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI void pop(); _LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q) @@ -681,7 +684,7 @@ public: [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } }; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template ::value>, @@ -735,9 +738,9 @@ template ::value> > priority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc) -> priority_queue; -#endif +# endif -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template >, @@ -757,7 +760,7 @@ template priority_queue, vector, _Alloc>>; -#endif +# endif template inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, const container_type& __c) @@ -765,7 +768,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& std::make_heap(c.begin(), c.end(), comp); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, container_type&& __c) @@ -773,7 +776,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_com std::make_heap(c.begin(), c.end(), comp); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template template ::value, int> > @@ -792,7 +795,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( std::make_heap(c.begin(), c.end(), comp); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template template ::value, int> > @@ -803,7 +806,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( std::make_heap(c.begin(), c.end(), comp); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template template ::value, int> > @@ -827,7 +830,7 @@ template ::value, inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, const _Alloc& __a) : c(__q.c, __a), comp(__q.comp) {} -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template template ::value, int> > @@ -842,7 +845,7 @@ template ::value, inline priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, const _Alloc& __a) : c(std::move(__q.c), __a), comp(std::move(__q.comp)) {} -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template template < @@ -877,7 +880,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( std::make_heap(c.begin(), c.end(), comp); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template template < class _InputIter, @@ -889,7 +892,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( c.insert(c.end(), __f, __l); std::make_heap(c.begin(), c.end(), comp); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template inline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) { @@ -897,7 +900,7 @@ inline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __ std::push_heap(c.begin(), c.end(), comp); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template inline void priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) { @@ -912,7 +915,7 @@ inline void priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args std::push_heap(c.begin(), c.end(), comp); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template inline void priority_queue<_Tp, _Container, _Compare>::pop() { @@ -946,11 +949,12 @@ _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_QUEUE diff --git a/libcxx/include/random b/libcxx/include/random index 6cc3760c20e16c7..ce9680441d4bb47 100644 --- a/libcxx/include/random +++ b/libcxx/include/random @@ -1677,66 +1677,72 @@ class piecewise_linear_distribution } // std */ -#include <__config> -#include <__random/bernoulli_distribution.h> -#include <__random/binomial_distribution.h> -#include <__random/cauchy_distribution.h> -#include <__random/chi_squared_distribution.h> -#include <__random/default_random_engine.h> -#include <__random/discard_block_engine.h> -#include <__random/discrete_distribution.h> -#include <__random/exponential_distribution.h> -#include <__random/extreme_value_distribution.h> -#include <__random/fisher_f_distribution.h> -#include <__random/gamma_distribution.h> -#include <__random/generate_canonical.h> -#include <__random/geometric_distribution.h> -#include <__random/independent_bits_engine.h> -#include <__random/is_seed_sequence.h> -#include <__random/knuth_b.h> -#include <__random/linear_congruential_engine.h> -#include <__random/lognormal_distribution.h> -#include <__random/mersenne_twister_engine.h> -#include <__random/negative_binomial_distribution.h> -#include <__random/normal_distribution.h> -#include <__random/piecewise_constant_distribution.h> -#include <__random/piecewise_linear_distribution.h> -#include <__random/poisson_distribution.h> -#include <__random/random_device.h> -#include <__random/ranlux.h> -#include <__random/seed_seq.h> -#include <__random/shuffle_order_engine.h> -#include <__random/student_t_distribution.h> -#include <__random/subtract_with_carry_engine.h> -#include <__random/uniform_int_distribution.h> -#include <__random/uniform_random_bit_generator.h> -#include <__random/uniform_real_distribution.h> -#include <__random/weibull_distribution.h> -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/random> +#else +# include <__config> +# include <__random/bernoulli_distribution.h> +# include <__random/binomial_distribution.h> +# include <__random/cauchy_distribution.h> +# include <__random/chi_squared_distribution.h> +# include <__random/default_random_engine.h> +# include <__random/discard_block_engine.h> +# include <__random/discrete_distribution.h> +# include <__random/exponential_distribution.h> +# include <__random/extreme_value_distribution.h> +# include <__random/fisher_f_distribution.h> +# include <__random/gamma_distribution.h> +# include <__random/generate_canonical.h> +# include <__random/geometric_distribution.h> +# include <__random/independent_bits_engine.h> +# include <__random/is_seed_sequence.h> +# include <__random/knuth_b.h> +# include <__random/linear_congruential_engine.h> +# include <__random/lognormal_distribution.h> +# include <__random/mersenne_twister_engine.h> +# include <__random/negative_binomial_distribution.h> +# include <__random/normal_distribution.h> +# include <__random/piecewise_constant_distribution.h> +# include <__random/piecewise_linear_distribution.h> +# include <__random/poisson_distribution.h> +# include <__random/random_device.h> +# include <__random/ranlux.h> +# include <__random/seed_seq.h> +# include <__random/shuffle_order_engine.h> +# include <__random/student_t_distribution.h> +# include <__random/subtract_with_carry_engine.h> +# include <__random/uniform_int_distribution.h> +# include <__random/uniform_random_bit_generator.h> +# include <__random/uniform_real_distribution.h> +# include <__random/weibull_distribution.h> +# include // standard-mandated includes // [rand.synopsis] -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_RANDOM diff --git a/libcxx/include/ranges b/libcxx/include/ranges index fa35874265de675..b01d69642d69757 100644 --- a/libcxx/include/ranges +++ b/libcxx/include/ranges @@ -380,84 +380,90 @@ namespace std { } */ -#include <__config> - -#if _LIBCPP_STD_VER >= 20 -# include <__ranges/access.h> -# include <__ranges/all.h> -# include <__ranges/common_view.h> -# include <__ranges/concepts.h> -# include <__ranges/counted.h> -# include <__ranges/dangling.h> -# include <__ranges/data.h> -# include <__ranges/drop_view.h> -# include <__ranges/drop_while_view.h> -# include <__ranges/elements_view.h> -# include <__ranges/empty.h> -# include <__ranges/empty_view.h> -# include <__ranges/enable_borrowed_range.h> -# include <__ranges/enable_view.h> -# include <__ranges/filter_view.h> -# include <__ranges/iota_view.h> -# include <__ranges/join_view.h> -# include <__ranges/lazy_split_view.h> -# include <__ranges/rbegin.h> -# include <__ranges/ref_view.h> -# include <__ranges/rend.h> -# include <__ranges/reverse_view.h> -# include <__ranges/single_view.h> -# include <__ranges/size.h> -# include <__ranges/split_view.h> -# include <__ranges/subrange.h> -# include <__ranges/take_view.h> -# include <__ranges/take_while_view.h> -# include <__ranges/transform_view.h> -# include <__ranges/view_interface.h> -# include <__ranges/views.h> - -# if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include <__ranges/istream_view.h> +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/ranges> +#else +# include <__config> + +# if _LIBCPP_STD_VER >= 20 +# include <__ranges/access.h> +# include <__ranges/all.h> +# include <__ranges/common_view.h> +# include <__ranges/concepts.h> +# include <__ranges/counted.h> +# include <__ranges/dangling.h> +# include <__ranges/data.h> +# include <__ranges/drop_view.h> +# include <__ranges/drop_while_view.h> +# include <__ranges/elements_view.h> +# include <__ranges/empty.h> +# include <__ranges/empty_view.h> +# include <__ranges/enable_borrowed_range.h> +# include <__ranges/enable_view.h> +# include <__ranges/filter_view.h> +# include <__ranges/iota_view.h> +# include <__ranges/join_view.h> +# include <__ranges/lazy_split_view.h> +# include <__ranges/rbegin.h> +# include <__ranges/ref_view.h> +# include <__ranges/rend.h> +# include <__ranges/reverse_view.h> +# include <__ranges/single_view.h> +# include <__ranges/size.h> +# include <__ranges/split_view.h> +# include <__ranges/subrange.h> +# include <__ranges/take_view.h> +# include <__ranges/take_while_view.h> +# include <__ranges/transform_view.h> +# include <__ranges/view_interface.h> +# include <__ranges/views.h> + +# if !defined(_LIBCPP_HAS_NO_LOCALIZATION) +# include <__ranges/istream_view.h> +# endif # endif -#endif -#if _LIBCPP_STD_VER >= 23 -# include <__ranges/as_rvalue_view.h> -# include <__ranges/chunk_by_view.h> -# include <__ranges/from_range.h> -# include <__ranges/repeat_view.h> -# include <__ranges/to.h> -# include <__ranges/zip_view.h> -#endif +# if _LIBCPP_STD_VER >= 23 +# include <__ranges/as_rvalue_view.h> +# include <__ranges/chunk_by_view.h> +# include <__ranges/from_range.h> +# include <__ranges/repeat_view.h> +# include <__ranges/to.h> +# include <__ranges/zip_view.h> +# endif -#include +# include // standard-mandated includes // [ranges.syn] -#include -#include -#include +# include +# include +# include // [tuple.helper] -#include <__tuple/tuple_element.h> -#include <__tuple/tuple_size.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 -# include -# include -# include -# include -# include -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -#endif +# include <__tuple/tuple_element.h> +# include <__tuple/tuple_size.h> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 +# include +# include +# include +# include +# include +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_RANGES diff --git a/libcxx/include/ratio b/libcxx/include/ratio index b989c272aaee6ad..ed32d2bb8becc53 100644 --- a/libcxx/include/ratio +++ b/libcxx/include/ratio @@ -81,18 +81,21 @@ using quetta = ratio <1'000'000'000'000'000'000'000'000'000'000, 1>; // Since C+ } */ -#include <__config> -#include <__type_traits/integral_constant.h> -#include -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/ratio> +#else +# include <__config> +# include <__type_traits/integral_constant.h> +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -296,17 +299,17 @@ public: __ll_mul<_R2::den / __gcd_n1_d2, _R1::den / __gcd_d1_n2>::value >::type type; }; -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template using ratio_multiply = typename __ratio_multiply<_R1, _R2>::type; -#else // _LIBCPP_CXX03_LANG +# else // _LIBCPP_CXX03_LANG template struct _LIBCPP_TEMPLATE_VIS ratio_multiply : public __ratio_multiply<_R1, _R2>::type {}; -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template struct __ratio_divide { @@ -322,17 +325,17 @@ public: __ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value >::type type; }; -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template using ratio_divide = typename __ratio_divide<_R1, _R2>::type; -#else // _LIBCPP_CXX03_LANG +# else // _LIBCPP_CXX03_LANG template struct _LIBCPP_TEMPLATE_VIS ratio_divide : public __ratio_divide<_R1, _R2>::type {}; -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template struct __ratio_add { @@ -351,17 +354,17 @@ public: _R2::den > >::type type; }; -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template using ratio_add = typename __ratio_add<_R1, _R2>::type; -#else // _LIBCPP_CXX03_LANG +# else // _LIBCPP_CXX03_LANG template struct _LIBCPP_TEMPLATE_VIS ratio_add : public __ratio_add<_R1, _R2>::type {}; -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template struct __ratio_subtract { @@ -380,17 +383,17 @@ public: _R2::den > >::type type; }; -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template using ratio_subtract = typename __ratio_subtract<_R1, _R2>::type; -#else // _LIBCPP_CXX03_LANG +# else // _LIBCPP_CXX03_LANG template struct _LIBCPP_TEMPLATE_VIS ratio_subtract : public __ratio_subtract<_R1, _R2>::type {}; -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG // ratio_equal @@ -486,7 +489,7 @@ struct __ratio_gcd { typedef ratio<__static_gcd<_R1::num, _R2::num>::value, __static_lcm<_R1::den, _R2::den>::value> type; }; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template inline constexpr bool ratio_equal_v = ratio_equal<_R1, _R2>::value; @@ -504,14 +507,15 @@ inline constexpr bool ratio_greater_v = ratio_greater<_R1, _R2>::value; template inline constexpr bool ratio_greater_equal_v = ratio_greater_equal<_R1, _R2>::value; -#endif +# endif _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_RATIO diff --git a/libcxx/include/regex b/libcxx/include/regex index 074b19865cb4ff9..d9056921aa62959 100644 --- a/libcxx/include/regex +++ b/libcxx/include/regex @@ -789,48 +789,53 @@ typedef regex_token_iterator wsregex_token_iterator; } // std */ -#include <__algorithm/find.h> -#include <__algorithm/search.h> -#include <__assert> -#include <__config> -#include <__iterator/back_insert_iterator.h> -#include <__iterator/default_sentinel.h> -#include <__iterator/wrap_iter.h> -#include <__locale> -#include <__memory/shared_ptr.h> -#include <__memory_resource/polymorphic_allocator.h> -#include <__type_traits/is_swappable.h> -#include <__utility/move.h> -#include <__utility/pair.h> -#include <__utility/swap.h> -#include <__verbose_abort> -#include -#include -#include -#include -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/regex> +#else +# include <__algorithm/find.h> +# include <__algorithm/search.h> +# include <__assert> +# include <__config> +# include <__iterator/back_insert_iterator.h> +# include <__iterator/default_sentinel.h> +# include <__iterator/wrap_iter.h> +# include <__locale> +# include <__memory/shared_ptr.h> +# include <__memory_resource/polymorphic_allocator.h> +# include <__type_traits/is_swappable.h> +# include <__utility/move.h> +# include <__utility/pair.h> +# include <__utility/swap.h> +# include <__verbose_abort> +# include +# include +# include +# include +# include // standard-mandated includes // [iterator.range] -#include <__iterator/access.h> -#include <__iterator/data.h> -#include <__iterator/empty.h> -#include <__iterator/reverse_access.h> -#include <__iterator/size.h> +# include <__iterator/access.h> +# include <__iterator/data.h> +# include <__iterator/empty.h> +# include <__iterator/reverse_access.h> +# include <__iterator/size.h> // [re.syn] -#include -#include +# include +# include -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> -#define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096 +# define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096 _LIBCPP_BEGIN_NAMESPACE_STD @@ -843,11 +848,11 @@ enum syntax_option_type { nosubs = 1 << 1, optimize = 1 << 2, collate = 1 << 3, -#ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO +# ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO ECMAScript = 1 << 9, -#else +# else ECMAScript = 0, -#endif +# endif basic = 1 << 4, extended = 1 << 5, awk = 1 << 6, @@ -858,11 +863,11 @@ enum syntax_option_type { }; _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR syntax_option_type __get_grammar(syntax_option_type __g) { -#ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO +# ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO return static_cast(__g & 0x3F0); -#else +# else return static_cast(__g & 0x1F0); -#endif +# endif } inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR syntax_option_type operator~(syntax_option_type __x) { @@ -984,11 +989,11 @@ public: template [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_regex_error() { -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw regex_error(_Ev); -#else +# else _LIBCPP_VERBOSE_ABORT("regex_error was thrown in -fno-exceptions mode"); -#endif +# endif } template @@ -997,7 +1002,7 @@ public: typedef _CharT char_type; typedef basic_string string_type; typedef locale locale_type; -#if defined(__BIONIC__) || defined(_NEWLIB_VERSION) +# if defined(__BIONIC__) || defined(_NEWLIB_VERSION) // Originally bionic's ctype_base used its own ctype masks because the // builtin ctype implementation wasn't in libc++ yet. Bionic's ctype mask // was only 8 bits wide and already saturated, so it used a wider type here @@ -1012,9 +1017,9 @@ public: // often used for space constrained environments, so it makes sense not to // duplicate the ctype table. typedef uint16_t char_class_type; -#else +# else typedef ctype_base::mask char_class_type; -#endif +# endif static const char_class_type __regex_word = ctype_base::__regex_word; @@ -1054,30 +1059,30 @@ private: template string_type __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template string_type __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const; -#endif +# endif template string_type __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template string_type __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const; -#endif +# endif template char_class_type __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, char) const; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template char_class_type __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, wchar_t) const; -#endif +# endif static int __regex_traits_value(unsigned char __ch, int __radix); _LIBCPP_HIDE_FROM_ABI int __regex_traits_value(char __ch, int __radix) const { return __regex_traits_value(static_cast(__ch), __radix); } -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_HIDE_FROM_ABI int __regex_traits_value(wchar_t __ch, int __radix) const; -#endif +# endif }; template @@ -1136,7 +1141,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator return __d; } -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template template typename regex_traits<_CharT>::string_type @@ -1155,7 +1160,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator } return __d; } -#endif +# endif // lookup_collatename is very FreeBSD-specific @@ -1180,7 +1185,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, _ForwardIterato return __r; } -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template template typename regex_traits<_CharT>::string_type @@ -1208,7 +1213,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, _ForwardIterato } return __r; } -#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS +# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS // lookup_classname @@ -1223,7 +1228,7 @@ regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator return std::__get_classname(__s.c_str(), __icase); } -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template template typename regex_traits<_CharT>::char_class_type @@ -1239,7 +1244,7 @@ regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator } return __get_classname(__n.c_str(), __icase); } -#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS +# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS template bool regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const { @@ -1250,28 +1255,28 @@ bool regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const { inline _LIBCPP_HIDE_FROM_ABI bool __is_07(unsigned char __c) { return (__c & 0xF8u) == -#if defined(__MVS__) && !defined(__NATIVE_ASCII_F) +# if defined(__MVS__) && !defined(__NATIVE_ASCII_F) 0xF0; -#else +# else 0x30; -#endif +# endif } inline _LIBCPP_HIDE_FROM_ABI bool __is_89(unsigned char __c) { return (__c & 0xFEu) == -#if defined(__MVS__) && !defined(__NATIVE_ASCII_F) +# if defined(__MVS__) && !defined(__NATIVE_ASCII_F) 0xF8; -#else +# else 0x38; -#endif +# endif } inline _LIBCPP_HIDE_FROM_ABI unsigned char __to_lower(unsigned char __c) { -#if defined(__MVS__) && !defined(__NATIVE_ASCII_F) +# if defined(__MVS__) && !defined(__NATIVE_ASCII_F) return __c & 0xBF; -#else +# else return __c | 0x20; -#endif +# endif } template @@ -1290,12 +1295,12 @@ int regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix) return -1; } -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template inline int regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const { return __regex_traits_value(static_cast(__ct_->narrow(__ch, char_type())), __radix); } -#endif +# endif template class __node; @@ -1938,10 +1943,10 @@ public: template <> _LIBCPP_EXPORTED_FROM_ABI void __match_any_but_newline::__exec(__state&) const; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> _LIBCPP_EXPORTED_FROM_ABI void __match_any_but_newline::__exec(__state&) const; -#endif +# endif // __match_char @@ -2262,9 +2267,9 @@ template > class _LIBCPP_TEMPLATE_VIS basic_regex; typedef basic_regex regex; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS typedef basic_regex wregex; -#endif +# endif template class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(regex) @@ -2335,21 +2340,21 @@ public: : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), __end_(nullptr) { __init(__first, __last); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI basic_regex(initializer_list __il, flag_type __f = regex_constants::ECMAScript) : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), __end_(nullptr) { __init(__il.begin(), __il.end()); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG // ~basic_regex() = default; // basic_regex& operator=(const basic_regex&) = default; // basic_regex& operator=(basic_regex&&) = default; _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(const value_type* __p) { return assign(__p); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(initializer_list __il) { return assign(__il); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(const basic_string& __p) { return assign(__p); @@ -2357,9 +2362,9 @@ public: // assign: _LIBCPP_HIDE_FROM_ABI basic_regex& assign(const basic_regex& __that) { return *this = __that; } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI basic_regex& assign(basic_regex&& __that) _NOEXCEPT { return *this = std::move(__that); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI basic_regex& assign(const value_type* __p, flag_type __f = regex_constants::ECMAScript) { return assign(__p, __p + __traits_.length(__p), __f); } @@ -2396,14 +2401,14 @@ public: return assign(basic_regex(__first, __last, __f)); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI basic_regex& assign(initializer_list __il, flag_type __f = regex_constants::ECMAScript) { return assign(__il.begin(), __il.end(), __f); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG // const operations: _LIBCPP_HIDE_FROM_ABI unsigned mark_count() const { return __marked_count_; } @@ -2644,11 +2649,11 @@ private: friend class __lookahead; }; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template ::value, int> = 0> basic_regex(_ForwardIterator, _ForwardIterator, regex_constants::syntax_option_type = regex_constants::ECMAScript) -> basic_regex::value_type>; -#endif +# endif template const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::icase; @@ -4181,10 +4186,10 @@ void basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp, bo typedef sub_match csub_match; typedef sub_match ssub_match; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS typedef sub_match wcsub_match; typedef sub_match wssub_match; -#endif +# endif template class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(csub_match) @@ -4224,7 +4229,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator==(const sub_match<_BiIter>& __x, cons return __x.compare(__y) == 0; } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template using __sub_match_cat = compare_three_way_result_t::value_type>>; @@ -4232,7 +4237,7 @@ template _LIBCPP_HIDE_FROM_ABI auto operator<=>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) { return static_cast<__sub_match_cat<_BiIter>>(__x.compare(__y) <=> 0); } -#else // _LIBCPP_STD_VER >= 20 +# else // _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) { return !(__x == __y); @@ -4299,7 +4304,7 @@ operator<=(const basic_string::value_type, _ST const sub_match<_BiIter>& __y) { return !(__y < __x); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI bool @@ -4308,7 +4313,7 @@ operator==(const sub_match<_BiIter>& __x, return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0; } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template _LIBCPP_HIDE_FROM_ABI auto operator<=>(const sub_match<_BiIter>& __x, @@ -4316,7 +4321,7 @@ operator<=>(const sub_match<_BiIter>& __x, return static_cast<__sub_match_cat<_BiIter>>( __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) <=> 0); } -#else // _LIBCPP_STD_VER >= 20 +# else // _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const sub_match<_BiIter>& __x, @@ -4387,7 +4392,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(typename iterator_traits<_BiIter>::value_type const* __x, const sub_match<_BiIter>& __y) { return !(__y < __x); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI bool @@ -4395,13 +4400,13 @@ operator==(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::val return __x.compare(__y) == 0; } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template _LIBCPP_HIDE_FROM_ABI auto operator<=>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) { return static_cast<__sub_match_cat<_BiIter>>(__x.compare(__y) <=> 0); } -#else // _LIBCPP_STD_VER >= 20 +# else // _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) { @@ -4469,7 +4474,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(typename iterator_traits<_BiIter>::value_type const& __x, const sub_match<_BiIter>& __y) { return !(__y < __x); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI bool @@ -4478,14 +4483,14 @@ operator==(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::val return __x.compare(string_type(1, __y)) == 0; } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template _LIBCPP_HIDE_FROM_ABI auto operator<=>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) { using string_type = basic_string::value_type>; return static_cast<__sub_match_cat<_BiIter>>(__x.compare(string_type(1, __y)) <=> 0); } -#else // _LIBCPP_STD_VER >= 20 +# else // _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) { @@ -4516,7 +4521,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) { return !(__y < __x); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _ST>& @@ -4526,10 +4531,10 @@ operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m) { typedef match_results cmatch; typedef match_results smatch; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS typedef match_results wcmatch; typedef match_results wsmatch; -#endif +# endif template class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cmatch) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcmatch)) @@ -4559,12 +4564,12 @@ public: typedef basic_string string_type; // construct/copy/destroy: -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG match_results() : match_results(allocator_type()) {} explicit match_results(const allocator_type& __a); -#else +# else explicit match_results(const allocator_type& __a = allocator_type()); -#endif +# endif // match_results(const match_results&) = default; // match_results& operator=(const match_results&) = default; @@ -4814,13 +4819,13 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const match_results<_BidirectionalIterator return __x.__matches_ == __y.__matches_ && __x.__prefix_ == __y.__prefix_ && __x.__suffix_ == __y.__suffix_; } -#if _LIBCPP_STD_VER < 20 +# if _LIBCPP_STD_VER < 20 template inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const match_results<_BidirectionalIterator, _Allocator>& __x, const match_results<_BidirectionalIterator, _Allocator>& __y) { return !(__x == __y); } -#endif +# endif template inline _LIBCPP_HIDE_FROM_ABI void @@ -5232,13 +5237,13 @@ regex_search(const basic_string<_CharT, _ST, _SA>& __s, return __r; } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template bool regex_search(const basic_string<_Cp, _ST, _SA>&& __s, match_results::const_iterator, _Ap>&, const basic_regex<_Cp, _Tp>& __e, regex_constants::match_flag_type __flags = regex_constants::match_default) = delete; -#endif +# endif // regex_match @@ -5287,14 +5292,14 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s, return std::regex_match(__s.begin(), __s.end(), __m, __e, __flags); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template inline _LIBCPP_HIDE_FROM_ABI bool regex_match(const basic_string<_CharT, _ST, _SA>&& __s, match_results::const_iterator, _Allocator>& __m, const basic_regex<_CharT, _Traits>& __e, regex_constants::match_flag_type __flags = regex_constants::match_default) = delete; -#endif +# endif template inline _LIBCPP_HIDE_FROM_ABI bool @@ -5321,10 +5326,10 @@ class _LIBCPP_TEMPLATE_VIS regex_iterator; typedef regex_iterator cregex_iterator; typedef regex_iterator sregex_iterator; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS typedef regex_iterator wcregex_iterator; typedef regex_iterator wsregex_iterator; -#endif +# endif template class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cregex_iterator) @@ -5337,9 +5342,9 @@ public: typedef const value_type* pointer; typedef const value_type& reference; typedef forward_iterator_tag iterator_category; -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 typedef input_iterator_tag iterator_concept; -#endif +# endif private: _BidirectionalIterator __begin_; @@ -5354,20 +5359,20 @@ public: _BidirectionalIterator __b, const regex_type& __re, regex_constants::match_flag_type __m = regex_constants::match_default); -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, const regex_type&& __re, regex_constants::match_flag_type __m = regex_constants::match_default) = delete; -#endif +# endif _LIBCPP_HIDE_FROM_ABI bool operator==(const regex_iterator& __x) const; -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI bool operator==(default_sentinel_t) const { return *this == regex_iterator(); } -#endif -#if _LIBCPP_STD_VER < 20 +# endif +# if _LIBCPP_STD_VER < 20 _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_iterator& __x) const { return !(*this == __x); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __match_; } _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return std::addressof(__match_); } @@ -5451,10 +5456,10 @@ class _LIBCPP_TEMPLATE_VIS regex_token_iterator; typedef regex_token_iterator cregex_token_iterator; typedef regex_token_iterator sregex_token_iterator; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS typedef regex_token_iterator wcregex_token_iterator; typedef regex_token_iterator wsregex_token_iterator; -#endif +# endif template class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cregex_token_iterator) @@ -5468,9 +5473,9 @@ public: typedef const value_type* pointer; typedef const value_type& reference; typedef forward_iterator_tag iterator_category; -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 typedef input_iterator_tag iterator_concept; -#endif +# endif private: typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Position; @@ -5488,69 +5493,69 @@ public: const regex_type& __re, int __submatch = 0, regex_constants::match_flag_type __m = regex_constants::match_default); -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, const regex_type&& __re, int __submatch = 0, regex_constants::match_flag_type __m = regex_constants::match_default) = delete; -#endif +# endif regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, const regex_type& __re, const vector& __submatches, regex_constants::match_flag_type __m = regex_constants::match_default); -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, const regex_type&& __re, const vector& __submatches, regex_constants::match_flag_type __m = regex_constants::match_default) = delete; -#endif +# endif -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, const regex_type& __re, initializer_list __submatches, regex_constants::match_flag_type __m = regex_constants::match_default); -# if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, const regex_type&& __re, initializer_list __submatches, regex_constants::match_flag_type __m = regex_constants::match_default) = delete; -# endif -#endif // _LIBCPP_CXX03_LANG +# endif +# endif // _LIBCPP_CXX03_LANG template regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, const regex_type& __re, const int (&__submatches)[_Np], regex_constants::match_flag_type __m = regex_constants::match_default); -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, const regex_type&& __re, const int (&__submatches)[_Np], regex_constants::match_flag_type __m = regex_constants::match_default) = delete; -#endif +# endif regex_token_iterator(const regex_token_iterator&); regex_token_iterator& operator=(const regex_token_iterator&); _LIBCPP_HIDE_FROM_ABI bool operator==(const regex_token_iterator& __x) const; -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDE_FROM_ABI bool operator==(default_sentinel_t) const { return *this == regex_token_iterator(); } -#endif -#if _LIBCPP_STD_VER < 20 +# endif +# if _LIBCPP_STD_VER < 20 _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_token_iterator& __x) const { return !(*this == __x); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI const value_type& operator*() const { return *__result_; } _LIBCPP_HIDE_FROM_ABI const value_type* operator->() const { return __result_; } @@ -5612,7 +5617,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera __init(__a, __b); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_iterator( @@ -5625,7 +5630,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera __init(__a, __b); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template template @@ -5800,7 +5805,7 @@ regex_replace(const _CharT* __s, _LIBCPP_END_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_BEGIN_NAMESPACE_STD namespace pmr { template @@ -5810,27 +5815,28 @@ using match_results _LIBCPP_AVAILABILITY_PMR = using cmatch _LIBCPP_AVAILABILITY_PMR = match_results; using smatch _LIBCPP_AVAILABILITY_PMR = match_results; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using wcmatch _LIBCPP_AVAILABILITY_PMR = match_results; using wsmatch _LIBCPP_AVAILABILITY_PMR = match_results; -# endif +# endif } // namespace pmr _LIBCPP_END_NAMESPACE_STD -#endif +# endif _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_REGEX diff --git a/libcxx/include/scoped_allocator b/libcxx/include/scoped_allocator index 13e43c2f15ac891..9be65624e118e22 100644 --- a/libcxx/include/scoped_allocator +++ b/libcxx/include/scoped_allocator @@ -109,32 +109,37 @@ template */ -#include <__config> -#include <__memory/allocator_traits.h> -#include <__memory/uses_allocator_construction.h> -#include <__type_traits/common_type.h> -#include <__type_traits/enable_if.h> -#include <__type_traits/integral_constant.h> -#include <__type_traits/is_constructible.h> -#include <__type_traits/remove_reference.h> -#include <__utility/declval.h> -#include <__utility/forward.h> -#include <__utility/move.h> -#include <__utility/pair.h> -#include <__utility/piecewise_construct.h> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/scoped_allocator> +#else +# include <__config> +# include <__memory/allocator_traits.h> +# include <__memory/uses_allocator_construction.h> +# include <__type_traits/common_type.h> +# include <__type_traits/enable_if.h> +# include <__type_traits/integral_constant.h> +# include <__type_traits/is_constructible.h> +# include <__type_traits/remove_reference.h> +# include <__utility/declval.h> +# include <__utility/forward.h> +# include <__utility/move.h> +# include <__utility/pair.h> +# include <__utility/piecewise_construct.h> +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_CXX03_LANG) +# if !defined(_LIBCPP_CXX03_LANG) // scoped_allocator_adaptor @@ -404,7 +409,7 @@ public: return allocator_traits::max_size(outer_allocator()); } -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template _LIBCPP_HIDE_FROM_ABI void construct(_Type* __ptr, _Args&&... __args) { using _OM = __outermost; @@ -415,7 +420,7 @@ public: }, std::uses_allocator_construction_args<_Type>(inner_allocator(), std::forward<_Args>(__args)...)); } -# else +# else template _LIBCPP_HIDE_FROM_ABI void construct(_Tp* __p, _Args&&... __args) { __construct(__uses_alloc_ctor<_Tp, inner_allocator_type&, _Args...>(), __p, std::forward<_Args>(__args)...); @@ -462,7 +467,7 @@ public: std::forward_as_tuple(std::forward<_Up>(__x.first)), std::forward_as_tuple(std::forward<_Vp>(__x.second))); } -# endif +# endif template _LIBCPP_HIDE_FROM_ABI void destroy(_Tp* __p) { @@ -522,10 +527,10 @@ private: friend class __scoped_allocator_storage; }; -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template scoped_allocator_adaptor(_OuterAlloc, _InnerAllocs...) -> scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>; -# endif +# endif template inline _LIBCPP_HIDE_FROM_ABI bool @@ -540,7 +545,7 @@ operator==(const scoped_allocator_adaptor<_OuterA1, _InnerA0, _InnerAllocs...>& return __a.outer_allocator() == __b.outer_allocator() && __a.inner_allocator() == __b.inner_allocator(); } -# if _LIBCPP_STD_VER <= 17 +# if _LIBCPP_STD_VER <= 17 template inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a, @@ -548,26 +553,27 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const scoped_allocator_adaptor<_Out return !(__a == __b); } -# endif // _LIBCPP_STD_VER <= 17 +# endif // _LIBCPP_STD_VER <= 17 -#endif // !defined(_LIBCPP_CXX03_LANG) +# endif // !defined(_LIBCPP_CXX03_LANG) _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_SCOPED_ALLOCATOR diff --git a/libcxx/include/semaphore b/libcxx/include/semaphore index bf6317c587e2f97..a39223cba64a334 100644 --- a/libcxx/include/semaphore +++ b/libcxx/include/semaphore @@ -45,30 +45,35 @@ using binary_semaphore = counting_semaphore<1>; // since C++20 */ -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_THREADS) - -# include <__assert> -# include <__atomic/atomic_base.h> -# include <__atomic/atomic_sync.h> -# include <__atomic/memory_order.h> -# include <__chrono/time_point.h> -# include <__thread/poll_with_backoff.h> -# include <__thread/support.h> -# include <__thread/timed_backoff_policy.h> -# include -# include -# include - -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/semaphore> +#else +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_THREADS) + +# include <__assert> +# include <__atomic/atomic_base.h> +# include <__atomic/atomic_sync.h> +# include <__atomic/memory_order.h> +# include <__chrono/time_point.h> +# include <__thread/poll_with_backoff.h> +# include <__thread/support.h> +# include <__thread/timed_backoff_policy.h> +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -# include <__undef_macros> +# include <__undef_macros> -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_BEGIN_NAMESPACE_STD @@ -80,7 +85,7 @@ functions. It avoids contention against users' own use of those facilities. */ -# define _LIBCPP_SEMAPHORE_MAX (numeric_limits::max()) +# define _LIBCPP_SEMAPHORE_MAX (numeric_limits::max()) class __atomic_semaphore_base { __atomic_base __a_; @@ -173,14 +178,15 @@ using binary_semaphore = counting_semaphore<1>; _LIBCPP_END_NAMESPACE_STD -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_POP_MACROS -#endif // !defined(_LIBCPP_HAS_NO_THREADS) +# endif // !defined(_LIBCPP_HAS_NO_THREADS) -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_SEMAPHORE diff --git a/libcxx/include/set b/libcxx/include/set index 5db0db8086dec6a..cb66c2b9bf7be3d 100644 --- a/libcxx/include/set +++ b/libcxx/include/set @@ -512,57 +512,62 @@ erase_if(multiset& c, Predicate pred); // C++20 */ -#include <__algorithm/equal.h> -#include <__algorithm/lexicographical_compare.h> -#include <__algorithm/lexicographical_compare_three_way.h> -#include <__assert> -#include <__config> -#include <__functional/is_transparent.h> -#include <__functional/operations.h> -#include <__iterator/erase_if_container.h> -#include <__iterator/iterator_traits.h> -#include <__iterator/ranges_iterator_traits.h> -#include <__iterator/reverse_iterator.h> -#include <__memory/allocator.h> -#include <__memory/allocator_traits.h> -#include <__memory_resource/polymorphic_allocator.h> -#include <__node_handle> -#include <__ranges/concepts.h> -#include <__ranges/container_compatible_range.h> -#include <__ranges/from_range.h> -#include <__tree> -#include <__type_traits/container_traits.h> -#include <__type_traits/enable_if.h> -#include <__type_traits/is_allocator.h> -#include <__type_traits/is_nothrow_assignable.h> -#include <__type_traits/is_nothrow_constructible.h> -#include <__type_traits/is_same.h> -#include <__type_traits/is_swappable.h> -#include <__type_traits/type_identity.h> -#include <__utility/forward.h> -#include <__utility/move.h> -#include <__utility/pair.h> -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/set> +#else +# include <__algorithm/equal.h> +# include <__algorithm/lexicographical_compare.h> +# include <__algorithm/lexicographical_compare_three_way.h> +# include <__assert> +# include <__config> +# include <__functional/is_transparent.h> +# include <__functional/operations.h> +# include <__iterator/erase_if_container.h> +# include <__iterator/iterator_traits.h> +# include <__iterator/ranges_iterator_traits.h> +# include <__iterator/reverse_iterator.h> +# include <__memory/allocator.h> +# include <__memory/allocator_traits.h> +# include <__memory_resource/polymorphic_allocator.h> +# include <__node_handle> +# include <__ranges/concepts.h> +# include <__ranges/container_compatible_range.h> +# include <__ranges/from_range.h> +# include <__tree> +# include <__type_traits/container_traits.h> +# include <__type_traits/enable_if.h> +# include <__type_traits/is_allocator.h> +# include <__type_traits/is_nothrow_assignable.h> +# include <__type_traits/is_nothrow_constructible.h> +# include <__type_traits/is_same.h> +# include <__type_traits/is_swappable.h> +# include <__type_traits/type_identity.h> +# include <__utility/forward.h> +# include <__utility/move.h> +# include <__utility/pair.h> +# include // standard-mandated includes // [iterator.range] -#include <__iterator/access.h> -#include <__iterator/data.h> -#include <__iterator/empty.h> -#include <__iterator/reverse_access.h> -#include <__iterator/size.h> +# include <__iterator/access.h> +# include <__iterator/data.h> +# include <__iterator/empty.h> +# include <__iterator/reverse_access.h> +# include <__iterator/size.h> // [associative.set.syn] -#include -#include +# include +# include -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -602,10 +607,10 @@ public: typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 typedef __set_node_handle node_type; typedef __insert_return_type insert_return_type; -#endif +# endif template friend class _LIBCPP_TEMPLATE_VIS set; @@ -635,7 +640,7 @@ public: insert(__f, __l); } -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange _Range> _LIBCPP_HIDE_FROM_ABI set(from_range_t, @@ -645,19 +650,19 @@ public: : __tree_(__comp, __a) { insert_range(std::forward<_Range>(__range)); } -#endif +# endif -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template _LIBCPP_HIDE_FROM_ABI set(_InputIterator __f, _InputIterator __l, const allocator_type& __a) : set(__f, __l, key_compare(), __a) {} -#endif +# endif -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange _Range> _LIBCPP_HIDE_FROM_ABI set(from_range_t, _Range&& __range, const allocator_type& __a) : set(from_range, std::forward<_Range>(__range), key_compare(), __a) {} -#endif +# endif _LIBCPP_HIDE_FROM_ABI set(const set& __s) : __tree_(__s.__tree_) { insert(__s.begin(), __s.end()); } @@ -666,10 +671,10 @@ public: return *this; } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI set(set&& __s) noexcept(is_nothrow_move_constructible<__base>::value) : __tree_(std::move(__s.__tree_)) {} -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI explicit set(const allocator_type& __a) : __tree_(__a) {} @@ -677,7 +682,7 @@ public: insert(__s.begin(), __s.end()); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI set(set&& __s, const allocator_type& __a); _LIBCPP_HIDE_FROM_ABI set(initializer_list __il, const value_compare& __comp = value_compare()) @@ -690,10 +695,10 @@ public: insert(__il.begin(), __il.end()); } -# if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 _LIBCPP_HIDE_FROM_ABI set(initializer_list __il, const allocator_type& __a) : set(__il, key_compare(), __a) {} -# endif +# endif _LIBCPP_HIDE_FROM_ABI set& operator=(initializer_list __il) { __tree_.__assign_unique(__il.begin(), __il.end()); @@ -704,7 +709,7 @@ public: __tree_ = std::move(__s.__tree_); return *this; } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI ~set() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); } @@ -728,7 +733,7 @@ public: _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } // modifiers: -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template _LIBCPP_HIDE_FROM_ABI pair emplace(_Args&&... __args) { return __tree_.__emplace_unique(std::forward<_Args>(__args)...); @@ -737,7 +742,7 @@ public: _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) { return __tree_.__emplace_hint_unique(__p, std::forward<_Args>(__args)...); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI pair insert(const value_type& __v) { return __tree_.__insert_unique(__v); } _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { @@ -750,7 +755,7 @@ public: __tree_.__insert_unique(__e, *__f); } -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange _Range> _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { const_iterator __end = cend(); @@ -758,9 +763,9 @@ public: __tree_.__insert_unique(__end, std::forward(__element)); } } -#endif +# endif -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI pair insert(value_type&& __v) { return __tree_.__insert_unique(std::move(__v)); } @@ -770,14 +775,14 @@ public: } _LIBCPP_HIDE_FROM_ABI void insert(initializer_list __il) { insert(__il.begin(), __il.end()); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p); } _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_unique(__k); } _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f, __l); } _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); } -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) { _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(), "node_type with incompatible allocator passed to set::insert()"); @@ -818,7 +823,7 @@ public: __source.get_allocator() == get_allocator(), "merging container with incompatible allocator"); __tree_.__node_handle_merge_unique(__source.__tree_); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__s.__tree_); } @@ -829,7 +834,7 @@ public: // set operations: _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { return __tree_.find(__k); @@ -838,27 +843,27 @@ public: _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { return __tree_.find(__k); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { return __tree_.__count_multi(__k); } -#endif +# endif -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } template , int> = 0> _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { return find(__k) != end(); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { return __tree_.lower_bound(__k); @@ -868,11 +873,11 @@ public: _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { return __tree_.lower_bound(__k); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { return __tree_.upper_bound(__k); @@ -881,7 +886,7 @@ public: _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { return __tree_.upper_bound(__k); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI pair equal_range(const key_type& __k) { return __tree_.__equal_range_unique(__k); @@ -889,7 +894,7 @@ public: _LIBCPP_HIDE_FROM_ABI pair equal_range(const key_type& __k) const { return __tree_.__equal_range_unique(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI pair equal_range(const _K2& __k) { return __tree_.__equal_range_multi(__k); @@ -898,10 +903,10 @@ public: _LIBCPP_HIDE_FROM_ABI pair equal_range(const _K2& __k) const { return __tree_.__equal_range_multi(__k); } -#endif +# endif }; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template >, class _Allocator = allocator<__iter_value_type<_InputIterator>>, @@ -911,7 +916,7 @@ template set<__iter_value_type<_InputIterator>, _Compare, _Allocator>; -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template >, class _Allocator = allocator>, @@ -919,7 +924,7 @@ template ::value, void>> set(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> set, _Compare, _Allocator>; -# endif +# endif template , @@ -932,22 +937,20 @@ template ::value, void>, class = enable_if_t<__is_allocator<_Allocator>::value, void>> -set(_InputIterator, - _InputIterator, - _Allocator) -> set<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>; +set(_InputIterator, _InputIterator, _Allocator) + -> set<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>; -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template ::value, void>> -set(from_range_t, - _Range&&, - _Allocator) -> set, less>, _Allocator>; -# endif +set(from_range_t, _Range&&, _Allocator) + -> set, less>, _Allocator>; +# endif template ::value, void>> set(initializer_list<_Key>, _Allocator) -> set<_Key, less<_Key>, _Allocator>; -#endif +# endif -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) : __tree_(std::move(__s.__tree_), __a) { @@ -958,7 +961,7 @@ set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) : __t } } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template inline _LIBCPP_HIDE_FROM_ABI bool @@ -966,7 +969,7 @@ operator==(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); } -#if _LIBCPP_STD_VER <= 17 +# if _LIBCPP_STD_VER <= 17 template inline _LIBCPP_HIDE_FROM_ABI bool @@ -998,7 +1001,7 @@ operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, return !(__y < __x); } -#else // _LIBCPP_STD_VER <= 17 +# else // _LIBCPP_STD_VER <= 17 template _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key> @@ -1006,7 +1009,7 @@ operator<=>(const set<_Key, _Allocator>& __x, const set<_Key, _Allocator>& __y) return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); } -#endif // _LIBCPP_STD_VER <= 17 +# endif // _LIBCPP_STD_VER <= 17 // specialized algorithms: template @@ -1015,13 +1018,13 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(set<_Key, _Compare, _Allocator>& __x, set __x.swap(__y); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI typename set<_Key, _Compare, _Allocator>::size_type erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) { return std::__libcpp_erase_if_container(__c, __pred); } -#endif +# endif template struct __container_traits > { @@ -1064,9 +1067,9 @@ public: typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 typedef __set_node_handle node_type; -#endif +# endif template friend class _LIBCPP_TEMPLATE_VIS set; @@ -1091,11 +1094,11 @@ public: insert(__f, __l); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template _LIBCPP_HIDE_FROM_ABI multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a) : multiset(__f, __l, key_compare(), __a) {} -#endif +# endif template _LIBCPP_HIDE_FROM_ABI @@ -1104,7 +1107,7 @@ public: insert(__f, __l); } -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange _Range> _LIBCPP_HIDE_FROM_ABI multiset(from_range_t, @@ -1118,7 +1121,7 @@ public: template <_ContainerCompatibleRange _Range> _LIBCPP_HIDE_FROM_ABI multiset(from_range_t, _Range&& __range, const allocator_type& __a) : multiset(from_range, std::forward<_Range>(__range), key_compare(), __a) {} -#endif +# endif _LIBCPP_HIDE_FROM_ABI multiset(const multiset& __s) : __tree_(__s.__tree_.value_comp(), @@ -1131,19 +1134,19 @@ public: return *this; } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s) noexcept(is_nothrow_move_constructible<__base>::value) : __tree_(std::move(__s.__tree_)) {} _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s, const allocator_type& __a); -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI explicit multiset(const allocator_type& __a) : __tree_(__a) {} _LIBCPP_HIDE_FROM_ABI multiset(const multiset& __s, const allocator_type& __a) : __tree_(__s.__tree_.value_comp(), __a) { insert(__s.begin(), __s.end()); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI multiset(initializer_list __il, const value_compare& __comp = value_compare()) : __tree_(__comp) { insert(__il.begin(), __il.end()); @@ -1155,10 +1158,10 @@ public: insert(__il.begin(), __il.end()); } -# if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 _LIBCPP_HIDE_FROM_ABI multiset(initializer_list __il, const allocator_type& __a) : multiset(__il, key_compare(), __a) {} -# endif +# endif _LIBCPP_HIDE_FROM_ABI multiset& operator=(initializer_list __il) { __tree_.__assign_multi(__il.begin(), __il.end()); @@ -1169,7 +1172,7 @@ public: __tree_ = std::move(__s.__tree_); return *this; } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI ~multiset() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); } @@ -1193,7 +1196,7 @@ public: _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } // modifiers: -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) { return __tree_.__emplace_multi(std::forward<_Args>(__args)...); @@ -1202,7 +1205,7 @@ public: _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) { return __tree_.__emplace_hint_multi(__p, std::forward<_Args>(__args)...); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__insert_multi(__v); } _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { @@ -1215,7 +1218,7 @@ public: __tree_.__insert_multi(__e, *__f); } -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange _Range> _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { const_iterator __end = cend(); @@ -1223,9 +1226,9 @@ public: __tree_.__insert_multi(__end, std::forward(__element)); } } -#endif +# endif -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __v) { return __tree_.__insert_multi(std::move(__v)); } _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) { @@ -1233,14 +1236,14 @@ public: } _LIBCPP_HIDE_FROM_ABI void insert(initializer_list __il) { insert(__il.begin(), __il.end()); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p); } _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_multi(__k); } _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f, __l); } _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); } -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) { _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(), "node_type with incompatible allocator passed to multiset::insert()"); @@ -1281,7 +1284,7 @@ public: __source.get_allocator() == get_allocator(), "merging container with incompatible allocator"); __tree_.__node_handle_merge_multi(__source.__tree_); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI void swap(multiset& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__s.__tree_); @@ -1294,7 +1297,7 @@ public: // set operations: _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { return __tree_.find(__k); @@ -1303,27 +1306,27 @@ public: _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { return __tree_.find(__k); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { return __tree_.__count_multi(__k); } -#endif +# endif -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } template , int> = 0> _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { return find(__k) != end(); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { return __tree_.lower_bound(__k); @@ -1333,11 +1336,11 @@ public: _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { return __tree_.lower_bound(__k); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { return __tree_.upper_bound(__k); @@ -1346,7 +1349,7 @@ public: _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { return __tree_.upper_bound(__k); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI pair equal_range(const key_type& __k) { return __tree_.__equal_range_multi(__k); @@ -1354,7 +1357,7 @@ public: _LIBCPP_HIDE_FROM_ABI pair equal_range(const key_type& __k) const { return __tree_.__equal_range_multi(__k); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template , int> = 0> _LIBCPP_HIDE_FROM_ABI pair equal_range(const _K2& __k) { return __tree_.__equal_range_multi(__k); @@ -1363,10 +1366,10 @@ public: _LIBCPP_HIDE_FROM_ABI pair equal_range(const _K2& __k) const { return __tree_.__equal_range_multi(__k); } -#endif +# endif }; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template >, class _Allocator = allocator<__iter_value_type<_InputIterator>>, @@ -1376,7 +1379,7 @@ template multiset<__iter_value_type<_InputIterator>, _Compare, _Allocator>; -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template >, class _Allocator = allocator>, @@ -1384,16 +1387,15 @@ template ::value, void>> multiset(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> multiset, _Compare, _Allocator>; -# endif +# endif template , class _Allocator = allocator<_Key>, class = enable_if_t<__is_allocator<_Allocator>::value, void>, class = enable_if_t::value, void>> -multiset(initializer_list<_Key>, - _Compare = _Compare(), - _Allocator = _Allocator()) -> multiset<_Key, _Compare, _Allocator>; +multiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) + -> multiset<_Key, _Compare, _Allocator>; template multiset<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>; -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template ::value, void>> -multiset(from_range_t, - _Range&&, - _Allocator) -> multiset, less>, _Allocator>; -# endif +multiset(from_range_t, _Range&&, _Allocator) + -> multiset, less>, _Allocator>; +# endif template ::value, void>> multiset(initializer_list<_Key>, _Allocator) -> multiset<_Key, less<_Key>, _Allocator>; -#endif +# endif -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a) @@ -1425,7 +1426,7 @@ multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_t } } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template inline _LIBCPP_HIDE_FROM_ABI bool @@ -1433,7 +1434,7 @@ operator==(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); } -#if _LIBCPP_STD_VER <= 17 +# if _LIBCPP_STD_VER <= 17 template inline _LIBCPP_HIDE_FROM_ABI bool @@ -1465,7 +1466,7 @@ operator<=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, return !(__y < __x); } -#else // _LIBCPP_STD_VER <= 17 +# else // _LIBCPP_STD_VER <= 17 template _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key> @@ -1473,7 +1474,7 @@ operator<=>(const multiset<_Key, _Allocator>& __x, const multiset<_Key, _Allocat return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way); } -#endif // _LIBCPP_STD_VER <= 17 +# endif // _LIBCPP_STD_VER <= 17 template inline _LIBCPP_HIDE_FROM_ABI void @@ -1482,13 +1483,13 @@ swap(multiset<_Key, _Compare, _Allocator>& __x, multiset<_Key, _Compare, _Alloca __x.swap(__y); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI typename multiset<_Key, _Compare, _Allocator>::size_type erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred) { return std::__libcpp_erase_if_container(__c, __pred); } -#endif +# endif template struct __container_traits > { @@ -1500,7 +1501,7 @@ struct __container_traits > { _LIBCPP_END_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_BEGIN_NAMESPACE_STD namespace pmr { template > @@ -1510,17 +1511,18 @@ template > using multiset _LIBCPP_AVAILABILITY_PMR = std::multiset<_KeyT, _CompareT, polymorphic_allocator<_KeyT>>; } // namespace pmr _LIBCPP_END_NAMESPACE_STD -#endif +# endif _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_SET diff --git a/libcxx/include/shared_mutex b/libcxx/include/shared_mutex index f63bd25493878b5..44c801994d88eeb 100644 --- a/libcxx/include/shared_mutex +++ b/libcxx/include/shared_mutex @@ -122,31 +122,36 @@ template */ -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_THREADS) - -# include <__chrono/duration.h> -# include <__chrono/steady_clock.h> -# include <__chrono/time_point.h> -# include <__condition_variable/condition_variable.h> -# include <__memory/addressof.h> -# include <__mutex/mutex.h> -# include <__mutex/tag_types.h> -# include <__mutex/unique_lock.h> -# include <__system_error/system_error.h> -# include <__utility/swap.h> -# include -# include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/shared_mutex> +#else +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_THREADS) + +# include <__chrono/duration.h> +# include <__chrono/steady_clock.h> +# include <__chrono/time_point.h> +# include <__condition_variable/condition_variable.h> +# include <__memory/addressof.h> +# include <__mutex/mutex.h> +# include <__mutex/tag_types.h> +# include <__mutex/unique_lock.h> +# include <__system_error/system_error.h> +# include <__utility/swap.h> +# include +# include _LIBCPP_PUSH_MACROS -# include <__undef_macros> +# include <__undef_macros> -# if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -179,7 +184,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __shared_mutex_base { // native_handle_type native_handle(); // See 30.2.3 }; -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_mutex")) shared_mutex { __shared_mutex_base __base_; @@ -216,7 +221,7 @@ public: // typedef __shared_mutex_base::native_handle_type native_handle_type; // _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return __base::unlock_shared(); } }; -# endif +# endif class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_timed_mutex")) shared_timed_mutex { @@ -451,14 +456,15 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(shared_lock<_Mutex>& __x, shared_lock<_Mu _LIBCPP_END_NAMESPACE_STD -# endif // _LIBCPP_STD_VER >= 14 +# endif // _LIBCPP_STD_VER >= 14 _LIBCPP_POP_MACROS -#endif // !defined(_LIBCPP_HAS_NO_THREADS) +# endif // !defined(_LIBCPP_HAS_NO_THREADS) -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_SHARED_MUTEX diff --git a/libcxx/include/source_location b/libcxx/include/source_location index d16e3c46fce55e7..4f37b9250c04c00 100644 --- a/libcxx/include/source_location +++ b/libcxx/include/source_location @@ -25,17 +25,22 @@ namespace std { } */ -#include <__config> -#include -#include +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/source_location> +#else +# include <__config> +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 class source_location { // The names source_location::__impl, _M_file_name, _M_function_name, _M_line, and _M_column @@ -78,7 +83,8 @@ public: } }; -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_CXX03_LANG _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/span b/libcxx/include/span index a32f7a372e2ae1f..5e78547826e061c 100644 --- a/libcxx/include/span +++ b/libcxx/include/span @@ -144,59 +144,64 @@ template */ -#include <__assert> -#include <__concepts/convertible_to.h> -#include <__concepts/equality_comparable.h> -#include <__config> -#include <__fwd/array.h> -#include <__fwd/span.h> -#include <__iterator/bounded_iter.h> -#include <__iterator/concepts.h> -#include <__iterator/iterator_traits.h> -#include <__iterator/reverse_iterator.h> -#include <__iterator/wrap_iter.h> -#include <__memory/pointer_traits.h> -#include <__ranges/concepts.h> -#include <__ranges/data.h> -#include <__ranges/enable_borrowed_range.h> -#include <__ranges/enable_view.h> -#include <__ranges/size.h> -#include <__type_traits/integral_constant.h> -#include <__type_traits/is_array.h> -#include <__type_traits/is_const.h> -#include <__type_traits/is_convertible.h> -#include <__type_traits/is_integral.h> -#include <__type_traits/is_same.h> -#include <__type_traits/remove_const.h> -#include <__type_traits/remove_cv.h> -#include <__type_traits/remove_cvref.h> -#include <__type_traits/remove_reference.h> -#include <__type_traits/type_identity.h> -#include <__utility/forward.h> -#include // for byte -#include -#include -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/span> +#else +# include <__assert> +# include <__concepts/convertible_to.h> +# include <__concepts/equality_comparable.h> +# include <__config> +# include <__fwd/array.h> +# include <__fwd/span.h> +# include <__iterator/bounded_iter.h> +# include <__iterator/concepts.h> +# include <__iterator/iterator_traits.h> +# include <__iterator/reverse_iterator.h> +# include <__iterator/wrap_iter.h> +# include <__memory/pointer_traits.h> +# include <__ranges/concepts.h> +# include <__ranges/data.h> +# include <__ranges/enable_borrowed_range.h> +# include <__ranges/enable_view.h> +# include <__ranges/size.h> +# include <__type_traits/integral_constant.h> +# include <__type_traits/is_array.h> +# include <__type_traits/is_const.h> +# include <__type_traits/is_convertible.h> +# include <__type_traits/is_integral.h> +# include <__type_traits/is_same.h> +# include <__type_traits/remove_const.h> +# include <__type_traits/remove_cv.h> +# include <__type_traits/remove_cvref.h> +# include <__type_traits/remove_reference.h> +# include <__type_traits/type_identity.h> +# include <__utility/forward.h> +# include // for byte +# include +# include +# include // standard-mandated includes // [iterator.range] -#include <__iterator/access.h> -#include <__iterator/data.h> -#include <__iterator/empty.h> -#include <__iterator/reverse_access.h> -#include <__iterator/size.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# include <__iterator/access.h> +# include <__iterator/data.h> +# include <__iterator/empty.h> +# include <__iterator/reverse_access.h> +# include <__iterator/size.h> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template struct __is_std_span : false_type {}; @@ -236,11 +241,11 @@ public: using const_pointer = const _Tp*; using reference = _Tp&; using const_reference = const _Tp&; -# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS +# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS using iterator = __bounded_iter; -# else +# else using iterator = __wrap_iter; -# endif +# endif using reverse_iterator = std::reverse_iterator; static constexpr size_type extent = _Extent; @@ -250,14 +255,14 @@ public: requires(_Sz == 0) _LIBCPP_HIDE_FROM_ABI constexpr span() noexcept : __data_{nullptr} {} -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 _LIBCPP_HIDE_FROM_ABI constexpr explicit span(std::initializer_list __il) requires is_const_v : __data_{__il.begin()} { _LIBCPP_ASSERT_VALID_INPUT_RANGE( _Extent == __il.size(), "Size mismatch in span's constructor _Extent != __il.size()."); } -# endif +# endif constexpr span(const span&) noexcept = default; constexpr span& operator=(const span&) noexcept = default; @@ -326,8 +331,8 @@ public: } template - _LIBCPP_HIDE_FROM_ABI constexpr auto - subspan() const noexcept -> span { + _LIBCPP_HIDE_FROM_ABI constexpr auto subspan() const noexcept + -> span { static_assert(_Offset <= _Extent, "span::subspan(): Offset out of range"); static_assert(_Count == dynamic_extent || _Count <= _Extent - _Offset, "span::subspan(): Offset + Count out of range"); @@ -355,13 +360,13 @@ public: return __data_[__idx]; } -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 _LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __index) const { if (__index >= size()) std::__throw_out_of_range("span"); return __data_[__index]; } -# endif +# endif _LIBCPP_HIDE_FROM_ABI constexpr reference front() const noexcept { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on empty span"); @@ -377,18 +382,18 @@ public: // [span.iter], span iterator support _LIBCPP_HIDE_FROM_ABI constexpr iterator begin() const noexcept { -# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS +# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS return std::__make_bounded_iter(data(), data(), data() + size()); -# else +# else return iterator(data()); -# endif +# endif } _LIBCPP_HIDE_FROM_ABI constexpr iterator end() const noexcept { -# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS +# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS return std::__make_bounded_iter(data() + size(), data(), data() + size()); -# else +# else return iterator(data() + size()); -# endif +# endif } _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); } _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); } @@ -417,11 +422,11 @@ public: using const_pointer = const _Tp*; using reference = _Tp&; using const_reference = const _Tp&; -# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS +# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS using iterator = __bounded_iter; -# else +# else using iterator = __wrap_iter; -# endif +# endif using reverse_iterator = std::reverse_iterator; static constexpr size_type extent = dynamic_extent; @@ -429,11 +434,11 @@ public: // [span.cons], span constructors, copy, assignment, and destructor _LIBCPP_HIDE_FROM_ABI constexpr span() noexcept : __data_{nullptr}, __size_{0} {} -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 _LIBCPP_HIDE_FROM_ABI constexpr span(std::initializer_list __il) requires is_const_v : __data_{__il.begin()}, __size_{__il.size()} {} -# endif +# endif constexpr span(const span&) noexcept = default; constexpr span& operator=(const span&) noexcept = default; @@ -517,13 +522,13 @@ public: return __data_[__idx]; } -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 _LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __index) const { if (__index >= size()) std::__throw_out_of_range("span"); return __data_[__index]; } -# endif +# endif _LIBCPP_HIDE_FROM_ABI constexpr reference front() const noexcept { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on empty span"); @@ -539,18 +544,18 @@ public: // [span.iter], span iterator support _LIBCPP_HIDE_FROM_ABI constexpr iterator begin() const noexcept { -# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS +# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS return std::__make_bounded_iter(data(), data(), data() + size()); -# else +# else return iterator(data()); -# endif +# endif } _LIBCPP_HIDE_FROM_ABI constexpr iterator end() const noexcept { -# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS +# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS return std::__make_bounded_iter(data() + size(), data(), data() + size()); -# else +# else return iterator(data() + size()); -# endif +# endif } _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); } _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); } @@ -586,7 +591,7 @@ _LIBCPP_HIDE_FROM_ABI auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept { return __s.__as_writable_bytes(); } -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template concept __integral_constant_like = is_integral_v && !is_same_v> && @@ -602,10 +607,10 @@ inline constexpr size_t __maybe_static_ext<_Tp> = {_Tp::value}; template span(_It, _EndOrSize) -> span>, __maybe_static_ext<_EndOrSize>>; -# else +# else template span(_It, _EndOrSize) -> span>>; -# endif +# endif template span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>; @@ -619,18 +624,19 @@ span(const array<_Tp, _Sz>&) -> span; template span(_Range&&) -> span>>; -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_SPAN diff --git a/libcxx/include/sstream b/libcxx/include/sstream index df039194996d74c..4329cb3f1ccda4b 100644 --- a/libcxx/include/sstream +++ b/libcxx/include/sstream @@ -312,27 +312,32 @@ typedef basic_stringstream wstringstream; // clang-format on -#include <__config> - -#ifndef _LIBCPP_HAS_NO_LOCALIZATION - -# include <__fwd/sstream.h> -# include <__ostream/basic_ostream.h> -# include <__type_traits/is_convertible.h> -# include <__utility/swap.h> -# include -# include -# include -# include -# include -# include - -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/sstream> +#else +# include <__config> + +# ifndef _LIBCPP_HAS_NO_LOCALIZATION + +# include <__fwd/sstream.h> +# include <__ostream/basic_ostream.h> +# include <__type_traits/is_convertible.h> +# include <__utility/swap.h> +# include +# include +# include +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -# include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -375,7 +380,7 @@ public: str(__s); } -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(const allocator_type& __a) : basic_stringbuf(ios_base::in | ios_base::out, __a) {} @@ -409,9 +414,9 @@ public: : __str_(__s), __hm_(nullptr), __mode_(__wch) { __init_buf_ptrs(); } -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template requires is_convertible_v> @@ -433,37 +438,37 @@ public: __init_buf_ptrs(); } -# endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 basic_stringbuf(const basic_stringbuf&) = delete; basic_stringbuf(basic_stringbuf&& __rhs) : __mode_(__rhs.__mode_) { __move_init(std::move(__rhs)); } -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a) : basic_stringbuf(__rhs.__mode_, __a) { __move_init(std::move(__rhs)); } -# endif +# endif // [stringbuf.assign] Assign and swap: basic_stringbuf& operator=(const basic_stringbuf&) = delete; basic_stringbuf& operator=(basic_stringbuf&& __rhs); void swap(basic_stringbuf& __rhs) -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 noexcept(allocator_traits::propagate_on_container_swap::value || allocator_traits::is_always_equal::value) -# endif +# endif ; // [stringbuf.members] Member functions: -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const noexcept { return __str_.get_allocator(); } -# endif +# endif -# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) +# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) string_type str() const; -# else +# else _LIBCPP_HIDE_FROM_ABI string_type str() const& { return str(__str_.get_allocator()); } _LIBCPP_HIDE_FROM_ABI string_type str() && { @@ -477,9 +482,9 @@ public: __init_buf_ptrs(); return __result; } -# endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) +# endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template requires __is_allocator<_SAlloc>::value _LIBCPP_HIDE_FROM_ABI basic_string str(const _SAlloc& __sa) const { @@ -487,14 +492,14 @@ public: } _LIBCPP_HIDE_FROM_ABI basic_string_view view() const noexcept; -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 void str(const string_type& __s) { __str_ = __s; __init_buf_ptrs(); } -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template requires(!is_same_v<_SAlloc, allocator_type>) _LIBCPP_HIDE_FROM_ABI void str(const basic_string& __s) { @@ -506,9 +511,9 @@ public: __str_ = std::move(__s); __init_buf_ptrs(); } -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template requires is_convertible_v> @@ -518,7 +523,7 @@ public: __init_buf_ptrs(); } -# endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 protected: // [stringbuf.virtuals] Overridden virtual functions: @@ -614,10 +619,10 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs) template void basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs) -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 noexcept(allocator_traits<_Allocator>::propagate_on_container_swap::value || allocator_traits<_Allocator>::is_always_equal::value) -# endif +# endif { char_type* __p = const_cast(__rhs.__str_.data()); ptrdiff_t __rbinp = -1; @@ -687,14 +692,14 @@ void basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs) template inline _LIBCPP_HIDE_FROM_ABI void swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, basic_stringbuf<_CharT, _Traits, _Allocator>& __y) -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 noexcept(noexcept(__x.swap(__y))) -# endif +# endif { __x.swap(__y); } -# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) +# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) template basic_string<_CharT, _Traits, _Allocator> basic_stringbuf<_CharT, _Traits, _Allocator>::str() const { if (__mode_ & ios_base::out) { @@ -705,7 +710,7 @@ basic_string<_CharT, _Traits, _Allocator> basic_stringbuf<_CharT, _Traits, _Allo return string_type(this->eback(), this->egptr(), __str_.get_allocator()); return string_type(__str_.get_allocator()); } -# endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) +# endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) template _LIBCPP_HIDE_FROM_ABI void basic_stringbuf<_CharT, _Traits, _Allocator>::__init_buf_ptrs() { @@ -731,7 +736,7 @@ _LIBCPP_HIDE_FROM_ABI void basic_stringbuf<_CharT, _Traits, _Allocator>::__init_ } } -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template _LIBCPP_HIDE_FROM_ABI basic_string_view<_CharT, _Traits> basic_stringbuf<_CharT, _Traits, _Allocator>::view() const noexcept { @@ -743,7 +748,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::view() const noexcept { return basic_string_view<_CharT, _Traits>(this->eback(), this->egptr()); return basic_string_view<_CharT, _Traits>(); } -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 template typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type @@ -786,9 +791,9 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) { if (this->pptr() == this->epptr()) { if (!(__mode_ & ios_base::out)) return traits_type::eof(); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS ptrdiff_t __nout = this->pptr() - this->pbase(); ptrdiff_t __hm = __hm_ - this->pbase(); __str_.push_back(char_type()); @@ -797,11 +802,11 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) { this->setp(__p, __p + __str_.size()); this->__pbump(__nout); __hm_ = this->pbase() + __hm; -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { return traits_type::eof(); } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } __hm_ = std::max(this->pptr() + 1, __hm_); if (__mode_ & ios_base::in) { @@ -886,7 +891,7 @@ public: _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const string_type& __s, ios_base::openmode __wch = ios_base::in) : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in) {} -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI basic_istringstream(ios_base::openmode __wch, const _Allocator& __a) : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::in, __a) {} @@ -906,9 +911,9 @@ public: _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s, ios_base::openmode __wch = ios_base::in) : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in) {} -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template requires is_convertible_v> @@ -925,7 +930,7 @@ public: _LIBCPP_HIDE_FROM_ABI basic_istringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a) : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::in, __a) {} -# endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 basic_istringstream(const basic_istringstream&) = delete; _LIBCPP_HIDE_FROM_ABI basic_istringstream(basic_istringstream&& __rhs) @@ -950,15 +955,15 @@ public: return const_cast*>(std::addressof(__sb_)); } -# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) +# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } -# else +# else _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); } _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); } -# endif +# endif -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template requires __is_allocator<_SAlloc>::value _LIBCPP_HIDE_FROM_ABI basic_string str(const _SAlloc& __sa) const { @@ -966,26 +971,26 @@ public: } _LIBCPP_HIDE_FROM_ABI basic_string_view view() const noexcept { return __sb_.view(); } -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); } -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template _LIBCPP_HIDE_FROM_ABI void str(const basic_string& __s) { __sb_.str(__s); } _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); } -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template requires is_convertible_v> _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) { rdbuf()->str(__t); } -# endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 }; template @@ -1022,7 +1027,7 @@ public: _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(const string_type& __s, ios_base::openmode __wch = ios_base::out) : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out) {} -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI basic_ostringstream(ios_base::openmode __wch, const _Allocator& __a) : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::out, __a) {} @@ -1043,9 +1048,9 @@ public: _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s, ios_base::openmode __wch = ios_base::out) : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out) {} -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template requires is_convertible_v> @@ -1062,7 +1067,7 @@ public: _LIBCPP_HIDE_FROM_ABI basic_ostringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a) : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::out, __a) {} -# endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 basic_ostringstream(const basic_ostringstream&) = delete; _LIBCPP_HIDE_FROM_ABI basic_ostringstream(basic_ostringstream&& __rhs) @@ -1088,15 +1093,15 @@ public: return const_cast*>(std::addressof(__sb_)); } -# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) +# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } -# else +# else _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); } _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); } -# endif +# endif -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template requires __is_allocator<_SAlloc>::value _LIBCPP_HIDE_FROM_ABI basic_string str(const _SAlloc& __sa) const { @@ -1104,26 +1109,26 @@ public: } _LIBCPP_HIDE_FROM_ABI basic_string_view view() const noexcept { return __sb_.view(); } -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); } -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template _LIBCPP_HIDE_FROM_ABI void str(const basic_string& __s) { __sb_.str(__s); } _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); } -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template requires is_convertible_v> _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) { rdbuf()->str(__t); } -# endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 }; template @@ -1161,7 +1166,7 @@ public: ios_base::openmode __wch = ios_base::in | ios_base::out) : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch) {} -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI basic_stringstream(ios_base::openmode __wch, const _Allocator& __a) : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch, __a) {} @@ -1183,9 +1188,9 @@ public: _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s, ios_base::openmode __wch = ios_base::out | ios_base::in) : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch) {} -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template requires is_convertible_v> @@ -1203,7 +1208,7 @@ public: _LIBCPP_HIDE_FROM_ABI basic_stringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a) : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which, __a) {} -# endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 basic_stringstream(const basic_stringstream&) = delete; _LIBCPP_HIDE_FROM_ABI basic_stringstream(basic_stringstream&& __rhs) @@ -1228,15 +1233,15 @@ public: return const_cast*>(std::addressof(__sb_)); } -# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) +# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } -# else +# else _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); } _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); } -# endif +# endif -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template requires __is_allocator<_SAlloc>::value _LIBCPP_HIDE_FROM_ABI basic_string str(const _SAlloc& __sa) const { @@ -1244,26 +1249,26 @@ public: } _LIBCPP_HIDE_FROM_ABI basic_string_view view() const noexcept { return __sb_.view(); } -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); } -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template _LIBCPP_HIDE_FROM_ABI void str(const basic_string& __s) { __sb_.str(__s); } _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); } -# endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -# if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template requires is_convertible_v> _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) { rdbuf()->str(__t); } -# endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 }; template @@ -1272,22 +1277,23 @@ swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, basic_stringstream<_C __x.swap(__y); } -# if _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 +# if _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringbuf; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringstream; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istringstream; -# endif +# endif _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#endif // !_LIBCPP_HAS_NO_LOCALIZATION +# endif // !_LIBCPP_HAS_NO_LOCALIZATION -#if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) -# include -# include -#endif +# if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_SSTREAM diff --git a/libcxx/include/stack b/libcxx/include/stack index f75769f8a42062b..b8caf05f66ff0a1 100644 --- a/libcxx/include/stack +++ b/libcxx/include/stack @@ -113,33 +113,38 @@ template */ -#include <__algorithm/ranges_copy.h> -#include <__config> -#include <__fwd/stack.h> -#include <__iterator/back_insert_iterator.h> -#include <__iterator/iterator_traits.h> -#include <__memory/uses_allocator.h> -#include <__ranges/access.h> -#include <__ranges/concepts.h> -#include <__ranges/container_compatible_range.h> -#include <__ranges/from_range.h> -#include <__type_traits/is_same.h> -#include <__utility/forward.h> -#include -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/stack> +#else +# include <__algorithm/ranges_copy.h> +# include <__config> +# include <__fwd/stack.h> +# include <__iterator/back_insert_iterator.h> +# include <__iterator/iterator_traits.h> +# include <__memory/uses_allocator.h> +# include <__ranges/access.h> +# include <__ranges/concepts.h> +# include <__ranges/container_compatible_range.h> +# include <__ranges/from_range.h> +# include <__type_traits/is_same.h> +# include <__utility/forward.h> +# include +# include // standard-mandated includes // [stack.syn] -#include -#include +# include +# include -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -172,7 +177,7 @@ public: return *this; } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI stack(stack&& __q) noexcept(is_nothrow_move_constructible::value) : c(std::move(__q.c)) {} @@ -182,7 +187,7 @@ public: } _LIBCPP_HIDE_FROM_ABI explicit stack(container_type&& __c) : c(std::move(__c)) {} -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI explicit stack(const container_type& __c) : c(__c) {} @@ -198,7 +203,7 @@ public: _LIBCPP_HIDE_FROM_ABI stack(const stack& __s, const _Alloc& __a, __enable_if_t::value>* = 0) : c(__s.c, __a) {} -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template _LIBCPP_HIDE_FROM_ABI stack(container_type&& __c, const _Alloc& __a, __enable_if_t::value>* = 0) @@ -207,9 +212,9 @@ public: _LIBCPP_HIDE_FROM_ABI stack(stack&& __s, const _Alloc& __a, __enable_if_t::value>* = 0) : c(std::move(__s.c), __a) {} -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI stack(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} @@ -229,7 +234,7 @@ public: _LIBCPP_HIDE_FROM_ABI stack(from_range_t, _Range&& __range, const _Alloc& __alloc) : c(from_range, std::forward<_Range>(__range), __alloc) {} -#endif +# endif [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } @@ -237,10 +242,10 @@ public: _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.back(); } _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v) { c.push_back(std::move(__v)); } -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) { if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) { @@ -249,22 +254,22 @@ public: ranges::copy(std::forward<_Range>(__range), std::back_inserter(c)); } } -# endif +# endif template _LIBCPP_HIDE_FROM_ABI -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 decltype(auto) emplace(_Args&&... __args) { return c.emplace_back(std::forward<_Args>(__args)...); } -# else +# else void emplace(_Args&&... __args) { c.emplace_back(std::forward<_Args>(__args)...); } -# endif -#endif // _LIBCPP_CXX03_LANG +# endif +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_back(); } @@ -282,7 +287,7 @@ public: friend bool operator<(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y); }; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template ::value> > stack(_Container) -> stack; @@ -291,9 +296,9 @@ template ::value>, class = enable_if_t::value> > stack(_Container, _Alloc) -> stack; -#endif +# endif -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template ::value, int> = 0> stack(_InputIterator, _InputIterator) -> stack<__iter_value_type<_InputIterator>>; @@ -304,16 +309,14 @@ template ::value, int> = 0, __enable_if_t<__is_allocator<_Alloc>::value, int> = 0> -stack(_InputIterator, - _InputIterator, - _Alloc) -> stack<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; +stack(_InputIterator, _InputIterator, _Alloc) + -> stack<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; template ::value, int> = 0> -stack(from_range_t, - _Range&&, - _Alloc) -> stack, deque, _Alloc>>; +stack(from_range_t, _Range&&, _Alloc) + -> stack, deque, _Alloc>>; -#endif +# endif template inline _LIBCPP_HIDE_FROM_ABI bool operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) { @@ -345,7 +348,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const stack<_Tp, _Container>& __x, return !(__y < __x); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template _LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container> @@ -354,7 +357,7 @@ operator<=>(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y return __x.__get_container() <=> __y.__get_container(); } -#endif +# endif template , int> = 0> inline _LIBCPP_HIDE_FROM_ABI void swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y) @@ -370,10 +373,11 @@ _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_STACK diff --git a/libcxx/include/stdatomic.h b/libcxx/include/stdatomic.h index 2f25b057df0874a..989e5794eaadc29 100644 --- a/libcxx/include/stdatomic.h +++ b/libcxx/include/stdatomic.h @@ -117,22 +117,25 @@ using std::atomic_signal_fence // see below */ -#include <__config> +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/stdatomic.h> +#else +# include <__config> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif -#if defined(__cplusplus) +# if defined(__cplusplus) && _LIBCPP_STD_VER >= 23 -# include -# include +# include +# include -# ifdef _Atomic -# undef _Atomic -# endif +# ifdef _Atomic +# undef _Atomic +# endif -# define _Atomic(_Tp) ::std::atomic<_Tp> +# define _Atomic(_Tp) ::std::atomic<_Tp> using std::memory_order _LIBCPP_USING_IF_EXISTS; using std::memory_order_relaxed _LIBCPP_USING_IF_EXISTS; @@ -156,14 +159,14 @@ using std::atomic_long _LIBCPP_USING_IF_EXISTS; using std::atomic_ulong _LIBCPP_USING_IF_EXISTS; using std::atomic_llong _LIBCPP_USING_IF_EXISTS; using std::atomic_ullong _LIBCPP_USING_IF_EXISTS; -# if _LIBCPP_HAS_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T using std::atomic_char8_t _LIBCPP_USING_IF_EXISTS; -# endif +# endif using std::atomic_char16_t _LIBCPP_USING_IF_EXISTS; using std::atomic_char32_t _LIBCPP_USING_IF_EXISTS; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using std::atomic_wchar_t _LIBCPP_USING_IF_EXISTS; -# endif +# endif using std::atomic_int8_t _LIBCPP_USING_IF_EXISTS; using std::atomic_uint8_t _LIBCPP_USING_IF_EXISTS; @@ -228,12 +231,13 @@ using std::atomic_store_explicit _LIBCPP_USING_IF_EXISTS; using std::atomic_signal_fence _LIBCPP_USING_IF_EXISTS; using std::atomic_thread_fence _LIBCPP_USING_IF_EXISTS; -#else +# else -# if __has_include_next() -# include_next -# endif +# if __has_include_next() +# include_next +# endif -#endif // defined(__cplusplus) +# endif // defined(__cplusplus) +#endif #endif // _LIBCPP_STDATOMIC_H diff --git a/libcxx/include/stdbool.h b/libcxx/include/stdbool.h index e74d91f45945925..1a63dda85e84ea2 100644 --- a/libcxx/include/stdbool.h +++ b/libcxx/include/stdbool.h @@ -19,22 +19,28 @@ */ -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if __has_include_next() -# include_next -#endif - -#ifdef __cplusplus -# undef bool -# undef true -# undef false -# undef __bool_true_false_are_defined -# define __bool_true_false_are_defined 1 -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/stdbool.h> +#else +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if __has_include_next() +# include_next +# endif + +# ifdef __cplusplus +# undef bool +# undef true +# undef false +# undef __bool_true_false_are_defined +# define __bool_true_false_are_defined 1 +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_STDBOOL_H diff --git a/libcxx/include/stddef.h b/libcxx/include/stddef.h index 1583e78e3739ba4..2bdceeaad917bdd 100644 --- a/libcxx/include/stddef.h +++ b/libcxx/include/stddef.h @@ -24,21 +24,27 @@ */ -#include <__config> +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/stddef.h> +#else +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif // Note: This include is outside of header guards because we sometimes get included multiple times // with different defines and the underlying will know how to deal with that. -#include_next +# include_next -#ifndef _LIBCPP_STDDEF_H -# define _LIBCPP_STDDEF_H +# ifndef _LIBCPP_STDDEF_H +# define _LIBCPP_STDDEF_H -# ifdef __cplusplus +# ifdef __cplusplus typedef decltype(nullptr) nullptr_t; -# endif +# endif +# endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_STDDEF_H diff --git a/libcxx/include/stdexcept b/libcxx/include/stdexcept index daa7b501a86999b..2ae8a0ad74af1cf 100644 --- a/libcxx/include/stdexcept +++ b/libcxx/include/stdexcept @@ -41,18 +41,23 @@ public: */ -#include <__config> -#include <__exception/exception.h> -#include <__fwd/string.h> -#include <__verbose_abort> +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/stdexcept> +#else +# include <__config> +# include <__exception/exception.h> +# include <__fwd/string.h> +# include <__verbose_abort> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD -#ifndef _LIBCPP_ABI_VCRUNTIME +# ifndef _LIBCPP_ABI_VCRUNTIME class _LIBCPP_HIDDEN __libcpp_refstring { const char* __imp_; @@ -66,7 +71,7 @@ public: _LIBCPP_HIDE_FROM_ABI const char* c_str() const _NOEXCEPT { return __imp_; } }; -#endif // !_LIBCPP_ABI_VCRUNTIME +# endif // !_LIBCPP_ABI_VCRUNTIME _LIBCPP_END_NAMESPACE_STD @@ -74,7 +79,7 @@ namespace std // purposefully not using versioning namespace { class _LIBCPP_EXPORTED_FROM_ABI logic_error : public exception { -#ifndef _LIBCPP_ABI_VCRUNTIME +# ifndef _LIBCPP_ABI_VCRUNTIME private: std::__libcpp_refstring __imp_; @@ -89,16 +94,16 @@ public: ~logic_error() _NOEXCEPT override; const char* what() const _NOEXCEPT override; -#else +# else public: explicit logic_error(const std::string&); // Symbol uses versioned std::string _LIBCPP_HIDE_FROM_ABI explicit logic_error(const char* __s) : exception(__s) {} -#endif +# endif }; class _LIBCPP_EXPORTED_FROM_ABI runtime_error : public exception { -#ifndef _LIBCPP_ABI_VCRUNTIME +# ifndef _LIBCPP_ABI_VCRUNTIME private: std::__libcpp_refstring __imp_; @@ -113,12 +118,12 @@ public: ~runtime_error() _NOEXCEPT override; const char* what() const _NOEXCEPT override; -#else +# else public: explicit runtime_error(const std::string&); // Symbol uses versioned std::string _LIBCPP_HIDE_FROM_ABI explicit runtime_error(const char* __s) : exception(__s) {} -#endif // _LIBCPP_ABI_VCRUNTIME +# endif // _LIBCPP_ABI_VCRUNTIME }; class _LIBCPP_EXPORTED_FROM_ABI domain_error : public logic_error { @@ -126,11 +131,11 @@ public: _LIBCPP_HIDE_FROM_ABI explicit domain_error(const string& __s) : logic_error(__s) {} _LIBCPP_HIDE_FROM_ABI explicit domain_error(const char* __s) : logic_error(__s) {} -#ifndef _LIBCPP_ABI_VCRUNTIME +# ifndef _LIBCPP_ABI_VCRUNTIME _LIBCPP_HIDE_FROM_ABI domain_error(const domain_error&) _NOEXCEPT = default; _LIBCPP_HIDE_FROM_ABI domain_error& operator=(const domain_error&) _NOEXCEPT = default; ~domain_error() _NOEXCEPT override; -#endif +# endif }; class _LIBCPP_EXPORTED_FROM_ABI invalid_argument : public logic_error { @@ -138,22 +143,22 @@ public: _LIBCPP_HIDE_FROM_ABI explicit invalid_argument(const string& __s) : logic_error(__s) {} _LIBCPP_HIDE_FROM_ABI explicit invalid_argument(const char* __s) : logic_error(__s) {} -#ifndef _LIBCPP_ABI_VCRUNTIME +# ifndef _LIBCPP_ABI_VCRUNTIME _LIBCPP_HIDE_FROM_ABI invalid_argument(const invalid_argument&) _NOEXCEPT = default; _LIBCPP_HIDE_FROM_ABI invalid_argument& operator=(const invalid_argument&) _NOEXCEPT = default; ~invalid_argument() _NOEXCEPT override; -#endif +# endif }; class _LIBCPP_EXPORTED_FROM_ABI length_error : public logic_error { public: _LIBCPP_HIDE_FROM_ABI explicit length_error(const string& __s) : logic_error(__s) {} _LIBCPP_HIDE_FROM_ABI explicit length_error(const char* __s) : logic_error(__s) {} -#ifndef _LIBCPP_ABI_VCRUNTIME +# ifndef _LIBCPP_ABI_VCRUNTIME _LIBCPP_HIDE_FROM_ABI length_error(const length_error&) _NOEXCEPT = default; _LIBCPP_HIDE_FROM_ABI length_error& operator=(const length_error&) _NOEXCEPT = default; ~length_error() _NOEXCEPT override; -#endif +# endif }; class _LIBCPP_EXPORTED_FROM_ABI out_of_range : public logic_error { @@ -161,11 +166,11 @@ public: _LIBCPP_HIDE_FROM_ABI explicit out_of_range(const string& __s) : logic_error(__s) {} _LIBCPP_HIDE_FROM_ABI explicit out_of_range(const char* __s) : logic_error(__s) {} -#ifndef _LIBCPP_ABI_VCRUNTIME +# ifndef _LIBCPP_ABI_VCRUNTIME _LIBCPP_HIDE_FROM_ABI out_of_range(const out_of_range&) _NOEXCEPT = default; _LIBCPP_HIDE_FROM_ABI out_of_range& operator=(const out_of_range&) _NOEXCEPT = default; ~out_of_range() _NOEXCEPT override; -#endif +# endif }; class _LIBCPP_EXPORTED_FROM_ABI range_error : public runtime_error { @@ -173,11 +178,11 @@ public: _LIBCPP_HIDE_FROM_ABI explicit range_error(const string& __s) : runtime_error(__s) {} _LIBCPP_HIDE_FROM_ABI explicit range_error(const char* __s) : runtime_error(__s) {} -#ifndef _LIBCPP_ABI_VCRUNTIME +# ifndef _LIBCPP_ABI_VCRUNTIME _LIBCPP_HIDE_FROM_ABI range_error(const range_error&) _NOEXCEPT = default; _LIBCPP_HIDE_FROM_ABI range_error& operator=(const range_error&) _NOEXCEPT = default; ~range_error() _NOEXCEPT override; -#endif +# endif }; class _LIBCPP_EXPORTED_FROM_ABI overflow_error : public runtime_error { @@ -185,11 +190,11 @@ public: _LIBCPP_HIDE_FROM_ABI explicit overflow_error(const string& __s) : runtime_error(__s) {} _LIBCPP_HIDE_FROM_ABI explicit overflow_error(const char* __s) : runtime_error(__s) {} -#ifndef _LIBCPP_ABI_VCRUNTIME +# ifndef _LIBCPP_ABI_VCRUNTIME _LIBCPP_HIDE_FROM_ABI overflow_error(const overflow_error&) _NOEXCEPT = default; _LIBCPP_HIDE_FROM_ABI overflow_error& operator=(const overflow_error&) _NOEXCEPT = default; ~overflow_error() _NOEXCEPT override; -#endif +# endif }; class _LIBCPP_EXPORTED_FROM_ABI underflow_error : public runtime_error { @@ -197,11 +202,11 @@ public: _LIBCPP_HIDE_FROM_ABI explicit underflow_error(const string& __s) : runtime_error(__s) {} _LIBCPP_HIDE_FROM_ABI explicit underflow_error(const char* __s) : runtime_error(__s) {} -#ifndef _LIBCPP_ABI_VCRUNTIME +# ifndef _LIBCPP_ABI_VCRUNTIME _LIBCPP_HIDE_FROM_ABI underflow_error(const underflow_error&) _NOEXCEPT = default; _LIBCPP_HIDE_FROM_ABI underflow_error& operator=(const underflow_error&) _NOEXCEPT = default; ~underflow_error() _NOEXCEPT override; -#endif +# endif }; } // namespace std @@ -212,75 +217,76 @@ _LIBCPP_BEGIN_NAMESPACE_STD [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_runtime_error(const char*); [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_logic_error(const char* __msg) { -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw logic_error(__msg); -#else +# else _LIBCPP_VERBOSE_ABORT("logic_error was thrown in -fno-exceptions mode with message \"%s\"", __msg); -#endif +# endif } [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_domain_error(const char* __msg) { -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw domain_error(__msg); -#else +# else _LIBCPP_VERBOSE_ABORT("domain_error was thrown in -fno-exceptions mode with message \"%s\"", __msg); -#endif +# endif } [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_invalid_argument(const char* __msg) { -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw invalid_argument(__msg); -#else +# else _LIBCPP_VERBOSE_ABORT("invalid_argument was thrown in -fno-exceptions mode with message \"%s\"", __msg); -#endif +# endif } [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_length_error(const char* __msg) { -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw length_error(__msg); -#else +# else _LIBCPP_VERBOSE_ABORT("length_error was thrown in -fno-exceptions mode with message \"%s\"", __msg); -#endif +# endif } [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range(const char* __msg) { -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw out_of_range(__msg); -#else +# else _LIBCPP_VERBOSE_ABORT("out_of_range was thrown in -fno-exceptions mode with message \"%s\"", __msg); -#endif +# endif } [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_range_error(const char* __msg) { -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw range_error(__msg); -#else +# else _LIBCPP_VERBOSE_ABORT("range_error was thrown in -fno-exceptions mode with message \"%s\"", __msg); -#endif +# endif } [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_overflow_error(const char* __msg) { -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw overflow_error(__msg); -#else +# else _LIBCPP_VERBOSE_ABORT("overflow_error was thrown in -fno-exceptions mode with message \"%s\"", __msg); -#endif +# endif } [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_underflow_error(const char* __msg) { -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw underflow_error(__msg); -#else +# else _LIBCPP_VERBOSE_ABORT("underflow_error was thrown in -fno-exceptions mode with message \"%s\"", __msg); -#endif +# endif } _LIBCPP_END_NAMESPACE_STD -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_STDEXCEPT diff --git a/libcxx/include/stdint.h b/libcxx/include/stdint.h new file mode 100644 index 000000000000000..4b9867c368bc7f2 --- /dev/null +++ b/libcxx/include/stdint.h @@ -0,0 +1,131 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_STDINT_H +// AIX system headers need stdint.h to be re-enterable while _STD_TYPES_T +// is defined until an inclusion of it without _STD_TYPES_T occurs, in which +// case the header guard macro is defined. +#if !defined(_AIX) || !defined(_STD_TYPES_T) +# define _LIBCPP_STDINT_H +#endif // _STD_TYPES_T + +/* + stdint.h synopsis + +Macros: + + INT8_MIN + INT16_MIN + INT32_MIN + INT64_MIN + + INT8_MAX + INT16_MAX + INT32_MAX + INT64_MAX + + UINT8_MAX + UINT16_MAX + UINT32_MAX + UINT64_MAX + + INT_LEAST8_MIN + INT_LEAST16_MIN + INT_LEAST32_MIN + INT_LEAST64_MIN + + INT_LEAST8_MAX + INT_LEAST16_MAX + INT_LEAST32_MAX + INT_LEAST64_MAX + + UINT_LEAST8_MAX + UINT_LEAST16_MAX + UINT_LEAST32_MAX + UINT_LEAST64_MAX + + INT_FAST8_MIN + INT_FAST16_MIN + INT_FAST32_MIN + INT_FAST64_MIN + + INT_FAST8_MAX + INT_FAST16_MAX + INT_FAST32_MAX + INT_FAST64_MAX + + UINT_FAST8_MAX + UINT_FAST16_MAX + UINT_FAST32_MAX + UINT_FAST64_MAX + + INTPTR_MIN + INTPTR_MAX + UINTPTR_MAX + + INTMAX_MIN + INTMAX_MAX + + UINTMAX_MAX + + PTRDIFF_MIN + PTRDIFF_MAX + + SIG_ATOMIC_MIN + SIG_ATOMIC_MAX + + SIZE_MAX + + WCHAR_MIN + WCHAR_MAX + + WINT_MIN + WINT_MAX + + INT8_C(value) + INT16_C(value) + INT32_C(value) + INT64_C(value) + + UINT8_C(value) + UINT16_C(value) + UINT32_C(value) + UINT64_C(value) + + INTMAX_C(value) + UINTMAX_C(value) + +*/ + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/stdint.h> +#else +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed + for C++11 unless __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS + are defined +*/ +# if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS) +# define __STDC_LIMIT_MACROS +# endif +# if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS) +# define __STDC_CONSTANT_MACROS +# endif + +# if __has_include_next() +# include_next +# endif +#endif // _LIBCPP_CXX03_LANG + +#endif // _LIBCPP_STDINT_H diff --git a/libcxx/include/stdio.h b/libcxx/include/stdio.h index 3aa559393f18530..d26f335dffd468d 100644 --- a/libcxx/include/stdio.h +++ b/libcxx/include/stdio.h @@ -98,26 +98,32 @@ int ferror(FILE* stream); void perror(const char* s); */ -# include <__config> +# include <__configuration/cxx03.h> -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +# if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/stdio.h> +# else +# include <__config> -# if __has_include_next() -# include_next -# endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif -# ifdef __cplusplus +# if __has_include_next() +# include_next +# endif -# undef getc -# undef putc -# undef clearerr -# undef feof -# undef ferror -# undef putchar -# undef getchar +# ifdef __cplusplus -# endif +# undef getc +# undef putc +# undef clearerr +# undef feof +# undef ferror +# undef putchar +# undef getchar + +# endif +# endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_STDIO_H diff --git a/libcxx/include/stdlib.h b/libcxx/include/stdlib.h index 358b10c0392a522..c5d2ce7032e1252 100644 --- a/libcxx/include/stdlib.h +++ b/libcxx/include/stdlib.h @@ -84,35 +84,40 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 */ -# include <__config> +# include <__configuration/cxx03.h> -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +# if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/stdlib.h> +# else +# include <__config> -# if __has_include_next() -# include_next -# endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif -# ifdef __cplusplus +# if __has_include_next() +# include_next +# endif + +# ifdef __cplusplus extern "C++" { // abs -# ifdef abs -# undef abs -# endif -# ifdef labs -# undef labs -# endif -# ifdef llabs -# undef llabs -# endif +# ifdef abs +# undef abs +# endif +# ifdef labs +# undef labs +# endif +# ifdef llabs +# undef llabs +# endif // MSVCRT already has the correct prototype in if __cplusplus is defined -# if !defined(_LIBCPP_MSVCRT) +# if !defined(_LIBCPP_MSVCRT) [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); } [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); } -# endif // !defined(_LIBCPP_MSVCRT) +# endif // !defined(_LIBCPP_MSVCRT) [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float abs(float __lcpp_x) _NOEXCEPT { return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h @@ -128,24 +133,25 @@ extern "C++" { // div -# ifdef div -# undef div -# endif -# ifdef ldiv -# undef ldiv -# endif -# ifdef lldiv -# undef lldiv -# endif +# ifdef div +# undef div +# endif +# ifdef ldiv +# undef ldiv +# endif +# ifdef lldiv +# undef lldiv +# endif // MSVCRT already has the correct prototype in if __cplusplus is defined -# if !defined(_LIBCPP_MSVCRT) +# if !defined(_LIBCPP_MSVCRT) inline _LIBCPP_HIDE_FROM_ABI ldiv_t div(long __x, long __y) _NOEXCEPT { return ::ldiv(__x, __y); } -# if !(defined(__FreeBSD__) && !defined(__LONG_LONG_SUPPORTED)) +# if !(defined(__FreeBSD__) && !defined(__LONG_LONG_SUPPORTED)) inline _LIBCPP_HIDE_FROM_ABI lldiv_t div(long long __x, long long __y) _NOEXCEPT { return ::lldiv(__x, __y); } -# endif -# endif // _LIBCPP_MSVCRT +# endif +# endif // _LIBCPP_MSVCRT } // extern "C++" -# endif // __cplusplus +# endif // __cplusplus +# endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_STDLIB_H diff --git a/libcxx/include/stop_token b/libcxx/include/stop_token index d4e651d9541f4ed..05a9e36a9c716e7 100644 --- a/libcxx/include/stop_token +++ b/libcxx/include/stop_token @@ -31,26 +31,32 @@ namespace std { */ -#include <__config> +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_THREADS) +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/stop_token> +#else +# include <__config> -# if _LIBCPP_STD_VER >= 20 -# include <__stop_token/stop_callback.h> -# include <__stop_token/stop_source.h> -# include <__stop_token/stop_token.h> -# endif +# if !defined(_LIBCPP_HAS_NO_THREADS) -# include +# if _LIBCPP_STD_VER >= 20 +# include <__stop_token/stop_callback.h> +# include <__stop_token/stop_source.h> +# include <__stop_token/stop_token.h> +# endif -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +# include -#endif // !defined(_LIBCPP_HAS_NO_THREADS) +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -#endif +# endif // !defined(_LIBCPP_HAS_NO_THREADS) + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_STOP_TOKEN diff --git a/libcxx/include/streambuf b/libcxx/include/streambuf index 906340ef03335e4..c946944af315e14 100644 --- a/libcxx/include/streambuf +++ b/libcxx/include/streambuf @@ -107,26 +107,31 @@ protected: */ -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) - -# include <__assert> -# include <__fwd/streambuf.h> -# include <__locale> -# include <__type_traits/is_same.h> -# include <__utility/is_valid_range.h> -# include -# include -# include -# include - -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/streambuf> +#else +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +# include <__assert> +# include <__fwd/streambuf.h> +# include <__locale> +# include <__type_traits/is_same.h> +# include <__utility/is_valid_range.h> +# include +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -# include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -433,18 +438,19 @@ typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Tra extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf; -# endif +# endif _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) +# endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_STREAMBUF diff --git a/libcxx/include/string b/libcxx/include/string index 4b5017f5e7753f4..2f0bd27a3b9cec0 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -586,102 +586,107 @@ basic_string operator""s( const char32_t *str, size_t len ); // clang-format on -#include <__algorithm/max.h> -#include <__algorithm/min.h> -#include <__algorithm/remove.h> -#include <__algorithm/remove_if.h> -#include <__assert> -#include <__config> -#include <__debug_utils/sanitizers.h> -#include <__format/enable_insertable.h> -#include <__functional/hash.h> -#include <__functional/unary_function.h> -#include <__fwd/string.h> -#include <__ios/fpos.h> -#include <__iterator/bounded_iter.h> -#include <__iterator/distance.h> -#include <__iterator/iterator_traits.h> -#include <__iterator/reverse_iterator.h> -#include <__iterator/wrap_iter.h> -#include <__memory/addressof.h> -#include <__memory/allocate_at_least.h> -#include <__memory/allocator.h> -#include <__memory/allocator_traits.h> -#include <__memory/compressed_pair.h> -#include <__memory/construct_at.h> -#include <__memory/noexcept_move_assign_container.h> -#include <__memory/pointer_traits.h> -#include <__memory/swap_allocator.h> -#include <__memory_resource/polymorphic_allocator.h> -#include <__ranges/access.h> -#include <__ranges/concepts.h> -#include <__ranges/container_compatible_range.h> -#include <__ranges/from_range.h> -#include <__ranges/size.h> -#include <__string/char_traits.h> -#include <__string/extern_template_lists.h> -#include <__type_traits/conditional.h> -#include <__type_traits/enable_if.h> -#include <__type_traits/is_allocator.h> -#include <__type_traits/is_array.h> -#include <__type_traits/is_convertible.h> -#include <__type_traits/is_nothrow_assignable.h> -#include <__type_traits/is_nothrow_constructible.h> -#include <__type_traits/is_same.h> -#include <__type_traits/is_standard_layout.h> -#include <__type_traits/is_trivial.h> -#include <__type_traits/is_trivially_relocatable.h> -#include <__type_traits/remove_cvref.h> -#include <__type_traits/void_t.h> -#include <__utility/auto_cast.h> -#include <__utility/declval.h> -#include <__utility/forward.h> -#include <__utility/is_pointer_in_range.h> -#include <__utility/move.h> -#include <__utility/swap.h> -#include <__utility/unreachable.h> -#include -#include // EOF -#include -#include -#include -#include -#include - -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -# include -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/string> +#else +# include <__algorithm/max.h> +# include <__algorithm/min.h> +# include <__algorithm/remove.h> +# include <__algorithm/remove_if.h> +# include <__assert> +# include <__config> +# include <__debug_utils/sanitizers.h> +# include <__format/enable_insertable.h> +# include <__functional/hash.h> +# include <__functional/unary_function.h> +# include <__fwd/string.h> +# include <__ios/fpos.h> +# include <__iterator/bounded_iter.h> +# include <__iterator/distance.h> +# include <__iterator/iterator_traits.h> +# include <__iterator/reverse_iterator.h> +# include <__iterator/wrap_iter.h> +# include <__memory/addressof.h> +# include <__memory/allocate_at_least.h> +# include <__memory/allocator.h> +# include <__memory/allocator_traits.h> +# include <__memory/compressed_pair.h> +# include <__memory/construct_at.h> +# include <__memory/noexcept_move_assign_container.h> +# include <__memory/pointer_traits.h> +# include <__memory/swap_allocator.h> +# include <__memory_resource/polymorphic_allocator.h> +# include <__ranges/access.h> +# include <__ranges/concepts.h> +# include <__ranges/container_compatible_range.h> +# include <__ranges/from_range.h> +# include <__ranges/size.h> +# include <__string/char_traits.h> +# include <__string/extern_template_lists.h> +# include <__type_traits/conditional.h> +# include <__type_traits/enable_if.h> +# include <__type_traits/is_allocator.h> +# include <__type_traits/is_array.h> +# include <__type_traits/is_convertible.h> +# include <__type_traits/is_nothrow_assignable.h> +# include <__type_traits/is_nothrow_constructible.h> +# include <__type_traits/is_same.h> +# include <__type_traits/is_standard_layout.h> +# include <__type_traits/is_trivial.h> +# include <__type_traits/is_trivially_relocatable.h> +# include <__type_traits/remove_cvref.h> +# include <__type_traits/void_t.h> +# include <__utility/auto_cast.h> +# include <__utility/declval.h> +# include <__utility/forward.h> +# include <__utility/is_pointer_in_range.h> +# include <__utility/move.h> +# include <__utility/swap.h> +# include <__utility/unreachable.h> +# include +# include // EOF +# include +# include +# include +# include +# include + +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# include +# endif // standard-mandated includes // [iterator.range] -#include <__iterator/access.h> -#include <__iterator/data.h> -#include <__iterator/empty.h> -#include <__iterator/reverse_access.h> -#include <__iterator/size.h> +# include <__iterator/access.h> +# include <__iterator/data.h> +# include <__iterator/empty.h> +# include <__iterator/reverse_access.h> +# include <__iterator/size.h> // [string.syn] -#include -#include +# include +# include -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> -#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) -# define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS __attribute__((__no_sanitize__("address"))) +# if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) +# define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS __attribute__((__no_sanitize__("address"))) // This macro disables AddressSanitizer (ASan) instrumentation for a specific function, // allowing memory accesses that would normally trigger ASan errors to proceed without crashing. // This is useful for accessing parts of objects memory, which should not be accessed, // such as unused bytes in short strings, that should never be accessed // by other parts of the program. -#else -# define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS -#endif +# else +# define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS +# endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -707,7 +712,7 @@ template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); -#if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> @@ -727,7 +732,7 @@ template _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> operator+(type_identity_t> __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs); -#endif +# endif extern template _LIBCPP_EXPORTED_FROM_ABI string operator+ , allocator >(char const*, string const&); @@ -785,7 +790,7 @@ public: // // This string implementation doesn't contain any references into itself. It only contains a bit that says whether // it is in small or large string mode, so the entire structure is trivially relocatable if its members are. -#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) +# if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) // When compiling with AddressSanitizer (ASan), basic_string cannot be trivially // relocatable. Because the object's memory might be poisoned when its content // is kept inside objects memory (short string optimization), instead of in allocated @@ -793,14 +798,14 @@ public: // the memory to avoid triggering false positives. // Therefore it's crucial to ensure the destructor is called. using __trivially_relocatable = void; -#else +# else using __trivially_relocatable = __conditional_t< __libcpp_is_trivially_relocatable::value && __libcpp_is_trivially_relocatable::value, basic_string, void>; -#endif +# endif -#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) +# if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __asan_volatile_wrapper(pointer const& __ptr) const { if (__libcpp_is_constant_evaluated()) return __ptr; @@ -819,10 +824,10 @@ public: return const_cast(__copy_ptr); } -# define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) __asan_volatile_wrapper(PTR) -#else -# define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) PTR -#endif +# define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) __asan_volatile_wrapper(PTR) +# else +# define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) PTR +# endif static_assert(!is_array::value, "Character type of basic_string must not be an array"); static_assert(is_standard_layout::value, "Character type of basic_string must be standard-layout"); @@ -833,23 +838,23 @@ public: "Allocator::value_type must be same type as value_type"); static_assert(__check_valid_allocator::value, ""); -#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING +# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is // considered contiguous. typedef __bounded_iter<__wrap_iter > iterator; typedef __bounded_iter<__wrap_iter > const_iterator; -#else +# else typedef __wrap_iter iterator; typedef __wrap_iter const_iterator; -#endif +# endif typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; private: static_assert(CHAR_BIT == 8, "This implementation assumes that one byte contains 8 bits"); -#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT +# ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT struct __long { pointer __data_; @@ -880,19 +885,19 @@ private: // This does not impact the short string representation, since we never need the MSB // for representing the size of a short string anyway. -# ifdef _LIBCPP_BIG_ENDIAN +# ifdef _LIBCPP_BIG_ENDIAN static const size_type __endian_factor = 2; -# else +# else static const size_type __endian_factor = 1; -# endif +# endif -#else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT +# else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT -# ifdef _LIBCPP_BIG_ENDIAN +# ifdef _LIBCPP_BIG_ENDIAN static const size_type __endian_factor = 1; -# else +# else static const size_type __endian_factor = 2; -# endif +# endif // Attribute 'packed' is used to keep the layout compatible with the // previous definition that did not use bit fields. This is because on @@ -918,7 +923,7 @@ private: value_type __data_[__min_cap]; }; -#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT +# endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT static_assert(sizeof(__short) == (sizeof(value_type) * (__min_cap + 1)), "__short has an unexpected size."); @@ -959,7 +964,7 @@ private: } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iterator(pointer __p) { -#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING +# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING // Bound the iterator according to the size (and not the capacity, unlike vector). // // By the Standard, string iterators are generally not guaranteed to stay valid when the container is modified, @@ -970,21 +975,21 @@ private: std::__wrap_iter(__p), std::__wrap_iter(__get_pointer()), std::__wrap_iter(__get_pointer() + size())); -#else +# else return iterator(__p); -#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING +# endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator __make_const_iterator(const_pointer __p) const { -#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING +# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING // Bound the iterator according to the size (and not the capacity, unlike vector). return std::__make_bounded_iter( std::__wrap_iter(__p), std::__wrap_iter(__get_pointer()), std::__wrap_iter(__get_pointer() + size())); -#else +# else return const_iterator(__p); -#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING +# endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING } public: @@ -997,11 +1002,11 @@ public: } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const allocator_type& __a) -#if _LIBCPP_STD_VER <= 14 +# if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_copy_constructible::value) -#else +# else _NOEXCEPT -#endif +# endif : __rep_(), __alloc_(__a) { __annotate_new(0); } @@ -1025,13 +1030,13 @@ public: __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(basic_string&& __str) -# if _LIBCPP_STD_VER <= 14 +# if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_move_constructible::value) -# else +# else _NOEXCEPT -# endif +# endif // Turning off ASan instrumentation for variable initialization with _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS // does not work consistently during initialization of __r_, so we instead unpoison __str's memory manually first. // __str's memory needs to be unpoisoned only in the case where it's a short string. @@ -1063,7 +1068,7 @@ public: __annotate_new(size()); } } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s) { @@ -1078,9 +1083,9 @@ public: __init(__s, traits_type::length(__s)); } -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 basic_string(nullptr_t) = delete; -#endif +# endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n) { _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); @@ -1096,7 +1101,7 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c) { __init(__n, __c); } -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 _LIBCPP_HIDE_FROM_ABI constexpr basic_string( basic_string&& __str, size_type __pos, const _Allocator& __alloc = _Allocator()) : basic_string(std::move(__str), __pos, npos, __alloc) {} @@ -1115,7 +1120,7 @@ public: __init(__str.data() + __pos, __len); } } -#endif +# endif template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c, const _Allocator& __a) @@ -1186,7 +1191,7 @@ public: __init(__first, __last); } -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_CharT> _Range> _LIBCPP_HIDE_FROM_ABI constexpr basic_string( from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) @@ -1197,9 +1202,9 @@ public: __init_with_sentinel(ranges::begin(__range), ranges::end(__range)); } } -#endif +# endif -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il) { __init(__il.begin(), __il.end()); } @@ -1208,7 +1213,7 @@ public: : __alloc_(__a) { __init(__il.begin(), __il.end()); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG inline _LIBCPP_CONSTEXPR_SINCE_CXX20 ~basic_string() { __annotate_delete(); @@ -1232,7 +1237,7 @@ public: return assign(__sv); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(basic_string&& __str) noexcept(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) { __move_assign(__str, integral_constant()); @@ -1242,13 +1247,13 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(initializer_list __il) { return assign(__il.begin(), __il.size()); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const value_type* __s) { return assign(__s); } -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 basic_string& operator=(nullptr_t) = delete; -#endif +# endif _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(value_type __c); _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT { @@ -1308,19 +1313,19 @@ public: _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __requested_capacity); -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template _LIBCPP_HIDE_FROM_ABI constexpr void resize_and_overwrite(size_type __n, _Op __op) { __resize_default_init(__n); __erase_to_end(std::move(__op)(data(), _LIBCPP_AUTO_CAST(__n))); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __resize_default_init(size_type __n); -#if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRING_RESERVE) +# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRING_RESERVE) _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve() _NOEXCEPT { shrink_to_fit(); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void clear() _NOEXCEPT; @@ -1370,11 +1375,11 @@ public: return *this; } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(initializer_list __il) { return append(__il); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const basic_string& __str) { return append(__str.data(), __str.size()); @@ -1419,19 +1424,19 @@ public: _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(_ForwardIterator __first, _ForwardIterator __last); -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_CharT> _Range> _LIBCPP_HIDE_FROM_ABI constexpr basic_string& append_range(_Range&& __range) { insert_range(end(), std::forward<_Range>(__range)); return *this; } -#endif +# endif -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(initializer_list __il) { return append(__il.begin(), __il.size()); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_CONSTEXPR_SINCE_CXX20 void push_back(value_type __c); _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void pop_back(); @@ -1463,7 +1468,7 @@ public: return assign(__sv.data(), __sv.size()); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI constexpr void __move_assign(basic_string&& __str, size_type __pos, size_type __len) { // Pilfer the allocation from __str. _LIBCPP_ASSERT_INTERNAL(__alloc_ == __str.__alloc_, "__move_assign called with wrong allocator"); @@ -1484,18 +1489,18 @@ public: __annotate_shrink(__old_sz); } } -#endif +# endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const basic_string& __str) { return *this = __str; } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(basic_string&& __str) noexcept(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) { *this = std::move(__str); return *this; } -#endif +# endif _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const basic_string& __str, size_type __pos, size_type __n = npos); template = 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_CharT> _Range> _LIBCPP_HIDE_FROM_ABI constexpr basic_string& assign_range(_Range&& __range) { if constexpr (__string_is_trivial_iterator>::value && @@ -1530,13 +1535,13 @@ public: return *this; } -#endif +# endif -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(initializer_list __il) { return assign(__il.begin(), __il.size()); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos1, const basic_string& __str) { @@ -1564,7 +1569,7 @@ public: _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, size_type __n, value_type __c); _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __pos, value_type __c); -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_CharT> _Range> _LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) { if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { @@ -1576,7 +1581,7 @@ public: return insert(__position, __temp.data(), __temp.data() + __temp.size()); } } -#endif +# endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __pos, size_type __n, value_type __c) { @@ -1593,12 +1598,12 @@ public: _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last); -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __pos, initializer_list __il) { return insert(__pos, __il.begin(), __il.end()); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& erase(size_type __pos = 0, size_type __n = npos); _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __pos); @@ -1663,30 +1668,30 @@ public: _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2); -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_CharT> _Range> _LIBCPP_HIDE_FROM_ABI constexpr basic_string& replace_with_range(const_iterator __i1, const_iterator __i2, _Range&& __range) { basic_string __temp(from_range, std::forward<_Range>(__range), __alloc_); return replace(__i1, __i2, __temp); } -#endif +# endif -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list __il) { return replace(__i1, __i2, __il.begin(), __il.end()); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const; -#if _LIBCPP_STD_VER <= 20 +# if _LIBCPP_STD_VER <= 20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string substr(size_type __pos = 0, size_type __n = npos) const { return basic_string(*this, __pos, __n); } -#else +# else _LIBCPP_HIDE_FROM_ABI constexpr basic_string substr(size_type __pos = 0, size_type __n = npos) const& { return basic_string(*this, __pos, __n); } @@ -1694,24 +1699,24 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr basic_string substr(size_type __pos = 0, size_type __n = npos) && { return basic_string(std::move(*this), __pos, __n); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(basic_string& __str) -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 _NOEXCEPT; -#else +# else _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v); -#endif +# endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* c_str() const _NOEXCEPT { return data(); } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* data() const _NOEXCEPT { return std::__to_address(__get_pointer()); } -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 value_type* data() _NOEXCEPT { return std::__to_address(__get_pointer()); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT { return __alloc_; @@ -1824,7 +1829,7 @@ public: _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const; -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(__self_view __sv) const noexcept { return __self_view(typename __self_view::__assume_valid(), data(), size()).starts_with(__sv); } @@ -1848,9 +1853,9 @@ public: constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(const value_type* __s) const noexcept { return ends_with(__self_view(__s)); } -#endif +# endif -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(__self_view __sv) const noexcept { return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__sv); } @@ -1862,7 +1867,7 @@ public: constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* __s) const { return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__s); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const; @@ -1885,15 +1890,15 @@ private: } static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __begin_lifetime(pointer __begin, size_type __n) { -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 if (__libcpp_is_constant_evaluated()) { for (size_type __i = 0; __i != __n; ++__i) std::construct_at(std::addressof(__begin[__i])); } -#else +# else (void)__begin; (void)__n; -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 } _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) { return __sz < __min_cap; } @@ -1909,13 +1914,13 @@ private: template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static value_type* __copy_non_overlapping_range(_ForwardIter __first, _Sent __last, value_type* __dest) { -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG if constexpr (__libcpp_is_contiguous_iterator<_ForwardIter>::value && is_same>::value && is_same<_ForwardIter, _Sent>::value) { traits_type::copy(__dest, std::__to_address(__first), __last - __first); return __dest + (__last - __first); } -#endif +# endif for (; __first != __last; ++__first) traits_type::assign(*__dest++, *__first); @@ -2019,45 +2024,45 @@ private: __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const { (void)__old_mid; (void)__new_mid; -#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) -# if defined(__APPLE__) +# if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) +# if defined(__APPLE__) // TODO: remove after addressing issue #96099 (https://github.com/llvm/llvm-project/issues/96099) if (!__is_long()) return; -# endif +# endif std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity() + 1, __old_mid, __new_mid); -#endif +# endif } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_new(size_type __current_size) const _NOEXCEPT { (void)__current_size; -#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) +# if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) if (!__libcpp_is_constant_evaluated()) __annotate_contiguous_container(data() + capacity() + 1, data() + __current_size + 1); -#endif +# endif } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_delete() const _NOEXCEPT { -#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) +# if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) if (!__libcpp_is_constant_evaluated()) __annotate_contiguous_container(data() + size() + 1, data() + capacity() + 1); -#endif +# endif } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_increase(size_type __n) const _NOEXCEPT { (void)__n; -#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) +# if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) if (!__libcpp_is_constant_evaluated()) __annotate_contiguous_container(data() + size() + 1, data() + size() + 1 + __n); -#endif +# endif } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_shrink(size_type __old_size) const _NOEXCEPT { (void)__old_size; -#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) +# if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) if (!__libcpp_is_constant_evaluated()) __annotate_contiguous_container(data() + __old_size + 1, data() + size() + 1); -#endif +# endif } template @@ -2104,9 +2109,9 @@ private: __init_with_size(_InputIterator __first, _Sentinel __last, size_type __sz); _LIBCPP_CONSTEXPR_SINCE_CXX20 -#if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1 +# if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1 _LIBCPP_HIDE_FROM_ABI -#endif +# endif _LIBCPP_DEPRECATED_("use __grow_by_without_replace") void __grow_by( size_type __old_cap, size_type __delta_cap, @@ -2175,17 +2180,17 @@ private: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT {} -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(basic_string& __str, false_type) noexcept(__alloc_traits::is_always_equal::value); _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void __move_assign(basic_string& __str, true_type) -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 noexcept; -# else +# else noexcept(is_nothrow_move_assignable::value); +# endif # endif -#endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(basic_string& __str) _NOEXCEPT_(!__alloc_traits::propagate_on_container_move_assignment::value || @@ -2248,10 +2253,10 @@ private: friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(value_type, const basic_string&); friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, const value_type*); friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, value_type); -#if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 friend constexpr basic_string operator+ <>(const basic_string&, type_identity_t<__self_view>); friend constexpr basic_string operator+ <>(type_identity_t<__self_view>, const basic_string&); -#endif +# endif template friend inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool @@ -2260,21 +2265,21 @@ private: // These declarations must appear before any functions are implicitly used // so that they have the correct visibility specifier. -#define _LIBCPP_DECLARE(...) extern template __VA_ARGS__; -#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION +# define _LIBCPP_DECLARE(...) extern template __VA_ARGS__; +# ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char) -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, wchar_t) -# endif -#else +# endif +# else _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char) -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, wchar_t) +# endif # endif -#endif -#undef _LIBCPP_DECLARE +# undef _LIBCPP_DECLARE -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template , class _Allocator = allocator<_CharT>, @@ -2287,8 +2292,8 @@ template , class = enable_if_t<__is_allocator<_Allocator>::value> > -explicit basic_string(basic_string_view<_CharT, _Traits>, - const _Allocator& = _Allocator()) -> basic_string<_CharT, _Traits, _Allocator>; +explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator()) + -> basic_string<_CharT, _Traits, _Allocator>; template ::size_type > basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator()) -> basic_string<_CharT, _Traits, _Allocator>; -#endif +# endif -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template >, class = enable_if_t<__is_allocator<_Allocator>::value> > basic_string(from_range_t, _Range&&, _Allocator = _Allocator()) -> basic_string, char_traits>, _Allocator>; -#endif +# endif template _LIBCPP_CONSTEXPR_SINCE_CXX20 void @@ -2417,19 +2422,19 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_sentinel(_InputIterator _ __rep_ = __rep(); __annotate_new(0); -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS for (; __first != __last; ++__first) push_back(*__first); -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __annotate_delete(); if (__is_long()) __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); throw; } -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -2464,18 +2469,18 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __fir __set_long_size(__sz); } -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__p)); traits_type::assign(*__end, value_type()); -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { if (__is_long()) __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); throw; } -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __annotate_new(__sz); } @@ -2521,9 +2526,9 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__ // not removed or changed to avoid breaking the ABI. template void _LIBCPP_CONSTEXPR_SINCE_CXX20 -#if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1 +# if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1 _LIBCPP_HIDE_FROM_ABI -#endif +# endif _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Traits, _Allocator>::__grow_by( size_type __old_cap, size_type __delta_cap, @@ -2678,7 +2683,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) return *this; } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__move_assign( @@ -2692,22 +2697,22 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat template inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type) -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 noexcept -# else +# else noexcept(is_nothrow_move_assignable::value) -# endif +# endif { __annotate_delete(); if (__is_long()) { __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); -# if _LIBCPP_STD_VER <= 14 +# if _LIBCPP_STD_VER <= 14 if (!is_nothrow_move_assignable::value) { __set_short_size(0); traits_type::assign(__get_short_pointer()[0], value_type()); __annotate_new(0); } -# endif +# endif } size_type __str_old_size = __str.size(); bool __str_was_short = !__str.__is_long(); @@ -2736,7 +2741,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr __annotate_new(__get_short_size()); } -#endif +# endif template template ::value, int> > @@ -3377,9 +3382,9 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target // Shrink // - called from shrink_to_fit should not throw. // - called from reserve may throw but is not required to. -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS auto __allocation = std::__allocate_at_least(__alloc_, __target_capacity + 1); // The Standard mandates shrink_to_fit() does not increase the capacity. @@ -3392,11 +3397,11 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target } __new_data = __allocation.ptr; __target_capacity = __allocation.count - 1; -#if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { return; } -#endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } __begin_lifetime(__new_data, __target_capacity + 1); __now_long = true; @@ -3444,11 +3449,11 @@ basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, template inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 _NOEXCEPT -#else +# else _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v) -#endif +# endif { _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR( __alloc_traits::propagate_on_container_swap::value || __alloc_traits::is_always_equal::value || @@ -3823,12 +3828,12 @@ template inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 return basic_string_view<_CharT, _Traits>(__lhs) == basic_string_view<_CharT, _Traits>(__rhs); -#else +# else size_t __lhs_sz = __lhs.size(); return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(), __rhs.data(), __lhs_sz) == 0; -#endif +# endif } template @@ -3841,7 +3846,7 @@ operator==(const basic_string, _Allocator>& __lhs, return char_traits::compare(__lhs.data(), __rhs.data(), __sz) == 0; } -#if _LIBCPP_STD_VER <= 17 +# if _LIBCPP_STD_VER <= 17 template inline _LIBCPP_HIDE_FROM_ABI bool operator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { @@ -3852,7 +3857,7 @@ operator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& return false; return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0; } -#endif // _LIBCPP_STD_VER <= 17 +# endif // _LIBCPP_STD_VER <= 17 template inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool @@ -3871,7 +3876,7 @@ operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0; } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template _LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(const basic_string<_CharT, _Traits, _Allocator>& __lhs, @@ -3885,7 +3890,7 @@ operator<=>(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT return basic_string_view<_CharT, _Traits>(__lhs) <=> basic_string_view<_CharT, _Traits>(__rhs); } -#else // _LIBCPP_STD_VER >= 20 +# else // _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, @@ -3984,7 +3989,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { return !(__lhs < __rhs); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 // operator + @@ -4067,7 +4072,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) return __r; } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> @@ -4113,9 +4118,9 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) { return std::move(__lhs); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG -#if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> @@ -4167,7 +4172,7 @@ operator+(type_identity_t> __lhs, return std::move(__rhs); } -#endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 // swap @@ -4198,7 +4203,7 @@ _LIBCPP_EXPORTED_FROM_ABI string to_string(float __val); _LIBCPP_EXPORTED_FROM_ABI string to_string(double __val); _LIBCPP_EXPORTED_FROM_ABI string to_string(long double __val); -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_EXPORTED_FROM_ABI int stoi(const wstring& __str, size_t* __idx = nullptr, int __base = 10); _LIBCPP_EXPORTED_FROM_ABI long stol(const wstring& __str, size_t* __idx = nullptr, int __base = 10); _LIBCPP_EXPORTED_FROM_ABI unsigned long stoul(const wstring& __str, size_t* __idx = nullptr, int __base = 10); @@ -4218,7 +4223,7 @@ _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(unsigned long long __val); _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(float __val); _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(double __val); _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(long double __val); -#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS +# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS template _LIBCPP_TEMPLATE_DATA_VIS const typename basic_string<_CharT, _Traits, _Allocator>::size_type @@ -4235,10 +4240,10 @@ struct __string_hash : public __unary_function struct hash, _Allocator> > : __string_hash {}; -#if _LIBCPP_HAS_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T template struct hash, _Allocator> > : __string_hash {}; -#endif +# endif template struct hash, _Allocator> > : __string_hash {}; @@ -4246,10 +4251,10 @@ struct hash, _Allocator> > : __stri template struct hash, _Allocator> > : __string_hash {}; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template struct hash, _Allocator> > : __string_hash {}; -#endif +# endif template _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& @@ -4275,7 +4280,7 @@ template inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str); -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template inline _LIBCPP_HIDE_FROM_ABI typename basic_string<_CharT, _Traits, _Allocator>::size_type erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) { @@ -4291,9 +4296,9 @@ erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred) { __str.erase(std::remove_if(__str.begin(), __str.end(), __pred), __str.end()); return __old_size - __str.size(); } -#endif +# endif -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 // Literal suffixes for basic_string [basic.string.literals] inline namespace literals { inline namespace string_literals { @@ -4302,18 +4307,18 @@ operator""s(const char* __str, size_t __len) { return basic_string(__str, __len); } -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator""s(const wchar_t* __str, size_t __len) { return basic_string(__str, __len); } -# endif +# endif -# if _LIBCPP_HAS_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string operator""s(const char8_t* __str, size_t __len) { return basic_string(__str, __len); } -# endif +# endif inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator""s(const char16_t* __str, size_t __len) { @@ -4327,30 +4332,31 @@ operator""s(const char32_t* __str, size_t __len) { } // namespace string_literals } // namespace literals -# if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template <> inline constexpr bool __format::__enable_insertable> = true; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> inline constexpr bool __format::__enable_insertable> = true; +# endif # endif -# endif -#endif +# endif _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_STRING diff --git a/libcxx/include/string.h b/libcxx/include/string.h index ae10d5ad2c76f10..ff76db1159e9706 100644 --- a/libcxx/include/string.h +++ b/libcxx/include/string.h @@ -51,24 +51,30 @@ size_t strlen(const char* s); */ -#include <__config> +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/string.h> +#else +# include <__config> -#if __has_include_next() -# include_next -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if __has_include_next() +# include_next +# endif // MSVCRT, GNU libc and its derivates may already have the correct prototype in // . This macro can be defined by users if their C library provides // the right signature. -#if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_) -# define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS -#endif +# if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || \ + defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_) +# define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS +# endif -#if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD) +# if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD) extern "C++" { inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strchr(const char* __s, int __c) { return __builtin_strchr(__s, __c); @@ -105,6 +111,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strstr(char* __s1, return __builtin_strstr(__s1, __s2); } } // extern "C++" -#endif +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_STRING_H diff --git a/libcxx/include/string_view b/libcxx/include/string_view index 5beac404fb5b54f..a2805d1ab16e3a5 100644 --- a/libcxx/include/string_view +++ b/libcxx/include/string_view @@ -205,58 +205,63 @@ namespace std { // clang-format on -#include <__algorithm/min.h> -#include <__assert> -#include <__config> -#include <__functional/hash.h> -#include <__functional/unary_function.h> -#include <__fwd/ostream.h> -#include <__fwd/string.h> -#include <__fwd/string_view.h> -#include <__iterator/bounded_iter.h> -#include <__iterator/concepts.h> -#include <__iterator/iterator_traits.h> -#include <__iterator/reverse_iterator.h> -#include <__iterator/wrap_iter.h> -#include <__memory/pointer_traits.h> -#include <__ranges/concepts.h> -#include <__ranges/data.h> -#include <__ranges/enable_borrowed_range.h> -#include <__ranges/enable_view.h> -#include <__ranges/size.h> -#include <__string/char_traits.h> -#include <__type_traits/is_array.h> -#include <__type_traits/is_convertible.h> -#include <__type_traits/is_same.h> -#include <__type_traits/is_standard_layout.h> -#include <__type_traits/is_trivial.h> -#include <__type_traits/remove_cvref.h> -#include <__type_traits/remove_reference.h> -#include <__type_traits/type_identity.h> -#include -#include -#include -#include -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/string_view> +#else +# include <__algorithm/min.h> +# include <__assert> +# include <__config> +# include <__functional/hash.h> +# include <__functional/unary_function.h> +# include <__fwd/ostream.h> +# include <__fwd/string.h> +# include <__fwd/string_view.h> +# include <__iterator/bounded_iter.h> +# include <__iterator/concepts.h> +# include <__iterator/iterator_traits.h> +# include <__iterator/reverse_iterator.h> +# include <__iterator/wrap_iter.h> +# include <__memory/pointer_traits.h> +# include <__ranges/concepts.h> +# include <__ranges/data.h> +# include <__ranges/enable_borrowed_range.h> +# include <__ranges/enable_view.h> +# include <__ranges/size.h> +# include <__string/char_traits.h> +# include <__type_traits/is_array.h> +# include <__type_traits/is_convertible.h> +# include <__type_traits/is_same.h> +# include <__type_traits/is_standard_layout.h> +# include <__type_traits/is_trivial.h> +# include <__type_traits/remove_cvref.h> +# include <__type_traits/remove_reference.h> +# include <__type_traits/type_identity.h> +# include +# include +# include +# include +# include // standard-mandated includes // [iterator.range] -#include <__iterator/access.h> -#include <__iterator/data.h> -#include <__iterator/empty.h> -#include <__iterator/reverse_access.h> -#include <__iterator/size.h> +# include <__iterator/access.h> +# include <__iterator/data.h> +# include <__iterator/empty.h> +# include <__iterator/reverse_access.h> +# include <__iterator/size.h> // [string.view.synop] -#include +# include -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -281,13 +286,13 @@ public: using const_pointer = const _CharT*; using reference = _CharT&; using const_reference = const _CharT&; -#if defined(_LIBCPP_ABI_BOUNDED_ITERATORS) +# if defined(_LIBCPP_ABI_BOUNDED_ITERATORS) using const_iterator = __bounded_iter; -#elif defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW) +# elif defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW) using const_iterator = __wrap_iter; -#else +# else using const_iterator = const_pointer; -#endif +# endif using iterator = const_iterator; using const_reverse_iterator = std::reverse_iterator; using reverse_iterator = const_reverse_iterator; @@ -311,7 +316,7 @@ public: _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT : __data_(__s), __size_(__len) { -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 // Allocations must fit in `ptrdiff_t` for pointer arithmetic to work. If `__len` exceeds it, the input // range could not have been valid. Most likely the caller underflowed some arithmetic and inadvertently // passed in a negative length. @@ -320,10 +325,10 @@ public: "string_view::string_view(_CharT *, size_t): length does not fit in difference_type"); _LIBCPP_ASSERT_NON_NULL( __len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr"); -#endif +# endif } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template _End> requires(is_same_v, _CharT> && !is_convertible_v<_End, size_type>) constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_It __begin, _End __end) @@ -331,9 +336,9 @@ public: _LIBCPP_ASSERT_VALID_INPUT_RANGE( (__end - __begin) >= 0, "std::string_view::string_view(iterator, sentinel) received invalid range"); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template requires(!is_same_v, basic_string_view> && ranges::contiguous_range<_Range> && ranges::sized_range<_Range> && is_same_v, _CharT> && @@ -341,14 +346,14 @@ public: (!requires(remove_cvref_t<_Range>& __d) { __d.operator std::basic_string_view<_CharT, _Traits>(); })) constexpr explicit _LIBCPP_HIDE_FROM_ABI basic_string_view(_Range&& __r) : __data_(ranges::data(__r)), __size_(ranges::size(__r)) {} -#endif // _LIBCPP_STD_VER >= 23 +# endif // _LIBCPP_STD_VER >= 23 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view(const _CharT* __s) : __data_(__s), __size_(std::__char_traits_length_checked<_Traits>(__s)) {} -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 basic_string_view(nullptr_t) = delete; -#endif +# endif // [string.view.iterators], iterators _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return cbegin(); } @@ -356,19 +361,19 @@ public: _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return cend(); } _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { -#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS +# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS return std::__make_bounded_iter(data(), data(), data() + size()); -#else +# else return const_iterator(__data_); -#endif +# endif } _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { -#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS +# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS return std::__make_bounded_iter(data() + size(), data(), data() + size()); -#else +# else return const_iterator(__data_ + __size_); -#endif +# endif } _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { @@ -643,7 +648,7 @@ public: data(), size(), __s, __pos, traits_type::length(__s)); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(basic_string_view __s) const noexcept { return size() >= __s.size() && compare(0, __s.size(), __s) == 0; } @@ -667,15 +672,15 @@ public: constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(const value_type* __s) const noexcept { return ends_with(basic_string_view(__s)); } -#endif +# endif -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(basic_string_view __sv) const noexcept { return find(__sv) != npos; } constexpr _LIBCPP_HIDE_FROM_ABI bool contains(value_type __c) const noexcept { return find(__c) != npos; } constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* __s) const { return find(__s) != npos; } -#endif +# endif private: struct __assume_valid {}; @@ -696,29 +701,29 @@ private: }; _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_string_view); -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template inline constexpr bool ranges::enable_view> = true; template inline constexpr bool ranges::enable_borrowed_range > = true; -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 // [string.view.deduct] -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template _End> basic_string_view(_It, _End) -> basic_string_view>; -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template basic_string_view(_Range) -> basic_string_view>; -#endif +# endif // [string.view.comparison] -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(basic_string_view<_CharT, _Traits> __lhs, @@ -741,7 +746,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(basic_string_view<_CharT, _Trai } } -#else +# else // operator == @@ -884,7 +889,7 @@ operator>=(__type_identity_t > __lhs, return __lhs.compare(__rhs) >= 0; } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 template _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& @@ -901,10 +906,10 @@ struct __string_view_hash : public __unary_function struct hash > > : __string_view_hash {}; -#if _LIBCPP_HAS_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T template <> struct hash > > : __string_view_hash {}; -#endif +# endif template <> struct hash > > : __string_view_hash {}; @@ -912,31 +917,31 @@ struct hash > > : __string_vie template <> struct hash > > : __string_view_hash {}; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> struct hash > > : __string_view_hash {}; -#endif +# endif -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 inline namespace literals { inline namespace string_view_literals { inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view operator""sv(const char* __str, size_t __len) noexcept { return basic_string_view(__str, __len); } -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view operator""sv(const wchar_t* __str, size_t __len) noexcept { return basic_string_view(__str, __len); } -# endif +# endif -# if _LIBCPP_HAS_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view operator""sv(const char8_t* __str, size_t __len) noexcept { return basic_string_view(__str, __len); } -# endif +# endif inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view operator""sv(const char16_t* __str, size_t __len) noexcept { @@ -949,17 +954,18 @@ operator""sv(const char32_t* __str, size_t __len) noexcept { } } // namespace string_view_literals } // namespace literals -#endif +# endif _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_STRING_VIEW diff --git a/libcxx/include/strstream b/libcxx/include/strstream index 9ff4024a7c7e212..ff715a2aa513b45 100644 --- a/libcxx/include/strstream +++ b/libcxx/include/strstream @@ -129,30 +129,35 @@ private: */ -#include <__config> -#include -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/strstream> +#else +# include <__config> +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif -#if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY) +# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY) _LIBCPP_PUSH_MACROS -# include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI strstreambuf : public streambuf { public: -# ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI strstreambuf() : strstreambuf(0) {} explicit strstreambuf(streamsize __alsize); -# else +# else explicit strstreambuf(streamsize __alsize = 0); -# endif +# endif strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*)); strstreambuf(char* __gnext, streamsize __n, char* __pbeg = nullptr); strstreambuf(const char* __gnext, streamsize __n); @@ -162,10 +167,10 @@ public: strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = nullptr); strstreambuf(const unsigned char* __gnext, streamsize __n); -# ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI strstreambuf(strstreambuf&& __rhs); _LIBCPP_HIDE_FROM_ABI strstreambuf& operator=(strstreambuf&& __rhs); -# endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG ~strstreambuf() override; @@ -199,7 +204,7 @@ private: void __init(char* __gnext, streamsize __n, char* __pbeg); }; -# ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG inline _LIBCPP_HIDE_FROM_ABI strstreambuf::strstreambuf(strstreambuf&& __rhs) : streambuf(__rhs), @@ -228,7 +233,7 @@ inline _LIBCPP_HIDE_FROM_ABI strstreambuf& strstreambuf::operator=(strstreambuf& return *this; } -# endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI istrstream : public istream { public: @@ -237,7 +242,7 @@ public: _LIBCPP_HIDE_FROM_ABI istrstream(const char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {} _LIBCPP_HIDE_FROM_ABI istrstream(char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {} -# ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI istrstream(istrstream&& __rhs) // extension : istream(std::move(static_cast(__rhs))), __sb_(std::move(__rhs.__sb_)) { istream::set_rdbuf(&__sb_); @@ -248,7 +253,7 @@ public: istream::operator=(std::move(__rhs)); return *this; } -# endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG ~istrstream() override; @@ -270,7 +275,7 @@ public: _LIBCPP_HIDE_FROM_ABI ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out) : ostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {} -# ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI ostrstream(ostrstream&& __rhs) // extension : ostream(std::move(static_cast(__rhs))), __sb_(std::move(__rhs.__sb_)) { ostream::set_rdbuf(&__sb_); @@ -281,7 +286,7 @@ public: ostream::operator=(std::move(__rhs)); return *this; } -# endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG ~ostrstream() override; @@ -312,7 +317,7 @@ public: _LIBCPP_HIDE_FROM_ABI strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out) : iostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {} -# ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI strstream(strstream&& __rhs) // extension : iostream(std::move(static_cast(__rhs))), __sb_(std::move(__rhs.__sb_)) { iostream::set_rdbuf(&__sb_); @@ -323,7 +328,7 @@ public: iostream::operator=(std::move(__rhs)); return *this; } -# endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG ~strstream() override; @@ -346,6 +351,7 @@ _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY) +# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY) +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_STRSTREAM diff --git a/libcxx/include/syncstream b/libcxx/include/syncstream index 72a5f6ca5c86c13..64f494b8938cc69 100644 --- a/libcxx/include/syncstream +++ b/libcxx/include/syncstream @@ -117,37 +117,42 @@ namespace std { */ -#include <__config> +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/syncstream> +#else +# include <__config> -# include <__utility/move.h> -# include -# include // required for declaration of default arguments -# include -# include +# if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# ifndef _LIBCPP_HAS_NO_THREADS -# include -# include -# include -# endif +# include <__utility/move.h> +# include +# include // required for declaration of default arguments +# include +# include + +# ifndef _LIBCPP_HAS_NO_THREADS +# include +# include +# include +# endif // standard-mandated includes // [syncstream.syn] -# include +# include -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -# include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD -# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) +# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) // [syncstream.syncbuf.overview]/1 // Class template basic_syncbuf stores character data written to it, @@ -160,7 +165,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD // // This helper singleton is used to implement the required // synchronisation guarantees. -# ifndef _LIBCPP_HAS_NO_THREADS +# ifndef _LIBCPP_HAS_NO_THREADS class __wrapped_streambuf_mutex { _LIBCPP_HIDE_FROM_ABI __wrapped_streambuf_mutex() = default; @@ -233,7 +238,7 @@ private: return __it; } }; -# endif // _LIBCPP_HAS_NO_THREADS +# endif // _LIBCPP_HAS_NO_THREADS // basic_syncbuf @@ -273,14 +278,14 @@ public: } _LIBCPP_HIDE_FROM_ABI ~basic_syncbuf() { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS emit(); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { } -# endif // _LIBCPP_HAS_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __dec_reference(); } @@ -337,9 +342,9 @@ protected: return traits_type::not_eof(__c); if (this->pptr() == this->epptr()) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif +# endif size_t __size = __str_.size(); __str_.resize(__str_.capacity() + 1); _LIBCPP_ASSERT_INTERNAL(__str_.size() > __size, "the buffer hasn't grown"); @@ -348,11 +353,11 @@ protected: this->setp(__p, __p + __str_.size()); this->pbump(__size); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { return traits_type::eof(); } -# endif +# endif } return this->sputc(traits_type::to_char_type(__c)); @@ -373,9 +378,9 @@ private: if (!__wrapped_) return false; -# ifndef _LIBCPP_HAS_NO_THREADS +# ifndef _LIBCPP_HAS_NO_THREADS lock_guard __lock = __wrapped_streambuf_mutex::__instance().__get_lock(__wrapped_); -# endif +# endif bool __result = true; if (this->pptr() != this->pbase()) { @@ -407,24 +412,24 @@ private: } _LIBCPP_HIDE_FROM_ABI void __inc_reference() { -# ifndef _LIBCPP_HAS_NO_THREADS +# ifndef _LIBCPP_HAS_NO_THREADS if (__wrapped_) __wrapped_streambuf_mutex::__instance().__inc_reference(__wrapped_); -# endif +# endif } _LIBCPP_HIDE_FROM_ABI void __dec_reference() noexcept { -# ifndef _LIBCPP_HAS_NO_THREADS +# ifndef _LIBCPP_HAS_NO_THREADS if (__wrapped_) __wrapped_streambuf_mutex::__instance().__dec_reference(__wrapped_); -# endif +# endif } }; using std::syncbuf; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using std::wsyncbuf; -# endif +# endif // [syncstream.syncbuf.special], specialized algorithms template @@ -480,17 +485,17 @@ public: // TODO validate other unformatted output functions. typename basic_ostream::sentry __s(*this); if (__s) { -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif +# endif if (__sb_.emit() == false) this->setstate(ios::badbit); -# if _LIBCPP_HAS_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif +# endif } } @@ -505,16 +510,17 @@ private: }; using std::osyncstream; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using std::wosyncstream; -# endif +# endif -# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) +# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) +# endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_SYNCSTREAM diff --git a/libcxx/include/system_error b/libcxx/include/system_error index eeab347788a9a52..7d289841e0595fe 100644 --- a/libcxx/include/system_error +++ b/libcxx/include/system_error @@ -144,28 +144,34 @@ template <> struct hash; */ -#include <__config> -#include <__system_error/errc.h> -#include <__system_error/error_category.h> -#include <__system_error/error_code.h> -#include <__system_error/error_condition.h> -#include <__system_error/system_error.h> -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/system_error> +#else +# include <__config> +# include <__system_error/errc.h> +# include <__system_error/error_category.h> +# include <__system_error/error_code.h> +# include <__system_error/error_condition.h> +# include <__system_error/system_error.h> +# include // standard-mandated includes // [system.error.syn] -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -#endif +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_SYSTEM_ERROR diff --git a/libcxx/include/tgmath.h b/libcxx/include/tgmath.h index 1c5058cb065a91c..aac1df13daeeeba 100644 --- a/libcxx/include/tgmath.h +++ b/libcxx/include/tgmath.h @@ -17,19 +17,33 @@ */ -#include <__config> +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#ifdef __cplusplus -# include -# include +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/tgmath.h> #else -# if __has_include_next() -# include_next +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# ifdef __cplusplus +# include +# include +# else +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# ifdef __cplusplus +# include +# else +# if __has_include_next() +# include_next +# endif +# endif # endif -#endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_TGMATH_H diff --git a/libcxx/include/thread b/libcxx/include/thread index 25cb7ce6d7231e0..04d0dbe8d55e07c 100644 --- a/libcxx/include/thread +++ b/libcxx/include/thread @@ -86,45 +86,51 @@ void sleep_for(const chrono::duration& rel_time); */ -#include <__config> +#include <__configuration/cxx03.h> -#if !defined(_LIBCPP_HAS_NO_THREADS) +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/thread> +#else +# include <__config> -# include <__thread/formatter.h> -# include <__thread/jthread.h> -# include <__thread/support.h> -# include <__thread/this_thread.h> -# include <__thread/thread.h> -# include +# if !defined(_LIBCPP_HAS_NO_THREADS) + +# include <__thread/formatter.h> +# include <__thread/jthread.h> +# include <__thread/support.h> +# include <__thread/this_thread.h> +# include <__thread/thread.h> +# include // standard-mandated includes // [thread.syn] -# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# endif // !defined(_LIBCPP_HAS_NO_THREADS) -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) +# include +# include +# include +# include # endif -#endif // !defined(_LIBCPP_HAS_NO_THREADS) - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) -# include -# include -# include -# include -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 -# include -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -#endif +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 +# include +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# endif +#endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP_THREAD diff --git a/libcxx/include/tuple b/libcxx/include/tuple index e7e14b8d12d42a4..122e8e003be1615 100644 --- a/libcxx/include/tuple +++ b/libcxx/include/tuple @@ -210,76 +210,81 @@ template // clang-format on -#include <__compare/common_comparison_category.h> -#include <__compare/ordering.h> -#include <__compare/synth_three_way.h> -#include <__config> -#include <__fwd/array.h> -#include <__fwd/pair.h> -#include <__fwd/tuple.h> -#include <__memory/allocator_arg_t.h> -#include <__memory/uses_allocator.h> -#include <__tuple/find_index.h> -#include <__tuple/ignore.h> -#include <__tuple/make_tuple_types.h> -#include <__tuple/sfinae_helpers.h> -#include <__tuple/tuple_element.h> -#include <__tuple/tuple_indices.h> -#include <__tuple/tuple_like_ext.h> -#include <__tuple/tuple_size.h> -#include <__tuple/tuple_types.h> -#include <__type_traits/common_reference.h> -#include <__type_traits/common_type.h> -#include <__type_traits/conditional.h> -#include <__type_traits/conjunction.h> -#include <__type_traits/copy_cvref.h> -#include <__type_traits/disjunction.h> -#include <__type_traits/enable_if.h> -#include <__type_traits/invoke.h> -#include <__type_traits/is_arithmetic.h> -#include <__type_traits/is_assignable.h> -#include <__type_traits/is_constructible.h> -#include <__type_traits/is_convertible.h> -#include <__type_traits/is_empty.h> -#include <__type_traits/is_final.h> -#include <__type_traits/is_implicitly_default_constructible.h> -#include <__type_traits/is_nothrow_assignable.h> -#include <__type_traits/is_nothrow_constructible.h> -#include <__type_traits/is_reference.h> -#include <__type_traits/is_same.h> -#include <__type_traits/is_swappable.h> -#include <__type_traits/is_trivially_relocatable.h> -#include <__type_traits/lazy.h> -#include <__type_traits/maybe_const.h> -#include <__type_traits/nat.h> -#include <__type_traits/negation.h> -#include <__type_traits/remove_cvref.h> -#include <__type_traits/remove_reference.h> -#include <__type_traits/unwrap_ref.h> -#include <__utility/declval.h> -#include <__utility/forward.h> -#include <__utility/integer_sequence.h> -#include <__utility/move.h> -#include <__utility/piecewise_construct.h> -#include <__utility/swap.h> -#include -#include +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/tuple> +#else +# include <__compare/common_comparison_category.h> +# include <__compare/ordering.h> +# include <__compare/synth_three_way.h> +# include <__config> +# include <__fwd/array.h> +# include <__fwd/pair.h> +# include <__fwd/tuple.h> +# include <__memory/allocator_arg_t.h> +# include <__memory/uses_allocator.h> +# include <__tuple/find_index.h> +# include <__tuple/ignore.h> +# include <__tuple/make_tuple_types.h> +# include <__tuple/sfinae_helpers.h> +# include <__tuple/tuple_element.h> +# include <__tuple/tuple_indices.h> +# include <__tuple/tuple_like_ext.h> +# include <__tuple/tuple_size.h> +# include <__tuple/tuple_types.h> +# include <__type_traits/common_reference.h> +# include <__type_traits/common_type.h> +# include <__type_traits/conditional.h> +# include <__type_traits/conjunction.h> +# include <__type_traits/copy_cvref.h> +# include <__type_traits/disjunction.h> +# include <__type_traits/enable_if.h> +# include <__type_traits/invoke.h> +# include <__type_traits/is_arithmetic.h> +# include <__type_traits/is_assignable.h> +# include <__type_traits/is_constructible.h> +# include <__type_traits/is_convertible.h> +# include <__type_traits/is_empty.h> +# include <__type_traits/is_final.h> +# include <__type_traits/is_implicitly_default_constructible.h> +# include <__type_traits/is_nothrow_assignable.h> +# include <__type_traits/is_nothrow_constructible.h> +# include <__type_traits/is_reference.h> +# include <__type_traits/is_same.h> +# include <__type_traits/is_swappable.h> +# include <__type_traits/is_trivially_relocatable.h> +# include <__type_traits/lazy.h> +# include <__type_traits/maybe_const.h> +# include <__type_traits/nat.h> +# include <__type_traits/negation.h> +# include <__type_traits/remove_cvref.h> +# include <__type_traits/remove_reference.h> +# include <__type_traits/unwrap_ref.h> +# include <__utility/declval.h> +# include <__utility/forward.h> +# include <__utility/integer_sequence.h> +# include <__utility/move.h> +# include <__utility/piecewise_construct.h> +# include <__utility/swap.h> +# include +# include // standard-mandated includes // [tuple.syn] -#include +# include -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG // __tuple_leaf @@ -305,11 +310,11 @@ class __tuple_leaf { template static _LIBCPP_HIDE_FROM_ABI constexpr bool __can_bind_reference() { -# if __has_keyword(__reference_binds_to_temporary) +# if __has_keyword(__reference_binds_to_temporary) return !__reference_binds_to_temporary(_Hp, _Tp); -# else +# else return true; -# endif +# endif } public: @@ -693,7 +698,7 @@ public: tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t) : __base_(allocator_arg_t(), __a, __t) {} -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 // tuple(tuple&) constructors (including allocator_arg_t variants) template &>::value>* = nullptr> @@ -704,7 +709,7 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value) tuple(allocator_arg_t, const _Alloc& __alloc, tuple<_Up...>& __t) : __base_(allocator_arg_t(), __alloc, __t) {} -# endif // _LIBCPP_STD_VER >= 23 +# endif // _LIBCPP_STD_VER >= 23 // tuple(tuple&&) constructors (including allocator_arg_t variants) template &&> >::value, int> = 0> @@ -719,7 +724,7 @@ public: tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t) : __base_(allocator_arg_t(), __a, std::move(__t)) {} -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 // tuple(const tuple&&) constructors (including allocator_arg_t variants) template &&>::value>* = nullptr> @@ -733,7 +738,7 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible...>::value) tuple(allocator_arg_t, const _Alloc& __alloc, const tuple<_Up...>&& __t) : __base_(allocator_arg_t(), __alloc, std::move(__t)) {} -# endif // _LIBCPP_STD_VER >= 23 +# endif // _LIBCPP_STD_VER >= 23 // tuple(const pair&) constructors (including allocator_arg_t variants) @@ -779,7 +784,7 @@ public: tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p) : __base_(allocator_arg_t(), __a, __p) {} -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 // tuple(pair&) constructors (including allocator_arg_t variants) template &>::value>* = nullptr> @@ -794,7 +799,7 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible&>::value) tuple(allocator_arg_t, const _Alloc& __alloc, pair<_U1, _U2>& __p) : __base_(allocator_arg_t(), __alloc, __p) {} -# endif +# endif // tuple(pair&&) constructors (including allocator_arg_t variants) @@ -817,7 +822,7 @@ public: tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p) : __base_(allocator_arg_t(), __a, std::move(__p)) {} -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 // tuple(const pair&&) constructors (including allocator_arg_t variants) template &&>::value>* = nullptr> @@ -832,7 +837,7 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible&&>::value) tuple(allocator_arg_t, const _Alloc& __alloc, const pair<_U1, _U2>&& __p) : __base_(allocator_arg_t(), __alloc, std::move(__p)) {} -# endif // _LIBCPP_STD_VER >= 23 +# endif // _LIBCPP_STD_VER >= 23 // [tuple.assign] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& @@ -842,7 +847,7 @@ public: return *this; } -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple const& __tuple) const requires(_And...>::value) { @@ -857,7 +862,7 @@ public: *this, std::move(__tuple), __tuple_types<_Tp...>(), typename __make_tuple_indices::type()); return *this; } -# endif // _LIBCPP_STD_VER >= 23 +# endif // _LIBCPP_STD_VER >= 23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(_If<_And...>::value, tuple, __nat>&& __tuple) noexcept( @@ -887,7 +892,7 @@ public: return *this; } -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template , is_assignable...>::value>* = nullptr> @@ -904,7 +909,7 @@ public: *this, __u, __tuple_types<_UTypes...>(), typename __make_tuple_indices::type()); return *this; } -# endif // _LIBCPP_STD_VER >= 23 +# endif // _LIBCPP_STD_VER >= 23 template