diff --git a/.clang-format b/.clang-format index 525a846df7f..0ffd390f783 100644 --- a/.clang-format +++ b/.clang-format @@ -1,7 +1,18 @@ # Copyright (c) Microsoft Corporation. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# https://releases.llvm.org/17.0.1/tools/clang/docs/ClangFormatStyleOptions.html +# https://releases.llvm.org/18.1.8/tools/clang/docs/ClangFormatStyleOptions.html + +# To update this .clang-format file for a new clang-format version: +# 1. Update the documentation link above. +# 2. Copy the output of `clang-format -dump-config` into a temporary file. +# a. Comment out all of its lines. +# b. Uncomment `BasedOnStyle: LLVM`. +# 3. Compare that temporary file to this .clang-format file. +# 4. Adjust this .clang-format file to record new and updated options. +# a. Read the new documentation to understand such changes. +# 5. The goal is for the comparison from the temporary file to this .clang-format file to be pure additions (green). +# a. That is, comments here are recording the defaults, while added lines are our customized settings. --- # Language: Cpp @@ -11,12 +22,12 @@ AccessModifierOffset: -4 # AlignAfterOpenBracket: Align AlignAfterOpenBracket: DontAlign # AlignArrayOfStructures: None -# TRANSITION, LLVM-51935 (try using AlignArrayOfStructures after this crash is fixed) # AlignConsecutiveAssignments: # Enabled: false # AcrossEmptyLines: false # AcrossComments: false # AlignCompound: false +# AlignFunctionPointers: false # PadOperators: true AlignConsecutiveAssignments: Consecutive # AlignConsecutiveBitFields: @@ -24,18 +35,21 @@ AlignConsecutiveAssignments: Consecutive # AcrossEmptyLines: false # AcrossComments: false # AlignCompound: false +# AlignFunctionPointers: false # PadOperators: false # AlignConsecutiveDeclarations: # Enabled: false # AcrossEmptyLines: false # AcrossComments: false # AlignCompound: false +# AlignFunctionPointers: false # PadOperators: false # AlignConsecutiveMacros: # Enabled: false # AcrossEmptyLines: false # AcrossComments: false # AlignCompound: false +# AlignFunctionPointers: false # PadOperators: false AlignConsecutiveMacros: Consecutive # AlignConsecutiveShortCaseStatements: @@ -54,8 +68,11 @@ AlignTrailingComments: Kind: Never # AllowAllArgumentsOnNextLine: true # AllowAllParametersOfDeclarationOnNextLine: true +# AllowBreakBeforeNoexceptSpecifier: Never +AllowBreakBeforeNoexceptSpecifier: OnlyWithParen # AllowShortBlocksOnASingleLine: Never # AllowShortCaseLabelsOnASingleLine: false +# AllowShortCompoundRequirementOnASingleLine: true # AllowShortEnumsOnASingleLine: true # AllowShortFunctionsOnASingleLine: All AllowShortFunctionsOnASingleLine: Empty @@ -91,7 +108,9 @@ AlwaysBreakTemplateDeclarations: Yes # SplitEmptyFunction: true # SplitEmptyRecord: true # SplitEmptyNamespace: true -# BreakAfterAttributes: Never +# BreakAdjacentStringLiterals: true +# BreakAfterAttributes: Leave +BreakAfterAttributes: Never # BreakAfterJavaFieldAnnotations: false # BreakArrays: true # BreakBeforeBinaryOperators: None @@ -138,20 +157,23 @@ IncludeBlocks: Regroup # SortPriority: 0 # CaseSensitive: false IncludeCategories: - - Regex: '^$' - Priority: 1 - - Regex: '^<(Windows|userenv)\.h>$' - Priority: 3 - SortPriority: 3 - - Regex: '^$' - Priority: 3 - SortPriority: 4 - - Regex: '^<__.*\.hpp>$' - Priority: 2 + - Regex: '^<(yvals|yvals_core)\.h>$' + Priority: 10 + - Regex: '^<__msvc_.*\.hpp>$' + Priority: 20 + - Regex: '^$' # should be included before any header that includes + Priority: 30 + SortPriority: 30 + - Regex: '^<(DbgEng|DbgHelp|Shlwapi|Windows)\.h>$' + Priority: 30 + SortPriority: 31 + - Regex: '^$' + Priority: 30 + SortPriority: 32 - Regex: '\.hpp[>"]$' - Priority: 5 + Priority: 40 - Regex: '.*' - Priority: 2 + Priority: 20 # IncludeIsMainRegex: '(Test)?$' # IncludeIsMainSourceRegex: '' # IndentAccessModifiers: false @@ -203,6 +225,7 @@ NamespaceIndentation: All # PenaltyBreakComment: 300 # PenaltyBreakFirstLessLess: 120 # PenaltyBreakOpenParenthesis: 0 +# PenaltyBreakScopeResolution: 500 # PenaltyBreakString: 1000 # PenaltyBreakTemplateDeclaration: 10 # PenaltyExcessCharacter: 1000000 @@ -222,6 +245,7 @@ RemoveSemicolon: true # RequiresExpressionIndentation: OuterScope # SeparateDefinitionBlocks: Leave # ShortNamespaceLines: 1 +# SkipMacroDefinitionBody: false # SortIncludes: CaseSensitive # SortJavaStaticImport: Before # SortUsingDeclarations: LexicographicNumeric @@ -244,6 +268,7 @@ SpaceAfterCStyleCast: true # AfterFunctionDeclarationName: false # AfterIfMacros: true # AfterOverloadedOperator: false +# AfterPlacementOperator: true # AfterRequiresInClause: false # AfterRequiresInExpression: false # BeforeNonEmptyParentheses: false diff --git a/README.md b/README.md index 84077532aee..e5631dc1c8d 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ Just try to follow these rules, so we can spend more time fixing bugs and implem # How To Build With The Visual Studio IDE -1. Install Visual Studio 2022 17.12 Preview 1 or later. +1. Install Visual Studio 2022 17.12 Preview 2 or later. * Select "Windows 11 SDK (10.0.22621.0)" in the VS Installer. * Select "MSVC v143 - VS 2022 C++ ARM64/ARM64EC build tools (Latest)" in the VS Installer if you would like to build the ARM64/ARM64EC target. @@ -160,7 +160,7 @@ Just try to follow these rules, so we can spend more time fixing bugs and implem # How To Build With A Native Tools Command Prompt -1. Install Visual Studio 2022 17.12 Preview 1 or later. +1. Install Visual Studio 2022 17.12 Preview 2 or later. * Select "Windows 11 SDK (10.0.22621.0)" in the VS Installer. * Select "MSVC v143 - VS 2022 C++ ARM64/ARM64EC build tools (Latest)" in the VS Installer if you would like to build the ARM64/ARM64EC target. diff --git a/azure-devops/config.yml b/azure-devops/config.yml index af1ef4d88f3..bc90f9f8e74 100644 --- a/azure-devops/config.yml +++ b/azure-devops/config.yml @@ -5,7 +5,7 @@ variables: - name: poolName - value: 'StlBuild-2024-08-14T0018-Pool' + value: 'StlBuild-2024-09-10T1506-Pool' readonly: true - name: poolDemands value: 'EnableSpotVM -equals false' diff --git a/azure-devops/provision-image.ps1 b/azure-devops/provision-image.ps1 index e864be37473..9117f0a8bd1 100644 --- a/azure-devops/provision-image.ps1 +++ b/azure-devops/provision-image.ps1 @@ -40,10 +40,10 @@ foreach ($workload in $VisualStudioWorkloads) { } # https://github.com/PowerShell/PowerShell/releases/latest -$PowerShellUrl = 'https://github.com/PowerShell/PowerShell/releases/download/v7.4.4/PowerShell-7.4.4-win-x64.msi' +$PowerShellUrl = 'https://github.com/PowerShell/PowerShell/releases/download/v7.4.5/PowerShell-7.4.5-win-x64.msi' $PowerShellArgs = @('/quiet', '/norestart') -$PythonUrl = 'https://www.python.org/ftp/python/3.12.5/python-3.12.5-amd64.exe' +$PythonUrl = 'https://www.python.org/ftp/python/3.12.6/python-3.12.6-amd64.exe' $PythonArgs = @('/quiet', 'InstallAllUsers=1', 'PrependPath=1', 'CompileAll=1', 'Include_doc=0') $CudaUrl = 'https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_551.61_windows.exe' diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 6b71cb76f25..31572a968f2 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -104,11 +104,10 @@ function(add_benchmark name) target_compile_features(benchmark-${name} PRIVATE cxx_std_${arg_CXX_STANDARD}) target_include_directories(benchmark-${name} PRIVATE inc) target_link_libraries(benchmark-${name} PRIVATE benchmark::benchmark) - # TRANSITION, google/benchmark#1450 - target_compile_definitions(benchmark-${name} PRIVATE BENCHMARK_STATIC_DEFINE) endfunction() add_benchmark(bitset_to_string src/bitset_to_string.cpp) +add_benchmark(efficient_nonlocking_print src/efficient_nonlocking_print.cpp) add_benchmark(find_and_count src/find_and_count.cpp) add_benchmark(find_first_of src/find_first_of.cpp) add_benchmark(iota src/iota.cpp) @@ -121,6 +120,7 @@ add_benchmark(random_integer_generation src/random_integer_generation.cpp) add_benchmark(replace src/replace.cpp) add_benchmark(search src/search.cpp) add_benchmark(std_copy src/std_copy.cpp) +add_benchmark(sv_equal src/sv_equal.cpp) add_benchmark(swap_ranges src/swap_ranges.cpp) add_benchmark(vector_bool_copy src/std/containers/sequences/vector.bool/copy/test.cpp) diff --git a/benchmarks/src/efficient_nonlocking_print.cpp b/benchmarks/src/efficient_nonlocking_print.cpp new file mode 100644 index 00000000000..d14973ddc9e --- /dev/null +++ b/benchmarks/src/efficient_nonlocking_print.cpp @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +// This benchmark inherently prints many lines to stdout. To view its results, run it with these options: +// --benchmark_out=efficient_nonlocking_print.log --benchmark_out_format=console + +#include +#include +#include +#include +#include +#include +#include + +namespace { + using PrintType = void (*)(FILE*, std::string_view, std::format_args); + + template + void BM_vprint(benchmark::State& state) { + for (auto _ : state) { + PrintFunction(stdout, "Hello cool I am going to print as unicode\n", std::make_format_args()); + } + } + BENCHMARK(BM_vprint<&std::vprint_unicode>); + BENCHMARK(BM_vprint<&std::vprint_unicode_buffered>); + + template + void BM_vprint_complex(benchmark::State& state) { + const int i = 42; + const std::string str = "Hello world!!!!!!!!!!!!!!!!!!!!!!!!"; + const double f = -902.16283758; + const std::pair p{16, 2.073f}; + for (auto _ : state) { + PrintFunction(stdout, + "Hello cool I am going to print as unicode!! {:X}, {}, {:a}, " + "I am a big string, lots of words, multiple {} formats\n", + std::make_format_args(i, str, f, p)); + } + } + BENCHMARK(BM_vprint_complex<&std::vprint_unicode>); + BENCHMARK(BM_vprint_complex<&std::vprint_unicode_buffered>); +} // namespace + +BENCHMARK_MAIN(); diff --git a/benchmarks/src/find_first_of.cpp b/benchmarks/src/find_first_of.cpp index 05731a18938..19ee1a340fc 100644 --- a/benchmarks/src/find_first_of.cpp +++ b/benchmarks/src/find_first_of.cpp @@ -7,20 +7,26 @@ #include #include #include +#include +#include #include using namespace std; -template +enum class AlgType : bool { std_func, str_member }; + +template void bm(benchmark::State& state) { const size_t Pos = static_cast(state.range(0)); const size_t NSize = static_cast(state.range(1)); const size_t HSize = Pos * 2; const size_t Which = 0; - vector h(HSize, T{'.'}); - vector n(NSize); - iota(n.begin(), n.end(), T{'a'}); + using container = conditional_t, vector>; + + container h(HSize, T{'.'}); + container n(NSize, T{0}); + iota(n.begin(), n.end(), Start); if (Pos >= HSize || Which >= NSize) { abort(); @@ -29,18 +35,28 @@ void bm(benchmark::State& state) { h[Pos] = n[Which]; for (auto _ : state) { - benchmark::DoNotOptimize(find_first_of(h.begin(), h.end(), n.begin(), n.end())); + benchmark::DoNotOptimize(h); + benchmark::DoNotOptimize(n); + if constexpr (Alg == AlgType::str_member) { + benchmark::DoNotOptimize(h.find_first_of(n.data(), 0, n.size())); + } else { + benchmark::DoNotOptimize(find_first_of(h.begin(), h.end(), n.begin(), n.end())); + } } } void common_args(auto bm) { bm->Args({2, 3})->Args({7, 4})->Args({9, 3})->Args({22, 5})->Args({58, 2}); - bm->Args({102, 4})->Args({325, 1})->Args({1011, 11})->Args({3056, 7}); + bm->Args({102, 4})->Args({325, 1})->Args({1011, 11})->Args({1502, 23})->Args({3056, 7}); } -BENCHMARK(bm)->Apply(common_args); -BENCHMARK(bm)->Apply(common_args); -BENCHMARK(bm)->Apply(common_args); -BENCHMARK(bm)->Apply(common_args); +BENCHMARK(bm)->Apply(common_args); +BENCHMARK(bm)->Apply(common_args); +BENCHMARK(bm)->Apply(common_args); +BENCHMARK(bm)->Apply(common_args); + +BENCHMARK(bm)->Apply(common_args); +BENCHMARK(bm)->Apply(common_args); +BENCHMARK(bm)->Apply(common_args); BENCHMARK_MAIN(); diff --git a/benchmarks/src/search.cpp b/benchmarks/src/search.cpp index a7423e6c63e..c6fad3d4fcc 100644 --- a/benchmarks/src/search.cpp +++ b/benchmarks/src/search.cpp @@ -2,12 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include +#include #include #include #include #include #include +#include #include +using namespace std::string_view_literals; const char src_haystack[] = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam mollis imperdiet massa, at dapibus elit interdum " @@ -40,9 +43,14 @@ const char src_haystack[] = "euismod eros, ut posuere ligula ullamcorper id. Nullam aliquet malesuada est at dignissim. Pellentesque finibus " "sagittis libero nec bibendum. Phasellus dolor ipsum, finibus quis turpis quis, mollis interdum felis."; -const char src_needle[] = "aliquet"; +constexpr std::array patterns = { + "aliquet"sv, + "aliquet malesuada"sv, +}; void c_strstr(benchmark::State& state) { + const auto& src_needle = patterns[static_cast(state.range())]; + const std::string haystack(std::begin(src_haystack), std::end(src_haystack)); const std::string needle(std::begin(src_needle), std::end(src_needle)); @@ -56,6 +64,8 @@ void c_strstr(benchmark::State& state) { template void classic_search(benchmark::State& state) { + const auto& src_needle = patterns[static_cast(state.range())]; + const std::vector haystack(std::begin(src_haystack), std::end(src_haystack)); const std::vector needle(std::begin(src_needle), std::end(src_needle)); @@ -69,6 +79,8 @@ void classic_search(benchmark::State& state) { template void ranges_search(benchmark::State& state) { + const auto& src_needle = patterns[static_cast(state.range())]; + const std::vector haystack(std::begin(src_haystack), std::end(src_haystack)); const std::vector needle(std::begin(src_needle), std::end(src_needle)); @@ -82,6 +94,8 @@ void ranges_search(benchmark::State& state) { template void search_default_searcher(benchmark::State& state) { + const auto& src_needle = patterns[static_cast(state.range())]; + const std::vector haystack(std::begin(src_haystack), std::end(src_haystack)); const std::vector needle(std::begin(src_needle), std::end(src_needle)); @@ -93,22 +107,26 @@ void search_default_searcher(benchmark::State& state) { } } -BENCHMARK(c_strstr); +void common_args(auto bm) { + bm->Range(0, patterns.size() - 1); +} + +BENCHMARK(c_strstr)->Apply(common_args); -BENCHMARK(classic_search); -BENCHMARK(classic_search); -BENCHMARK(classic_search); -BENCHMARK(classic_search); +BENCHMARK(classic_search)->Apply(common_args); +BENCHMARK(classic_search)->Apply(common_args); +BENCHMARK(classic_search)->Apply(common_args); +BENCHMARK(classic_search)->Apply(common_args); -BENCHMARK(ranges_search); -BENCHMARK(ranges_search); -BENCHMARK(ranges_search); -BENCHMARK(ranges_search); +BENCHMARK(ranges_search)->Apply(common_args); +BENCHMARK(ranges_search)->Apply(common_args); +BENCHMARK(ranges_search)->Apply(common_args); +BENCHMARK(ranges_search)->Apply(common_args); -BENCHMARK(search_default_searcher); -BENCHMARK(search_default_searcher); -BENCHMARK(search_default_searcher); -BENCHMARK(search_default_searcher); +BENCHMARK(search_default_searcher)->Apply(common_args); +BENCHMARK(search_default_searcher)->Apply(common_args); +BENCHMARK(search_default_searcher)->Apply(common_args); +BENCHMARK(search_default_searcher)->Apply(common_args); BENCHMARK_MAIN(); diff --git a/benchmarks/src/sv_equal.cpp b/benchmarks/src/sv_equal.cpp new file mode 100644 index 00000000000..ee47ab63c87 --- /dev/null +++ b/benchmarks/src/sv_equal.cpp @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include +#include +#include +#include + +using namespace std::string_view_literals; + +constexpr auto haystack = + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam mollis imperdiet massa, at dapibus elit " + "interdumac. In eget sollicitudin mi. Nam at tellus at sapien tincidunt sollicitudin vel non eros. Pellentesque " + "nunc nunc,ullamcorper eu accumsan at, pulvinar non turpis. Quisque vel mauris pulvinar, pretium purus vel, " + "ultricies erat.Curabitur a magna in ligula tristique ornare. Quisque commodo, massa viverra laoreet luctus, sem " + "nisi aliquamvelit, fermentum pulvinar velit leo eget justo. Suspendisse vel erat efficitur, pulvinar eros " + "volutpat, vulputateex. Phasellus non purus vel velit tristique tristique id at ligula. Quisque mollis sodales " + "magna. Mauris et quameu quam viverra tempus. Nullam tempus maximus porta. Nunc mattis eleifend fermentum. Nullam " + "aliquam liberoaccumsan velit elementum, eu laoreet metus convallis. Donec pellentesque lacus ut iaculis iaculis. " + "Curabitur orcielit, bibendum sit amet feugiat at, iaculis sit amet massa. Maecenas imperdiet lacus at vehicula " + "iaculis. Donecvolutpat nunc sit amet accumsan tempor. Quisque pretium vestibulum ultricies. Suspendisse potenti. " + "Aenean at diamiaculis, condimentum felis venenatis, condimentum erat. Nam quis elit dui. Duis quis odio vitae " + "metus hendreritrhoncus ut et magna. Cras ac augue quis nibh pharetra sagittis. Donec ullamcorper vel eros semper " + "pretium. Proinvel sollicitudin eros. Nulla sollicitudin mattis turpis id suscipit. Aliquam sed risus velit. " + "Aliquam iaculis necnibh ac egestas. Duis finibus semper est sed consequat. Sed in sapien quis nibh dignissim " + "mattis. Vestibulum necmetus sodales, euismod mauris ac, sollicitudin libero. Maecenas non arcu ac velit " + "ullamcorper fringilla et quisnulla. Curabitur posuere leo eget ipsum tincidunt dignissim. Cras ultricies suscipit " + "neque, quis suscipit tortorvenenatis non. Cras nisl mi, bibendum in vulputate quis, vestibulum ornare enim. Nunc " + "hendrerit placerat dui,aliquam mollis sem convallis et. Integer vitae urna diam. Phasellus et imperdiet est. " + "Maecenas auctor facilisisnibh non commodo. Suspendisse iaculis quam "sv; + +constexpr std::size_t Count = 8u; + +template +constexpr std::array make_svs() { + std::array result{}; + + if constexpr (Length != 0) { + using namespace std::views; + + std::ranges::copy( + haystack | chunk(Length) | transform([](auto&& t) { return std::string_view(t); }) | take(Count), + result.begin()); + } + + return result; +} + +template +void sv_equal(benchmark::State& state) { + constexpr auto arr = make_svs(); + benchmark::DoNotOptimize(arr); + + for (auto _ : state) { + for (auto& i : arr) { + benchmark::DoNotOptimize(i); + auto res = (i == arr[0]); + benchmark::DoNotOptimize(res); + } + } +} + +BENCHMARK(sv_equal<0>); +BENCHMARK(sv_equal<8>); +BENCHMARK(sv_equal<16>); +BENCHMARK(sv_equal<32>); +BENCHMARK(sv_equal<64>); +BENCHMARK(sv_equal<128>); +BENCHMARK(sv_equal<256>); + +static_assert(haystack.size() >= Count * 256, "haystack is too small"); + +BENCHMARK_MAIN(); diff --git a/llvm-project b/llvm-project index 1b7631a699e..886b76128fb 160000 --- a/llvm-project +++ b/llvm-project @@ -1 +1 @@ -Subproject commit 1b7631a699e6af7f497548a1ceb5be0570c60ed0 +Subproject commit 886b76128fba5f995c8c8e24aaa2030b59dec01a diff --git a/stl/CMakeLists.txt b/stl/CMakeLists.txt index 9881ad8388a..b4e0f31a159 100644 --- a/stl/CMakeLists.txt +++ b/stl/CMakeLists.txt @@ -17,6 +17,7 @@ set(HEADERS ${CMAKE_CURRENT_LIST_DIR}/inc/__msvc_int128.hpp ${CMAKE_CURRENT_LIST_DIR}/inc/__msvc_iter_core.hpp ${CMAKE_CURRENT_LIST_DIR}/inc/__msvc_minmax.hpp + ${CMAKE_CURRENT_LIST_DIR}/inc/__msvc_ostream.hpp ${CMAKE_CURRENT_LIST_DIR}/inc/__msvc_print.hpp ${CMAKE_CURRENT_LIST_DIR}/inc/__msvc_ranges_to.hpp ${CMAKE_CURRENT_LIST_DIR}/inc/__msvc_sanitizer_annotate_container.hpp diff --git a/stl/inc/__msvc_bit_utils.hpp b/stl/inc/__msvc_bit_utils.hpp index eb86c43d0f4..48567e8d523 100644 --- a/stl/inc/__msvc_bit_utils.hpp +++ b/stl/inc/__msvc_bit_utils.hpp @@ -127,24 +127,6 @@ _NODISCARD int _Checked_x86_x64_countl_zero(const _Ty _Val) noexcept { #endif // (defined(_M_IX86) && !defined(_M_HYBRID_X86_ARM64)) || (defined(_M_X64) && !defined(_M_ARM64EC)) #if defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC) || defined(_M_HYBRID_X86_ARM64) -#ifdef __clang__ // TRANSITION, GH-1586 -_NODISCARD constexpr int _Clang_arm_arm64_countl_zero(const unsigned short _Val) { - return __builtin_clzs(_Val); -} - -_NODISCARD constexpr int _Clang_arm_arm64_countl_zero(const unsigned int _Val) { - return __builtin_clz(_Val); -} - -_NODISCARD constexpr int _Clang_arm_arm64_countl_zero(const unsigned long _Val) { - return __builtin_clzl(_Val); -} - -_NODISCARD constexpr int _Clang_arm_arm64_countl_zero(const unsigned long long _Val) { - return __builtin_clzll(_Val); -} -#endif // TRANSITION, GH-1586 - template _NODISCARD int _Checked_arm_arm64_countl_zero(const _Ty _Val) noexcept { constexpr int _Digits = _Unsigned_integer_digits<_Ty>; @@ -152,20 +134,11 @@ _NODISCARD int _Checked_arm_arm64_countl_zero(const _Ty _Val) noexcept { return _Digits; } -#ifdef __clang__ // TRANSITION, GH-1586 - if constexpr (is_same_v, unsigned char>) { - return _Clang_arm_arm64_countl_zero(static_cast(_Val)) - - (_Unsigned_integer_digits - _Digits); - } else { - return _Clang_arm_arm64_countl_zero(_Val); - } -#else // ^^^ workaround / no workaround vvv if constexpr (_Digits <= 32) { return static_cast(_CountLeadingZeros(_Val)) - (_Unsigned_integer_digits - _Digits); } else { return static_cast(_CountLeadingZeros64(_Val)); } -#endif // ^^^ no workaround ^^^ } #endif // defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC) || defined(_M_HYBRID_X86_ARM64) #endif // _HAS_COUNTL_ZERO_INTRINSICS diff --git a/stl/inc/__msvc_chrono.hpp b/stl/inc/__msvc_chrono.hpp index 08268b83b84..226df1df848 100644 --- a/stl/inc/__msvc_chrono.hpp +++ b/stl/inc/__msvc_chrono.hpp @@ -84,8 +84,8 @@ namespace chrono { constexpr bool _Is_duration_v = _Is_specialization_v<_Ty, duration>; _EXPORT_STD template , int> = 0> - constexpr _To duration_cast(const duration<_Rep, _Period>&) noexcept( - is_arithmetic_v<_Rep> && is_arithmetic_v); // strengthened + constexpr _To duration_cast(const duration<_Rep, _Period>&) + noexcept(is_arithmetic_v<_Rep> && is_arithmetic_v); // strengthened _EXPORT_STD template class duration { // represents a time duration @@ -103,16 +103,16 @@ namespace chrono { enable_if_t && (treat_as_floating_point_v<_Rep> || !treat_as_floating_point_v<_Rep2>), int> = 0> - constexpr explicit duration(const _Rep2& _Val) noexcept( - is_arithmetic_v<_Rep> && is_arithmetic_v<_Rep2>) // strengthened + constexpr explicit duration(const _Rep2& _Val) + noexcept(is_arithmetic_v<_Rep> && is_arithmetic_v<_Rep2>) // strengthened : _MyRep(static_cast<_Rep>(_Val)) {} template || (_Ratio_divide_sfinae<_Period2, _Period>::den == 1 && !treat_as_floating_point_v<_Rep2>), int> = 0> - constexpr duration(const duration<_Rep2, _Period2>& _Dur) noexcept( - is_arithmetic_v<_Rep> && is_arithmetic_v<_Rep2>) // strengthened + constexpr duration(const duration<_Rep2, _Period2>& _Dur) + noexcept(is_arithmetic_v<_Rep> && is_arithmetic_v<_Rep2>) // strengthened : _MyRep(_CHRONO duration_cast(_Dur).count()) {} _NODISCARD constexpr _Rep count() const noexcept(is_arithmetic_v<_Rep>) /* strengthened */ { @@ -213,8 +213,8 @@ namespace chrono { : _MyDur(_Other) {} template , int> = 0> - constexpr time_point(const time_point<_Clock, _Duration2>& _Tp) noexcept( - is_arithmetic_v && is_arithmetic_v) // strengthened + constexpr time_point(const time_point<_Clock, _Duration2>& _Tp) + noexcept(is_arithmetic_v && is_arithmetic_v) // strengthened : _MyDur(_Tp.time_since_epoch()) {} _NODISCARD constexpr _Duration time_since_epoch() const noexcept(is_arithmetic_v) /* strengthened */ { @@ -285,17 +285,17 @@ struct common_type<_CHRONO time_point<_Clock, _Duration1>, namespace chrono { _EXPORT_STD template - _NODISCARD constexpr common_type_t, duration<_Rep2, _Period2>> - operator+(const duration<_Rep1, _Period1>& _Left, const duration<_Rep2, _Period2>& _Right) noexcept( - is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { + _NODISCARD constexpr common_type_t, duration<_Rep2, _Period2>> operator+( + const duration<_Rep1, _Period1>& _Left, const duration<_Rep2, _Period2>& _Right) + noexcept(is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { using _CD = common_type_t, duration<_Rep2, _Period2>>; return _CD(_CD(_Left).count() + _CD(_Right).count()); } _EXPORT_STD template - _NODISCARD constexpr common_type_t, duration<_Rep2, _Period2>> - operator-(const duration<_Rep1, _Period1>& _Left, const duration<_Rep2, _Period2>& _Right) noexcept( - is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { + _NODISCARD constexpr common_type_t, duration<_Rep2, _Period2>> operator-( + const duration<_Rep1, _Period1>& _Left, const duration<_Rep2, _Period2>& _Right) + noexcept(is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { using _CD = common_type_t, duration<_Rep2, _Period2>>; return _CD(_CD(_Left).count() - _CD(_Right).count()); } @@ -303,8 +303,8 @@ namespace chrono { _EXPORT_STD template >, int> = 0> _NODISCARD constexpr duration, _Period1> operator*( - const duration<_Rep1, _Period1>& _Left, - const _Rep2& _Right) noexcept(is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { + const duration<_Rep1, _Period1>& _Left, const _Rep2& _Right) + noexcept(is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { using _CR = common_type_t<_Rep1, _Rep2>; using _CD = duration<_CR, _Period1>; return _CD(_CD(_Left).count() * _Right); @@ -312,9 +312,9 @@ namespace chrono { _EXPORT_STD template >, int> = 0> - _NODISCARD constexpr duration, _Period2> operator*(const _Rep1& _Left, - const duration<_Rep2, _Period2>& _Right) noexcept(is_arithmetic_v<_Rep1> - && is_arithmetic_v<_Rep2>) /* strengthened */ { + _NODISCARD constexpr duration, _Period2> operator*( + const _Rep1& _Left, const duration<_Rep2, _Period2>& _Right) + noexcept(is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { return _Right * _Left; } @@ -336,98 +336,96 @@ namespace chrono { _EXPORT_STD template _NODISCARD constexpr typename _Duration_div_mod, _Period1, _Rep2>::type operator/( - const duration<_Rep1, _Period1>& _Left, - const _Rep2& _Right) noexcept(is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { + const duration<_Rep1, _Period1>& _Left, const _Rep2& _Right) + noexcept(is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { using _CR = common_type_t<_Rep1, _Rep2>; using _CD = duration<_CR, _Period1>; return _CD(_CD(_Left).count() / _Right); } _EXPORT_STD template - _NODISCARD constexpr common_type_t<_Rep1, _Rep2> operator/(const duration<_Rep1, _Period1>& _Left, - const duration<_Rep2, _Period2>& _Right) noexcept(is_arithmetic_v<_Rep1> - && is_arithmetic_v<_Rep2>) /* strengthened */ { + _NODISCARD constexpr common_type_t<_Rep1, _Rep2> operator/( + const duration<_Rep1, _Period1>& _Left, const duration<_Rep2, _Period2>& _Right) + noexcept(is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { using _CD = common_type_t, duration<_Rep2, _Period2>>; return _CD(_Left).count() / _CD(_Right).count(); } _EXPORT_STD template _NODISCARD constexpr typename _Duration_div_mod, _Period1, _Rep2>::type operator%( - const duration<_Rep1, _Period1>& _Left, - const _Rep2& _Right) noexcept(is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { + const duration<_Rep1, _Period1>& _Left, const _Rep2& _Right) + noexcept(is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { using _CR = common_type_t<_Rep1, _Rep2>; using _CD = duration<_CR, _Period1>; return _CD(_CD(_Left).count() % _Right); } _EXPORT_STD template - _NODISCARD constexpr common_type_t, duration<_Rep2, _Period2>> - operator%(const duration<_Rep1, _Period1>& _Left, const duration<_Rep2, _Period2>& _Right) noexcept( - is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { + _NODISCARD constexpr common_type_t, duration<_Rep2, _Period2>> operator%( + const duration<_Rep1, _Period1>& _Left, const duration<_Rep2, _Period2>& _Right) + noexcept(is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { using _CD = common_type_t, duration<_Rep2, _Period2>>; return _CD(_CD(_Left).count() % _CD(_Right).count()); } _EXPORT_STD template - _NODISCARD constexpr bool operator==(const duration<_Rep1, _Period1>& _Left, - const duration<_Rep2, _Period2>& _Right) noexcept(is_arithmetic_v<_Rep1> - && is_arithmetic_v<_Rep2>) /* strengthened */ { + _NODISCARD constexpr bool operator==( + const duration<_Rep1, _Period1>& _Left, const duration<_Rep2, _Period2>& _Right) + noexcept(is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { using _CT = common_type_t, duration<_Rep2, _Period2>>; return _CT(_Left).count() == _CT(_Right).count(); } #if !_HAS_CXX20 template - _NODISCARD constexpr bool operator!=(const duration<_Rep1, _Period1>& _Left, - const duration<_Rep2, _Period2>& _Right) noexcept(is_arithmetic_v<_Rep1> - && is_arithmetic_v<_Rep2>) /* strengthened */ { + _NODISCARD constexpr bool operator!=( + const duration<_Rep1, _Period1>& _Left, const duration<_Rep2, _Period2>& _Right) + noexcept(is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { return !(_Left == _Right); } #endif // !_HAS_CXX20 _EXPORT_STD template - _NODISCARD constexpr bool operator<(const duration<_Rep1, _Period1>& _Left, - const duration<_Rep2, _Period2>& _Right) noexcept(is_arithmetic_v<_Rep1> - && is_arithmetic_v<_Rep2>) /* strengthened */ { + _NODISCARD constexpr bool operator<(const duration<_Rep1, _Period1>& _Left, const duration<_Rep2, _Period2>& _Right) + noexcept(is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { using _CT = common_type_t, duration<_Rep2, _Period2>>; return _CT(_Left).count() < _CT(_Right).count(); } _EXPORT_STD template - _NODISCARD constexpr bool operator<=(const duration<_Rep1, _Period1>& _Left, - const duration<_Rep2, _Period2>& _Right) noexcept(is_arithmetic_v<_Rep1> - && is_arithmetic_v<_Rep2>) /* strengthened */ { + _NODISCARD constexpr bool operator<=( + const duration<_Rep1, _Period1>& _Left, const duration<_Rep2, _Period2>& _Right) + noexcept(is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { return !(_Right < _Left); } _EXPORT_STD template - _NODISCARD constexpr bool operator>(const duration<_Rep1, _Period1>& _Left, - const duration<_Rep2, _Period2>& _Right) noexcept(is_arithmetic_v<_Rep1> - && is_arithmetic_v<_Rep2>) /* strengthened */ { + _NODISCARD constexpr bool operator>(const duration<_Rep1, _Period1>& _Left, const duration<_Rep2, _Period2>& _Right) + noexcept(is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { return _Right < _Left; } _EXPORT_STD template - _NODISCARD constexpr bool operator>=(const duration<_Rep1, _Period1>& _Left, - const duration<_Rep2, _Period2>& _Right) noexcept(is_arithmetic_v<_Rep1> - && is_arithmetic_v<_Rep2>) /* strengthened */ { + _NODISCARD constexpr bool operator>=( + const duration<_Rep1, _Period1>& _Left, const duration<_Rep2, _Period2>& _Right) + noexcept(is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { return !(_Left < _Right); } #if _HAS_CXX20 _EXPORT_STD template requires three_way_comparable, duration<_Rep2, _Period2>>::rep> - _NODISCARD constexpr auto operator<=>(const duration<_Rep1, _Period1>& _Left, - const duration<_Rep2, _Period2>& _Right) noexcept(is_arithmetic_v<_Rep1> - && is_arithmetic_v<_Rep2>) /* strengthened */ { + _NODISCARD constexpr auto operator<=>( + const duration<_Rep1, _Period1>& _Left, const duration<_Rep2, _Period2>& _Right) + noexcept(is_arithmetic_v<_Rep1> && is_arithmetic_v<_Rep2>) /* strengthened */ { using _CT = common_type_t, duration<_Rep2, _Period2>>; return _CT(_Left).count() <=> _CT(_Right).count(); } #endif // _HAS_CXX20 _EXPORT_STD template , int> /* = 0 */> - _NODISCARD constexpr _To duration_cast(const duration<_Rep, _Period>& _Dur) noexcept( - is_arithmetic_v<_Rep> && is_arithmetic_v) /* strengthened */ { + _NODISCARD constexpr _To duration_cast(const duration<_Rep, _Period>& _Dur) + noexcept(is_arithmetic_v<_Rep> && is_arithmetic_v) /* strengthened */ { // convert duration to another duration; truncate using _CF = ratio_divide<_Period, typename _To::period>; @@ -456,8 +454,8 @@ namespace chrono { } _EXPORT_STD template , int> = 0> - _NODISCARD constexpr _To floor(const duration<_Rep, _Period>& _Dur) noexcept( - is_arithmetic_v<_Rep> && is_arithmetic_v) /* strengthened */ { + _NODISCARD constexpr _To floor(const duration<_Rep, _Period>& _Dur) + noexcept(is_arithmetic_v<_Rep> && is_arithmetic_v) /* strengthened */ { // convert duration to another duration; round towards negative infinity // i.e. the greatest integral result such that the result <= _Dur const _To _Casted{_CHRONO duration_cast<_To>(_Dur)}; @@ -469,8 +467,8 @@ namespace chrono { } _EXPORT_STD template , int> = 0> - _NODISCARD constexpr _To ceil(const duration<_Rep, _Period>& _Dur) noexcept( - is_arithmetic_v<_Rep> && is_arithmetic_v) /* strengthened */ { + _NODISCARD constexpr _To ceil(const duration<_Rep, _Period>& _Dur) + noexcept(is_arithmetic_v<_Rep> && is_arithmetic_v) /* strengthened */ { // convert duration to another duration; round towards positive infinity // i.e. the least integral result such that _Dur <= the result const _To _Casted{_CHRONO duration_cast<_To>(_Dur)}; @@ -489,8 +487,8 @@ namespace chrono { _EXPORT_STD template && !treat_as_floating_point_v, int> = 0> - _NODISCARD constexpr _To round(const duration<_Rep, _Period>& _Dur) noexcept( - is_arithmetic_v<_Rep> && is_arithmetic_v) /* strengthened */ { + _NODISCARD constexpr _To round(const duration<_Rep, _Period>& _Dur) + noexcept(is_arithmetic_v<_Rep> && is_arithmetic_v) /* strengthened */ { // convert duration to another duration, round to nearest, ties to even const _To _Floored{_CHRONO floor<_To>(_Dur)}; const _To _Ceiled{_Floored + _To{1}}; @@ -505,8 +503,8 @@ namespace chrono { } _EXPORT_STD template ::is_signed, int> = 0> - _NODISCARD constexpr duration<_Rep, _Period> abs(const duration<_Rep, _Period> _Dur) noexcept( - is_arithmetic_v<_Rep>) /* strengthened */ { + _NODISCARD constexpr duration<_Rep, _Period> abs(const duration<_Rep, _Period> _Dur) + noexcept(is_arithmetic_v<_Rep>) /* strengthened */ { // create a duration whose count() is the absolute value of _Dur.count() if (_Dur < duration<_Rep, _Period>::zero()) { return -_Dur; @@ -529,113 +527,121 @@ namespace chrono { #endif // _HAS_CXX20 _EXPORT_STD template - _NODISCARD constexpr time_point<_Clock, common_type_t<_Duration, duration<_Rep, _Period>>> - operator+(const time_point<_Clock, _Duration>& _Left, const duration<_Rep, _Period>& _Right) noexcept( - is_arithmetic_v && is_arithmetic_v<_Rep>) /* strengthened */ { + _NODISCARD constexpr time_point<_Clock, common_type_t<_Duration, duration<_Rep, _Period>>> operator+( + const time_point<_Clock, _Duration>& _Left, const duration<_Rep, _Period>& _Right) + noexcept(is_arithmetic_v && is_arithmetic_v<_Rep>) /* strengthened */ { using _RT = time_point<_Clock, common_type_t<_Duration, duration<_Rep, _Period>>>; return _RT(_Left.time_since_epoch() + _Right); } _EXPORT_STD template - _NODISCARD constexpr time_point<_Clock, common_type_t, _Duration>> - operator+(const duration<_Rep, _Period>& _Left, const time_point<_Clock, _Duration>& _Right) noexcept( - is_arithmetic_v<_Rep> && is_arithmetic_v) /* strengthened */ { + _NODISCARD constexpr time_point<_Clock, common_type_t, _Duration>> operator+( + const duration<_Rep, _Period>& _Left, const time_point<_Clock, _Duration>& _Right) + noexcept(is_arithmetic_v<_Rep> && is_arithmetic_v) /* strengthened */ { return _Right + _Left; } _EXPORT_STD template - _NODISCARD constexpr time_point<_Clock, common_type_t<_Duration, duration<_Rep, _Period>>> - operator-(const time_point<_Clock, _Duration>& _Left, const duration<_Rep, _Period>& _Right) noexcept( - is_arithmetic_v && is_arithmetic_v<_Rep>) /* strengthened */ { + _NODISCARD constexpr time_point<_Clock, common_type_t<_Duration, duration<_Rep, _Period>>> operator-( + const time_point<_Clock, _Duration>& _Left, const duration<_Rep, _Period>& _Right) + noexcept(is_arithmetic_v && is_arithmetic_v<_Rep>) /* strengthened */ { using _RT = time_point<_Clock, common_type_t<_Duration, duration<_Rep, _Period>>>; return _RT(_Left.time_since_epoch() - _Right); } _EXPORT_STD template - _NODISCARD constexpr common_type_t<_Duration1, _Duration2> - operator-(const time_point<_Clock, _Duration1>& _Left, const time_point<_Clock, _Duration2>& _Right) noexcept( + _NODISCARD constexpr common_type_t<_Duration1, _Duration2> operator-( + const time_point<_Clock, _Duration1>& _Left, const time_point<_Clock, _Duration2>& _Right) + noexcept( is_arithmetic_v && is_arithmetic_v) /* strengthened */ { return _Left.time_since_epoch() - _Right.time_since_epoch(); } _EXPORT_STD template - _NODISCARD constexpr bool - operator==(const time_point<_Clock, _Duration1>& _Left, const time_point<_Clock, _Duration2>& _Right) noexcept( + _NODISCARD constexpr bool operator==( + const time_point<_Clock, _Duration1>& _Left, const time_point<_Clock, _Duration2>& _Right) + noexcept( is_arithmetic_v && is_arithmetic_v) /* strengthened */ { return _Left.time_since_epoch() == _Right.time_since_epoch(); } #if !_HAS_CXX20 template - _NODISCARD constexpr bool - operator!=(const time_point<_Clock, _Duration1>& _Left, const time_point<_Clock, _Duration2>& _Right) noexcept( + _NODISCARD constexpr bool operator!=( + const time_point<_Clock, _Duration1>& _Left, const time_point<_Clock, _Duration2>& _Right) + noexcept( is_arithmetic_v && is_arithmetic_v) /* strengthened */ { return !(_Left == _Right); } #endif // !_HAS_CXX20 _EXPORT_STD template - _NODISCARD constexpr bool - operator<(const time_point<_Clock, _Duration1>& _Left, const time_point<_Clock, _Duration2>& _Right) noexcept( + _NODISCARD constexpr bool operator<( + const time_point<_Clock, _Duration1>& _Left, const time_point<_Clock, _Duration2>& _Right) + noexcept( is_arithmetic_v && is_arithmetic_v) /* strengthened */ { return _Left.time_since_epoch() < _Right.time_since_epoch(); } _EXPORT_STD template - _NODISCARD constexpr bool - operator<=(const time_point<_Clock, _Duration1>& _Left, const time_point<_Clock, _Duration2>& _Right) noexcept( + _NODISCARD constexpr bool operator<=( + const time_point<_Clock, _Duration1>& _Left, const time_point<_Clock, _Duration2>& _Right) + noexcept( is_arithmetic_v && is_arithmetic_v) /* strengthened */ { return !(_Right < _Left); } _EXPORT_STD template - _NODISCARD constexpr bool - operator>(const time_point<_Clock, _Duration1>& _Left, const time_point<_Clock, _Duration2>& _Right) noexcept( + _NODISCARD constexpr bool operator>( + const time_point<_Clock, _Duration1>& _Left, const time_point<_Clock, _Duration2>& _Right) + noexcept( is_arithmetic_v && is_arithmetic_v) /* strengthened */ { return _Right < _Left; } _EXPORT_STD template - _NODISCARD constexpr bool - operator>=(const time_point<_Clock, _Duration1>& _Left, const time_point<_Clock, _Duration2>& _Right) noexcept( + _NODISCARD constexpr bool operator>=( + const time_point<_Clock, _Duration1>& _Left, const time_point<_Clock, _Duration2>& _Right) + noexcept( is_arithmetic_v && is_arithmetic_v) /* strengthened */ { return !(_Left < _Right); } #if _HAS_CXX20 _EXPORT_STD template _Duration2> - _NODISCARD constexpr auto - operator<=>(const time_point<_Clock, _Duration1>& _Left, const time_point<_Clock, _Duration2>& _Right) noexcept( + _NODISCARD constexpr auto operator<=>( + const time_point<_Clock, _Duration1>& _Left, const time_point<_Clock, _Duration2>& _Right) + noexcept( is_arithmetic_v && is_arithmetic_v) /* strengthened */ { return _Left.time_since_epoch() <=> _Right.time_since_epoch(); } #endif // _HAS_CXX20 _EXPORT_STD template , int> = 0> - _NODISCARD constexpr time_point<_Clock, _To> time_point_cast(const time_point<_Clock, _Duration>& _Time) noexcept( - is_arithmetic_v && is_arithmetic_v) /* strengthened */ { + _NODISCARD constexpr time_point<_Clock, _To> time_point_cast(const time_point<_Clock, _Duration>& _Time) + noexcept(is_arithmetic_v && is_arithmetic_v) /* strengthened */ { // change the duration type of a time_point; truncate return time_point<_Clock, _To>(_CHRONO duration_cast<_To>(_Time.time_since_epoch())); } _EXPORT_STD template , int> = 0> - _NODISCARD constexpr time_point<_Clock, _To> floor(const time_point<_Clock, _Duration>& _Time) noexcept( - is_arithmetic_v && is_arithmetic_v) /* strengthened */ { + _NODISCARD constexpr time_point<_Clock, _To> floor(const time_point<_Clock, _Duration>& _Time) + noexcept(is_arithmetic_v && is_arithmetic_v) /* strengthened */ { // change the duration type of a time_point; round towards negative infinity return time_point<_Clock, _To>(_CHRONO floor<_To>(_Time.time_since_epoch())); } _EXPORT_STD template , int> = 0> - _NODISCARD constexpr time_point<_Clock, _To> ceil(const time_point<_Clock, _Duration>& _Time) noexcept( - is_arithmetic_v && is_arithmetic_v) /* strengthened */ { + _NODISCARD constexpr time_point<_Clock, _To> ceil(const time_point<_Clock, _Duration>& _Time) + noexcept(is_arithmetic_v && is_arithmetic_v) /* strengthened */ { // change the duration type of a time_point; round towards positive infinity return time_point<_Clock, _To>(_CHRONO ceil<_To>(_Time.time_since_epoch())); } _EXPORT_STD template && !treat_as_floating_point_v, int> = 0> - _NODISCARD constexpr time_point<_Clock, _To> round(const time_point<_Clock, _Duration>& _Time) noexcept( - is_arithmetic_v && is_arithmetic_v) /* strengthened */ { + _NODISCARD constexpr time_point<_Clock, _To> round(const time_point<_Clock, _Duration>& _Time) + noexcept(is_arithmetic_v && is_arithmetic_v) /* strengthened */ { // change the duration type of a time_point; round to nearest, ties to even return time_point<_Clock, _To>(_CHRONO round<_To>(_Time.time_since_epoch())); } diff --git a/stl/inc/__msvc_formatter.hpp b/stl/inc/__msvc_formatter.hpp index 5ff1bea2f4b..b8ff37b0d25 100644 --- a/stl/inc/__msvc_formatter.hpp +++ b/stl/inc/__msvc_formatter.hpp @@ -90,6 +90,9 @@ enum class _Basic_format_arg_type : uint8_t { static_assert(static_cast(_Basic_format_arg_type::_Custom_type) < 16, "must fit in 4-bit bitfield"); #if _HAS_CXX23 +_EXPORT_STD template +constexpr bool enable_nonlocking_formatter_optimization = false; + _NODISCARD consteval bool _Is_debug_enabled_fmt_type(_Basic_format_arg_type _Ty) { return _Ty == _Basic_format_arg_type::_Char_type || _Ty == _Basic_format_arg_type::_CString_type || _Ty == _Basic_format_arg_type::_String_type; @@ -126,8 +129,6 @@ class basic_format_parse_context; template concept _Format_supported_charT = _Is_any_of_v<_CharT, char, wchar_t>; -// Generic formatter definition, the deleted default constructor -// makes it "disabled" as per N4950 [format.formatter.spec]/5 _EXPORT_STD template struct formatter { formatter() = delete; @@ -170,7 +171,16 @@ struct _Formatter_base { }; _FMT_P2286_END +#if _HAS_CXX23 +#define _FORMAT_SPECIALIZE_NONLOCKING_FOR(_Type) \ + template <> \ + inline constexpr bool enable_nonlocking_formatter_optimization<_Type> = true; +#else // ^^^ _HAS_CXX23 / !_HAS_CXX23 vvv +#define _FORMAT_SPECIALIZE_NONLOCKING_FOR(_Type) +#endif // ^^^ !_HAS_CXX23 ^^^ + #define _FORMAT_SPECIALIZE_FOR(_Type, _ArgType) \ + _FORMAT_SPECIALIZE_NONLOCKING_FOR(_Type) \ template <_Format_supported_charT _CharT> \ struct formatter<_Type, _CharT> : _Formatter_base<_Type, _CharT, _ArgType> {} @@ -193,6 +203,7 @@ _FORMAT_SPECIALIZE_FOR(signed char, _Basic_format_arg_type::_Int_type); _FORMAT_SPECIALIZE_FOR(unsigned char, _Basic_format_arg_type::_UInt_type); #undef _FORMAT_SPECIALIZE_FOR +#undef _FORMAT_SPECIALIZE_NONLOCKING_FOR // not using the macro because we'd like to add 'set_debug_format' member function in C++23 mode template <_Format_supported_charT _CharT> @@ -361,6 +372,32 @@ struct formatter, _CharT>; template <_Format_supported_charT _CharT, class... _Types> struct formatter, _CharT>; + +template <_Format_supported_charT _CharT> +constexpr bool enable_nonlocking_formatter_optimization<_CharT> = true; + +template <_Format_supported_charT _CharT> +constexpr bool enable_nonlocking_formatter_optimization<_CharT*> = true; + +template <_Format_supported_charT _CharT> +constexpr bool enable_nonlocking_formatter_optimization = true; + +template <_Format_supported_charT _CharT, size_t _Nx> +constexpr bool enable_nonlocking_formatter_optimization<_CharT[_Nx]> = true; + +template <_Format_supported_charT _CharT, class _Traits, class _Allocator> +constexpr bool enable_nonlocking_formatter_optimization> = true; + +template <_Format_supported_charT _CharT, class _Traits> +constexpr bool enable_nonlocking_formatter_optimization> = true; + +template +constexpr bool enable_nonlocking_formatter_optimization> = + enable_nonlocking_formatter_optimization<_Ty1> && enable_nonlocking_formatter_optimization<_Ty2>; + +template +constexpr bool enable_nonlocking_formatter_optimization> = + (enable_nonlocking_formatter_optimization<_Ts> && ...); #endif // _HAS_CXX23 _STD_END diff --git a/stl/inc/__msvc_int128.hpp b/stl/inc/__msvc_int128.hpp index cef5bd87c0a..9a3f2e3c69b 100644 --- a/stl/inc/__msvc_int128.hpp +++ b/stl/inc/__msvc_int128.hpp @@ -707,9 +707,9 @@ struct _Unsigned128 : _Base128 { using _Signed_type = _Signed128; using _Unsigned_type = _Unsigned128; -#if !_HAS_CXX17 +#if !_HAS_CXX17 || (_HAS_CXX20 && !defined(__clang__) && !defined(__EDG__)) // TRANSITION, DevCom-10729775 constexpr _Unsigned128() noexcept : _Base128{} {} -#endif // !_HAS_CXX17 +#endif // ^^^ workaround for C++20 MSVC modules and header units; should be guarded for !_HAS_CXX17 only ^^^ using _Base128::_Base128; constexpr explicit _Unsigned128(const _Base128& _That) noexcept : _Base128{_That} {} @@ -1024,9 +1024,9 @@ struct _Signed128 : _Base128 { using _Signed_type = _Signed128; using _Unsigned_type = _Unsigned128; -#if !_HAS_CXX17 +#if !_HAS_CXX17 || (_HAS_CXX20 && !defined(__clang__) && !defined(__EDG__)) // TRANSITION, DevCom-10729775 constexpr _Signed128() noexcept : _Base128{} {} -#endif // !_HAS_CXX17 +#endif // ^^^ workaround for C++20 MSVC modules and header units; should be guarded for !_HAS_CXX17 only ^^^ using _Base128::_Base128; constexpr explicit _Signed128(const _Base128& _That) noexcept : _Base128{_That} {} diff --git a/stl/inc/__msvc_iter_core.hpp b/stl/inc/__msvc_iter_core.hpp index 6107a8700aa..619e97aa65d 100644 --- a/stl/inc/__msvc_iter_core.hpp +++ b/stl/inc/__msvc_iter_core.hpp @@ -206,38 +206,32 @@ struct _Iter_traits_difference { using _Apply = void; }; -// clang-format off template -concept _Cpp17_iterator = - requires(_It __i) { - { *__i } -> _Can_reference; - { ++__i } -> same_as<_It&>; - { *__i++ } -> _Can_reference; - } - && copyable<_It>; +concept _Cpp17_iterator = requires(_It __i) { + { *__i } -> _Can_reference; + { ++__i } -> same_as<_It&>; + { *__i++ } -> _Can_reference; +} && copyable<_It>; template -concept _Cpp17_input_iterator = _Cpp17_iterator<_It> - && equality_comparable<_It> - && _Has_member_difference_type> - && _Has_member_value_type> - && requires(_It __i) { - typename common_reference_t&&, typename indirectly_readable_traits<_It>::value_type&>; - typename common_reference_t::value_type&>; - requires signed_integral::difference_type>; - }; +concept _Cpp17_input_iterator = + _Cpp17_iterator<_It> && equality_comparable<_It> && _Has_member_difference_type> + && _Has_member_value_type> && requires(_It __i) { + typename common_reference_t&&, typename indirectly_readable_traits<_It>::value_type&>; + typename common_reference_t::value_type&>; + requires signed_integral::difference_type>; + }; template requires (!_Has_iter_types<_It> && _Cpp17_iterator<_It> && !_Cpp17_input_iterator<_It>) struct _Iterator_traits_base<_It> { using iterator_category = output_iterator_tag; - using value_type = void; + using value_type = void; using difference_type = _Iter_traits_difference<_Has_member_difference_type>>::template _Apply<_It>; - using pointer = void; - using reference = void; + using pointer = void; + using reference = void; }; -// clang-format on enum class _Itraits_pointer_strategy { _Use_void, _Use_member, _Use_decltype }; @@ -287,19 +281,17 @@ struct _Iter_traits_category4 { using type = bidirectional_iterator_tag; }; -// clang-format off template -concept _Cpp17_random_delta = totally_ordered<_It> - && requires(_It __i, incrementable_traits<_It>::difference_type __n) { +concept _Cpp17_random_delta = + totally_ordered<_It> && requires(_It __i, incrementable_traits<_It>::difference_type __n) { { __i += __n } -> same_as<_It&>; { __i -= __n } -> same_as<_It&>; - { __i + __n } -> same_as<_It>; - { __n + __i } -> same_as<_It>; - { __i - __n } -> same_as<_It>; - { __i - __i } -> same_as; - { __i[__n] } -> convertible_to>; + { __i + __n } -> same_as<_It>; + { __n + __i } -> same_as<_It>; + { __i - __n } -> same_as<_It>; + { __i - __i } -> same_as; + { __i[__n] } -> convertible_to>; }; -// clang-format on template struct _Iter_traits_category3 { @@ -332,15 +324,14 @@ struct _Iter_traits_category2 { using _Apply = input_iterator_tag; }; -// clang-format off template -concept _Cpp17_forward_delta = constructible_from<_It> && is_reference_v> +concept _Cpp17_forward_delta = + constructible_from<_It> && is_reference_v> && same_as>, typename indirectly_readable_traits<_It>::value_type> && requires(_It __i) { - { __i++ } -> convertible_to; - requires same_as>; - }; -// clang-format on + { __i++ } -> convertible_to; + requires same_as>; + }; template struct _Iter_traits_category { @@ -354,20 +345,18 @@ struct _Iter_traits_category { using _Apply = _Iter_traits_category2<_Cpp17_forward_delta<_It>>::template _Apply<_It>; }; -// clang-format off template requires (!_Has_iter_types<_It> && _Cpp17_input_iterator<_It>) struct _Iterator_traits_base<_It> { using iterator_category = _Iter_traits_category<_Has_member_iterator_category<_It>>::template _Apply<_It>; using value_type = indirectly_readable_traits<_It>::value_type; using difference_type = incrementable_traits<_It>::difference_type; - using pointer = _Iter_traits_pointer<( - _Has_member_pointer<_It> ? _Itraits_pointer_strategy::_Use_member - : _Has_member_arrow<_It&> ? _Itraits_pointer_strategy::_Use_decltype - : _Itraits_pointer_strategy::_Use_void)>::template _Apply<_It>; - using reference = _Iter_traits_reference<_Has_member_reference<_It>>::template _Apply<_It>; + using pointer = + _Iter_traits_pointer<(_Has_member_pointer<_It> ? _Itraits_pointer_strategy::_Use_member + : _Has_member_arrow<_It&> ? _Itraits_pointer_strategy::_Use_decltype + : _Itraits_pointer_strategy::_Use_void)>::template _Apply<_It>; + using reference = _Iter_traits_reference<_Has_member_reference<_It>>::template _Apply<_It>; }; -// clang-format on _EXPORT_STD template struct iterator_traits : _Iterator_traits_base<_Ty> { @@ -397,38 +386,31 @@ concept _Integer_like = _Is_nonbool_integral> || _Integer_class template concept _Signed_integer_like = _Integer_like<_Ty> && static_cast<_Ty>(-1) < static_cast<_Ty>(0); -// clang-format off _EXPORT_STD template -concept weakly_incrementable = movable<_Ty> - && requires(_Ty __i) { - typename iter_difference_t<_Ty>; - requires _Signed_integer_like>; - { ++__i } -> same_as<_Ty&>; - __i++; - }; +concept weakly_incrementable = movable<_Ty> && requires(_Ty __i) { + typename iter_difference_t<_Ty>; + requires _Signed_integer_like>; + { ++__i } -> same_as<_Ty&>; + __i++; +}; _EXPORT_STD template -concept input_or_output_iterator = requires(_It __i) { { *__i } -> _Can_reference; } - && weakly_incrementable<_It>; +concept input_or_output_iterator = requires(_It __i) { + { *__i } -> _Can_reference; +} && weakly_incrementable<_It>; _EXPORT_STD template -concept sentinel_for = semiregular<_Se> - && input_or_output_iterator<_It> - && _Weakly_equality_comparable_with<_Se, _It>; -// clang-format on +concept sentinel_for = semiregular<_Se> && input_or_output_iterator<_It> && _Weakly_equality_comparable_with<_Se, _It>; _EXPORT_STD template constexpr bool disable_sized_sentinel_for = false; -// clang-format off _EXPORT_STD template -concept sized_sentinel_for = sentinel_for<_Se, _It> - && !disable_sized_sentinel_for, remove_cv_t<_It>> - && requires(const _It& __i, const _Se& __s) { - { __s - __i } -> same_as>; - { __i - __s } -> same_as>; - }; -// clang-format on +concept sized_sentinel_for = sentinel_for<_Se, _It> && !disable_sized_sentinel_for, remove_cv_t<_It>> + && requires(const _It& __i, const _Se& __s) { + { __s - __i } -> same_as>; + { __i - __s } -> same_as>; + }; _EXPORT_STD struct default_sentinel_t {}; @@ -456,6 +438,11 @@ _EXPORT_STD using ranges::get; template constexpr bool _Is_subrange_v> = true; +#if _HAS_CXX23 +template +constexpr bool _Tuple_like_impl> = true; +#endif // _HAS_CXX23 + template struct tuple_size> : integral_constant {}; diff --git a/stl/inc/__msvc_ostream.hpp b/stl/inc/__msvc_ostream.hpp new file mode 100644 index 00000000000..38622ad5977 --- /dev/null +++ b/stl/inc/__msvc_ostream.hpp @@ -0,0 +1,1043 @@ +// __msvc_ostream.hpp internal header + +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef __MSVC_OSTREAM_HPP +#define __MSVC_OSTREAM_HPP +#include +#if _STL_COMPILER_PREPROCESSOR +#include + +#pragma pack(push, _CRT_PACKING) +#pragma warning(push, _STL_WARNING_LEVEL) +#pragma warning(disable : _STL_DISABLED_WARNINGS) +_STL_DISABLE_CLANG_WARNINGS +#pragma push_macro("new") +#undef new + +_STD_BEGIN +#pragma vtordisp(push, 2) // compiler bug workaround + +_EXPORT_STD extern "C++" template +class basic_ostream : virtual public basic_ios<_Elem, _Traits> { // control insertions into a stream buffer +public: + using _Myios = basic_ios<_Elem, _Traits>; + using _Mysb = basic_streambuf<_Elem, _Traits>; + using _Iter = ostreambuf_iterator<_Elem, _Traits>; + using _Nput = num_put<_Elem, _Iter>; + + explicit __CLR_OR_THIS_CALL basic_ostream(basic_streambuf<_Elem, _Traits>* _Strbuf, bool _Isstd = false) { + _Myios::init(_Strbuf, _Isstd); + } + + __CLR_OR_THIS_CALL basic_ostream(_Uninitialized, bool _Addit = true) { + if (_Addit) { + this->_Addstd(this); // suppress for basic_iostream + } + } + +protected: + __CLR_OR_THIS_CALL basic_ostream(basic_ostream&& _Right) noexcept(false) { + _Myios::init(); + _Myios::move(_STD move(_Right)); + } + + basic_ostream& __CLR_OR_THIS_CALL operator=(basic_ostream&& _Right) noexcept /* strengthened */ { + this->swap(_Right); + return *this; + } + + void __CLR_OR_THIS_CALL swap(basic_ostream& _Right) noexcept /* strengthened */ { + if (this != _STD addressof(_Right)) { + _Myios::swap(_Right); + } + } + +public: + __CLR_OR_THIS_CALL basic_ostream(const basic_ostream&) = delete; + basic_ostream& __CLR_OR_THIS_CALL operator=(const basic_ostream&) = delete; + + __CLR_OR_THIS_CALL ~basic_ostream() noexcept override {} + + using int_type = typename _Traits::int_type; + using pos_type = typename _Traits::pos_type; + using off_type = typename _Traits::off_type; + + class _Sentry_base { // stores thread lock and reference to output stream + public: + __CLR_OR_THIS_CALL _Sentry_base(basic_ostream& _Ostr) : _Myostr(_Ostr) { // lock the stream buffer, if there + const auto _Rdbuf = _Myostr.rdbuf(); + if (_Rdbuf) { + _Rdbuf->_Lock(); + } + } + + __CLR_OR_THIS_CALL ~_Sentry_base() noexcept { // destroy after unlocking + const auto _Rdbuf = _Myostr.rdbuf(); + if (_Rdbuf) { + _Rdbuf->_Unlock(); + } + } + + basic_ostream& _Myostr; // the output stream, for _Unlock call at destruction + + _Sentry_base& operator=(const _Sentry_base&) = delete; + }; + + class sentry : public _Sentry_base { + public: + explicit __CLR_OR_THIS_CALL sentry(basic_ostream& _Ostr) : _Sentry_base(_Ostr) { + if (!_Ostr.good()) { + _Ok = false; + return; + } + + const auto _Tied = _Ostr.tie(); + if (!_Tied || _Tied == _STD addressof(_Ostr)) { + _Ok = true; + return; + } + + _Tied->flush(); + _Ok = _Ostr.good(); // store test only after flushing tie + } + + _STL_DISABLE_DEPRECATED_WARNING + __CLR_OR_THIS_CALL ~sentry() noexcept { +#if !_HAS_EXCEPTIONS + const bool _Zero_uncaught_exceptions = true; +#elif _HAS_DEPRECATED_UNCAUGHT_EXCEPTION + const bool _Zero_uncaught_exceptions = !_STD uncaught_exception(); // TRANSITION, ArchivedOS-12000909 +#else // ^^^ _HAS_DEPRECATED_UNCAUGHT_EXCEPTION / !_HAS_DEPRECATED_UNCAUGHT_EXCEPTION vvv + const bool _Zero_uncaught_exceptions = _STD uncaught_exceptions() == 0; +#endif // ^^^ !_HAS_DEPRECATED_UNCAUGHT_EXCEPTION ^^^ + + if (_Zero_uncaught_exceptions) { + this->_Myostr._Osfx(); + } + } + _STL_RESTORE_DEPRECATED_WARNING + + explicit __CLR_OR_THIS_CALL operator bool() const { + return _Ok; + } + + __CLR_OR_THIS_CALL sentry(const sentry&) = delete; + sentry& __CLR_OR_THIS_CALL operator=(const sentry&) = delete; + + private: + bool _Ok; // true if stream state okay at construction + }; + +#pragma push_macro("opfx") +#pragma push_macro("osfx") +#undef opfx +#undef osfx + // TRANSITION, ABI: non-Standard opfx() is preserved for binary compatibility + _DEPRECATE_IO_PFX_SFX bool __CLR_OR_THIS_CALL opfx() { // test stream state and flush tie stream as needed + if (!this->good()) { + return false; + } + + const auto _Tied = _Myios::tie(); + if (!_Tied || _Myios::tie() == this) { + return true; + } + + _Tied->flush(); + return this->good(); + } + + // TRANSITION, ABI: non-Standard osfx() is preserved for binary compatibility + _DEPRECATE_IO_PFX_SFX void __CLR_OR_THIS_CALL osfx() noexcept { // perform any wrapup + _Osfx(); + } +#pragma pop_macro("osfx") +#pragma pop_macro("opfx") + + void __CLR_OR_THIS_CALL _Osfx() noexcept { // perform any wrapup + _TRY_BEGIN + if (this->good() && this->flags() & ios_base::unitbuf) { + if (_Myios::rdbuf()->pubsync() == -1) { // flush stream as needed + _Myios::setstate(ios_base::badbit); + } + } + _CATCH_ALL + _CATCH_END + } + +#ifdef _M_CEE_PURE + basic_ostream& __CLR_OR_THIS_CALL operator<<(basic_ostream&(__clrcall* _Pfn)(basic_ostream&) ) { + // call basic_ostream manipulator + return _Pfn(*this); + } + + basic_ostream& __CLR_OR_THIS_CALL operator<<(_Myios&(__clrcall* _Pfn)(_Myios&) ) { + // call basic_ios manipulator + _Pfn(*this); + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL operator<<(ios_base&(__clrcall* _Pfn)(ios_base&) ) { + // call ios_base manipulator + _Pfn(*this); + return *this; + } +#endif // defined(_M_CEE_PURE) + + basic_ostream& __CLR_OR_THIS_CALL operator<<(basic_ostream&(__cdecl* _Pfn)(basic_ostream&) ) { + // call basic_ostream manipulator + return _Pfn(*this); + } + + basic_ostream& __CLR_OR_THIS_CALL operator<<(_Myios&(__cdecl* _Pfn)(_Myios&) ) { + // call basic_ios manipulator + _Pfn(*this); + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL operator<<(ios_base&(__cdecl* _Pfn)(ios_base&) ) { + // call ios_base manipulator + _Pfn(*this); + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL operator<<(bool _Val) { // insert a boolean + ios_base::iostate _State = ios_base::goodbit; + const sentry _Ok(*this); + + if (_Ok) { // state okay, use facet to insert + const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); + + _TRY_IO_BEGIN + if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Val).failed()) { + _State |= ios_base::badbit; + } + _CATCH_IO_END + } + + _Myios::setstate(_State); + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL operator<<(short _Val) { // insert a short + ios_base::iostate _State = ios_base::goodbit; + const sentry _Ok(*this); + + if (_Ok) { // state okay, use facet to insert + const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); + ios_base::fmtflags _Bfl = this->flags() & ios_base::basefield; + + long _Tmp; + if (_Bfl == ios_base::oct || _Bfl == ios_base::hex) { + _Tmp = static_cast(static_cast(_Val)); + } else { + _Tmp = static_cast(_Val); + } + + _TRY_IO_BEGIN + if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Tmp).failed()) { + _State |= ios_base::badbit; + } + _CATCH_IO_END + } + + _Myios::setstate(_State); + return *this; + } + + // NOTE: + // If you are not using native wchar_t, the unsigned short inserter + // is masked by an explicit specialization that treats an unsigned + // short as a wide character. + + // To read or write unsigned shorts as integers with wchar_t streams, + // make wchar_t a native type with the command line option /Zc:wchar_t. + + basic_ostream& __CLR_OR_THIS_CALL operator<<(unsigned short _Val) { // insert an unsigned short + ios_base::iostate _State = ios_base::goodbit; + const sentry _Ok(*this); + + if (_Ok) { // state okay, use facet to insert + const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); + + _TRY_IO_BEGIN + if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), static_cast(_Val)) + .failed()) { + _State |= ios_base::badbit; + } + _CATCH_IO_END + } + + _Myios::setstate(_State); + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL operator<<(int _Val) { // insert an int + ios_base::iostate _State = ios_base::goodbit; + const sentry _Ok(*this); + + if (_Ok) { // state okay, use facet to insert + const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); + ios_base::fmtflags _Bfl = this->flags() & ios_base::basefield; + + long _Tmp; + if (_Bfl == ios_base::oct || _Bfl == ios_base::hex) { + _Tmp = static_cast(static_cast(_Val)); + } else { + _Tmp = static_cast(_Val); + } + + _TRY_IO_BEGIN + if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Tmp).failed()) { + _State |= ios_base::badbit; + } + _CATCH_IO_END + } + + _Myios::setstate(_State); + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL operator<<(unsigned int _Val) { // insert an unsigned int + ios_base::iostate _State = ios_base::goodbit; + const sentry _Ok(*this); + + if (_Ok) { // state okay, use facet to insert + const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); + + _TRY_IO_BEGIN + if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), static_cast(_Val)) + .failed()) { + _State |= ios_base::badbit; + } + _CATCH_IO_END + } + + _Myios::setstate(_State); + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL operator<<(long _Val) { // insert a long + ios_base::iostate _State = ios_base::goodbit; + const sentry _Ok(*this); + + if (_Ok) { // state okay, use facet to insert + const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); + + _TRY_IO_BEGIN + if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Val).failed()) { + _State |= ios_base::badbit; + } + _CATCH_IO_END + } + + _Myios::setstate(_State); + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL operator<<(unsigned long _Val) { // insert an unsigned long + ios_base::iostate _State = ios_base::goodbit; + const sentry _Ok(*this); + + if (_Ok) { // state okay, use facet to insert + const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); + + _TRY_IO_BEGIN + if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Val).failed()) { + _State |= ios_base::badbit; + } + _CATCH_IO_END + } + + _Myios::setstate(_State); + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL operator<<(long long _Val) { // insert a long long + ios_base::iostate _State = ios_base::goodbit; + const sentry _Ok(*this); + + if (_Ok) { // state okay, use facet to insert + const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); + + _TRY_IO_BEGIN + if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Val).failed()) { + _State |= ios_base::badbit; + } + _CATCH_IO_END + } + + _Myios::setstate(_State); + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL operator<<(unsigned long long _Val) { // insert an unsigned long long + ios_base::iostate _State = ios_base::goodbit; + const sentry _Ok(*this); + + if (_Ok) { // state okay, use facet to insert + const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); + + _TRY_IO_BEGIN + if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Val).failed()) { + _State |= ios_base::badbit; + } + _CATCH_IO_END + } + + _Myios::setstate(_State); + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL operator<<(float _Val) { // insert a float + ios_base::iostate _State = ios_base::goodbit; + const sentry _Ok(*this); + + if (_Ok) { // state okay, use facet to insert + const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); + + _TRY_IO_BEGIN + if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), static_cast(_Val)).failed()) { + _State |= ios_base::badbit; + } + _CATCH_IO_END + } + + _Myios::setstate(_State); + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL operator<<(double _Val) { // insert a double + ios_base::iostate _State = ios_base::goodbit; + const sentry _Ok(*this); + + if (_Ok) { // state okay, use facet to insert + const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); + + _TRY_IO_BEGIN + if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Val).failed()) { + _State |= ios_base::badbit; + } + _CATCH_IO_END + } + + _Myios::setstate(_State); + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL operator<<(long double _Val) { // insert a long double + ios_base::iostate _State = ios_base::goodbit; + const sentry _Ok(*this); + + if (_Ok) { // state okay, use facet to insert + const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); + + _TRY_IO_BEGIN + if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Val).failed()) { + _State |= ios_base::badbit; + } + _CATCH_IO_END + } + + _Myios::setstate(_State); + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL operator<<(const void* _Val) { // insert a void pointer + ios_base::iostate _State = ios_base::goodbit; + const sentry _Ok(*this); + + if (_Ok) { // state okay, use facet to insert + const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); + + _TRY_IO_BEGIN + if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Val).failed()) { + _State |= ios_base::badbit; + } + _CATCH_IO_END + } + + _Myios::setstate(_State); + return *this; + } + +#if _HAS_CXX23 + template // TRANSITION, ABI + basic_ostream& operator<<(const volatile void* _Val) { + return *this << const_cast(_Val); + } +#endif // _HAS_CXX23 + +#if _HAS_CXX17 + template // TRANSITION, ABI + basic_ostream& operator<<(nullptr_t) { // insert a null pointer + return *this << "nullptr"; + } +#endif // _HAS_CXX17 + + basic_ostream& __CLR_OR_THIS_CALL operator<<(_Mysb* _Strbuf) { // insert until end-of-file from a stream buffer + ios_base::iostate _State = ios_base::goodbit; + bool _Copied = false; + const sentry _Ok(*this); + + if (_Ok && _Strbuf) { + for (int_type _Meta = _Traits::eof();; _Copied = true) { // extract another character from stream buffer + _TRY_BEGIN + _Meta = _Traits::eq_int_type(_Traits::eof(), _Meta) ? _Strbuf->sgetc() : _Strbuf->snextc(); + _CATCH_ALL + // N4971 [ostream.inserters]/9: "If an exception was thrown + // while extracting a character, the function sets failbit in the error state, + // and if failbit is set in exceptions() the caught exception is rethrown." + _Myios::setstate(ios_base::failbit, _Myios::exceptions() == ios_base::failbit); + _CATCH_END + + if (_Traits::eq_int_type(_Traits::eof(), _Meta)) { + break; // end of file, quit + } + + _TRY_IO_BEGIN + if (_Traits::eq_int_type(_Traits::eof(), _Myios::rdbuf()->sputc(_Traits::to_char_type(_Meta)))) { + _State |= ios_base::badbit; // insertion failed, quit + break; + } + _CATCH_IO_END + } + } + + this->width(0); + int _Setstate_with; + if (_Strbuf) { + if (_Copied) { + _Setstate_with = _State; + } else { + _Setstate_with = _State | ios_base::failbit; + } + } else { + _Setstate_with = ios_base::badbit; + } + + _Myios::setstate(_Setstate_with); + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL put(_Elem _Ch) { // insert a character + ios_base::iostate _State = ios_base::goodbit; + const sentry _Ok(*this); + + if (!_Ok) { + _State |= ios_base::badbit; + } else { // state okay, insert character + _TRY_IO_BEGIN + if (_Traits::eq_int_type(_Traits::eof(), _Myios::rdbuf()->sputc(_Ch))) { + _State |= ios_base::badbit; + } + _CATCH_IO_END + } + + _Myios::setstate(_State); + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL write(const _Elem* _Str, streamsize _Count) { + // insert _Count characters from array _Str + ios_base::iostate _State = ios_base::goodbit; + const sentry _Ok(*this); + + if (!_Ok) { + _State |= ios_base::badbit; + } else if (0 < _Count) { // state okay, insert characters + _TRY_IO_BEGIN + if (_Myios::rdbuf()->sputn(_Str, _Count) != _Count) { + _State |= ios_base::badbit; + } + _CATCH_IO_END + } + + _Myios::setstate(_State); + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL flush() { // flush output stream + const auto _Rdbuf = _Myios::rdbuf(); + if (_Rdbuf) { // buffer exists, flush it + const sentry _Ok(*this); + + if (_Ok) { + ios_base::iostate _State = ios_base::goodbit; + _TRY_IO_BEGIN + if (_Rdbuf->pubsync() == -1) { + _State |= ios_base::badbit; // sync failed + } + _CATCH_IO_END + _Myios::setstate(_State); + } + } + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL seekp(pos_type _Pos) { // set output stream position to _Pos + const sentry _Ok(*this); + + if (!this->fail()) { + ios_base::iostate _State = ios_base::goodbit; + _TRY_IO_BEGIN + if (static_cast(_Myios::rdbuf()->pubseekpos(_Pos, ios_base::out)) == -1) { + _State |= ios_base::failbit; // seek failed + } + _CATCH_IO_END + _Myios::setstate(_State); + } + + return *this; + } + + basic_ostream& __CLR_OR_THIS_CALL seekp(off_type _Off, ios_base::seekdir _Way) { + // change output stream position by _Off, according to _Way + const sentry _Ok(*this); + + if (!this->fail()) { + ios_base::iostate _State = ios_base::goodbit; + _TRY_IO_BEGIN + if (static_cast(_Myios::rdbuf()->pubseekoff(_Off, _Way, ios_base::out)) == -1) { + _State |= ios_base::failbit; // seek failed + } + _CATCH_IO_END + _Myios::setstate(_State); + } + + return *this; + } + + pos_type __CLR_OR_THIS_CALL tellp() { + const sentry _Ok(*this); + + if (!this->fail()) { + _TRY_IO_BEGIN + return _Myios::rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out); + _CATCH_IO_END + } + + return pos_type{off_type{-1}}; + } +}; + +#pragma vtordisp(pop) // compiler bug workaround + +#ifndef _NATIVE_WCHAR_T_DEFINED +// NOTE: +// If you are not using native wchar_t, the following explicit +// specialization will mask the member function (above) that treats +// an unsigned short as an integer. + +// To read or write unsigned shorts as integers with wchar_t streams, +// make wchar_t a native type with the command line option /Zc:wchar_t. + +template <> +inline basic_ostream>& __CLR_OR_THIS_CALL basic_ostream>::operator<<(unsigned short _Ch) { // extract a character + using _Traits = char_traits; + + ios_base::iostate _State = ios_base::goodbit; + const sentry _Ok(*this); + + if (_Ok) { // state okay, insert + streamsize _Pad = this->width() <= 1 ? 0 : this->width() - 1; + + _TRY_IO_BEGIN + if ((this->flags() & ios_base::adjustfield) != ios_base::left) { + for (; _State == ios_base::goodbit && 0 < _Pad; --_Pad) { // pad on left + if (_Traits::eq_int_type(_Traits::eof(), this->rdbuf()->sputc(this->fill()))) { + _State |= ios_base::badbit; + } + } + } + + if (_State == ios_base::goodbit && _Traits::eq_int_type(_Traits::eof(), this->rdbuf()->sputc(_Ch))) { + _State |= ios_base::badbit; + } + + for (; _State == ios_base::goodbit && 0 < _Pad; --_Pad) { // pad on right + if (_Traits::eq_int_type(_Traits::eof(), this->rdbuf()->sputc(this->fill()))) { + _State |= ios_base::badbit; + } + } + _CATCH_IO_END + } + + this->width(0); + _Myios::setstate(_State); + return *this; +} +#endif // _NATIVE_WCHAR_T_DEFINED + +#if defined(_DLL_CPPLIB) + +#if !defined(_CRTBLD) || defined(__FORCE_INSTANCE) +template class _CRTIMP2_PURE_IMPORT basic_ostream>; +template class _CRTIMP2_PURE_IMPORT basic_ostream>; +#endif // !defined(_CRTBLD) || defined(__FORCE_INSTANCE) + +#ifdef __FORCE_INSTANCE +template class _CRTIMP2_PURE_IMPORT basic_ostream>; +#endif // defined(__FORCE_INSTANCE) +#endif // defined(_DLL_CPPLIB) + +_EXPORT_STD template +basic_ostream<_Elem, _Traits>& operator<<(basic_ostream<_Elem, _Traits>& _Ostr, const char* _Val) { // insert NTBS + ios_base::iostate _State = ios_base::goodbit; + streamsize _Count = static_cast(_CSTD strlen(_Val)); + streamsize _Pad = _Ostr.width() <= 0 || _Ostr.width() <= _Count ? 0 : _Ostr.width() - _Count; + const typename basic_ostream<_Elem, _Traits>::sentry _Ok(_Ostr); + + if (!_Ok) { + _State |= ios_base::badbit; + } else { // state okay, insert characters + _TRY_IO_BEGIN + const ctype<_Elem>& _Ctype_fac = _STD use_facet>(_Ostr.getloc()); + if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left) { + for (; 0 < _Pad; --_Pad) { // pad on left + if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { + _State |= ios_base::badbit; // insertion failed, quit + break; + } + } + } + + for (; _State == ios_base::goodbit && 0 < _Count; --_Count, ++_Val) { + if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ctype_fac.widen(*_Val)))) { + _State |= ios_base::badbit; + } + } + + if (_State == ios_base::goodbit) { + for (; 0 < _Pad; --_Pad) { // pad on right + if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { + _State |= ios_base::badbit; // insertion failed, quit + break; + } + } + } + + _Ostr.width(0); + _CATCH_IO_(ios_base, _Ostr) + } + + _Ostr.setstate(_State); + return _Ostr; +} + +_EXPORT_STD template +basic_ostream<_Elem, _Traits>& operator<<(basic_ostream<_Elem, _Traits>& _Ostr, char _Ch) { // insert a character + ios_base::iostate _State = ios_base::goodbit; + const typename basic_ostream<_Elem, _Traits>::sentry _Ok(_Ostr); + + if (_Ok) { // state okay, insert + const ctype<_Elem>& _Ctype_fac = _STD use_facet>(_Ostr.getloc()); + streamsize _Pad = _Ostr.width() <= 1 ? 0 : _Ostr.width() - 1; + + _TRY_IO_BEGIN + if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left) { + for (; _State == ios_base::goodbit && 0 < _Pad; --_Pad) { // pad on left + if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { + _State |= ios_base::badbit; + } + } + } + + if (_State == ios_base::goodbit + && _Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ctype_fac.widen(_Ch)))) { + _State |= ios_base::badbit; + } + + for (; _State == ios_base::goodbit && 0 < _Pad; --_Pad) { // pad on right + if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { + _State |= ios_base::badbit; + } + } + _CATCH_IO_(ios_base, _Ostr) + } + + _Ostr.width(0); + _Ostr.setstate(_State); + return _Ostr; +} + +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream& _Ostr, const char* _Val) { + // insert NTBS into char stream + using _Elem = char; + using _Myos = basic_ostream<_Elem, _Traits>; + + ios_base::iostate _State = ios_base::goodbit; + streamsize _Count = static_cast(_Traits::length(_Val)); + streamsize _Pad = _Ostr.width() <= 0 || _Ostr.width() <= _Count ? 0 : _Ostr.width() - _Count; + const typename _Myos::sentry _Ok(_Ostr); + + if (!_Ok) { + _State |= ios_base::badbit; + } else { // state okay, insert + _TRY_IO_BEGIN + if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left) { + for (; 0 < _Pad; --_Pad) { // pad on left + if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { + _State |= ios_base::badbit; // insertion failed, quit + break; + } + } + } + + if (_State == ios_base::goodbit && _Ostr.rdbuf()->sputn(_Val, _Count) != _Count) { + _State |= ios_base::badbit; + } + + if (_State == ios_base::goodbit) { + for (; 0 < _Pad; --_Pad) { // pad on right + if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { + _State |= ios_base::badbit; // insertion failed, quit + break; + } + } + } + + _Ostr.width(0); + _CATCH_IO_(ios_base, _Ostr) + } + + _Ostr.setstate(_State); + return _Ostr; +} + +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream& _Ostr, char _Ch) { + // insert a char into char stream + using _Elem = char; + using _Myos = basic_ostream<_Elem, _Traits>; + + ios_base::iostate _State = ios_base::goodbit; + const typename _Myos::sentry _Ok(_Ostr); + + if (_Ok) { // state okay, insert + streamsize _Pad = _Ostr.width() <= 1 ? 0 : _Ostr.width() - 1; + + _TRY_IO_BEGIN + if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left) { + for (; _State == ios_base::goodbit && 0 < _Pad; --_Pad) { // pad on left + if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { + _State |= ios_base::badbit; + } + } + } + + if (_State == ios_base::goodbit && _Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ch))) { + _State |= ios_base::badbit; + } + + for (; _State == ios_base::goodbit && 0 < _Pad; --_Pad) { // pad on right + if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { + _State |= ios_base::badbit; + } + } + _CATCH_IO_(ios_base, _Ostr) + } + + _Ostr.width(0); + _Ostr.setstate(_State); + return _Ostr; +} + +_EXPORT_STD template +basic_ostream<_Elem, _Traits>& operator<<(basic_ostream<_Elem, _Traits>& _Ostr, const _Elem* _Val) { // insert NTCS + using _Myos = basic_ostream<_Elem, _Traits>; + + ios_base::iostate _State = ios_base::goodbit; + streamsize _Count = static_cast(_Traits::length(_Val)); + streamsize _Pad = _Ostr.width() <= 0 || _Ostr.width() <= _Count ? 0 : _Ostr.width() - _Count; + const typename _Myos::sentry _Ok(_Ostr); + + if (!_Ok) { + _State |= ios_base::badbit; + } else { // state okay, insert + _TRY_IO_BEGIN + if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left) { + for (; 0 < _Pad; --_Pad) { // pad on left + if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { + _State |= ios_base::badbit; // insertion failed, quit + break; + } + } + } + + if (_State == ios_base::goodbit && _Ostr.rdbuf()->sputn(_Val, _Count) != _Count) { + _State |= ios_base::badbit; + } + + if (_State == ios_base::goodbit) { + for (; 0 < _Pad; --_Pad) { // pad on right + if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { + _State |= ios_base::badbit; // insertion failed, quit + break; + } + } + } + + _Ostr.width(0); + _CATCH_IO_(ios_base, _Ostr) + } + + _Ostr.setstate(_State); + return _Ostr; +} + +_EXPORT_STD template +basic_ostream<_Elem, _Traits>& operator<<(basic_ostream<_Elem, _Traits>& _Ostr, _Elem _Ch) { // insert a character + using _Myos = basic_ostream<_Elem, _Traits>; + + ios_base::iostate _State = ios_base::goodbit; + const typename _Myos::sentry _Ok(_Ostr); + + if (_Ok) { // state okay, insert + streamsize _Pad = _Ostr.width() <= 1 ? 0 : _Ostr.width() - 1; + + _TRY_IO_BEGIN + if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left) { + for (; _State == ios_base::goodbit && 0 < _Pad; --_Pad) { // pad on left + if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { + _State |= ios_base::badbit; + } + } + } + + if (_State == ios_base::goodbit && _Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ch))) { + _State |= ios_base::badbit; + } + + for (; _State == ios_base::goodbit && 0 < _Pad; --_Pad) { // pad on right + if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { + _State |= ios_base::badbit; + } + } + _CATCH_IO_(ios_base, _Ostr) + } + + _Ostr.width(0); + _Ostr.setstate(_State); + return _Ostr; +} + +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream& _Ostr, const signed char* _Val) { + // insert a signed char NTBS + return _Ostr << reinterpret_cast(_Val); +} + +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream& _Ostr, signed char _Ch) { // insert a signed char + return _Ostr << static_cast(_Ch); +} + +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream& _Ostr, const unsigned char* _Val) { + // insert an unsigned char NTBS + return _Ostr << reinterpret_cast(_Val); +} + +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream& _Ostr, unsigned char _Ch) { + // insert an unsigned char + return _Ostr << static_cast(_Ch); +} + +#ifdef __cpp_char8_t // These deleted overloads are specified in P1423. +// don't insert a UTF-8 NTBS +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream&, const char8_t*) = delete; +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream&, const char8_t*) = delete; + +// don't insert a UTF-8 code unit +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream&, char8_t) = delete; +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream&, char8_t) = delete; +#endif // defined(__cpp_char8_t) + +#if !_HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20 +#ifdef _NATIVE_WCHAR_T_DEFINED +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream&, wchar_t) = delete; + +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream&, const wchar_t*) = delete; +#endif // _NATIVE_WCHAR_T_DEFINED + +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream&, char16_t) = delete; +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream&, char32_t) = delete; + +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream&, char16_t) = delete; +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream&, char32_t) = delete; + +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream&, const char16_t*) = delete; +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream&, const char32_t*) = delete; + +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream&, const char16_t*) = delete; +_EXPORT_STD template +basic_ostream& operator<<(basic_ostream&, const char32_t*) = delete; +#endif // !_HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20 + +template +struct _Can_stream_out : false_type {}; + +template +struct _Can_stream_out<_Ostr, _Ty, void_t() << _STD declval())>> : true_type { +}; + +_EXPORT_STD template , _Can_stream_out<_Ostr, _Ty>>, int> = 0> +_Ostr&& operator<<(_Ostr&& _Os, const _Ty& _Val) { // insert to rvalue stream + _Os << _Val; + return _STD move(_Os); +} + +_EXPORT_STD template +basic_ostream<_Elem, _Traits>& __CLRCALL_OR_CDECL endl( + basic_ostream<_Elem, _Traits>& _Ostr) { // insert newline and flush stream + _Ostr.put(_Ostr.widen('\n')); + _Ostr.flush(); + return _Ostr; +} + +_EXPORT_STD template +basic_ostream<_Elem, _Traits>& __CLRCALL_OR_CDECL ends(basic_ostream<_Elem, _Traits>& _Ostr) { // insert null character + _Ostr.put(_Elem()); + return _Ostr; +} + +_EXPORT_STD template +basic_ostream<_Elem, _Traits>& __CLRCALL_OR_CDECL flush(basic_ostream<_Elem, _Traits>& _Ostr) { // flush stream + _Ostr.flush(); + return _Ostr; +} + +_EXPORT_STD template +basic_ostream<_Elem, _Traits>& operator<<(basic_ostream<_Elem, _Traits>& _Ostr, const error_code& _Errcode) { + // display error code + return _Ostr << _Errcode.category().name() << ':' << _Errcode.value(); +} +_STD_END + +#pragma pop_macro("new") +_STL_RESTORE_CLANG_WARNINGS +#pragma warning(pop) +#pragma pack(pop) + +#endif // _STL_COMPILER_PREPROCESSOR +#endif // __MSVC_OSTREAM_HPP diff --git a/stl/inc/__msvc_ranges_to.hpp b/stl/inc/__msvc_ranges_to.hpp index 5477a7347e9..e6c76ee1b13 100644 --- a/stl/inc/__msvc_ranges_to.hpp +++ b/stl/inc/__msvc_ranges_to.hpp @@ -33,14 +33,12 @@ namespace ranges { template constexpr bool _Is_initializer_list = _Is_specialization_v, initializer_list>; - // clang-format off _EXPORT_STD template concept viewable_range = range<_Rng> - && ((view> && constructible_from, _Rng>) - || (!view> - && (is_lvalue_reference_v<_Rng> - || (movable> && !_Is_initializer_list<_Rng>)))); - // clang-format on + && ((view> && constructible_from, _Rng>) + || (!view> + && (is_lvalue_reference_v<_Rng> + || (movable> && !_Is_initializer_list<_Rng>) ))); namespace _Pipe { template @@ -73,7 +71,7 @@ namespace ranges { void operator()(auto&&) const&& = delete; template - _NODISCARD constexpr decltype(auto) operator()(_Ty && _Val) & noexcept( + _NODISCARD constexpr decltype(auto) operator()(_Ty&& _Val) & noexcept( noexcept(_Right(_Left(_STD forward<_Ty>(_Val))))) requires requires { _Right(_Left(_STD forward<_Ty>(_Val))); } { @@ -81,7 +79,7 @@ namespace ranges { } template - _NODISCARD constexpr decltype(auto) operator()(_Ty && _Val) const& noexcept( + _NODISCARD constexpr decltype(auto) operator()(_Ty&& _Val) const& noexcept( noexcept(_Right(_Left(_STD forward<_Ty>(_Val))))) requires requires { _Right(_Left(_STD forward<_Ty>(_Val))); } { @@ -89,7 +87,7 @@ namespace ranges { } template - _NODISCARD constexpr decltype(auto) operator()(_Ty && _Val) && noexcept( + _NODISCARD constexpr decltype(auto) operator()(_Ty&& _Val) && noexcept( noexcept(_STD move(_Right)(_STD move(_Left)(_STD forward<_Ty>(_Val))))) requires requires { _STD move(_Right)(_STD move(_Left)(_STD forward<_Ty>(_Val))); } { @@ -97,7 +95,7 @@ namespace ranges { } template - _NODISCARD constexpr decltype(auto) operator()(_Ty && _Val) const&& noexcept( + _NODISCARD constexpr decltype(auto) operator()(_Ty&& _Val) const&& noexcept( noexcept(_STD move(_Right)(_STD move(_Left)(_STD forward<_Ty>(_Val))))) requires requires { _STD move(_Right)(_STD move(_Left)(_STD forward<_Ty>(_Val))); } { @@ -112,15 +110,15 @@ namespace ranges { requires _Range_adaptor_closure_object<_Left> && _Range_adaptor_closure_object<_Right> && constructible_from, _Left> && constructible_from, _Right> - _NODISCARD constexpr auto operator|(_Left&& __l, _Right&& __r) noexcept( - noexcept(_Pipeline{static_cast<_Left&&>(__l), static_cast<_Right&&>(__r)})) { + _NODISCARD constexpr auto operator|(_Left&& __l, _Right&& __r) + noexcept(noexcept(_Pipeline{static_cast<_Left&&>(__l), static_cast<_Right&&>(__r)})) { return _Pipeline{static_cast<_Left&&>(__l), static_cast<_Right&&>(__r)}; } _EXPORT_STD template requires (_Range_adaptor_closure_object<_Right> && range<_Left>) - _NODISCARD constexpr decltype(auto) operator|(_Left && __l, _Right && __r) noexcept( - noexcept(_STD forward<_Right>(__r)(_STD forward<_Left>(__l)))) + _NODISCARD constexpr decltype(auto) operator|(_Left&& __l, _Right&& __r) + noexcept(noexcept(_STD forward<_Right>(__r)(_STD forward<_Left>(__l)))) requires requires { static_cast<_Right&&>(__r)(static_cast<_Left&&>(__l)); } { return _STD forward<_Right>(__r)(_STD forward<_Left>(__l)); @@ -147,8 +145,8 @@ namespace ranges { : _Val(), _Engaged{true} {} template - constexpr _Movable_box(in_place_t, _Types&&... _Args) noexcept( - is_nothrow_constructible_v<_Ty, _Types...>) // strengthened + constexpr _Movable_box(in_place_t, _Types&&... _Args) + noexcept(is_nothrow_constructible_v<_Ty, _Types...>) // strengthened : _Val(_STD forward<_Types>(_Args)...), _Engaged{true} {} constexpr ~_Movable_box() { @@ -157,12 +155,13 @@ namespace ranges { } } - // clang-format off - ~_Movable_box() requires is_trivially_destructible_v<_Ty> = default; + ~_Movable_box() + requires is_trivially_destructible_v<_Ty> + = default; _Movable_box(const _Movable_box&) - requires copy_constructible<_Ty> && is_trivially_copy_constructible_v<_Ty> = default; - // clang-format on + requires copy_constructible<_Ty> && is_trivially_copy_constructible_v<_Ty> + = default; constexpr _Movable_box(const _Movable_box& _That) requires copy_constructible<_Ty> @@ -172,9 +171,9 @@ namespace ranges { } } - // clang-format off - _Movable_box(_Movable_box&&) requires is_trivially_move_constructible_v<_Ty> = default; - // clang-format on + _Movable_box(_Movable_box&&) + requires is_trivially_move_constructible_v<_Ty> + = default; constexpr _Movable_box(_Movable_box&& _That) : _Engaged{_That._Engaged} { if (_That._Engaged) { @@ -182,13 +181,12 @@ namespace ranges { } } - // clang-format off _Movable_box& operator=(const _Movable_box&) noexcept - requires copyable<_Ty> && is_trivially_copy_assignable_v<_Ty> = default; - // clang-format on + requires copyable<_Ty> && is_trivially_copy_assignable_v<_Ty> + = default; - constexpr _Movable_box& operator=(const _Movable_box& _That) noexcept( - is_nothrow_copy_constructible_v<_Ty> && is_nothrow_copy_assignable_v<_Ty>) // strengthened + constexpr _Movable_box& operator=(const _Movable_box& _That) + noexcept(is_nothrow_copy_constructible_v<_Ty> && is_nothrow_copy_assignable_v<_Ty>) // strengthened requires copyable<_Ty> { if (_Engaged) { @@ -230,13 +228,12 @@ namespace ranges { return *this; } - // clang-format off _Movable_box& operator=(_Movable_box&&) noexcept - requires movable<_Ty> && is_trivially_move_assignable_v<_Ty> = default; - // clang-format on + requires movable<_Ty> && is_trivially_move_assignable_v<_Ty> + = default; - constexpr _Movable_box& operator=(_Movable_box&& _That) noexcept( - is_nothrow_move_constructible_v<_Ty> && is_nothrow_move_assignable_v<_Ty>) // strengthened + constexpr _Movable_box& operator=(_Movable_box&& _That) + noexcept(is_nothrow_move_constructible_v<_Ty> && is_nothrow_move_assignable_v<_Ty>) // strengthened requires movable<_Ty> { if (_Engaged) { @@ -314,20 +311,21 @@ namespace ranges { requires _Use_simple_movable_box_wrapper<_Ty> class _Movable_box<_Ty> { // provide the same API more efficiently when we can avoid the disengaged state public: - // clang-format off - _Movable_box() requires default_initializable<_Ty> = default; - // clang-format on + _Movable_box() + requires default_initializable<_Ty> + = default; template - constexpr _Movable_box(in_place_t, _Types&&... _Args) noexcept( - is_nothrow_constructible_v<_Ty, _Types...>) // strengthened + constexpr _Movable_box(in_place_t, _Types&&... _Args) + noexcept(is_nothrow_constructible_v<_Ty, _Types...>) // strengthened : _Val(_STD forward<_Types>(_Args)...) {} - // clang-format off _Movable_box(const _Movable_box&) - requires _Copy_constructible_for_box<_Ty> && is_trivially_copy_constructible_v<_Ty> = default; - _Movable_box(_Movable_box&&) requires is_trivially_move_constructible_v<_Ty> = default; - // clang-format on + requires _Copy_constructible_for_box<_Ty> && is_trivially_copy_constructible_v<_Ty> + = default; + _Movable_box(_Movable_box&&) + requires is_trivially_move_constructible_v<_Ty> + = default; constexpr _Movable_box(const _Movable_box& _That) noexcept(is_nothrow_copy_constructible_v<_Ty>) requires _Copy_constructible_for_box<_Ty> @@ -336,14 +334,15 @@ namespace ranges { constexpr _Movable_box(_Movable_box&& _That) noexcept(is_nothrow_move_constructible_v<_Ty>) : _Val(static_cast<_Ty&&>(_That._Val)) {} - // clang-format off _Movable_box& operator=(const _Movable_box&) - requires copyable<_Ty> && is_trivially_copy_assignable_v<_Ty> = default; - _Movable_box& operator=(_Movable_box&&) requires movable<_Ty> && is_trivially_move_assignable_v<_Ty> = default; - // clang-format on - - constexpr _Movable_box& operator=(const _Movable_box& _That) noexcept( - is_nothrow_copy_assignable_v<_Ty> || !copyable<_Ty>) // strengthened + requires copyable<_Ty> && is_trivially_copy_assignable_v<_Ty> + = default; + _Movable_box& operator=(_Movable_box&&) + requires movable<_Ty> && is_trivially_move_assignable_v<_Ty> + = default; + + constexpr _Movable_box& operator=(const _Movable_box& _That) + noexcept(is_nothrow_copy_assignable_v<_Ty> || !copyable<_Ty>) // strengthened requires copy_constructible<_Ty> { if constexpr (copyable<_Ty>) { @@ -357,8 +356,8 @@ namespace ranges { return *this; } - constexpr _Movable_box& operator=(_Movable_box&& _That) noexcept( - is_nothrow_move_assignable_v<_Ty> || !movable<_Ty>) /* strengthened */ { + constexpr _Movable_box& operator=(_Movable_box&& _That) + noexcept(is_nothrow_move_assignable_v<_Ty> || !movable<_Ty>) /* strengthened */ { if constexpr (movable<_Ty>) { static_cast<_Ty&>(_Val) = static_cast<_Ty&&>(_That._Val); } else { @@ -399,8 +398,8 @@ namespace ranges { template requires (same_as, _Types> && ...) - constexpr explicit _Range_closure(_UTypes&&... _Args) noexcept( - conjunction_v...>) + constexpr explicit _Range_closure(_UTypes&&... _Args) + noexcept(conjunction_v...>) : _Captures(_STD forward<_UTypes>(_Args)...) {} void operator()(auto&&) & = delete; @@ -412,28 +411,28 @@ namespace ranges { template requires invocable<_Fn, _Ty, _Types&...> - constexpr decltype(auto) operator()(_Ty && _Arg) & noexcept( + constexpr decltype(auto) operator()(_Ty&& _Arg) & noexcept( noexcept(_Call(*this, _STD forward<_Ty>(_Arg), _Indices{}))) { return _Call(*this, _STD forward<_Ty>(_Arg), _Indices{}); } template requires invocable<_Fn, _Ty, const _Types&...> - constexpr decltype(auto) operator()(_Ty && _Arg) const& noexcept( + constexpr decltype(auto) operator()(_Ty&& _Arg) const& noexcept( noexcept(_Call(*this, _STD forward<_Ty>(_Arg), _Indices{}))) { return _Call(*this, _STD forward<_Ty>(_Arg), _Indices{}); } template requires invocable<_Fn, _Ty, _Types...> - constexpr decltype(auto) operator()(_Ty && _Arg) && noexcept( + constexpr decltype(auto) operator()(_Ty&& _Arg) && noexcept( noexcept(_Call(_STD move(*this), _STD forward<_Ty>(_Arg), _Indices{}))) { return _Call(_STD move(*this), _STD forward<_Ty>(_Arg), _Indices{}); } template requires invocable<_Fn, _Ty, const _Types...> - constexpr decltype(auto) operator()(_Ty && _Arg) const&& noexcept( + constexpr decltype(auto) operator()(_Ty&& _Arg) const&& noexcept( noexcept(_Call(_STD move(*this), _STD forward<_Ty>(_Arg), _Indices{}))) { return _Call(_STD move(*this), _STD forward<_Ty>(_Arg), _Indices{}); } @@ -459,14 +458,11 @@ namespace ranges { static void _Rvalue_poison(_Rng&&) = delete; public: - // clang-format off template <_Different_from _OtherRng> - constexpr ref_view(_OtherRng&& _Other) noexcept( - noexcept(static_cast<_Rng&>(_STD forward<_OtherRng>(_Other)))) // strengthened - requires convertible_to<_OtherRng, _Rng&> && requires { - _Rvalue_poison(static_cast<_OtherRng&&>(_Other)); - } : _Range{_STD addressof(static_cast<_Rng&>(_STD forward<_OtherRng>(_Other)))} {} - // clang-format on + constexpr ref_view(_OtherRng&& _Other) + noexcept(noexcept(static_cast<_Rng&>(_STD forward<_OtherRng>(_Other)))) // strengthened + requires convertible_to<_OtherRng, _Rng&> && requires { _Rvalue_poison(static_cast<_OtherRng&&>(_Other)); } + : _Range{_STD addressof(static_cast<_Rng&>(_STD forward<_OtherRng>(_Other)))} {} _NODISCARD constexpr _Rng& base() const noexcept /* strengthened */ { return *_Range; @@ -513,9 +509,9 @@ namespace ranges { _Rng _Range{}; public: - // clang-format off - owning_view() requires default_initializable<_Rng> = default; - // clang-format on + owning_view() + requires default_initializable<_Rng> + = default; constexpr owning_view(_Rng&& _Range_) noexcept(is_nothrow_move_constructible_v<_Rng>) // strengthened : _Range(_STD move(_Range_)) {} @@ -700,12 +696,12 @@ namespace ranges { using value_type = remove_cvref_t&, range_reference_t<_Base>>>; using difference_type = range_difference_t<_Base>; - // clang-format off - _Iterator() requires default_initializable> = default; - // clang-format on + _Iterator() + requires default_initializable> + = default; - constexpr _Iterator(_Parent_t& _Parent_, iterator_t<_Base> _Current_) noexcept( - is_nothrow_move_constructible_v>) // strengthened + constexpr _Iterator(_Parent_t& _Parent_, iterator_t<_Base> _Current_) + noexcept(is_nothrow_move_constructible_v>) // strengthened : _Current{_STD move(_Current_)}, _Parent{_STD addressof(_Parent_)} { #if _ITERATOR_DEBUG_LEVEL != 0 _STD _Adl_verify_range(_Current, _RANGES end(_Parent_._Range)); @@ -715,8 +711,8 @@ namespace ranges { #endif // _ITERATOR_DEBUG_LEVEL != 0 } - constexpr _Iterator(_Iterator _It) noexcept( - is_nothrow_constructible_v, iterator_t<_Vw>>) // strengthened + constexpr _Iterator(_Iterator _It) + noexcept(is_nothrow_constructible_v, iterator_t<_Vw>>) // strengthened requires _Const && convertible_to, iterator_t<_Base>> : _Current(_STD move(_It._Current)), _Parent(_It._Parent) {} @@ -773,8 +769,8 @@ namespace ranges { --_Current; return *this; } - constexpr _Iterator operator--(int) noexcept( - noexcept(--_Current) && is_nothrow_copy_constructible_v>) /* strengthened */ + constexpr _Iterator operator--(int) + noexcept(noexcept(--_Current) && is_nothrow_copy_constructible_v>) /* strengthened */ requires bidirectional_range<_Base> { auto _Tmp = *this; @@ -793,8 +789,8 @@ namespace ranges { } #endif // _ITERATOR_DEBUG_LEVEL != 0 - constexpr _Iterator& operator+=(const difference_type _Off) noexcept( - noexcept(_Current += _Off)) /* strengthened */ + constexpr _Iterator& operator+=(const difference_type _Off) + noexcept(noexcept(_Current += _Off)) /* strengthened */ requires random_access_range<_Base> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -803,8 +799,8 @@ namespace ranges { _Current += _Off; return *this; } - constexpr _Iterator& operator-=(const difference_type _Off) noexcept( - noexcept(_Current -= _Off)) /* strengthened */ + constexpr _Iterator& operator-=(const difference_type _Off) + noexcept(noexcept(_Current -= _Off)) /* strengthened */ requires random_access_range<_Base> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -827,8 +823,8 @@ namespace ranges { return _STD invoke(*_Parent->_Fun, _Current[_Idx]); } - _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Current == _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current == _Right._Current)) /* strengthened */ requires equality_comparable> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -837,8 +833,8 @@ namespace ranges { return _Left._Current == _Right._Current; } - _NODISCARD friend constexpr bool operator<(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Current < _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr bool operator<(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current < _Right._Current)) /* strengthened */ requires random_access_range<_Base> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -846,26 +842,26 @@ namespace ranges { #endif // _ITERATOR_DEBUG_LEVEL != 0 return _Left._Current < _Right._Current; } - _NODISCARD friend constexpr bool operator>(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Current < _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr bool operator>(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current < _Right._Current)) /* strengthened */ requires random_access_range<_Base> { return _Right < _Left; } - _NODISCARD friend constexpr bool operator<=(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Current < _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr bool operator<=(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current < _Right._Current)) /* strengthened */ requires random_access_range<_Base> { return !(_Right < _Left); } - _NODISCARD friend constexpr bool operator>=(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Current < _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr bool operator>=(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current < _Right._Current)) /* strengthened */ requires random_access_range<_Base> { return !(_Left < _Right); } - _NODISCARD friend constexpr auto operator<=>(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Current <=> _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr auto operator<=>(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current <=> _Right._Current)) /* strengthened */ requires random_access_range<_Base> && three_way_comparable> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -874,8 +870,8 @@ namespace ranges { return _Left._Current <=> _Right._Current; } - _NODISCARD friend constexpr _Iterator operator+(_Iterator _It, const difference_type _Off) noexcept( - noexcept(_It._Current += _Off)) /* strengthened */ + _NODISCARD friend constexpr _Iterator operator+(_Iterator _It, const difference_type _Off) + noexcept(noexcept(_It._Current += _Off)) /* strengthened */ requires random_access_range<_Base> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -884,8 +880,8 @@ namespace ranges { _It._Current += _Off; return _It; } - _NODISCARD friend constexpr _Iterator operator+(const difference_type _Off, _Iterator _It) noexcept( - noexcept(_It._Current += _Off)) /* strengthened */ + _NODISCARD friend constexpr _Iterator operator+(const difference_type _Off, _Iterator _It) + noexcept(noexcept(_It._Current += _Off)) /* strengthened */ requires random_access_range<_Base> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -895,8 +891,8 @@ namespace ranges { return _It; } - _NODISCARD friend constexpr _Iterator operator-(_Iterator _It, const difference_type _Off) noexcept( - noexcept(_It._Current -= _Off)) /* strengthened */ + _NODISCARD friend constexpr _Iterator operator-(_Iterator _It, const difference_type _Off) + noexcept(noexcept(_It._Current -= _Off)) /* strengthened */ requires random_access_range<_Base> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -907,8 +903,8 @@ namespace ranges { return _It; } - _NODISCARD friend constexpr difference_type operator-(const _Iterator& _Left, - const _Iterator& _Right) noexcept(noexcept(_Left._Current - _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr difference_type operator-(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current - _Right._Current)) /* strengthened */ requires sized_sentinel_for, iterator_t<_Base>> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -942,12 +938,12 @@ namespace ranges { public: _Sentinel() = default; - constexpr explicit _Sentinel(sentinel_t<_Base> _Last_) noexcept( - is_nothrow_move_constructible_v>) // strengthened + constexpr explicit _Sentinel(sentinel_t<_Base> _Last_) + noexcept(is_nothrow_move_constructible_v>) // strengthened : _Last(_STD move(_Last_)) {} - constexpr _Sentinel(_Sentinel _Se) noexcept( - is_nothrow_constructible_v, sentinel_t<_Vw>>) // strengthened + constexpr _Sentinel(_Sentinel _Se) + noexcept(is_nothrow_constructible_v, sentinel_t<_Vw>>) // strengthened requires _Const && convertible_to, sentinel_t<_Base>> : _Last(_STD move(_Se._Last)) {} @@ -958,35 +954,35 @@ namespace ranges { template requires sentinel_for, _Maybe_const_iter<_OtherConst>> - _NODISCARD friend constexpr bool operator==(const _Iterator<_OtherConst>& _Left, - const _Sentinel& _Right) noexcept(noexcept(_Get_current(_Left) == _Right._Last)) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Iterator<_OtherConst>& _Left, const _Sentinel& _Right) + noexcept(noexcept(_Get_current(_Left) == _Right._Last)) /* strengthened */ { return _Get_current(_Left) == _Right._Last; } template requires sized_sentinel_for, _Maybe_const_iter<_OtherConst>> _NODISCARD friend constexpr range_difference_t<_Maybe_const<_OtherConst, _Vw>> operator-( - const _Iterator<_OtherConst>& _Left, - const _Sentinel& _Right) noexcept(noexcept(_Get_current(_Left) - _Right._Last)) /* strengthened */ { + const _Iterator<_OtherConst>& _Left, const _Sentinel& _Right) + noexcept(noexcept(_Get_current(_Left) - _Right._Last)) /* strengthened */ { return _Get_current(_Left) - _Right._Last; } template requires sized_sentinel_for, _Maybe_const_iter<_OtherConst>> - _NODISCARD friend constexpr range_difference_t<_Maybe_const<_OtherConst, _Vw>> - operator-(const _Sentinel& _Left, const _Iterator<_OtherConst>& _Right) noexcept( - noexcept(_Left._Last - _Get_current(_Right))) /* strengthened */ { + _NODISCARD friend constexpr range_difference_t<_Maybe_const<_OtherConst, _Vw>> operator-( + const _Sentinel& _Left, const _Iterator<_OtherConst>& _Right) + noexcept(noexcept(_Left._Last - _Get_current(_Right))) /* strengthened */ { return _Left._Last - _Get_current(_Right); } }; public: - // clang-format off - transform_view() requires default_initializable<_Vw> && default_initializable<_Fn> = default; - // clang-format on + transform_view() + requires default_initializable<_Vw> && default_initializable<_Fn> + = default; - constexpr explicit transform_view(_Vw _Range_, _Fn _Fun_) noexcept( - is_nothrow_move_constructible_v<_Vw> && is_nothrow_move_constructible_v<_Fn>) // strengthened + constexpr explicit transform_view(_Vw _Range_, _Fn _Fun_) + noexcept(is_nothrow_move_constructible_v<_Vw> && is_nothrow_move_constructible_v<_Fn>) // strengthened : _Range(_STD move(_Range_)), _Fun{in_place, _STD move(_Fun_)} {} _NODISCARD constexpr _Vw base() const& noexcept(is_nothrow_copy_constructible_v<_Vw>) /* strengthened */ @@ -1010,9 +1006,9 @@ namespace ranges { return _Iterator{*this, _RANGES begin(_Range)}; } - _NODISCARD constexpr auto end() noexcept( - noexcept(_RANGES end(_Range)) - && is_nothrow_move_constructible_v) /* strengthened */ { + _NODISCARD constexpr auto end() + noexcept(noexcept(_RANGES end(_Range)) + && is_nothrow_move_constructible_v) /* strengthened */ { if constexpr (common_range<_Vw>) { return _Iterator{*this, _RANGES end(_Range)}; } else { diff --git a/stl/inc/__msvc_string_view.hpp b/stl/inc/__msvc_string_view.hpp index acc6ac364be..a0f6055a5c5 100644 --- a/stl/inc/__msvc_string_view.hpp +++ b/stl/inc/__msvc_string_view.hpp @@ -528,7 +528,15 @@ template constexpr bool _Traits_equal(_In_reads_(_Left_size) const _Traits_ptr_t<_Traits> _Left, const size_t _Left_size, _In_reads_(_Right_size) const _Traits_ptr_t<_Traits> _Right, const size_t _Right_size) noexcept { // compare [_Left, _Left + _Left_size) to [_Right, _Right + _Right_size) for equality using _Traits - return _Left_size == _Right_size && _Traits::compare(_Left, _Right, _Left_size) == 0; + if (_Left_size != _Right_size) { + return false; + } + + if (_Left_size == 0u) { + return true; + } + + return _Traits::compare(_Left, _Right, _Left_size) == 0; } template @@ -657,7 +665,7 @@ class _String_bitmap { // _String_bitmap for character types } constexpr bool _Match(const _Elem _Ch) const noexcept { // test if _Ch is in the bitmap - return _Matches[static_cast(_Ch)]; + return _Matches[static_cast(_Ch)]; // lgtm [cpp/unclear-array-index-validation] } private: @@ -700,25 +708,55 @@ constexpr size_t _Traits_find_first_of(_In_reads_(_Hay_size) const _Traits_ptr_t const size_t _Needle_size) noexcept { // in [_Haystack, _Haystack + _Hay_size), look for one of [_Needle, _Needle + _Needle_size), at/after _Start_at if (_Needle_size != 0 && _Start_at < _Hay_size) { // room for match, look for it + const auto _Hay_start = _Haystack + _Start_at; + const auto _Hay_end = _Haystack + _Hay_size; + if constexpr (_Special) { - _String_bitmap _Matches; - if (!_Matches._Mark(_Needle, _Needle + _Needle_size)) { // couldn't put one of the characters into the - // bitmap, fall back to the serial algorithm - return _Traits_find_first_of<_Traits, false>(_Haystack, _Hay_size, _Start_at, _Needle, _Needle_size); - } + if (!_STD _Is_constant_evaluated()) { + using _Elem = typename _Traits::char_type; + +#if _USE_STD_VECTOR_ALGORITHMS + const bool _Try_vectorize = _Hay_size - _Start_at > _Threshold_find_first_of; + + // Additional condition for when the vectorization outperforms the table lookup + const bool _Use_bitmap = !_Try_vectorize || (sizeof(_Elem) > 1 && sizeof(_Elem) * _Needle_size > 16); +#else + const bool _Use_bitmap = true; +#endif // _USE_STD_VECTOR_ALGORITHMS + + if (_Use_bitmap) { + _String_bitmap<_Elem> _Matches; + + if (_Matches._Mark(_Needle, _Needle + _Needle_size)) { + for (auto _Match_try = _Hay_start; _Match_try < _Hay_end; ++_Match_try) { + if (_Matches._Match(*_Match_try)) { + return static_cast(_Match_try - _Haystack); // found a match + } + } + return static_cast(-1); // no match + } + + // couldn't put one of the characters into the bitmap, fall back to vectorized or serial algorithms + } - const auto _End = _Haystack + _Hay_size; - for (auto _Match_try = _Haystack + _Start_at; _Match_try < _End; ++_Match_try) { - if (_Matches._Match(*_Match_try)) { - return static_cast(_Match_try - _Haystack); // found a match +#if _USE_STD_VECTOR_ALGORITHMS + if (_Try_vectorize) { + const _Traits_ptr_t<_Traits> _Found = + _STD _Find_first_of_vectorized(_Hay_start, _Hay_end, _Needle, _Needle + _Needle_size); + + if (_Found != _Hay_end) { + return static_cast(_Found - _Haystack); // found a match + } else { + return static_cast(-1); // no match + } } +#endif // _USE_STD_VECTOR_ALGORITHMS } - } else { - const auto _End = _Haystack + _Hay_size; - for (auto _Match_try = _Haystack + _Start_at; _Match_try < _End; ++_Match_try) { - if (_Traits::find(_Needle, _Needle_size, *_Match_try)) { - return static_cast(_Match_try - _Haystack); // found a match - } + } + + for (auto _Match_try = _Hay_start; _Match_try < _Hay_end; ++_Match_try) { + if (_Traits::find(_Needle, _Needle_size, *_Match_try)) { + return static_cast(_Match_try - _Haystack); // found a match } } } @@ -1202,20 +1240,15 @@ class basic_string_view { // wrapper for any kind of contiguous character buffer : _Mydata(_STD to_address(_First)), _Mysize(static_cast(_Last - _First)) {} #if _HAS_CXX23 - // clang-format off template - requires (!same_as, basic_string_view> - && _RANGES contiguous_range<_Range> - && _RANGES sized_range<_Range> - && same_as<_RANGES range_value_t<_Range>, _Elem> - && !is_convertible_v<_Range, const _Elem*> - && !requires(remove_cvref_t<_Range>& _Rng) { - _Rng.operator _STD basic_string_view<_Elem, _Traits>(); - }) - constexpr explicit basic_string_view(_Range&& _Rng) noexcept( - noexcept(_RANGES data(_Rng)) && noexcept(_RANGES size(_Rng))) // strengthened + requires (!same_as, basic_string_view> && _RANGES contiguous_range<_Range> + && _RANGES sized_range<_Range> && same_as<_RANGES range_value_t<_Range>, _Elem> + && !is_convertible_v<_Range, const _Elem*> + && !requires( + remove_cvref_t<_Range>& _Rng) { _Rng.operator _STD basic_string_view<_Elem, _Traits>(); }) + constexpr explicit basic_string_view(_Range&& _Rng) + noexcept(noexcept(_RANGES data(_Rng)) && noexcept(_RANGES size(_Rng))) // strengthened : _Mydata(_RANGES data(_Rng)), _Mysize(static_cast(_RANGES size(_Rng))) {} - // clang-format on #endif // _HAS_CXX23 #endif // _HAS_CXX20 @@ -1293,7 +1326,7 @@ class basic_string_view { // wrapper for any kind of contiguous character buffer #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Off < _Mysize, "string_view subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 - return _Mydata[_Off]; + return _Mydata[_Off]; // lgtm [cpp/unclear-array-index-validation] } _NODISCARD constexpr const_reference at(const size_type _Off) const { diff --git a/stl/inc/algorithm b/stl/inc/algorithm index a0c9712ed3d..c16afa7d042 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -59,15 +59,6 @@ const void* __stdcall __std_find_last_trivial_2(const void* _First, const void* const void* __stdcall __std_find_last_trivial_4(const void* _First, const void* _Last, uint32_t _Val) noexcept; const void* __stdcall __std_find_last_trivial_8(const void* _First, const void* _Last, uint64_t _Val) noexcept; -const void* __stdcall __std_find_first_of_trivial_1( - const void* _First1, const void* _Last1, const void* _First2, const void* _Last2) noexcept; -const void* __stdcall __std_find_first_of_trivial_2( - const void* _First1, const void* _Last1, const void* _First2, const void* _Last2) noexcept; -const void* __stdcall __std_find_first_of_trivial_4( - const void* _First1, const void* _Last1, const void* _First2, const void* _Last2) noexcept; -const void* __stdcall __std_find_first_of_trivial_8( - const void* _First1, const void* _Last1, const void* _First2, const void* _Last2) noexcept; - __declspec(noalias) _Min_max_1i __stdcall __std_minmax_1i(const void* _First, const void* _Last) noexcept; __declspec(noalias) _Min_max_1u __stdcall __std_minmax_1u(const void* _First, const void* _Last) noexcept; __declspec(noalias) _Min_max_2i __stdcall __std_minmax_2i(const void* _First, const void* _Last) noexcept; @@ -198,27 +189,6 @@ _Ty* _Find_last_vectorized(_Ty* const _First, _Ty* const _Last, const _TVal _Val } } -template -_Ty1* _Find_first_of_vectorized( - _Ty1* const _First1, _Ty1* const _Last1, _Ty2* const _First2, _Ty2* const _Last2) noexcept { - _STL_INTERNAL_STATIC_ASSERT(sizeof(_Ty1) == sizeof(_Ty2)); - if constexpr (sizeof(_Ty1) == 1) { - return const_cast<_Ty1*>( - static_cast(::__std_find_first_of_trivial_1(_First1, _Last1, _First2, _Last2))); - } else if constexpr (sizeof(_Ty1) == 2) { - return const_cast<_Ty1*>( - static_cast(::__std_find_first_of_trivial_2(_First1, _Last1, _First2, _Last2))); - } else if constexpr (sizeof(_Ty1) == 4) { - return const_cast<_Ty1*>( - static_cast(::__std_find_first_of_trivial_4(_First1, _Last1, _First2, _Last2))); - } else if constexpr (sizeof(_Ty1) == 8) { - return const_cast<_Ty1*>( - static_cast(::__std_find_first_of_trivial_8(_First1, _Last1, _First2, _Last2))); - } else { - _STL_INTERNAL_STATIC_ASSERT(false); // unexpected size - } -} - template __declspec(noalias) void _Replace_vectorized( _Ty* const _First, _Ty* const _Last, const _TVal1 _Old_val, const _TVal2 _New_val) noexcept { @@ -237,9 +207,6 @@ __declspec(noalias) void _Replace_vectorized( } } -// find_first_of vectorization is likely to be a win after this size (in elements) -_INLINE_VAR constexpr ptrdiff_t _Threshold_find_first_of = 16; - // Can we activate the vector algorithms for find_first_of? template constexpr bool _Vector_alg_in_find_first_of_is_safe = _Equal_memcmp_is_safe<_It1, _It2, _Pr>; @@ -2140,6 +2107,26 @@ _NODISCARD _CONSTEXPR20 _FwdItHaystack search(_FwdItHaystack _First1, _FwdItHays if constexpr (_Is_ranges_random_iter_v<_FwdItHaystack> && _Is_ranges_random_iter_v<_FwdItPat>) { const _Iter_diff_t<_FwdItPat> _Count2 = _ULast2 - _UFirst2; if (_ULast1 - _UFirst1 >= _Count2) { +#if _USE_STD_VECTOR_ALGORITHMS + if constexpr (_Vector_alg_in_search_is_safe) { + if (!_STD _Is_constant_evaluated()) { + const auto _Ptr1 = _STD _To_address(_UFirst1); + + const auto _Ptr_res1 = _STD _Search_vectorized( + _Ptr1, _STD _To_address(_ULast1), _STD _To_address(_UFirst2), static_cast(_Count2)); + + if constexpr (is_pointer_v) { + _UFirst1 = _Ptr_res1; + } else { + _UFirst1 += _Ptr_res1 - _Ptr1; + } + + _STD _Seek_wrapped(_Last1, _UFirst1); + return _Last1; + } + } +#endif // _USE_STD_VECTOR_ALGORITHMS + const auto _Last_possible = _ULast1 - static_cast<_Iter_diff_t<_FwdItHaystack>>(_Count2); for (;; ++_UFirst1) { if (_STD _Equal_rev_pred_unchecked(_UFirst1, _UFirst2, _ULast2, _STD _Pass_fn(_Pred))) { @@ -7064,9 +7051,9 @@ namespace ranges { template _NODISCARD constexpr _It _Lower_bound_unchecked( - _It _First, iter_difference_t<_It> _Count, const _Ty& _Val, _Pr _Pred, _Pj _Proj) { + _It _First, iter_difference_t<_It> _Count, _Ty&& _Val, _Pr _Pred, _Pj _Proj) { _STL_INTERNAL_STATIC_ASSERT(forward_iterator<_It>); - _STL_INTERNAL_STATIC_ASSERT(indirect_strict_weak_order<_Pr, const _Ty*, projected<_It, _Pj>>); + _STL_INTERNAL_STATIC_ASSERT(indirect_strict_weak_order<_Pr, add_pointer_t<_Ty>, projected<_It, _Pj>>); using _Diff = iter_difference_t<_It>; @@ -7115,9 +7102,9 @@ namespace ranges { template _NODISCARD constexpr _It _Upper_bound_unchecked( - _It _First, iter_difference_t<_It> _Count, const _Ty& _Val, _Pr _Pred, _Pj _Proj) { + _It _First, iter_difference_t<_It> _Count, _Ty&& _Val, _Pr _Pred, _Pj _Proj) { _STL_INTERNAL_STATIC_ASSERT(forward_iterator<_It>); - _STL_INTERNAL_STATIC_ASSERT(indirect_strict_weak_order<_Pr, const _Ty*, projected<_It, _Pj>>); + _STL_INTERNAL_STATIC_ASSERT(indirect_strict_weak_order<_Pr, add_pointer_t<_Ty>, projected<_It, _Pj>>); using _Diff = iter_difference_t<_It>; @@ -10186,9 +10173,9 @@ namespace ranges { #endif // _HAS_CXX17 _EXPORT_STD template -_NODISCARD constexpr pair minmax(const _Ty& _Left _MSVC_LIFETIMEBOUND, - const _Ty& _Right _MSVC_LIFETIMEBOUND, - _Pr _Pred) noexcept(noexcept(_DEBUG_LT_PRED(_Pred, _Right, _Left))) /* strengthened */ { +_NODISCARD constexpr pair minmax( + const _Ty& _Left _MSVC_LIFETIMEBOUND, const _Ty& _Right _MSVC_LIFETIMEBOUND, _Pr _Pred) + noexcept(noexcept(_DEBUG_LT_PRED(_Pred, _Right, _Left))) /* strengthened */ { // return pair(leftmost/smaller, rightmost/larger) of _Left and _Right if (_DEBUG_LT_PRED(_Pred, _Right, _Left)) { return {_Right, _Left}; @@ -10203,7 +10190,7 @@ _NODISCARD constexpr pair<_Ty, _Ty> minmax(initializer_list<_Ty> _Ilist, _Pr _Pr _STL_ASSERT( _Ilist.size() != 0, "An initializer_list passed to std::minmax must not be empty. (N4971 [alg.min.max]/21)"); #if _USE_STD_VECTOR_ALGORITHMS - if constexpr (_Is_min_max_optimization_safe) { + if constexpr (_Is_min_max_value_optimization_safe) { if (!_STD _Is_constant_evaluated()) { const auto _Result = _STD _Minmax_vectorized(_Ilist.begin(), _Ilist.end()); return {static_cast<_Ty>(_Result._Min), static_cast<_Ty>(_Result._Max)}; @@ -10260,6 +10247,21 @@ namespace ranges { const auto _Last = _Range.end(); _STL_ASSERT(_First != _Last, "An initializer_list passed to std::ranges::minmax must not be empty. (N4971 [alg.min.max]/21)"); +#if _USE_STD_VECTOR_ALGORITHMS + if constexpr (is_same_v<_Pj, identity>) { + if constexpr (_Is_min_max_value_optimization_safe) { + if (!_STD is_constant_evaluated()) { + const auto _Result = _STD _Minmax_vectorized(_First, _Last); + return {static_cast<_Ty>(_Result._Min), static_cast<_Ty>(_Result._Max)}; + } + } else if constexpr (_Is_min_max_optimization_safe) { + if (!_STD is_constant_evaluated()) { + const auto _Result = _STD _Minmax_element_vectorized(_First, _Last); + return {*static_cast(_Result.first), *static_cast(_Result.second)}; + } + } + } +#endif // _USE_STD_VECTOR_ALGORITHMS return _Minmax_fwd_unchecked(_First, _Last, _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); } @@ -10272,11 +10274,30 @@ namespace ranges { auto _ULast = _RANGES _Uend(_Range); _STL_ASSERT( _UFirst != _ULast, "A range passed to std::ranges::minmax must not be empty. (N4971 [alg.min.max]/21)"); + using _Vty = range_value_t<_Rng>; +#if _USE_STD_VECTOR_ALGORITHMS + if constexpr (is_same_v<_Pj, identity> && sized_sentinel_for) { + if constexpr (_Is_min_max_value_optimization_safe) { + if (!_STD is_constant_evaluated()) { + const auto _First_ptr = _STD to_address(_UFirst); + const auto _Last_ptr = _First_ptr + (_ULast - _UFirst); + const auto _Result = _STD _Minmax_vectorized(_First_ptr, _Last_ptr); + return {static_cast<_Vty>(_Result._Min), static_cast<_Vty>(_Result._Max)}; + } + } else if constexpr (_Is_min_max_optimization_safe) { + if (!_STD is_constant_evaluated()) { + const auto _First_ptr = _STD to_address(_UFirst); + const auto _Last_ptr = _First_ptr + (_ULast - _UFirst); + const auto _Result = _STD _Minmax_element_vectorized(_First_ptr, _Last_ptr); + return {*static_cast(_Result.first), *static_cast(_Result.second)}; + } + } + } +#endif // _USE_STD_VECTOR_ALGORITHMS if constexpr (forward_range<_Rng> && _Prefer_iterator_copies) { return _Minmax_fwd_unchecked( _STD move(_UFirst), _STD move(_ULast), _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); } else { - using _Vty = range_value_t<_Rng>; // This initialization is correct, similar to the N4950 [dcl.init.aggr]/6 example minmax_result<_Vty> _Found = {static_cast<_Vty>(*_UFirst), _Found.min}; if (_UFirst == _ULast) { @@ -10331,17 +10352,6 @@ namespace ranges { _STL_INTERNAL_CHECK(_First != _Last); using _Vty = iter_value_t<_It>; -#if _USE_STD_VECTOR_ALGORITHMS - if constexpr (is_same_v<_Pj, identity> && _Is_min_max_optimization_safe<_It, _Pr> - && sized_sentinel_for<_Se, _It>) { - if (!_STD is_constant_evaluated()) { - const auto _First_ptr = _STD to_address(_First); - const auto _Last_ptr = _First_ptr + (_Last - _First); - const auto _Result = _STD _Minmax_vectorized(_First_ptr, _Last_ptr); - return {static_cast<_Vty>(_Result._Min), static_cast<_Vty>(_Result._Max)}; - } - } -#endif // _USE_STD_VECTOR_ALGORITHMS auto _Found_min = _First; if (++_First == _Last) { diff --git a/stl/inc/atomic b/stl/inc/atomic index 67582d9b4f7..b9b48316567 100644 --- a/stl/inc/atomic +++ b/stl/inc/atomic @@ -2089,8 +2089,7 @@ struct _Atomic_nonobject_pointer : _Atomic_storage<_Ty> { using _Base::_Base; }; -#define ATOMIC_VAR_INIT(_Value) \ - { _Value } +#define ATOMIC_VAR_INIT(_Value) {_Value} template using _Choose_atomic_base2_t = diff --git a/stl/inc/charconv b/stl/inc/charconv index 666be9f0372..5dee948f3f2 100644 --- a/stl/inc/charconv +++ b/stl/inc/charconv @@ -228,7 +228,7 @@ _STL_INTERNAL_STATIC_ASSERT(_STD size(_Digit_from_byte) == 256); _NODISCARD _CONSTEXPR23 unsigned char _Digit_from_char(const char _Ch) noexcept { // convert ['0', '9'] ['A', 'Z'] ['a', 'z'] to [0, 35], everything else to 255 - return _Digit_from_byte[static_cast(_Ch)]; + return _Digit_from_byte[static_cast(_Ch)]; // lgtm [cpp/unclear-array-index-validation] } template diff --git a/stl/inc/chrono b/stl/inc/chrono index 4a8e089c91a..c983d982154 100644 --- a/stl/inc/chrono +++ b/stl/inc/chrono @@ -1944,65 +1944,75 @@ namespace chrono { return _Elapsed_offset; } - private: - sys_seconds _Date; - bool _Is_positive; - seconds _Elapsed_offset; - }; + _NODISCARD friend constexpr bool operator==(const leap_second& _Left, const leap_second& _Right) noexcept { + return _Left.date() == _Right.date(); + } + template + _NODISCARD friend constexpr bool operator==( + const leap_second& _Left, const sys_time<_Duration>& _Right) noexcept { + return _Left.date() == _Right; + } - _EXPORT_STD _NODISCARD constexpr bool operator==(const leap_second& _Left, const leap_second& _Right) noexcept { - return _Left.date() == _Right.date(); - } - _EXPORT_STD template - _NODISCARD constexpr bool operator==(const leap_second& _Left, const sys_time<_Duration>& _Right) noexcept { - return _Left.date() == _Right; - } + template + _NODISCARD friend constexpr bool operator<( + const leap_second& _Left, const sys_time<_Duration>& _Right) noexcept { + return _Left.date() < _Right; + } + template + _NODISCARD friend constexpr bool operator<( + const sys_time<_Duration>& _Left, const leap_second& _Right) noexcept { + return _Left < _Right.date(); + } - _EXPORT_STD template - _NODISCARD constexpr bool operator<(const leap_second& _Left, const sys_time<_Duration>& _Right) noexcept { - return _Left.date() < _Right; - } - _EXPORT_STD template - _NODISCARD constexpr bool operator<(const sys_time<_Duration>& _Left, const leap_second& _Right) noexcept { - return _Left < _Right.date(); - } + template + _NODISCARD friend constexpr bool operator>( + const leap_second& _Left, const sys_time<_Duration>& _Right) noexcept { + return _Right < _Left.date(); + } + template + _NODISCARD friend constexpr bool operator>( + const sys_time<_Duration>& _Left, const leap_second& _Right) noexcept { + return _Right.date() < _Left; + } - _EXPORT_STD template - _NODISCARD constexpr bool operator>(const leap_second& _Left, const sys_time<_Duration>& _Right) noexcept { - return _Right < _Left.date(); - } - _EXPORT_STD template - _NODISCARD constexpr bool operator>(const sys_time<_Duration>& _Left, const leap_second& _Right) noexcept { - return _Right.date() < _Left; - } + template + _NODISCARD friend constexpr bool operator<=( + const leap_second& _Left, const sys_time<_Duration>& _Right) noexcept { + return !(_Right < _Left.date()); + } + template + _NODISCARD friend constexpr bool operator<=( + const sys_time<_Duration>& _Left, const leap_second& _Right) noexcept { + return !(_Right.date() < _Left); + } - _EXPORT_STD template - _NODISCARD constexpr bool operator<=(const leap_second& _Left, const sys_time<_Duration>& _Right) noexcept { - return !(_Right < _Left.date()); - } - _EXPORT_STD template - _NODISCARD constexpr bool operator<=(const sys_time<_Duration>& _Left, const leap_second& _Right) noexcept { - return !(_Right.date() < _Left); - } + template + _NODISCARD friend constexpr bool operator>=( + const leap_second& _Left, const sys_time<_Duration>& _Right) noexcept { + return !(_Left.date() < _Right); + } + template + _NODISCARD friend constexpr bool operator>=( + const sys_time<_Duration>& _Left, const leap_second& _Right) noexcept { + return !(_Left < _Right.date()); + } - _EXPORT_STD template - _NODISCARD constexpr bool operator>=(const leap_second& _Left, const sys_time<_Duration>& _Right) noexcept { - return !(_Left.date() < _Right); - } - _EXPORT_STD template - _NODISCARD constexpr bool operator>=(const sys_time<_Duration>& _Left, const leap_second& _Right) noexcept { - return !(_Left < _Right.date()); - } + template + requires three_way_comparable_with> + _NODISCARD friend constexpr auto operator<=>( + const leap_second& _Left, const sys_time<_Duration>& _Right) noexcept { + return _Left.date() <=> _Right; + } + _NODISCARD friend constexpr strong_ordering operator<=>( + const leap_second& _Left, const leap_second& _Right) noexcept { + return _Left.date() <=> _Right.date(); + } - _EXPORT_STD template - requires three_way_comparable_with> - _NODISCARD constexpr auto operator<=>(const leap_second& _Left, const sys_time<_Duration>& _Right) noexcept { - return _Left.date() <=> _Right; - } - _EXPORT_STD _NODISCARD constexpr strong_ordering operator<=>( - const leap_second& _Left, const leap_second& _Right) noexcept { - return _Left.date() <=> _Right.date(); - } + private: + sys_seconds _Date; + bool _Is_positive; + seconds _Elapsed_offset; + }; // [time.zone.link] @@ -2199,6 +2209,7 @@ namespace chrono { auto [_Icu_version, _Zones, _Links] = _Tzdb_generate_time_zones(); auto [_Leap_sec, _All_ls_positive] = _Tzdb_generate_leap_seconds(0); auto _Version = _Icu_version + "." + _STD to_string(_Leap_sec.size()); + // TRANSITION, VSO-2228186, should call emplace_front with construction arguments _Tzdb_list.emplace_front(tzdb{ _STD move(_Version), _STD move(_Zones), _STD move(_Links), _STD move(_Leap_sec), _All_ls_positive}); } @@ -2256,6 +2267,7 @@ namespace chrono { } auto _Version = _Tzdb_update_version(_Tzdb.version, _Leap_sec.size()); + // TRANSITION, VSO-2228186, should call emplace_front with construction arguments _Tzdb_list.emplace_front(tzdb{ _STD move(_Version), _STD move(_Zones), _STD move(_Links), _STD move(_Leap_sec), _All_ls_positive}); } @@ -4659,18 +4671,14 @@ namespace chrono { // [time.format] -// clang-format off template -concept _Chrono_parse_spec_callbacks = _Parse_align_callbacks<_Ty, _CharT> - && _Parse_width_callbacks<_Ty, _CharT> - && _Parse_precision_callbacks<_Ty, _CharT> - && _Width_adapter_callbacks<_Ty, _CharT> - && _Precision_adapter_callbacks<_Ty, _CharT> - && requires(_Ty _At, basic_string_view<_CharT> _Sv, _Fmt_align _Aln) { - { _At._On_conversion_spec(char{}, _CharT{}) } -> same_as; - { _At._On_lit_char(_CharT{}) } -> same_as; -}; -// clang-format on +concept _Chrono_parse_spec_callbacks = + _Parse_align_callbacks<_Ty, _CharT> && _Parse_width_callbacks<_Ty, _CharT> + && _Parse_precision_callbacks<_Ty, _CharT> && _Width_adapter_callbacks<_Ty, _CharT> + && _Precision_adapter_callbacks<_Ty, _CharT> && requires(_Ty _At, basic_string_view<_CharT> _Sv, _Fmt_align _Aln) { + { _At._On_conversion_spec(char{}, _CharT{}) } -> same_as; + { _At._On_lit_char(_CharT{}) } -> same_as; + }; template concept _Has_ok = requires(_Ty _At) { @@ -5064,7 +5072,7 @@ namespace chrono { basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& _Os, const month& _Val) { return _Os << (_Val.ok() ? _STD format(_Os.getloc(), _STATICALLY_WIDEN(_CharT, "{:L%b}"), _Val) : _STD format(_Os.getloc(), _STATICALLY_WIDEN(_CharT, "{} is not a valid month"), - static_cast(_Val))); + static_cast(_Val))); } _EXPORT_STD template @@ -5077,7 +5085,7 @@ namespace chrono { basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& _Os, const weekday& _Val) { return _Os << (_Val.ok() ? _STD format(_Os.getloc(), _STATICALLY_WIDEN(_CharT, "{:L%a}"), _Val) : _STD format(_Os.getloc(), _STATICALLY_WIDEN(_CharT, "{} is not a valid weekday"), - _Val.c_encoding())); + _Val.c_encoding())); } _EXPORT_STD template @@ -5086,7 +5094,7 @@ namespace chrono { return _Os << (_Idx >= 1 && _Idx <= 5 ? _STD format(_Os.getloc(), _STATICALLY_WIDEN(_CharT, "{:L}[{}]"), _Val.weekday(), _Idx) : _STD format(_Os.getloc(), _STATICALLY_WIDEN(_CharT, "{:L}[{} is not a valid index]"), - _Val.weekday(), _Idx)); + _Val.weekday(), _Idx)); } _EXPORT_STD template @@ -5793,62 +5801,158 @@ template struct formatter<_CHRONO duration<_Rep, _Period>, _CharT> : _Fill_tm_formatter<_CHRONO duration<_Rep, _Period>, _CharT> {}; +#if _HAS_CXX23 +template +constexpr bool enable_nonlocking_formatter_optimization<_CHRONO duration<_Rep, _Period>> = + enable_nonlocking_formatter_optimization<_Rep>; +#endif // _HAS_CXX23 + template <_Format_supported_charT _CharT> struct formatter<_CHRONO day, _CharT> : _Fill_tm_formatter<_CHRONO day, _CharT> {}; +#if _HAS_CXX23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<_CHRONO day> = true; +#endif // _HAS_CXX23 + template <_Format_supported_charT _CharT> struct formatter<_CHRONO month, _CharT> : _Fill_tm_formatter<_CHRONO month, _CharT> {}; +#if _HAS_CXX23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<_CHRONO month> = true; +#endif // _HAS_CXX23 + template <_Format_supported_charT _CharT> struct formatter<_CHRONO year, _CharT> : _Fill_tm_formatter<_CHRONO year, _CharT> {}; +#if _HAS_CXX23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<_CHRONO year> = true; +#endif // _HAS_CXX23 + template <_Format_supported_charT _CharT> struct formatter<_CHRONO weekday, _CharT> : _Fill_tm_formatter<_CHRONO weekday, _CharT> {}; +#if _HAS_CXX23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<_CHRONO weekday> = true; +#endif // _HAS_CXX23 + template <_Format_supported_charT _CharT> struct formatter<_CHRONO weekday_indexed, _CharT> : _Fill_tm_formatter<_CHRONO weekday_indexed, _CharT> {}; +#if _HAS_CXX23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<_CHRONO weekday_indexed> = true; +#endif // _HAS_CXX23 + template <_Format_supported_charT _CharT> struct formatter<_CHRONO weekday_last, _CharT> : _Fill_tm_formatter<_CHRONO weekday_last, _CharT> {}; +#if _HAS_CXX23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<_CHRONO weekday_last> = true; +#endif // _HAS_CXX23 + template <_Format_supported_charT _CharT> struct formatter<_CHRONO month_day, _CharT> : _Fill_tm_formatter<_CHRONO month_day, _CharT> {}; +#if _HAS_CXX23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<_CHRONO month_day> = true; +#endif // _HAS_CXX23 + template <_Format_supported_charT _CharT> struct formatter<_CHRONO month_day_last, _CharT> : _Fill_tm_formatter<_CHRONO month_day_last, _CharT> {}; +#if _HAS_CXX23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<_CHRONO month_day_last> = true; +#endif // _HAS_CXX23 + template <_Format_supported_charT _CharT> struct formatter<_CHRONO month_weekday, _CharT> : _Fill_tm_formatter<_CHRONO month_weekday, _CharT> {}; +#if _HAS_CXX23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<_CHRONO month_weekday> = true; +#endif // _HAS_CXX23 + template <_Format_supported_charT _CharT> struct formatter<_CHRONO month_weekday_last, _CharT> : _Fill_tm_formatter<_CHRONO month_weekday_last, _CharT> {}; +#if _HAS_CXX23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<_CHRONO month_weekday_last> = true; +#endif // _HAS_CXX23 + template <_Format_supported_charT _CharT> struct formatter<_CHRONO year_month, _CharT> : _Fill_tm_formatter<_CHRONO year_month, _CharT> {}; +#if _HAS_CXX23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<_CHRONO year_month> = true; +#endif // _HAS_CXX23 + template <_Format_supported_charT _CharT> struct formatter<_CHRONO year_month_day, _CharT> : _Fill_tm_formatter<_CHRONO year_month_day, _CharT> {}; +#if _HAS_CXX23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<_CHRONO year_month_day> = true; +#endif // _HAS_CXX23 + template <_Format_supported_charT _CharT> struct formatter<_CHRONO year_month_day_last, _CharT> : _Fill_tm_formatter<_CHRONO year_month_day_last, _CharT> {}; +#if _HAS_CXX23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<_CHRONO year_month_day_last> = true; +#endif // _HAS_CXX23 + template <_Format_supported_charT _CharT> struct formatter<_CHRONO year_month_weekday, _CharT> : _Fill_tm_formatter<_CHRONO year_month_weekday, _CharT> {}; +#if _HAS_CXX23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<_CHRONO year_month_weekday> = true; +#endif // _HAS_CXX23 + template <_Format_supported_charT _CharT> struct formatter<_CHRONO year_month_weekday_last, _CharT> : _Fill_tm_formatter<_CHRONO year_month_weekday_last, _CharT> {}; +#if _HAS_CXX23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<_CHRONO year_month_weekday_last> = true; +#endif // _HAS_CXX23 + template struct formatter<_CHRONO hh_mm_ss<_CHRONO duration<_Rep, _Period>>, _CharT> : _Fill_tm_formatter<_CHRONO hh_mm_ss<_CHRONO duration<_Rep, _Period>>, _CharT> {}; +#if _HAS_CXX23 +template +constexpr bool enable_nonlocking_formatter_optimization<_CHRONO hh_mm_ss<_CHRONO duration<_Rep, _Period>>> = true; +#endif // _HAS_CXX23 + template <_Format_supported_charT _CharT> struct formatter<_CHRONO sys_info, _CharT> : _Fill_tm_formatter<_CHRONO sys_info, _CharT> {}; +#if _HAS_CXX23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<_CHRONO sys_info> = true; +#endif // _HAS_CXX23 + template <_Format_supported_charT _CharT> struct formatter<_CHRONO local_info, _CharT> : _Fill_tm_formatter<_CHRONO local_info, _CharT> {}; +#if _HAS_CXX23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<_CHRONO local_info> = true; +#endif // _HAS_CXX23 + template struct formatter<_CHRONO sys_time<_Duration>, _CharT> { constexpr auto parse(basic_format_parse_context<_CharT>& _Parse_ctx) { @@ -5864,6 +5968,11 @@ private: _CHRONO _Chrono_formatter<_CharT> _Impl{_STATICALLY_WIDEN(_CharT, "UTC")}; }; +#if _HAS_CXX23 +template +constexpr bool enable_nonlocking_formatter_optimization<_CHRONO sys_time<_Duration>> = true; +#endif // _HAS_CXX23 + template struct formatter<_CHRONO utc_time<_Duration>, _CharT> { constexpr auto parse(basic_format_parse_context<_CharT>& _Parse_ctx) { @@ -5880,6 +5989,11 @@ private: _CHRONO _Chrono_formatter<_CharT> _Impl{_STATICALLY_WIDEN(_CharT, "UTC")}; }; +#if _HAS_CXX23 +template +constexpr bool enable_nonlocking_formatter_optimization<_CHRONO utc_time<_Duration>> = true; +#endif // _HAS_CXX23 + template struct formatter<_CHRONO tai_time<_Duration>, _CharT> { constexpr auto parse(basic_format_parse_context<_CharT>& _Parse_ctx) { @@ -5899,6 +6013,11 @@ private: _CHRONO _Chrono_formatter<_CharT> _Impl{_STATICALLY_WIDEN(_CharT, "TAI")}; }; +#if _HAS_CXX23 +template +constexpr bool enable_nonlocking_formatter_optimization<_CHRONO tai_time<_Duration>> = true; +#endif // _HAS_CXX23 + template struct formatter<_CHRONO gps_time<_Duration>, _CharT> { constexpr auto parse(basic_format_parse_context<_CharT>& _Parse_ctx) { @@ -5918,6 +6037,11 @@ private: _CHRONO _Chrono_formatter<_CharT> _Impl{_STATICALLY_WIDEN(_CharT, "GPS")}; }; +#if _HAS_CXX23 +template +constexpr bool enable_nonlocking_formatter_optimization<_CHRONO gps_time<_Duration>> = true; +#endif // _HAS_CXX23 + template struct formatter<_CHRONO file_time<_Duration>, _CharT> { constexpr auto parse(basic_format_parse_context<_CharT>& _Parse_ctx) { @@ -5935,13 +6059,28 @@ private: _CHRONO _Chrono_formatter<_CharT> _Impl{_STATICALLY_WIDEN(_CharT, "UTC")}; }; +#if _HAS_CXX23 +template +constexpr bool enable_nonlocking_formatter_optimization<_CHRONO file_time<_Duration>> = true; +#endif // _HAS_CXX23 + template struct formatter<_CHRONO local_time<_Duration>, _CharT> : _Fill_tm_formatter<_CHRONO local_time<_Duration>, _CharT> {}; +#if _HAS_CXX23 +template +constexpr bool enable_nonlocking_formatter_optimization<_CHRONO local_time<_Duration>> = true; +#endif // _HAS_CXX23 + template struct formatter<_CHRONO _Local_time_format_t<_Duration>, _CharT> : _Fill_tm_formatter<_CHRONO _Local_time_format_t<_Duration>, _CharT> {}; +#if _HAS_CXX23 +template +constexpr bool enable_nonlocking_formatter_optimization<_CHRONO _Local_time_format_t<_Duration>> = true; +#endif // _HAS_CXX23 + template struct formatter<_CHRONO zoned_time<_Duration, _TimeZonePtr>, _CharT> : formatter<_CHRONO _Local_time_format_t<_Duration>, _CharT> { @@ -5954,6 +6093,11 @@ struct formatter<_CHRONO zoned_time<_Duration, _TimeZonePtr>, _CharT> } }; +#if _HAS_CXX23 +template +constexpr bool enable_nonlocking_formatter_optimization<_CHRONO zoned_time<_Duration, const _CHRONO time_zone*>> = true; +#endif // _HAS_CXX23 + namespace chrono { template _NODISCARD string nonexistent_local_time::_Make_string(const local_time<_Duration>& _Tp, const local_info& _Info) { diff --git a/stl/inc/cmath b/stl/inc/cmath index 34052e7628d..885819380b9 100644 --- a/stl/inc/cmath +++ b/stl/inc/cmath @@ -605,7 +605,8 @@ _STD _Common_float_type_t<_Ty1, _Ty2> remquo(_Ty1 _Left, _Ty2 _Right, int* _Pquo return __builtin_##NAME(_Xx); \ } -// Updated by P0533R9 "constexpr For And ", but the builtins aren't constexpr as of Clang 18. +// Updated by P0533R9 "constexpr For And ". +// TRANSITION, Clang 20: The builtins were made constexpr by LLVM-94118. #define _CLANG_BUILTIN2_ARG(NAME, ARG) \ _NODISCARD _Check_return_ inline bool NAME(_In_ ARG _Xx, _In_ ARG _Yx) noexcept /* strengthened */ { \ return __builtin_##NAME(_Xx, _Yx); \ diff --git a/stl/inc/complex b/stl/inc/complex index 0292883927f..d1df8ab2c46 100644 --- a/stl/inc/complex +++ b/stl/inc/complex @@ -1418,147 +1418,147 @@ public: }; _EXPORT_STD template -_NODISCARD _CONSTEXPR20 complex<_Ty> operator+(const complex<_Ty>& _Left, const complex<_Ty>& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD _CONSTEXPR20 complex<_Ty> operator+(const complex<_Ty>& _Left, const complex<_Ty>& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { complex<_Ty> _Tmp(_Left); _Tmp += _Right; return _Tmp; } _EXPORT_STD template -_NODISCARD _CONSTEXPR20 complex<_Ty> operator+(const complex<_Ty>& _Left, const _Ty& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD _CONSTEXPR20 complex<_Ty> operator+(const complex<_Ty>& _Left, const _Ty& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { complex<_Ty> _Tmp(_Left); _Tmp += _Right; return _Tmp; } _EXPORT_STD template -_NODISCARD _CONSTEXPR20 complex<_Ty> operator+(const _Ty& _Left, const complex<_Ty>& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD _CONSTEXPR20 complex<_Ty> operator+(const _Ty& _Left, const complex<_Ty>& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { complex<_Ty> _Tmp(_Right); _Tmp += _Left; return _Tmp; } _EXPORT_STD template -_NODISCARD _CONSTEXPR20 complex<_Ty> operator-(const complex<_Ty>& _Left, const complex<_Ty>& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD _CONSTEXPR20 complex<_Ty> operator-(const complex<_Ty>& _Left, const complex<_Ty>& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { complex<_Ty> _Tmp(_Left); _Tmp -= _Right; return _Tmp; } _EXPORT_STD template -_NODISCARD _CONSTEXPR20 complex<_Ty> operator-(const complex<_Ty>& _Left, const _Ty& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD _CONSTEXPR20 complex<_Ty> operator-(const complex<_Ty>& _Left, const _Ty& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { complex<_Ty> _Tmp(_Left); _Tmp -= _Right; return _Tmp; } _EXPORT_STD template -_NODISCARD _CONSTEXPR20 complex<_Ty> operator-(const _Ty& _Left, const complex<_Ty>& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD _CONSTEXPR20 complex<_Ty> operator-(const _Ty& _Left, const complex<_Ty>& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { complex<_Ty> _Tmp(_Left); _Tmp -= _Right; return _Tmp; } _EXPORT_STD template -_NODISCARD _CONSTEXPR20 complex<_Ty> operator*(const complex<_Ty>& _Left, const complex<_Ty>& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD _CONSTEXPR20 complex<_Ty> operator*(const complex<_Ty>& _Left, const complex<_Ty>& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { complex<_Ty> _Tmp(_Left); _Tmp *= _Right; return _Tmp; } _EXPORT_STD template -_NODISCARD _CONSTEXPR20 complex<_Ty> operator*(const complex<_Ty>& _Left, const _Ty& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD _CONSTEXPR20 complex<_Ty> operator*(const complex<_Ty>& _Left, const _Ty& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { complex<_Ty> _Tmp(_Left); _Tmp *= _Right; return _Tmp; } _EXPORT_STD template -_NODISCARD _CONSTEXPR20 complex<_Ty> operator*(const _Ty& _Left, const complex<_Ty>& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD _CONSTEXPR20 complex<_Ty> operator*(const _Ty& _Left, const complex<_Ty>& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { complex<_Ty> _Tmp(_Right); _Tmp *= _Left; return _Tmp; } _EXPORT_STD template -_NODISCARD _CONSTEXPR20 complex<_Ty> operator/(const complex<_Ty>& _Left, const complex<_Ty>& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD _CONSTEXPR20 complex<_Ty> operator/(const complex<_Ty>& _Left, const complex<_Ty>& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { complex<_Ty> _Tmp(_Left); _Tmp /= _Right; return _Tmp; } _EXPORT_STD template -_NODISCARD _CONSTEXPR20 complex<_Ty> operator/(const complex<_Ty>& _Left, const _Ty& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD _CONSTEXPR20 complex<_Ty> operator/(const complex<_Ty>& _Left, const _Ty& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { complex<_Ty> _Tmp(_Left); _Tmp /= _Right; return _Tmp; } _EXPORT_STD template -_NODISCARD _CONSTEXPR20 complex<_Ty> operator/(const _Ty& _Left, const complex<_Ty>& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD _CONSTEXPR20 complex<_Ty> operator/(const _Ty& _Left, const complex<_Ty>& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { complex<_Ty> _Tmp(_Left); _Tmp /= _Right; return _Tmp; } _EXPORT_STD template -_NODISCARD _CONSTEXPR20 complex<_Ty> operator+(const complex<_Ty>& _Left) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD _CONSTEXPR20 complex<_Ty> operator+(const complex<_Ty>& _Left) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { return _Left; } _EXPORT_STD template -_NODISCARD _CONSTEXPR20 complex<_Ty> operator-(const complex<_Ty>& _Left) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD _CONSTEXPR20 complex<_Ty> operator-(const complex<_Ty>& _Left) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { return complex<_Ty>(-_Left.real(), -_Left.imag()); } _EXPORT_STD template -_NODISCARD constexpr bool operator==(const complex<_Ty>& _Left, const complex<_Ty>& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD constexpr bool operator==(const complex<_Ty>& _Left, const complex<_Ty>& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { return _Left.real() == _Right.real() && _Left.imag() == _Right.imag(); } _EXPORT_STD template -_NODISCARD constexpr bool operator==(const complex<_Ty>& _Left, const _Ty& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD constexpr bool operator==(const complex<_Ty>& _Left, const _Ty& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { return _Left.real() == _Right && _Left.imag() == 0; } #if !_HAS_CXX20 template -_NODISCARD constexpr bool operator==(const _Ty& _Left, const complex<_Ty>& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD constexpr bool operator==(const _Ty& _Left, const complex<_Ty>& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { return _Left == _Right.real() && 0 == _Right.imag(); } template -_NODISCARD constexpr bool operator!=(const complex<_Ty>& _Left, const complex<_Ty>& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD constexpr bool operator!=(const complex<_Ty>& _Left, const complex<_Ty>& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { return !(_Left == _Right); } template -_NODISCARD constexpr bool operator!=(const complex<_Ty>& _Left, const _Ty& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD constexpr bool operator!=(const complex<_Ty>& _Left, const _Ty& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { return !(_Left == _Right); } template -_NODISCARD constexpr bool operator!=(const _Ty& _Left, const complex<_Ty>& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD constexpr bool operator!=(const _Ty& _Left, const complex<_Ty>& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { return !(_Left == _Right); } #endif // !_HAS_CXX20 @@ -1856,8 +1856,8 @@ _NODISCARD complex<_Ty> cosh(const complex<_Ty>& _Left) noexcept(_Is_unqual_fp<_ } template -_NODISCARD complex<_Ty> _Polar_positive_nan_inf_zero_rho(const _Ty& _Rho, const _Ty& _Theta) noexcept( - _Is_unqual_fp<_Ty>) { // _Rho is +NaN/+Inf/+0 +_NODISCARD complex<_Ty> _Polar_positive_nan_inf_zero_rho(const _Ty& _Rho, const _Ty& _Theta) + noexcept(_Is_unqual_fp<_Ty>) { // _Rho is +NaN/+Inf/+0 if (_Ctraits<_Ty>::_Isnan(_Theta) || _Ctraits<_Ty>::_Isinf(_Theta)) { // _Theta is NaN/Inf if (_Ctraits<_Ty>::_Isinf(_Rho)) { return complex<_Ty>(_Rho, _Ctraits<_Ty>::sin(_Theta)); // (Inf, NaN/Inf) @@ -1990,8 +1990,8 @@ complex<_Ty> _Pow(const _Ty& _Left, const _Ty& _Right) noexcept(_Is_unqual_fp<_T } _EXPORT_STD template -_NODISCARD complex<_Ty> pow(const complex<_Ty>& _Left, const _Ty& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD complex<_Ty> pow(const complex<_Ty>& _Left, const _Ty& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { if (imag(_Left) == 0) { if (_Ctraits<_Ty>::_Signbit(imag(_Left))) { return conj(_Pow(real(_Left), _Right)); @@ -2004,8 +2004,8 @@ _NODISCARD complex<_Ty> pow(const complex<_Ty>& _Left, const _Ty& _Right) noexce } _EXPORT_STD template -_NODISCARD complex<_Ty> pow(const _Ty& _Left, const complex<_Ty>& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD complex<_Ty> pow(const _Ty& _Left, const complex<_Ty>& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { if (imag(_Right) == 0) { return _Pow(_Left, real(_Right)); } else if (0 < _Left) { @@ -2016,8 +2016,8 @@ _NODISCARD complex<_Ty> pow(const _Ty& _Left, const complex<_Ty>& _Right) noexce } _EXPORT_STD template -_NODISCARD complex<_Ty> pow(const complex<_Ty>& _Left, const complex<_Ty>& _Right) noexcept( - _Is_unqual_fp<_Ty>) /* strengthened */ { +_NODISCARD complex<_Ty> pow(const complex<_Ty>& _Left, const complex<_Ty>& _Right) + noexcept(_Is_unqual_fp<_Ty>) /* strengthened */ { if (imag(_Right) == 0) { return pow(_Left, real(_Right)); } else if (imag(_Left) == 0 && 0 < real(_Left)) { @@ -2227,23 +2227,23 @@ _NODISCARD complex<_Upgrade_to_double<_Ty>> proj(_Ty _Left) noexcept /* strength } _EXPORT_STD template -_NODISCARD complex<_Common_float_type_t<_Ty1, _Ty2>> pow(const complex<_Ty1>& _Left, - const complex<_Ty2>& _Right) noexcept(_Is_unqual_fp<_Ty1> && _Is_unqual_fp<_Ty2>) /* strengthened */ { +_NODISCARD complex<_Common_float_type_t<_Ty1, _Ty2>> pow(const complex<_Ty1>& _Left, const complex<_Ty2>& _Right) + noexcept(_Is_unqual_fp<_Ty1> && _Is_unqual_fp<_Ty2>) /* strengthened */ { using _Type = complex<_Common_float_type_t<_Ty1, _Ty2>>; return _STD pow(_Type(_Left), _Type(_Right)); } _EXPORT_STD template , int> = 0> -_NODISCARD complex<_Common_float_type_t<_Ty1, _Ty2>> pow(const complex<_Ty1>& _Left, const _Ty2& _Right) noexcept( - _Is_unqual_fp<_Ty1>) /* strengthened */ { +_NODISCARD complex<_Common_float_type_t<_Ty1, _Ty2>> pow(const complex<_Ty1>& _Left, const _Ty2& _Right) + noexcept(_Is_unqual_fp<_Ty1>) /* strengthened */ { using _Promoted = _Common_float_type_t<_Ty1, _Ty2>; using _Type = complex<_Promoted>; return _STD pow(_Type(_Left), _Type(static_cast<_Promoted>(_Right))); } _EXPORT_STD template , int> = 0> -_NODISCARD complex<_Common_float_type_t<_Ty1, _Ty2>> pow(const _Ty1& _Left, const complex<_Ty2>& _Right) noexcept( - _Is_unqual_fp<_Ty2>) /* strengthened */ { +_NODISCARD complex<_Common_float_type_t<_Ty1, _Ty2>> pow(const _Ty1& _Left, const complex<_Ty2>& _Right) + noexcept(_Is_unqual_fp<_Ty2>) /* strengthened */ { using _Promoted = _Common_float_type_t<_Ty1, _Ty2>; using _Type = complex<_Promoted>; return _STD pow(_Type(static_cast<_Promoted>(_Left)), _Type(_Right)); diff --git a/stl/inc/concepts b/stl/inc/concepts index a219f4fbe43..b16d6b1c589 100644 --- a/stl/inc/concepts +++ b/stl/inc/concepts @@ -22,7 +22,6 @@ _STL_DISABLE_CLANG_WARNINGS #undef new _STD_BEGIN -// clang-format off template concept _Same_impl = // Must be a distinct concept to provide symmetric subsumption for same_as #ifdef __clang__ @@ -35,8 +34,8 @@ _EXPORT_STD template concept same_as = _Same_impl<_Ty1, _Ty2> && _Same_impl<_Ty2, _Ty1>; _EXPORT_STD template -concept derived_from = __is_base_of(_Base, _Derived) - && __is_convertible_to(const volatile _Derived*, const volatile _Base*); +concept derived_from = + __is_base_of(_Base, _Derived) && __is_convertible_to(const volatile _Derived*, const volatile _Base*); template concept _Implicitly_convertible_to = is_convertible_v<_From, _To>; @@ -46,11 +45,10 @@ concept common_reference_with = requires { typename common_reference_t<_Ty1, _Ty2>; typename common_reference_t<_Ty2, _Ty1>; - } - && same_as, common_reference_t<_Ty2, _Ty1>> - && convertible_to<_Ty1, common_reference_t<_Ty1, _Ty2>> - && convertible_to<_Ty2, common_reference_t<_Ty1, _Ty2>>; + } && same_as, common_reference_t<_Ty2, _Ty1>> + && convertible_to<_Ty1, common_reference_t<_Ty1, _Ty2>> && convertible_to<_Ty2, common_reference_t<_Ty1, _Ty2>>; +// clang-format off _EXPORT_STD template concept common_with = requires { @@ -65,6 +63,7 @@ concept common_with = && common_reference_with, add_lvalue_reference_t> && common_reference_with>, common_reference_t, add_lvalue_reference_t>>; +// clang-format on _EXPORT_STD template concept integral = is_integral_v<_Ty>; @@ -80,10 +79,10 @@ concept floating_point = is_floating_point_v<_Ty>; _EXPORT_STD template concept assignable_from = is_lvalue_reference_v<_LTy> - && common_reference_with&, const remove_reference_t<_RTy>&> - && requires(_LTy _Left, _RTy&& _Right) { - { _Left = static_cast<_RTy&&>(_Right) } -> same_as<_LTy>; - }; + && common_reference_with&, const remove_reference_t<_RTy>&> + && requires(_LTy _Left, _RTy&& _Right) { + { _Left = static_cast<_RTy&&>(_Right) } -> same_as<_LTy>; + }; // swappable and swappable_with are defined below, since they depend on move_constructible. @@ -91,22 +90,20 @@ _EXPORT_STD template concept destructible = __is_nothrow_destructible(_Ty); _EXPORT_STD template -concept constructible_from = destructible<_Ty> - && __is_constructible(_Ty, _ArgTys...); +concept constructible_from = destructible<_Ty> && __is_constructible(_Ty, _ArgTys...); _EXPORT_STD template -concept default_initializable = constructible_from<_Ty> - && requires { - _Ty{}; - ::new (static_cast(nullptr)) _Ty; // is-default-initializable<_Ty> - }; +concept default_initializable = constructible_from<_Ty> && requires { + _Ty{}; + ::new (static_cast(nullptr)) _Ty; // is-default-initializable<_Ty> +}; _EXPORT_STD template concept move_constructible = constructible_from<_Ty, _Ty> && convertible_to<_Ty, _Ty>; template -concept _Has_class_or_enum_type = __is_class(remove_reference_t<_Ty>) || __is_enum(remove_reference_t<_Ty>) - || __is_union(remove_reference_t<_Ty>); +concept _Has_class_or_enum_type = + __is_class(remove_reference_t<_Ty>) || __is_enum(remove_reference_t<_Ty>) || __is_union(remove_reference_t<_Ty>); namespace ranges { namespace _Swap { @@ -114,8 +111,8 @@ namespace ranges { void swap(_Ty&, _Ty&) = delete; template - concept _Use_ADL_swap = (_Has_class_or_enum_type<_Ty1> || _Has_class_or_enum_type<_Ty2>) - && requires(_Ty1&& __t, _Ty2&& __u) { + concept _Use_ADL_swap = + (_Has_class_or_enum_type<_Ty1> || _Has_class_or_enum_type<_Ty2>) && requires(_Ty1&& __t, _Ty2&& __u) { swap(static_cast<_Ty1&&>(__t), static_cast<_Ty2&&>(__u)); // intentional ADL }; @@ -139,7 +136,8 @@ namespace ranges { template _STATIC_CALL_OPERATOR constexpr void operator()(_Ty1 (&__t)[_Size], _Ty2 (&__u)[_Size]) _CONST_CALL_OPERATOR noexcept(noexcept(operator()(__t[0], __u[0]))) - requires requires(_Cpo __fn) { __fn(__t[0], __u[0]); } { + requires requires(_Cpo __fn) { __fn(__t[0], __u[0]); } + { for (size_t __i = 0; __i < _Size; ++__i) { operator()(__t[__i], __u[__i]); } @@ -153,40 +151,34 @@ namespace ranges { } // namespace ranges _EXPORT_STD template -concept swappable = requires(_Ty& __x, _Ty& __y) { - _RANGES swap(__x, __y); -}; +concept swappable = requires(_Ty& __x, _Ty& __y) { _RANGES swap(__x, __y); }; _EXPORT_STD template -concept swappable_with = common_reference_with<_Ty1, _Ty2> - && requires(_Ty1&& __t, _Ty2&& __u) { - _RANGES swap(static_cast<_Ty1&&>(__t), static_cast<_Ty1&&>(__t)); - _RANGES swap(static_cast<_Ty2&&>(__u), static_cast<_Ty2&&>(__u)); - _RANGES swap(static_cast<_Ty1&&>(__t), static_cast<_Ty2&&>(__u)); - _RANGES swap(static_cast<_Ty2&&>(__u), static_cast<_Ty1&&>(__t)); - }; +concept swappable_with = common_reference_with<_Ty1, _Ty2> && requires(_Ty1&& __t, _Ty2&& __u) { + _RANGES swap(static_cast<_Ty1&&>(__t), static_cast<_Ty1&&>(__t)); + _RANGES swap(static_cast<_Ty2&&>(__u), static_cast<_Ty2&&>(__u)); + _RANGES swap(static_cast<_Ty1&&>(__t), static_cast<_Ty2&&>(__u)); + _RANGES swap(static_cast<_Ty2&&>(__u), static_cast<_Ty1&&>(__t)); +}; _EXPORT_STD template -concept copy_constructible = move_constructible<_Ty> - && constructible_from<_Ty, _Ty&> && convertible_to<_Ty&, _Ty> - && constructible_from<_Ty, const _Ty&> && convertible_to - && constructible_from<_Ty, const _Ty> && convertible_to; +concept copy_constructible = move_constructible<_Ty> && constructible_from<_Ty, _Ty&> && convertible_to<_Ty&, _Ty> + && constructible_from<_Ty, const _Ty&> && convertible_to + && constructible_from<_Ty, const _Ty> && convertible_to; template concept _Boolean_testable_impl = convertible_to<_Ty, bool>; template -concept _Boolean_testable = _Boolean_testable_impl<_Ty> - && requires(_Ty&& __t) { - { !static_cast<_Ty&&>(__t) } -> _Boolean_testable_impl; - }; +concept _Boolean_testable = _Boolean_testable_impl<_Ty> && requires(_Ty&& __t) { + { !static_cast<_Ty&&>(__t) } -> _Boolean_testable_impl; +}; template -concept _Half_equality_comparable = - requires(const remove_reference_t<_Ty1>& __x, const remove_reference_t<_Ty2>& __y) { - { __x == __y } -> _Boolean_testable; - { __x != __y } -> _Boolean_testable; - }; +concept _Half_equality_comparable = requires(const remove_reference_t<_Ty1>& __x, const remove_reference_t<_Ty2>& __y) { + { __x == __y } -> _Boolean_testable; + { __x != __y } -> _Boolean_testable; +}; template concept _Weakly_equality_comparable_with = @@ -197,19 +189,18 @@ concept equality_comparable = _Half_equality_comparable<_Ty, _Ty>; #if _HAS_CXX23 template > -concept _Comparison_common_type_with_impl = - same_as<_Ref, common_reference_t> - && requires { - requires convertible_to || convertible_to<_Ty1, const _Ref&>; - requires convertible_to || convertible_to<_Ty2, const _Ref&>; - }; +concept _Comparison_common_type_with_impl = same_as<_Ref, common_reference_t> && requires { + requires convertible_to || convertible_to<_Ty1, const _Ref&>; + requires convertible_to || convertible_to<_Ty2, const _Ref&>; +}; template concept _Comparison_common_type_with = _Comparison_common_type_with_impl, remove_cvref_t<_Ty2>>; #endif // _HAS_CXX23 _EXPORT_STD template -concept equality_comparable_with = equality_comparable<_Ty1> && equality_comparable<_Ty2> +concept equality_comparable_with = + equality_comparable<_Ty1> && equality_comparable<_Ty2> #if _HAS_CXX23 && _Comparison_common_type_with<_Ty1, _Ty2> #else // ^^^ _HAS_CXX23 / !_HAS_CXX23 vvv @@ -220,8 +211,8 @@ concept equality_comparable_with = equality_comparable<_Ty1> && equality_compara template concept _Half_ordered = requires(const remove_reference_t<_Ty1>& __t, const remove_reference_t<_Ty2>& __u) { - { __t < __u } -> _Boolean_testable; - { __t > __u } -> _Boolean_testable; + { __t < __u } -> _Boolean_testable; + { __t > __u } -> _Boolean_testable; { __t <= __u } -> _Boolean_testable; { __t >= __u } -> _Boolean_testable; }; @@ -233,23 +224,17 @@ _EXPORT_STD template concept totally_ordered = equality_comparable<_Ty> && _Half_ordered<_Ty, _Ty>; _EXPORT_STD template -concept totally_ordered_with = totally_ordered<_Ty1> && totally_ordered<_Ty2> - && equality_comparable_with<_Ty1, _Ty2> +concept totally_ordered_with = + totally_ordered<_Ty1> && totally_ordered<_Ty2> && equality_comparable_with<_Ty1, _Ty2> && totally_ordered&, const remove_reference_t<_Ty2>&>> && _Partially_ordered_with<_Ty1, _Ty2>; _EXPORT_STD template -concept movable = is_object_v<_Ty> - && move_constructible<_Ty> - && assignable_from<_Ty&, _Ty> - && swappable<_Ty>; +concept movable = is_object_v<_Ty> && move_constructible<_Ty> && assignable_from<_Ty&, _Ty> && swappable<_Ty>; _EXPORT_STD template -concept copyable = copy_constructible<_Ty> - && movable<_Ty> - && assignable_from<_Ty&, _Ty&> - && assignable_from<_Ty&, const _Ty&> - && assignable_from<_Ty&, const _Ty>; +concept copyable = copy_constructible<_Ty> && movable<_Ty> && assignable_from<_Ty&, _Ty&> + && assignable_from<_Ty&, const _Ty&> && assignable_from<_Ty&, const _Ty>; _EXPORT_STD template concept semiregular = copyable<_Ty> && default_initializable<_Ty>; @@ -258,23 +243,18 @@ _EXPORT_STD template concept regular = semiregular<_Ty> && equality_comparable<_Ty>; _EXPORT_STD template -concept invocable = requires(_FTy&& _Fn, _ArgTys&&... _Args) { - _STD invoke(static_cast<_FTy&&>(_Fn), static_cast<_ArgTys&&>(_Args)...); -}; +concept invocable = requires( + _FTy&& _Fn, _ArgTys&&... _Args) { _STD invoke(static_cast<_FTy&&>(_Fn), static_cast<_ArgTys&&>(_Args)...); }; _EXPORT_STD template concept regular_invocable = invocable<_FTy, _ArgTys...>; _EXPORT_STD template -concept predicate = regular_invocable<_FTy, _ArgTys...> - && _Boolean_testable>; +concept predicate = regular_invocable<_FTy, _ArgTys...> && _Boolean_testable>; _EXPORT_STD template -concept relation = - predicate<_FTy, _Ty1, _Ty1> - && predicate<_FTy, _Ty2, _Ty2> - && predicate<_FTy, _Ty1, _Ty2> - && predicate<_FTy, _Ty2, _Ty1>; +concept relation = predicate<_FTy, _Ty1, _Ty1> && predicate<_FTy, _Ty2, _Ty2> && predicate<_FTy, _Ty1, _Ty2> + && predicate<_FTy, _Ty2, _Ty1>; _EXPORT_STD template concept equivalence_relation = relation<_FTy, _Ty1, _Ty2>; @@ -282,8 +262,6 @@ concept equivalence_relation = relation<_FTy, _Ty1, _Ty2>; _EXPORT_STD template concept strict_weak_order = relation<_FTy, _Ty1, _Ty2>; -// clang-format on - template struct _Choice_t { _Ty _Strategy = _Ty{}; diff --git a/stl/inc/condition_variable b/stl/inc/condition_variable index 2931b1b03f8..8d52f7265bf 100644 --- a/stl/inc/condition_variable +++ b/stl/inc/condition_variable @@ -168,8 +168,8 @@ private: public: template - bool wait(_Lock& _Lck, stop_token _Stoken, _Predicate _Pred) noexcept( - noexcept(static_cast(_Pred()))) /* strengthened */ { + bool wait(_Lock& _Lck, stop_token _Stoken, _Predicate _Pred) + noexcept(noexcept(static_cast(_Pred()))) /* strengthened */ { // TRANSITION, ABI: Due to the unsynchronized delivery of notify_all by _Stoken, // this implementation cannot tolerate *this destruction while an interruptible wait // is outstanding. A future ABI should store both the internal CV and internal mutex diff --git a/stl/inc/deque b/stl/inc/deque index 7c8ad1f9be5..457136014d4 100644 --- a/stl/inc/deque +++ b/stl/inc/deque @@ -1516,8 +1516,8 @@ public: return erase(_Where, _Next_iter(_Where)); } - iterator erase(const_iterator _First_arg, const_iterator _Last_arg) noexcept( - is_nothrow_move_assignable_v) /* strengthened */ { + iterator erase(const_iterator _First_arg, const_iterator _Last_arg) + noexcept(is_nothrow_move_assignable_v) /* strengthened */ { iterator _First = _Make_iter(_First_arg); iterator _Last = _Make_iter(_Last_arg); diff --git a/stl/inc/execution b/stl/inc/execution index d331de71d60..fe639431605 100644 --- a/stl/inc/execution +++ b/stl/inc/execution @@ -351,7 +351,7 @@ struct _Generalized_sum_drop { // drop off point for GENERALIZED_SUM intermediat explicit _Generalized_sum_drop(const size_t _Slots) : _Data(static_cast<_Ty*>( - _Allocate<_New_alignof<_Ty>, _Parallelism_allocate_traits>(_Get_size_of_n(_Slots)))), + _Allocate<_New_alignof<_Ty>, _Parallelism_allocate_traits>(_Get_size_of_n(_Slots)))), _Slots(_Slots), _Frontier(0) {} ~_Generalized_sum_drop() noexcept { @@ -681,7 +681,7 @@ public: private: atomic _Bottom{0}; // modified by only owning thread atomic _Top{0}; // modified by all threads - _Guarded_by_(_Segment_lock) _Circular_buffer<_Ty>* _Segment{_Circular_buffer<_Ty>::_New_circular_buffer()}; + _Guarded_by_(_Segment_lock) _Circular_buffer<_Ty>* _Segment { _Circular_buffer<_Ty>::_New_circular_buffer() }; mutex _Segment_lock{}; }; diff --git a/stl/inc/expected b/stl/inc/expected index fd82ba69ac1..82c6d61269e 100644 --- a/stl/inc/expected +++ b/stl/inc/expected @@ -55,14 +55,14 @@ public: template requires is_constructible_v<_Err, _Args...> - constexpr explicit unexpected(in_place_t, _Args&&... _Vals) noexcept( - is_nothrow_constructible_v<_Err, _Args...>) // strengthened + constexpr explicit unexpected(in_place_t, _Args&&... _Vals) + noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened : _Unexpected(_STD forward<_Args>(_Vals)...) {} template requires is_constructible_v<_Err, initializer_list<_Uty>&, _Args...> - constexpr explicit unexpected(in_place_t, initializer_list<_Uty> _Ilist, _Args&&... _Vals) noexcept( - is_nothrow_constructible_v<_Err, initializer_list<_Uty>&, _Args...>) // strengthened + constexpr explicit unexpected(in_place_t, initializer_list<_Uty> _Ilist, _Args&&... _Vals) + noexcept(is_nothrow_constructible_v<_Err, initializer_list<_Uty>&, _Args...>) // strengthened : _Unexpected(_Ilist, _STD forward<_Args>(_Vals)...) {} // [expected.un.obs] @@ -94,8 +94,8 @@ public: // [expected.un.eq] template - _NODISCARD friend constexpr bool operator==(const unexpected& _Left, const unexpected<_UErr>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left._Unexpected == _Right.error()))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const unexpected& _Left, const unexpected<_UErr>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left._Unexpected == _Right.error()))) /* strengthened */ { return _Left._Unexpected == _Right.error(); } @@ -241,8 +241,8 @@ public: requires is_default_constructible_v<_Ty> : _Value(), _Has_value(true) {} - constexpr expected(const expected& _Other) noexcept( - is_nothrow_copy_constructible_v<_Ty> && is_nothrow_copy_constructible_v<_Err>) // strengthened + constexpr expected(const expected& _Other) + noexcept(is_nothrow_copy_constructible_v<_Ty> && is_nothrow_copy_constructible_v<_Err>) // strengthened requires (!(is_trivially_copy_constructible_v<_Ty> && is_trivially_copy_constructible_v<_Err>) && is_copy_constructible_v<_Ty> && is_copy_constructible_v<_Err>) : _Has_value(_Other._Has_value) { @@ -253,15 +253,14 @@ public: } } - // clang-format off - expected(const expected&) requires - is_trivially_copy_constructible_v<_Ty> && is_trivially_copy_constructible_v<_Err> = default; - // clang-format on + expected(const expected&) + requires is_trivially_copy_constructible_v<_Ty> && is_trivially_copy_constructible_v<_Err> + = default; expected(const expected&) = delete; - constexpr expected(expected&& _Other) noexcept( - is_nothrow_move_constructible_v<_Ty> && is_nothrow_move_constructible_v<_Err>) + constexpr expected(expected&& _Other) + noexcept(is_nothrow_move_constructible_v<_Ty> && is_nothrow_move_constructible_v<_Err>) requires (!(is_trivially_move_constructible_v<_Ty> && is_trivially_move_constructible_v<_Err>) && is_move_constructible_v<_Ty> && is_move_constructible_v<_Err>) : _Has_value(_Other._Has_value) { @@ -272,17 +271,17 @@ public: } } - // clang-format off - expected(expected&&) requires - is_trivially_move_constructible_v<_Ty> && is_trivially_move_constructible_v<_Err> = default; - // clang-format on + expected(expected&&) + requires is_trivially_move_constructible_v<_Ty> && is_trivially_move_constructible_v<_Err> + = default; template requires _Different_from, expected> && is_constructible_v<_Ty, const _Uty&> && is_constructible_v<_Err, const _UErr&> && _Allow_unwrapping<_Uty, _UErr> - constexpr explicit(!is_convertible_v || !is_convertible_v) expected( - const expected<_Uty, _UErr>& _Other) noexcept(is_nothrow_constructible_v<_Ty, const _Uty&> - && is_nothrow_constructible_v<_Err, const _UErr&>) // strengthened + constexpr explicit(!is_convertible_v || !is_convertible_v) + expected(const expected<_Uty, _UErr>& _Other) + noexcept(is_nothrow_constructible_v<_Ty, const _Uty&> + && is_nothrow_constructible_v<_Err, const _UErr&>) // strengthened : _Has_value(_Other._Has_value) { if (_Has_value) { _STD construct_at(_STD addressof(_Value), _Other._Value); @@ -295,8 +294,8 @@ public: requires _Different_from, expected> && is_constructible_v<_Ty, _Uty> && is_constructible_v<_Err, _UErr> && _Allow_unwrapping<_Uty, _UErr> constexpr explicit(!is_convertible_v<_Uty, _Ty> || !is_convertible_v<_UErr, _Err>) - expected(expected<_Uty, _UErr>&& _Other) noexcept( - is_nothrow_constructible_v<_Ty, _Uty> && is_nothrow_constructible_v<_Err, _UErr>) // strengthened + expected(expected<_Uty, _UErr>&& _Other) + noexcept(is_nothrow_constructible_v<_Ty, _Uty> && is_nothrow_constructible_v<_Err, _UErr>) // strengthened : _Has_value(_Other._Has_value) { if (_Has_value) { _STD construct_at(_STD addressof(_Value), _STD move(_Other._Value)); @@ -316,8 +315,8 @@ public: #endif // ^^^ workaround ^^^ ) && is_constructible_v<_Ty, _Uty>) - constexpr explicit(!is_convertible_v<_Uty, _Ty>) - expected(_Uty&& _Other) noexcept(is_nothrow_constructible_v<_Ty, _Uty>) // strengthened + constexpr explicit(!is_convertible_v<_Uty, _Ty>) expected(_Uty&& _Other) + noexcept(is_nothrow_constructible_v<_Ty, _Uty>) // strengthened : _Value(_STD forward<_Uty>(_Other)), _Has_value(true) { } @@ -335,26 +334,26 @@ public: template requires is_constructible_v<_Ty, _Args...> - constexpr explicit expected(in_place_t, _Args&&... _Vals) noexcept( - is_nothrow_constructible_v<_Ty, _Args...>) // strengthened + constexpr explicit expected(in_place_t, _Args&&... _Vals) + noexcept(is_nothrow_constructible_v<_Ty, _Args...>) // strengthened : _Value(_STD forward<_Args>(_Vals)...), _Has_value(true) {} template requires is_constructible_v<_Ty, initializer_list<_Uty>&, _Args...> - constexpr explicit expected(in_place_t, initializer_list<_Uty> _Ilist, _Args&&... _Vals) noexcept( - is_nothrow_constructible_v<_Ty, initializer_list<_Uty>&, _Args...>) // strengthened + constexpr explicit expected(in_place_t, initializer_list<_Uty> _Ilist, _Args&&... _Vals) + noexcept(is_nothrow_constructible_v<_Ty, initializer_list<_Uty>&, _Args...>) // strengthened : _Value(_Ilist, _STD forward<_Args>(_Vals)...), _Has_value(true) {} template requires is_constructible_v<_Err, _Args...> - constexpr explicit expected(unexpect_t, _Args&&... _Vals) noexcept( - is_nothrow_constructible_v<_Err, _Args...>) // strengthened + constexpr explicit expected(unexpect_t, _Args&&... _Vals) + noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened : _Unexpected(_STD forward<_Args>(_Vals)...), _Has_value(false) {} template requires is_constructible_v<_Err, initializer_list<_Uty>&, _Args...> - constexpr explicit expected(unexpect_t, initializer_list<_Uty> _Ilist, _Args&&... _Vals) noexcept( - is_nothrow_constructible_v<_Err, initializer_list<_Uty>&, _Args...>) // strengthened + constexpr explicit expected(unexpect_t, initializer_list<_Uty> _Ilist, _Args&&... _Vals) + noexcept(is_nothrow_constructible_v<_Err, initializer_list<_Uty>&, _Args...>) // strengthened : _Unexpected(_Ilist, _STD forward<_Args>(_Vals)...), _Has_value(false) {} // [expected.object.dtor] @@ -374,9 +373,9 @@ public: } } - // clang-format off - ~expected() requires is_trivially_destructible_v<_Ty> && is_trivially_destructible_v<_Err> = default; - // clang-format on + ~expected() + requires is_trivially_destructible_v<_Ty> && is_trivially_destructible_v<_Err> + = default; // [expected.object.assign] template @@ -393,8 +392,8 @@ public: }; template - static constexpr void _Reinit_expected(_First& _New_val, _Second& _Old_val, _Args&&... _Vals) noexcept( - is_nothrow_constructible_v<_First, _Args...>) /* strengthened */ { + static constexpr void _Reinit_expected(_First& _New_val, _Second& _Old_val, _Args&&... _Vals) + noexcept(is_nothrow_constructible_v<_First, _Args...>) /* strengthened */ { if constexpr (is_nothrow_constructible_v<_First, _Args...>) { if constexpr (!is_trivially_destructible_v<_Second>) { _Old_val.~_Second(); @@ -418,9 +417,9 @@ public: } } - constexpr expected& operator=(const expected& _Other) noexcept( - is_nothrow_copy_constructible_v<_Ty> && is_nothrow_copy_constructible_v<_Err> - && is_nothrow_copy_assignable_v<_Ty> && is_nothrow_copy_assignable_v<_Err>) // strengthened + constexpr expected& operator=(const expected& _Other) + noexcept(is_nothrow_copy_constructible_v<_Ty> && is_nothrow_copy_constructible_v<_Err> + && is_nothrow_copy_assignable_v<_Ty> && is_nothrow_copy_assignable_v<_Err>) // strengthened requires _Expected_binary_copy_assignable<_Ty, _Err> { if (_Has_value && _Other._Has_value) { @@ -445,9 +444,9 @@ public: expected& operator=(const expected&) = delete; - constexpr expected& operator=(expected&& _Other) noexcept( - is_nothrow_move_constructible_v<_Ty> && is_nothrow_move_constructible_v<_Err> - && is_nothrow_move_assignable_v<_Ty> && is_nothrow_move_assignable_v<_Err>) + constexpr expected& operator=(expected&& _Other) + noexcept(is_nothrow_move_constructible_v<_Ty> && is_nothrow_move_constructible_v<_Err> + && is_nothrow_move_assignable_v<_Ty> && is_nothrow_move_assignable_v<_Err>) requires _Expected_binary_move_assignable<_Ty, _Err> { if (_Has_value && _Other._Has_value) { @@ -475,8 +474,8 @@ public: && is_constructible_v<_Ty, _Uty> && is_assignable_v<_Ty&, _Uty> && (is_nothrow_constructible_v<_Ty, _Uty> || is_nothrow_move_constructible_v<_Ty> || is_nothrow_move_constructible_v<_Err>) ) - constexpr expected& operator=(_Uty&& _Other) noexcept( - is_nothrow_constructible_v<_Ty, _Uty> && is_nothrow_assignable_v<_Ty&, _Uty>) /* strengthened */ { + constexpr expected& operator=(_Uty&& _Other) + noexcept(is_nothrow_constructible_v<_Ty, _Uty> && is_nothrow_assignable_v<_Ty&, _Uty>) /* strengthened */ { if (_Has_value) { _Value = _STD forward<_Uty>(_Other); } else { @@ -491,9 +490,9 @@ public: requires (is_constructible_v<_Err, const _UErr&> && is_assignable_v<_Err&, const _UErr&> && (is_nothrow_constructible_v<_Err, const _UErr&> || is_nothrow_move_constructible_v<_Ty> || is_nothrow_move_constructible_v<_Err>) ) - constexpr expected& operator=(const unexpected<_UErr>& _Other) noexcept( - is_nothrow_constructible_v<_Err, const _UErr&> - && is_nothrow_assignable_v<_Err&, const _UErr&>) /* strengthened */ { + constexpr expected& operator=(const unexpected<_UErr>& _Other) + noexcept(is_nothrow_constructible_v<_Err, const _UErr&> + && is_nothrow_assignable_v<_Err&, const _UErr&>) /* strengthened */ { if (_Has_value) { _Reinit_expected(_Unexpected, _Value, _Other._Unexpected); _Has_value = false; @@ -508,8 +507,8 @@ public: requires (is_constructible_v<_Err, _UErr> && is_assignable_v<_Err&, _UErr> && (is_nothrow_constructible_v<_Err, _UErr> || is_nothrow_move_constructible_v<_Ty> || is_nothrow_move_constructible_v<_Err>) ) - constexpr expected& operator=(unexpected<_UErr>&& _Other) noexcept( - is_nothrow_constructible_v<_Err, _UErr> && is_nothrow_assignable_v<_Err&, _UErr>) /* strengthened */ { + constexpr expected& operator=(unexpected<_UErr>&& _Other) + noexcept(is_nothrow_constructible_v<_Err, _UErr> && is_nothrow_assignable_v<_Err&, _UErr>) /* strengthened */ { if (_Has_value) { _Reinit_expected(_Unexpected, _Value, _STD move(_Other._Unexpected)); _Has_value = false; @@ -555,9 +554,9 @@ public: } // [expected.object.swap] - constexpr void swap(expected& _Other) noexcept(is_nothrow_move_constructible_v<_Ty> && is_nothrow_swappable_v<_Ty> - && is_nothrow_move_constructible_v<_Err> - && is_nothrow_swappable_v<_Err>) + constexpr void swap(expected& _Other) + noexcept(is_nothrow_move_constructible_v<_Ty> && is_nothrow_swappable_v<_Ty> + && is_nothrow_move_constructible_v<_Err> && is_nothrow_swappable_v<_Err>) requires is_swappable_v<_Ty> && is_swappable_v<_Err> // && is_move_constructible_v<_Ty> && is_move_constructible_v<_Err> && (is_nothrow_move_constructible_v<_Ty> || is_nothrow_move_constructible_v<_Err>) @@ -609,9 +608,9 @@ public: } } - friend constexpr void swap(expected& _Lhs, expected& _Rhs) noexcept( - is_nothrow_move_constructible_v<_Ty> && is_nothrow_swappable_v<_Ty> && is_nothrow_move_constructible_v<_Err> - && is_nothrow_swappable_v<_Err>) + friend constexpr void swap(expected& _Lhs, expected& _Rhs) + noexcept(is_nothrow_move_constructible_v<_Ty> && is_nothrow_swappable_v<_Ty> + && is_nothrow_move_constructible_v<_Err> && is_nothrow_swappable_v<_Err>) requires is_swappable<_Ty>::value && is_swappable<_Err>::value // TRANSITION, /permissive needs ::value && is_move_constructible_v<_Ty> && is_move_constructible_v<_Err> && (is_nothrow_move_constructible_v<_Ty> || is_nothrow_move_constructible_v<_Err>) @@ -1136,9 +1135,9 @@ public: // [expected.object.eq] template requires (!is_void_v<_Uty>) - _NODISCARD friend constexpr bool operator==(const expected& _Left, const expected<_Uty, _UErr>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left._Value == *_Right)) && noexcept( - _STD _Fake_copy_init(_Left._Unexpected == _Right.error()))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const expected& _Left, const expected<_Uty, _UErr>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left._Value == *_Right)) + && noexcept(_STD _Fake_copy_init(_Left._Unexpected == _Right.error()))) /* strengthened */ { if (_Left._Has_value != _Right.has_value()) { return false; } else if (_Left._Has_value) { @@ -1149,8 +1148,8 @@ public: } template - _NODISCARD friend constexpr bool operator==(const expected& _Left, const _Uty& _Right) noexcept( - noexcept(static_cast(_Left._Value == _Right))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const expected& _Left, const _Uty& _Right) + noexcept(noexcept(static_cast(_Left._Value == _Right))) /* strengthened */ { if (_Left._Has_value) { return static_cast(_Left._Value == _Right); } else { @@ -1159,8 +1158,8 @@ public: } template - _NODISCARD friend constexpr bool operator==(const expected& _Left, const unexpected<_UErr>& _Right) noexcept( - noexcept(static_cast(_Left._Unexpected == _Right.error()))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const expected& _Left, const unexpected<_UErr>& _Right) + noexcept(noexcept(static_cast(_Left._Unexpected == _Right.error()))) /* strengthened */ { if (_Left._Has_value) { return false; } else { @@ -1171,19 +1170,19 @@ public: private: // These overloads force copy elision from the invoke call into _Value template - constexpr expected(_Construct_expected_from_invoke_result_tag, _Fn&& _Func, _Ux&& _Arg) noexcept( - noexcept(static_cast<_Ty>(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))))) + constexpr expected(_Construct_expected_from_invoke_result_tag, _Fn&& _Func, _Ux&& _Arg) + noexcept(noexcept(static_cast<_Ty>(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))))) : _Value(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))), _Has_value{true} {} // For when transform is called on an expected and requires calling _Func with no arg template - constexpr expected(_Construct_expected_from_invoke_result_tag, _Fn&& _Func) noexcept( - noexcept(static_cast<_Ty>(_STD forward<_Fn>(_Func)()))) // f() is equivalent to invoke(f) + constexpr expected(_Construct_expected_from_invoke_result_tag, _Fn&& _Func) + noexcept(noexcept(static_cast<_Ty>(_STD forward<_Fn>(_Func)()))) // f() is equivalent to invoke(f) : _Value(_STD forward<_Fn>(_Func)()), _Has_value{true} {} // f() is equivalent to invoke(f) template - constexpr expected(_Construct_expected_from_invoke_result_tag, unexpect_t, _Fn&& _Func, _Ux&& _Arg) noexcept( - noexcept(static_cast<_Err>(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))))) + constexpr expected(_Construct_expected_from_invoke_result_tag, unexpect_t, _Fn&& _Func, _Ux&& _Arg) + noexcept(noexcept(static_cast<_Err>(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))))) : _Unexpected(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))), _Has_value{false} {} [[noreturn]] void _Throw_bad_expected_access_lv() const { @@ -1243,9 +1242,9 @@ public: } } - // clang-format off - expected(const expected&) requires is_trivially_copy_constructible_v<_Err> = default; - // clang-format on + expected(const expected&) + requires is_trivially_copy_constructible_v<_Err> + = default; expected(const expected&) = delete; @@ -1257,15 +1256,15 @@ public: } } - // clang-format off - expected(expected&&) requires is_trivially_move_constructible_v<_Err> = default; - // clang-format on + expected(expected&&) + requires is_trivially_move_constructible_v<_Err> + = default; template requires _Different_from, expected> && is_void_v<_Uty> && is_constructible_v<_Err, const _UErr&> && _Allow_unwrapping<_Uty, _UErr> - constexpr explicit(!is_convertible_v) expected(const expected<_Uty, _UErr>& _Other) noexcept( - is_nothrow_constructible_v<_Err, const _UErr&>) // strengthened + constexpr explicit(!is_convertible_v) expected(const expected<_Uty, _UErr>& _Other) + noexcept(is_nothrow_constructible_v<_Err, const _UErr&>) // strengthened : _Has_value(_Other._Has_value) { if (!_Has_value) { _STD construct_at(_STD addressof(_Unexpected), _Other._Unexpected); @@ -1275,8 +1274,8 @@ public: template requires _Different_from, expected> && is_void_v<_Uty> && is_constructible_v<_Err, _UErr> && _Allow_unwrapping<_Uty, _UErr> - constexpr explicit(!is_convertible_v<_UErr, _Err>) - expected(expected<_Uty, _UErr>&& _Other) noexcept(is_nothrow_constructible_v<_Err, _UErr>) // strengthened + constexpr explicit(!is_convertible_v<_UErr, _Err>) expected(expected<_Uty, _UErr>&& _Other) + noexcept(is_nothrow_constructible_v<_Err, _UErr>) // strengthened : _Has_value(_Other._Has_value) { if (!_Has_value) { _STD construct_at(_STD addressof(_Unexpected), _STD move(_Other._Unexpected)); @@ -1285,28 +1284,28 @@ public: template requires is_constructible_v<_Err, const _UErr&> - constexpr explicit(!is_convertible_v) expected(const unexpected<_UErr>& _Other) noexcept( - is_nothrow_constructible_v<_Err, const _UErr&>) // strengthened + constexpr explicit(!is_convertible_v) expected(const unexpected<_UErr>& _Other) + noexcept(is_nothrow_constructible_v<_Err, const _UErr&>) // strengthened : _Unexpected(_Other._Unexpected), _Has_value(false) {} template requires is_constructible_v<_Err, _UErr> - constexpr explicit(!is_convertible_v<_UErr, _Err>) - expected(unexpected<_UErr>&& _Other) noexcept(is_nothrow_constructible_v<_Err, _UErr>) // strengthened + constexpr explicit(!is_convertible_v<_UErr, _Err>) expected(unexpected<_UErr>&& _Other) + noexcept(is_nothrow_constructible_v<_Err, _UErr>) // strengthened : _Unexpected(_STD move(_Other._Unexpected)), _Has_value(false) {} constexpr explicit expected(in_place_t) noexcept : _Has_value(true) {} template requires is_constructible_v<_Err, _Args...> - constexpr explicit expected(unexpect_t, _Args&&... _Vals) noexcept( - is_nothrow_constructible_v<_Err, _Args...>) // strengthened + constexpr explicit expected(unexpect_t, _Args&&... _Vals) + noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened : _Unexpected(_STD forward<_Args>(_Vals)...), _Has_value(false) {} template requires is_constructible_v<_Err, initializer_list<_Uty>&, _Args...> - constexpr explicit expected(unexpect_t, initializer_list<_Uty> _Ilist, _Args&&... _Vals) noexcept( - is_nothrow_constructible_v<_Err, initializer_list<_Uty>&, _Args...>) // strengthened + constexpr explicit expected(unexpect_t, initializer_list<_Uty> _Ilist, _Args&&... _Vals) + noexcept(is_nothrow_constructible_v<_Err, initializer_list<_Uty>&, _Args...>) // strengthened : _Unexpected(_Ilist, _STD forward<_Args>(_Vals)...), _Has_value(false) {} // [expected.void.dtor] @@ -1320,13 +1319,13 @@ public: } } - // clang-format off - ~expected() requires is_trivially_destructible_v<_Err> = default; - // clang-format on + ~expected() + requires is_trivially_destructible_v<_Err> + = default; // [expected.void.assign] - constexpr expected& operator=(const expected& _Other) noexcept( - is_nothrow_copy_constructible_v<_Err> && is_nothrow_copy_assignable_v<_Err>) // strengthened + constexpr expected& operator=(const expected& _Other) + noexcept(is_nothrow_copy_constructible_v<_Err> && is_nothrow_copy_assignable_v<_Err>) // strengthened requires _Expected_unary_copy_assignable<_Err> { if (_Has_value && _Other._Has_value) { @@ -1352,8 +1351,8 @@ public: expected& operator=(const expected&) = delete; - constexpr expected& operator=(expected&& _Other) noexcept( - is_nothrow_move_constructible_v<_Err> && is_nothrow_move_assignable_v<_Err>) + constexpr expected& operator=(expected&& _Other) + noexcept(is_nothrow_move_constructible_v<_Err> && is_nothrow_move_assignable_v<_Err>) requires _Expected_unary_move_assignable<_Err> { if (_Has_value && _Other._Has_value) { @@ -1379,9 +1378,9 @@ public: template requires is_constructible_v<_Err, const _UErr&> && is_assignable_v<_Err&, const _UErr&> - constexpr expected& operator=(const unexpected<_UErr>& _Other) noexcept( - is_nothrow_constructible_v<_Err, const _UErr&> - && is_nothrow_assignable_v<_Err&, const _UErr&>) /* strengthened */ { + constexpr expected& operator=(const unexpected<_UErr>& _Other) + noexcept(is_nothrow_constructible_v<_Err, const _UErr&> + && is_nothrow_assignable_v<_Err&, const _UErr&>) /* strengthened */ { if (_Has_value) { _STD construct_at(_STD addressof(_Unexpected), _Other._Unexpected); _Has_value = false; @@ -1394,8 +1393,8 @@ public: template requires is_constructible_v<_Err, _UErr> && is_assignable_v<_Err&, _UErr> - constexpr expected& operator=(unexpected<_UErr>&& _Other) noexcept( - is_nothrow_constructible_v<_Err, _UErr> && is_nothrow_assignable_v<_Err&, _UErr>) /* strengthened */ { + constexpr expected& operator=(unexpected<_UErr>&& _Other) + noexcept(is_nothrow_constructible_v<_Err, _UErr> && is_nothrow_assignable_v<_Err&, _UErr>) /* strengthened */ { if (_Has_value) { _STD construct_at(_STD addressof(_Unexpected), _STD move(_Other._Unexpected)); _Has_value = false; @@ -1416,8 +1415,8 @@ public: } // [expected.void.swap] - constexpr void swap(expected& _Other) noexcept( - is_nothrow_move_constructible_v<_Err> && is_nothrow_swappable_v<_Err>) + constexpr void swap(expected& _Other) + noexcept(is_nothrow_move_constructible_v<_Err> && is_nothrow_swappable_v<_Err>) requires is_swappable_v<_Err> && is_move_constructible_v<_Err> { using _STD swap; @@ -1442,8 +1441,8 @@ public: } } - friend constexpr void swap(expected& _Left, expected& _Right) noexcept( - is_nothrow_move_constructible_v<_Err> && is_nothrow_swappable_v<_Err>) + friend constexpr void swap(expected& _Left, expected& _Right) + noexcept(is_nothrow_move_constructible_v<_Err> && is_nothrow_swappable_v<_Err>) #if defined(__clang__) || defined(__EDG__) // TRANSITION, /permissive requires is_swappable_v<_Err> #else // ^^^ no workaround / workaround vvv @@ -1876,8 +1875,8 @@ public: // [expected.void.eq] template requires is_void_v<_Uty> - _NODISCARD friend constexpr bool operator==(const expected& _Left, const expected<_Uty, _UErr>& _Right) noexcept( - noexcept(static_cast(_Left._Unexpected == _Right.error()))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const expected& _Left, const expected<_Uty, _UErr>& _Right) + noexcept(noexcept(static_cast(_Left._Unexpected == _Right.error()))) /* strengthened */ { if (_Left._Has_value != _Right.has_value()) { return false; } else { @@ -1886,8 +1885,8 @@ public: } template - _NODISCARD friend constexpr bool operator==(const expected& _Left, const unexpected<_UErr>& _Right) noexcept( - noexcept(static_cast(_Left._Unexpected == _Right.error()))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const expected& _Left, const unexpected<_UErr>& _Right) + noexcept(noexcept(static_cast(_Left._Unexpected == _Right.error()))) /* strengthened */ { if (_Left._Has_value) { return false; } else { @@ -1897,8 +1896,8 @@ public: private: template - constexpr expected(_Construct_expected_from_invoke_result_tag, unexpect_t, _Fn&& _Func, _Ux&& _Arg) noexcept( - noexcept(_Err(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))))) + constexpr expected(_Construct_expected_from_invoke_result_tag, unexpect_t, _Fn&& _Func, _Ux&& _Arg) + noexcept(noexcept(_Err(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))))) : _Unexpected(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))), _Has_value{false} {} [[noreturn]] void _Throw_bad_expected_access_lv() const { diff --git a/stl/inc/flat_set b/stl/inc/flat_set index 4ec260e41a6..a117d113555 100644 --- a/stl/inc/flat_set +++ b/stl/inc/flat_set @@ -752,17 +752,17 @@ struct uses_allocator, _Alloc> template > flat_set(_Container, _Keylt = _Keylt()) -> flat_set; template -flat_set(_Container, _Alloc) - -> flat_set, _Container>; +flat_set( + _Container, _Alloc) -> flat_set, _Container>; template flat_set(_Container, _Keylt, _Alloc) -> flat_set; template > -flat_set(sorted_unique_t, _Container, _Keylt = _Keylt()) - -> flat_set; +flat_set( + sorted_unique_t, _Container, _Keylt = _Keylt()) -> flat_set; template -flat_set(sorted_unique_t, _Container, _Alloc) - -> flat_set, _Container>; +flat_set(sorted_unique_t, _Container, + _Alloc) -> flat_set, _Container>; template flat_set(sorted_unique_t, _Container, _Keylt, _Alloc) -> flat_set; @@ -772,11 +772,13 @@ template >> flat_set(sorted_unique_t, _Iter, _Iter, _Keylt = _Keylt()) -> flat_set, _Keylt>; template <_RANGES input_range _Range, class _Keylt = less<_RANGES range_value_t<_Range>>, class _Alloc = allocator<_RANGES range_value_t<_Range>>> -flat_set(from_range_t, _Range&&, _Keylt = _Keylt(), _Alloc = _Alloc()) -> flat_set<_RANGES range_value_t<_Range>, - _Keylt, vector<_RANGES range_value_t<_Range>, _Rebind_alloc_t<_Alloc, _RANGES range_value_t<_Range>>>>; +flat_set(from_range_t, _Range&&, _Keylt = _Keylt(), _Alloc = _Alloc()) + -> flat_set<_RANGES range_value_t<_Range>, _Keylt, + vector<_RANGES range_value_t<_Range>, _Rebind_alloc_t<_Alloc, _RANGES range_value_t<_Range>>>>; template <_RANGES input_range _Range, class _Alloc> -flat_set(from_range_t, _Range&&, _Alloc) -> flat_set<_RANGES range_value_t<_Range>, less<_RANGES range_value_t<_Range>>, - vector<_RANGES range_value_t<_Range>, _Rebind_alloc_t<_Alloc, _RANGES range_value_t<_Range>>>>; +flat_set(from_range_t, _Range&&, + _Alloc) -> flat_set<_RANGES range_value_t<_Range>, less<_RANGES range_value_t<_Range>>, + vector<_RANGES range_value_t<_Range>, _Rebind_alloc_t<_Alloc, _RANGES range_value_t<_Range>>>>; template > flat_set(initializer_list<_Kty>, _Keylt = _Keylt()) -> flat_set<_Kty, _Keylt>; template > @@ -786,35 +788,35 @@ flat_set(sorted_unique_t, initializer_list<_Kty>, _Keylt = _Keylt()) -> flat_set template > flat_multiset(_Container, _Keylt = _Keylt()) -> flat_multiset; template -flat_multiset(_Container, _Alloc) - -> flat_multiset, _Container>; +flat_multiset(_Container, + _Alloc) -> flat_multiset, _Container>; template flat_multiset(_Container, _Keylt, _Alloc) -> flat_multiset; template > -flat_multiset(sorted_equivalent_t, _Container, _Keylt = _Keylt()) - -> flat_multiset; +flat_multiset(sorted_equivalent_t, _Container, + _Keylt = _Keylt()) -> flat_multiset; template -flat_multiset(sorted_equivalent_t, _Container, _Alloc) - -> flat_multiset, _Container>; +flat_multiset(sorted_equivalent_t, _Container, + _Alloc) -> flat_multiset, _Container>; template -flat_multiset(sorted_equivalent_t, _Container, _Keylt, _Alloc) - -> flat_multiset; +flat_multiset(sorted_equivalent_t, _Container, _Keylt, + _Alloc) -> flat_multiset; template >> flat_multiset(_Iter, _Iter, _Keylt = _Keylt()) -> flat_multiset, iter_value_t<_Iter>, _Keylt>; template >> -flat_multiset(sorted_equivalent_t, _Iter, _Iter, _Keylt = _Keylt()) - -> flat_multiset, iter_value_t<_Iter>, _Keylt>; +flat_multiset(sorted_equivalent_t, _Iter, _Iter, + _Keylt = _Keylt()) -> flat_multiset, iter_value_t<_Iter>, _Keylt>; template <_RANGES input_range _Range, class _Keylt = less<_RANGES range_value_t<_Range>>, class _Alloc = allocator<_RANGES range_value_t<_Range>>> flat_multiset(from_range_t, _Range&&, _Keylt = _Keylt(), _Alloc = _Alloc()) -> flat_multiset<_RANGES range_value_t<_Range>, _Keylt, vector<_RANGES range_value_t<_Range>, _Rebind_alloc_t<_Alloc, _RANGES range_value_t<_Range>>>>; template <_RANGES input_range _Range, class _Alloc> -flat_multiset(from_range_t, _Range&&, _Alloc) - -> flat_multiset<_RANGES range_value_t<_Range>, less<_RANGES range_value_t<_Range>>, - vector<_RANGES range_value_t<_Range>, _Rebind_alloc_t<_Alloc, _RANGES range_value_t<_Range>>>>; +flat_multiset(from_range_t, _Range&&, + _Alloc) -> flat_multiset<_RANGES range_value_t<_Range>, less<_RANGES range_value_t<_Range>>, + vector<_RANGES range_value_t<_Range>, _Rebind_alloc_t<_Alloc, _RANGES range_value_t<_Range>>>>; template > flat_multiset(initializer_list<_Kty>, _Keylt = _Keylt()) -> flat_multiset<_Kty, _Keylt>; template > diff --git a/stl/inc/format b/stl/inc/format index c2af86f05a3..a40951eec2a 100644 --- a/stl/inc/format +++ b/stl/inc/format @@ -149,21 +149,16 @@ concept _Precision_adapter_callbacks = requires(_Ty _At) { { _At._On_dynamic_precision(size_t{}) } -> same_as; }; -// clang-format off template -concept _Parse_spec_callbacks = _Parse_align_callbacks<_Ty, _CharT> - && _Parse_width_callbacks<_Ty, _CharT> - && _Parse_precision_callbacks<_Ty, _CharT> - && _Width_adapter_callbacks<_Ty, _CharT> - && _Precision_adapter_callbacks<_Ty, _CharT> - && requires(_Ty _At, _Fmt_sign _Sgn) { +concept _Parse_spec_callbacks = _Parse_align_callbacks<_Ty, _CharT> && _Parse_width_callbacks<_Ty, _CharT> + && _Parse_precision_callbacks<_Ty, _CharT> && _Width_adapter_callbacks<_Ty, _CharT> + && _Precision_adapter_callbacks<_Ty, _CharT> && requires(_Ty _At, _Fmt_sign _Sgn) { { _At._On_sign(_Sgn) } -> same_as; { _At._On_hash() } -> same_as; { _At._On_zero() } -> same_as; { _At._On_localized() } -> same_as; { _At._On_type(_CharT{}) } -> same_as; -}; -// clang-format on + }; template struct _Decode_result { @@ -715,9 +710,8 @@ public: template explicit handle(_Ty& _Val) noexcept - : _Ptr(_STD addressof(_Val)), - _Format([](basic_format_parse_context<_CharType>& _Parse_ctx, _Context& _Format_ctx, const void* _Ptr) { - // TRANSITION, Clang 18, should be marked _STATIC_CALL_OPERATOR + : _Ptr(_STD addressof(_Val)), _Format([](basic_format_parse_context<_CharType>& _Parse_ctx, + _Context& _Format_ctx, const void* _Ptr) _STATIC_CALL_OPERATOR { using _Td = remove_const_t<_Ty>; // doesn't drop const-qualifier per an unnumbered LWG issue using _Tq = conditional_t<_Formattable_with, const _Ty, _Ty>; @@ -2199,9 +2193,6 @@ private: basic_format_args _Args; _Lazy_locale _Loc; - constexpr basic_format_context(_Out&& _OutputIt_, const basic_format_args& _Ctx_args) - : _OutputIt(_STD move(_OutputIt_)), _Args(_Ctx_args) {} - constexpr basic_format_context( _Out&& _OutputIt_, const basic_format_args& _Ctx_args, const _Lazy_locale& _Loc_) : _OutputIt(_STD move(_OutputIt_)), _Args(_Ctx_args), _Loc(_Loc_) {} @@ -2236,10 +2227,6 @@ public: return _Loc; } - _NODISCARD static constexpr basic_format_context _Make_from( - _Out _OutputIt_, basic_format_args _Ctx_args) { - return basic_format_context{_STD move(_OutputIt_), _Ctx_args}; - } _NODISCARD static constexpr basic_format_context _Make_from( _Out _OutputIt_, basic_format_args _Ctx_args, const _Lazy_locale& _Loc_) { return basic_format_context{_STD move(_OutputIt_), _Ctx_args, _Loc_}; @@ -2355,14 +2342,12 @@ public: inline constexpr size_t _Fmt_buffer_size = 256; -template -struct _Back_insert_iterator_container_type { - using type = void; -}; - -template -struct _Back_insert_iterator_container_type> { - using type = _Container; +template +struct _Fmt_iterator_flush { + template + static _OutputIt _Flush(const _Ty* const _First, const _Ty* const _Last, _OutputIt _Output) { + return _STD copy(_First, _Last, _STD move(_Output)); + } }; template @@ -2373,6 +2358,19 @@ struct _Back_insert_iterator_container_access : back_insert_iterator<_Container> using back_insert_iterator<_Container>::container; }; +template + requires (_Is_specialization_v<_Container, basic_string> || _Is_specialization_v<_Container, vector>) +struct _Fmt_iterator_flush> { + using _OutputIt = back_insert_iterator<_Container>; + + template + static _OutputIt _Flush(const _Ty* const _First, const _Ty* const _Last, _OutputIt _Output) { + _Container& _Cont = *_Back_insert_iterator_container_access<_Container>{_Output}.container; + _Cont.insert(_Cont.end(), _First, _Last); + return _Output; + } +}; + template class _Fmt_iterator_buffer final : public _Traits, public _Fmt_buffer<_Ty> { private: @@ -2390,14 +2388,7 @@ private: this->_Clear(); const auto _End = _Data + this->_Limit(_Size); - // extracts back_insert_iterator's underlying container type, or void if not. - using _Container = _Back_insert_iterator_container_type<_OutputIt>::type; - if constexpr (_Is_specialization_v<_Container, basic_string> || _Is_specialization_v<_Container, vector>) { - auto& _Cont = *_Back_insert_iterator_container_access<_Container>{_Output}.container; - _Cont.insert(_Cont.end(), _Data, _End); - } else { - _Output = _STD _Copy_unchecked(_Data, _End, _STD move(_Output)); - } + _Output = _Fmt_iterator_flush<_OutputIt>::_Flush(_Data, _End, _STD move(_Output)); } public: @@ -2632,16 +2623,16 @@ template _NODISCARD constexpr string_view _Get_integral_prefix(const char _Type, const _Integral _Value) noexcept { switch (_Type) { case 'b': - return "0b"sv; + return string_view{"0b", 2}; // TRANSITION, VSO-1775715 (should use UDLs in this function) case 'B': - return "0B"sv; + return string_view{"0B", 2}; case 'x': - return "0x"sv; + return string_view{"0x", 2}; case 'X': - return "0X"sv; + return string_view{"0X", 2}; case 'o': if (_Value != _Integral{0}) { - return "0"sv; + return string_view{"0", 1}; } return {}; default: @@ -3095,7 +3086,7 @@ _NODISCARD _OutputIt _Fmt_write( switch (_Format) { case chars_format::hex: case chars_format::scientific: - if (_Extra_precision != 0) { + if (_Extra_precision != 0 && !_Specs._Alt && !_Specs._Localized) { // Trailing zeroes are in front of the exponent while (*--_Exponent_start != _Exponent) { } @@ -3497,9 +3488,8 @@ _NODISCARD _OutputIt _Fmt_write( int _Width = _Specs._Precision; const _CharT* _Last = _Measure_string_prefix(_Value, _Width); - return _Write_aligned(_STD move(_Out), _Width, _Specs, _Fmt_align::_Left, [=](_OutputIt _Out) { - return _Fmt_write(_STD move(_Out), basic_string_view<_CharT>{_Value.data(), _Last}); - }); + return _Write_aligned(_STD move(_Out), _Width, _Specs, _Fmt_align::_Left, + [=](_OutputIt _Out) { return _Fmt_write(_STD move(_Out), basic_string_view<_CharT>{_Value.data(), _Last}); }); } // This is the visitor that's used for "simple" replacement fields. @@ -3606,9 +3596,6 @@ struct _Format_handler { basic_format_parse_context<_CharT> _Parse_context; _Context _Ctx; - explicit _Format_handler(_OutputIt _Out, basic_string_view<_CharT> _Str, basic_format_args<_Context> _Format_args) - : _Parse_context(_Str), _Ctx(_Context::_Make_from(_STD move(_Out), _Format_args)) {} - explicit _Format_handler(_OutputIt _Out, basic_string_view<_CharT> _Str, basic_format_args<_Context> _Format_args, const _Lazy_locale& _Loc) : _Parse_context(_Str), _Ctx(_Context::_Make_from(_STD move(_Out), _Format_args, _Loc)) {} @@ -3735,68 +3722,40 @@ _NODISCARD auto make_wformat_args(_Args&... _Vals) { } _FMT_P2286_BEGIN -_EXPORT_STD template _OutputIt> -_OutputIt vformat_to(_OutputIt _Out, const string_view _Fmt, const format_args _Args) { - // Make `_Parse_format_string` type-dependent to defer instantiation: - using _Dependent_char = decltype((void) _Out, char{}); - if constexpr (is_same_v<_OutputIt, _Fmt_it>) { - _Format_handler<_Dependent_char> _Handler(_Out, _Fmt, _Args); +template _OutputIt, class _Context> +_OutputIt _Format_to_it(_OutputIt _Out, const basic_string_view<_CharT> _Fmt, const basic_format_args<_Context> _Args, + const _Lazy_locale _Loc) { + using _Fmt_it_char = _Basic_fmt_it<_CharT>; + if constexpr (is_same_v<_OutputIt, _Fmt_it_char>) { + _Format_handler<_CharT> _Handler(_Out, _Fmt, _Args, _Loc); _Parse_format_string(_Fmt, _Handler); return _Out; } else { - _Fmt_iterator_buffer<_OutputIt, char> _Buf(_STD move(_Out)); - _Format_handler<_Dependent_char> _Handler(_Fmt_it{_Buf}, _Fmt, _Args); + _Fmt_iterator_buffer<_OutputIt, _CharT> _Buf(_STD move(_Out)); + _Format_handler<_CharT> _Handler(_Fmt_it_char{_Buf}, _Fmt, _Args, _Loc); _Parse_format_string(_Fmt, _Handler); return _Buf._Out(); } } +_EXPORT_STD template _OutputIt> +_OutputIt vformat_to(_OutputIt _Out, const string_view _Fmt, const format_args _Args) { + return _Format_to_it(_STD move(_Out), _Fmt, _Args, _Lazy_locale{}); +} + _EXPORT_STD template _OutputIt> _OutputIt vformat_to(_OutputIt _Out, const wstring_view _Fmt, const wformat_args _Args) { - // Make `_Parse_format_string` type-dependent to defer instantiation: - using _Dependent_char = decltype((void) _Out, wchar_t{}); - if constexpr (is_same_v<_OutputIt, _Fmt_wit>) { - _Format_handler<_Dependent_char> _Handler(_Out, _Fmt, _Args); - _Parse_format_string(_Fmt, _Handler); - return _Out; - } else { - _Fmt_iterator_buffer<_OutputIt, wchar_t> _Buf(_STD move(_Out)); - _Format_handler<_Dependent_char> _Handler(_Fmt_wit{_Buf}, _Fmt, _Args); - _Parse_format_string(_Fmt, _Handler); - return _Buf._Out(); - } + return _Format_to_it(_STD move(_Out), _Fmt, _Args, _Lazy_locale{}); } _EXPORT_STD template _OutputIt> _OutputIt vformat_to(_OutputIt _Out, const locale& _Loc, const string_view _Fmt, const format_args _Args) { - // Make `_Parse_format_string` type-dependent to defer instantiation: - using _Dependent_char = decltype((void) _Out, char{}); - if constexpr (is_same_v<_OutputIt, _Fmt_it>) { - _Format_handler<_Dependent_char> _Handler(_Out, _Fmt, _Args, _Lazy_locale{_Loc}); - _Parse_format_string(_Fmt, _Handler); - return _Out; - } else { - _Fmt_iterator_buffer<_OutputIt, char> _Buf(_STD move(_Out)); - _Format_handler<_Dependent_char> _Handler(_Fmt_it{_Buf}, _Fmt, _Args, _Lazy_locale{_Loc}); - _Parse_format_string(_Fmt, _Handler); - return _Buf._Out(); - } + return _Format_to_it(_STD move(_Out), _Fmt, _Args, _Lazy_locale{_Loc}); } _EXPORT_STD template _OutputIt> _OutputIt vformat_to(_OutputIt _Out, const locale& _Loc, const wstring_view _Fmt, const wformat_args _Args) { - // Make `_Parse_format_string` type-dependent to defer instantiation: - using _Dependent_char = decltype((void) _Out, wchar_t{}); - if constexpr (is_same_v<_OutputIt, _Fmt_wit>) { - _Format_handler<_Dependent_char> _Handler(_Out, _Fmt, _Args, _Lazy_locale{_Loc}); - _Parse_format_string(_Fmt, _Handler); - return _Out; - } else { - _Fmt_iterator_buffer<_OutputIt, wchar_t> _Buf(_STD move(_Out)); - _Format_handler<_Dependent_char> _Handler(_Fmt_wit{_Buf}, _Fmt, _Args, _Lazy_locale{_Loc}); - _Parse_format_string(_Fmt, _Handler); - return _Buf._Out(); - } + return _Format_to_it(_STD move(_Out), _Fmt, _Args, _Lazy_locale{_Loc}); } _EXPORT_STD template _OutputIt, class... _Types> @@ -4310,8 +4269,8 @@ private: range_formatter<_Element_type, _CharT> _Underlying; public: - constexpr _Range_default_formatter() noexcept( - is_nothrow_default_constructible_v>) /* strengthened */ { + constexpr _Range_default_formatter() + noexcept(is_nothrow_default_constructible_v>) /* strengthened */ { static_assert(_Is_two_tuple<_Element_type>, "the element type of the formatted range must be either pair " "or tuple (N4981 [format.range.fmtmap]/1)"); diff --git a/stl/inc/forward_list b/stl/inc/forward_list index afcdbf99254..f55da31fd95 100644 --- a/stl/inc/forward_list +++ b/stl/inc/forward_list @@ -635,8 +635,8 @@ public: _Take_head(_Right); } - forward_list(forward_list&& _Right, const _Identity_t<_Alloc>& _Al) noexcept( - _Alnode_traits::is_always_equal::value) // strengthened + forward_list(forward_list&& _Right, const _Identity_t<_Alloc>& _Al) + noexcept(_Alnode_traits::is_always_equal::value) // strengthened : _Mypair(_One_then_variadic_args_t{}, _Al) { if constexpr (!_Alty_traits::is_always_equal::value) { if (_Getal() != _Right._Getal()) { @@ -653,8 +653,8 @@ public: _Take_head(_Right); } - forward_list& operator=(forward_list&& _Right) noexcept( - _Choose_pocma_v<_Alnode> != _Pocma_values::_No_propagate_allocators) /* strengthened */ { + forward_list& operator=(forward_list&& _Right) + noexcept(_Choose_pocma_v<_Alnode> != _Pocma_values::_No_propagate_allocators) /* strengthened */ { if (this == _STD addressof(_Right)) { return *this; } @@ -1209,7 +1209,7 @@ public: }; auto remove(const _Ty& _Val) { // erase each element matching _Val - return remove_if([&](const _Ty& _Other) { return _Other == _Val; }); + return remove_if([&](const _Ty& _Other) -> bool { return _Other == _Val; }); } template @@ -1614,7 +1614,7 @@ _NODISCARD bool operator>=(const forward_list<_Ty, _Alloc>& _Left, const forward #if _HAS_CXX20 _EXPORT_STD template forward_list<_Ty, _Alloc>::size_type erase(forward_list<_Ty, _Alloc>& _Cont, const _Uty& _Val) { - return _Cont.remove_if([&](_Ty& _Elem) { return _Elem == _Val; }); + return _Cont.remove_if([&](_Ty& _Elem) -> bool { return _Elem == _Val; }); } _EXPORT_STD template diff --git a/stl/inc/functional b/stl/inc/functional index 5e81fc599f1..11150209876 100644 --- a/stl/inc/functional +++ b/stl/inc/functional @@ -146,7 +146,7 @@ struct bit_not { template <> struct divides { template - _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const + _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const // -> decltype(_STD forward<_Ty1>(_Left) / _STD forward<_Ty2>(_Right)) { return _STD forward<_Ty1>(_Left) / _STD forward<_Ty2>(_Right); } @@ -157,7 +157,7 @@ struct divides { template <> struct modulus { template - _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const + _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const // -> decltype(_STD forward<_Ty1>(_Left) % _STD forward<_Ty2>(_Right)) { return _STD forward<_Ty1>(_Left) % _STD forward<_Ty2>(_Right); } @@ -180,7 +180,7 @@ struct negate { template <> struct logical_and { template - _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const + _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const // -> decltype(_STD forward<_Ty1>(_Left) && _STD forward<_Ty2>(_Right)) { return _STD forward<_Ty1>(_Left) && _STD forward<_Ty2>(_Right); } @@ -191,7 +191,7 @@ struct logical_and { template <> struct logical_or { template - _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const + _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const // -> decltype(_STD forward<_Ty1>(_Left) || _STD forward<_Ty2>(_Right)) { return _STD forward<_Ty1>(_Left) || _STD forward<_Ty2>(_Right); } @@ -212,7 +212,7 @@ struct logical_not { template <> struct bit_and { template - _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const + _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const // -> decltype(_STD forward<_Ty1>(_Left) & _STD forward<_Ty2>(_Right)) { return _STD forward<_Ty1>(_Left) & _STD forward<_Ty2>(_Right); } @@ -223,7 +223,7 @@ struct bit_and { template <> struct bit_or { template - _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const + _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const // -> decltype(_STD forward<_Ty1>(_Left) | _STD forward<_Ty2>(_Right)) { return _STD forward<_Ty1>(_Left) | _STD forward<_Ty2>(_Right); } @@ -234,7 +234,7 @@ struct bit_or { template <> struct bit_xor { template - _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const + _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const // -> decltype(_STD forward<_Ty1>(_Left) ^ _STD forward<_Ty2>(_Right)) { return _STD forward<_Ty1>(_Left) ^ _STD forward<_Ty2>(_Right); } @@ -573,8 +573,8 @@ public: template _CONSTEXPR20 auto operator()(_Types&&... _Args) const - noexcept(noexcept(_STD invoke(_Pm, _STD forward<_Types>(_Args)...))) - -> decltype(_STD invoke(_Pm, _STD forward<_Types>(_Args)...)) { + noexcept(noexcept(_STD invoke(_Pm, _STD forward<_Types>(_Args)...))) // + -> decltype(_STD invoke(_Pm, _STD forward<_Types>(_Args)...)) { return _STD invoke(_Pm, _STD forward<_Types>(_Args)...); } }; @@ -602,8 +602,8 @@ private: public: template , int> = 0> - constexpr explicit _Not_fn(_Callable&& _Obj, _Tag) noexcept( - is_nothrow_constructible_v<_Decayed, _Callable>) // strengthened + constexpr explicit _Not_fn(_Callable&& _Obj, _Tag) + noexcept(is_nothrow_constructible_v<_Decayed, _Callable>) // strengthened : _Mybase(_STD forward<_Callable>(_Obj)) {} // store a callable object constexpr _Not_fn(const _Not_fn&) = default; @@ -652,28 +652,28 @@ public: #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv template auto operator()(_Types&&... _Args) & noexcept( - noexcept(!_STD invoke(this->_Get_val(), _STD forward<_Types>(_Args)...))) + noexcept(!_STD invoke(this->_Get_val(), _STD forward<_Types>(_Args)...))) // -> decltype(!_STD declval>()) { return !_STD invoke(this->_Get_val(), _STD forward<_Types>(_Args)...); } template auto operator()(_Types&&... _Args) const& noexcept( - noexcept(!_STD invoke(this->_Get_val(), _STD forward<_Types>(_Args)...))) + noexcept(!_STD invoke(this->_Get_val(), _STD forward<_Types>(_Args)...))) // -> decltype(!_STD declval>()) { return !_STD invoke(this->_Get_val(), _STD forward<_Types>(_Args)...); } template auto operator()(_Types&&... _Args) && noexcept( - noexcept(!_STD invoke(_STD move(this->_Get_val()), _STD forward<_Types>(_Args)...))) + noexcept(!_STD invoke(_STD move(this->_Get_val()), _STD forward<_Types>(_Args)...))) // -> decltype(!_STD declval>()) { return !_STD invoke(_STD move(this->_Get_val()), _STD forward<_Types>(_Args)...); } template auto operator()(_Types&&... _Args) const&& noexcept( - noexcept(!_STD invoke(_STD move(this->_Get_val()), _STD forward<_Types>(_Args)...))) + noexcept(!_STD invoke(_STD move(this->_Get_val()), _STD forward<_Types>(_Args)...))) // -> decltype(!_STD declval>()) { return !_STD invoke(_STD move(this->_Get_val()), _STD forward<_Types>(_Args)...); } @@ -681,8 +681,8 @@ public: }; _EXPORT_STD template -_NODISCARD _CONSTEXPR20 _Not_fn> not_fn(_Callable&& _Obj) noexcept( - is_nothrow_constructible_v, _Callable>) /* strengthened */ { +_NODISCARD _CONSTEXPR20 _Not_fn> not_fn(_Callable&& _Obj) + noexcept(is_nothrow_constructible_v, _Callable>) /* strengthened */ { // wrap a callable object to be negated static_assert(is_move_constructible_v>, "the callable type used with std::not_fn should be move constructible."); @@ -1836,23 +1836,20 @@ class move_only_function : private _Move_only_function_call<_Signature...> { private: using _Call = _Move_only_function_call<_Signature...>; - // clang-format off template - static constexpr bool _Enable_one_arg_constructor = - !is_same_v, move_only_function> - && !_Is_specialization_v, in_place_type_t> - && _Call::template _Is_callable_from>; + static constexpr bool _Enable_one_arg_constructor = !is_same_v, move_only_function> + && !_Is_specialization_v, in_place_type_t> + && _Call::template _Is_callable_from>; template static constexpr bool _Enable_in_place_constructor = - is_constructible_v, _CTypes...> - && _Call::template _Is_callable_from>; + is_constructible_v, _CTypes...> && _Call::template _Is_callable_from>; template static constexpr bool _Enable_in_place_list_constructor = is_constructible_v, initializer_list<_Ux>&, _CTypes...> && _Call::template _Is_callable_from>; - // clang-format on + public: using typename _Call::result_type; @@ -2013,16 +2010,16 @@ template struct _Select_fixer<_Cv_TiD, false, true, 0> { // nested bind fixer template )>...>, int> = 0> - static constexpr auto _Apply(_Cv_TiD& _Tid, _Untuple&& _Ut, index_sequence<_Jx...>) noexcept( - noexcept(_Tid(_STD get<_Jx>(_STD move(_Ut))...))) -> decltype(_Tid(_STD get<_Jx>(_STD move(_Ut))...)) { + static constexpr auto _Apply(_Cv_TiD& _Tid, _Untuple&& _Ut, index_sequence<_Jx...>) + noexcept(noexcept(_Tid(_STD get<_Jx>(_STD move(_Ut))...))) -> decltype(_Tid(_STD get<_Jx>(_STD move(_Ut))...)) { // call a nested bind expression return _Tid(_STD get<_Jx>(_STD move(_Ut))...); } template - static constexpr auto _Fix(_Cv_TiD& _Tid, _Untuple&& _Ut) noexcept( - noexcept(_Apply(_Tid, _STD move(_Ut), make_index_sequence>{}))) - -> decltype(_Apply(_Tid, _STD move(_Ut), make_index_sequence>{})) { + static constexpr auto _Fix(_Cv_TiD& _Tid, _Untuple&& _Ut) + noexcept(noexcept(_Apply(_Tid, _STD move(_Ut), make_index_sequence>{}))) + -> decltype(_Apply(_Tid, _STD move(_Ut), make_index_sequence>{})) { // call a nested bind expression return _Apply(_Tid, _STD move(_Ut), make_index_sequence>{}); } @@ -2049,8 +2046,8 @@ struct _Select_fixer<_Cv_TiD, false, false, _Jx> { // placeholder fixer }; template -constexpr auto _Fix_arg(_Cv_TiD& _Tid, _Untuple&& _Ut) noexcept( - noexcept(_Select_fixer<_Cv_TiD>::_Fix(_Tid, _STD move(_Ut)))) +constexpr auto _Fix_arg(_Cv_TiD& _Tid, _Untuple&& _Ut) + noexcept(noexcept(_Select_fixer<_Cv_TiD>::_Fix(_Tid, _STD move(_Ut)))) // -> decltype(_Select_fixer<_Cv_TiD>::_Fix(_Tid, _STD move(_Ut))) { // translate an argument for bind return _Select_fixer<_Cv_TiD>::_Fix(_Tid, _STD move(_Ut)); } @@ -2080,18 +2077,18 @@ struct _Invoker_ret { // selected for all _Rx other than _Unforced template <> struct _Invoker_ret<_Unforced> { // selected for _Rx being _Unforced template - static _CONSTEXPR20 auto _Call(_Fx&& _Func, _Valtys&&... _Vals) noexcept( - _Select_invoke_traits<_Fx, _Valtys...>::_Is_nothrow_invocable::value) - -> decltype(_STD invoke(static_cast<_Fx&&>(_Func), static_cast<_Valtys&&>(_Vals)...)) { // INVOKE, unchanged + static _CONSTEXPR20 auto _Call(_Fx&& _Func, _Valtys&&... _Vals) + noexcept(_Select_invoke_traits<_Fx, _Valtys...>::_Is_nothrow_invocable::value) + -> decltype(_STD invoke(static_cast<_Fx&&>(_Func), static_cast<_Valtys&&>(_Vals)...)) { // INVOKE, unchanged return _STD invoke(static_cast<_Fx&&>(_Func), static_cast<_Valtys&&>(_Vals)...); } }; template -_CONSTEXPR20 auto _Call_binder(_Invoker_ret<_Ret>, index_sequence<_Ix...>, _Cv_FD& _Obj, _Cv_tuple_TiD& _Tpl, - _Untuple&& _Ut) noexcept(noexcept(_Invoker_ret<_Ret>::_Call(_Obj, - _STD _Fix_arg(_STD get<_Ix>(_Tpl), _STD move(_Ut))...))) - -> decltype(_Invoker_ret<_Ret>::_Call(_Obj, _STD _Fix_arg(_STD get<_Ix>(_Tpl), _STD move(_Ut))...)) { +_CONSTEXPR20 auto _Call_binder( + _Invoker_ret<_Ret>, index_sequence<_Ix...>, _Cv_FD& _Obj, _Cv_tuple_TiD& _Tpl, _Untuple&& _Ut) + noexcept(noexcept(_Invoker_ret<_Ret>::_Call(_Obj, _STD _Fix_arg(_STD get<_Ix>(_Tpl), _STD move(_Ut))...))) + -> decltype(_Invoker_ret<_Ret>::_Call(_Obj, _STD _Fix_arg(_STD get<_Ix>(_Tpl), _STD move(_Ut))...)) { // bind() and bind() invocation return _Invoker_ret<_Ret>::_Call(_Obj, _STD _Fix_arg(_STD get<_Ix>(_Tpl), _STD move(_Ut))...); } @@ -2220,9 +2217,9 @@ namespace placeholders { #if _HAS_CXX20 template -constexpr auto _Call_front_binder(index_sequence<_Ix...>, _Cv_FD&& _Obj, _Cv_tuple_TiD&& _Tpl, - _Unbound&&... _Unbargs) noexcept(noexcept(_STD invoke(_STD forward<_Cv_FD>(_Obj), - _STD get<_Ix>(_STD forward<_Cv_tuple_TiD>(_Tpl))..., _STD forward<_Unbound>(_Unbargs)...))) +constexpr auto _Call_front_binder(index_sequence<_Ix...>, _Cv_FD&& _Obj, _Cv_tuple_TiD&& _Tpl, _Unbound&&... _Unbargs) + noexcept(noexcept(_STD invoke(_STD forward<_Cv_FD>(_Obj), _STD get<_Ix>(_STD forward<_Cv_tuple_TiD>(_Tpl))..., + _STD forward<_Unbound>(_Unbargs)...))) // -> decltype(_STD invoke(_STD forward<_Cv_FD>(_Obj), _STD get<_Ix>(_STD forward<_Cv_tuple_TiD>(_Tpl))..., _STD forward<_Unbound>(_Unbargs)...)) { return _STD invoke(_STD forward<_Cv_FD>(_Obj), _STD get<_Ix>(_STD forward<_Cv_tuple_TiD>(_Tpl))..., @@ -2313,11 +2310,11 @@ _NODISCARD constexpr auto bind_front(_Fx&& _Func, _Types&&... _Args) { #if _HAS_CXX23 template -constexpr auto _Call_back_binder(index_sequence<_Ix...>, _Cv_FD&& _Obj, _Cv_tuple_TiD&& _Tpl, - _Unbound&&... _Unbargs) noexcept(noexcept(_STD invoke(_STD forward<_Cv_FD>(_Obj), - _STD forward<_Unbound>(_Unbargs)..., _STD get<_Ix>(_STD forward<_Cv_tuple_TiD>(_Tpl))...))) - -> decltype(_STD invoke(_STD forward<_Cv_FD>(_Obj), _STD forward<_Unbound>(_Unbargs)..., - _STD get<_Ix>(_STD forward<_Cv_tuple_TiD>(_Tpl))...)) { +constexpr auto _Call_back_binder(index_sequence<_Ix...>, _Cv_FD&& _Obj, _Cv_tuple_TiD&& _Tpl, _Unbound&&... _Unbargs) + noexcept(noexcept(_STD invoke(_STD forward<_Cv_FD>(_Obj), _STD forward<_Unbound>(_Unbargs)..., + _STD get<_Ix>(_STD forward<_Cv_tuple_TiD>(_Tpl))...))) + -> decltype(_STD invoke(_STD forward<_Cv_FD>(_Obj), _STD forward<_Unbound>(_Unbargs)..., + _STD get<_Ix>(_STD forward<_Cv_tuple_TiD>(_Tpl))...)) { return _STD invoke(_STD forward<_Cv_FD>(_Obj), _STD forward<_Unbound>(_Unbargs)..., _STD get<_Ix>(_STD forward<_Cv_tuple_TiD>(_Tpl))...); } @@ -2459,6 +2456,29 @@ _CONSTEXPR20 pair<_FwdItHaystack, _FwdItHaystack> _Search_pair_unchecked( _Iter_diff_t<_FwdItHaystack> _Count1 = _Last1 - _First1; _Iter_diff_t<_FwdItPat> _Count2 = _Last2 - _First2; +#if _USE_STD_VECTOR_ALGORITHMS + if constexpr (_Vector_alg_in_search_is_safe<_FwdItHaystack, _FwdItPat, _Pred_eq>) { + if (!_STD _Is_constant_evaluated()) { + const auto _Ptr1 = _STD _To_address(_First1); + + const auto _Ptr_res1 = _STD _Search_vectorized( + _Ptr1, _STD _To_address(_Last1), _STD _To_address(_First2), static_cast(_Count2)); + + if constexpr (is_pointer_v<_FwdItHaystack>) { + _First1 = _Ptr_res1; + } else { + _First1 += _Ptr_res1 - _Ptr1; + } + + if (_First1 != _Last1) { + return {_First1, _First1 + static_cast<_Iter_diff_t<_FwdItHaystack>>(_Count2)}; + } else { + return {_Last1, _Last1}; + } + } + } +#endif // _USE_STD_VECTOR_ALGORITHMS + for (; _Count2 <= _Count1; ++_First1, (void) --_Count1) { // room for match, try it _FwdItHaystack _Mid1 = _First1; for (_FwdItPat _Mid2 = _First2;; ++_Mid1, (void) ++_Mid2) { diff --git a/stl/inc/future b/stl/inc/future index 6778c109923..7d385549d6b 100644 --- a/stl/inc/future +++ b/stl/inc/future @@ -1268,9 +1268,9 @@ public: template , packaged_task>, int> = 0> explicit packaged_task(_Fty2&& _Fnarg) : _MyPromise(new _MyStateType(_STD forward<_Fty2>(_Fnarg))) {} - packaged_task(packaged_task&&) = default; + packaged_task(packaged_task&&) noexcept = default; - packaged_task& operator=(packaged_task&&) = default; + packaged_task& operator=(packaged_task&&) noexcept = default; #if _HAS_FUNCTION_ALLOCATOR_SUPPORT template , packaged_task>, int> = 0> diff --git a/stl/inc/hash_map b/stl/inc/hash_map index 011a0667683..b204ecba06f 100644 --- a/stl/inc/hash_map +++ b/stl/inc/hash_map @@ -279,8 +279,8 @@ namespace stdext { }; template - void swap(hash_map<_Kty, _Ty, _Tr, _Alloc>& _Left, hash_map<_Kty, _Ty, _Tr, _Alloc>& _Right) noexcept( - noexcept(_Left.swap(_Right))) { + void swap(hash_map<_Kty, _Ty, _Tr, _Alloc>& _Left, hash_map<_Kty, _Ty, _Tr, _Alloc>& _Right) + noexcept(noexcept(_Left.swap(_Right))) { _Left.swap(_Right); } @@ -439,8 +439,8 @@ namespace stdext { }; template - void swap(hash_multimap<_Kty, _Ty, _Tr, _Alloc>& _Left, hash_multimap<_Kty, _Ty, _Tr, _Alloc>& _Right) noexcept( - noexcept(_Left.swap(_Right))) { + void swap(hash_multimap<_Kty, _Ty, _Tr, _Alloc>& _Left, hash_multimap<_Kty, _Ty, _Tr, _Alloc>& _Right) + noexcept(noexcept(_Left.swap(_Right))) { _Left.swap(_Right); } diff --git a/stl/inc/hash_set b/stl/inc/hash_set index 8b7f9a25869..914a09c5586 100644 --- a/stl/inc/hash_set +++ b/stl/inc/hash_set @@ -215,8 +215,8 @@ namespace stdext { }; template - void swap(hash_set<_Kty, _Tr, _Alloc>& _Left, hash_set<_Kty, _Tr, _Alloc>& _Right) noexcept( - noexcept(_Left.swap(_Right))) { + void swap(hash_set<_Kty, _Tr, _Alloc>& _Left, hash_set<_Kty, _Tr, _Alloc>& _Right) + noexcept(noexcept(_Left.swap(_Right))) { _Left.swap(_Right); } @@ -358,8 +358,8 @@ namespace stdext { }; template - void swap(hash_multiset<_Kty, _Tr, _Alloc>& _Left, hash_multiset<_Kty, _Tr, _Alloc>& _Right) noexcept( - noexcept(_Left.swap(_Right))) { + void swap(hash_multiset<_Kty, _Tr, _Alloc>& _Left, hash_multiset<_Kty, _Tr, _Alloc>& _Right) + noexcept(noexcept(_Left.swap(_Right))) { _Left.swap(_Right); } diff --git a/stl/inc/header-units.json b/stl/inc/header-units.json index 91a75c2dc2a..4f74e8f959f 100644 --- a/stl/inc/header-units.json +++ b/stl/inc/header-units.json @@ -15,6 +15,7 @@ "__msvc_int128.hpp", "__msvc_iter_core.hpp", "__msvc_minmax.hpp", + "__msvc_ostream.hpp", "__msvc_print.hpp", "__msvc_ranges_to.hpp", "__msvc_sanitizer_annotate_container.hpp", diff --git a/stl/inc/iostream b/stl/inc/iostream index d911968f885..b433b3afd1f 100644 --- a/stl/inc/iostream +++ b/stl/inc/iostream @@ -8,6 +8,7 @@ #include #if _STL_COMPILER_PREPROCESSOR #include +#include #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) diff --git a/stl/inc/istream b/stl/inc/istream index e377b0fc1ca..07d8681a84b 100644 --- a/stl/inc/istream +++ b/stl/inc/istream @@ -7,7 +7,7 @@ #define _ISTREAM_ #include #if _STL_COMPILER_PREPROCESSOR -#include +#include <__msvc_ostream.hpp> #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) diff --git a/stl/inc/iterator b/stl/inc/iterator index 25ebe3b4345..564bc7d0231 100644 --- a/stl/inc/iterator +++ b/stl/inc/iterator @@ -190,14 +190,14 @@ public: template requires convertible_to - constexpr move_sentinel(const move_sentinel<_Se2>& _Val) noexcept( - is_nothrow_constructible_v<_Se, const _Se2&>) // strengthened + constexpr move_sentinel(const move_sentinel<_Se2>& _Val) + noexcept(is_nothrow_constructible_v<_Se, const _Se2&>) // strengthened : _Last(_Val._Get_last()) {} template requires assignable_from<_Se&, const _Se2&> - constexpr move_sentinel& operator=(const move_sentinel<_Se2>& _Val) noexcept( - is_nothrow_assignable_v<_Se&, const _Se2&>) /* strengthened */ { + constexpr move_sentinel& operator=(const move_sentinel<_Se2>& _Val) + noexcept(is_nothrow_assignable_v<_Se&, const _Se2&>) /* strengthened */ { _Last = _Val._Get_last(); return *this; } @@ -212,18 +212,16 @@ public: using _Prevent_inheriting_unwrap = move_sentinel; - // clang-format off - _NODISCARD constexpr move_sentinel<_Unwrapped_t> _Unwrapped() const& - noexcept(noexcept(move_sentinel<_Unwrapped_t>{_Last._Unwrapped()})) - requires _RANGES _Weakly_unwrappable_sentinel<_Se> { - // clang-format on + _NODISCARD constexpr move_sentinel<_Unwrapped_t> _Unwrapped() const& noexcept( + noexcept(move_sentinel<_Unwrapped_t>{_Last._Unwrapped()})) + requires (_RANGES _Weakly_unwrappable_sentinel<_Se>) + { return move_sentinel<_Unwrapped_t>{_Last._Unwrapped()}; } - // clang-format off - _NODISCARD constexpr move_sentinel<_Unwrapped_t<_Se>> _Unwrapped() && - noexcept(noexcept(move_sentinel<_Unwrapped_t<_Se>>{_STD move(_Last)._Unwrapped()})) - requires _RANGES _Weakly_unwrappable_sentinel<_Se> { - // clang-format on + _NODISCARD constexpr move_sentinel<_Unwrapped_t<_Se>> _Unwrapped() && noexcept( + noexcept(move_sentinel<_Unwrapped_t<_Se>>{_STD move(_Last)._Unwrapped()})) + requires (_RANGES _Weakly_unwrappable_sentinel<_Se>) + { return move_sentinel<_Unwrapped_t<_Se>>{_STD move(_Last)._Unwrapped()}; } @@ -251,8 +249,8 @@ public: constexpr istream_iterator() noexcept(is_nothrow_default_constructible_v<_Ty>) /* strengthened */ {} #if _HAS_CXX20 - constexpr istream_iterator(default_sentinel_t) noexcept( - is_nothrow_default_constructible_v<_Ty>) /* strengthened */ {} + constexpr istream_iterator(default_sentinel_t) + noexcept(is_nothrow_default_constructible_v<_Ty>) /* strengthened */ {} #endif // _HAS_CXX20 istream_iterator(istream_type& _Istr) : _Myistr(_STD addressof(_Istr)) { @@ -393,8 +391,8 @@ private: private: friend istreambuf_iterator; - _Istreambuf_proxy(streambuf_type* _Strbuf_, _Elem _Keep_) noexcept( - is_nothrow_copy_constructible_v<_Elem>) // strengthened + _Istreambuf_proxy(streambuf_type* _Strbuf_, _Elem _Keep_) + noexcept(is_nothrow_copy_constructible_v<_Elem>) // strengthened : _Strbuf(_Strbuf_), _Keep(_Keep_) {} streambuf_type* _Strbuf; @@ -575,20 +573,20 @@ public: : _First{}, _Contains{_Variantish_state::_Holds_first} {} template - constexpr explicit _Variantish(in_place_type_t<_Ty1>, _Types&&... _Args) noexcept( - is_nothrow_constructible_v<_Ty1, _Types...>) + constexpr explicit _Variantish(in_place_type_t<_Ty1>, _Types&&... _Args) + noexcept(is_nothrow_constructible_v<_Ty1, _Types...>) : _First(_STD forward<_Types>(_Args)...), _Contains{_Variantish_state::_Holds_first} {} template requires _Different_from<_Ty1, _Ty2> - constexpr explicit _Variantish(in_place_type_t<_Ty2>, _Types&&... _Args) noexcept( - is_nothrow_constructible_v<_Ty2, _Types...>) + constexpr explicit _Variantish(in_place_type_t<_Ty2>, _Types&&... _Args) + noexcept(is_nothrow_constructible_v<_Ty2, _Types...>) : _Second(_STD forward<_Types>(_Args)...), _Contains{_Variantish_state::_Holds_second} {} template requires _Different_from<_Variantish<_Uty1, _Uty2>, _Variantish> - constexpr _Variantish(const _Variantish<_Uty1, _Uty2>& _That) noexcept( - is_nothrow_constructible_v<_Ty1, const _Uty1&> && is_nothrow_constructible_v<_Ty2, const _Uty2&>) + constexpr _Variantish(const _Variantish<_Uty1, _Uty2>& _That) + noexcept(is_nothrow_constructible_v<_Ty1, const _Uty1&> && is_nothrow_constructible_v<_Ty2, const _Uty2&>) : _Contains{_That._Contains} { switch (_That._Contains) { case _Variantish_state::_Holds_first: @@ -602,13 +600,12 @@ public: } } - // clang-format off - constexpr _Variantish(const _Variantish&) requires is_trivially_copy_constructible_v<_Ty1> - && is_trivially_copy_constructible_v<_Ty2> = default; - // clang-format on + constexpr _Variantish(const _Variantish&) + requires is_trivially_copy_constructible_v<_Ty1> && is_trivially_copy_constructible_v<_Ty2> + = default; - constexpr _Variantish(const _Variantish& _That) noexcept( - is_nothrow_copy_constructible_v<_Ty1> && is_nothrow_copy_constructible_v<_Ty2>) + constexpr _Variantish(const _Variantish& _That) + noexcept(is_nothrow_copy_constructible_v<_Ty1> && is_nothrow_copy_constructible_v<_Ty2>) : _Contains{_That._Contains} { switch (_Contains) { case _Variantish_state::_Holds_first: @@ -622,13 +619,12 @@ public: } } - // clang-format off - constexpr _Variantish(_Variantish&&) requires is_trivially_move_constructible_v<_Ty1> - && is_trivially_move_constructible_v<_Ty2> = default; - // clang-format on + constexpr _Variantish(_Variantish&&) + requires is_trivially_move_constructible_v<_Ty1> && is_trivially_move_constructible_v<_Ty2> + = default; - constexpr _Variantish(_Variantish&& _That) noexcept( - is_nothrow_move_constructible_v<_Ty1> && is_nothrow_move_constructible_v<_Ty2>) + constexpr _Variantish(_Variantish&& _That) + noexcept(is_nothrow_move_constructible_v<_Ty1> && is_nothrow_move_constructible_v<_Ty2>) : _Contains{_That._Contains} { switch (_Contains) { case _Variantish_state::_Holds_first: @@ -646,20 +642,19 @@ public: _Raw_clear(); } - // clang-format off - constexpr ~_Variantish() requires is_trivially_destructible_v<_Ty1> && is_trivially_destructible_v<_Ty2> = default; + constexpr ~_Variantish() + requires is_trivially_destructible_v<_Ty1> && is_trivially_destructible_v<_Ty2> + = default; - constexpr _Variantish& operator=(const _Variantish&) requires is_trivially_destructible_v<_Ty1> - && is_trivially_destructible_v<_Ty2> - && is_trivially_copy_constructible_v<_Ty1> - && is_trivially_copy_constructible_v<_Ty2> - && is_trivially_copy_assignable_v<_Ty1> - && is_trivially_copy_assignable_v<_Ty2> = default; - // clang-format on + constexpr _Variantish& operator=(const _Variantish&) + requires is_trivially_destructible_v<_Ty1> && is_trivially_destructible_v<_Ty2> + && is_trivially_copy_constructible_v<_Ty1> && is_trivially_copy_constructible_v<_Ty2> + && is_trivially_copy_assignable_v<_Ty1> && is_trivially_copy_assignable_v<_Ty2> + = default; - constexpr _Variantish& operator=(const _Variantish& _That) noexcept( - is_nothrow_copy_constructible_v<_Ty1> && is_nothrow_copy_constructible_v<_Ty2> - && is_nothrow_copy_assignable_v<_Ty1> && is_nothrow_copy_assignable_v<_Ty2>) { + constexpr _Variantish& operator=(const _Variantish& _That) + noexcept(is_nothrow_copy_constructible_v<_Ty1> && is_nothrow_copy_constructible_v<_Ty2> + && is_nothrow_copy_assignable_v<_Ty1> && is_nothrow_copy_assignable_v<_Ty2>) { if (_Contains == _That._Contains) { switch (_Contains) { case _Variantish_state::_Holds_first: @@ -693,18 +688,15 @@ public: return *this; } - // clang-format off - constexpr _Variantish& operator=(_Variantish&&) requires is_trivially_destructible_v<_Ty1> - && is_trivially_destructible_v<_Ty2> - && is_trivially_move_constructible_v<_Ty1> - && is_trivially_move_constructible_v<_Ty2> - && is_trivially_move_assignable_v<_Ty1> - && is_trivially_move_assignable_v<_Ty2> = default; - // clang-format on + constexpr _Variantish& operator=(_Variantish&&) + requires is_trivially_destructible_v<_Ty1> && is_trivially_destructible_v<_Ty2> + && is_trivially_move_constructible_v<_Ty1> && is_trivially_move_constructible_v<_Ty2> + && is_trivially_move_assignable_v<_Ty1> && is_trivially_move_assignable_v<_Ty2> + = default; - constexpr _Variantish& operator=(_Variantish&& _That) noexcept( - is_nothrow_move_constructible_v<_Ty1> && is_nothrow_move_constructible_v<_Ty2> - && is_nothrow_move_assignable_v<_Ty1> && is_nothrow_move_assignable_v<_Ty2>) { + constexpr _Variantish& operator=(_Variantish&& _That) + noexcept(is_nothrow_move_constructible_v<_Ty1> && is_nothrow_move_constructible_v<_Ty2> + && is_nothrow_move_assignable_v<_Ty1> && is_nothrow_move_assignable_v<_Ty2>) { if (_Contains == _That._Contains) { switch (_Contains) { case _Variantish_state::_Holds_first: @@ -740,9 +732,9 @@ public: template requires _Different_from<_Variantish<_Uty1, _Uty2>, _Variantish> - constexpr _Variantish& operator=(const _Variantish<_Uty1, _Uty2>& _That) noexcept( - is_nothrow_constructible_v<_Ty1, const _Uty1&> && is_nothrow_constructible_v<_Ty2, const _Uty2&> - && is_nothrow_assignable_v<_Ty1&, const _Uty1&> && is_nothrow_assignable_v<_Ty2&, const _Uty2&>) { + constexpr _Variantish& operator=(const _Variantish<_Uty1, _Uty2>& _That) + noexcept(is_nothrow_constructible_v<_Ty1, const _Uty1&> && is_nothrow_constructible_v<_Ty2, const _Uty2&> + && is_nothrow_assignable_v<_Ty1&, const _Uty1&> && is_nothrow_assignable_v<_Ty2&, const _Uty2&>) { if (_Contains == _That._Contains) { switch (_Contains) { case _Variantish_state::_Holds_first: @@ -776,12 +768,11 @@ public: return *this; } - // clang-format off - friend constexpr void swap(_Variantish& _Left, _Variantish& _Right) noexcept( - is_nothrow_move_constructible_v<_Ty1> && is_nothrow_move_constructible_v<_Ty2> - && is_nothrow_swappable_v<_Ty1> && is_nothrow_swappable_v<_Ty2>) - requires (!_Is_trivially_swappable_v<_Ty1> || !_Is_trivially_swappable_v<_Ty2>) { - // clang-format on + friend constexpr void swap(_Variantish& _Left, _Variantish& _Right) + noexcept(is_nothrow_move_constructible_v<_Ty1> && is_nothrow_move_constructible_v<_Ty2> + && is_nothrow_swappable_v<_Ty1> && is_nothrow_swappable_v<_Ty2>) + requires (!_Is_trivially_swappable_v<_Ty1> || !_Is_trivially_swappable_v<_Ty2>) + { if (_Left._Contains == _Right._Contains) { switch (_Left._Contains) { case _Variantish_state::_Holds_first: @@ -858,13 +849,12 @@ public: _Variantish_state _Contains; }; -// clang-format off template -concept _Use_postfix_proxy = !requires(_Iter& __it) { { *__it++ } -> _Can_reference; } - && indirectly_readable<_Iter> - && constructible_from, iter_reference_t<_Iter>> +concept _Use_postfix_proxy = + !requires(_Iter& __it) { + { *__it++ } -> _Can_reference; + } && indirectly_readable<_Iter> && constructible_from, iter_reference_t<_Iter>> && move_constructible>; -// clang-format on _EXPORT_STD template _Se> requires (!same_as<_Iter, _Se> && copyable<_Iter>) @@ -873,15 +863,15 @@ private: struct _Proxy_base { iter_value_t<_Iter> _Keep; - constexpr explicit _Proxy_base(iter_reference_t<_Iter>&& _Right) noexcept( - is_nothrow_constructible_v, iter_reference_t<_Iter>>) // strengthened + constexpr explicit _Proxy_base(iter_reference_t<_Iter>&& _Right) + noexcept(is_nothrow_constructible_v, iter_reference_t<_Iter>>) // strengthened : _Keep(_STD forward>(_Right)) {} }; public: - // clang-format off - constexpr common_iterator() requires default_initializable<_Iter> = default; - // clang-format on + constexpr common_iterator() + requires default_initializable<_Iter> + = default; constexpr common_iterator(_Iter _Right) noexcept(is_nothrow_move_constructible_v<_Iter>) // strengthened : _Val{in_place_type<_Iter>, _STD move(_Right)} {} @@ -893,18 +883,18 @@ public: template requires convertible_to && convertible_to - constexpr common_iterator(const common_iterator<_OIter, _OSe>& _Right) noexcept( - is_nothrow_constructible_v<_Iter, const _OIter&> - && is_nothrow_constructible_v<_Se, const _OSe&>) // strengthened + constexpr common_iterator(const common_iterator<_OIter, _OSe>& _Right) + noexcept(is_nothrow_constructible_v<_Iter, const _OIter&> + && is_nothrow_constructible_v<_Se, const _OSe&>) // strengthened : _Val{_Right._Get_val()} {} template requires convertible_to && convertible_to && assignable_from<_Iter&, const _OIter&> && assignable_from<_Se&, const _OSe&> - constexpr common_iterator& operator=(const common_iterator<_OIter, _OSe>& _Right) noexcept( - is_nothrow_constructible_v<_Iter, const _OIter&> && is_nothrow_constructible_v<_Se, const _OSe&> - && is_nothrow_assignable_v<_Iter&, const _OIter&> - && is_nothrow_assignable_v<_Se&, const _OSe&>) /* strengthened */ { + constexpr common_iterator& operator=(const common_iterator<_OIter, _OSe>& _Right) + noexcept(is_nothrow_constructible_v<_Iter, const _OIter&> && is_nothrow_constructible_v<_Se, const _OSe&> + && is_nothrow_assignable_v<_Iter&, const _OIter&> + && is_nothrow_assignable_v<_Se&, const _OSe&>) /* strengthened */ { _Val = _Right._Get_val(); return *this; } @@ -1051,8 +1041,8 @@ public: } } - _NODISCARD friend constexpr decltype(auto) iter_move(const common_iterator& _Right) noexcept( - noexcept(_RANGES iter_move(_Right._Val._Get_first()))) + _NODISCARD friend constexpr decltype(auto) iter_move(const common_iterator& _Right) + noexcept(noexcept(_RANGES iter_move(_Right._Val._Get_first()))) requires input_iterator<_Iter> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -1063,8 +1053,8 @@ public: } template _OIter, class _OSe> - friend constexpr void iter_swap(const common_iterator& _Left, const common_iterator<_OIter, _OSe>& _Right) noexcept( - noexcept(_RANGES iter_swap(_Left._Val._Get_first(), _Right._Get_val()._Get_first()))) { + friend constexpr void iter_swap(const common_iterator& _Left, const common_iterator<_OIter, _OSe>& _Right) + noexcept(noexcept(_RANGES iter_swap(_Left._Val._Get_first(), _Right._Get_val()._Get_first()))) { auto& _Right_val = _Right._Get_val(); #if _ITERATOR_DEBUG_LEVEL != 0 _STL_VERIFY(_Left._Val._Contains == _Variantish_state::_Holds_first @@ -1156,12 +1146,12 @@ public: using difference_type = iter_difference_t<_Iter>; // [counted.iter.const] - // clang-format off - constexpr counted_iterator() requires default_initializable<_Iter> = default; - // clang-format on + constexpr counted_iterator() + requires default_initializable<_Iter> + = default; - constexpr counted_iterator(_Iter _Right, const iter_difference_t<_Iter> _Diff) noexcept( - is_nothrow_move_constructible_v<_Iter>) // strengthened + constexpr counted_iterator(_Iter _Right, const iter_difference_t<_Iter> _Diff) + noexcept(is_nothrow_move_constructible_v<_Iter>) // strengthened : _Current(_STD move(_Right)), _Length(_Diff) { #if _ITERATOR_DEBUG_LEVEL != 0 _STL_VERIFY(_Diff >= 0, "counted_iterator requires non-negative length n"); @@ -1170,14 +1160,14 @@ public: template requires convertible_to - constexpr counted_iterator(const counted_iterator<_Other>& _Right) noexcept( - is_nothrow_constructible_v<_Iter, const _Other&>) // strengthened + constexpr counted_iterator(const counted_iterator<_Other>& _Right) + noexcept(is_nothrow_constructible_v<_Iter, const _Other&>) // strengthened : _Current(_Right.base()), _Length(_Right.count()) {} template requires assignable_from<_Iter&, const _Other&> - constexpr counted_iterator& operator=(const counted_iterator<_Other>& _Right) noexcept( - is_nothrow_assignable_v<_Iter&, const _Other&>) /* strengthened */ { + constexpr counted_iterator& operator=(const counted_iterator<_Other>& _Right) + noexcept(is_nothrow_assignable_v<_Iter&, const _Other&>) /* strengthened */ { _Current = _Right.base(); _Length = _Right.count(); return *this; @@ -1367,16 +1357,16 @@ public: } // [counted.iter.cust] - _NODISCARD friend constexpr decltype(auto) iter_move(const counted_iterator& _Right) noexcept( - noexcept(_RANGES iter_move(_Right._Current))) + _NODISCARD friend constexpr decltype(auto) iter_move(const counted_iterator& _Right) + noexcept(noexcept(_RANGES iter_move(_Right._Current))) requires input_iterator<_Iter> { return _RANGES iter_move(_Right._Current); } template _Other> - friend constexpr void iter_swap(const counted_iterator& _Left, const counted_iterator<_Other>& _Right) noexcept( - noexcept(_RANGES iter_swap(_Left._Current, _Right.base()))) { + friend constexpr void iter_swap(const counted_iterator& _Left, const counted_iterator<_Other>& _Right) + noexcept(noexcept(_RANGES iter_swap(_Left._Current, _Right.base()))) { _RANGES iter_swap(_Left._Current, _Right.base()); } diff --git a/stl/inc/list b/stl/inc/list index 84160362f46..5d42e9fe73d 100644 --- a/stl/inc/list +++ b/stl/inc/list @@ -916,8 +916,8 @@ public: _Swap_val(_Right); } - list& operator=(list&& _Right) noexcept( - _Choose_pocma_v<_Alnode> == _Pocma_values::_Equal_allocators) /* strengthened */ { + list& operator=(list&& _Right) + noexcept(_Choose_pocma_v<_Alnode> == _Pocma_values::_Equal_allocators) /* strengthened */ { if (this == _STD addressof(_Right)) { return *this; } @@ -1663,7 +1663,7 @@ public: }; auto remove(const _Ty& _Val) { // erase each element matching _Val - return remove_if([&](const _Ty& _Other) { return _Other == _Val; }); + return remove_if([&](const _Ty& _Other) -> bool { return _Other == _Val; }); } template @@ -1916,7 +1916,7 @@ _NODISCARD bool operator>=(const list<_Ty, _Alloc>& _Left, const list<_Ty, _Allo #if _HAS_CXX20 _EXPORT_STD template list<_Ty, _Alloc>::size_type erase(list<_Ty, _Alloc>& _Cont, const _Uty& _Val) { - return _Cont.remove_if([&](_Ty& _Elem) { return _Elem == _Val; }); + return _Cont.remove_if([&](_Ty& _Elem) -> bool { return _Elem == _Val; }); } _EXPORT_STD template diff --git a/stl/inc/map b/stl/inc/map index ecb13ccb948..4e601e3a0b4 100644 --- a/stl/inc/map +++ b/stl/inc/map @@ -387,12 +387,12 @@ map(initializer_list>, _Alloc) -> map<_Kty, _Ty, less<_Kty>, _Al template <_RANGES input_range _Rng, class _Pr = less<_Range_key_type<_Rng>>, _Allocator_for_container _Alloc = allocator<_Range_to_alloc_type<_Rng>>> requires (!_Allocator_for_container<_Pr>) -map(from_range_t, _Rng&&, _Pr = _Pr(), _Alloc = _Alloc()) - -> map<_Range_key_type<_Rng>, _Range_mapped_type<_Rng>, _Pr, _Alloc>; +map(from_range_t, _Rng&&, _Pr = _Pr(), + _Alloc = _Alloc()) -> map<_Range_key_type<_Rng>, _Range_mapped_type<_Rng>, _Pr, _Alloc>; template <_RANGES input_range _Rng, _Allocator_for_container _Alloc> -map(from_range_t, _Rng&&, _Alloc) - -> map<_Range_key_type<_Rng>, _Range_mapped_type<_Rng>, less<_Range_key_type<_Rng>>, _Alloc>; +map(from_range_t, _Rng&&, + _Alloc) -> map<_Range_key_type<_Rng>, _Range_mapped_type<_Rng>, less<_Range_key_type<_Rng>>, _Alloc>; #endif // _HAS_CXX23 #endif // _HAS_CXX17 @@ -438,8 +438,8 @@ _NODISCARD bool operator>=(const map<_Kty, _Ty, _Pr, _Alloc>& _Left, const map<_ #endif // ^^^ !_HAS_CXX20 ^^^ _EXPORT_STD template -void swap(map<_Kty, _Ty, _Pr, _Alloc>& _Left, map<_Kty, _Ty, _Pr, _Alloc>& _Right) noexcept( - noexcept(_Left.swap(_Right))) { +void swap(map<_Kty, _Ty, _Pr, _Alloc>& _Left, map<_Kty, _Ty, _Pr, _Alloc>& _Right) + noexcept(noexcept(_Left.swap(_Right))) { _Left.swap(_Right); } @@ -544,8 +544,8 @@ public: multimap(multimap&& _Right, const allocator_type& _Al) : _Mybase(_STD move(_Right), _Al) {} - multimap& operator=(multimap&& _Right) noexcept( - _Alnode_traits::is_always_equal::value && is_nothrow_move_assignable_v<_Pr>) { + multimap& operator=(multimap&& _Right) + noexcept(_Alnode_traits::is_always_equal::value && is_nothrow_move_assignable_v<_Pr>) { _Mybase::operator=(_STD move(_Right)); return *this; } @@ -601,8 +601,8 @@ public: #if _HAS_CXX17 template >, class _Alloc = allocator<_Guide_pair_t<_Iter>>, enable_if_t, negation<_Is_allocator<_Pr>>, _Is_allocator<_Alloc>>, int> = 0> -multimap(_Iter, _Iter, _Pr = _Pr(), _Alloc = _Alloc()) - -> multimap<_Guide_key_t<_Iter>, _Guide_val_t<_Iter>, _Pr, _Alloc>; +multimap( + _Iter, _Iter, _Pr = _Pr(), _Alloc = _Alloc()) -> multimap<_Guide_key_t<_Iter>, _Guide_val_t<_Iter>, _Pr, _Alloc>; template , class _Alloc = allocator>, enable_if_t>, _Is_allocator<_Alloc>>, int> = 0> @@ -618,12 +618,12 @@ multimap(initializer_list>, _Alloc) -> multimap<_Kty, _Ty, less< template <_RANGES input_range _Rng, class _Pr = less<_Range_key_type<_Rng>>, _Allocator_for_container _Alloc = allocator<_Range_to_alloc_type<_Rng>>> requires (!_Allocator_for_container<_Pr>) -multimap(from_range_t, _Rng&&, _Pr = _Pr(), _Alloc = _Alloc()) - -> multimap<_Range_key_type<_Rng>, _Range_mapped_type<_Rng>, _Pr, _Alloc>; +multimap(from_range_t, _Rng&&, _Pr = _Pr(), + _Alloc = _Alloc()) -> multimap<_Range_key_type<_Rng>, _Range_mapped_type<_Rng>, _Pr, _Alloc>; template <_RANGES input_range _Rng, _Allocator_for_container _Alloc> -multimap(from_range_t, _Rng&&, _Alloc) - -> multimap<_Range_key_type<_Rng>, _Range_mapped_type<_Rng>, less<_Range_key_type<_Rng>>, _Alloc>; +multimap(from_range_t, _Rng&&, + _Alloc) -> multimap<_Range_key_type<_Rng>, _Range_mapped_type<_Rng>, less<_Range_key_type<_Rng>>, _Alloc>; #endif // _HAS_CXX23 #endif // _HAS_CXX17 @@ -675,8 +675,8 @@ _NODISCARD bool operator>=( #endif // ^^^ !_HAS_CXX20 ^^^ _EXPORT_STD template -void swap(multimap<_Kty, _Ty, _Pr, _Alloc>& _Left, multimap<_Kty, _Ty, _Pr, _Alloc>& _Right) noexcept( - noexcept(_Left.swap(_Right))) { +void swap(multimap<_Kty, _Ty, _Pr, _Alloc>& _Left, multimap<_Kty, _Ty, _Pr, _Alloc>& _Right) + noexcept(noexcept(_Left.swap(_Right))) { _Left.swap(_Right); } diff --git a/stl/inc/mdspan b/stl/inc/mdspan index ce21eb7428d..3bb2292c5e2 100644 --- a/stl/inc/mdspan +++ b/stl/inc/mdspan @@ -1143,8 +1143,8 @@ struct _Mdspan_accessor_base<_AccessorPolicy> { #if _CONTAINER_DEBUG_LEVEL > 0 template -_NODISCARD constexpr _IndexType _Mdspan_checked_index_cast(_OtherIndexType&& _Idx) noexcept( - is_nothrow_constructible_v<_IndexType, _OtherIndexType>) { +_NODISCARD constexpr _IndexType _Mdspan_checked_index_cast(_OtherIndexType&& _Idx) + noexcept(is_nothrow_constructible_v<_IndexType, _OtherIndexType>) { _STL_INTERNAL_STATIC_ASSERT(is_integral_v<_IndexType> && is_constructible_v<_IndexType, _OtherIndexType>); using _Arg_value_t = remove_cvref_t<_OtherIndexType>; @@ -1225,9 +1225,9 @@ public: is_nothrow_constructible...> && (sizeof...(_OtherIndexTypes) == rank() || sizeof...(_OtherIndexTypes) == rank_dynamic()) && is_constructible_v && is_default_constructible_v - constexpr explicit mdspan(data_handle_type _Ptr_, _OtherIndexTypes... _Exts) noexcept( - is_nothrow_constructible_v - && is_nothrow_default_constructible_v) // strengthened + constexpr explicit mdspan(data_handle_type _Ptr_, _OtherIndexTypes... _Exts) + noexcept(is_nothrow_constructible_v + && is_nothrow_default_constructible_v) // strengthened : _Mapping_base(extents_type{static_cast(_STD move(_Exts))...}), _Accessor_base(), _Ptr(_STD move(_Ptr_)) {} @@ -1236,10 +1236,9 @@ public: && is_nothrow_constructible_v && (_Size == rank() || _Size == rank_dynamic()) && is_constructible_v && is_default_constructible_v - constexpr explicit(_Size != rank_dynamic()) - mdspan(data_handle_type _Ptr_, span<_OtherIndexType, _Size> _Exts) noexcept( - is_nothrow_constructible_v - && is_nothrow_default_constructible_v) // strengthened + constexpr explicit(_Size != rank_dynamic()) mdspan(data_handle_type _Ptr_, span<_OtherIndexType, _Size> _Exts) + noexcept(is_nothrow_constructible_v + && is_nothrow_default_constructible_v) // strengthened : _Mapping_base(extents_type{_Exts}), _Accessor_base(), _Ptr(_STD move(_Ptr_)) {} template @@ -1248,20 +1247,20 @@ public: && (_Size == rank() || _Size == rank_dynamic()) && is_constructible_v && is_default_constructible_v constexpr explicit(_Size != rank_dynamic()) - mdspan(data_handle_type _Ptr_, const array<_OtherIndexType, _Size>& _Exts) noexcept( - is_nothrow_constructible_v - && is_nothrow_default_constructible_v) // strengthened + mdspan(data_handle_type _Ptr_, const array<_OtherIndexType, _Size>& _Exts) + noexcept(is_nothrow_constructible_v + && is_nothrow_default_constructible_v) // strengthened : _Mapping_base(extents_type{_Exts}), _Accessor_base(), _Ptr(_STD move(_Ptr_)) {} - constexpr mdspan(data_handle_type _Ptr_, const extents_type& _Exts) noexcept( - is_nothrow_constructible_v - && is_nothrow_default_constructible_v) // strengthened + constexpr mdspan(data_handle_type _Ptr_, const extents_type& _Exts) + noexcept(is_nothrow_constructible_v + && is_nothrow_default_constructible_v) // strengthened requires is_constructible_v && is_default_constructible_v : _Mapping_base(_Exts), _Accessor_base(), _Ptr(_STD move(_Ptr_)) {} - constexpr mdspan(data_handle_type _Ptr_, const mapping_type& _Map_) noexcept( - is_nothrow_copy_constructible_v - && is_nothrow_default_constructible_v) // strengthened + constexpr mdspan(data_handle_type _Ptr_, const mapping_type& _Map_) + noexcept(is_nothrow_copy_constructible_v + && is_nothrow_default_constructible_v) // strengthened requires is_default_constructible_v : _Mapping_base(_Map_), _Accessor_base(), _Ptr(_STD move(_Ptr_)) {} @@ -1275,11 +1274,11 @@ public: constexpr explicit( !is_convertible_v&, mapping_type> || !is_convertible_v) - mdspan(const mdspan<_OtherElementType, _OtherExtents, _OtherLayoutPolicy, _OtherAccessor>& _Other) noexcept( - is_nothrow_constructible_v - && is_nothrow_constructible_v&> - && is_nothrow_constructible_v) // strengthened + mdspan(const mdspan<_OtherElementType, _OtherExtents, _OtherLayoutPolicy, _OtherAccessor>& _Other) + noexcept(is_nothrow_constructible_v + && is_nothrow_constructible_v&> + && is_nothrow_constructible_v) // strengthened : _Mapping_base(_Other.mapping()), _Accessor_base(_Other.accessor()), _Ptr(_Other.data_handle()) { static_assert(is_constructible_v, "The data_handle_type must be constructible from const typename OtherAccessor::data_handle_type& (N4950 " @@ -1464,17 +1463,17 @@ template mdspan(_ElementType*, const array<_OtherIndexType, _Nx>&) -> mdspan<_ElementType, dextents>; template -mdspan(_ElementType*, const extents<_IndexType, _ExtentsPack...>&) - -> mdspan<_ElementType, extents<_IndexType, _ExtentsPack...>>; +mdspan(_ElementType*, + const extents<_IndexType, _ExtentsPack...>&) -> mdspan<_ElementType, extents<_IndexType, _ExtentsPack...>>; template mdspan(_ElementType*, const _MappingType&) -> mdspan<_ElementType, typename _MappingType::extents_type, typename _MappingType::layout_type>; template -mdspan(const typename _AccessorType::data_handle_type&, const _MappingType&, const _AccessorType&) - -> mdspan; +mdspan(const typename _AccessorType::data_handle_type&, const _MappingType&, + const _AccessorType&) -> mdspan; _STD_END diff --git a/stl/inc/memory b/stl/inc/memory index 61cb6460203..e5272c95e88 100644 --- a/stl/inc/memory +++ b/stl/inc/memory @@ -529,10 +529,8 @@ namespace ranges { ::new (static_cast(_Ptr)) _Ty(static_cast<_Types&&>(_Args)...); // per LWG-3888 } _STATIC_CALL_OPERATOR constexpr _Ty* operator()(_Ty* _Location, _Types&&... _Args) _CONST_CALL_OPERATOR - // clang-format off noexcept(noexcept( - ::new(static_cast(_Location)) _Ty(_STD forward<_Types>(_Args)...))) /* strengthened */ { - // clang-format on + ::new (static_cast(_Location)) _Ty(_STD forward<_Types>(_Args)...))) /* strengthened */ { #ifdef __EDG__ return _STD construct_at(_Location, _STD forward<_Types>(_Args)...); #else // ^^^ EDG / Other vvv @@ -3034,8 +3032,8 @@ _NODISCARD shared_ptr<_Ty> _Allocate_shared_unbounded_array( // make a shared_ptr to an unbounded array static_assert(is_unbounded_array_v<_Ty>); using _Refc = conditional_t<_IsForOverwrite, // - _Ref_count_unbounded_array_alloc_for_overwrite, _Alloc>, - _Ref_count_unbounded_array_alloc, _Alloc>>; + _Ref_count_unbounded_array_alloc_for_overwrite, _Alloc>, + _Ref_count_unbounded_array_alloc, _Alloc>>; constexpr size_t _Align = alignof(_Refc); using _Storage = _Alignas_storage_unit<_Align>; _Rebind_alloc_t<_Alloc, _Storage> _Rebound(_Al); @@ -3380,7 +3378,7 @@ public: #if _HAS_AUTO_PTR_ETC template , is_same<_Dx, default_delete<_Ty>>>, int> = 0> + enable_if_t, is_same<_Dx, default_delete<_Ty>>>, int> = 0> unique_ptr(auto_ptr<_Ty2>&& _Right) noexcept : _Mypair(_Zero_then_variadic_args_t{}, _Right.release()) {} #endif // _HAS_AUTO_PTR_ETC @@ -3665,14 +3663,12 @@ _NODISCARD bool operator<=(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr } #if _HAS_CXX20 -// clang-format off _EXPORT_STD template requires three_way_comparable_with::pointer, typename unique_ptr<_Ty2, _Dx2>::pointer> -_NODISCARD compare_three_way_result_t::pointer, - typename unique_ptr<_Ty2, _Dx2>::pointer> +_NODISCARD + compare_three_way_result_t::pointer, typename unique_ptr<_Ty2, _Dx2>::pointer> operator<=>(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { - // clang-format on return _Left.get() <=> _Right.get(); } #endif // _HAS_CXX20 @@ -3852,8 +3848,8 @@ struct owner_less { template struct hash> : _Conditionally_enabled_hash, is_default_constructible_v::pointer>>> { - static size_t _Do_hash(const unique_ptr<_Ty, _Dx>& _Keyval) noexcept( - _Is_nothrow_hashable::pointer>::value) { + static size_t _Do_hash(const unique_ptr<_Ty, _Dx>& _Keyval) + noexcept(_Is_nothrow_hashable::pointer>::value) { return hash::pointer>{}(_Keyval.get()); } }; @@ -4278,14 +4274,12 @@ struct _Pointer_of_helper<_Ty> { using type = _Ty::element_type*; }; -// clang-format off template - requires (!_Has_member_element_type<_Ty> && !_Has_member_pointer<_Ty> - && _Has_member_element_type>) + requires ( + !_Has_member_element_type<_Ty> && !_Has_member_pointer<_Ty> && _Has_member_element_type>) struct _Pointer_of_helper<_Ty> { using type = pointer_traits<_Ty>::element_type*; }; -// clang-format on template using _Pointer_of = _Pointer_of_helper<_Ty>::type; @@ -4315,8 +4309,8 @@ class out_ptr_t { "out_ptr_t with shared_ptr requires a deleter (N4950 [out.ptr.t]/3)"); public: - explicit out_ptr_t(_SmartPtr& _Smart_ptr_, _ArgsT... _Args_) noexcept( - is_nothrow_constructible_v, _ArgsT...>) /* strengthened */ + explicit out_ptr_t(_SmartPtr& _Smart_ptr_, _ArgsT... _Args_) + noexcept(is_nothrow_constructible_v, _ArgsT...>) /* strengthened */ : _Smart_ptr(_Smart_ptr_), _Mypair(_One_then_variadic_args_t{}, tuple<_ArgsT...>{_STD forward<_ArgsT>(_Args_)...}) { constexpr bool _Is_resettable = requires { _Smart_ptr.reset(); }; // TRANSITION, DevCom-10291456 @@ -4399,9 +4393,9 @@ private: } public: - explicit inout_ptr_t(_SmartPtr& _Smart_ptr_, _ArgsT... _Args_) noexcept( - is_nothrow_constructible_v, _ArgsT...> // - && noexcept(_Get_ptr_from_smart(_Smart_ptr_))) /* strengthened */ + explicit inout_ptr_t(_SmartPtr& _Smart_ptr_, _ArgsT... _Args_) + noexcept(is_nothrow_constructible_v, _ArgsT...> + && noexcept(_Get_ptr_from_smart(_Smart_ptr_))) /* strengthened */ : _Smart_ptr(_Smart_ptr_), _Mypair(_One_then_variadic_args_t{}, tuple<_ArgsT...>{_STD forward<_ArgsT>(_Args_)...}, _Get_ptr_from_smart(_Smart_ptr_)) {} diff --git a/stl/inc/optional b/stl/inc/optional index 7afd6425607..6ce1bcf4c31 100644 --- a/stl/inc/optional +++ b/stl/inc/optional @@ -77,14 +77,14 @@ struct _Optional_destruct_base { // either contains a value of _Ty or is empty ( constexpr _Optional_destruct_base() noexcept : _Dummy{}, _Has_value{false} {} // initialize an empty optional template - constexpr explicit _Optional_destruct_base(in_place_t, _Types&&... _Args) noexcept( - is_nothrow_constructible_v<_Ty, _Types...>) + constexpr explicit _Optional_destruct_base(in_place_t, _Types&&... _Args) + noexcept(is_nothrow_constructible_v<_Ty, _Types...>) : _Value(_STD forward<_Types>(_Args)...), _Has_value{true} {} // initialize contained value with _Args... #if _HAS_CXX23 template - constexpr _Optional_destruct_base(_Construct_from_invoke_result_tag, _Fn&& _Func, _Ux&& _Arg) noexcept( - noexcept(static_cast<_Ty>(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))))) + constexpr _Optional_destruct_base(_Construct_from_invoke_result_tag, _Fn&& _Func, _Ux&& _Arg) + noexcept(noexcept(static_cast<_Ty>(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))))) : _Value(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))), _Has_value{true} {} #endif // _HAS_CXX23 @@ -110,14 +110,14 @@ struct _Optional_destruct_base<_Ty, false> { // either contains a value of _Ty o constexpr _Optional_destruct_base() noexcept : _Dummy{}, _Has_value{false} {} // initialize an empty optional template - constexpr explicit _Optional_destruct_base(in_place_t, _Types&&... _Args) noexcept( - is_nothrow_constructible_v<_Ty, _Types...>) + constexpr explicit _Optional_destruct_base(in_place_t, _Types&&... _Args) + noexcept(is_nothrow_constructible_v<_Ty, _Types...>) : _Value(_STD forward<_Types>(_Args)...), _Has_value{true} {} // initialize contained value with _Args... #if _HAS_CXX23 template - constexpr _Optional_destruct_base(_Construct_from_invoke_result_tag, _Fn&& _Func, _Ux&& _Arg) noexcept( - noexcept(static_cast<_Ty>(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))))) + constexpr _Optional_destruct_base(_Construct_from_invoke_result_tag, _Fn&& _Func, _Ux&& _Arg) + noexcept(noexcept(static_cast<_Ty>(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))))) : _Value(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))), _Has_value{true} {} #endif // _HAS_CXX23 @@ -149,8 +149,8 @@ struct _Optional_construct_base : _Optional_destruct_base<_Ty> { } template - _CONSTEXPR20 void _Assign(_Ty2&& _Right) noexcept( - is_nothrow_assignable_v<_Ty&, _Ty2> && is_nothrow_constructible_v<_Ty, _Ty2>) { + _CONSTEXPR20 void _Assign(_Ty2&& _Right) + noexcept(is_nothrow_assignable_v<_Ty&, _Ty2> && is_nothrow_constructible_v<_Ty, _Ty2>) { // assign / initialize the contained value from _Right if (this->_Has_value) { static_cast<_Ty&>(this->_Value) = _STD forward<_Ty2>(_Right); @@ -160,8 +160,8 @@ struct _Optional_construct_base : _Optional_destruct_base<_Ty> { } template - _CONSTEXPR20 void _Construct_from(_Self&& _Right) noexcept( - is_nothrow_constructible_v<_Ty, decltype(*_STD forward<_Self>(_Right))>) { + _CONSTEXPR20 void _Construct_from(_Self&& _Right) + noexcept(is_nothrow_constructible_v<_Ty, decltype(*_STD forward<_Self>(_Right))>) { // initialize contained value from _Right iff it contains a value if (_Right._Has_value) { _Construct(*_STD forward<_Self>(_Right)); @@ -169,9 +169,9 @@ struct _Optional_construct_base : _Optional_destruct_base<_Ty> { } template - _CONSTEXPR20 void _Assign_from(_Self&& _Right) noexcept( - is_nothrow_constructible_v<_Ty, decltype(*_STD forward<_Self>(_Right))> - && is_nothrow_assignable_v<_Ty&, decltype(*_STD forward<_Self>(_Right))>) { + _CONSTEXPR20 void _Assign_from(_Self&& _Right) + noexcept(is_nothrow_constructible_v<_Ty, decltype(*_STD forward<_Self>(_Right))> + && is_nothrow_assignable_v<_Ty&, decltype(*_STD forward<_Self>(_Right))>) { // assign/initialize/destroy contained value from _Right if (_Right._Has_value) { _Assign(*_STD forward<_Self>(_Right)); @@ -226,14 +226,14 @@ public: constexpr optional(nullopt_t) noexcept {} template , int> = 0> - constexpr explicit optional(in_place_t, _Types&&... _Args) noexcept( - is_nothrow_constructible_v<_Ty, _Types...>) // strengthened + constexpr explicit optional(in_place_t, _Types&&... _Args) + noexcept(is_nothrow_constructible_v<_Ty, _Types...>) // strengthened : _Mybase(in_place, _STD forward<_Types>(_Args)...) {} template &, _Types...>, int> = 0> - constexpr explicit optional(in_place_t, initializer_list<_Elem> _Ilist, _Types&&... _Args) noexcept( - is_nothrow_constructible_v<_Ty, initializer_list<_Elem>&, _Types...>) // strengthened + constexpr explicit optional(in_place_t, initializer_list<_Elem> _Ilist, _Types&&... _Args) + noexcept(is_nothrow_constructible_v<_Ty, initializer_list<_Elem>&, _Types...>) // strengthened : _Mybase(in_place, _Ilist, _STD forward<_Types>(_Args)...) {} template @@ -243,8 +243,8 @@ public: is_constructible<_Ty, _Ty2>>>; template ::value, int> = 0> - constexpr explicit(!is_convertible_v<_Ty2, _Ty>) - optional(_Ty2&& _Right) noexcept(is_nothrow_constructible_v<_Ty, _Ty2>) // strengthened + constexpr explicit(!is_convertible_v<_Ty2, _Ty>) optional(_Ty2&& _Right) + noexcept(is_nothrow_constructible_v<_Ty, _Ty2>) // strengthened : _Mybase(in_place, _STD forward<_Ty2>(_Right)) {} template @@ -258,16 +258,16 @@ public: template , is_constructible<_Ty, const _Ty2&>>, int> = 0> - _CONSTEXPR20 explicit(!is_convertible_v) optional(const optional<_Ty2>& _Right) noexcept( - is_nothrow_constructible_v<_Ty, const _Ty2&>) /* strengthened */ { + _CONSTEXPR20 explicit(!is_convertible_v) optional(const optional<_Ty2>& _Right) + noexcept(is_nothrow_constructible_v<_Ty, const _Ty2&>) /* strengthened */ { if (_Right) { this->_Construct(*_Right); } } template , is_constructible<_Ty, _Ty2>>, int> = 0> - _CONSTEXPR20 explicit(!is_convertible_v<_Ty2, _Ty>) - optional(optional<_Ty2>&& _Right) noexcept(is_nothrow_constructible_v<_Ty, _Ty2>) /* strengthened */ { + _CONSTEXPR20 explicit(!is_convertible_v<_Ty2, _Ty>) optional(optional<_Ty2>&& _Right) + noexcept(is_nothrow_constructible_v<_Ty, _Ty2>) /* strengthened */ { if (_Right) { this->_Construct(_STD move(*_Right)); } @@ -275,8 +275,8 @@ public: #if _HAS_CXX23 template - constexpr optional(_Construct_from_invoke_result_tag _Tag, _Fn&& _Func, _Ux&& _Arg) noexcept( - noexcept(static_cast<_Ty>(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))))) + constexpr optional(_Construct_from_invoke_result_tag _Tag, _Fn&& _Func, _Ux&& _Arg) + noexcept(noexcept(static_cast<_Ty>(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))))) : _Mybase(_Tag, _STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg)) {} #endif // _HAS_CXX23 @@ -289,8 +289,8 @@ public: negation, is_same<_Ty, decay_t<_Ty2>>>>, is_constructible<_Ty, _Ty2>, is_assignable<_Ty&, _Ty2>>, int> = 0> - _CONSTEXPR20 optional& operator=(_Ty2&& _Right) noexcept( - is_nothrow_assignable_v<_Ty&, _Ty2> && is_nothrow_constructible_v<_Ty, _Ty2>) /* strengthened */ { + _CONSTEXPR20 optional& operator=(_Ty2&& _Right) + noexcept(is_nothrow_assignable_v<_Ty&, _Ty2> && is_nothrow_constructible_v<_Ty, _Ty2>) /* strengthened */ { this->_Assign(_STD forward<_Ty2>(_Right)); return *this; } @@ -318,8 +318,8 @@ public: template , is_constructible<_Ty, _Ty2>, is_assignable<_Ty&, _Ty2>>, int> = 0> - _CONSTEXPR20 optional& operator=(optional<_Ty2>&& _Right) noexcept( - is_nothrow_assignable_v<_Ty&, _Ty2> && is_nothrow_constructible_v<_Ty, _Ty2>) /* strengthened */ { + _CONSTEXPR20 optional& operator=(optional<_Ty2>&& _Right) + noexcept(is_nothrow_assignable_v<_Ty&, _Ty2> && is_nothrow_constructible_v<_Ty, _Ty2>) /* strengthened */ { if (_Right) { this->_Assign(_STD move(*_Right)); } else { @@ -330,22 +330,22 @@ public: } template - _CONSTEXPR20 _Ty& emplace(_Types&&... _Args) noexcept( - is_nothrow_constructible_v<_Ty, _Types...>) /* strengthened */ { + _CONSTEXPR20 _Ty& emplace(_Types&&... _Args) + noexcept(is_nothrow_constructible_v<_Ty, _Types...>) /* strengthened */ { reset(); return this->_Construct(_STD forward<_Types>(_Args)...); } template &, _Types...>, int> = 0> - _CONSTEXPR20 _Ty& emplace(initializer_list<_Elem> _Ilist, _Types&&... _Args) noexcept( - is_nothrow_constructible_v<_Ty, initializer_list<_Elem>&, _Types...>) /* strengthened */ { + _CONSTEXPR20 _Ty& emplace(initializer_list<_Elem> _Ilist, _Types&&... _Args) + noexcept(is_nothrow_constructible_v<_Ty, initializer_list<_Elem>&, _Types...>) /* strengthened */ { reset(); return this->_Construct(_Ilist, _STD forward<_Types>(_Args)...); } - _CONSTEXPR20 void swap(optional& _Right) noexcept( - is_nothrow_move_constructible_v<_Ty> && is_nothrow_swappable_v<_Ty>) { + _CONSTEXPR20 void swap(optional& _Right) + noexcept(is_nothrow_move_constructible_v<_Ty> && is_nothrow_swappable_v<_Ty>) { static_assert(is_move_constructible_v<_Ty>, "optional::swap requires T to be move constructible (N4950 [optional.swap]/1)."); static_assert(!is_move_constructible_v<_Ty> || is_swappable_v<_Ty>, @@ -620,8 +620,8 @@ template optional(_Ty) -> optional<_Ty>; _EXPORT_STD template -_NODISCARD constexpr bool operator==(const optional<_Ty1>& _Left, const optional<_Ty2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(*_Left == *_Right))) /* strengthened */ +_NODISCARD constexpr bool operator==(const optional<_Ty1>& _Left, const optional<_Ty2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(*_Left == *_Right))) /* strengthened */ #if _HAS_CXX20 requires requires { { *_Left == *_Right } -> _Implicitly_convertible_to; @@ -637,8 +637,8 @@ _NODISCARD constexpr bool operator==(const optional<_Ty1>& _Left, const optional } _EXPORT_STD template -_NODISCARD constexpr bool operator!=(const optional<_Ty1>& _Left, const optional<_Ty2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(*_Left != *_Right))) /* strengthened */ +_NODISCARD constexpr bool operator!=(const optional<_Ty1>& _Left, const optional<_Ty2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(*_Left != *_Right))) /* strengthened */ #if _HAS_CXX20 requires requires { { *_Left != *_Right } -> _Implicitly_convertible_to; @@ -654,8 +654,8 @@ _NODISCARD constexpr bool operator!=(const optional<_Ty1>& _Left, const optional } _EXPORT_STD template -_NODISCARD constexpr bool operator<(const optional<_Ty1>& _Left, const optional<_Ty2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(*_Left < *_Right))) /* strengthened */ +_NODISCARD constexpr bool operator<(const optional<_Ty1>& _Left, const optional<_Ty2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(*_Left < *_Right))) /* strengthened */ #if _HAS_CXX20 requires requires { { *_Left < *_Right } -> _Implicitly_convertible_to; @@ -671,8 +671,8 @@ _NODISCARD constexpr bool operator<(const optional<_Ty1>& _Left, const optional< } _EXPORT_STD template -_NODISCARD constexpr bool operator>(const optional<_Ty1>& _Left, const optional<_Ty2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(*_Left > *_Right))) /* strengthened */ +_NODISCARD constexpr bool operator>(const optional<_Ty1>& _Left, const optional<_Ty2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(*_Left > *_Right))) /* strengthened */ #if _HAS_CXX20 requires requires { { *_Left > *_Right } -> _Implicitly_convertible_to; @@ -688,8 +688,8 @@ _NODISCARD constexpr bool operator>(const optional<_Ty1>& _Left, const optional< } _EXPORT_STD template -_NODISCARD constexpr bool operator<=(const optional<_Ty1>& _Left, const optional<_Ty2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(*_Left <= *_Right))) /* strengthened */ +_NODISCARD constexpr bool operator<=(const optional<_Ty1>& _Left, const optional<_Ty2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(*_Left <= *_Right))) /* strengthened */ #if _HAS_CXX20 requires requires { { *_Left <= *_Right } -> _Implicitly_convertible_to; @@ -705,8 +705,8 @@ _NODISCARD constexpr bool operator<=(const optional<_Ty1>& _Left, const optional } _EXPORT_STD template -_NODISCARD constexpr bool operator>=(const optional<_Ty1>& _Left, const optional<_Ty2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(*_Left >= *_Right))) /* strengthened */ +_NODISCARD constexpr bool operator>=(const optional<_Ty1>& _Left, const optional<_Ty2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(*_Left >= *_Right))) /* strengthened */ #if _HAS_CXX20 requires requires { { *_Left >= *_Right } -> _Implicitly_convertible_to; @@ -825,8 +825,8 @@ using _Enable_if_comparable_with_greater_equal = _Enable_if_bool_convertible() >= _STD declval())>; _EXPORT_STD template = 0> -_NODISCARD constexpr bool operator==(const optional<_Ty1>& _Left, const _Ty2& _Right) noexcept( - noexcept(_STD _Fake_copy_init(*_Left == _Right))) /* strengthened */ { +_NODISCARD constexpr bool operator==(const optional<_Ty1>& _Left, const _Ty2& _Right) + noexcept(noexcept(_STD _Fake_copy_init(*_Left == _Right))) /* strengthened */ { if (_Left) { return *_Left == _Right; } @@ -834,8 +834,8 @@ _NODISCARD constexpr bool operator==(const optional<_Ty1>& _Left, const _Ty2& _R } _EXPORT_STD template = 0> -_NODISCARD constexpr bool operator==(const _Ty1& _Left, const optional<_Ty2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left == *_Right))) /* strengthened */ { +_NODISCARD constexpr bool operator==(const _Ty1& _Left, const optional<_Ty2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left == *_Right))) /* strengthened */ { if (_Right) { return _Left == *_Right; } @@ -843,16 +843,16 @@ _NODISCARD constexpr bool operator==(const _Ty1& _Left, const optional<_Ty2>& _R } _EXPORT_STD template = 0> -_NODISCARD constexpr bool operator!=(const optional<_Ty1>& _Left, const _Ty2& _Right) noexcept( - noexcept(_STD _Fake_copy_init(*_Left != _Right))) /* strengthened */ { +_NODISCARD constexpr bool operator!=(const optional<_Ty1>& _Left, const _Ty2& _Right) + noexcept(noexcept(_STD _Fake_copy_init(*_Left != _Right))) /* strengthened */ { if (_Left) { return *_Left != _Right; } return true; } _EXPORT_STD template = 0> -_NODISCARD constexpr bool operator!=(const _Ty1& _Left, const optional<_Ty2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left != *_Right))) /* strengthened */ { +_NODISCARD constexpr bool operator!=(const _Ty1& _Left, const optional<_Ty2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left != *_Right))) /* strengthened */ { if (_Right) { return _Left != *_Right; } @@ -860,16 +860,16 @@ _NODISCARD constexpr bool operator!=(const _Ty1& _Left, const optional<_Ty2>& _R } _EXPORT_STD template = 0> -_NODISCARD constexpr bool operator<(const optional<_Ty1>& _Left, const _Ty2& _Right) noexcept( - noexcept(_STD _Fake_copy_init(*_Left < _Right))) /* strengthened */ { +_NODISCARD constexpr bool operator<(const optional<_Ty1>& _Left, const _Ty2& _Right) + noexcept(noexcept(_STD _Fake_copy_init(*_Left < _Right))) /* strengthened */ { if (_Left) { return *_Left < _Right; } return true; } _EXPORT_STD template = 0> -_NODISCARD constexpr bool operator<(const _Ty1& _Left, const optional<_Ty2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left < *_Right))) /* strengthened */ { +_NODISCARD constexpr bool operator<(const _Ty1& _Left, const optional<_Ty2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left < *_Right))) /* strengthened */ { if (_Right) { return _Left < *_Right; } @@ -877,16 +877,16 @@ _NODISCARD constexpr bool operator<(const _Ty1& _Left, const optional<_Ty2>& _Ri } _EXPORT_STD template = 0> -_NODISCARD constexpr bool operator>(const optional<_Ty1>& _Left, const _Ty2& _Right) noexcept( - noexcept(_STD _Fake_copy_init(*_Left > _Right))) /* strengthened */ { +_NODISCARD constexpr bool operator>(const optional<_Ty1>& _Left, const _Ty2& _Right) + noexcept(noexcept(_STD _Fake_copy_init(*_Left > _Right))) /* strengthened */ { if (_Left) { return *_Left > _Right; } return false; } _EXPORT_STD template = 0> -_NODISCARD constexpr bool operator>(const _Ty1& _Left, const optional<_Ty2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left > *_Right))) /* strengthened */ { +_NODISCARD constexpr bool operator>(const _Ty1& _Left, const optional<_Ty2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left > *_Right))) /* strengthened */ { if (_Right) { return _Left > *_Right; } @@ -894,16 +894,16 @@ _NODISCARD constexpr bool operator>(const _Ty1& _Left, const optional<_Ty2>& _Ri } _EXPORT_STD template = 0> -_NODISCARD constexpr bool operator<=(const optional<_Ty1>& _Left, const _Ty2& _Right) noexcept( - noexcept(_STD _Fake_copy_init(*_Left <= _Right))) /* strengthened */ { +_NODISCARD constexpr bool operator<=(const optional<_Ty1>& _Left, const _Ty2& _Right) + noexcept(noexcept(_STD _Fake_copy_init(*_Left <= _Right))) /* strengthened */ { if (_Left) { return *_Left <= _Right; } return true; } _EXPORT_STD template = 0> -_NODISCARD constexpr bool operator<=(const _Ty1& _Left, const optional<_Ty2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left <= *_Right))) /* strengthened */ { +_NODISCARD constexpr bool operator<=(const _Ty1& _Left, const optional<_Ty2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left <= *_Right))) /* strengthened */ { if (_Right) { return _Left <= *_Right; } @@ -911,16 +911,16 @@ _NODISCARD constexpr bool operator<=(const _Ty1& _Left, const optional<_Ty2>& _R } _EXPORT_STD template = 0> -_NODISCARD constexpr bool operator>=(const optional<_Ty1>& _Left, const _Ty2& _Right) noexcept( - noexcept(_STD _Fake_copy_init(*_Left >= _Right))) /* strengthened */ { +_NODISCARD constexpr bool operator>=(const optional<_Ty1>& _Left, const _Ty2& _Right) + noexcept(noexcept(_STD _Fake_copy_init(*_Left >= _Right))) /* strengthened */ { if (_Left) { return *_Left >= _Right; } return false; } _EXPORT_STD template = 0> -_NODISCARD constexpr bool operator>=(const _Ty1& _Left, const optional<_Ty2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left >= *_Right))) /* strengthened */ { +_NODISCARD constexpr bool operator>=(const _Ty1& _Left, const optional<_Ty2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left >= *_Right))) /* strengthened */ { if (_Right) { return _Left >= *_Right; } @@ -930,8 +930,8 @@ _NODISCARD constexpr bool operator>=(const _Ty1& _Left, const optional<_Ty2>& _R #if _HAS_CXX20 _EXPORT_STD template requires (!_Derived_from_specialization_of<_Ty2, optional>) && three_way_comparable_with<_Ty1, _Ty2> -_NODISCARD constexpr compare_three_way_result_t<_Ty1, _Ty2> operator<=>( - const optional<_Ty1>& _Left, const _Ty2& _Right) noexcept(noexcept(*_Left <=> _Right)) /* strengthened */ { +_NODISCARD constexpr compare_three_way_result_t<_Ty1, _Ty2> operator<=>(const optional<_Ty1>& _Left, const _Ty2& _Right) + noexcept(noexcept(*_Left <=> _Right)) /* strengthened */ { if (_Left) { return *_Left <=> _Right; } @@ -946,19 +946,19 @@ _CONSTEXPR20 void swap(optional<_Ty>& _Left, optional<_Ty>& _Right) noexcept(noe } _EXPORT_STD template , _Ty>, int> = 0> // LWG-3627 -_NODISCARD constexpr optional> make_optional(_Ty&& _Value) noexcept( - noexcept(optional>{_STD forward<_Ty>(_Value)})) /* strengthened */ { +_NODISCARD constexpr optional> make_optional(_Ty&& _Value) + noexcept(noexcept(optional>{_STD forward<_Ty>(_Value)})) /* strengthened */ { return optional>{_STD forward<_Ty>(_Value)}; } _EXPORT_STD template , int> = 0> -_NODISCARD constexpr optional<_Ty> make_optional(_Types&&... _Args) noexcept( - noexcept(optional<_Ty>{in_place, _STD forward<_Types>(_Args)...})) /* strengthened */ { +_NODISCARD constexpr optional<_Ty> make_optional(_Types&&... _Args) + noexcept(noexcept(optional<_Ty>{in_place, _STD forward<_Types>(_Args)...})) /* strengthened */ { return optional<_Ty>{in_place, _STD forward<_Types>(_Args)...}; } _EXPORT_STD template &, _Types...>, int> = 0> -_NODISCARD constexpr optional<_Ty> make_optional(initializer_list<_Elem> _Ilist, _Types&&... _Args) noexcept( - noexcept(optional<_Ty>{in_place, _Ilist, _STD forward<_Types>(_Args)...})) /* strengthened */ { +_NODISCARD constexpr optional<_Ty> make_optional(initializer_list<_Elem> _Ilist, _Types&&... _Args) + noexcept(noexcept(optional<_Ty>{in_place, _Ilist, _STD forward<_Types>(_Args)...})) /* strengthened */ { return optional<_Ty>{in_place, _Ilist, _STD forward<_Types>(_Args)...}; } diff --git a/stl/inc/ostream b/stl/inc/ostream index b682a8b68bd..40a60377077 100644 --- a/stl/inc/ostream +++ b/stl/inc/ostream @@ -7,7 +7,7 @@ #define _OSTREAM_ #include #if _STL_COMPILER_PREPROCESSOR -#include +#include <__msvc_ostream.hpp> #if _HAS_CXX23 #include <__msvc_filebuf.hpp> @@ -23,1016 +23,6 @@ _STL_DISABLE_CLANG_WARNINGS #undef new _STD_BEGIN -#pragma vtordisp(push, 2) // compiler bug workaround - -_EXPORT_STD extern "C++" template -class basic_ostream : virtual public basic_ios<_Elem, _Traits> { // control insertions into a stream buffer -public: - using _Myios = basic_ios<_Elem, _Traits>; - using _Mysb = basic_streambuf<_Elem, _Traits>; - using _Iter = ostreambuf_iterator<_Elem, _Traits>; - using _Nput = num_put<_Elem, _Iter>; - - explicit __CLR_OR_THIS_CALL basic_ostream(basic_streambuf<_Elem, _Traits>* _Strbuf, bool _Isstd = false) { - _Myios::init(_Strbuf, _Isstd); - } - - __CLR_OR_THIS_CALL basic_ostream(_Uninitialized, bool _Addit = true) { - if (_Addit) { - this->_Addstd(this); // suppress for basic_iostream - } - } - -protected: - __CLR_OR_THIS_CALL basic_ostream(basic_ostream&& _Right) noexcept(false) { - _Myios::init(); - _Myios::move(_STD move(_Right)); - } - - basic_ostream& __CLR_OR_THIS_CALL operator=(basic_ostream&& _Right) noexcept /* strengthened */ { - this->swap(_Right); - return *this; - } - - void __CLR_OR_THIS_CALL swap(basic_ostream& _Right) noexcept /* strengthened */ { - if (this != _STD addressof(_Right)) { - _Myios::swap(_Right); - } - } - -public: - __CLR_OR_THIS_CALL basic_ostream(const basic_ostream&) = delete; - basic_ostream& __CLR_OR_THIS_CALL operator=(const basic_ostream&) = delete; - - __CLR_OR_THIS_CALL ~basic_ostream() noexcept override {} - - using int_type = typename _Traits::int_type; - using pos_type = typename _Traits::pos_type; - using off_type = typename _Traits::off_type; - - class _Sentry_base { // stores thread lock and reference to output stream - public: - __CLR_OR_THIS_CALL _Sentry_base(basic_ostream& _Ostr) : _Myostr(_Ostr) { // lock the stream buffer, if there - const auto _Rdbuf = _Myostr.rdbuf(); - if (_Rdbuf) { - _Rdbuf->_Lock(); - } - } - - __CLR_OR_THIS_CALL ~_Sentry_base() noexcept { // destroy after unlocking - const auto _Rdbuf = _Myostr.rdbuf(); - if (_Rdbuf) { - _Rdbuf->_Unlock(); - } - } - - basic_ostream& _Myostr; // the output stream, for _Unlock call at destruction - - _Sentry_base& operator=(const _Sentry_base&) = delete; - }; - - class sentry : public _Sentry_base { - public: - explicit __CLR_OR_THIS_CALL sentry(basic_ostream& _Ostr) : _Sentry_base(_Ostr) { - if (!_Ostr.good()) { - _Ok = false; - return; - } - - const auto _Tied = _Ostr.tie(); - if (!_Tied || _Tied == &_Ostr) { - _Ok = true; - return; - } - - _Tied->flush(); - _Ok = _Ostr.good(); // store test only after flushing tie - } - - _STL_DISABLE_DEPRECATED_WARNING - __CLR_OR_THIS_CALL ~sentry() noexcept { -#if !_HAS_EXCEPTIONS - const bool _Zero_uncaught_exceptions = true; -#elif _HAS_DEPRECATED_UNCAUGHT_EXCEPTION - const bool _Zero_uncaught_exceptions = !_STD uncaught_exception(); // TRANSITION, ArchivedOS-12000909 -#else // ^^^ _HAS_DEPRECATED_UNCAUGHT_EXCEPTION / !_HAS_DEPRECATED_UNCAUGHT_EXCEPTION vvv - const bool _Zero_uncaught_exceptions = _STD uncaught_exceptions() == 0; -#endif // ^^^ !_HAS_DEPRECATED_UNCAUGHT_EXCEPTION ^^^ - - if (_Zero_uncaught_exceptions) { - this->_Myostr._Osfx(); - } - } - _STL_RESTORE_DEPRECATED_WARNING - - explicit __CLR_OR_THIS_CALL operator bool() const { - return _Ok; - } - - __CLR_OR_THIS_CALL sentry(const sentry&) = delete; - sentry& __CLR_OR_THIS_CALL operator=(const sentry&) = delete; - - private: - bool _Ok; // true if stream state okay at construction - }; - -#pragma push_macro("opfx") -#pragma push_macro("osfx") -#undef opfx -#undef osfx - // TRANSITION, ABI: non-Standard opfx() is preserved for binary compatibility - _DEPRECATE_IO_PFX_SFX bool __CLR_OR_THIS_CALL opfx() { // test stream state and flush tie stream as needed - if (!this->good()) { - return false; - } - - const auto _Tied = _Myios::tie(); - if (!_Tied || _Myios::tie() == this) { - return true; - } - - _Tied->flush(); - return this->good(); - } - - // TRANSITION, ABI: non-Standard osfx() is preserved for binary compatibility - _DEPRECATE_IO_PFX_SFX void __CLR_OR_THIS_CALL osfx() noexcept { // perform any wrapup - _Osfx(); - } -#pragma pop_macro("osfx") -#pragma pop_macro("opfx") - - void __CLR_OR_THIS_CALL _Osfx() noexcept { // perform any wrapup - _TRY_BEGIN - if (this->good() && this->flags() & ios_base::unitbuf) { - if (_Myios::rdbuf()->pubsync() == -1) { // flush stream as needed - _Myios::setstate(ios_base::badbit); - } - } - _CATCH_ALL - _CATCH_END - } - -#ifdef _M_CEE_PURE - basic_ostream& __CLR_OR_THIS_CALL operator<<(basic_ostream&(__clrcall* _Pfn)(basic_ostream&) ) { - // call basic_ostream manipulator - return _Pfn(*this); - } - - basic_ostream& __CLR_OR_THIS_CALL operator<<(_Myios&(__clrcall* _Pfn)(_Myios&) ) { - // call basic_ios manipulator - _Pfn(*this); - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL operator<<(ios_base&(__clrcall* _Pfn)(ios_base&) ) { - // call ios_base manipulator - _Pfn(*this); - return *this; - } -#endif // defined(_M_CEE_PURE) - - basic_ostream& __CLR_OR_THIS_CALL operator<<(basic_ostream&(__cdecl* _Pfn)(basic_ostream&) ) { - // call basic_ostream manipulator - return _Pfn(*this); - } - - basic_ostream& __CLR_OR_THIS_CALL operator<<(_Myios&(__cdecl* _Pfn)(_Myios&) ) { - // call basic_ios manipulator - _Pfn(*this); - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL operator<<(ios_base&(__cdecl* _Pfn)(ios_base&) ) { - // call ios_base manipulator - _Pfn(*this); - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL operator<<(bool _Val) { // insert a boolean - ios_base::iostate _State = ios_base::goodbit; - const sentry _Ok(*this); - - if (_Ok) { // state okay, use facet to insert - const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); - - _TRY_IO_BEGIN - if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Val).failed()) { - _State |= ios_base::badbit; - } - _CATCH_IO_END - } - - _Myios::setstate(_State); - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL operator<<(short _Val) { // insert a short - ios_base::iostate _State = ios_base::goodbit; - const sentry _Ok(*this); - - if (_Ok) { // state okay, use facet to insert - const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); - ios_base::fmtflags _Bfl = this->flags() & ios_base::basefield; - - long _Tmp; - if (_Bfl == ios_base::oct || _Bfl == ios_base::hex) { - _Tmp = static_cast(static_cast(_Val)); - } else { - _Tmp = static_cast(_Val); - } - - _TRY_IO_BEGIN - if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Tmp).failed()) { - _State |= ios_base::badbit; - } - _CATCH_IO_END - } - - _Myios::setstate(_State); - return *this; - } - - // NOTE: - // If you are not using native wchar_t, the unsigned short inserter - // is masked by an explicit specialization that treats an unsigned - // short as a wide character. - - // To read or write unsigned shorts as integers with wchar_t streams, - // make wchar_t a native type with the command line option /Zc:wchar_t. - - basic_ostream& __CLR_OR_THIS_CALL operator<<(unsigned short _Val) { // insert an unsigned short - ios_base::iostate _State = ios_base::goodbit; - const sentry _Ok(*this); - - if (_Ok) { // state okay, use facet to insert - const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); - - _TRY_IO_BEGIN - if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), static_cast(_Val)) - .failed()) { - _State |= ios_base::badbit; - } - _CATCH_IO_END - } - - _Myios::setstate(_State); - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL operator<<(int _Val) { // insert an int - ios_base::iostate _State = ios_base::goodbit; - const sentry _Ok(*this); - - if (_Ok) { // state okay, use facet to insert - const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); - ios_base::fmtflags _Bfl = this->flags() & ios_base::basefield; - - long _Tmp; - if (_Bfl == ios_base::oct || _Bfl == ios_base::hex) { - _Tmp = static_cast(static_cast(_Val)); - } else { - _Tmp = static_cast(_Val); - } - - _TRY_IO_BEGIN - if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Tmp).failed()) { - _State |= ios_base::badbit; - } - _CATCH_IO_END - } - - _Myios::setstate(_State); - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL operator<<(unsigned int _Val) { // insert an unsigned int - ios_base::iostate _State = ios_base::goodbit; - const sentry _Ok(*this); - - if (_Ok) { // state okay, use facet to insert - const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); - - _TRY_IO_BEGIN - if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), static_cast(_Val)) - .failed()) { - _State |= ios_base::badbit; - } - _CATCH_IO_END - } - - _Myios::setstate(_State); - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL operator<<(long _Val) { // insert a long - ios_base::iostate _State = ios_base::goodbit; - const sentry _Ok(*this); - - if (_Ok) { // state okay, use facet to insert - const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); - - _TRY_IO_BEGIN - if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Val).failed()) { - _State |= ios_base::badbit; - } - _CATCH_IO_END - } - - _Myios::setstate(_State); - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL operator<<(unsigned long _Val) { // insert an unsigned long - ios_base::iostate _State = ios_base::goodbit; - const sentry _Ok(*this); - - if (_Ok) { // state okay, use facet to insert - const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); - - _TRY_IO_BEGIN - if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Val).failed()) { - _State |= ios_base::badbit; - } - _CATCH_IO_END - } - - _Myios::setstate(_State); - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL operator<<(long long _Val) { // insert a long long - ios_base::iostate _State = ios_base::goodbit; - const sentry _Ok(*this); - - if (_Ok) { // state okay, use facet to insert - const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); - - _TRY_IO_BEGIN - if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Val).failed()) { - _State |= ios_base::badbit; - } - _CATCH_IO_END - } - - _Myios::setstate(_State); - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL operator<<(unsigned long long _Val) { // insert an unsigned long long - ios_base::iostate _State = ios_base::goodbit; - const sentry _Ok(*this); - - if (_Ok) { // state okay, use facet to insert - const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); - - _TRY_IO_BEGIN - if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Val).failed()) { - _State |= ios_base::badbit; - } - _CATCH_IO_END - } - - _Myios::setstate(_State); - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL operator<<(float _Val) { // insert a float - ios_base::iostate _State = ios_base::goodbit; - const sentry _Ok(*this); - - if (_Ok) { // state okay, use facet to insert - const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); - - _TRY_IO_BEGIN - if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), static_cast(_Val)).failed()) { - _State |= ios_base::badbit; - } - _CATCH_IO_END - } - - _Myios::setstate(_State); - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL operator<<(double _Val) { // insert a double - ios_base::iostate _State = ios_base::goodbit; - const sentry _Ok(*this); - - if (_Ok) { // state okay, use facet to insert - const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); - - _TRY_IO_BEGIN - if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Val).failed()) { - _State |= ios_base::badbit; - } - _CATCH_IO_END - } - - _Myios::setstate(_State); - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL operator<<(long double _Val) { // insert a long double - ios_base::iostate _State = ios_base::goodbit; - const sentry _Ok(*this); - - if (_Ok) { // state okay, use facet to insert - const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); - - _TRY_IO_BEGIN - if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Val).failed()) { - _State |= ios_base::badbit; - } - _CATCH_IO_END - } - - _Myios::setstate(_State); - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL operator<<(const void* _Val) { // insert a void pointer - ios_base::iostate _State = ios_base::goodbit; - const sentry _Ok(*this); - - if (_Ok) { // state okay, use facet to insert - const _Nput& _Nput_fac = _STD use_facet<_Nput>(this->getloc()); - - _TRY_IO_BEGIN - if (_Nput_fac.put(_Iter(_Myios::rdbuf()), *this, _Myios::fill(), _Val).failed()) { - _State |= ios_base::badbit; - } - _CATCH_IO_END - } - - _Myios::setstate(_State); - return *this; - } - -#if _HAS_CXX23 - template // TRANSITION, ABI - basic_ostream& operator<<(const volatile void* _Val) { - return *this << const_cast(_Val); - } -#endif // _HAS_CXX23 - -#if _HAS_CXX17 - template // TRANSITION, ABI - basic_ostream& operator<<(nullptr_t) { // insert a null pointer - return *this << "nullptr"; - } -#endif // _HAS_CXX17 - - basic_ostream& __CLR_OR_THIS_CALL operator<<(_Mysb* _Strbuf) { // insert until end-of-file from a stream buffer - ios_base::iostate _State = ios_base::goodbit; - bool _Copied = false; - const sentry _Ok(*this); - - if (_Ok && _Strbuf) { - for (int_type _Meta = _Traits::eof();; _Copied = true) { // extract another character from stream buffer - _TRY_BEGIN - _Meta = _Traits::eq_int_type(_Traits::eof(), _Meta) ? _Strbuf->sgetc() : _Strbuf->snextc(); - _CATCH_ALL - // N4971 [ostream.inserters]/9: "If an exception was thrown - // while extracting a character, the function sets failbit in the error state, - // and if failbit is set in exceptions() the caught exception is rethrown." - _Myios::setstate(ios_base::failbit, _Myios::exceptions() == ios_base::failbit); - _CATCH_END - - if (_Traits::eq_int_type(_Traits::eof(), _Meta)) { - break; // end of file, quit - } - - _TRY_IO_BEGIN - if (_Traits::eq_int_type(_Traits::eof(), _Myios::rdbuf()->sputc(_Traits::to_char_type(_Meta)))) { - _State |= ios_base::badbit; // insertion failed, quit - break; - } - _CATCH_IO_END - } - } - - this->width(0); - int _Setstate_with; - if (_Strbuf) { - if (_Copied) { - _Setstate_with = _State; - } else { - _Setstate_with = _State | ios_base::failbit; - } - } else { - _Setstate_with = ios_base::badbit; - } - - _Myios::setstate(_Setstate_with); - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL put(_Elem _Ch) { // insert a character - ios_base::iostate _State = ios_base::goodbit; - const sentry _Ok(*this); - - if (!_Ok) { - _State |= ios_base::badbit; - } else { // state okay, insert character - _TRY_IO_BEGIN - if (_Traits::eq_int_type(_Traits::eof(), _Myios::rdbuf()->sputc(_Ch))) { - _State |= ios_base::badbit; - } - _CATCH_IO_END - } - - _Myios::setstate(_State); - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL write(const _Elem* _Str, streamsize _Count) { - // insert _Count characters from array _Str - ios_base::iostate _State = ios_base::goodbit; - const sentry _Ok(*this); - - if (!_Ok) { - _State |= ios_base::badbit; - } else if (0 < _Count) { // state okay, insert characters - _TRY_IO_BEGIN - if (_Myios::rdbuf()->sputn(_Str, _Count) != _Count) { - _State |= ios_base::badbit; - } - _CATCH_IO_END - } - - _Myios::setstate(_State); - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL flush() { // flush output stream - const auto _Rdbuf = _Myios::rdbuf(); - if (_Rdbuf) { // buffer exists, flush it - const sentry _Ok(*this); - - if (_Ok) { - ios_base::iostate _State = ios_base::goodbit; - _TRY_IO_BEGIN - if (_Rdbuf->pubsync() == -1) { - _State |= ios_base::badbit; // sync failed - } - _CATCH_IO_END - _Myios::setstate(_State); - } - } - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL seekp(pos_type _Pos) { // set output stream position to _Pos - const sentry _Ok(*this); - - if (!this->fail()) { - ios_base::iostate _State = ios_base::goodbit; - _TRY_IO_BEGIN - if (static_cast(_Myios::rdbuf()->pubseekpos(_Pos, ios_base::out)) == -1) { - _State |= ios_base::failbit; // seek failed - } - _CATCH_IO_END - _Myios::setstate(_State); - } - - return *this; - } - - basic_ostream& __CLR_OR_THIS_CALL seekp(off_type _Off, ios_base::seekdir _Way) { - // change output stream position by _Off, according to _Way - const sentry _Ok(*this); - - if (!this->fail()) { - ios_base::iostate _State = ios_base::goodbit; - _TRY_IO_BEGIN - if (static_cast(_Myios::rdbuf()->pubseekoff(_Off, _Way, ios_base::out)) == -1) { - _State |= ios_base::failbit; // seek failed - } - _CATCH_IO_END - _Myios::setstate(_State); - } - - return *this; - } - - pos_type __CLR_OR_THIS_CALL tellp() { - const sentry _Ok(*this); - - if (!this->fail()) { - _TRY_IO_BEGIN - return _Myios::rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out); - _CATCH_IO_END - } - - return pos_type{off_type{-1}}; - } -}; - -#pragma vtordisp(pop) // compiler bug workaround - -#ifndef _NATIVE_WCHAR_T_DEFINED -// NOTE: -// If you are not using native wchar_t, the following explicit -// specialization will mask the member function (above) that treats -// an unsigned short as an integer. - -// To read or write unsigned shorts as integers with wchar_t streams, -// make wchar_t a native type with the command line option /Zc:wchar_t. - -template <> -inline basic_ostream>& __CLR_OR_THIS_CALL basic_ostream>::operator<<(unsigned short _Ch) { // extract a character - using _Traits = char_traits; - - ios_base::iostate _State = ios_base::goodbit; - const sentry _Ok(*this); - - if (_Ok) { // state okay, insert - streamsize _Pad = this->width() <= 1 ? 0 : this->width() - 1; - - _TRY_IO_BEGIN - if ((this->flags() & ios_base::adjustfield) != ios_base::left) { - for (; _State == ios_base::goodbit && 0 < _Pad; --_Pad) { // pad on left - if (_Traits::eq_int_type(_Traits::eof(), this->rdbuf()->sputc(this->fill()))) { - _State |= ios_base::badbit; - } - } - } - - if (_State == ios_base::goodbit && _Traits::eq_int_type(_Traits::eof(), this->rdbuf()->sputc(_Ch))) { - _State |= ios_base::badbit; - } - - for (; _State == ios_base::goodbit && 0 < _Pad; --_Pad) { // pad on right - if (_Traits::eq_int_type(_Traits::eof(), this->rdbuf()->sputc(this->fill()))) { - _State |= ios_base::badbit; - } - } - _CATCH_IO_END - } - - this->width(0); - _Myios::setstate(_State); - return *this; -} -#endif // _NATIVE_WCHAR_T_DEFINED - -#if defined(_DLL_CPPLIB) - -#if !defined(_CRTBLD) || defined(__FORCE_INSTANCE) -template class _CRTIMP2_PURE_IMPORT basic_ostream>; -template class _CRTIMP2_PURE_IMPORT basic_ostream>; -#endif // !defined(_CRTBLD) || defined(__FORCE_INSTANCE) - -#ifdef __FORCE_INSTANCE -template class _CRTIMP2_PURE_IMPORT basic_ostream>; -#endif // defined(__FORCE_INSTANCE) -#endif // defined(_DLL_CPPLIB) - -_EXPORT_STD template -basic_ostream<_Elem, _Traits>& operator<<(basic_ostream<_Elem, _Traits>& _Ostr, const char* _Val) { // insert NTBS - ios_base::iostate _State = ios_base::goodbit; - streamsize _Count = static_cast(_CSTD strlen(_Val)); - streamsize _Pad = _Ostr.width() <= 0 || _Ostr.width() <= _Count ? 0 : _Ostr.width() - _Count; - const typename basic_ostream<_Elem, _Traits>::sentry _Ok(_Ostr); - - if (!_Ok) { - _State |= ios_base::badbit; - } else { // state okay, insert characters - _TRY_IO_BEGIN - const ctype<_Elem>& _Ctype_fac = _STD use_facet>(_Ostr.getloc()); - if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left) { - for (; 0 < _Pad; --_Pad) { // pad on left - if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { - _State |= ios_base::badbit; // insertion failed, quit - break; - } - } - } - - for (; _State == ios_base::goodbit && 0 < _Count; --_Count, ++_Val) { - if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ctype_fac.widen(*_Val)))) { - _State |= ios_base::badbit; - } - } - - if (_State == ios_base::goodbit) { - for (; 0 < _Pad; --_Pad) { // pad on right - if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { - _State |= ios_base::badbit; // insertion failed, quit - break; - } - } - } - - _Ostr.width(0); - _CATCH_IO_(ios_base, _Ostr) - } - - _Ostr.setstate(_State); - return _Ostr; -} - -_EXPORT_STD template -basic_ostream<_Elem, _Traits>& operator<<(basic_ostream<_Elem, _Traits>& _Ostr, char _Ch) { // insert a character - ios_base::iostate _State = ios_base::goodbit; - const typename basic_ostream<_Elem, _Traits>::sentry _Ok(_Ostr); - - if (_Ok) { // state okay, insert - const ctype<_Elem>& _Ctype_fac = _STD use_facet>(_Ostr.getloc()); - streamsize _Pad = _Ostr.width() <= 1 ? 0 : _Ostr.width() - 1; - - _TRY_IO_BEGIN - if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left) { - for (; _State == ios_base::goodbit && 0 < _Pad; --_Pad) { // pad on left - if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { - _State |= ios_base::badbit; - } - } - } - - if (_State == ios_base::goodbit - && _Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ctype_fac.widen(_Ch)))) { - _State |= ios_base::badbit; - } - - for (; _State == ios_base::goodbit && 0 < _Pad; --_Pad) { // pad on right - if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { - _State |= ios_base::badbit; - } - } - _CATCH_IO_(ios_base, _Ostr) - } - - _Ostr.width(0); - _Ostr.setstate(_State); - return _Ostr; -} - -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream& _Ostr, const char* _Val) { - // insert NTBS into char stream - using _Elem = char; - using _Myos = basic_ostream<_Elem, _Traits>; - - ios_base::iostate _State = ios_base::goodbit; - streamsize _Count = static_cast(_Traits::length(_Val)); - streamsize _Pad = _Ostr.width() <= 0 || _Ostr.width() <= _Count ? 0 : _Ostr.width() - _Count; - const typename _Myos::sentry _Ok(_Ostr); - - if (!_Ok) { - _State |= ios_base::badbit; - } else { // state okay, insert - _TRY_IO_BEGIN - if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left) { - for (; 0 < _Pad; --_Pad) { // pad on left - if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { - _State |= ios_base::badbit; // insertion failed, quit - break; - } - } - } - - if (_State == ios_base::goodbit && _Ostr.rdbuf()->sputn(_Val, _Count) != _Count) { - _State |= ios_base::badbit; - } - - if (_State == ios_base::goodbit) { - for (; 0 < _Pad; --_Pad) { // pad on right - if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { - _State |= ios_base::badbit; // insertion failed, quit - break; - } - } - } - - _Ostr.width(0); - _CATCH_IO_(ios_base, _Ostr) - } - - _Ostr.setstate(_State); - return _Ostr; -} - -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream& _Ostr, char _Ch) { - // insert a char into char stream - using _Elem = char; - using _Myos = basic_ostream<_Elem, _Traits>; - - ios_base::iostate _State = ios_base::goodbit; - const typename _Myos::sentry _Ok(_Ostr); - - if (_Ok) { // state okay, insert - streamsize _Pad = _Ostr.width() <= 1 ? 0 : _Ostr.width() - 1; - - _TRY_IO_BEGIN - if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left) { - for (; _State == ios_base::goodbit && 0 < _Pad; --_Pad) { // pad on left - if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { - _State |= ios_base::badbit; - } - } - } - - if (_State == ios_base::goodbit && _Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ch))) { - _State |= ios_base::badbit; - } - - for (; _State == ios_base::goodbit && 0 < _Pad; --_Pad) { // pad on right - if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { - _State |= ios_base::badbit; - } - } - _CATCH_IO_(ios_base, _Ostr) - } - - _Ostr.width(0); - _Ostr.setstate(_State); - return _Ostr; -} - -_EXPORT_STD template -basic_ostream<_Elem, _Traits>& operator<<(basic_ostream<_Elem, _Traits>& _Ostr, const _Elem* _Val) { // insert NTCS - using _Myos = basic_ostream<_Elem, _Traits>; - - ios_base::iostate _State = ios_base::goodbit; - streamsize _Count = static_cast(_Traits::length(_Val)); - streamsize _Pad = _Ostr.width() <= 0 || _Ostr.width() <= _Count ? 0 : _Ostr.width() - _Count; - const typename _Myos::sentry _Ok(_Ostr); - - if (!_Ok) { - _State |= ios_base::badbit; - } else { // state okay, insert - _TRY_IO_BEGIN - if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left) { - for (; 0 < _Pad; --_Pad) { // pad on left - if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { - _State |= ios_base::badbit; // insertion failed, quit - break; - } - } - } - - if (_State == ios_base::goodbit && _Ostr.rdbuf()->sputn(_Val, _Count) != _Count) { - _State |= ios_base::badbit; - } - - if (_State == ios_base::goodbit) { - for (; 0 < _Pad; --_Pad) { // pad on right - if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { - _State |= ios_base::badbit; // insertion failed, quit - break; - } - } - } - - _Ostr.width(0); - _CATCH_IO_(ios_base, _Ostr) - } - - _Ostr.setstate(_State); - return _Ostr; -} - -_EXPORT_STD template -basic_ostream<_Elem, _Traits>& operator<<(basic_ostream<_Elem, _Traits>& _Ostr, _Elem _Ch) { // insert a character - using _Myos = basic_ostream<_Elem, _Traits>; - - ios_base::iostate _State = ios_base::goodbit; - const typename _Myos::sentry _Ok(_Ostr); - - if (_Ok) { // state okay, insert - streamsize _Pad = _Ostr.width() <= 1 ? 0 : _Ostr.width() - 1; - - _TRY_IO_BEGIN - if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left) { - for (; _State == ios_base::goodbit && 0 < _Pad; --_Pad) { // pad on left - if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { - _State |= ios_base::badbit; - } - } - } - - if (_State == ios_base::goodbit && _Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ch))) { - _State |= ios_base::badbit; - } - - for (; _State == ios_base::goodbit && 0 < _Pad; --_Pad) { // pad on right - if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { - _State |= ios_base::badbit; - } - } - _CATCH_IO_(ios_base, _Ostr) - } - - _Ostr.width(0); - _Ostr.setstate(_State); - return _Ostr; -} - -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream& _Ostr, const signed char* _Val) { - // insert a signed char NTBS - return _Ostr << reinterpret_cast(_Val); -} - -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream& _Ostr, signed char _Ch) { // insert a signed char - return _Ostr << static_cast(_Ch); -} - -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream& _Ostr, const unsigned char* _Val) { - // insert an unsigned char NTBS - return _Ostr << reinterpret_cast(_Val); -} - -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream& _Ostr, unsigned char _Ch) { - // insert an unsigned char - return _Ostr << static_cast(_Ch); -} - -#ifdef __cpp_char8_t // These deleted overloads are specified in P1423. -// don't insert a UTF-8 NTBS -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream&, const char8_t*) = delete; -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream&, const char8_t*) = delete; - -// don't insert a UTF-8 code unit -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream&, char8_t) = delete; -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream&, char8_t) = delete; -#endif // defined(__cpp_char8_t) - -#if !_HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20 -#ifdef _NATIVE_WCHAR_T_DEFINED -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream&, wchar_t) = delete; - -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream&, const wchar_t*) = delete; -#endif // _NATIVE_WCHAR_T_DEFINED - -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream&, char16_t) = delete; -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream&, char32_t) = delete; - -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream&, char16_t) = delete; -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream&, char32_t) = delete; - -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream&, const char16_t*) = delete; -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream&, const char32_t*) = delete; - -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream&, const char16_t*) = delete; -_EXPORT_STD template -basic_ostream& operator<<(basic_ostream&, const char32_t*) = delete; -#endif // !_HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20 - -template -struct _Can_stream_out : false_type {}; - -template -struct _Can_stream_out<_Ostr, _Ty, void_t() << _STD declval())>> : true_type { -}; - -_EXPORT_STD template , _Can_stream_out<_Ostr, _Ty>>, int> = 0> -_Ostr&& operator<<(_Ostr&& _Os, const _Ty& _Val) { // insert to rvalue stream - _Os << _Val; - return _STD move(_Os); -} - -_EXPORT_STD template -basic_ostream<_Elem, _Traits>& __CLRCALL_OR_CDECL endl( - basic_ostream<_Elem, _Traits>& _Ostr) { // insert newline and flush stream - _Ostr.put(_Ostr.widen('\n')); - _Ostr.flush(); - return _Ostr; -} - -_EXPORT_STD template -basic_ostream<_Elem, _Traits>& __CLRCALL_OR_CDECL ends(basic_ostream<_Elem, _Traits>& _Ostr) { // insert null character - _Ostr.put(_Elem()); - return _Ostr; -} - -_EXPORT_STD template -basic_ostream<_Elem, _Traits>& __CLRCALL_OR_CDECL flush(basic_ostream<_Elem, _Traits>& _Ostr) { // flush stream - _Ostr.flush(); - return _Ostr; -} - #if _HAS_CXX20 #ifdef _CPPRTTI _EXPORT_STD template @@ -1082,13 +72,7 @@ basic_ostream<_Elem, _Traits>& noemit_on_flush(basic_ostream<_Elem, _Traits>&) = _EXPORT_STD template basic_ostream<_Elem, _Traits>& flush_emit(basic_ostream<_Elem, _Traits>&) = delete; // requires /GR option #endif // ^^^ !defined(_CPPRTTI) ^^^ -#endif // _HAS_CXX20 - -_EXPORT_STD template -basic_ostream<_Elem, _Traits>& operator<<(basic_ostream<_Elem, _Traits>& _Ostr, const error_code& _Errcode) { - // display error code - return _Ostr << _Errcode.category().name() << ':' << _Errcode.value(); -} +#endif // ^^^ _HAS_CXX20 ^^^ #if _HAS_CXX23 #ifdef _CPPRTTI @@ -1296,7 +280,7 @@ void println(ostream&, format_string<_Types...>, _Types&&...) = delete; // requi _EXPORT_STD void vprint_unicode(ostream&, string_view, format_args) = delete; // requires /GR option _EXPORT_STD void vprint_nonunicode(ostream&, string_view, format_args) = delete; // requires /GR option #endif // ^^^ !defined(_CPPRTTI) ^^^ -#endif // _HAS_CXX23 +#endif // ^^^ _HAS_CXX23 ^^^ _STD_END diff --git a/stl/inc/print b/stl/inc/print index 13f12ea0467..6e6b15b9e83 100644 --- a/stl/inc/print +++ b/stl/inc/print @@ -24,15 +24,108 @@ _STL_DISABLE_CLANG_WARNINGS _STD_BEGIN -inline void _Print_noformat_nonunicode(FILE* const _Stream, const string_view _Str) { - const bool _Was_write_successful = _CSTD fwrite(_Str.data(), 1, _Str.size(), _Stream) == _Str.size(); +struct _NODISCARD _Stream_lock_guard { + explicit _Stream_lock_guard(FILE* const _Stream_) : _Stream(_Stream_) { + _CSTD _lock_file(_Stream); + } + ~_Stream_lock_guard() { + _CSTD _unlock_file(_Stream); + } + + _Stream_lock_guard(const _Stream_lock_guard&) = delete; + _Stream_lock_guard& operator=(const _Stream_lock_guard&) = delete; + + FILE* const _Stream; +}; + +class _Print_to_stream_it { +public: + using iterator_category = output_iterator_tag; + using value_type = void; + using difference_type = ptrdiff_t; + using pointer = void; + using reference = void; + + explicit _Print_to_stream_it(FILE* const _Stream_) noexcept : _Stream(_Stream_) {} + + _Print_to_stream_it& operator=(char); // These members are intentionally not defined + _Print_to_stream_it& operator*(); + _Print_to_stream_it& operator++(); + _Print_to_stream_it operator++(int); + + FILE* _Get_stream() const noexcept { + return _Stream; + } + +private: + FILE* _Stream; +}; + +inline void _Print_noformat_nonunicode_nonlocking(FILE* const _Stream, const string_view _Str) { + const bool _Was_write_successful = _CSTD _fwrite_nolock(_Str.data(), 1, _Str.size(), _Stream) == _Str.size(); if (!_Was_write_successful) [[unlikely]] { _Throw_system_error(static_cast(errno)); } } -inline void _Vprint_nonunicode_impl( +template <> +struct _Fmt_iterator_flush<_Print_to_stream_it> { + static _Print_to_stream_it _Flush(const char* const _First, const char* const _Last, _Print_to_stream_it _Output) { + _STD _Print_noformat_nonunicode_nonlocking(_Output._Get_stream(), {_First, _Last}); + return _Output; + } +}; + +class _Print_to_unicode_console_it { +public: + using iterator_category = output_iterator_tag; + using value_type = void; + using difference_type = ptrdiff_t; + using pointer = void; + using reference = void; + + explicit _Print_to_unicode_console_it(const __std_unicode_console_handle _Console_handle_) noexcept + : _Console_handle(_Console_handle_) {} + + _Print_to_unicode_console_it& operator=(char); // These members are intentionally not defined + _Print_to_unicode_console_it& operator*(); + _Print_to_unicode_console_it& operator++(); + _Print_to_unicode_console_it operator++(int); + + __std_unicode_console_handle _Get_console_handle() const noexcept { + return _Console_handle; + } + +private: + __std_unicode_console_handle _Console_handle; +}; + +inline void _Print_noformat_unicode_to_console_nonlocking( + const __std_unicode_console_handle _Console_handle, const string_view _Str) { + const __std_win_error _Console_print_result = + __std_print_to_unicode_console(_Console_handle, _Str.data(), _Str.size()); + if (_Console_print_result != __std_win_error::_Success) [[unlikely]] { + _STD _Throw_system_error_from_std_win_error(_Console_print_result); + } +} + +template <> +struct _Fmt_iterator_flush<_Print_to_unicode_console_it> { + static _Print_to_unicode_console_it _Flush( + const char* const _First, const char* const _Last, _Print_to_unicode_console_it _Output) { + _STD _Print_noformat_unicode_to_console_nonlocking(_Output._Get_console_handle(), {_First, _Last}); + return _Output; + } +}; + +inline void _Print_noformat_nonunicode(FILE* const _Stream, const string_view _Str) { + const _Stream_lock_guard _Guard{_Stream}; + _STD _Print_noformat_nonunicode_nonlocking(_Stream, _Str); +} + +// Format non unicode into a temporary string, then print to stream +inline void _Vprint_nonunicode_buffered_impl( const _Add_newline _Add_nl, FILE* const _Stream, const string_view _Fmt_str, const format_args _Fmt_args) { string _Output_str = _STD vformat(_Fmt_str, _Fmt_args); if (_Add_nl == _Add_newline::_Yes) { @@ -42,7 +135,19 @@ inline void _Vprint_nonunicode_impl( _STD _Print_noformat_nonunicode(_Stream, _Output_str); } -inline void _Print_noformat_unicode(FILE* const _Stream, const string_view _Str) { +// Format non unicode directly into _Stream +inline void _Vprint_nonunicode_impl( + const _Add_newline _Add_nl, FILE* const _Stream, const string_view _Fmt_str, const format_args _Fmt_args) { + const _Stream_lock_guard _Guard{_Stream}; + _STD vformat_to(_Print_to_stream_it{_Stream}, _Fmt_str, _Fmt_args); + if (_Add_nl == _Add_newline::_Yes) { + _Print_noformat_nonunicode_nonlocking(_Stream, "\n"); + } +} + +template +void _Do_on_maybe_unicode_console( + FILE* const _Stream, _UnicodeConsoleFn _Unicode_console_func, _FallbackFn _Fallback_func) { const __std_unicode_console_retrieval_result _Unicode_console_retrieval_result{ __std_get_unicode_console_handle_from_file_stream(_Stream)}; @@ -69,47 +174,86 @@ inline void _Print_noformat_unicode(FILE* const _Stream, const string_view _Str) #pragma warning(pop) if (_Is_unicode_console) { - const bool _Was_flush_successful = _CSTD fflush(_Stream) == 0; + _Unicode_console_func(_Unicode_console_retrieval_result._Console_handle); + } else { + _Fallback_func(); + } +} + +// If a unicode console, write using native API, else write to stream +inline void _Vprint_unicode_noformat_impl(FILE* const _Stream, const string_view _Output_str) { + const auto _Unicode_console = [&](const __std_unicode_console_handle _Console_handle) { + const _Stream_lock_guard _Guard{_Stream}; + + const bool _Was_flush_successful = _CSTD _fflush_nolock(_Stream) == 0; if (!_Was_flush_successful) [[unlikely]] { _Throw_system_error(static_cast(errno)); } - const __std_win_error _Console_print_result = - __std_print_to_unicode_console(_Unicode_console_retrieval_result._Console_handle, _Str.data(), _Str.size()); - if (_Console_print_result != __std_win_error::_Success) [[unlikely]] { - _STD _Throw_system_error_from_std_win_error(_Console_print_result); - } - } else { - _STD _Print_noformat_nonunicode(_Stream, _Str); - } + _STD _Print_noformat_unicode_to_console_nonlocking(_Console_handle, _Output_str); + }; + + const auto _Fallback = [&] { _STD _Print_noformat_nonunicode(_Stream, _Output_str); }; + + _STD _Do_on_maybe_unicode_console(_Stream, _Unicode_console, _Fallback); } -inline void _Vprint_unicode_impl( +// Format to intermediate string buffer, then print to unicode console/file +inline void _Vprint_unicode_buffered_impl( const _Add_newline _Add_nl, FILE* const _Stream, const string_view _Fmt_str, const format_args _Fmt_args) { string _Output_str = _STD vformat(_Fmt_str, _Fmt_args); if (_Add_nl == _Add_newline::_Yes) { _Output_str.push_back('\n'); } + _STD _Vprint_unicode_noformat_impl(_Stream, _Output_str); +} - _STD _Print_noformat_unicode(_Stream, _Output_str); +inline void _Vprint_unicode_impl( + const _Add_newline _Add_nl, FILE* const _Stream, const string_view _Fmt_str, const format_args _Fmt_args) { + const auto _Unicode_console = [&](const __std_unicode_console_handle _Console_handle) { + const _Stream_lock_guard _Guard{_Stream}; + + const bool _Was_flush_successful = _CSTD _fflush_nolock(_Stream) == 0; + if (!_Was_flush_successful) [[unlikely]] { + _Throw_system_error(static_cast(errno)); + } + + _STD vformat_to(_Print_to_unicode_console_it{_Console_handle}, _Fmt_str, _Fmt_args); + if (_Add_nl == _Add_newline::_Yes) { + _Print_noformat_unicode_to_console_nonlocking(_Console_handle, "\n"); + } + }; + + const auto _Fallback = [&] { _STD _Vprint_nonunicode_impl(_Add_nl, _Stream, _Fmt_str, _Fmt_args); }; + + _STD _Do_on_maybe_unicode_console(_Stream, _Unicode_console, _Fallback); } template void _Print_impl( const _Add_newline _Add_nl, FILE* const _Stream, const format_string<_Types...> _Fmt, _Types&&... _Args) { - constexpr bool _Has_format_args = sizeof...(_Types) > 0; + constexpr bool _Has_format_args = sizeof...(_Types) > 0; + constexpr bool _Print_nonlocking = (enable_nonlocking_formatter_optimization> && ...); if constexpr (_Has_format_args) { if constexpr (_STD _Is_ordinary_literal_encoding_utf8()) { - _STD _Vprint_unicode_impl(_Add_nl, _Stream, _Fmt.get(), _STD make_format_args(_Args...)); + if constexpr (_Print_nonlocking) { + _STD _Vprint_unicode_impl(_Add_nl, _Stream, _Fmt.get(), _STD make_format_args(_Args...)); + } else { + _STD _Vprint_unicode_buffered_impl(_Add_nl, _Stream, _Fmt.get(), _STD make_format_args(_Args...)); + } } else { - _STD _Vprint_nonunicode_impl(_Add_nl, _Stream, _Fmt.get(), _STD make_format_args(_Args...)); + if constexpr (_Print_nonlocking) { + _STD _Vprint_nonunicode_impl(_Add_nl, _Stream, _Fmt.get(), _STD make_format_args(_Args...)); + } else { + _STD _Vprint_nonunicode_buffered_impl(_Add_nl, _Stream, _Fmt.get(), _STD make_format_args(_Args...)); + } } } else { const string _Unescaped_str{_Unescape_braces(_Add_nl, _Fmt.get())}; if constexpr (_STD _Is_ordinary_literal_encoding_utf8()) { - _STD _Print_noformat_unicode(_Stream, _Unescaped_str); + _STD _Vprint_unicode_noformat_impl(_Stream, _Unescaped_str); } else { _STD _Print_noformat_nonunicode(_Stream, _Unescaped_str); } @@ -147,23 +291,33 @@ void println(const format_string<_Types...> _Fmt, _Types&&... _Args) { } _EXPORT_STD template // improves throughput, see GH-2329 -void vprint_unicode(FILE* const _Stream, const string_view _Fmt_str, const format_args _Fmt_args) { - _STD _Vprint_unicode_impl(_Add_newline::_Nope, _Stream, _Fmt_str, _Fmt_args); +void vprint_unicode_buffered(FILE* const _Stream, const string_view _Fmt_str, const format_args _Fmt_args) { + _STD _Vprint_unicode_buffered_impl(_Add_newline::_Nope, _Stream, _Fmt_str, _Fmt_args); } _EXPORT_STD template // improves throughput, see GH-2329 -void vprint_unicode(const string_view _Fmt_str, const format_args _Fmt_args) { - _STD vprint_unicode(stdout, _Fmt_str, _Fmt_args); +void vprint_unicode_buffered(const string_view _Fmt_str, const format_args _Fmt_args) { + _STD vprint_unicode_buffered(stdout, _Fmt_str, _Fmt_args); } _EXPORT_STD template // improves throughput, see GH-2329 -void vprint_nonunicode(FILE* const _Stream, const string_view _Fmt_str, const format_args _Fmt_args) { - _STD _Vprint_nonunicode_impl(_Add_newline::_Nope, _Stream, _Fmt_str, _Fmt_args); +void vprint_nonunicode_buffered(FILE* const _Stream, const string_view _Fmt_str, const format_args _Fmt_args) { + _STD _Vprint_nonunicode_buffered_impl(_Add_newline::_Nope, _Stream, _Fmt_str, _Fmt_args); +} + +_EXPORT_STD template // improves throughput, see GH-2329 +void vprint_nonunicode_buffered(const string_view _Fmt_str, const format_args _Fmt_args) { + _STD vprint_nonunicode_buffered(stdout, _Fmt_str, _Fmt_args); +} + +_EXPORT_STD template // improves throughput, see GH-2329 +void vprint_unicode(FILE* const _Stream, const string_view _Fmt_str, const format_args _Fmt_args) { + _STD _Vprint_unicode_impl(_Add_newline::_Nope, _Stream, _Fmt_str, _Fmt_args); } _EXPORT_STD template // improves throughput, see GH-2329 -void vprint_nonunicode(const string_view _Fmt_str, const format_args _Fmt_args) { - _STD vprint_nonunicode(stdout, _Fmt_str, _Fmt_args); +void vprint_nonunicode(FILE* const _Stream, const string_view _Fmt_str, const format_args _Fmt_args) { + _STD _Vprint_nonunicode_impl(_Add_newline::_Nope, _Stream, _Fmt_str, _Fmt_args); } _STD_END diff --git a/stl/inc/queue b/stl/inc/queue index 832ed8fbc33..2d8b6bd0df1 100644 --- a/stl/inc/queue +++ b/stl/inc/queue @@ -67,23 +67,23 @@ public: queue(const _Container& _Cont, const _Alloc& _Al) : c(_Cont, _Al) {} template , int> = 0> - queue(_Container&& _Cont, const _Alloc& _Al) noexcept( - is_nothrow_constructible_v<_Container, _Container, const _Alloc&>) // strengthened + queue(_Container&& _Cont, const _Alloc& _Al) + noexcept(is_nothrow_constructible_v<_Container, _Container, const _Alloc&>) // strengthened : c(_STD move(_Cont), _Al) {} template , int> = 0> queue(const queue& _Right, const _Alloc& _Al) : c(_Right.c, _Al) {} template , int> = 0> - queue(queue&& _Right, const _Alloc& _Al) noexcept( - is_nothrow_constructible_v<_Container, _Container, const _Alloc&>) // strengthened + queue(queue&& _Right, const _Alloc& _Al) + noexcept(is_nothrow_constructible_v<_Container, _Container, const _Alloc&>) // strengthened : c(_STD move(_Right.c), _Al) {} #if _HAS_CXX23 template <_Iterator_for_container _InIt, class _Alloc> requires uses_allocator_v<_Container, _Alloc> - queue(_InIt _First, _InIt _Last, const _Alloc& _Al) noexcept( - is_nothrow_constructible_v<_Container, _InIt, _InIt, const _Alloc&>) // strengthened + queue(_InIt _First, _InIt _Last, const _Alloc& _Al) + noexcept(is_nothrow_constructible_v<_Container, _InIt, _InIt, const _Alloc&>) // strengthened : c(_STD move(_First), _STD move(_Last), _Al) {} template <_Container_compatible_range<_Ty> _Rng, class _Alloc> @@ -174,8 +174,8 @@ template <_Iterator_for_container _InIt, _Allocator_for_container _Alloc = alloc queue(_InIt, _InIt, _Alloc = _Alloc()) -> queue<_Iter_value_t<_InIt>, deque<_Iter_value_t<_InIt>, _Alloc>>; template <_RANGES input_range _Rng, _Allocator_for_container _Alloc = allocator<_RANGES range_value_t<_Rng>>> -queue(from_range_t, _Rng&&, _Alloc = _Alloc()) - -> queue<_RANGES range_value_t<_Rng>, deque<_RANGES range_value_t<_Rng>, _Alloc>>; +queue(from_range_t, _Rng&&, + _Alloc = _Alloc()) -> queue<_RANGES range_value_t<_Rng>, deque<_RANGES range_value_t<_Rng>, _Alloc>>; #endif // _HAS_CXX23 _EXPORT_STD template @@ -248,9 +248,9 @@ public: priority_queue() = default; - explicit priority_queue(const _Pr& _Pred) noexcept( - is_nothrow_default_constructible_v<_Container> - && is_nothrow_copy_constructible_v) // strengthened + explicit priority_queue(const _Pr& _Pred) + noexcept(is_nothrow_default_constructible_v<_Container> + && is_nothrow_copy_constructible_v) // strengthened : c(), comp(_Pred) {} priority_queue(const _Pr& _Pred, const _Container& _Cont) : c(_Cont), comp(_Pred) { @@ -292,15 +292,15 @@ public: #endif // _HAS_CXX23 template , int> = 0> - explicit priority_queue(const _Alloc& _Al) noexcept( - is_nothrow_constructible_v<_Container, const _Alloc&> - && is_nothrow_default_constructible_v) // strengthened + explicit priority_queue(const _Alloc& _Al) + noexcept(is_nothrow_constructible_v<_Container, const _Alloc&> + && is_nothrow_default_constructible_v) // strengthened : c(_Al), comp() {} template , int> = 0> - priority_queue(const _Pr& _Pred, const _Alloc& _Al) noexcept( - is_nothrow_constructible_v<_Container, const _Alloc&> - && is_nothrow_copy_constructible_v) // strengthened + priority_queue(const _Pr& _Pred, const _Alloc& _Al) + noexcept(is_nothrow_constructible_v<_Container, const _Alloc&> + && is_nothrow_copy_constructible_v) // strengthened : c(_Al), comp(_Pred) {} template , int> = 0> @@ -317,9 +317,9 @@ public: priority_queue(const priority_queue& _Right, const _Alloc& _Al) : c(_Right.c, _Al), comp(_Right.comp) {} template , int> = 0> - priority_queue(priority_queue&& _Right, const _Alloc& _Al) noexcept( - is_nothrow_constructible_v<_Container, _Container, const _Alloc&> - && is_nothrow_move_constructible_v) // strengthened + priority_queue(priority_queue&& _Right, const _Alloc& _Al) + noexcept(is_nothrow_constructible_v<_Container, _Container, const _Alloc&> + && is_nothrow_move_constructible_v) // strengthened : c(_STD move(_Right.c), _Al), comp(_STD move(_Right.comp)) {} template ::value && _Is_nothrow_swappable<_Pr>::value) { + void swap(priority_queue& _Right) + noexcept(_Is_nothrow_swappable<_Container>::value && _Is_nothrow_swappable<_Pr>::value) { using _STD swap; swap(c, _Right.c); // intentional ADL swap(comp, _Right.comp); // intentional ADL @@ -450,8 +450,8 @@ priority_queue(_Pr, _Container) -> priority_queue>, class _Container = vector<_Iter_value_t<_Iter>>, enable_if_t, negation<_Is_allocator<_Pr>>, negation<_Is_allocator<_Container>>>, int> = 0> -priority_queue(_Iter, _Iter, _Pr = _Pr(), _Container = _Container()) - -> priority_queue<_Iter_value_t<_Iter>, _Container, _Pr>; +priority_queue( + _Iter, _Iter, _Pr = _Pr(), _Container = _Container()) -> priority_queue<_Iter_value_t<_Iter>, _Container, _Pr>; template >, negation<_Is_allocator<_Container>>, @@ -469,30 +469,30 @@ priority_queue(_Iter, _Iter, _Compare, _Alloc) -> priority_queue<_Iter_value_t<_ template , uses_allocator<_Container, _Alloc>>, int> = 0> -priority_queue(_Iter, _Iter, _Compare, _Container, _Alloc) - -> priority_queue; +priority_queue(_Iter, _Iter, _Compare, _Container, + _Alloc) -> priority_queue; #if _HAS_CXX23 template <_RANGES input_range _Rng, class _Pr = less<_RANGES range_value_t<_Rng>>, enable_if_t::value, int> = 0> -priority_queue(from_range_t, _Rng&&, _Pr = _Pr()) - -> priority_queue<_RANGES range_value_t<_Rng>, vector<_RANGES range_value_t<_Rng>>, _Pr>; +priority_queue(from_range_t, _Rng&&, + _Pr = _Pr()) -> priority_queue<_RANGES range_value_t<_Rng>, vector<_RANGES range_value_t<_Rng>>, _Pr>; template <_RANGES input_range _Rng, class _Pr, class _Alloc, enable_if_t>, _Is_allocator<_Alloc>>, int> = 0> -priority_queue(from_range_t, _Rng&&, _Pr, _Alloc) - -> priority_queue<_RANGES range_value_t<_Rng>, vector<_RANGES range_value_t<_Rng>, _Alloc>, _Pr>; +priority_queue(from_range_t, _Rng&&, _Pr, + _Alloc) -> priority_queue<_RANGES range_value_t<_Rng>, vector<_RANGES range_value_t<_Rng>, _Alloc>, _Pr>; template <_RANGES input_range _Rng, class _Alloc, enable_if_t<_Is_allocator<_Alloc>::value, int> = 0> -priority_queue(from_range_t, _Rng&&, _Alloc) - -> priority_queue<_RANGES range_value_t<_Rng>, vector<_RANGES range_value_t<_Rng>, _Alloc>>; +priority_queue(from_range_t, _Rng&&, + _Alloc) -> priority_queue<_RANGES range_value_t<_Rng>, vector<_RANGES range_value_t<_Rng>, _Alloc>>; #endif // _HAS_CXX23 #endif // _HAS_CXX17 _EXPORT_STD template ::value && _Is_swappable<_Pr>::value, int> = 0> -void swap(priority_queue<_Ty, _Container, _Pr>& _Left, priority_queue<_Ty, _Container, _Pr>& _Right) noexcept( - noexcept(_Left.swap(_Right))) { +void swap(priority_queue<_Ty, _Container, _Pr>& _Left, priority_queue<_Ty, _Container, _Pr>& _Right) + noexcept(noexcept(_Left.swap(_Right))) { _Left.swap(_Right); } diff --git a/stl/inc/ranges b/stl/inc/ranges index db45abf8e13..bb5eca79ce3 100644 --- a/stl/inc/ranges +++ b/stl/inc/ranges @@ -84,12 +84,9 @@ namespace ranges { constexpr auto _Compile_time_max_size> = _Extent; #endif // _HAS_CXX23 - // clang-format off template - concept _Simple_view = view<_Rng> && range - && same_as, iterator_t> - && same_as, sentinel_t>; - // clang-format on + concept _Simple_view = view<_Rng> && range && same_as, iterator_t> + && same_as, sentinel_t>; template concept _Has_arrow = input_iterator<_It> && (is_pointer_v<_It> || _Has_member_arrow<_It&>); @@ -183,8 +180,8 @@ namespace ranges { return _RANGES begin(_Range) + _Off; } - constexpr void _Set_cache(_Rng& _Range, const _It& _Iter) noexcept( - noexcept(_Off = _Iter - _RANGES begin(_Range))) { + constexpr void _Set_cache(_Rng& _Range, const _It& _Iter) + noexcept(noexcept(_Off = _Iter - _RANGES begin(_Range))) { _Off = _Iter - _RANGES begin(_Range); } }; @@ -203,12 +200,13 @@ namespace ranges { } } - // clang-format off - ~_Defaultabox() requires is_trivially_destructible_v<_Ty> = default; + ~_Defaultabox() + requires is_trivially_destructible_v<_Ty> + = default; _Defaultabox(const _Defaultabox&) - requires copy_constructible<_Ty> && is_trivially_copy_constructible_v<_Ty> = default; - // clang-format on + requires copy_constructible<_Ty> && is_trivially_copy_constructible_v<_Ty> + = default; constexpr _Defaultabox(const _Defaultabox& _That) noexcept(is_nothrow_copy_constructible_v<_Ty>) requires copy_constructible<_Ty> @@ -218,9 +216,9 @@ namespace ranges { } } - // clang-format off - _Defaultabox(_Defaultabox&&) requires is_trivially_move_constructible_v<_Ty> = default; - // clang-format on + _Defaultabox(_Defaultabox&&) + requires is_trivially_move_constructible_v<_Ty> + = default; constexpr _Defaultabox(_Defaultabox&& _That) noexcept(is_nothrow_move_constructible_v<_Ty>) : _Engaged{_That._Engaged} { @@ -247,13 +245,12 @@ namespace ranges { } } - // clang-format off _Defaultabox& operator=(const _Defaultabox&) noexcept - requires copyable<_Ty> && is_trivially_copy_assignable_v<_Ty> = default; - // clang-format on + requires copyable<_Ty> && is_trivially_copy_assignable_v<_Ty> + = default; - constexpr _Defaultabox& operator=(const _Defaultabox& _That) noexcept( - is_nothrow_copy_constructible_v<_Ty> && is_nothrow_copy_assignable_v<_Ty>) + constexpr _Defaultabox& operator=(const _Defaultabox& _That) + noexcept(is_nothrow_copy_constructible_v<_Ty> && is_nothrow_copy_assignable_v<_Ty>) requires copyable<_Ty> { if (_Engaged) { @@ -275,12 +272,12 @@ namespace ranges { return *this; } - // clang-format off - _Defaultabox& operator=(_Defaultabox&&) noexcept requires is_trivially_move_assignable_v<_Ty> = default; - // clang-format on + _Defaultabox& operator=(_Defaultabox&&) noexcept + requires is_trivially_move_assignable_v<_Ty> + = default; - constexpr _Defaultabox& operator=(_Defaultabox&& _That) noexcept( - is_nothrow_move_constructible_v<_Ty> && is_nothrow_move_assignable_v<_Ty>) { + constexpr _Defaultabox& operator=(_Defaultabox&& _That) + noexcept(is_nothrow_move_constructible_v<_Ty> && is_nothrow_move_assignable_v<_Ty>) { if (_Engaged) { if (_That._Engaged) { static_cast<_Ty&>(_Val) = static_cast<_Ty&&>(_That._Val); @@ -300,8 +297,8 @@ namespace ranges { return *this; } - constexpr _Defaultabox& operator=(_Ty&& _That) noexcept( - is_nothrow_move_constructible_v<_Ty> && is_nothrow_move_assignable_v<_Ty>) { + constexpr _Defaultabox& operator=(_Ty&& _That) + noexcept(is_nothrow_move_constructible_v<_Ty> && is_nothrow_move_assignable_v<_Ty>) { if (_Engaged) { static_cast<_Ty&>(_Val) = _STD move(_That); } else { @@ -312,8 +309,8 @@ namespace ranges { return *this; } - constexpr _Defaultabox& operator=(const _Ty& _That) noexcept( - is_nothrow_copy_constructible_v<_Ty> && is_nothrow_copy_assignable_v<_Ty>) + constexpr _Defaultabox& operator=(const _Ty& _That) + noexcept(is_nothrow_copy_constructible_v<_Ty> && is_nothrow_copy_assignable_v<_Ty>) requires copyable<_Ty> { if (_Engaged) { @@ -368,8 +365,8 @@ namespace ranges { template <_Different_from<_Ty> _Uty> requires convertible_to - constexpr _Defaultabox(const _Defaultabox<_Uty>& _That) noexcept(is_nothrow_default_constructible_v<_Ty> // - && noexcept(_Value = static_cast<_Ty>(*_That))) { + constexpr _Defaultabox(const _Defaultabox<_Uty>& _That) + noexcept(is_nothrow_default_constructible_v<_Ty> && noexcept(_Value = static_cast<_Ty>(*_That))) { if (_That) { _Value = static_cast<_Ty>(*_That); } @@ -377,8 +374,8 @@ namespace ranges { template <_Different_from<_Ty> _Uty> requires convertible_to<_Uty, _Ty> - constexpr _Defaultabox(_Defaultabox<_Uty>&& _That) noexcept(is_nothrow_default_constructible_v<_Ty> // - && noexcept(_Value = static_cast<_Ty>(_STD move(*_That)))) { + constexpr _Defaultabox(_Defaultabox<_Uty>&& _That) noexcept( + is_nothrow_default_constructible_v<_Ty> && noexcept(_Value = static_cast<_Ty>(_STD move(*_That)))) { if (_That) { _Value = static_cast<_Ty>(_STD move(*_That)); } @@ -427,9 +424,9 @@ namespace ranges { } } - // clang-format off - ~_Non_propagating_cache() requires is_trivially_destructible_v<_Ty> = default; - // clang-format on + ~_Non_propagating_cache() + requires is_trivially_destructible_v<_Ty> + = default; constexpr _Non_propagating_cache(const _Non_propagating_cache&) noexcept {} @@ -584,9 +581,9 @@ namespace ranges { _EXPORT_STD template <_Valid_movable_box_object _Ty> class single_view : public view_interface> { public: - // clang-format off - single_view() requires default_initializable<_Ty> = default; - // clang-format on + single_view() + requires default_initializable<_Ty> + = default; constexpr explicit single_view(const _Ty& _Val_) noexcept(is_nothrow_copy_constructible_v<_Ty>) // strengthened requires copy_constructible<_Ty> @@ -596,8 +593,8 @@ namespace ranges { template requires constructible_from<_Ty, _Types...> - constexpr explicit single_view(in_place_t, _Types&&... _Args) noexcept( - is_nothrow_constructible_v<_Ty, _Types...>) // strengthened + constexpr explicit single_view(in_place_t, _Types&&... _Args) + noexcept(is_nothrow_constructible_v<_Ty, _Types...>) // strengthened : _Val{in_place, _STD forward<_Types>(_Args)...} {} _NODISCARD constexpr _Ty* begin() noexcept { @@ -696,9 +693,9 @@ namespace ranges { using value_type = _Wi; using difference_type = _Iota_diff_t<_Wi>; - // clang-format off - _Ioterator() requires default_initializable<_Wi> = default; - // clang-format on + _Ioterator() + requires default_initializable<_Wi> + = default; constexpr explicit _Ioterator(_Wi _Val) noexcept(is_nothrow_move_constructible_v<_Wi>) /* strengthened */ : _Current(_STD move(_Val)) {} @@ -731,7 +728,7 @@ namespace ranges { } constexpr _Ioterator operator--(int) noexcept(is_nothrow_copy_constructible_v<_Wi> // - && noexcept(--_Current)) /* strengthened */ + && noexcept(--_Current)) /* strengthened */ requires _Decrementable<_Wi> { auto _Tmp = *this; @@ -813,72 +810,69 @@ namespace ranges { } } - _NODISCARD friend constexpr bool operator==(const _Ioterator& _Left, const _Ioterator& _Right) noexcept( - noexcept(_Left._Current == _Right._Current)) + _NODISCARD friend constexpr bool operator==(const _Ioterator& _Left, const _Ioterator& _Right) + noexcept(noexcept(_Left._Current == _Right._Current)) requires equality_comparable<_Wi> { return _Left._Current == _Right._Current; } - _NODISCARD friend constexpr bool operator<(const _Ioterator& _Left, const _Ioterator& _Right) noexcept( - noexcept(_Left._Current < _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr bool operator<(const _Ioterator& _Left, const _Ioterator& _Right) + noexcept(noexcept(_Left._Current < _Right._Current)) /* strengthened */ requires totally_ordered<_Wi> { return _Left._Current < _Right._Current; } - _NODISCARD friend constexpr bool operator>(const _Ioterator& _Left, const _Ioterator& _Right) noexcept( - noexcept(_Right._Current < _Left._Current)) /* strengthened */ + _NODISCARD friend constexpr bool operator>(const _Ioterator& _Left, const _Ioterator& _Right) + noexcept(noexcept(_Right._Current < _Left._Current)) /* strengthened */ requires totally_ordered<_Wi> { return _Right._Current < _Left._Current; } - _NODISCARD friend constexpr bool operator<=(const _Ioterator& _Left, const _Ioterator& _Right) noexcept( - noexcept(!(_Right._Current < _Left._Current))) /* strengthened */ + _NODISCARD friend constexpr bool operator<=(const _Ioterator& _Left, const _Ioterator& _Right) + noexcept(noexcept(!(_Right._Current < _Left._Current))) /* strengthened */ requires totally_ordered<_Wi> { return !(_Right._Current < _Left._Current); } - _NODISCARD friend constexpr bool operator>=(const _Ioterator& _Left, const _Ioterator& _Right) noexcept( - noexcept(!(_Left._Current < _Right._Current))) /* strengthened */ + _NODISCARD friend constexpr bool operator>=(const _Ioterator& _Left, const _Ioterator& _Right) + noexcept(noexcept(!(_Left._Current < _Right._Current))) /* strengthened */ requires totally_ordered<_Wi> { return !(_Left._Current < _Right._Current); } - _NODISCARD friend constexpr auto operator<=>(const _Ioterator& _Left, const _Ioterator& _Right) noexcept( - noexcept(_Left._Current <=> _Right._Current)) + _NODISCARD friend constexpr auto operator<=>(const _Ioterator& _Left, const _Ioterator& _Right) + noexcept(noexcept(_Left._Current <=> _Right._Current)) requires totally_ordered<_Wi> && three_way_comparable<_Wi> { return _Left._Current <=> _Right._Current; } - _NODISCARD friend constexpr _Ioterator operator+(_Ioterator _It, const difference_type _Off) noexcept( - is_nothrow_move_constructible_v<_Ioterator> // - && noexcept(_It += _Off)) /* strengthened */ + _NODISCARD friend constexpr _Ioterator operator+(_Ioterator _It, const difference_type _Off) + noexcept(is_nothrow_move_constructible_v<_Ioterator> && noexcept(_It += _Off)) /* strengthened */ requires _Advanceable<_Wi> { _It += _Off; return _It; } _NODISCARD friend constexpr _Ioterator operator+(const difference_type _Off, _Ioterator _It) noexcept( - is_nothrow_move_constructible_v<_Wi> // - && noexcept(static_cast<_Wi>(_It._Current + _Off))) /* strengthened */ + is_nothrow_move_constructible_v<_Wi> && noexcept(static_cast<_Wi>(_It._Current + _Off))) /* strengthened */ requires _Advanceable<_Wi> { return _Ioterator{static_cast<_Wi>(_It._Current + _Off)}; } - _NODISCARD friend constexpr _Ioterator operator-(_Ioterator _It, const difference_type _Off) noexcept( - is_nothrow_move_constructible_v<_Ioterator> // - && noexcept(_It -= _Off)) /* strengthened */ + _NODISCARD friend constexpr _Ioterator operator-(_Ioterator _It, const difference_type _Off) + noexcept(is_nothrow_move_constructible_v<_Ioterator> && noexcept(_It -= _Off)) /* strengthened */ requires _Advanceable<_Wi> { _It -= _Off; return _It; } - _NODISCARD friend constexpr difference_type operator-(const _Ioterator& _Left, - const _Ioterator& _Right) noexcept(noexcept(_Left._Current - _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr difference_type operator-(const _Ioterator& _Left, const _Ioterator& _Right) + noexcept(noexcept(_Left._Current - _Right._Current)) /* strengthened */ requires _Advanceable<_Wi> { if constexpr (_Integer_like<_Wi>) { @@ -916,20 +910,20 @@ namespace ranges { public: /* [[no_unique_address]] */ _Bo _Last{}; - _NODISCARD friend constexpr bool operator==(const _It& _Left, const _Iotinel& _Right) noexcept( - noexcept(_Right._Equal(_Left))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _It& _Left, const _Iotinel& _Right) + noexcept(noexcept(_Right._Equal(_Left))) /* strengthened */ { return _Right._Equal(_Left); } - _NODISCARD friend constexpr iter_difference_t<_Wi> operator-(const _It& _Left, const _Iotinel& _Right) noexcept( - noexcept(_Right._Delta(_Left))) /* strengthened */ + _NODISCARD friend constexpr iter_difference_t<_Wi> operator-(const _It& _Left, const _Iotinel& _Right) + noexcept(noexcept(_Right._Delta(_Left))) /* strengthened */ requires sized_sentinel_for<_Bo, _Wi> { return -_Right._Delta(_Left); } - _NODISCARD friend constexpr iter_difference_t<_Wi> operator-(const _Iotinel& _Left, const _It& _Right) noexcept( - noexcept(_Left._Delta(_Right))) /* strengthened */ + _NODISCARD friend constexpr iter_difference_t<_Wi> operator-(const _Iotinel& _Left, const _It& _Right) + noexcept(noexcept(_Left._Delta(_Right))) /* strengthened */ requires sized_sentinel_for<_Bo, _Wi> { return _Left._Delta(_Right); @@ -958,12 +952,12 @@ namespace ranges { } public: - // clang-format off - iota_view() requires default_initializable<_Wi> = default; - // clang-format on + iota_view() + requires default_initializable<_Wi> + = default; - constexpr explicit iota_view(_Wi _Value_) noexcept( - is_nothrow_move_constructible_v<_Wi> && is_nothrow_default_constructible_v<_Bo>) // strengthened + constexpr explicit iota_view(_Wi _Value_) + noexcept(is_nothrow_move_constructible_v<_Wi> && is_nothrow_default_constructible_v<_Bo>) // strengthened : _Value(_STD move(_Value_)) { #if _CONTAINER_DEBUG_LEVEL > 0 if constexpr (totally_ordered_with<_Wi, _Bo>) { @@ -973,8 +967,8 @@ namespace ranges { #endif // _CONTAINER_DEBUG_LEVEL > 0 } - constexpr explicit iota_view(type_identity_t<_Wi> _Value_, type_identity_t<_Bo> _Bound_) noexcept( - is_nothrow_move_constructible_v<_Wi> && is_nothrow_move_constructible_v<_Bo>) // strengthened + constexpr explicit iota_view(type_identity_t<_Wi> _Value_, type_identity_t<_Bo> _Bound_) + noexcept(is_nothrow_move_constructible_v<_Wi> && is_nothrow_move_constructible_v<_Bo>) // strengthened : _Value(_STD move(_Value_)), _Bound(_STD move(_Bound_)) { #if _CONTAINER_DEBUG_LEVEL > 0 if constexpr (totally_ordered_with<_Wi, _Bo>) { @@ -984,8 +978,8 @@ namespace ranges { #endif // _CONTAINER_DEBUG_LEVEL > 0 } - constexpr explicit iota_view(_It _First, _Se _Last) noexcept( - is_nothrow_move_constructible_v<_Wi> && is_nothrow_move_constructible_v<_Bo>) // strengthened + constexpr explicit iota_view(_It _First, _Se _Last) + noexcept(is_nothrow_move_constructible_v<_Wi> && is_nothrow_move_constructible_v<_Bo>) // strengthened : _Value(_STD move(_First._Current)), _Bound(_STD move(_Bound_from(_Last))) { #if _CONTAINER_DEBUG_LEVEL > 0 if constexpr (totally_ordered_with<_Wi, _Bo>) { @@ -1030,12 +1024,10 @@ namespace ranges { #pragma warning(pop) }; - // clang-format off template requires (!_Integer_like<_Wi> || !_Integer_like<_Bo> - || (_Signed_integer_like<_Wi> == _Signed_integer_like<_Bo>)) + || (_Signed_integer_like<_Wi> == _Signed_integer_like<_Bo>) ) iota_view(_Wi, _Bo) -> iota_view<_Wi, _Bo>; - // clang-format on template constexpr bool enable_borrowed_range> = true; @@ -1051,11 +1043,12 @@ namespace ranges { } template - _NODISCARD _STATIC_CALL_OPERATOR constexpr auto operator()(_Ty1&& _Val1, _Ty2&& _Val2) _CONST_CALL_OPERATOR - noexcept(noexcept(iota_view(static_cast<_Ty1&&>(_Val1), static_cast<_Ty2&&>(_Val2)))) - requires requires { iota_view(static_cast<_Ty1&&>(_Val1), static_cast<_Ty2&&>(_Val2)); } + _NODISCARD _STATIC_CALL_OPERATOR constexpr auto operator()( + _Ty1&& _Start, _Ty2&& _Bound) _CONST_CALL_OPERATOR + noexcept(noexcept(iota_view(static_cast<_Ty1&&>(_Start), static_cast<_Ty2&&>(_Bound)))) + requires requires { iota_view(static_cast<_Ty1&&>(_Start), static_cast<_Ty2&&>(_Bound)); } { - return iota_view(static_cast<_Ty1&&>(_Val1), static_cast<_Ty2&&>(_Val2)); + return iota_view(static_cast<_Ty1&&>(_Start), static_cast<_Ty2&&>(_Bound)); } }; @@ -1233,17 +1226,17 @@ namespace ranges { /* [[no_unique_address]] */ _Bo _Bound{}; template - _NODISCARD_CTOR constexpr repeat_view(_Tuple& _Val, index_sequence<_Indices...>, _Bo _Bound_) noexcept( - is_nothrow_constructible_v<_Ty, tuple_element_t<_Indices, _Tuple>...>) + _NODISCARD_CTOR constexpr repeat_view(_Tuple& _Val, index_sequence<_Indices...>, _Bo _Bound_) + noexcept(is_nothrow_constructible_v<_Ty, tuple_element_t<_Indices, _Tuple>...>) : _Value(in_place, _Tuple_get<_Indices>(_STD move(_Val))...), _Bound(_STD move(_Bound_)) {} public: - // clang-format off - repeat_view() requires default_initializable<_Ty> = default; - // clang-format on + repeat_view() + requires default_initializable<_Ty> + = default; - _NODISCARD_CTOR constexpr explicit repeat_view(const _Ty& _Value_, _Bo _Bound_ = _Bo{}) noexcept( - is_nothrow_copy_constructible_v<_Ty>) // strengthened + _NODISCARD_CTOR constexpr explicit repeat_view(const _Ty& _Value_, _Bo _Bound_ = _Bo{}) + noexcept(is_nothrow_copy_constructible_v<_Ty>) // strengthened requires copy_constructible<_Ty> : _Value(in_place, _Value_), _Bound(_STD move(_Bound_)) { #if _CONTAINER_DEBUG_LEVEL > 0 @@ -1252,8 +1245,8 @@ namespace ranges { } #endif // _CONTAINER_DEBUG_LEVEL > 0 } - _NODISCARD_CTOR constexpr explicit repeat_view(_Ty&& _Value_, _Bo _Bound_ = _Bo{}) noexcept( - is_nothrow_move_constructible_v<_Ty>) // strengthened + _NODISCARD_CTOR constexpr explicit repeat_view(_Ty&& _Value_, _Bo _Bound_ = _Bo{}) + noexcept(is_nothrow_move_constructible_v<_Ty>) // strengthened : _Value(in_place, _STD move(_Value_)), _Bound(_STD move(_Bound_)) { #if _CONTAINER_DEBUG_LEVEL > 0 if constexpr (_Signed_integer_like<_Bo>) { @@ -1263,9 +1256,10 @@ namespace ranges { } template requires constructible_from<_Ty, _TArgs...> && constructible_from<_Bo, _BArgs...> - _NODISCARD_CTOR constexpr explicit repeat_view(piecewise_construct_t, tuple<_TArgs...> _Val_args, - tuple<_BArgs...> _Bound_args = tuple<>{}) noexcept(is_nothrow_constructible_v<_Ty, _TArgs...> // - && noexcept(_STD make_from_tuple<_Bo>(_Bound_args))) // strengthened + _NODISCARD_CTOR constexpr explicit repeat_view( + piecewise_construct_t, tuple<_TArgs...> _Val_args, tuple<_BArgs...> _Bound_args = tuple<>{}) + noexcept(is_nothrow_constructible_v<_Ty, _TArgs...> + && noexcept(_STD make_from_tuple<_Bo>(_Bound_args))) // strengthened : repeat_view(_Val_args, index_sequence_for<_TArgs...>{}, _STD make_from_tuple<_Bo>(_Bound_args)) { #if _CONTAINER_DEBUG_LEVEL > 0 if constexpr (_Signed_integer_like<_Bo>) { @@ -1306,11 +1300,12 @@ namespace ranges { } template - _NODISCARD _STATIC_CALL_OPERATOR constexpr auto operator()(_Ty1&& _Val1, _Ty2&& _Val2) _CONST_CALL_OPERATOR - noexcept(noexcept(repeat_view(_STD forward<_Ty1>(_Val1), _STD forward<_Ty2>(_Val2)))) - requires requires { repeat_view(_STD forward<_Ty1>(_Val1), _STD forward<_Ty2>(_Val2)); } + _NODISCARD _STATIC_CALL_OPERATOR constexpr auto operator()( + _Ty1&& _Value, _Ty2&& _Count) _CONST_CALL_OPERATOR + noexcept(noexcept(repeat_view(_STD forward<_Ty1>(_Value), _STD forward<_Ty2>(_Count)))) + requires requires { repeat_view(_STD forward<_Ty1>(_Value), _STD forward<_Ty2>(_Count)); } { - return repeat_view(_STD forward<_Ty1>(_Val1), _STD forward<_Ty2>(_Val2)); + return repeat_view(_STD forward<_Ty1>(_Value), _STD forward<_Ty2>(_Count)); } }; @@ -1374,8 +1369,8 @@ namespace ranges { _Ty _Val = _Ty{}; public: - constexpr explicit basic_istream_view(basic_istream<_Elem, _Traits>& _Stream_) noexcept( - is_nothrow_default_constructible_v<_Ty>) // strengthened + constexpr explicit basic_istream_view(basic_istream<_Elem, _Traits>& _Stream_) + noexcept(is_nothrow_default_constructible_v<_Ty>) // strengthened : _Stream{_STD addressof(_Stream_)} {} _NODISCARD constexpr auto begin() { @@ -1448,9 +1443,9 @@ namespace ranges { static constexpr bool _Is_end_nothrow_v<_Rng> = noexcept(move_iterator{_RANGES end(_STD declval<_Rng&>())}); public: - // clang-format off - as_rvalue_view() requires default_initializable<_Vw> = default; - // clang-format on + as_rvalue_view() + requires default_initializable<_Vw> + = default; constexpr explicit as_rvalue_view(_Vw _Range_) noexcept(is_nothrow_move_constructible_v<_Vw>) // strengthened : _Range(_STD move(_Range_)) {} @@ -1603,12 +1598,12 @@ namespace ranges { using value_type = range_value_t<_Vw>; using difference_type = range_difference_t<_Vw>; - // clang-format off - _Iterator() requires default_initializable> = default; - // clang-format on + _Iterator() + requires default_initializable> + = default; - constexpr _Iterator(filter_view& _Parent_, iterator_t<_Vw> _Current_) noexcept( - is_nothrow_move_constructible_v>) // strengthened + constexpr _Iterator(filter_view& _Parent_, iterator_t<_Vw> _Current_) + noexcept(is_nothrow_move_constructible_v>) // strengthened : _Current(_STD move(_Current_)), _Parent{_STD addressof(_Parent_)} { #if _ITERATOR_DEBUG_LEVEL != 0 _STD _Adl_verify_range(_Current, _RANGES end(_Parent_._Range)); @@ -1698,16 +1693,16 @@ namespace ranges { return _Left._Current == _Right._Current; } - _NODISCARD friend constexpr range_rvalue_reference_t<_Vw> iter_move(const _Iterator& _It) noexcept( - noexcept(_RANGES iter_move(_It._Current))) { + _NODISCARD friend constexpr range_rvalue_reference_t<_Vw> iter_move(const _Iterator& _It) + noexcept(noexcept(_RANGES iter_move(_It._Current))) { #if _ITERATOR_DEBUG_LEVEL != 0 _It._Check_dereference(); #endif // _ITERATOR_DEBUG_LEVEL != 0 return _RANGES iter_move(_It._Current); } - friend constexpr void iter_swap(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_RANGES iter_swap(_Left._Current, _Right._Current))) + friend constexpr void iter_swap(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_RANGES iter_swap(_Left._Current, _Right._Current))) requires indirectly_swappable> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -1729,9 +1724,9 @@ namespace ranges { public: _Sentinel() = default; - constexpr explicit _Sentinel(filter_view& _Parent) noexcept( - noexcept(_RANGES end(_Parent._Range)) - && is_nothrow_move_constructible_v>) // strengthened + constexpr explicit _Sentinel(filter_view& _Parent) + noexcept(noexcept(_RANGES end(_Parent._Range)) + && is_nothrow_move_constructible_v>) // strengthened : _Last(_RANGES end(_Parent._Range)) {} _NODISCARD constexpr sentinel_t<_Vw> base() const @@ -1739,19 +1734,19 @@ namespace ranges { return _Last; } - _NODISCARD friend constexpr bool operator==(const _Iterator& _It, const _Sentinel& _Se) noexcept( - noexcept(_It._Equal(_Se._Last))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Iterator& _It, const _Sentinel& _Se) + noexcept(noexcept(_It._Equal(_Se._Last))) /* strengthened */ { return _It._Equal(_Se._Last); } }; public: - // clang-format off - filter_view() requires default_initializable<_Vw> && default_initializable<_Pr> = default; - // clang-format on + filter_view() + requires default_initializable<_Vw> && default_initializable<_Pr> + = default; - constexpr explicit filter_view(_Vw _Range_, _Pr _Pred_) noexcept( - is_nothrow_move_constructible_v<_Vw> && is_nothrow_move_constructible_v<_Pr>) // strengthened + constexpr explicit filter_view(_Vw _Range_, _Pr _Pred_) + noexcept(is_nothrow_move_constructible_v<_Vw> && is_nothrow_move_constructible_v<_Pr>) // strengthened : _Range(_STD move(_Range_)), _Pred{in_place, _STD move(_Pred_)} {} _NODISCARD constexpr _Vw base() const& noexcept(is_nothrow_copy_constructible_v<_Vw>) /* strengthened */ @@ -1858,8 +1853,8 @@ namespace ranges { public: _Sentinel() = default; - constexpr explicit _Sentinel(_Base_sentinel _Last_) noexcept( - is_nothrow_move_constructible_v<_Base_sentinel>) // strengthened + constexpr explicit _Sentinel(_Base_sentinel _Last_) + noexcept(is_nothrow_move_constructible_v<_Base_sentinel>) // strengthened : _Last(_STD move(_Last_)) {} constexpr _Sentinel(_Sentinel _That) noexcept( @@ -1913,12 +1908,12 @@ namespace ranges { }; public: - // clang-format off - take_view() requires default_initializable<_Vw> = default; - // clang-format on + take_view() + requires default_initializable<_Vw> + = default; - constexpr explicit take_view(_Vw _Range_, const range_difference_t<_Vw> _Count_) noexcept( - is_nothrow_move_constructible_v<_Vw>) // strengthened + constexpr explicit take_view(_Vw _Range_, const range_difference_t<_Vw> _Count_) + noexcept(is_nothrow_move_constructible_v<_Vw>) // strengthened : _Range(_STD move(_Range_)), _Count{_Count_} { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Count_ >= 0, "Number of elements to take must be non-negative (N4971 [range.take.view]/1)"); @@ -2155,8 +2150,8 @@ namespace ranges { public: _Sentinel() = default; - constexpr explicit _Sentinel(_Base_sentinel _Last_, const _Pr* const _Pred_) noexcept( - is_nothrow_move_constructible_v<_Base_sentinel>) // strengthened + constexpr explicit _Sentinel(_Base_sentinel _Last_, const _Pr* const _Pred_) + noexcept(is_nothrow_move_constructible_v<_Base_sentinel>) // strengthened : _Last(_STD move(_Last_)), _Pred(_Pred_) {} constexpr _Sentinel(_Sentinel _That) noexcept( @@ -2210,12 +2205,12 @@ namespace ranges { }; public: - // clang-format off - take_while_view() requires default_initializable<_Vw> && default_initializable<_Pr> = default; - // clang-format on + take_while_view() + requires default_initializable<_Vw> && default_initializable<_Pr> + = default; - constexpr explicit take_while_view(_Vw _Range_, _Pr _Pred_) noexcept( - is_nothrow_move_constructible_v<_Vw> && is_nothrow_move_constructible_v<_Pr>) // strengthened + constexpr explicit take_while_view(_Vw _Range_, _Pr _Pred_) + noexcept(is_nothrow_move_constructible_v<_Vw> && is_nothrow_move_constructible_v<_Pr>) // strengthened : _Range(_STD move(_Range_)), _Pred{in_place, _STD move(_Pred_)} {} _NODISCARD constexpr _Vw base() const& noexcept(is_nothrow_copy_constructible_v<_Vw>) /* strengthened */ @@ -2333,12 +2328,12 @@ namespace ranges { } public: - // clang-format off - drop_view() requires default_initializable<_Vw> = default; - // clang-format on + drop_view() + requires default_initializable<_Vw> + = default; - constexpr explicit drop_view(_Vw _Range_, const range_difference_t<_Vw> _Count_) noexcept( - is_nothrow_move_constructible_v<_Vw>) // strengthened + constexpr explicit drop_view(_Vw _Range_, const range_difference_t<_Vw> _Count_) + noexcept(is_nothrow_move_constructible_v<_Vw>) // strengthened : _Range(_STD move(_Range_)), _Count{_Count_} { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Count_ >= 0, "Number of elements to drop must be non-negative (N4971 [range.drop.view]/1)"); @@ -2544,12 +2539,12 @@ namespace ranges { /* [[no_unique_address]] */ _Movable_box<_Pr> _Pred{}; public: - // clang-format off - drop_while_view() requires default_initializable<_Vw> && default_initializable<_Pr> = default; - // clang-format on + drop_while_view() + requires default_initializable<_Vw> && default_initializable<_Pr> + = default; - constexpr explicit drop_while_view(_Vw _Range_, _Pr _Pred_) noexcept( - is_nothrow_move_constructible_v<_Vw> && is_nothrow_move_constructible_v<_Pr>) // strengthened + constexpr explicit drop_while_view(_Vw _Range_, _Pr _Pred_) + noexcept(is_nothrow_move_constructible_v<_Vw> && is_nothrow_move_constructible_v<_Pr>) // strengthened : _Range(_STD move(_Range_)), _Pred{in_place, _STD move(_Pred_)} {} _NODISCARD constexpr _Vw base() const& noexcept(is_nothrow_copy_constructible_v<_Vw>) /* strengthened */ @@ -2642,8 +2637,8 @@ namespace ranges { private: struct _Cache_wrapper { template - constexpr _Cache_wrapper(_Construct_tag, const _Iter& _It) noexcept( - noexcept(static_cast(*_It))) + constexpr _Cache_wrapper(_Construct_tag, const _Iter& _It) + noexcept(noexcept(static_cast(*_It))) : _Val(*_It) {} remove_cv_t> _Val; @@ -2884,8 +2879,8 @@ namespace ranges { return _Tmp; } - _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Outer == _Right._Outer && _Left._Inner == _Right._Inner)) /* strengthened */ + _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Outer == _Right._Outer && _Left._Inner == _Right._Inner)) /* strengthened */ requires _Deref_is_glvalue && forward_range<_Base> && equality_comparable<_InnerIter> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -2894,16 +2889,16 @@ namespace ranges { return _Left._Outer == _Right._Outer && _Left._Inner == _Right._Inner; } - _NODISCARD friend constexpr decltype(auto) iter_move(const _Iterator& _It) noexcept( - noexcept(_RANGES iter_move(*_It._Inner))) { + _NODISCARD friend constexpr decltype(auto) iter_move(const _Iterator& _It) + noexcept(noexcept(_RANGES iter_move(*_It._Inner))) { #if _ITERATOR_DEBUG_LEVEL != 0 _It._Check_dereference(); #endif // _ITERATOR_DEBUG_LEVEL != 0 return _RANGES iter_move(*_It._Inner); } - friend constexpr void iter_swap(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_RANGES iter_swap(*_Left._Inner, *_Right._Inner))) + friend constexpr void iter_swap(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_RANGES iter_swap(*_Left._Inner, *_Right._Inner))) requires indirectly_swappable<_InnerIter> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -2936,28 +2931,28 @@ namespace ranges { public: _Sentinel() = default; - constexpr explicit _Sentinel(_Parent_t& _Parent) noexcept( - noexcept(_RANGES end(_Parent._Range)) - && is_nothrow_move_constructible_v>) // strengthened + constexpr explicit _Sentinel(_Parent_t& _Parent) + noexcept(noexcept(_RANGES end(_Parent._Range)) + && is_nothrow_move_constructible_v>) // strengthened : _Last(_RANGES end(_Parent._Range)) {} - constexpr _Sentinel(_Sentinel _Se) noexcept( - is_nothrow_constructible_v, sentinel_t<_Vw>>) // strengthened + constexpr _Sentinel(_Sentinel _Se) + noexcept(is_nothrow_constructible_v, sentinel_t<_Vw>>) // strengthened requires _Const && convertible_to, sentinel_t<_Base>> : _Last(_STD move(_Se._Last)) {} template requires sentinel_for, _Maybe_const_iter<_OtherConst>> - _NODISCARD friend constexpr bool operator==(const _Iterator<_OtherConst>& _Left, - const _Sentinel& _Right) noexcept(noexcept(_Right._Equal(_Left))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Iterator<_OtherConst>& _Left, const _Sentinel& _Right) + noexcept(noexcept(_Right._Equal(_Left))) /* strengthened */ { return _Right._Equal(_Left); } }; public: - // clang-format off - join_view() requires default_initializable<_Vw> = default; - // clang-format on + join_view() + requires default_initializable<_Vw> + = default; constexpr explicit join_view(_Vw _Range_) noexcept(is_nothrow_move_constructible_v<_Vw>) // strengthened : _Range(_STD move(_Range_)) {} @@ -3090,8 +3085,8 @@ namespace ranges { private: struct _Cache_wrapper { template - constexpr _Cache_wrapper(_Construct_tag, const _Iter& _It) noexcept( - noexcept(static_cast(*_It))) + constexpr _Cache_wrapper(_Construct_tag, const _Iter& _It) + noexcept(noexcept(static_cast(*_It))) : _Val(*_It) {} remove_cv_t> _Val; @@ -3460,9 +3455,9 @@ namespace ranges { /* [[no_unique_address]] */ sentinel_t<_Base> _Last{}; - constexpr explicit _Sentinel(_Parent_t& _Parent) noexcept( - noexcept(_RANGES end(_Parent._Range)) - && is_nothrow_move_constructible_v>) // strengthened + constexpr explicit _Sentinel(_Parent_t& _Parent) + noexcept(noexcept(_RANGES end(_Parent._Range)) + && is_nothrow_move_constructible_v>) // strengthened : _Last(_RANGES end(_Parent._Range)) {} template @@ -3476,34 +3471,34 @@ namespace ranges { public: _Sentinel() = default; - constexpr _Sentinel(_Sentinel _Se) noexcept( - is_nothrow_constructible_v, sentinel_t<_Vw>>) // strengthened + constexpr _Sentinel(_Sentinel _Se) + noexcept(is_nothrow_constructible_v, sentinel_t<_Vw>>) // strengthened requires _Const && convertible_to, sentinel_t<_Base>> : _Last(_STD move(_Se._Last)) {} template requires sentinel_for, iterator_t<_Maybe_const<_OtherConst, _Vw>>> - _NODISCARD friend constexpr bool operator==(const _Iterator<_OtherConst>& _Left, - const _Sentinel& _Right) noexcept(noexcept(_Right._Equal(_Left))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Iterator<_OtherConst>& _Left, const _Sentinel& _Right) + noexcept(noexcept(_Right._Equal(_Left))) /* strengthened */ { return _Right._Equal(_Left); } }; public: - // clang-format off - join_with_view() requires default_initializable<_Vw> && default_initializable<_Pat> = default; - // clang-format on + join_with_view() + requires default_initializable<_Vw> && default_initializable<_Pat> + = default; - constexpr explicit join_with_view(_Vw _Range_, _Pat _Pattern_) noexcept( - is_nothrow_move_constructible_v<_Vw> && is_nothrow_move_constructible_v<_Pat>) // strengthened + constexpr explicit join_with_view(_Vw _Range_, _Pat _Pattern_) + noexcept(is_nothrow_move_constructible_v<_Vw> && is_nothrow_move_constructible_v<_Pat>) // strengthened : _Range{_STD move(_Range_)}, _Pattern{_STD move(_Pattern_)} {} template requires constructible_from<_Vw, views::all_t<_Rng>> && constructible_from<_Pat, single_view>>> - constexpr explicit join_with_view(_Rng&& _Range_, range_value_t<_InnerRng> _Elem) noexcept( - noexcept(_Vw(views::all(_STD forward<_Rng>(_Range_)))) && noexcept( - _Pat(views::single(_STD move(_Elem))))) // strengthened + constexpr explicit join_with_view(_Rng&& _Range_, range_value_t<_InnerRng> _Elem) + noexcept(noexcept(_Vw(views::all(_STD forward<_Rng>(_Range_)))) + && noexcept(_Pat(views::single(_STD move(_Elem))))) // strengthened : _Range(views::all(_STD forward<_Rng>(_Range_))), _Pattern(views::single(_STD move(_Elem))) {} _NODISCARD constexpr _Vw base() const& noexcept(is_nothrow_copy_constructible_v<_Vw>) /* strengthened */ @@ -3613,18 +3608,14 @@ namespace ranges { } // namespace views #endif // _HAS_CXX23 - // clang-format off template - concept _Tiny_range = sized_range<_Ty> - && requires { typename _Require_constant::size()>; } - && (remove_reference_t<_Ty>::size() <= 1); + concept _Tiny_range = sized_range<_Ty> && requires { typename _Require_constant::size()>; } + && (remove_reference_t<_Ty>::size() <= 1); _EXPORT_STD template - requires (view<_Vw> && view<_Pat> - && indirectly_comparable, iterator_t<_Pat>, _RANGES equal_to> - && (forward_range<_Vw> || _Tiny_range<_Pat>)) + requires (view<_Vw> && view<_Pat> && indirectly_comparable, iterator_t<_Pat>, _RANGES equal_to> + && (forward_range<_Vw> || _Tiny_range<_Pat>) ) class lazy_split_view; - // clang-format on template class _Lazy_split_view_base : public view_interface> { @@ -3703,8 +3694,8 @@ namespace ranges { private: /* [[no_unique_address]] */ _Outer_iter _First{}; - constexpr explicit value_type(_Outer_iter _First_) noexcept( - is_nothrow_move_constructible_v<_Outer_iter>) + constexpr explicit value_type(_Outer_iter _First_) + noexcept(is_nothrow_move_constructible_v<_Outer_iter>) : _First{_STD move(_First_)} {} friend _Outer_iter; @@ -3725,8 +3716,8 @@ namespace ranges { requires (!forward_range<_BaseTy>) : _Parent{_STD addressof(_Parent_)} {} - constexpr _Outer_iter(_ParentTy& _Parent_, iterator_t<_BaseTy> _Current_) noexcept( - is_nothrow_move_constructible_v>) // strengthened + constexpr _Outer_iter(_ParentTy& _Parent_, iterator_t<_BaseTy> _Current_) + noexcept(is_nothrow_move_constructible_v>) // strengthened requires forward_range<_BaseTy> : _Mybase{_STD move(_Current_)}, _Parent{_STD addressof(_Parent_)} {} @@ -3783,14 +3774,14 @@ namespace ranges { } } - _NODISCARD friend constexpr bool operator==(const _Outer_iter& _Left, const _Outer_iter& _Right) noexcept( - noexcept(_Left._Current == _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr bool operator==(const _Outer_iter& _Left, const _Outer_iter& _Right) + noexcept(noexcept(_Left._Current == _Right._Current)) /* strengthened */ requires forward_range<_BaseTy> { return _Left._Current == _Right._Current && _Left._Trailing_empty == _Right._Trailing_empty; } - _NODISCARD friend constexpr bool operator==(const _Outer_iter& _Left, default_sentinel_t) noexcept( - noexcept(_Left._At_end())) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Outer_iter& _Left, default_sentinel_t) + noexcept(noexcept(_Left._At_end())) /* strengthened */ { return _Left._At_end() && !_Left._Trailing_empty; } }; @@ -3873,8 +3864,8 @@ namespace ranges { using difference_type = range_difference_t<_BaseTy>; _Inner_iter() = default; - constexpr explicit _Inner_iter(_Outer_iter<_Const> _It_) noexcept( - is_nothrow_move_constructible_v<_Outer_iter<_Const>>) // strengthened + constexpr explicit _Inner_iter(_Outer_iter<_Const> _It_) + noexcept(is_nothrow_move_constructible_v<_Outer_iter<_Const>>) // strengthened : _It{_STD move(_It_)} {} _NODISCARD constexpr const iterator_t<_BaseTy>& base() const& noexcept { @@ -3923,13 +3914,13 @@ namespace ranges { return _Left._At_end(); } - _NODISCARD friend constexpr decltype(auto) iter_move(const _Inner_iter& _Iter) noexcept( - noexcept(_RANGES iter_move(_Iter._Get_current()))) { + _NODISCARD friend constexpr decltype(auto) iter_move(const _Inner_iter& _Iter) + noexcept(noexcept(_RANGES iter_move(_Iter._Get_current()))) { return _RANGES iter_move(_Iter._Get_current()); } - friend constexpr void iter_swap(const _Inner_iter& _Left, const _Inner_iter& _Right) noexcept( - noexcept(_RANGES iter_swap(_Left._Get_current(), _Right._Get_current()))) + friend constexpr void iter_swap(const _Inner_iter& _Left, const _Inner_iter& _Right) + noexcept(noexcept(_RANGES iter_swap(_Left._Get_current(), _Right._Get_current()))) requires indirectly_swappable> { _RANGES iter_swap(_Left._Get_current(), _Right._Get_current()); @@ -3937,19 +3928,20 @@ namespace ranges { }; public: - // clang-format off - lazy_split_view() requires default_initializable<_Vw> && default_initializable<_Pat> = default; - // clang-format on + lazy_split_view() + requires default_initializable<_Vw> && default_initializable<_Pat> + = default; - constexpr explicit lazy_split_view(_Vw _Range_, _Pat _Pattern_) noexcept( - is_nothrow_move_constructible_v<_Vw> && is_nothrow_move_constructible_v<_Pat>) // strengthened + constexpr explicit lazy_split_view(_Vw _Range_, _Pat _Pattern_) + noexcept(is_nothrow_move_constructible_v<_Vw> && is_nothrow_move_constructible_v<_Pat>) // strengthened : _Range(_STD move(_Range_)), _Pattern(_STD move(_Pattern_)) {} template requires constructible_from<_Vw, views::all_t<_Rng>> && constructible_from<_Pat, single_view>> - constexpr explicit lazy_split_view(_Rng&& _Range_, range_value_t<_Rng> _Elem) noexcept(noexcept(_Vw(views::all( - _STD forward<_Rng>(_Range_)))) && noexcept(_Pat(views::single(_STD move(_Elem))))) // strengthened + constexpr explicit lazy_split_view(_Rng&& _Range_, range_value_t<_Rng> _Elem) + noexcept(noexcept(_Vw(views::all(_STD forward<_Rng>(_Range_)))) + && noexcept(_Pat(views::single(_STD move(_Elem))))) // strengthened : _Range(views::all(_STD forward<_Rng>(_Range_))), _Pattern(views::single(_STD move(_Elem))) {} _NODISCARD constexpr _Vw base() const& noexcept(is_nothrow_copy_constructible_v<_Vw>) /* strengthened */ @@ -3997,8 +3989,8 @@ namespace ranges { lazy_split_view(_Rng&&, _Pat&&) -> lazy_split_view, views::all_t<_Pat>>; template - lazy_split_view(_Rng&&, range_value_t<_Rng>) - -> lazy_split_view, single_view>>; + lazy_split_view( + _Rng&&, range_value_t<_Rng>) -> lazy_split_view, single_view>>; #if _HAS_CXX23 template @@ -4100,8 +4092,8 @@ namespace ranges { return _Tmp; } - _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Current == _Right._Current)) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current == _Right._Current)) /* strengthened */ { return _Left._Current == _Right._Current && _Left._Trailing_empty == _Right._Trailing_empty; } }; @@ -4117,13 +4109,13 @@ namespace ranges { public: _Sentinel() = default; - constexpr explicit _Sentinel(split_view& _Parent) noexcept( - noexcept(_RANGES end(_Parent._Range)) - && is_nothrow_move_constructible_v>) // strengthened + constexpr explicit _Sentinel(split_view& _Parent) + noexcept(noexcept(_RANGES end(_Parent._Range)) + && is_nothrow_move_constructible_v>) // strengthened : _Last(_RANGES end(_Parent._Range)) {} - _NODISCARD friend constexpr bool operator==(const _Iterator& _It, const _Sentinel& _Se) noexcept( - noexcept(_Se._Equal(_It))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Iterator& _It, const _Sentinel& _Se) + noexcept(noexcept(_Se._Equal(_It))) /* strengthened */ { return _Se._Equal(_It); } }; @@ -4140,21 +4132,21 @@ namespace ranges { } public: - // clang-format off - split_view() requires default_initializable<_Vw> && default_initializable<_Pat> = default; - // clang-format on + split_view() + requires default_initializable<_Vw> && default_initializable<_Pat> + = default; - constexpr explicit split_view(_Vw _Range_, _Pat _Pattern_) noexcept( - is_nothrow_move_constructible_v<_Vw> && is_nothrow_move_constructible_v<_Pat>) // strengthened + constexpr explicit split_view(_Vw _Range_, _Pat _Pattern_) + noexcept(is_nothrow_move_constructible_v<_Vw> && is_nothrow_move_constructible_v<_Pat>) // strengthened : _Range(_STD move(_Range_)), _Pattern(_STD move(_Pattern_)) {} template requires constructible_from<_Vw, views::all_t<_Rng>> && constructible_from<_Pat, single_view>> - constexpr explicit split_view(_Rng&& _Range_, range_value_t<_Rng> _Elem) noexcept( - is_nothrow_constructible_v<_Vw, views::all_t<_Rng>> - && is_nothrow_constructible_v<_Pat, single_view>> - && is_nothrow_move_constructible_v>) // strengthened + constexpr explicit split_view(_Rng&& _Range_, range_value_t<_Rng> _Elem) + noexcept(is_nothrow_constructible_v<_Vw, views::all_t<_Rng>> + && is_nothrow_constructible_v<_Pat, single_view>> + && is_nothrow_move_constructible_v>) // strengthened : _Range(views::all(_STD forward<_Rng>(_Range_))), _Pattern(views::single(_STD move(_Elem))) {} _NODISCARD constexpr _Vw base() const& noexcept(is_nothrow_copy_constructible_v<_Vw>) /* strengthened */ @@ -4271,9 +4263,9 @@ namespace ranges { /* [[no_unique_address]] */ _Vw _Base{}; public: - // clang-format off - common_view() requires default_initializable<_Vw> = default; - // clang-format on + common_view() + requires default_initializable<_Vw> + = default; constexpr explicit common_view(_Vw _Base_) noexcept(is_nothrow_move_constructible_v<_Vw>) // strengthened : _Base(_STD move(_Base_)) {} @@ -4404,9 +4396,9 @@ namespace ranges { using _Rev_iter = reverse_iterator>; public: - // clang-format off - reverse_view() requires default_initializable<_Vw> = default; - // clang-format on + reverse_view() + requires default_initializable<_Vw> + = default; constexpr explicit reverse_view(_Vw _Range_) noexcept(is_nothrow_move_constructible_v<_Vw>) // strengthened : _Range(_STD move(_Range_)) {} @@ -4446,8 +4438,8 @@ namespace ranges { return _Rev_iter{_RANGES end(_Range)}; } - _NODISCARD constexpr _Rev_iter<_Vw> end() noexcept( - noexcept(_Rev_iter<_Vw>{_RANGES begin(_Range)})) /* strengthened */ { + _NODISCARD constexpr _Rev_iter<_Vw> end() + noexcept(noexcept(_Rev_iter<_Vw>{_RANGES begin(_Range)})) /* strengthened */ { return _Rev_iter<_Vw>{_RANGES begin(_Range)}; } _NODISCARD constexpr auto end() const @@ -4561,9 +4553,9 @@ namespace ranges { /* [[no_unique_address]] */ _Vw _Range{}; public: - // clang-format off - as_const_view() requires default_initializable<_Vw> = default; - // clang-format on + as_const_view() + requires default_initializable<_Vw> + = default; constexpr explicit as_const_view(_Vw _Range_) noexcept(is_nothrow_move_constructible_v<_Vw>) // strengthened : _Range(_STD move(_Range_)) {} @@ -4748,16 +4740,16 @@ namespace ranges { using value_type = remove_cvref_t>>; using difference_type = range_difference_t<_Base>; - // clang-format off - _Iterator() requires default_initializable> = default; - // clang-format on + _Iterator() + requires default_initializable> + = default; - constexpr explicit _Iterator(iterator_t<_Base> _Current_) noexcept( - is_nothrow_move_constructible_v>) // strengthened + constexpr explicit _Iterator(iterator_t<_Base> _Current_) + noexcept(is_nothrow_move_constructible_v>) // strengthened : _Current{_STD move(_Current_)} {} - constexpr _Iterator(_Iterator _It) noexcept( - is_nothrow_constructible_v, iterator_t<_Vw>>) // strengthened + constexpr _Iterator(_Iterator _It) + noexcept(is_nothrow_constructible_v, iterator_t<_Vw>>) // strengthened requires _Const && convertible_to, iterator_t<_Base>> : _Current(_STD move(_It._Current)) {} @@ -4779,7 +4771,7 @@ namespace ranges { _NODISCARD constexpr decltype(auto) operator*() const noexcept(is_nothrow_move_constructible_v>> // - && noexcept(_STD get<_Index>(*_Current))) /* strengthened */ { + && noexcept(_STD get<_Index>(*_Current))) /* strengthened */ { using _ElemTy = remove_cv_t>>; return static_cast<_ElemTy>(_STD get<_Index>(*_Current)); } @@ -4793,8 +4785,8 @@ namespace ranges { ++_Current; } - constexpr _Iterator operator++(int) noexcept( - noexcept(++_Current) && is_nothrow_copy_constructible_v>) /* strengthened */ + constexpr _Iterator operator++(int) + noexcept(noexcept(++_Current) && is_nothrow_copy_constructible_v>) /* strengthened */ requires forward_range<_Base> { auto _Tmp = *this; @@ -4809,8 +4801,8 @@ namespace ranges { return *this; } - constexpr _Iterator operator--(int) noexcept( - noexcept(--_Current) && is_nothrow_copy_constructible_v>) /* strengthened */ + constexpr _Iterator operator--(int) + noexcept(noexcept(--_Current) && is_nothrow_copy_constructible_v>) /* strengthened */ requires bidirectional_range<_Base> { auto _Tmp = *this; @@ -4828,8 +4820,8 @@ namespace ranges { } #endif // _ITERATOR_DEBUG_LEVEL != 0 - constexpr _Iterator& operator+=(const difference_type _Off) noexcept( - noexcept(_Current += _Off)) /* strengthened */ + constexpr _Iterator& operator+=(const difference_type _Off) + noexcept(noexcept(_Current += _Off)) /* strengthened */ requires random_access_range<_Base> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -4838,8 +4830,8 @@ namespace ranges { _Current += _Off; return *this; } - constexpr _Iterator& operator-=(const difference_type _Off) noexcept( - noexcept(_Current -= _Off)) /* strengthened */ + constexpr _Iterator& operator-=(const difference_type _Off) + noexcept(noexcept(_Current -= _Off)) /* strengthened */ requires random_access_range<_Base> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -4862,7 +4854,7 @@ namespace ranges { _NODISCARD constexpr decltype(auto) operator[](const difference_type _Idx) const noexcept(is_nothrow_move_constructible_v>> // - && noexcept(_STD get<_Index>(*(_Current + _Idx)))) /* strengthened */ + && noexcept(_STD get<_Index>(*(_Current + _Idx)))) /* strengthened */ requires random_access_range<_Base> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -4872,48 +4864,48 @@ namespace ranges { return static_cast<_ElemTy>(_STD get<_Index>(*(_Current + _Idx))); } - _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Current == _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current == _Right._Current)) /* strengthened */ requires equality_comparable> { return _Left._Current == _Right._Current; } - _NODISCARD friend constexpr bool operator<(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Current < _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr bool operator<(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current < _Right._Current)) /* strengthened */ requires random_access_range<_Base> { return _Left._Current < _Right._Current; } - _NODISCARD friend constexpr bool operator>(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Current < _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr bool operator>(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current < _Right._Current)) /* strengthened */ requires random_access_range<_Base> { return _Right < _Left; } - _NODISCARD friend constexpr bool operator<=(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Current < _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr bool operator<=(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current < _Right._Current)) /* strengthened */ requires random_access_range<_Base> { return !(_Right < _Left); } - _NODISCARD friend constexpr bool operator>=(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Current < _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr bool operator>=(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current < _Right._Current)) /* strengthened */ requires random_access_range<_Base> { return !(_Left < _Right); } - _NODISCARD friend constexpr auto operator<=>(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Current <=> _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr auto operator<=>(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current <=> _Right._Current)) /* strengthened */ requires random_access_range<_Base> && three_way_comparable> { return _Left._Current <=> _Right._Current; } - _NODISCARD friend constexpr _Iterator operator+(const _Iterator& _It, const difference_type _Off) noexcept( - noexcept(_STD declval&>() += _Off) - && is_nothrow_copy_constructible_v>) /* strengthened */ + _NODISCARD friend constexpr _Iterator operator+(const _Iterator& _It, const difference_type _Off) + noexcept(noexcept(_STD declval&>() += _Off) + && is_nothrow_copy_constructible_v>) /* strengthened */ requires random_access_range<_Base> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -4924,9 +4916,9 @@ namespace ranges { return _Copy; } - _NODISCARD friend constexpr _Iterator operator+(const difference_type _Off, const _Iterator& _It) noexcept( - noexcept(_STD declval&>() += _Off) - && is_nothrow_copy_constructible_v>) /* strengthened */ + _NODISCARD friend constexpr _Iterator operator+(const difference_type _Off, const _Iterator& _It) + noexcept(noexcept(_STD declval&>() += _Off) + && is_nothrow_copy_constructible_v>) /* strengthened */ requires random_access_range<_Base> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -4937,9 +4929,9 @@ namespace ranges { return _Copy; } - _NODISCARD friend constexpr _Iterator operator-(const _Iterator& _It, const difference_type _Off) noexcept( - noexcept(_STD declval&>() -= _Off) - && is_nothrow_copy_constructible_v>) /* strengthened */ + _NODISCARD friend constexpr _Iterator operator-(const _Iterator& _It, const difference_type _Off) + noexcept(noexcept(_STD declval&>() -= _Off) + && is_nothrow_copy_constructible_v>) /* strengthened */ requires random_access_range<_Base> { #if _ITERATOR_DEBUG_LEVEL != 0 @@ -4951,8 +4943,8 @@ namespace ranges { return _Copy; } - _NODISCARD friend constexpr difference_type operator-(const _Iterator& _Left, - const _Iterator& _Right) noexcept(noexcept(_Left._Current - _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr difference_type operator-(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current - _Right._Current)) /* strengthened */ requires sized_sentinel_for, iterator_t<_Base>> { return _Left._Current - _Right._Current; @@ -4978,12 +4970,12 @@ namespace ranges { public: _Sentinel() = default; - constexpr explicit _Sentinel(sentinel_t<_Base> _Last_) noexcept( - is_nothrow_move_constructible_v>) // strengthened + constexpr explicit _Sentinel(sentinel_t<_Base> _Last_) + noexcept(is_nothrow_move_constructible_v>) // strengthened : _Last(_STD move(_Last_)) {} - constexpr _Sentinel(_Sentinel _Se) noexcept( - is_nothrow_constructible_v, sentinel_t<_Vw>>) // strengthened + constexpr _Sentinel(_Sentinel _Se) + noexcept(is_nothrow_constructible_v, sentinel_t<_Vw>>) // strengthened requires _Const && convertible_to, sentinel_t<_Base>> : _Last(_STD move(_Se._Last)) {} @@ -4994,32 +4986,32 @@ namespace ranges { template requires sentinel_for, _Maybe_const_iter<_OtherConst>> - _NODISCARD friend constexpr bool operator==(const _Iterator<_OtherConst>& _Left, - const _Sentinel& _Right) noexcept(noexcept(_Get_current(_Left) == _Right._Last)) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Iterator<_OtherConst>& _Left, const _Sentinel& _Right) + noexcept(noexcept(_Get_current(_Left) == _Right._Last)) /* strengthened */ { return _Get_current(_Left) == _Right._Last; } template requires sized_sentinel_for, _Maybe_const_iter<_OtherConst>> _NODISCARD friend constexpr range_difference_t<_Maybe_const<_OtherConst, _Vw>> operator-( - const _Iterator<_OtherConst>& _Left, - const _Sentinel& _Right) noexcept(noexcept(_Get_current(_Left) - _Right._Last)) /* strengthened */ { + const _Iterator<_OtherConst>& _Left, const _Sentinel& _Right) + noexcept(noexcept(_Get_current(_Left) - _Right._Last)) /* strengthened */ { return _Get_current(_Left) - _Right._Last; } template requires sized_sentinel_for, _Maybe_const_iter<_OtherConst>> - _NODISCARD friend constexpr range_difference_t<_Maybe_const<_OtherConst, _Vw>> - operator-(const _Sentinel& _Left, const _Iterator<_OtherConst>& _Right) noexcept( - noexcept(_Left._Last - _Get_current(_Right))) /* strengthened */ { + _NODISCARD friend constexpr range_difference_t<_Maybe_const<_OtherConst, _Vw>> operator-( + const _Sentinel& _Left, const _Iterator<_OtherConst>& _Right) + noexcept(noexcept(_Left._Last - _Get_current(_Right))) /* strengthened */ { return _Left._Last - _Get_current(_Right); } }; public: - // clang-format off - elements_view() requires default_initializable<_Vw> = default; - // clang-format on + elements_view() + requires default_initializable<_Vw> + = default; constexpr explicit elements_view(_Vw _Range_) noexcept(is_nothrow_move_constructible_v<_Vw>) // strengthened : _Range(_STD move(_Range_)) {} @@ -5141,24 +5133,24 @@ namespace ranges { /* [[no_unique_address]] */ _Base_iterator _Current{}; range_difference_t<_Base_t> _Pos = 0; - constexpr explicit _Iterator(_Base_iterator _Current_, range_difference_t<_Base_t> _Pos_) noexcept( - is_nothrow_move_constructible_v<_Base_iterator>) // strengthened + constexpr explicit _Iterator(_Base_iterator _Current_, range_difference_t<_Base_t> _Pos_) + noexcept(is_nothrow_move_constructible_v<_Base_iterator>) // strengthened : _Current(_STD move(_Current_)), _Pos(_Pos_) {} public: using iterator_category = input_iterator_tag; using iterator_concept = conditional_t, random_access_iterator_tag, - conditional_t, bidirectional_iterator_tag, - conditional_t, forward_iterator_tag, input_iterator_tag>>>; + conditional_t, bidirectional_iterator_tag, + conditional_t, forward_iterator_tag, input_iterator_tag>>>; using difference_type = range_difference_t<_Base_t>; using value_type = tuple>; - // clang-format off - _Iterator() requires default_initializable<_Base_iterator> = default; - // clang-format on + _Iterator() + requires default_initializable<_Base_iterator> + = default; - constexpr _Iterator(_Iterator _Other) noexcept( - is_nothrow_constructible_v<_Base_iterator, iterator_t<_Vw>>) // strengthened + constexpr _Iterator(_Iterator _Other) + noexcept(is_nothrow_constructible_v<_Base_iterator, iterator_t<_Vw>>) // strengthened requires _Const && convertible_to, _Base_iterator> : _Current(_STD move(_Other._Current)), _Pos(_Other._Pos) {} @@ -5190,8 +5182,8 @@ namespace ranges { ++*this; } - constexpr _Iterator operator++(int) noexcept( - noexcept(++*this) && is_nothrow_copy_constructible_v<_Iterator>) // strengthened + constexpr _Iterator operator++(int) + noexcept(noexcept(++*this) && is_nothrow_copy_constructible_v<_Iterator>) // strengthened requires forward_range<_Base_t> { auto _Tmp = *this; @@ -5207,8 +5199,8 @@ namespace ranges { return *this; } - constexpr _Iterator operator--(int) noexcept( - noexcept(--*this) && is_nothrow_copy_constructible_v<_Iterator>) // strengthened + constexpr _Iterator operator--(int) + noexcept(noexcept(--*this) && is_nothrow_copy_constructible_v<_Iterator>) // strengthened requires bidirectional_range<_Base_t> { auto _Tmp = *this; @@ -5216,8 +5208,8 @@ namespace ranges { return _Tmp; } - constexpr _Iterator& operator+=(const difference_type _Off) noexcept( - noexcept(_Current += _Off)) // strengthened + constexpr _Iterator& operator+=(const difference_type _Off) + noexcept(noexcept(_Current += _Off)) // strengthened requires random_access_range<_Base_t> { _Current += _Off; @@ -5225,8 +5217,8 @@ namespace ranges { return *this; } - constexpr _Iterator& operator-=(const difference_type _Off) noexcept( - noexcept(_Current -= _Off)) // strengthened + constexpr _Iterator& operator-=(const difference_type _Off) + noexcept(noexcept(_Current -= _Off)) // strengthened requires random_access_range<_Base_t> { _Current -= _Off; @@ -5250,9 +5242,9 @@ namespace ranges { return _Left._Pos <=> _Right._Pos; } - _NODISCARD friend constexpr _Iterator operator+(const _Iterator& _It, const difference_type _Off) noexcept( - is_nothrow_copy_constructible_v<_Iterator> // - && noexcept(_STD declval<_Iterator&>() += _Off)) // strengthened + _NODISCARD friend constexpr _Iterator operator+(const _Iterator& _It, const difference_type _Off) + noexcept(is_nothrow_copy_constructible_v<_Iterator> + && noexcept(_STD declval<_Iterator&>() += _Off)) // strengthened requires random_access_range<_Base_t> { auto _Tmp = _It; @@ -5260,16 +5252,16 @@ namespace ranges { return _Tmp; } - _NODISCARD friend constexpr _Iterator operator+(const difference_type _Off, const _Iterator& _It) noexcept( - noexcept(_It + _Off)) // strengthened + _NODISCARD friend constexpr _Iterator operator+(const difference_type _Off, const _Iterator& _It) + noexcept(noexcept(_It + _Off)) // strengthened requires random_access_range<_Base_t> { return _It + _Off; } - _NODISCARD friend constexpr _Iterator operator-(const _Iterator& _It, const difference_type _Off) noexcept( - is_nothrow_copy_constructible_v<_Iterator> // - && noexcept(_STD declval<_Iterator&>() -= _Off)) // strengthened + _NODISCARD friend constexpr _Iterator operator-(const _Iterator& _It, const difference_type _Off) + noexcept(is_nothrow_copy_constructible_v<_Iterator> + && noexcept(_STD declval<_Iterator&>() -= _Off)) // strengthened requires random_access_range<_Base_t> { auto _Tmp = _It; @@ -5282,9 +5274,9 @@ namespace ranges { return _Left._Pos - _Right._Pos; } - _NODISCARD friend constexpr auto iter_move(const _Iterator& _It) noexcept( - noexcept(_RANGES iter_move(_It._Current)) - && is_nothrow_move_constructible_v>) { + _NODISCARD friend constexpr auto iter_move(const _Iterator& _It) + noexcept(noexcept(_RANGES iter_move(_It._Current)) + && is_nothrow_move_constructible_v>) { return tuple>{ _It._Pos, _RANGES iter_move(_It._Current)}; } @@ -5300,8 +5292,8 @@ namespace ranges { /* [[no_unique_address]] */ _Base_sentinel _End{}; - constexpr explicit _Sentinel(_Base_sentinel _End_) noexcept( - is_nothrow_move_constructible_v<_Base_sentinel>) // strengthened + constexpr explicit _Sentinel(_Base_sentinel _End_) + noexcept(is_nothrow_move_constructible_v<_Base_sentinel>) // strengthened : _End(_STD move(_End_)) {} template @@ -5321,8 +5313,8 @@ namespace ranges { public: _Sentinel() = default; - constexpr _Sentinel(_Sentinel _Other) noexcept( - is_nothrow_constructible_v<_Base_sentinel, sentinel_t<_Vw>>) // strengthened + constexpr _Sentinel(_Sentinel _Other) + noexcept(is_nothrow_constructible_v<_Base_sentinel, sentinel_t<_Vw>>) // strengthened requires _Const && convertible_to, _Base_sentinel> : _End(_STD move(_Other._End)) {} @@ -5333,8 +5325,8 @@ namespace ranges { template requires sentinel_for<_Base_sentinel, iterator_t<_Maybe_const<_OtherConst, _Vw>>> - _NODISCARD friend constexpr bool operator==(const _Iterator<_OtherConst>& _It, - const _Sentinel& _Se) noexcept(noexcept(_Se._Equal(_It))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Iterator<_OtherConst>& _It, const _Sentinel& _Se) + noexcept(noexcept(_Se._Equal(_It))) /* strengthened */ { return _Se._Equal(_It); } @@ -5357,18 +5349,18 @@ namespace ranges { template static constexpr bool _Is_end_nothrow_v = is_nothrow_move_constructible_v> // - && noexcept(_RANGES end(_STD declval<_Rng&>())); + && noexcept(_RANGES end(_STD declval<_Rng&>())); template requires common_range<_Rng> && sized_range<_Rng> static constexpr bool _Is_end_nothrow_v<_Rng> = is_nothrow_move_constructible_v> // - && noexcept(_RANGES end(_STD declval<_Rng&>())) // - && noexcept(_RANGES distance(_STD declval<_Rng&>())); + && noexcept(_RANGES end(_STD declval<_Rng&>())) // + && noexcept(_RANGES distance(_STD declval<_Rng&>())); public: - // clang-format off - constexpr enumerate_view() requires default_initializable<_Vw> = default; - // clang-format on + constexpr enumerate_view() + requires default_initializable<_Vw> + = default; constexpr explicit enumerate_view(_Vw _Range_) noexcept(is_nothrow_move_constructible_v<_Vw>) // strengthened : _Range(_STD move(_Range_)) {} @@ -5515,8 +5507,9 @@ namespace ranges { return **_Parent->_Current; } - constexpr _Inner_iterator& operator++() noexcept(noexcept(++*_Parent->_Current) && noexcept( - static_cast(*_Parent->_Current == _RANGES end(_Parent->_Range)))) /* strengthened */ { + constexpr _Inner_iterator& operator++() noexcept( + noexcept(++*_Parent->_Current) + && noexcept(static_cast(*_Parent->_Current == _RANGES end(_Parent->_Range)))) /* strengthened */ { #if _ITERATOR_DEBUG_LEVEL != 0 _STL_VERIFY(*this != default_sentinel, "cannot increment chunk_view end iterator"); #endif // _ITERATOR_DEBUG_LEVEL != 0 @@ -5530,8 +5523,9 @@ namespace ranges { return *this; } - constexpr void operator++(int) noexcept(noexcept(++*_Parent->_Current) && noexcept( - static_cast(*_Parent->_Current == _RANGES end(_Parent->_Range)))) /* strengthened */ { + constexpr void operator++(int) noexcept( + noexcept(++*_Parent->_Current) + && noexcept(static_cast(*_Parent->_Current == _RANGES end(_Parent->_Range)))) /* strengthened */ { #if _ITERATOR_DEBUG_LEVEL != 0 _STL_VERIFY(*this != default_sentinel, "cannot increment chunk_view end iterator"); #endif // _ITERATOR_DEBUG_LEVEL != 0 @@ -5548,27 +5542,27 @@ namespace ranges { return _Left._Get_remainder() == 0; } - _NODISCARD friend constexpr difference_type operator-(default_sentinel_t, - const _Inner_iterator& _Right) noexcept(noexcept(_Right._Get_size())) /* strengthened */ + _NODISCARD friend constexpr difference_type operator-(default_sentinel_t, const _Inner_iterator& _Right) + noexcept(noexcept(_Right._Get_size())) /* strengthened */ requires sized_sentinel_for, iterator_t<_Vw>> { return _Right._Get_size(); } - _NODISCARD friend constexpr difference_type operator-(const _Inner_iterator& _Left, - default_sentinel_t) noexcept(noexcept(_Left._Get_size())) /* strengthened */ + _NODISCARD friend constexpr difference_type operator-(const _Inner_iterator& _Left, default_sentinel_t) + noexcept(noexcept(_Left._Get_size())) /* strengthened */ requires sized_sentinel_for, iterator_t<_Vw>> { return -_Left._Get_size(); } - _NODISCARD friend constexpr range_rvalue_reference_t<_Vw> iter_move(const _Inner_iterator& _It) noexcept( - noexcept(_RANGES iter_move(_It._Get_current()))) { + _NODISCARD friend constexpr range_rvalue_reference_t<_Vw> iter_move(const _Inner_iterator& _It) + noexcept(noexcept(_RANGES iter_move(_It._Get_current()))) { return _RANGES iter_move(_It._Get_current()); } - friend constexpr void iter_swap(const _Inner_iterator& _Left, const _Inner_iterator& _Right) noexcept( - noexcept(_RANGES iter_swap(_Left._Get_current(), _Right._Get_current()))) + friend constexpr void iter_swap(const _Inner_iterator& _Left, const _Inner_iterator& _Right) + noexcept(noexcept(_RANGES iter_swap(_Left._Get_current(), _Right._Get_current()))) requires indirectly_swappable> { _RANGES iter_swap(_Left._Get_current(), _Right._Get_current()); @@ -5652,20 +5646,20 @@ namespace ranges { _Parent->_Remainder = _Parent->_Count; } - _NODISCARD friend constexpr bool operator==(const _Outer_iterator& _Left, default_sentinel_t) noexcept( - noexcept(_Left._Is_end())) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Outer_iterator& _Left, default_sentinel_t) + noexcept(noexcept(_Left._Is_end())) /* strengthened */ { return _Left._Is_end(); } - _NODISCARD friend constexpr difference_type operator-(default_sentinel_t, - const _Outer_iterator& _Right) noexcept(noexcept(_Right._Get_size())) /* strengthened */ + _NODISCARD friend constexpr difference_type operator-(default_sentinel_t, const _Outer_iterator& _Right) + noexcept(noexcept(_Right._Get_size())) /* strengthened */ requires sized_sentinel_for, iterator_t<_Vw>> { return _Right._Get_size(); } - _NODISCARD friend constexpr difference_type operator-(const _Outer_iterator& _Left, - default_sentinel_t) noexcept(noexcept(_Left._Get_size())) /* strengthened */ + _NODISCARD friend constexpr difference_type operator-(const _Outer_iterator& _Left, default_sentinel_t) + noexcept(noexcept(_Left._Get_size())) /* strengthened */ requires sized_sentinel_for, iterator_t<_Vw>> { return -_Left._Get_size(); @@ -5673,8 +5667,8 @@ namespace ranges { }; public: - constexpr explicit chunk_view(_Vw _Range_, const range_difference_t<_Vw> _Count_) noexcept( - is_nothrow_move_constructible_v<_Vw>) /* strengthened */ + constexpr explicit chunk_view(_Vw _Range_, const range_difference_t<_Vw> _Count_) + noexcept(is_nothrow_move_constructible_v<_Vw>) /* strengthened */ : _Range(_STD move(_Range_)), _Count{_Count_} { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Count > 0, "chunk size must be greater than 0"); @@ -5691,8 +5685,8 @@ namespace ranges { return _STD move(_Range); } - _NODISCARD constexpr _Outer_iterator begin() noexcept( - noexcept(_Current._Emplace(_RANGES begin(_Range)))) /* strengthened */ { + _NODISCARD constexpr _Outer_iterator begin() + noexcept(noexcept(_Current._Emplace(_RANGES begin(_Range)))) /* strengthened */ { _Current._Emplace(_RANGES begin(_Range)); _Remainder = _Count; return _Outer_iterator{this}; @@ -5747,16 +5741,16 @@ namespace ranges { public: using iterator_category = input_iterator_tag; using iterator_concept = conditional_t, random_access_iterator_tag, - conditional_t, bidirectional_iterator_tag, forward_iterator_tag>>; + conditional_t, bidirectional_iterator_tag, forward_iterator_tag>>; using value_type = decltype(views::take(subrange(_Current, _End), _Count)); using difference_type = range_difference_t<_Base>; _Iterator() = default; - constexpr _Iterator(_Iterator _Other) noexcept( - is_nothrow_constructible_v<_Base_iterator, typename _Iterator::_Base_iterator> // - && is_nothrow_constructible_v<_Base_sentinel, typename _Iterator::_Base_sentinel> // - ) /* strengthened */ + constexpr _Iterator(_Iterator _Other) + noexcept(is_nothrow_constructible_v<_Base_iterator, typename _Iterator::_Base_iterator> + && is_nothrow_constructible_v<_Base_sentinel, + typename _Iterator::_Base_sentinel>) /* strengthened */ requires _Const && convertible_to, _Base_iterator> && convertible_to, _Base_sentinel> : _Current(_STD move(_Other._Current)), _End(_STD move(_Other._End)), _Count(_Other._Count), @@ -5848,54 +5842,54 @@ namespace ranges { return *(*this + _Off); } - _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left._Current == _Right._Current))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left._Current == _Right._Current))) /* strengthened */ { return _Left._Current == _Right._Current; } - _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, default_sentinel_t) noexcept( - noexcept(_STD _Fake_copy_init(_Left._Current == _Left._End))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, default_sentinel_t) + noexcept(noexcept(_STD _Fake_copy_init(_Left._Current == _Left._End))) /* strengthened */ { return _Left._Current == _Left._End; } - _NODISCARD friend constexpr bool operator<(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left._Current < _Right._Current))) /* strengthened */ + _NODISCARD friend constexpr bool operator<(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left._Current < _Right._Current))) /* strengthened */ requires random_access_range<_Base> { return _Left._Current < _Right._Current; } - _NODISCARD friend constexpr bool operator>(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Right._Current < _Left._Current))) /* strengthened */ + _NODISCARD friend constexpr bool operator>(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Right._Current < _Left._Current))) /* strengthened */ requires random_access_range<_Base> { return _Right._Current < _Left._Current; } - _NODISCARD friend constexpr bool operator<=(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(!(_Right._Current < _Left._Current)))) /* strengthened */ + _NODISCARD friend constexpr bool operator<=(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(!(_Right._Current < _Left._Current)))) /* strengthened */ requires random_access_range<_Base> { return !(_Right._Current < _Left._Current); } - _NODISCARD friend constexpr bool operator>=(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(!(_Left._Current < _Right._Current)))) /* strengthened */ + _NODISCARD friend constexpr bool operator>=(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(!(_Left._Current < _Right._Current)))) /* strengthened */ requires random_access_range<_Base> { return !(_Left._Current < _Right._Current); } - _NODISCARD friend constexpr auto operator<=>(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Current <=> _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr auto operator<=>(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current <=> _Right._Current)) /* strengthened */ requires random_access_range<_Base> && three_way_comparable<_Base_iterator> { return _Left._Current <=> _Right._Current; } - _NODISCARD friend constexpr _Iterator operator+(const _Iterator& _It, const difference_type _Off) noexcept( - is_nothrow_copy_constructible_v<_Iterator> // - && noexcept(_STD declval<_Iterator&>() += _Off)) /* strengthened */ + _NODISCARD friend constexpr _Iterator operator+(const _Iterator& _It, const difference_type _Off) + noexcept(is_nothrow_copy_constructible_v<_Iterator> + && noexcept(_STD declval<_Iterator&>() += _Off)) /* strengthened */ requires random_access_range<_Base> { auto _Copy = _It; @@ -5903,9 +5897,9 @@ namespace ranges { return _Copy; } - _NODISCARD friend constexpr _Iterator operator+(const difference_type _Off, const _Iterator& _It) noexcept( - is_nothrow_copy_constructible_v<_Iterator> // - && noexcept(_STD declval<_Iterator&>() += _Off)) /* strengthened */ + _NODISCARD friend constexpr _Iterator operator+(const difference_type _Off, const _Iterator& _It) + noexcept(is_nothrow_copy_constructible_v<_Iterator> + && noexcept(_STD declval<_Iterator&>() += _Off)) /* strengthened */ requires random_access_range<_Base> { auto _Copy = _It; @@ -5913,9 +5907,9 @@ namespace ranges { return _Copy; } - _NODISCARD friend constexpr _Iterator operator-(const _Iterator& _It, const difference_type _Off) noexcept( - is_nothrow_copy_constructible_v<_Iterator> // - && noexcept(_STD declval<_Iterator&>() -= _Off)) /* strengthened */ + _NODISCARD friend constexpr _Iterator operator-(const _Iterator& _It, const difference_type _Off) + noexcept(is_nothrow_copy_constructible_v<_Iterator> + && noexcept(_STD declval<_Iterator&>() -= _Off)) /* strengthened */ requires random_access_range<_Base> { auto _Copy = _It; @@ -5923,22 +5917,22 @@ namespace ranges { return _Copy; } - _NODISCARD friend constexpr difference_type operator-(const _Iterator& _Left, - const _Iterator& _Right) noexcept(noexcept(_Left._Current - _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr difference_type operator-(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current - _Right._Current)) /* strengthened */ requires sized_sentinel_for<_Base_iterator, _Base_iterator> { return (_Left._Current - _Right._Current + _Left._Missing - _Right._Missing) / _Left._Count; } - _NODISCARD friend constexpr difference_type operator-(default_sentinel_t, const _Iterator& _Right) noexcept( - noexcept(_Right._End - _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr difference_type operator-(default_sentinel_t, const _Iterator& _Right) + noexcept(noexcept(_Right._End - _Right._Current)) /* strengthened */ requires sized_sentinel_for<_Base_sentinel, _Base_iterator> { return _Div_ceil(_Right._End - _Right._Current, _Right._Count); } - _NODISCARD friend constexpr difference_type operator-(const _Iterator& _Left, default_sentinel_t) noexcept( - noexcept(_Left._End - _Left._Current)) /* strengthened */ + _NODISCARD friend constexpr difference_type operator-(const _Iterator& _Left, default_sentinel_t) + noexcept(noexcept(_Left._End - _Left._Current)) /* strengthened */ requires sized_sentinel_for<_Base_sentinel, _Base_iterator> { return -_Div_ceil(_Left._End - _Left._Current, _Left._Count); @@ -5946,8 +5940,8 @@ namespace ranges { }; public: - constexpr explicit chunk_view(_Vw _Range_, const range_difference_t<_Vw> _Count_) noexcept( - is_nothrow_move_constructible_v<_Vw>) /* strengthened */ + constexpr explicit chunk_view(_Vw _Range_, const range_difference_t<_Vw> _Count_) + noexcept(is_nothrow_move_constructible_v<_Vw>) /* strengthened */ : _Range(_STD move(_Range_)), _Count{_Count_} { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Count > 0, "chunk size must be greater than 0"); @@ -6089,8 +6083,8 @@ namespace ranges { public: _Iter_base() = default; - constexpr explicit _Iter_base(_Base_iterator _Last_element_) noexcept( - is_nothrow_move_constructible_v<_Base_iterator>) + constexpr explicit _Iter_base(_Base_iterator _Last_element_) + noexcept(is_nothrow_move_constructible_v<_Base_iterator>) : _Last_element{_STD move(_Last_element_)} {} _NODISCARD constexpr const _Base_iterator& _Get_last_element() const noexcept { @@ -6109,8 +6103,8 @@ namespace ranges { /* [[no_unique_address]] */ _Base_iterator _Current{}; range_difference_t<_Base> _Count = 0; - constexpr _Iterator(_Base_iterator _Current_, range_difference_t<_Base> _Count_) noexcept( - is_nothrow_move_constructible_v<_Base_iterator>) /* strengthened */ + constexpr _Iterator(_Base_iterator _Current_, range_difference_t<_Base> _Count_) + noexcept(is_nothrow_move_constructible_v<_Base_iterator>) /* strengthened */ requires (!_Slide_caches_first<_Base>) : _Current(_STD move(_Current_)), _Count(_Count_) {} @@ -6124,12 +6118,12 @@ namespace ranges { using difference_type = range_difference_t<_Base>; using iterator_category = input_iterator_tag; using iterator_concept = conditional_t, random_access_iterator_tag, - conditional_t, bidirectional_iterator_tag, forward_iterator_tag>>; + conditional_t, bidirectional_iterator_tag, forward_iterator_tag>>; _Iterator() = default; - constexpr _Iterator(_Iterator _Other) noexcept( - is_nothrow_constructible_v<_Base_iterator, iterator_t<_Vw>>) // strengthened + constexpr _Iterator(_Iterator _Other) + noexcept(is_nothrow_constructible_v<_Base_iterator, iterator_t<_Vw>>) // strengthened requires _Const && convertible_to, _Base_iterator> : _Current(_STD move(_Other._Current)), _Count(_Other._Count) {} @@ -6148,7 +6142,7 @@ namespace ranges { } constexpr _Iterator operator++(int) noexcept(is_nothrow_copy_constructible_v<_Base_iterator> // - && noexcept(++_Current)) /* strengthened */ { + && noexcept(++_Current)) /* strengthened */ { auto _Tmp = *this; ++*this; return _Tmp; @@ -6166,7 +6160,7 @@ namespace ranges { } constexpr _Iterator operator--(int) noexcept(is_nothrow_copy_constructible_v<_Base_iterator> // - && noexcept(--_Current)) /* strengthened */ + && noexcept(--_Current)) /* strengthened */ requires bidirectional_range<_Base> { auto _Tmp = *this; @@ -6174,8 +6168,8 @@ namespace ranges { return _Tmp; } - constexpr _Iterator& operator+=(const difference_type _Off) noexcept( - noexcept(_Current += _Off)) /* strengthened */ + constexpr _Iterator& operator+=(const difference_type _Off) + noexcept(noexcept(_Current += _Off)) /* strengthened */ requires random_access_range<_Base> { _Current += _Off; @@ -6186,8 +6180,8 @@ namespace ranges { return *this; } - constexpr _Iterator& operator-=(const difference_type _Off) noexcept( - noexcept(_Current -= _Off)) /* strengthened */ + constexpr _Iterator& operator-=(const difference_type _Off) + noexcept(noexcept(_Current -= _Off)) /* strengthened */ requires random_access_range<_Base> { _Current -= _Off; @@ -6205,8 +6199,8 @@ namespace ranges { return views::counted(_Current + _Off, _Count); } - _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left._Current == _Right._Current))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left._Current == _Right._Current))) /* strengthened */ { if constexpr (_Slide_caches_first<_Base>) { return _Left._Last_element == _Right._Last_element; } else { @@ -6214,43 +6208,43 @@ namespace ranges { } } - _NODISCARD friend constexpr bool operator<(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left._Current < _Right._Current))) /* strengthened */ + _NODISCARD friend constexpr bool operator<(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left._Current < _Right._Current))) /* strengthened */ requires random_access_range<_Base> { return _Left._Current < _Right._Current; } - _NODISCARD friend constexpr bool operator>(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Right._Current < _Left._Current))) /* strengthened */ + _NODISCARD friend constexpr bool operator>(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Right._Current < _Left._Current))) /* strengthened */ requires random_access_range<_Base> { return _Right._Current < _Left._Current; } - _NODISCARD friend constexpr bool operator<=(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(!(_Right._Current < _Left._Current)))) /* strengthened */ + _NODISCARD friend constexpr bool operator<=(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(!(_Right._Current < _Left._Current)))) /* strengthened */ requires random_access_range<_Base> { return !(_Right._Current < _Left._Current); } - _NODISCARD friend constexpr bool operator>=(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(!(_Left._Current < _Right._Current)))) /* strengthened */ + _NODISCARD friend constexpr bool operator>=(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(!(_Left._Current < _Right._Current)))) /* strengthened */ requires random_access_range<_Base> { return !(_Left._Current < _Right._Current); } - _NODISCARD friend constexpr auto operator<=>(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Current <=> _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr auto operator<=>(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current <=> _Right._Current)) /* strengthened */ requires random_access_range<_Base> && three_way_comparable<_Base_iterator> { return _Left._Current <=> _Right._Current; } - _NODISCARD friend constexpr _Iterator operator+(const _Iterator& _It, const difference_type _Off) noexcept( - noexcept(_STD declval<_Iterator&>() += _Off)) /* strengthened */ + _NODISCARD friend constexpr _Iterator operator+(const _Iterator& _It, const difference_type _Off) + noexcept(noexcept(_STD declval<_Iterator&>() += _Off)) /* strengthened */ requires random_access_range<_Base> { auto _Copy = _It; @@ -6258,8 +6252,8 @@ namespace ranges { return _Copy; } - _NODISCARD friend constexpr _Iterator operator+(const difference_type _Off, const _Iterator& _It) noexcept( - noexcept(_STD declval<_Iterator&>() += _Off)) /* strengthened */ + _NODISCARD friend constexpr _Iterator operator+(const difference_type _Off, const _Iterator& _It) + noexcept(noexcept(_STD declval<_Iterator&>() += _Off)) /* strengthened */ requires random_access_range<_Base> { auto _Copy = _It; @@ -6267,8 +6261,8 @@ namespace ranges { return _Copy; } - _NODISCARD friend constexpr _Iterator operator-(const _Iterator& _It, const difference_type _Off) noexcept( - noexcept(_STD declval<_Iterator&>() -= _Off)) /* strengthened */ + _NODISCARD friend constexpr _Iterator operator-(const _Iterator& _It, const difference_type _Off) + noexcept(noexcept(_STD declval<_Iterator&>() -= _Off)) /* strengthened */ requires random_access_range<_Base> { auto _Copy = _It; @@ -6276,8 +6270,8 @@ namespace ranges { return _Copy; } - _NODISCARD friend constexpr difference_type operator-(const _Iterator& _Left, - const _Iterator& _Right) noexcept(noexcept(_Left._Current - _Right._Current)) /* strengthened */ + _NODISCARD friend constexpr difference_type operator-(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current - _Right._Current)) /* strengthened */ requires sized_sentinel_for<_Base_iterator, _Base_iterator> { if constexpr (_Slide_caches_first<_Base>) { @@ -6293,15 +6287,15 @@ namespace ranges { friend slide_view; /* [[no_unique_address]] */ sentinel_t<_Vw> _Last{}; - constexpr explicit _Sentinel(sentinel_t<_Vw> _Last_) noexcept( - is_nothrow_move_constructible_v>) /* strengthened */ + constexpr explicit _Sentinel(sentinel_t<_Vw> _Last_) + noexcept(is_nothrow_move_constructible_v>) /* strengthened */ : _Last(_STD move(_Last_)) {} public: _Sentinel() = default; - _NODISCARD friend constexpr bool - operator==(const _Iterator& _Left, const _Sentinel& _Right) noexcept(noexcept( + _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Sentinel& _Right) + noexcept(noexcept( _STD _Fake_copy_init(_Left._Get_last_element() == _Right._Last))) /* strengthened */ { return _Left._Get_last_element() == _Right._Last; } @@ -6313,9 +6307,9 @@ namespace ranges { return _Left._Get_last_element() - _Right._Last; } - _NODISCARD friend constexpr range_difference_t<_Vw> - operator-(const _Sentinel& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Last - _Right._Get_last_element())) /* strengthened */ + _NODISCARD friend constexpr range_difference_t<_Vw> operator-( + const _Sentinel& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Last - _Right._Get_last_element())) /* strengthened */ requires sized_sentinel_for, iterator_t<_Vw>> { return _Left._Last - _Right._Get_last_element(); @@ -6323,8 +6317,8 @@ namespace ranges { }; public: - constexpr explicit slide_view(_Vw _Range_, const range_difference_t<_Vw> _Count_) noexcept( - is_nothrow_move_constructible_v<_Vw>) /* strengthened */ + constexpr explicit slide_view(_Vw _Range_, const range_difference_t<_Vw> _Count_) + noexcept(is_nothrow_move_constructible_v<_Vw>) /* strengthened */ : _Range(_STD move(_Range_)), _Count{_Count_} { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Count > 0, "The window size must be positive (N4950 [range.slide.view]/1)"); @@ -6391,8 +6385,9 @@ namespace ranges { } } - _NODISCARD constexpr auto end() const noexcept(is_nothrow_move_constructible_v> // - && noexcept(_RANGES distance(_Range)) && noexcept(_RANGES begin(_Range) + _Count)) /* strengthened */ + _NODISCARD constexpr auto end() const + noexcept(is_nothrow_move_constructible_v> && noexcept(_RANGES distance(_Range)) + && noexcept(_RANGES begin(_Range) + _Count)) /* strengthened */ requires _Slide_caches_nothing { const auto _Size = _RANGES distance(_Range) - (_Count - 1); @@ -6494,8 +6489,8 @@ namespace ranges { /* [[no_unique_address]] */ iterator_t<_Vw> _Current{}; /* [[no_unique_address]] */ iterator_t<_Vw> _Next{}; - constexpr _Iterator(chunk_by_view& _Parent_, iterator_t<_Vw> _Current_, iterator_t<_Vw> _Next_) noexcept( - is_nothrow_move_constructible_v>) // strengthened + constexpr _Iterator(chunk_by_view& _Parent_, iterator_t<_Vw> _Current_, iterator_t<_Vw> _Next_) + noexcept(is_nothrow_move_constructible_v>) // strengthened : _Parent(_STD addressof(_Parent_)), _Current(_STD move(_Current_)), _Next(_STD move(_Next_)) {} public: @@ -6551,13 +6546,13 @@ namespace ranges { return _Tmp; } - _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left._Current == _Right._Current))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left._Current == _Right._Current))) /* strengthened */ { return _Left._Current == _Right._Current; } - _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, default_sentinel_t) noexcept( - noexcept(_STD _Fake_copy_init(_Left._Current == _Left._Next))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, default_sentinel_t) + noexcept(noexcept(_STD _Fake_copy_init(_Left._Current == _Left._Next))) /* strengthened */ { return _Left._Current == _Left._Next; } }; @@ -6583,12 +6578,12 @@ namespace ranges { } public: - // clang-format off - chunk_by_view() requires default_initializable<_Vw> && default_initializable<_Pr> = default; - // clang-format on + chunk_by_view() + requires default_initializable<_Vw> && default_initializable<_Pr> + = default; - constexpr explicit chunk_by_view(_Vw _Range_, _Pr _Pred_) noexcept( - is_nothrow_move_constructible_v<_Vw> && is_nothrow_move_constructible_v<_Pr>) // strengthened + constexpr explicit chunk_by_view(_Vw _Range_, _Pr _Pred_) + noexcept(is_nothrow_move_constructible_v<_Vw> && is_nothrow_move_constructible_v<_Pr>) // strengthened : _Range(_STD move(_Range_)), _Pred{in_place, _STD move(_Pred_)} {} _NODISCARD constexpr _Vw base() const& noexcept(is_nothrow_copy_constructible_v<_Vw>) /* strengthened */ @@ -6708,14 +6703,13 @@ namespace ranges { conditional_t, bidirectional_iterator_tag, conditional_t, forward_iterator_tag, input_iterator_tag>>>; - // clang-format off - _Iterator() requires default_initializable<_Base_iterator> = default; - // clang-format on + _Iterator() + requires default_initializable<_Base_iterator> + = default; - constexpr _Iterator(_Iterator _Other) noexcept( - is_nothrow_constructible_v<_Base_iterator, iterator_t<_Vw>> // - && is_nothrow_constructible_v<_Base_sentinel, sentinel_t<_Vw>> // - ) /* strengthened */ + constexpr _Iterator(_Iterator _Other) + noexcept(is_nothrow_constructible_v<_Base_iterator, iterator_t<_Vw>> + && is_nothrow_constructible_v<_Base_sentinel, sentinel_t<_Vw>>) /* strengthened */ requires _Const && convertible_to, _Base_iterator> && convertible_to, _Base_sentinel> : _Current(_STD move(_Other._Current)), _End(_STD move(_Other._End)), _Stride(_Other._Stride), @@ -6816,48 +6810,48 @@ namespace ranges { return *(*this + _Off); } - _NODISCARD friend constexpr bool operator==(const _Iterator& _It, default_sentinel_t) noexcept( - noexcept(_STD _Fake_copy_init(_It._Current == _It._End))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Iterator& _It, default_sentinel_t) + noexcept(noexcept(_STD _Fake_copy_init(_It._Current == _It._End))) /* strengthened */ { return _It._Current == _It._End; } - _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left._Current == _Right._Current))) // strengthened + _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left._Current == _Right._Current))) // strengthened requires equality_comparable<_Base_iterator> { return _Left._Current == _Right._Current; } - _NODISCARD friend constexpr bool operator<(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left._Current < _Right._Current))) // strengthened + _NODISCARD friend constexpr bool operator<(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left._Current < _Right._Current))) // strengthened requires random_access_range<_Base> { return _Left._Current < _Right._Current; } - _NODISCARD friend constexpr bool operator>(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Right._Current < _Left._Current))) // strengthened + _NODISCARD friend constexpr bool operator>(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Right._Current < _Left._Current))) // strengthened requires random_access_range<_Base> { return _Right._Current < _Left._Current; } - _NODISCARD friend constexpr bool operator<=(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(!(_Right._Current < _Left._Current)))) // strengthened + _NODISCARD friend constexpr bool operator<=(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(!(_Right._Current < _Left._Current)))) // strengthened requires random_access_range<_Base> { return !(_Right._Current < _Left._Current); } - _NODISCARD friend constexpr bool operator>=(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(!(_Left._Current < _Right._Current)))) // strengthened + _NODISCARD friend constexpr bool operator>=(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(!(_Left._Current < _Right._Current)))) // strengthened requires random_access_range<_Base> { return !(_Left._Current < _Right._Current); } - _NODISCARD friend constexpr auto operator<=>(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Current <=> _Right._Current)) // strengthened + _NODISCARD friend constexpr auto operator<=>(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current <=> _Right._Current)) // strengthened requires random_access_range<_Base> && three_way_comparable<_Base_iterator> { return _Left._Current <=> _Right._Current; @@ -6903,27 +6897,27 @@ namespace ranges { } } - _NODISCARD friend constexpr difference_type operator-(default_sentinel_t, const _Iterator& _It) noexcept( - noexcept(_It._End - _It._Current)) // strengthened + _NODISCARD friend constexpr difference_type operator-(default_sentinel_t, const _Iterator& _It) + noexcept(noexcept(_It._End - _It._Current)) // strengthened requires sized_sentinel_for<_Base_sentinel, _Base_iterator> { return _Div_ceil(_It._End - _It._Current, _It._Stride); } - _NODISCARD friend constexpr difference_type operator-(const _Iterator& _It, default_sentinel_t) noexcept( - noexcept(_It._End - _It._Current)) // strengthened + _NODISCARD friend constexpr difference_type operator-(const _Iterator& _It, default_sentinel_t) + noexcept(noexcept(_It._End - _It._Current)) // strengthened requires sized_sentinel_for<_Base_sentinel, _Base_iterator> { return -_Div_ceil(_It._End - _It._Current, _It._Stride); } - _NODISCARD friend constexpr range_rvalue_reference_t<_Base> iter_move(const _Iterator& _It) noexcept( - noexcept(_RANGES iter_move(_It._Current))) { + _NODISCARD friend constexpr range_rvalue_reference_t<_Base> iter_move(const _Iterator& _It) + noexcept(noexcept(_RANGES iter_move(_It._Current))) { return _RANGES iter_move(_It._Current); } - friend constexpr void iter_swap(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_RANGES iter_swap(_Left._Current, _Right._Current))) + friend constexpr void iter_swap(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_RANGES iter_swap(_Left._Current, _Right._Current))) requires indirectly_swappable<_Base_iterator> { return _RANGES iter_swap(_Left._Current, _Right._Current); @@ -6931,8 +6925,8 @@ namespace ranges { }; public: - constexpr explicit stride_view(_Vw _Range_, range_difference_t<_Vw> _Stride_) noexcept( - is_nothrow_move_constructible_v<_Vw>) // strengthened + constexpr explicit stride_view(_Vw _Range_, range_difference_t<_Vw> _Stride_) + noexcept(is_nothrow_move_constructible_v<_Vw>) // strengthened : _Range(_STD move(_Range_)), _Stride(_Stride_) { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Stride > 0, "stride must be greater than 0"); @@ -7128,13 +7122,11 @@ namespace ranges { requires (sizeof...(_LHSTupleTypes) == sizeof...(_RHSTupleTypes)) _NODISCARD constexpr bool _Zip_iterator_sentinel_equal( const tuple<_LHSTupleTypes...>& _Lhs_tuple, const tuple<_RHSTupleTypes...>& _Rhs_tuple) - // clang-format off noexcept((noexcept(_STD declval() == _STD declval()) && ...)) { - // clang-format on const auto _Evaluate_equality_closure = [&_Lhs_tuple, &_Rhs_tuple](index_sequence<_Indices...>) noexcept( (noexcept(_STD declval() == _STD declval())&&...)) { - return ((_STD get<_Indices>(_Lhs_tuple) == _STD get<_Indices>(_Rhs_tuple)) || ...); + return ((_STD get<_Indices>(_Lhs_tuple) == _STD get<_Indices>(_Rhs_tuple)) || ... || false); }; return _Evaluate_equality_closure(index_sequence_for<_LHSTupleTypes...>{}); @@ -7166,7 +7158,7 @@ namespace ranges { private: friend zip_view; -#ifdef __clang__ // TRANSITION, LLVM-61763 +#ifdef __clang__ // TRANSITION, need to reduce and report (was thought to be LLVM-61763) public: #else // ^^^ workaround / no workaround vvv template @@ -7178,8 +7170,8 @@ namespace ranges { /* [[no_unique_address]] */ _My_tuple _Current; - constexpr explicit _Iterator(_My_tuple _Current_) noexcept( - is_nothrow_move_constructible_v<_My_tuple>) // strengthened + constexpr explicit _Iterator(_My_tuple _Current_) + noexcept(is_nothrow_move_constructible_v<_My_tuple>) // strengthened : _Current(_STD move(_Current_)) {} public: @@ -7245,10 +7237,10 @@ namespace ranges { return _Temp; } - constexpr _Iterator& operator+=(const difference_type _Off) noexcept( - (noexcept(_STD declval>&>() += - static_cast>>>(_Off)) - && ...)) // strengthened + constexpr _Iterator& operator+=(const difference_type _Off) + noexcept((noexcept(_STD declval>&>() += + static_cast>>>(_Off)) + && ...)) // strengthened requires _All_random_access<_IsConst, _ViewTypes...> { _Tuple_for_each( @@ -7261,10 +7253,10 @@ namespace ranges { return *this; } - constexpr _Iterator& operator-=(const difference_type _Off) noexcept( - (noexcept(_STD declval>&>() -= - static_cast>>>(_Off)) - && ...)) // strengthened + constexpr _Iterator& operator-=(const difference_type _Off) + noexcept((noexcept(_STD declval>&>() -= + static_cast>>>(_Off)) + && ...)) // strengthened requires _All_random_access<_IsConst, _ViewTypes...> { _Tuple_for_each( @@ -7291,8 +7283,8 @@ namespace ranges { _Current); } - _NODISCARD friend constexpr bool operator==(const _Iterator& _Lhs, const _Iterator& _Rhs) noexcept( - noexcept(_Zip_iterator_sentinel_equal(_Lhs._Current, _Rhs._Current))) // strengthened + _NODISCARD friend constexpr bool operator==(const _Iterator& _Lhs, const _Iterator& _Rhs) + noexcept(noexcept(_Zip_iterator_sentinel_equal(_Lhs._Current, _Rhs._Current))) // strengthened requires (equality_comparable>> && ...) { if constexpr (!_Zip_is_common<_Maybe_const<_IsConst, _ViewTypes>...> @@ -7309,9 +7301,9 @@ namespace ranges { return _Lhs._Current <=> _Rhs._Current; } - _NODISCARD friend constexpr _Iterator operator+(const _Iterator& _Lhs, const difference_type _Rhs) noexcept( - noexcept(_STD declval<_Iterator&>() += _Rhs) - && is_nothrow_copy_constructible_v<_Iterator>) // strengthened + _NODISCARD friend constexpr _Iterator operator+(const _Iterator& _Lhs, const difference_type _Rhs) + noexcept(noexcept(_STD declval<_Iterator&>() += _Rhs) + && is_nothrow_copy_constructible_v<_Iterator>) // strengthened requires _All_random_access<_IsConst, _ViewTypes...> { auto _Modified_iterator = _Lhs; @@ -7320,16 +7312,16 @@ namespace ranges { return _Modified_iterator; } - _NODISCARD friend constexpr _Iterator operator+(const difference_type _Lhs, const _Iterator& _Rhs) noexcept( - noexcept(_Rhs + _Lhs)) /* strengthened */ + _NODISCARD friend constexpr _Iterator operator+(const difference_type _Lhs, const _Iterator& _Rhs) + noexcept(noexcept(_Rhs + _Lhs)) /* strengthened */ requires _All_random_access<_IsConst, _ViewTypes...> { return _Rhs + _Lhs; } - _NODISCARD friend constexpr _Iterator operator-(const _Iterator& _Lhs, const difference_type _Rhs) noexcept( - noexcept(_STD declval<_Iterator&>() -= _Rhs) - && is_nothrow_copy_constructible_v<_Iterator>) // strengthened + _NODISCARD friend constexpr _Iterator operator-(const _Iterator& _Lhs, const difference_type _Rhs) + noexcept(noexcept(_STD declval<_Iterator&>() -= _Rhs) + && is_nothrow_copy_constructible_v<_Iterator>) // strengthened requires _All_random_access<_IsConst, _ViewTypes...> { auto _Modified_iterator = _Lhs; @@ -7338,10 +7330,9 @@ namespace ranges { return _Modified_iterator; } - _NODISCARD friend constexpr difference_type - operator-(const _Iterator& _Lhs, const _Iterator& _Rhs) noexcept( - noexcept(_Zip_get_smallest_distance(_STD declval<_My_tuple>(), - _STD declval<_My_tuple>()))) // strengthened + _NODISCARD friend constexpr difference_type operator-(const _Iterator& _Lhs, const _Iterator& _Rhs) + noexcept(noexcept(_Zip_get_smallest_distance(_STD declval<_My_tuple>(), + _STD declval<_My_tuple>()))) // strengthened requires (sized_sentinel_for>, iterator_t<_Maybe_const<_IsConst, _ViewTypes>>> && ...) @@ -7357,14 +7348,12 @@ namespace ranges { return _Tuple_transform(_RANGES iter_move, _Itr._Current); } - // clang-format off friend constexpr void iter_swap(const _Iterator& _Lhs, const _Iterator& _Rhs) - noexcept((noexcept(_RANGES iter_swap( - _STD declval>&>(), - _STD declval>&>())) && ...)) + noexcept((noexcept(_RANGES iter_swap(_STD declval>&>(), + _STD declval>&>())) + && ...)) requires (indirectly_swappable>> && ...) { - // clang-format on const auto _Swap_every_pair_closure = [&_Lhs, &_Rhs](index_sequence<_Indices...>) noexcept(noexcept( ((_RANGES iter_swap(_STD get<_Indices>(_Lhs._Current), _STD get<_Indices>(_Rhs._Current))), @@ -7386,8 +7375,8 @@ namespace ranges { /* [[no_unique_address]] */ _My_tuple _End; - constexpr explicit _Sentinel(_My_tuple _End_) noexcept( - is_nothrow_copy_constructible_v<_My_tuple>) // strengthened + constexpr explicit _Sentinel(_My_tuple _End_) + noexcept(is_nothrow_copy_constructible_v<_My_tuple>) // strengthened : _End(_End_) {} template @@ -7410,8 +7399,8 @@ namespace ranges { requires (sentinel_for>, iterator_t<_Maybe_const<_IteratorConst, _ViewTypes>>> && ...) - _NODISCARD friend constexpr bool - operator==(const _Iterator<_IteratorConst>& _Lhs, const _Sentinel& _Rhs) noexcept( + _NODISCARD friend constexpr bool operator==(const _Iterator<_IteratorConst>& _Lhs, const _Sentinel& _Rhs) + noexcept( noexcept(_Zip_iterator_sentinel_equal(_Get_iterator_tuple(_Lhs), _Rhs._End))) /* strengthened */ { return _Zip_iterator_sentinel_equal(_Get_iterator_tuple(_Lhs), _Rhs._End); } @@ -7421,8 +7410,8 @@ namespace ranges { iterator_t<_Maybe_const<_IteratorConst, _ViewTypes>>> && ...) _NODISCARD friend constexpr common_type_t>...> - operator-(const _Iterator<_IteratorConst>& _Lhs, const _Sentinel& _Rhs) noexcept( - noexcept(_Zip_get_smallest_distance< + operator-(const _Iterator<_IteratorConst>& _Lhs, const _Sentinel& _Rhs) + noexcept(noexcept(_Zip_get_smallest_distance< common_type_t>...>>( _Get_iterator_tuple(_Lhs), _Rhs._End))) /* strengthened */ { using _Difference_type = common_type_t>...>; @@ -7434,8 +7423,8 @@ namespace ranges { iterator_t<_Maybe_const<_IteratorConst, _ViewTypes>>> && ...) _NODISCARD friend constexpr common_type_t>...> - operator-(const _Sentinel& _Lhs, const _Iterator<_IteratorConst>& _Rhs) noexcept( - noexcept(-(_Rhs - _Lhs))) /* strengthened */ { + operator-(const _Sentinel& _Lhs, const _Iterator<_IteratorConst>& _Rhs) + noexcept(noexcept(-(_Rhs - _Lhs))) /* strengthened */ { return -(_Rhs - _Lhs); } }; @@ -7455,15 +7444,20 @@ namespace ranges { } } + static constexpr auto _Size_closure = [](auto... _Sizes) _STATIC_CALL_OPERATOR noexcept { + using _Common_unsigned_type = _Make_unsigned_like_t>; + return (_RANGES min)({static_cast<_Common_unsigned_type>(_Sizes)...}); + }; + public: zip_view() noexcept((is_nothrow_default_constructible_v<_ViewTypes> && ...)) = default; - constexpr explicit zip_view(_ViewTypes... _Args) noexcept( - (is_nothrow_move_constructible_v<_ViewTypes> && ...)) // strengthened + constexpr explicit zip_view(_ViewTypes... _Args) + noexcept((is_nothrow_move_constructible_v<_ViewTypes> && ...)) // strengthened : _Views(_STD move(_Args)...) {} - _NODISCARD constexpr auto begin() noexcept( - noexcept(_Iterator{_Tuple_transform(_RANGES begin, _Views)})) // strengthened + _NODISCARD constexpr auto begin() + noexcept(noexcept(_Iterator{_Tuple_transform(_RANGES begin, _Views)})) // strengthened requires (!(_Simple_view<_ViewTypes> && ...)) { return _Iterator{_Tuple_transform(_RANGES begin, _Views)}; @@ -7500,26 +7494,18 @@ namespace ranges { } } - _NODISCARD constexpr auto size() noexcept( - noexcept(_STD apply(_Size_closure(), _Tuple_transform(_RANGES size, _Views)))) // strengthened + _NODISCARD constexpr auto size() + noexcept(noexcept(_STD apply(_Size_closure, _Tuple_transform(_RANGES size, _Views)))) // strengthened requires (sized_range<_ViewTypes> && ...) { - return _STD apply(_Size_closure(), _Tuple_transform(_RANGES size, _Views)); + return _STD apply(_Size_closure, _Tuple_transform(_RANGES size, _Views)); } _NODISCARD constexpr auto size() const - noexcept(noexcept(_STD apply(_Size_closure(), _Tuple_transform(_RANGES size, _Views)))) // strengthened + noexcept(noexcept(_STD apply(_Size_closure, _Tuple_transform(_RANGES size, _Views)))) // strengthened requires (sized_range && ...) { - return _STD apply(_Size_closure(), _Tuple_transform(_RANGES size, _Views)); - } - - private: - _NODISCARD static constexpr auto _Size_closure() noexcept { - return [](auto... _Sizes) _STATIC_CALL_OPERATOR noexcept { - using _Common_unsigned_type = _Make_unsigned_like_t>; - return (_RANGES min)({static_cast<_Common_unsigned_type>(_Sizes)...}); - }; + return _STD apply(_Size_closure, _Tuple_transform(_RANGES size, _Views)); } }; @@ -7627,20 +7613,20 @@ namespace ranges { _Parent_t* _Parent = nullptr; /* [[no_unique_address]] */ _Ziperator<_IsConst> _Inner; - constexpr _Iterator(_Parent_t& _Parent_, _Ziperator<_IsConst> _Inner_) noexcept( - is_nothrow_move_constructible_v<_Ziperator<_IsConst>>) // strengthened + constexpr _Iterator(_Parent_t& _Parent_, _Ziperator<_IsConst> _Inner_) + noexcept(is_nothrow_move_constructible_v<_Ziperator<_IsConst>>) // strengthened : _Parent(_STD addressof(_Parent_)), _Inner(_STD move(_Inner_)) {} public: using iterator_concept = _Ziperator<_IsConst>::iterator_concept; using value_type = remove_cvref_t&, - range_reference_t<_Maybe_const<_IsConst, _ViewTypes>>...>>; + range_reference_t<_Maybe_const<_IsConst, _ViewTypes>>...>>; using difference_type = range_difference_t<_Base_t>; _Iterator() = default; - constexpr _Iterator(_Iterator _Rhs) noexcept( - is_nothrow_convertible_v<_Ziperator, _Ziperator<_IsConst>>) // strengthened + constexpr _Iterator(_Iterator _Rhs) + noexcept(is_nothrow_convertible_v<_Ziperator, _Ziperator<_IsConst>>) // strengthened requires (_IsConst && convertible_to<_Ziperator, _Ziperator<_IsConst>>) : _Parent(_Rhs._Parent), _Inner(_STD move(_Rhs._Inner)) {} @@ -7659,7 +7645,7 @@ namespace ranges { } constexpr _Iterator operator++(int) noexcept(is_nothrow_copy_constructible_v<_Iterator> // - && noexcept(++*this)) // strengthened + && noexcept(++*this)) // strengthened requires forward_range<_Base_t> { auto _Temp = *this; @@ -7675,7 +7661,7 @@ namespace ranges { } constexpr _Iterator operator--(int) noexcept(is_nothrow_copy_constructible_v<_Iterator> // - && noexcept(--*this)) // strengthened + && noexcept(--*this)) // strengthened requires bidirectional_range<_Base_t> { auto _Temp = *this; @@ -7683,16 +7669,16 @@ namespace ranges { return _Temp; } - constexpr _Iterator& operator+=(const difference_type _Off) noexcept( - noexcept(_Inner += _Off)) // strengthened + constexpr _Iterator& operator+=(const difference_type _Off) + noexcept(noexcept(_Inner += _Off)) // strengthened requires random_access_range<_Base_t> { _Inner += _Off; return *this; } - constexpr _Iterator& operator-=(const difference_type _Off) noexcept( - noexcept(_Inner -= _Off)) // strengthened + constexpr _Iterator& operator-=(const difference_type _Off) + noexcept(noexcept(_Inner -= _Off)) // strengthened requires random_access_range<_Base_t> { _Inner -= _Off; @@ -7706,36 +7692,36 @@ namespace ranges { return _STD apply(_Subscript_closure(_Where), _Inner._Current); } - _NODISCARD friend constexpr bool operator==(const _Iterator& _Lhs, const _Iterator& _Rhs) noexcept( - noexcept(_Lhs._Inner == _Rhs._Inner)) // strengthened + _NODISCARD friend constexpr bool operator==(const _Iterator& _Lhs, const _Iterator& _Rhs) + noexcept(noexcept(_Lhs._Inner == _Rhs._Inner)) // strengthened requires equality_comparable<_Ziperator<_IsConst>> { return _Lhs._Inner == _Rhs._Inner; } - _NODISCARD friend constexpr auto operator<=>(const _Iterator& _Lhs, const _Iterator& _Rhs) noexcept( - noexcept(_Lhs._Inner <=> _Rhs._Inner)) // strengthened + _NODISCARD friend constexpr auto operator<=>(const _Iterator& _Lhs, const _Iterator& _Rhs) + noexcept(noexcept(_Lhs._Inner <=> _Rhs._Inner)) // strengthened requires random_access_range<_Base_t> { return _Lhs._Inner <=> _Rhs._Inner; } - _NODISCARD friend constexpr _Iterator operator+(const _Iterator& _Lhs, const difference_type _Rhs) noexcept( - noexcept(_Iterator{*_Lhs._Parent, _Lhs._Inner + _Rhs})) // strengthened + _NODISCARD friend constexpr _Iterator operator+(const _Iterator& _Lhs, const difference_type _Rhs) + noexcept(noexcept(_Iterator{*_Lhs._Parent, _Lhs._Inner + _Rhs})) // strengthened requires random_access_range<_Base_t> { return _Iterator{*_Lhs._Parent, _Lhs._Inner + _Rhs}; } - _NODISCARD friend constexpr _Iterator operator+(const difference_type _Lhs, const _Iterator& _Rhs) noexcept( - noexcept(_Iterator{*_Rhs._Parent, _Rhs._Inner + _Lhs})) // strengthened + _NODISCARD friend constexpr _Iterator operator+(const difference_type _Lhs, const _Iterator& _Rhs) + noexcept(noexcept(_Iterator{*_Rhs._Parent, _Rhs._Inner + _Lhs})) // strengthened requires random_access_range<_Base_t> { return _Iterator{*_Rhs._Parent, _Rhs._Inner + _Lhs}; } - _NODISCARD friend constexpr _Iterator operator-(const _Iterator& _Lhs, const difference_type _Rhs) noexcept( - noexcept(_Iterator{*_Lhs._Parent, _Lhs._Inner - _Rhs})) // strengthened + _NODISCARD friend constexpr _Iterator operator-(const _Iterator& _Lhs, const difference_type _Rhs) + noexcept(noexcept(_Iterator{*_Lhs._Parent, _Lhs._Inner - _Rhs})) // strengthened requires random_access_range<_Base_t> { return _Iterator{*_Lhs._Parent, _Lhs._Inner - _Rhs}; @@ -7775,8 +7761,8 @@ namespace ranges { /* [[no_unique_address]] */ _Zentinel<_IsConst> _Inner; - constexpr explicit _Sentinel(_Zentinel<_IsConst> _Inner_) noexcept( - is_nothrow_copy_constructible_v<_Zentinel<_IsConst>>) // strengthened + constexpr explicit _Sentinel(_Zentinel<_IsConst> _Inner_) + noexcept(is_nothrow_copy_constructible_v<_Zentinel<_IsConst>>) // strengthened : _Inner(_Inner_) {} template @@ -7788,31 +7774,31 @@ namespace ranges { public: _Sentinel() = default; - constexpr _Sentinel(_Sentinel _Rhs) noexcept( - is_nothrow_convertible_v<_Zentinel, _Zentinel<_IsConst>>) // strengthened + constexpr _Sentinel(_Sentinel _Rhs) + noexcept(is_nothrow_convertible_v<_Zentinel, _Zentinel<_IsConst>>) // strengthened requires (_IsConst && convertible_to<_Zentinel, _Zentinel<_IsConst>>) : _Inner(_STD move(_Rhs._Inner)) {} template requires sentinel_for<_Zentinel<_IsConst>, _Ziperator<_IteratorConst>> - _NODISCARD friend constexpr bool operator==(const _Iterator<_IteratorConst>& _Lhs, - const _Sentinel& _Rhs) noexcept(noexcept(_Get_iterator_inner(_Lhs) == _Rhs._Inner)) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Iterator<_IteratorConst>& _Lhs, const _Sentinel& _Rhs) + noexcept(noexcept(_Get_iterator_inner(_Lhs) == _Rhs._Inner)) /* strengthened */ { return _Get_iterator_inner(_Lhs) == _Rhs._Inner; } template requires sized_sentinel_for<_Zentinel<_IsConst>, _Ziperator<_IteratorConst>> _NODISCARD friend constexpr _Iter_sent_difference_type<_IteratorConst> // TRANSITION, DevCom-10253131 - operator-(const _Iterator<_IteratorConst>& _Lhs, const _Sentinel & _Rhs) noexcept( - noexcept(_Get_iterator_inner(_Lhs) - _Rhs._Inner)) /* strengthened */ { + operator-(const _Iterator<_IteratorConst>& _Lhs, const _Sentinel & _Rhs) + noexcept(noexcept(_Get_iterator_inner(_Lhs) - _Rhs._Inner)) /* strengthened */ { return _Get_iterator_inner(_Lhs) - _Rhs._Inner; } template requires sized_sentinel_for<_Zentinel<_IsConst>, _Ziperator<_IteratorConst>> _NODISCARD friend constexpr _Iter_sent_difference_type<_IteratorConst> // TRANSITION, DevCom-10253131 - operator-(const _Sentinel & _Lhs, const _Iterator<_IteratorConst>& _Rhs) noexcept( - noexcept(_Lhs._Inner - _Get_iterator_inner(_Rhs))) /* strengthened */ { + operator-(const _Sentinel & _Lhs, const _Iterator<_IteratorConst>& _Rhs) + noexcept(noexcept(_Lhs._Inner - _Get_iterator_inner(_Rhs))) /* strengthened */ { return _Lhs._Inner - _Get_iterator_inner(_Rhs); } }; @@ -7830,9 +7816,9 @@ namespace ranges { public: zip_transform_view() = default; - constexpr explicit zip_transform_view(_Func _Function_, _ViewTypes... _Views) noexcept( - is_nothrow_move_constructible_v<_Func> - && is_nothrow_constructible_v<_Inner_view, remove_reference_t<_ViewTypes>&&...>) // strengthened + constexpr explicit zip_transform_view(_Func _Function_, _ViewTypes... _Views) + noexcept(is_nothrow_move_constructible_v<_Func> + && is_nothrow_constructible_v<_Inner_view, remove_reference_t<_ViewTypes>&&...>) // strengthened : _Function(in_place, _STD move(_Function_)), _Zip(_STD move(_Views)...) {} _NODISCARD constexpr auto begin() noexcept(noexcept(_Iterator{*this, _Zip.begin()})) /* strengthened */ { @@ -7997,13 +7983,14 @@ namespace ranges { private: friend adjacent_view; -#ifdef __clang__ // TRANSITION, LLVM-61763 +#ifdef __clang__ // TRANSITION, need to reduce and report (was thought to be LLVM-61763) public: #else // ^^^ workaround / no workaround vvv template requires _Adjacent_transform_constraints<_Vw2, _Fn, _Nx2> friend class adjacent_transform_view; #endif // ^^^ no workaround ^^^ + using _Base = _Maybe_const<_Const, _Vw>; using _Base_iterator = iterator_t<_Base>; @@ -8030,22 +8017,22 @@ namespace ranges { } template - constexpr _Iterator(_Iterator& _Other, index_sequence<_Indices...>) noexcept( - is_nothrow_convertible_v, _Base_iterator>) + constexpr _Iterator(_Iterator& _Other, index_sequence<_Indices...>) + noexcept(is_nothrow_convertible_v, _Base_iterator>) requires _Const && convertible_to, _Base_iterator> : _Current{_STD move(_Other._Current[_Indices])...} {} public: using iterator_category = input_iterator_tag; using iterator_concept = conditional_t, random_access_iterator_tag, - conditional_t, bidirectional_iterator_tag, forward_iterator_tag>>; + conditional_t, bidirectional_iterator_tag, forward_iterator_tag>>; using value_type = _Repeated_tuple, _Nx>; using difference_type = range_difference_t<_Base>; _Iterator() = default; - constexpr _Iterator(_Iterator _Other) noexcept( - is_nothrow_convertible_v, _Base_iterator>) // strengthened + constexpr _Iterator(_Iterator _Other) + noexcept(is_nothrow_convertible_v, _Base_iterator>) // strengthened requires _Const && convertible_to, _Base_iterator> : _Iterator(_Other, make_index_sequence<_Nx>{}) {} @@ -8061,8 +8048,8 @@ namespace ranges { return *this; } - constexpr _Iterator operator++(int) noexcept( - noexcept(++*this) && is_nothrow_copy_constructible_v<_Iterator>) /* strengthened */ { + constexpr _Iterator operator++(int) + noexcept(noexcept(++*this) && is_nothrow_copy_constructible_v<_Iterator>) /* strengthened */ { auto _Tmp = *this; ++*this; return _Tmp; @@ -8077,8 +8064,8 @@ namespace ranges { return *this; } - constexpr _Iterator operator--(int) noexcept( - noexcept(--*this) && is_nothrow_copy_constructible_v<_Iterator>) // strengthened + constexpr _Iterator operator--(int) + noexcept(noexcept(--*this) && is_nothrow_copy_constructible_v<_Iterator>) // strengthened requires bidirectional_range<_Base> { auto _Tmp = *this; @@ -8086,8 +8073,8 @@ namespace ranges { return _Tmp; } - constexpr _Iterator& operator+=(const difference_type _Off) noexcept( - noexcept(_Current.back() += _Off)) // strengthened + constexpr _Iterator& operator+=(const difference_type _Off) + noexcept(noexcept(_Current.back() += _Off)) // strengthened requires random_access_range<_Base> { for (_Base_iterator& _It : _Current) { @@ -8096,8 +8083,8 @@ namespace ranges { return *this; } - constexpr _Iterator& operator-=(const difference_type _Off) noexcept( - noexcept(_Current.back() -= _Off)) // strengthened + constexpr _Iterator& operator-=(const difference_type _Off) + noexcept(noexcept(_Current.back() -= _Off)) // strengthened requires random_access_range<_Base> { for (_Base_iterator& _It : _Current) { @@ -8125,37 +8112,37 @@ namespace ranges { return _Left._Current.back() < _Right._Current.back(); } - _NODISCARD friend constexpr bool operator>(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Right < _Left)) // strengthened + _NODISCARD friend constexpr bool operator>(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Right < _Left)) // strengthened requires random_access_range<_Base> { return _Right < _Left; } - _NODISCARD friend constexpr bool operator<=(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(!(_Right < _Left))) // strengthened + _NODISCARD friend constexpr bool operator<=(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(!(_Right < _Left))) // strengthened requires random_access_range<_Base> { return !(_Right < _Left); } - _NODISCARD friend constexpr bool operator>=(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(!(_Left < _Right))) // strengthened + _NODISCARD friend constexpr bool operator>=(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(!(_Left < _Right))) // strengthened requires random_access_range<_Base> { return !(_Left < _Right); } - _NODISCARD friend constexpr auto operator<=>(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Current.back() <=> _Right._Current.back())) // strengthened + _NODISCARD friend constexpr auto operator<=>(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current.back() <=> _Right._Current.back())) // strengthened requires random_access_range<_Base> && three_way_comparable<_Base_iterator> { return _Left._Current.back() <=> _Right._Current.back(); } - _NODISCARD friend constexpr _Iterator operator+(const _Iterator& _It, const difference_type _Off) noexcept( - noexcept(_STD declval<_Iterator&>() += _Off) - && is_nothrow_copy_constructible_v<_Iterator>) // strengthened + _NODISCARD friend constexpr _Iterator operator+(const _Iterator& _It, const difference_type _Off) + noexcept(noexcept(_STD declval<_Iterator&>() += _Off) + && is_nothrow_copy_constructible_v<_Iterator>) // strengthened requires random_access_range<_Base> { auto _Tmp = _It; @@ -8163,9 +8150,9 @@ namespace ranges { return _Tmp; } - _NODISCARD friend constexpr _Iterator operator+(const difference_type _Off, const _Iterator& _It) noexcept( - noexcept(_STD declval<_Iterator&>() += _Off) - && is_nothrow_copy_constructible_v<_Iterator>) // strengthened + _NODISCARD friend constexpr _Iterator operator+(const difference_type _Off, const _Iterator& _It) + noexcept(noexcept(_STD declval<_Iterator&>() += _Off) + && is_nothrow_copy_constructible_v<_Iterator>) // strengthened requires random_access_range<_Base> { auto _Tmp = _It; @@ -8173,9 +8160,9 @@ namespace ranges { return _Tmp; } - _NODISCARD friend constexpr _Iterator operator-(const _Iterator& _It, const difference_type _Off) noexcept( - noexcept(_STD declval<_Iterator&>() -= _Off) - && is_nothrow_copy_constructible_v<_Iterator>) // strengthened + _NODISCARD friend constexpr _Iterator operator-(const _Iterator& _It, const difference_type _Off) + noexcept(noexcept(_STD declval<_Iterator&>() -= _Off) + && is_nothrow_copy_constructible_v<_Iterator>) // strengthened requires random_access_range<_Base> { auto _Tmp = _It; @@ -8183,22 +8170,21 @@ namespace ranges { return _Tmp; } - _NODISCARD friend constexpr difference_type - operator-(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Current.back() - _Right._Current.back())) // strengthened + _NODISCARD friend constexpr difference_type operator-(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Current.back() - _Right._Current.back())) // strengthened requires sized_sentinel_for<_Base_iterator, _Base_iterator> { return _Left._Current.back() - _Right._Current.back(); } - _NODISCARD friend constexpr auto iter_move(const _Iterator& _It) noexcept( - noexcept(_RANGES iter_move(_STD declval())) - && is_nothrow_move_constructible_v>) { + _NODISCARD friend constexpr auto iter_move(const _Iterator& _It) + noexcept(noexcept(_RANGES iter_move(_STD declval())) + && is_nothrow_move_constructible_v>) { return _RANGES _Tuple_transform(_RANGES iter_move, _It._Current); } - friend constexpr void iter_swap(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_RANGES iter_swap(_STD declval<_Base_iterator>(), _STD declval<_Base_iterator>()))) + friend constexpr void iter_swap(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_RANGES iter_swap(_STD declval<_Base_iterator>(), _STD declval<_Base_iterator>()))) requires indirectly_swappable<_Base_iterator> { for (size_t _Ix = 0; _Ix < _Nx; ++_Ix) { @@ -8217,8 +8203,8 @@ namespace ranges { /* [[no_unique_address]] */ _Base_sentinel _End{}; - constexpr explicit _Sentinel(_Base_sentinel _Last_) noexcept( - is_nothrow_move_constructible_v<_Base_sentinel>) // strengthened + constexpr explicit _Sentinel(_Base_sentinel _Last_) + noexcept(is_nothrow_move_constructible_v<_Base_sentinel>) // strengthened : _End(_STD move(_Last_)) {} template @@ -8238,15 +8224,15 @@ namespace ranges { public: _Sentinel() = default; - constexpr _Sentinel(_Sentinel _Other) noexcept( - is_nothrow_convertible_v, _Base_sentinel>) // strengthened + constexpr _Sentinel(_Sentinel _Other) + noexcept(is_nothrow_convertible_v, _Base_sentinel>) // strengthened requires _Const && convertible_to, _Base_sentinel> : _End(_STD move(_Other._End)) {} template requires sentinel_for<_Base_sentinel, iterator_t<_Maybe_const<_OtherConst, _Vw>>> - _NODISCARD friend constexpr bool operator==(const _Iterator<_OtherConst>& _It, - const _Sentinel& _Se) noexcept(noexcept(_Se._Equal(_It))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Iterator<_OtherConst>& _It, const _Sentinel& _Se) + noexcept(noexcept(_Se._Equal(_It))) /* strengthened */ { return _Se._Equal(_It); } @@ -8268,9 +8254,9 @@ namespace ranges { }; public: - // clang-format off - adjacent_view() requires default_initializable<_Vw> = default; - // clang-format on + adjacent_view() + requires default_initializable<_Vw> + = default; constexpr explicit adjacent_view(_Vw _Range_) noexcept(is_nothrow_move_constructible_v<_Vw>) // strengthened : _Range(_STD move(_Range_)) {} @@ -8405,8 +8391,8 @@ namespace ranges { _Parent_t* _Parent = nullptr; _Inner_iterator<_Const> _Inner; - constexpr _Iterator(_Parent_t& _Parent_, _Inner_iterator<_Const> _Inner_) noexcept( - is_nothrow_move_constructible_v<_Inner_iterator<_Const>>) // strengthened + constexpr _Iterator(_Parent_t& _Parent_, _Inner_iterator<_Const> _Inner_) + noexcept(is_nothrow_move_constructible_v<_Inner_iterator<_Const>>) // strengthened : _Parent(_STD addressof(_Parent_)), _Inner(_STD move(_Inner_)) {} _NODISCARD static consteval auto _Get_iterator_category() noexcept { @@ -8438,7 +8424,7 @@ namespace ranges { using iterator_category = decltype(_Get_iterator_category()); using iterator_concept = _Inner_iterator<_Const>::iterator_concept; using value_type = remove_cvref_t< - _Invoke_result_with_repeated_type<_Maybe_const<_Const, _Fn>&, range_reference_t<_Base>, _Nx>>; + _Invoke_result_with_repeated_type<_Maybe_const<_Const, _Fn>&, range_reference_t<_Base>, _Nx>>; using difference_type = range_difference_t<_Base>; _Iterator() = default; @@ -8459,8 +8445,8 @@ namespace ranges { return *this; } - constexpr _Iterator operator++(int) noexcept( - noexcept(++*this) && is_nothrow_copy_constructible_v<_Iterator>) /* strengthened */ { + constexpr _Iterator operator++(int) + noexcept(noexcept(++*this) && is_nothrow_copy_constructible_v<_Iterator>) /* strengthened */ { auto _Tmp = *this; ++*this; return _Tmp; @@ -8473,8 +8459,8 @@ namespace ranges { return *this; } - constexpr _Iterator operator--(int) noexcept( - noexcept(--*this) && is_nothrow_copy_constructible_v<_Iterator>) // strengthened + constexpr _Iterator operator--(int) + noexcept(noexcept(--*this) && is_nothrow_copy_constructible_v<_Iterator>) // strengthened requires bidirectional_range<_Base> { auto _Tmp = *this; @@ -8482,16 +8468,16 @@ namespace ranges { return _Tmp; } - constexpr _Iterator& operator+=(const difference_type _Off) noexcept( - noexcept(_Inner += _Off)) // strengthened + constexpr _Iterator& operator+=(const difference_type _Off) + noexcept(noexcept(_Inner += _Off)) // strengthened requires random_access_range<_Base> { _Inner += _Off; return *this; } - constexpr _Iterator& operator-=(const difference_type _Off) noexcept( - noexcept(_Inner -= _Off)) // strengthened + constexpr _Iterator& operator-=(const difference_type _Off) + noexcept(noexcept(_Inner -= _Off)) // strengthened requires random_access_range<_Base> { _Inner -= _Off; @@ -8508,41 +8494,41 @@ namespace ranges { _Inner._Current); } - _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Inner == _Right._Inner)) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Inner == _Right._Inner)) /* strengthened */ { return _Left._Inner == _Right._Inner; } - _NODISCARD friend constexpr bool operator<(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Inner < _Right._Inner)) // strengthened + _NODISCARD friend constexpr bool operator<(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Inner < _Right._Inner)) // strengthened requires random_access_range<_Base> { return _Left._Inner < _Right._Inner; } - _NODISCARD friend constexpr bool operator>(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Inner > _Right._Inner)) // strengthened + _NODISCARD friend constexpr bool operator>(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Inner > _Right._Inner)) // strengthened requires random_access_range<_Base> { return _Left._Inner > _Right._Inner; } - _NODISCARD friend constexpr bool operator<=(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Inner <= _Right._Inner)) // strengthened + _NODISCARD friend constexpr bool operator<=(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Inner <= _Right._Inner)) // strengthened requires random_access_range<_Base> { return _Left._Inner <= _Right._Inner; } - _NODISCARD friend constexpr bool operator>=(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Inner >= _Right._Inner)) // strengthened + _NODISCARD friend constexpr bool operator>=(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Inner >= _Right._Inner)) // strengthened requires random_access_range<_Base> { return _Left._Inner >= _Right._Inner; } - _NODISCARD friend constexpr auto operator<=>(const _Iterator& _Left, const _Iterator& _Right) noexcept( - noexcept(_Left._Inner <=> _Right._Inner)) // strengthened + _NODISCARD friend constexpr auto operator<=>(const _Iterator& _Left, const _Iterator& _Right) + noexcept(noexcept(_Left._Inner <=> _Right._Inner)) // strengthened requires random_access_range<_Base> && three_way_comparable<_Inner_iterator<_Const>> { return _Left._Inner <=> _Right._Inner; @@ -8609,8 +8595,8 @@ namespace ranges { template requires sentinel_for<_Inner_sentinel<_Const>, _Inner_iterator<_OtherConst>> - _NODISCARD friend constexpr bool operator==(const _Iterator<_OtherConst>& _It, - const _Sentinel& _Se) noexcept(noexcept(_Se._Equal(_It))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const _Iterator<_OtherConst>& _It, const _Sentinel& _Se) + noexcept(noexcept(_Se._Equal(_It))) /* strengthened */ { return _Se._Equal(_It); } @@ -8634,8 +8620,8 @@ namespace ranges { public: adjacent_transform_view() = default; - constexpr explicit adjacent_transform_view(_Vw _Range_, _Fn _Func_) noexcept( - is_nothrow_move_constructible_v<_Vw> && is_nothrow_move_constructible_v<_Fn>) // strengthened + constexpr explicit adjacent_transform_view(_Vw _Range_, _Fn _Func_) + noexcept(is_nothrow_move_constructible_v<_Vw> && is_nothrow_move_constructible_v<_Fn>) // strengthened : _Func(in_place, _STD move(_Func_)), _Inner(_STD move(_Range_)) {} _NODISCARD constexpr _Vw base() const& noexcept(noexcept(_Inner.base())) // strengthened @@ -8956,15 +8942,17 @@ namespace ranges { public: using iterator_category = input_iterator_tag; - using iterator_concept = conditional_t<_Cartesian_product_is_random_access<_Const, _First, _Rest...>, + + using iterator_concept = conditional_t<_Cartesian_product_is_random_access<_Const, _First, _Rest...>, random_access_iterator_tag, conditional_t<_Cartesian_product_is_bidirectional<_Const, _First, _Rest...>, bidirectional_iterator_tag, conditional_t>, forward_iterator_tag, input_iterator_tag>>>; + using value_type = tuple>, range_value_t<_Maybe_const<_Const, _Rest>>...>; using reference = tuple>, - range_reference_t<_Maybe_const<_Const, _Rest>>...>; + range_reference_t<_Maybe_const<_Const, _Rest>>...>; using difference_type = _Difference_type<_Const>; _Iterator() = default; @@ -9084,19 +9072,18 @@ namespace ranges { return -(_It - _Se); } - _NODISCARD friend constexpr auto iter_move(const _Iterator& _It) noexcept( - _Is_iter_move_nothrow(make_index_sequence<1 + sizeof...(_Rest)>{})) { + _NODISCARD friend constexpr auto iter_move(const _Iterator& _It) + noexcept(_Is_iter_move_nothrow(make_index_sequence<1 + sizeof...(_Rest)>{})) { return _RANGES _Tuple_transform(_RANGES iter_move, _It._Current); } - friend constexpr void iter_swap(const _Iterator& _Left, const _Iterator& _Right) noexcept( - _Is_iter_swap_nothrow(make_index_sequence<1 + sizeof...(_Rest)>{})) + friend constexpr void iter_swap(const _Iterator& _Left, const _Iterator& _Right) + noexcept(_Is_iter_swap_nothrow(make_index_sequence<1 + sizeof...(_Rest)>{})) requires (indirectly_swappable>> && ... && indirectly_swappable>>) { - return [&](index_sequence<_Indices...>) { - return (_RANGES iter_swap(_STD get<_Indices>(_Left._Current), _STD get<_Indices>(_Right._Current)), - ...); + [&](index_sequence<_Indices...>) { + (_RANGES iter_swap(_STD get<_Indices>(_Left._Current), _STD get<_Indices>(_Right._Current)), ...); }(make_index_sequence<1 + sizeof...(_Rest)>{}); } }; @@ -9144,7 +9131,7 @@ namespace ranges { requires ((!_Simple_view<_First> || ... || !_Simple_view<_Rest>) && _Cartesian_product_is_common<_First>) { const bool _Is_empty = [&](index_sequence<_Indices...>) { - return (_RANGES empty(_STD get<_Indices + 1>(_Bases)) || ...); + return (_RANGES empty(_STD get<_Indices + 1>(_Bases)) || ... || false); }(make_index_sequence{}); const auto _Make_iter_tuple = [&](index_sequence<_Indices...>) { @@ -9157,7 +9144,7 @@ namespace ranges { requires _Cartesian_product_is_common { const bool _Is_empty = [&](index_sequence<_Indices...>) { - return (_RANGES empty(_STD get<_Indices + 1>(_Bases)) || ...); + return (_RANGES empty(_STD get<_Indices + 1>(_Bases)) || ... || false); }(make_index_sequence{}); const auto _Make_iter_tuple = [&](index_sequence<_Indices...>) { diff --git a/stl/inc/regex b/stl/inc/regex index 587c3b60559..06cf594662d 100644 --- a/stl/inc/regex +++ b/stl/inc/regex @@ -2067,8 +2067,8 @@ void swap(basic_regex<_Elem, _RxTraits>& _Left, basic_regex<_Elem, _RxTraits>& _ } _EXPORT_STD template -void swap(match_results<_BidIt, _Alloc>& _Left, match_results<_BidIt, _Alloc>& _Right) noexcept( - noexcept(_Left.swap(_Right))) /* strengthened */ { +void swap(match_results<_BidIt, _Alloc>& _Left, match_results<_BidIt, _Alloc>& _Right) + noexcept(noexcept(_Left.swap(_Right))) /* strengthened */ { _Left.swap(_Right); } diff --git a/stl/inc/scoped_allocator b/stl/inc/scoped_allocator index e6884b3650f..0ad22596afa 100644 --- a/stl/inc/scoped_allocator +++ b/stl/inc/scoped_allocator @@ -205,8 +205,8 @@ public: return static_cast(*this); } - _NODISCARD_RAW_PTR_ALLOC __declspec(allocator) pointer - allocate(_CRT_GUARDOVERFLOW size_type _Count) { // allocate array of _Count elements, ignore hint + _NODISCARD_RAW_PTR_ALLOC __declspec(allocator) pointer allocate(_CRT_GUARDOVERFLOW size_type _Count) { + // allocate array of _Count elements, ignore hint return _Outer_traits::allocate(outer_allocator(), _Count); } diff --git a/stl/inc/set b/stl/inc/set index 44bb78db034..5e049118ad4 100644 --- a/stl/inc/set +++ b/stl/inc/set @@ -351,8 +351,8 @@ public: multiset(multiset&& _Right, const allocator_type& _Al) : _Mybase(_STD move(_Right), _Al) {} - multiset& operator=(multiset&& _Right) noexcept( - _Alnode_traits::is_always_equal::value && is_nothrow_move_assignable_v<_Pr>) { + multiset& operator=(multiset&& _Right) + noexcept(_Alnode_traits::is_always_equal::value && is_nothrow_move_assignable_v<_Pr>) { _Mybase::operator=(_STD move(_Right)); return *this; } @@ -415,8 +415,8 @@ template <_RANGES input_range _Rng, class _Pr = less<_RANGES range_value_t<_Rng> multiset(from_range_t, _Rng&&, _Pr = _Pr(), _Alloc = _Alloc()) -> multiset<_RANGES range_value_t<_Rng>, _Pr, _Alloc>; template <_RANGES input_range _Rng, _Allocator_for_container _Alloc> -multiset(from_range_t, _Rng&&, _Alloc) - -> multiset<_RANGES range_value_t<_Rng>, less<_RANGES range_value_t<_Rng>>, _Alloc>; +multiset( + from_range_t, _Rng&&, _Alloc) -> multiset<_RANGES range_value_t<_Rng>, less<_RANGES range_value_t<_Rng>>, _Alloc>; #endif // _HAS_CXX23 #endif // _HAS_CXX17 @@ -462,8 +462,8 @@ _NODISCARD bool operator>=(const multiset<_Kty, _Pr, _Alloc>& _Left, const multi #endif // ^^^ !_HAS_CXX20 ^^^ _EXPORT_STD template -void swap(multiset<_Kty, _Pr, _Alloc>& _Left, multiset<_Kty, _Pr, _Alloc>& _Right) noexcept( - noexcept(_Left.swap(_Right))) { +void swap(multiset<_Kty, _Pr, _Alloc>& _Left, multiset<_Kty, _Pr, _Alloc>& _Right) + noexcept(noexcept(_Left.swap(_Right))) { _Left.swap(_Right); } diff --git a/stl/inc/source_location b/stl/inc/source_location index 2d3490f76f7..618fada2822 100644 --- a/stl/inc/source_location +++ b/stl/inc/source_location @@ -21,11 +21,7 @@ _STL_DISABLE_CLANG_WARNINGS #undef new #ifndef _USE_DETAILED_FUNCTION_NAME_IN_SOURCE_LOCATION -#ifdef __EDG__ // TRANSITION, DevCom-10199227 -#define _USE_DETAILED_FUNCTION_NAME_IN_SOURCE_LOCATION 0 -#else // ^^^ workaround / no workaround vvv #define _USE_DETAILED_FUNCTION_NAME_IN_SOURCE_LOCATION 1 -#endif // ^^^ no workaround ^^^ #endif // ^^^ !defined(_USE_DETAILED_FUNCTION_NAME_IN_SOURCE_LOCATION) ^^^ _STD_BEGIN diff --git a/stl/inc/span b/stl/inc/span index 018bc98cc98..bae1370bff2 100644 --- a/stl/inc/span +++ b/stl/inc/span @@ -235,25 +235,24 @@ constexpr bool _Is_span_v = false; template constexpr bool _Is_span_v> = true; -// clang-format off +template +constexpr bool _Is_std_array_v = false; + +template +constexpr bool _Is_std_array_v> = true; + template -concept _Span_compatible_iterator = contiguous_iterator<_It> - && is_convertible_v>(*)[], _Ty(*)[]>; +concept _Span_compatible_iterator = + contiguous_iterator<_It> && is_convertible_v> (*)[], _Ty (*)[]>; template -concept _Span_compatible_sentinel = sized_sentinel_for<_Sentinel, _It> - && !is_convertible_v<_Sentinel, size_t>; +concept _Span_compatible_sentinel = sized_sentinel_for<_Sentinel, _It> && !is_convertible_v<_Sentinel, size_t>; template concept _Span_compatible_range = - !is_array_v> - && !_Is_span_v> - && !_Is_std_array_v> - && _RANGES contiguous_range<_Rng> - && _RANGES sized_range<_Rng> - && (_RANGES borrowed_range<_Rng> || is_const_v<_Ty>) - && is_convertible_v>(*)[], _Ty(*)[]>; -// clang-format on + !is_array_v> && !_Is_span_v> && !_Is_std_array_v> + && _RANGES contiguous_range<_Rng> && _RANGES sized_range<_Rng> && (_RANGES borrowed_range<_Rng> || is_const_v<_Ty>) + && is_convertible_v> (*)[], _Ty (*)[]>; // [views.span] _EXPORT_STD template @@ -282,9 +281,9 @@ public: static constexpr size_type extent = _Extent; // [span.cons] Constructors, copy, and assignment - // clang-format off - constexpr span() noexcept requires (_Extent == 0 || _Extent == dynamic_extent) = default; - // clang-format on + constexpr span() noexcept + requires (_Extent == 0 || _Extent == dynamic_extent) + = default; template <_Span_compatible_iterator _It> constexpr explicit(_Extent != dynamic_extent) span(_It _First, size_type _Count) noexcept // strengthened @@ -298,8 +297,8 @@ public: } template <_Span_compatible_iterator _It, _Span_compatible_sentinel<_It> _Sentinel> - constexpr explicit(_Extent != dynamic_extent) - span(_It _First, _Sentinel _Last) noexcept(noexcept(_Last - _First)) // strengthened + constexpr explicit(_Extent != dynamic_extent) span(_It _First, _Sentinel _Last) + noexcept(noexcept(_Last - _First)) // strengthened : _Mybase(_STD to_address(_First), static_cast(_Last - _First)) { _STD _Adl_verify_range(_First, _Last); #if _CONTAINER_DEBUG_LEVEL > 0 diff --git a/stl/inc/spanstream b/stl/inc/spanstream index cf2347865b4..77a3bc478d9 100644 --- a/stl/inc/spanstream +++ b/stl/inc/spanstream @@ -10,9 +10,9 @@ #if !_HAS_CXX23 _EMIT_STL_WARNING(STL4038, "The contents of are available only with C++23 or later."); #else // ^^^ !_HAS_CXX23 / _HAS_CXX23 vvv +#include <__msvc_ostream.hpp> #include #include -#include #include #include #include @@ -207,6 +207,9 @@ public: explicit basic_ispanstream(_STD span<_Elem> _Span, ios_base::openmode _Which = ios_base::in) : _Mybase(_STD addressof(_Buf)), _Buf(_Span, _Which | ios_base::in) {} + explicit basic_ispanstream(_STD span _Span) + : basic_ispanstream(_STD span<_Elem>{const_cast<_Elem*>(_Span.data()), _Span.size()}) {} + basic_ispanstream(const basic_ispanstream&) = delete; basic_ispanstream(basic_ispanstream&& _Right) : _Mybase(_STD move(_Right)), _Buf(_STD move(_Right._Buf)) { @@ -217,8 +220,7 @@ public: requires ( !convertible_to<_ReadOnlyRange, _STD span<_Elem>> && convertible_to<_ReadOnlyRange, _STD span>) explicit basic_ispanstream(_ReadOnlyRange&& _Range) - : basic_ispanstream( - _STD span<_Elem>{const_cast<_Elem*>(_RANGES data(_Range)), static_cast(_RANGES size(_Range))}) {} + : basic_ispanstream(static_cast<_STD span>(_STD forward<_ReadOnlyRange>(_Range))) {} basic_ispanstream& operator=(const basic_ispanstream&) = delete; @@ -251,8 +253,8 @@ public: requires ( !convertible_to<_ReadOnlyRange, _STD span<_Elem>> && convertible_to<_ReadOnlyRange, _STD span>) void span(_ReadOnlyRange&& _Range) noexcept { - this->span( - _STD span<_Elem>{const_cast<_Elem*>(_RANGES data(_Range)), static_cast(_RANGES size(_Range))}); + const auto _Sp = static_cast<_STD span>(_STD forward<_ReadOnlyRange>(_Range)); + this->span(_STD span<_Elem>{const_cast<_Elem*>(_Sp.data()), _Sp.size()}); } private: diff --git a/stl/inc/sstream b/stl/inc/sstream index 338f3f41cd6..83e7ad49aa8 100644 --- a/stl/inc/sstream +++ b/stl/inc/sstream @@ -85,8 +85,8 @@ public: _Mysb::swap(_Right); } - basic_stringbuf& operator=(basic_stringbuf&& _Right) noexcept( - _Choose_pocma_v<_Alloc> != _Pocma_values::_No_propagate_allocators) /* strengthened */ { + basic_stringbuf& operator=(basic_stringbuf&& _Right) + noexcept(_Choose_pocma_v<_Alloc> != _Pocma_values::_No_propagate_allocators) /* strengthened */ { if (this != _STD addressof(_Right)) { _Assign_rv_no_alias(_STD move(_Right)); } @@ -135,8 +135,8 @@ public: _Right._Tidy(); } - void _Assign_rv_no_alias(basic_stringbuf&& _Right) noexcept( - _Choose_pocma_v<_Alloc> != _Pocma_values::_No_propagate_allocators) { + void _Assign_rv_no_alias(basic_stringbuf&& _Right) + noexcept(_Choose_pocma_v<_Alloc> != _Pocma_values::_No_propagate_allocators) { // pre: this != std::addressof(_Right) _Tidy(); if constexpr (_Choose_pocma_v<_Alloc> == _Pocma_values::_No_propagate_allocators) { @@ -654,8 +654,8 @@ public: : _Mybase(_STD addressof(_Stringbuffer)), _Stringbuffer((_Mybase::swap(_Right), _STD move(_Right._Stringbuffer))) {} - basic_istringstream& operator=(basic_istringstream&& _Right) noexcept( - _Choose_pocma_v<_Alloc> != _Pocma_values::_No_propagate_allocators) /* strengthened */ { + basic_istringstream& operator=(basic_istringstream&& _Right) + noexcept(_Choose_pocma_v<_Alloc> != _Pocma_values::_No_propagate_allocators) /* strengthened */ { if (this != _STD addressof(_Right)) { _Mybase::swap(_Right); _Stringbuffer._Assign_rv_no_alias(_STD move(_Right._Stringbuffer)); @@ -773,8 +773,8 @@ public: : _Mybase(_STD addressof(_Stringbuffer)), _Stringbuffer((_Mybase::swap(_Right), _STD move(_Right._Stringbuffer))) {} - basic_ostringstream& operator=(basic_ostringstream&& _Right) noexcept( - _Choose_pocma_v<_Alloc> != _Pocma_values::_No_propagate_allocators) /* strengthened */ { + basic_ostringstream& operator=(basic_ostringstream&& _Right) + noexcept(_Choose_pocma_v<_Alloc> != _Pocma_values::_No_propagate_allocators) /* strengthened */ { if (this != _STD addressof(_Right)) { _Mybase::swap(_Right); _Stringbuffer._Assign_rv_no_alias(_STD move(_Right._Stringbuffer)); @@ -898,8 +898,8 @@ public: : _Mybase(_STD addressof(_Stringbuffer)), _Stringbuffer((_Mybase::swap(_Right), _STD move(_Right._Stringbuffer))) {} - basic_stringstream& operator=(basic_stringstream&& _Right) noexcept( - _Choose_pocma_v<_Alloc> != _Pocma_values::_No_propagate_allocators) /* strengthened */ { + basic_stringstream& operator=(basic_stringstream&& _Right) + noexcept(_Choose_pocma_v<_Alloc> != _Pocma_values::_No_propagate_allocators) /* strengthened */ { if (this != _STD addressof(_Right)) { _Mybase::swap(_Right); _Stringbuffer._Assign_rv_no_alias(_STD move(_Right._Stringbuffer)); diff --git a/stl/inc/stack b/stl/inc/stack index 09931202339..02c404594c1 100644 --- a/stl/inc/stack +++ b/stl/inc/stack @@ -60,23 +60,23 @@ public: stack(const _Container& _Cont, const _Alloc& _Al) : c(_Cont, _Al) {} template , int> = 0> - stack(_Container&& _Cont, const _Alloc& _Al) noexcept( - is_nothrow_constructible_v<_Container, _Container, const _Alloc&>) // strengthened + stack(_Container&& _Cont, const _Alloc& _Al) + noexcept(is_nothrow_constructible_v<_Container, _Container, const _Alloc&>) // strengthened : c(_STD move(_Cont), _Al) {} template , int> = 0> stack(const stack& _Right, const _Alloc& _Al) : c(_Right.c, _Al) {} template , int> = 0> - stack(stack&& _Right, const _Alloc& _Al) noexcept( - is_nothrow_constructible_v<_Container, _Container, const _Alloc&>) // strengthened + stack(stack&& _Right, const _Alloc& _Al) + noexcept(is_nothrow_constructible_v<_Container, _Container, const _Alloc&>) // strengthened : c(_STD move(_Right.c), _Al) {} #if _HAS_CXX23 template <_Iterator_for_container _InIt, class _Alloc> requires uses_allocator_v<_Container, _Alloc> - stack(_InIt _First, _InIt _Last, const _Alloc& _Al) noexcept( - is_nothrow_constructible_v<_Container, _InIt, _InIt, const _Alloc&>) // strengthened + stack(_InIt _First, _InIt _Last, const _Alloc& _Al) + noexcept(is_nothrow_constructible_v<_Container, _InIt, _InIt, const _Alloc&>) // strengthened : c(_STD move(_First), _STD move(_Last), _Al) {} template <_Container_compatible_range<_Ty> _Rng, class _Alloc> diff --git a/stl/inc/stacktrace b/stl/inc/stacktrace index b5b57c00c9b..f48353556be 100644 --- a/stl/inc/stacktrace +++ b/stl/inc/stacktrace @@ -46,14 +46,14 @@ _NODISCARD unsigned short __stdcall __std_stacktrace_capture(unsigned long _Fram // Some of these functions may throw // (they would propagate bad_alloc potentially thrown from string::resize_and_overwrite) -void __stdcall __std_stacktrace_address_to_string( - const void* _Address, void* _Str, _Stacktrace_string_fill _Fill) noexcept(false); +void __stdcall __std_stacktrace_address_to_string(const void* _Address, void* _Str, _Stacktrace_string_fill _Fill) + noexcept(false); -void __stdcall __std_stacktrace_description( // - const void* _Address, void* _Str, _Stacktrace_string_fill _Fill) noexcept(false); +void __stdcall __std_stacktrace_description(const void* _Address, void* _Str, _Stacktrace_string_fill _Fill) + noexcept(false); -void __stdcall __std_stacktrace_source_file( // - const void* _Address, void* _Str, _Stacktrace_string_fill _Fill) noexcept(false); +void __stdcall __std_stacktrace_source_file(const void* _Address, void* _Str, _Stacktrace_string_fill _Fill) + noexcept(false); _NODISCARD unsigned int __stdcall __std_stacktrace_source_line(const void* _Address) noexcept; @@ -136,8 +136,8 @@ public: // __declspec(noinline) to make the same behavior for debug and release. // We force the current function to be always noinline and add its frame to skipped. - _NODISCARD __declspec(noinline) static basic_stacktrace - current(const allocator_type& _Al = allocator_type()) noexcept { + _NODISCARD __declspec(noinline) static basic_stacktrace current( + const allocator_type& _Al = allocator_type()) noexcept { _TRY_BEGIN basic_stacktrace _Result{_Internal_t{}, _Max_frames, _Al}; const unsigned short _Actual_size = __std_stacktrace_capture( @@ -149,8 +149,8 @@ public: _CATCH_END } - _NODISCARD __declspec(noinline) static basic_stacktrace - current(const size_type _Skip, const allocator_type& _Al = allocator_type()) noexcept { + _NODISCARD __declspec(noinline) static basic_stacktrace current( + const size_type _Skip, const allocator_type& _Al = allocator_type()) noexcept { _TRY_BEGIN basic_stacktrace _Result{_Internal_t{}, _Max_frames, _Al}; const unsigned short _Actual_size = __std_stacktrace_capture( @@ -162,8 +162,8 @@ public: _CATCH_END } - _NODISCARD __declspec(noinline) static basic_stacktrace - current(const size_type _Skip, size_type _Max_depth, const allocator_type& _Al = allocator_type()) noexcept { + _NODISCARD __declspec(noinline) static basic_stacktrace current( + const size_type _Skip, size_type _Max_depth, const allocator_type& _Al = allocator_type()) noexcept { _TRY_BEGIN if (_Max_depth > _Max_frames) { _Max_depth = _Max_frames; @@ -356,6 +356,9 @@ private: _Fill_align_and_width_formatter _Impl; }; +template <> +inline constexpr bool enable_nonlocking_formatter_optimization = true; + template struct formatter> { constexpr format_parse_context::iterator parse(format_parse_context& _Parse_ctx) { @@ -373,6 +376,9 @@ struct formatter> { } }; +template +constexpr bool enable_nonlocking_formatter_optimization> = true; + namespace pmr { _EXPORT_STD using stacktrace = basic_stacktrace>; } diff --git a/stl/inc/stop_token b/stl/inc/stop_token index 6e37adb0158..7444a69048c 100644 --- a/stl/inc/stop_token +++ b/stl/inc/stop_token @@ -359,16 +359,16 @@ public: template requires is_constructible_v<_Callback, _CbInitTy> - explicit stop_callback(const stop_token& _Token, _CbInitTy&& _Cb_) noexcept( - is_nothrow_constructible_v<_Callback, _CbInitTy>) + explicit stop_callback(const stop_token& _Token, _CbInitTy&& _Cb_) + noexcept(is_nothrow_constructible_v<_Callback, _CbInitTy>) : _Stop_callback_base{_Invoke_by_stop}, _Cb(_STD forward<_CbInitTy>(_Cb_)) { _Attach(_Token); } template requires is_constructible_v<_Callback, _CbInitTy> - explicit stop_callback(stop_token&& _Token, _CbInitTy&& _Cb_) noexcept( - is_nothrow_constructible_v<_Callback, _CbInitTy>) + explicit stop_callback(stop_token&& _Token, _CbInitTy&& _Cb_) + noexcept(is_nothrow_constructible_v<_Callback, _CbInitTy>) : _Stop_callback_base{_Invoke_by_stop}, _Cb(_STD forward<_CbInitTy>(_Cb_)) { _Attach(_STD move(_Token)); } diff --git a/stl/inc/thread b/stl/inc/thread index 079f4b7af36..3fd00318057 100644 --- a/stl/inc/thread +++ b/stl/inc/thread @@ -330,6 +330,9 @@ public: private: _Fill_align_and_width_formatter<_CharT> _Impl; }; + +template <> +inline constexpr bool enable_nonlocking_formatter_optimization = true; #endif // _HAS_CXX23 template <> diff --git a/stl/inc/tuple b/stl/inc/tuple index 0f79be7872e..81e42e4f9ce 100644 --- a/stl/inc/tuple +++ b/stl/inc/tuple @@ -175,7 +175,7 @@ template constexpr bool _Can_construct_values_from_tuple_like_v, _Other, index_sequence<_Indices...>> = conjunction_v(_STD declval<_Other>()))>...>; -#if defined(__clang__) || defined(__EDG__) // TRANSITION, LLVM-59827 and VSO-1900279 +#ifdef __EDG__ // TRANSITION, VSO-1900279 template concept _Can_construct_from_tuple_like = _Different_from<_TupleLike, _Tuple> && _Tuple_like<_TupleLike> && !_Is_subrange_v> @@ -307,7 +307,7 @@ public: template , int> = 0> constexpr tuple(_Tag, _Tpl&& _Right) : tuple(_Unpack_tuple_t{}, _STD forward<_Tpl>(_Right), - make_index_sequence>>{}) {} + make_index_sequence>>{}) {} template , int> = 0> @@ -322,7 +322,7 @@ public: template , int> = 0> constexpr tuple(_Tag, const _Alloc& _Al, _Tpl&& _Right) : tuple(_Alloc_unpack_tuple_t{}, _Al, _STD forward<_Tpl>(_Right), - make_index_sequence>>{}) {} + make_index_sequence>>{}) {} template , _STD is_default_constructible<_Rest>...>, @@ -334,17 +334,19 @@ public: : _Mybase(), _Myfirst() {} template , int> = 0> - constexpr explicit(_Tuple_conditional_explicit_v) tuple( - const _This& _This_arg, const _Rest&... _Rest_arg) noexcept(conjunction_v, - is_nothrow_copy_constructible<_Rest>...>) // strengthened + constexpr explicit(_Tuple_conditional_explicit_v) + tuple(const _This& _This_arg, const _Rest&... _Rest_arg) + noexcept(conjunction_v, + is_nothrow_copy_constructible<_Rest>...>) // strengthened : tuple(_Exact_args_t{}, _This_arg, _Rest_arg...) {} template , _STD _Tuple_constructible_val>, int> = 0> - constexpr explicit(_Tuple_conditional_explicit_v) tuple(_This2&& _This_arg, - _Rest2&&... _Rest_arg) noexcept(_Tuple_nothrow_constructible_v) // strengthened + constexpr explicit(_Tuple_conditional_explicit_v) + tuple(_This2&& _This_arg, _Rest2&&... _Rest_arg) + noexcept(_Tuple_nothrow_constructible_v) // strengthened : tuple(_Exact_args_t{}, _STD forward<_This2>(_This_arg), _STD forward<_Rest2>(_Rest_arg)...) {} tuple(const tuple&) = default; @@ -354,60 +356,57 @@ public: template , _STD _Tuple_convert_val&, _Other...>>, int> = 0> - constexpr explicit(_Tuple_conditional_explicit_v) - tuple(tuple<_Other...>& _Right) noexcept(_Tuple_nothrow_constructible_v) // strengthened + constexpr explicit(_Tuple_conditional_explicit_v) tuple(tuple<_Other...>& _Right) + noexcept(_Tuple_nothrow_constructible_v) // strengthened : tuple(_Unpack_tuple_t{}, _Right) {} #endif // _HAS_CXX23 template , _STD _Tuple_convert_val&, _Other...>>, int> = 0> - constexpr explicit(_Tuple_conditional_explicit_v) - tuple(const tuple<_Other...>& _Right) noexcept( - _Tuple_nothrow_constructible_v) // strengthened + constexpr explicit(_Tuple_conditional_explicit_v) tuple(const tuple<_Other...>& _Right) + noexcept(_Tuple_nothrow_constructible_v) // strengthened : tuple(_Unpack_tuple_t{}, _Right) {} template , _STD _Tuple_convert_val, _Other...>>, int> = 0> - constexpr explicit(_Tuple_conditional_explicit_v) - tuple(tuple<_Other...>&& _Right) noexcept(_Tuple_nothrow_constructible_v) // strengthened + constexpr explicit(_Tuple_conditional_explicit_v) tuple(tuple<_Other...>&& _Right) + noexcept(_Tuple_nothrow_constructible_v) // strengthened : tuple(_Unpack_tuple_t{}, _STD move(_Right)) {} #if _HAS_CXX23 template , _STD _Tuple_convert_val, _Other...>>, int> = 0> - constexpr explicit(_Tuple_conditional_explicit_v) - tuple(const tuple<_Other...>&& _Right) noexcept( - _Tuple_nothrow_constructible_v) // strengthened + constexpr explicit(_Tuple_conditional_explicit_v) tuple(const tuple<_Other...>&& _Right) + noexcept(_Tuple_nothrow_constructible_v) // strengthened : tuple(_Unpack_tuple_t{}, _STD move(_Right)) {} template , int> = 0> - constexpr explicit(_Tuple_conditional_explicit_v) - tuple(pair<_First, _Second>& _Right) noexcept( - _Tuple_nothrow_constructible_v) // strengthened + constexpr explicit(_Tuple_conditional_explicit_v) tuple(pair<_First, _Second>& _Right) + noexcept(_Tuple_nothrow_constructible_v) // strengthened : tuple(_Unpack_tuple_t{}, _Right) {} #endif // _HAS_CXX23 template , int> = 0> constexpr explicit(_Tuple_conditional_explicit_v) - tuple(const pair<_First, _Second>& _Right) noexcept( - _Tuple_nothrow_constructible_v) // strengthened + tuple(const pair<_First, _Second>& _Right) + noexcept(_Tuple_nothrow_constructible_v) // strengthened : tuple(_Unpack_tuple_t{}, _Right) {} template , int> = 0> - constexpr explicit(_Tuple_conditional_explicit_v) tuple( - pair<_First, _Second>&& _Right) noexcept(_Tuple_nothrow_constructible_v) // strengthened + constexpr explicit(_Tuple_conditional_explicit_v) tuple(pair<_First, _Second>&& _Right) + noexcept(_Tuple_nothrow_constructible_v) // strengthened : tuple(_Unpack_tuple_t{}, _STD move(_Right)) {} #if _HAS_CXX23 template , int> = 0> constexpr explicit(_Tuple_conditional_explicit_v) - tuple(const pair<_First, _Second>&& _Right) noexcept( - _Tuple_nothrow_constructible_v) // strengthened + tuple(const pair<_First, _Second>&& _Right) + noexcept(_Tuple_nothrow_constructible_v) // strengthened : tuple(_Unpack_tuple_t{}, _STD move(_Right)) {} template > @@ -418,7 +417,7 @@ public: negation_v(_STD declval<_Other>())), _This>, is_convertible(_STD declval<_Other>())), _Rest>...>>; -#if defined(__clang__) || defined(__EDG__) // TRANSITION, LLVM-59827 and VSO-1900279 +#ifdef __EDG__ // TRANSITION, VSO-1900279 template , int> = 0> #else // ^^^ workaround / no workaround vvv template <_Different_from _Other> @@ -524,7 +523,7 @@ public: tuple(allocator_arg_t, const _Alloc& _Al, const pair<_First, _Second>&& _Right) : tuple(_Alloc_unpack_tuple_t{}, _Al, _STD move(_Right)) {} -#if defined(__clang__) || defined(__EDG__) // TRANSITION, LLVM-59827 (Clang), VSO-1900279 (EDG) +#ifdef __EDG__ // TRANSITION, VSO-1900279 template , int> = 0> #else // ^^^ workaround / no workaround vvv template _Other> @@ -569,8 +568,8 @@ public: enable_if_t, _STD _Is_move_assignable_no_precondition_check<_Rest>...>, int> = 0> - _CONSTEXPR20 tuple& operator=(_Identity_t<_Myself&&> _Right) noexcept( - conjunction_v, is_nothrow_move_assignable<_Rest>...>) { + _CONSTEXPR20 tuple& operator=(_Identity_t<_Myself&&> _Right) + noexcept(conjunction_v, is_nothrow_move_assignable<_Rest>...>) { _Myfirst._Val = _STD forward<_This>(_Right._Myfirst._Val); _Get_rest() = _STD forward<_Mybase>(_Right._Get_rest()); return *this; @@ -592,8 +591,8 @@ public: template >>, _STD _Tuple_assignable_val>, int> = 0> - _CONSTEXPR20 tuple& operator=(const tuple<_Other...>& _Right) noexcept( - _Tuple_nothrow_assignable_v) /* strengthened */ { + _CONSTEXPR20 tuple& operator=(const tuple<_Other...>& _Right) + noexcept(_Tuple_nothrow_assignable_v) /* strengthened */ { _Myfirst._Val = _Right._Myfirst._Val; _Get_rest() = _Right._Get_rest(); return *this; @@ -613,8 +612,8 @@ public: template >>, _STD _Tuple_assignable_val>, int> = 0> - _CONSTEXPR20 tuple& operator=(tuple<_Other...>&& _Right) noexcept( - _Tuple_nothrow_assignable_v) /* strengthened */ { + _CONSTEXPR20 tuple& operator=(tuple<_Other...>&& _Right) + noexcept(_Tuple_nothrow_assignable_v) /* strengthened */ { _Myfirst._Val = _STD forward::_This_type>(_Right._Myfirst._Val); _Get_rest() = _STD forward::_Mybase>(_Right._Get_rest()); return *this; @@ -633,8 +632,8 @@ public: template , int> = 0> - _CONSTEXPR20 tuple& operator=(const pair<_First, _Second>& _Right) noexcept( - _Tuple_nothrow_assignable_v) /* strengthened */ { + _CONSTEXPR20 tuple& operator=(const pair<_First, _Second>& _Right) + noexcept(_Tuple_nothrow_assignable_v) /* strengthened */ { _Myfirst._Val = _Right.first; _Get_rest()._Myfirst._Val = _Right.second; return *this; @@ -652,8 +651,8 @@ public: #endif // _HAS_CXX23 template , int> = 0> - _CONSTEXPR20 tuple& operator=(pair<_First, _Second>&& _Right) noexcept( - _Tuple_nothrow_assignable_v) /* strengthened */ { + _CONSTEXPR20 tuple& operator=(pair<_First, _Second>&& _Right) + noexcept(_Tuple_nothrow_assignable_v) /* strengthened */ { _Myfirst._Val = _STD forward<_First>(_Right.first); _Get_rest()._Myfirst._Val = _STD forward<_Second>(_Right.second); return *this; @@ -711,8 +710,8 @@ public: } #endif // _HAS_CXX23 - _CONSTEXPR20 void swap(tuple& _Right) noexcept( - conjunction_v<_Is_nothrow_swappable<_This>, _Is_nothrow_swappable<_Rest>...>) { + _CONSTEXPR20 void swap(tuple& _Right) + noexcept(conjunction_v<_Is_nothrow_swappable<_This>, _Is_nothrow_swappable<_Rest>...>) { using _STD swap; swap(_Myfirst._Val, _Right._Myfirst._Val); // intentional ADL _Mybase::swap(_Right._Get_rest()); @@ -786,7 +785,7 @@ public: } template <_Tuple_like_non_tuple _Other> - _NODISCARD friend constexpr auto operator<=>(const tuple& _Left, const _Other& _Right) + _NODISCARD friend constexpr auto operator<=>(const tuple& _Left, const _Other& _Right) // -> _Three_way_comparison_result_with_tuple_like_t { return _Left._Three_way_compare_with_tuple_like(_Right, make_index_sequence<1 + sizeof...(_Rest)>{}); } @@ -895,8 +894,8 @@ _CONSTEXPR20 void swap(tuple<_Types...>& _Left, tuple<_Types...>& _Right) noexce #if _HAS_CXX23 _EXPORT_STD template requires conjunction_v...> -constexpr void swap(const tuple<_Types...>& _Left, const tuple<_Types...>& _Right) noexcept( - noexcept(_Left.swap(_Right))) { +constexpr void swap(const tuple<_Types...>& _Left, const tuple<_Types...>& _Right) + noexcept(noexcept(_Left.swap(_Right))) { _Left.swap(_Right); } #endif // _HAS_CXX23 @@ -1059,8 +1058,8 @@ template #else // ^^^ _HAS_CXX23 / !_HAS_CXX23 vvv template #endif // ^^^ !_HAS_CXX23 ^^^ -constexpr decltype(auto) _Apply_impl(_Callable&& _Obj, _Tuple&& _Tpl, index_sequence<_Indices...>) noexcept( - noexcept(_STD invoke(_STD forward<_Callable>(_Obj), _STD get<_Indices>(_STD forward<_Tuple>(_Tpl))...))) { +constexpr decltype(auto) _Apply_impl(_Callable&& _Obj, _Tuple&& _Tpl, index_sequence<_Indices...>) + noexcept(noexcept(_STD invoke(_STD forward<_Callable>(_Obj), _STD get<_Indices>(_STD forward<_Tuple>(_Tpl))...))) { return _STD invoke(_STD forward<_Callable>(_Obj), _STD get<_Indices>(_STD forward<_Tuple>(_Tpl))...); } @@ -1069,8 +1068,8 @@ _EXPORT_STD template #else // ^^^ _HAS_CXX23 / !_HAS_CXX23 vvv _EXPORT_STD template #endif // ^^^ !_HAS_CXX23 ^^^ -constexpr decltype(auto) apply(_Callable&& _Obj, _Tuple&& _Tpl) noexcept( - noexcept(_STD _Apply_impl(_STD forward<_Callable>(_Obj), _STD forward<_Tuple>(_Tpl), +constexpr decltype(auto) apply(_Callable&& _Obj, _Tuple&& _Tpl) + noexcept(noexcept(_STD _Apply_impl(_STD forward<_Callable>(_Obj), _STD forward<_Tuple>(_Tpl), make_index_sequence>>{}))) { return _STD _Apply_impl(_STD forward<_Callable>(_Obj), _STD forward<_Tuple>(_Tpl), make_index_sequence>>{}); @@ -1083,8 +1082,8 @@ constexpr bool _Can_make_from_tuple<_Ty, _Tuple, index_sequence<_Indices...>> = is_constructible_v<_Ty, decltype(_STD get<_Indices>(_STD declval<_Tuple>()))...>; template -constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>) noexcept( - is_nothrow_constructible_v<_Ty, decltype(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl)))...>) { +constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>) + noexcept(is_nothrow_constructible_v<_Ty, decltype(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl)))...>) { return _Ty(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl))...); } @@ -1127,9 +1126,8 @@ struct _Tuple_like_common_reference<_TTuple, _UTuple, _TQual, _UQual, index_sequ template <_Tuple_like _TTuple, _Tuple_like _UTuple, template class _TQual, template class _UQual> requires (_Is_specialization_v<_TTuple, tuple> || _Is_specialization_v<_UTuple, tuple>) && is_same_v<_TTuple, decay_t<_TTuple>> && is_same_v<_UTuple, decay_t<_UTuple>> - && (tuple_size_v<_TTuple> == tuple_size_v<_UTuple>) && requires { - typename _Tuple_like_common_reference<_TTuple, _UTuple, _TQual, _UQual>::type; - } + && (tuple_size_v<_TTuple> == tuple_size_v<_UTuple>) + && requires { typename _Tuple_like_common_reference<_TTuple, _UTuple, _TQual, _UQual>::type; } struct basic_common_reference<_TTuple, _UTuple, _TQual, _UQual> { using type = _Tuple_like_common_reference<_TTuple, _UTuple, _TQual, _UQual>::type; }; @@ -1148,9 +1146,8 @@ struct _Tuple_like_common_type<_TTuple, _UTuple, index_sequence<_Indices...>> { template <_Tuple_like _TTuple, _Tuple_like _UTuple> requires (_Is_specialization_v<_TTuple, tuple> || _Is_specialization_v<_UTuple, tuple>) && is_same_v<_TTuple, decay_t<_TTuple>> && is_same_v<_UTuple, decay_t<_UTuple>> - && (tuple_size_v<_TTuple> == tuple_size_v<_UTuple>) && requires { - typename _Tuple_like_common_type<_TTuple, _UTuple>::type; - } + && (tuple_size_v<_TTuple> == tuple_size_v<_UTuple>) + && requires { typename _Tuple_like_common_type<_TTuple, _UTuple>::type; } struct common_type<_TTuple, _UTuple> { using type = _Tuple_like_common_type<_TTuple, _UTuple>::type; }; diff --git a/stl/inc/type_traits b/stl/inc/type_traits index 3f941094cd8..91f78d99c2f 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -1596,8 +1596,8 @@ struct _Invoker_functor { static constexpr _Invoker_strategy _Strategy = _Invoker_strategy::_Functor; template - static constexpr auto _Call(_Callable&& _Obj, _Types&&... _Args) noexcept( - noexcept(static_cast<_Callable&&>(_Obj)(static_cast<_Types&&>(_Args)...))) + static constexpr auto _Call(_Callable&& _Obj, _Types&&... _Args) + noexcept(noexcept(static_cast<_Callable&&>(_Obj)(static_cast<_Types&&>(_Args)...))) // -> decltype(static_cast<_Callable&&>(_Obj)(static_cast<_Types&&>(_Args)...)) { return static_cast<_Callable&&>(_Obj)(static_cast<_Types&&>(_Args)...); } @@ -1607,8 +1607,8 @@ struct _Invoker_pmf_object { static constexpr _Invoker_strategy _Strategy = _Invoker_strategy::_Pmf_object; template - static constexpr auto _Call(_Decayed _Pmf, _Ty1&& _Arg1, _Types2&&... _Args2) noexcept( - noexcept((static_cast<_Ty1&&>(_Arg1).*_Pmf)(static_cast<_Types2&&>(_Args2)...))) + static constexpr auto _Call(_Decayed _Pmf, _Ty1&& _Arg1, _Types2&&... _Args2) + noexcept(noexcept((static_cast<_Ty1&&>(_Arg1).*_Pmf)(static_cast<_Types2&&>(_Args2)...))) // -> decltype((static_cast<_Ty1&&>(_Arg1).*_Pmf)(static_cast<_Types2&&>(_Args2)...)) { return (static_cast<_Ty1&&>(_Arg1).*_Pmf)(static_cast<_Types2&&>(_Args2)...); } @@ -1618,8 +1618,8 @@ struct _Invoker_pmf_refwrap { static constexpr _Invoker_strategy _Strategy = _Invoker_strategy::_Pmf_refwrap; template - static constexpr auto _Call(_Decayed _Pmf, _Refwrap _Rw, _Types2&&... _Args2) noexcept( - noexcept((_Rw.get().*_Pmf)(static_cast<_Types2&&>(_Args2)...))) + static constexpr auto _Call(_Decayed _Pmf, _Refwrap _Rw, _Types2&&... _Args2) + noexcept(noexcept((_Rw.get().*_Pmf)(static_cast<_Types2&&>(_Args2)...))) // -> decltype((_Rw.get().*_Pmf)(static_cast<_Types2&&>(_Args2)...)) { return (_Rw.get().*_Pmf)(static_cast<_Types2&&>(_Args2)...); } @@ -1629,8 +1629,8 @@ struct _Invoker_pmf_pointer { static constexpr _Invoker_strategy _Strategy = _Invoker_strategy::_Pmf_pointer; template - static constexpr auto _Call(_Decayed _Pmf, _Ty1&& _Arg1, _Types2&&... _Args2) noexcept( - noexcept(((*static_cast<_Ty1&&>(_Arg1)).*_Pmf)(static_cast<_Types2&&>(_Args2)...))) + static constexpr auto _Call(_Decayed _Pmf, _Ty1&& _Arg1, _Types2&&... _Args2) + noexcept(noexcept(((*static_cast<_Ty1&&>(_Arg1)).*_Pmf)(static_cast<_Types2&&>(_Args2)...))) // -> decltype(((*static_cast<_Ty1&&>(_Arg1)).*_Pmf)(static_cast<_Types2&&>(_Args2)...)) { return ((*static_cast<_Ty1&&>(_Arg1)).*_Pmf)(static_cast<_Types2&&>(_Args2)...); } @@ -1658,8 +1658,8 @@ struct _Invoker_pmd_pointer { static constexpr _Invoker_strategy _Strategy = _Invoker_strategy::_Pmd_pointer; template - static constexpr auto _Call(_Decayed _Pmd, _Ty1&& _Arg1) noexcept(noexcept((*static_cast<_Ty1&&>(_Arg1)).*_Pmd)) - -> decltype((*static_cast<_Ty1&&>(_Arg1)).*_Pmd) { + static constexpr auto _Call(_Decayed _Pmd, _Ty1&& _Arg1) + noexcept(noexcept((*static_cast<_Ty1&&>(_Arg1)).*_Pmd)) -> decltype((*static_cast<_Ty1&&>(_Arg1)).*_Pmd) { return (*static_cast<_Ty1&&>(_Arg1)).*_Pmd; } }; @@ -1690,15 +1690,15 @@ template struct _Invoker1<_Callable, _Ty1, _Removed_cvref, false, false> : _Invoker_functor {}; _EXPORT_STD template -constexpr auto invoke(_Callable&& _Obj) noexcept(noexcept(static_cast<_Callable&&>(_Obj)())) - -> decltype(static_cast<_Callable&&>(_Obj)()) { +constexpr auto invoke(_Callable&& _Obj) + noexcept(noexcept(static_cast<_Callable&&>(_Obj)())) -> decltype(static_cast<_Callable&&>(_Obj)()) { return static_cast<_Callable&&>(_Obj)(); } _EXPORT_STD template -constexpr auto invoke(_Callable&& _Obj, _Ty1&& _Arg1, _Types2&&... _Args2) noexcept( - noexcept(_Invoker1<_Callable, _Ty1>::_Call( - static_cast<_Callable&&>(_Obj), static_cast<_Ty1&&>(_Arg1), static_cast<_Types2&&>(_Args2)...))) +constexpr auto invoke(_Callable&& _Obj, _Ty1&& _Arg1, _Types2&&... _Args2) + noexcept(noexcept(_Invoker1<_Callable, _Ty1>::_Call( + static_cast<_Callable&&>(_Obj), static_cast<_Ty1&&>(_Arg1), static_cast<_Types2&&>(_Args2)...))) // -> decltype(_Invoker1<_Callable, _Ty1>::_Call( static_cast<_Callable&&>(_Obj), static_cast<_Ty1&&>(_Arg1), static_cast<_Types2&&>(_Args2)...)) { if constexpr (_Invoker1<_Callable, _Ty1>::_Strategy == _Invoker_strategy::_Functor) { @@ -2028,8 +2028,8 @@ private: public: template _CONSTEXPR20 auto operator()(_Types&&... _Args) const - noexcept(noexcept(_STD invoke(*_Ptr, static_cast<_Types&&>(_Args)...))) - -> decltype(_STD invoke(*_Ptr, static_cast<_Types&&>(_Args)...)) { + noexcept(noexcept(_STD invoke(*_Ptr, static_cast<_Types&&>(_Args)...))) // + -> decltype(_STD invoke(*_Ptr, static_cast<_Types&&>(_Args)...)) { return _STD invoke(*_Ptr, static_cast<_Types&&>(_Args)...); } }; diff --git a/stl/inc/unordered_map b/stl/inc/unordered_map index d0f0b2aa902..b8aff218ae4 100644 --- a/stl/inc/unordered_map +++ b/stl/inc/unordered_map @@ -249,9 +249,9 @@ public: unordered_map(unordered_map&& _Right, const allocator_type& _Al) : _Mybase(_STD move(_Right), _Al) {} - unordered_map& operator=(unordered_map&& _Right) noexcept(_Alnode_traits::is_always_equal::value - && is_nothrow_move_assignable_v<_Hasher> - && is_nothrow_move_assignable_v<_Keyeq>) { + unordered_map& operator=(unordered_map&& _Right) + noexcept(_Alnode_traits::is_always_equal::value + && is_nothrow_move_assignable_v<_Hasher> && is_nothrow_move_assignable_v<_Keyeq>) { _Mybase::operator=(_STD move(_Right)); return *this; } @@ -461,8 +461,8 @@ template >, class _Keyeq = enable_if_t< conjunction_v<_Is_iterator<_Iter>, _Is_hasher<_Hasher>, negation<_Is_allocator<_Keyeq>>, _Is_allocator<_Alloc>>, int> = 0> -unordered_map(_Iter, _Iter, _Guide_size_type_t<_Alloc> = 0, _Hasher = _Hasher(), _Keyeq = _Keyeq(), _Alloc = _Alloc()) - -> unordered_map<_Guide_key_t<_Iter>, _Guide_val_t<_Iter>, _Hasher, _Keyeq, _Alloc>; +unordered_map(_Iter, _Iter, _Guide_size_type_t<_Alloc> = 0, _Hasher = _Hasher(), _Keyeq = _Keyeq(), + _Alloc = _Alloc()) -> unordered_map<_Guide_key_t<_Iter>, _Guide_val_t<_Iter>, _Hasher, _Keyeq, _Alloc>; template , class _Keyeq = equal_to<_Kty>, class _Alloc = allocator>, @@ -472,29 +472,30 @@ unordered_map(initializer_list>, _Guide_size_type_t<_Alloc> = 0, template , _Is_allocator<_Alloc>>, int> = 0> unordered_map(_Iter, _Iter, _Alloc) -> unordered_map<_Guide_key_t<_Iter>, _Guide_val_t<_Iter>, - hash<_Guide_key_t<_Iter>>, equal_to<_Guide_key_t<_Iter>>, _Alloc>; + hash<_Guide_key_t<_Iter>>, equal_to<_Guide_key_t<_Iter>>, _Alloc>; template , _Is_allocator<_Alloc>>, int> = 0> -unordered_map(_Iter, _Iter, _Guide_size_type_t<_Alloc>, _Alloc) -> unordered_map<_Guide_key_t<_Iter>, - _Guide_val_t<_Iter>, hash<_Guide_key_t<_Iter>>, equal_to<_Guide_key_t<_Iter>>, _Alloc>; +unordered_map(_Iter, _Iter, _Guide_size_type_t<_Alloc>, + _Alloc) -> unordered_map<_Guide_key_t<_Iter>, _Guide_val_t<_Iter>, hash<_Guide_key_t<_Iter>>, + equal_to<_Guide_key_t<_Iter>>, _Alloc>; template , _Is_hasher<_Hasher>, _Is_allocator<_Alloc>>, int> = 0> -unordered_map(_Iter, _Iter, _Guide_size_type_t<_Alloc>, _Hasher, _Alloc) - -> unordered_map<_Guide_key_t<_Iter>, _Guide_val_t<_Iter>, _Hasher, equal_to<_Guide_key_t<_Iter>>, _Alloc>; +unordered_map(_Iter, _Iter, _Guide_size_type_t<_Alloc>, _Hasher, + _Alloc) -> unordered_map<_Guide_key_t<_Iter>, _Guide_val_t<_Iter>, _Hasher, equal_to<_Guide_key_t<_Iter>>, _Alloc>; template ::value, int> = 0> -unordered_map(initializer_list>, _Alloc) - -> unordered_map<_Kty, _Ty, hash<_Kty>, equal_to<_Kty>, _Alloc>; +unordered_map( + initializer_list>, _Alloc) -> unordered_map<_Kty, _Ty, hash<_Kty>, equal_to<_Kty>, _Alloc>; template ::value, int> = 0> -unordered_map(initializer_list>, _Guide_size_type_t<_Alloc>, _Alloc) - -> unordered_map<_Kty, _Ty, hash<_Kty>, equal_to<_Kty>, _Alloc>; +unordered_map(initializer_list>, _Guide_size_type_t<_Alloc>, + _Alloc) -> unordered_map<_Kty, _Ty, hash<_Kty>, equal_to<_Kty>, _Alloc>; template , _Is_allocator<_Alloc>>, int> = 0> -unordered_map(initializer_list>, _Guide_size_type_t<_Alloc>, _Hasher, _Alloc) - -> unordered_map<_Kty, _Ty, _Hasher, equal_to<_Kty>, _Alloc>; +unordered_map(initializer_list>, _Guide_size_type_t<_Alloc>, _Hasher, + _Alloc) -> unordered_map<_Kty, _Ty, _Hasher, equal_to<_Kty>, _Alloc>; #if _HAS_CXX23 template <_RANGES input_range _Rng, _Hasher_for_container _Hasher = hash<_Range_key_type<_Rng>>, @@ -505,12 +506,13 @@ unordered_map(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc> = 0, _Hasher = _H _Alloc = _Alloc()) -> unordered_map<_Range_key_type<_Rng>, _Range_mapped_type<_Rng>, _Hasher, _Keyeq, _Alloc>; template <_RANGES input_range _Rng, _Allocator_for_container _Alloc> -unordered_map(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc>, _Alloc) -> unordered_map<_Range_key_type<_Rng>, - _Range_mapped_type<_Rng>, hash<_Range_key_type<_Rng>>, equal_to<_Range_key_type<_Rng>>, _Alloc>; +unordered_map(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc>, + _Alloc) -> unordered_map<_Range_key_type<_Rng>, _Range_mapped_type<_Rng>, hash<_Range_key_type<_Rng>>, + equal_to<_Range_key_type<_Rng>>, _Alloc>; template <_RANGES input_range _Rng, _Allocator_for_container _Alloc> unordered_map(from_range_t, _Rng&&, _Alloc) -> unordered_map<_Range_key_type<_Rng>, _Range_mapped_type<_Rng>, - hash<_Range_key_type<_Rng>>, equal_to<_Range_key_type<_Rng>>, _Alloc>; + hash<_Range_key_type<_Rng>>, equal_to<_Range_key_type<_Rng>>, _Alloc>; template <_RANGES input_range _Rng, _Hasher_for_container _Hasher, _Allocator_for_container _Alloc> unordered_map(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc>, _Hasher, _Alloc) @@ -737,9 +739,9 @@ public: unordered_multimap(unordered_multimap&& _Right, const allocator_type& _Al) : _Mybase(_STD move(_Right), _Al) {} - unordered_multimap& operator=(unordered_multimap&& _Right) noexcept(_Alnode_traits::is_always_equal::value - && is_nothrow_move_assignable_v<_Hasher> - && is_nothrow_move_assignable_v<_Keyeq>) { + unordered_multimap& operator=(unordered_multimap&& _Right) + noexcept(_Alnode_traits::is_always_equal::value + && is_nothrow_move_assignable_v<_Hasher> && is_nothrow_move_assignable_v<_Keyeq>) { _Mybase::operator=(_STD move(_Right)); return *this; } @@ -842,11 +844,12 @@ unordered_multimap(initializer_list>, _Guide_size_type_t<_Alloc> template , _Is_allocator<_Alloc>>, int> = 0> unordered_multimap(_Iter, _Iter, _Alloc) -> unordered_multimap<_Guide_key_t<_Iter>, _Guide_val_t<_Iter>, - hash<_Guide_key_t<_Iter>>, equal_to<_Guide_key_t<_Iter>>, _Alloc>; + hash<_Guide_key_t<_Iter>>, equal_to<_Guide_key_t<_Iter>>, _Alloc>; template , _Is_allocator<_Alloc>>, int> = 0> -unordered_multimap(_Iter, _Iter, _Guide_size_type_t<_Alloc>, _Alloc) -> unordered_multimap<_Guide_key_t<_Iter>, - _Guide_val_t<_Iter>, hash<_Guide_key_t<_Iter>>, equal_to<_Guide_key_t<_Iter>>, _Alloc>; +unordered_multimap(_Iter, _Iter, _Guide_size_type_t<_Alloc>, + _Alloc) -> unordered_multimap<_Guide_key_t<_Iter>, _Guide_val_t<_Iter>, hash<_Guide_key_t<_Iter>>, + equal_to<_Guide_key_t<_Iter>>, _Alloc>; template , _Is_hasher<_Hasher>, _Is_allocator<_Alloc>>, int> = 0> @@ -854,17 +857,17 @@ unordered_multimap(_Iter, _Iter, _Guide_size_type_t<_Alloc>, _Hasher, _Alloc) -> unordered_multimap<_Guide_key_t<_Iter>, _Guide_val_t<_Iter>, _Hasher, equal_to<_Guide_key_t<_Iter>>, _Alloc>; template ::value, int> = 0> -unordered_multimap(initializer_list>, _Alloc) - -> unordered_multimap<_Kty, _Ty, hash<_Kty>, equal_to<_Kty>, _Alloc>; +unordered_multimap( + initializer_list>, _Alloc) -> unordered_multimap<_Kty, _Ty, hash<_Kty>, equal_to<_Kty>, _Alloc>; template ::value, int> = 0> -unordered_multimap(initializer_list>, _Guide_size_type_t<_Alloc>, _Alloc) - -> unordered_multimap<_Kty, _Ty, hash<_Kty>, equal_to<_Kty>, _Alloc>; +unordered_multimap(initializer_list>, _Guide_size_type_t<_Alloc>, + _Alloc) -> unordered_multimap<_Kty, _Ty, hash<_Kty>, equal_to<_Kty>, _Alloc>; template , _Is_allocator<_Alloc>>, int> = 0> -unordered_multimap(initializer_list>, _Guide_size_type_t<_Alloc>, _Hasher, _Alloc) - -> unordered_multimap<_Kty, _Ty, _Hasher, equal_to<_Kty>, _Alloc>; +unordered_multimap(initializer_list>, _Guide_size_type_t<_Alloc>, _Hasher, + _Alloc) -> unordered_multimap<_Kty, _Ty, _Hasher, equal_to<_Kty>, _Alloc>; #if _HAS_CXX23 template <_RANGES input_range _Rng, _Hasher_for_container _Hasher = hash<_Range_key_type<_Rng>>, @@ -875,18 +878,19 @@ unordered_multimap(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc> = 0, _Hasher _Alloc = _Alloc()) -> unordered_multimap<_Range_key_type<_Rng>, _Range_mapped_type<_Rng>, _Hasher, _Keyeq, _Alloc>; template <_RANGES input_range _Rng, _Allocator_for_container _Alloc> -unordered_multimap(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc>, _Alloc) - -> unordered_multimap<_Range_key_type<_Rng>, _Range_mapped_type<_Rng>, hash<_Range_key_type<_Rng>>, - equal_to<_Range_key_type<_Rng>>, _Alloc>; +unordered_multimap(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc>, + _Alloc) -> unordered_multimap<_Range_key_type<_Rng>, _Range_mapped_type<_Rng>, hash<_Range_key_type<_Rng>>, + equal_to<_Range_key_type<_Rng>>, _Alloc>; template <_RANGES input_range _Rng, _Allocator_for_container _Alloc> -unordered_multimap(from_range_t, _Rng&&, _Alloc) -> unordered_multimap<_Range_key_type<_Rng>, _Range_mapped_type<_Rng>, - hash<_Range_key_type<_Rng>>, equal_to<_Range_key_type<_Rng>>, _Alloc>; +unordered_multimap( + from_range_t, _Rng&&, _Alloc) -> unordered_multimap<_Range_key_type<_Rng>, _Range_mapped_type<_Rng>, + hash<_Range_key_type<_Rng>>, equal_to<_Range_key_type<_Rng>>, _Alloc>; template <_RANGES input_range _Rng, _Hasher_for_container _Hasher, _Allocator_for_container _Alloc> -unordered_multimap(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc>, _Hasher, _Alloc) - -> unordered_multimap<_Range_key_type<_Rng>, _Range_mapped_type<_Rng>, _Hasher, equal_to<_Range_key_type<_Rng>>, - _Alloc>; +unordered_multimap(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc>, _Hasher, + _Alloc) -> unordered_multimap<_Range_key_type<_Rng>, _Range_mapped_type<_Rng>, _Hasher, + equal_to<_Range_key_type<_Rng>>, _Alloc>; #endif // _HAS_CXX23 #endif // _HAS_CXX17 diff --git a/stl/inc/unordered_set b/stl/inc/unordered_set index e94e2b68062..7e49770386f 100644 --- a/stl/inc/unordered_set +++ b/stl/inc/unordered_set @@ -245,9 +245,9 @@ public: unordered_set(unordered_set&& _Right, const allocator_type& _Al) : _Mybase(_STD move(_Right), _Al) {} - unordered_set& operator=(unordered_set&& _Right) noexcept(_Alnode_traits::is_always_equal::value - && is_nothrow_move_assignable_v<_Hasher> - && is_nothrow_move_assignable_v<_Keyeq>) { + unordered_set& operator=(unordered_set&& _Right) + noexcept(_Alnode_traits::is_always_equal::value + && is_nothrow_move_assignable_v<_Hasher> && is_nothrow_move_assignable_v<_Keyeq>) { _Mybase::operator=(_STD move(_Right)); return *this; } @@ -326,8 +326,8 @@ template >, class _Keyeq enable_if_t< conjunction_v<_Is_iterator<_Iter>, _Is_hasher<_Hasher>, negation<_Is_allocator<_Keyeq>>, _Is_allocator<_Alloc>>, int> = 0> -unordered_set(_Iter, _Iter, _Guide_size_type_t<_Alloc> = 0, _Hasher = _Hasher(), _Keyeq = _Keyeq(), _Alloc = _Alloc()) - -> unordered_set<_Iter_value_t<_Iter>, _Hasher, _Keyeq, _Alloc>; +unordered_set(_Iter, _Iter, _Guide_size_type_t<_Alloc> = 0, _Hasher = _Hasher(), _Keyeq = _Keyeq(), + _Alloc = _Alloc()) -> unordered_set<_Iter_value_t<_Iter>, _Hasher, _Keyeq, _Alloc>; template , class _Keyeq = equal_to<_Kty>, class _Alloc = allocator<_Kty>, enable_if_t, negation<_Is_allocator<_Keyeq>>, _Is_allocator<_Alloc>>, int> = 0> @@ -335,22 +335,22 @@ unordered_set(initializer_list<_Kty>, _Guide_size_type_t<_Alloc> = 0, _Hasher = _Alloc = _Alloc()) -> unordered_set<_Kty, _Hasher, _Keyeq, _Alloc>; template , _Is_allocator<_Alloc>>, int> = 0> -unordered_set(_Iter, _Iter, _Guide_size_type_t<_Alloc>, _Alloc) - -> unordered_set<_Iter_value_t<_Iter>, hash<_Iter_value_t<_Iter>>, equal_to<_Iter_value_t<_Iter>>, _Alloc>; +unordered_set(_Iter, _Iter, _Guide_size_type_t<_Alloc>, + _Alloc) -> unordered_set<_Iter_value_t<_Iter>, hash<_Iter_value_t<_Iter>>, equal_to<_Iter_value_t<_Iter>>, _Alloc>; template , _Is_hasher<_Hasher>, _Is_allocator<_Alloc>>, int> = 0> -unordered_set(_Iter, _Iter, _Guide_size_type_t<_Alloc>, _Hasher, _Alloc) - -> unordered_set<_Iter_value_t<_Iter>, _Hasher, equal_to<_Iter_value_t<_Iter>>, _Alloc>; +unordered_set(_Iter, _Iter, _Guide_size_type_t<_Alloc>, _Hasher, + _Alloc) -> unordered_set<_Iter_value_t<_Iter>, _Hasher, equal_to<_Iter_value_t<_Iter>>, _Alloc>; template ::value, int> = 0> -unordered_set(initializer_list<_Kty>, _Guide_size_type_t<_Alloc>, _Alloc) - -> unordered_set<_Kty, hash<_Kty>, equal_to<_Kty>, _Alloc>; +unordered_set(initializer_list<_Kty>, _Guide_size_type_t<_Alloc>, + _Alloc) -> unordered_set<_Kty, hash<_Kty>, equal_to<_Kty>, _Alloc>; template , _Is_allocator<_Alloc>>, int> = 0> -unordered_set(initializer_list<_Kty>, _Guide_size_type_t<_Alloc>, _Hasher, _Alloc) - -> unordered_set<_Kty, _Hasher, equal_to<_Kty>, _Alloc>; +unordered_set(initializer_list<_Kty>, _Guide_size_type_t<_Alloc>, _Hasher, + _Alloc) -> unordered_set<_Kty, _Hasher, equal_to<_Kty>, _Alloc>; #if _HAS_CXX23 template <_RANGES input_range _Rng, _Hasher_for_container _Hasher = hash<_RANGES range_value_t<_Rng>>, @@ -361,22 +361,24 @@ unordered_set(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc> = 0, _Hasher = _H _Alloc = _Alloc()) -> unordered_set<_RANGES range_value_t<_Rng>, _Hasher, _Keyeq, _Alloc>; template <_RANGES input_range _Rng, _Allocator_for_container _Alloc> -unordered_set(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc>, _Alloc) -> unordered_set<_RANGES range_value_t<_Rng>, - hash<_RANGES range_value_t<_Rng>>, equal_to<_RANGES range_value_t<_Rng>>, _Alloc>; +unordered_set(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc>, + _Alloc) -> unordered_set<_RANGES range_value_t<_Rng>, hash<_RANGES range_value_t<_Rng>>, + equal_to<_RANGES range_value_t<_Rng>>, _Alloc>; template <_RANGES input_range _Rng, _Allocator_for_container _Alloc> -unordered_set(from_range_t, _Rng&&, _Alloc) -> unordered_set<_RANGES range_value_t<_Rng>, - hash<_RANGES range_value_t<_Rng>>, equal_to<_RANGES range_value_t<_Rng>>, _Alloc>; +unordered_set( + from_range_t, _Rng&&, _Alloc) -> unordered_set<_RANGES range_value_t<_Rng>, hash<_RANGES range_value_t<_Rng>>, + equal_to<_RANGES range_value_t<_Rng>>, _Alloc>; template <_RANGES input_range _Rng, _Hasher_for_container _Hasher, _Allocator_for_container _Alloc> -unordered_set(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc>, _Hasher, _Alloc) - -> unordered_set<_RANGES range_value_t<_Rng>, _Hasher, equal_to<_RANGES range_value_t<_Rng>>, _Alloc>; +unordered_set(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc>, _Hasher, + _Alloc) -> unordered_set<_RANGES range_value_t<_Rng>, _Hasher, equal_to<_RANGES range_value_t<_Rng>>, _Alloc>; #endif // _HAS_CXX23 #endif // _HAS_CXX17 _EXPORT_STD template -void swap(unordered_set<_Kty, _Hasher, _Keyeq, _Alloc>& _Left, - unordered_set<_Kty, _Hasher, _Keyeq, _Alloc>& _Right) noexcept(noexcept(_Left.swap(_Right))) { +void swap(unordered_set<_Kty, _Hasher, _Keyeq, _Alloc>& _Left, unordered_set<_Kty, _Hasher, _Keyeq, _Alloc>& _Right) + noexcept(noexcept(_Left.swap(_Right))) { _Left.swap(_Right); } @@ -587,9 +589,9 @@ public: } #endif // _HAS_CXX23 - unordered_multiset& operator=(unordered_multiset&& _Right) noexcept(_Alnode_traits::is_always_equal::value - && is_nothrow_move_assignable_v<_Hasher> - && is_nothrow_move_assignable_v<_Keyeq>) { + unordered_multiset& operator=(unordered_multiset&& _Right) + noexcept(_Alnode_traits::is_always_equal::value + && is_nothrow_move_assignable_v<_Hasher> && is_nothrow_move_assignable_v<_Keyeq>) { _Mybase::operator=(_STD move(_Right)); return *this; } @@ -683,17 +685,17 @@ unordered_multiset(_Iter, _Iter, _Guide_size_type_t<_Alloc>, _Alloc) template , _Is_hasher<_Hasher>, _Is_allocator<_Alloc>>, int> = 0> -unordered_multiset(_Iter, _Iter, _Guide_size_type_t<_Alloc>, _Hasher, _Alloc) - -> unordered_multiset<_Iter_value_t<_Iter>, _Hasher, equal_to<_Iter_value_t<_Iter>>, _Alloc>; +unordered_multiset(_Iter, _Iter, _Guide_size_type_t<_Alloc>, _Hasher, + _Alloc) -> unordered_multiset<_Iter_value_t<_Iter>, _Hasher, equal_to<_Iter_value_t<_Iter>>, _Alloc>; template ::value, int> = 0> -unordered_multiset(initializer_list<_Kty>, _Guide_size_type_t<_Alloc>, _Alloc) - -> unordered_multiset<_Kty, hash<_Kty>, equal_to<_Kty>, _Alloc>; +unordered_multiset(initializer_list<_Kty>, _Guide_size_type_t<_Alloc>, + _Alloc) -> unordered_multiset<_Kty, hash<_Kty>, equal_to<_Kty>, _Alloc>; template , _Is_allocator<_Alloc>>, int> = 0> -unordered_multiset(initializer_list<_Kty>, _Guide_size_type_t<_Alloc>, _Hasher, _Alloc) - -> unordered_multiset<_Kty, _Hasher, equal_to<_Kty>, _Alloc>; +unordered_multiset(initializer_list<_Kty>, _Guide_size_type_t<_Alloc>, _Hasher, + _Alloc) -> unordered_multiset<_Kty, _Hasher, equal_to<_Kty>, _Alloc>; #if _HAS_CXX23 template <_RANGES input_range _Rng, _Hasher_for_container _Hasher = hash<_RANGES range_value_t<_Rng>>, @@ -704,17 +706,18 @@ unordered_multiset(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc> = 0, _Hasher _Alloc = _Alloc()) -> unordered_multiset<_RANGES range_value_t<_Rng>, _Hasher, _Keyeq, _Alloc>; template <_RANGES input_range _Rng, _Allocator_for_container _Alloc> -unordered_multiset(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc>, _Alloc) - -> unordered_multiset<_RANGES range_value_t<_Rng>, hash<_RANGES range_value_t<_Rng>>, - equal_to<_RANGES range_value_t<_Rng>>, _Alloc>; +unordered_multiset(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc>, + _Alloc) -> unordered_multiset<_RANGES range_value_t<_Rng>, hash<_RANGES range_value_t<_Rng>>, + equal_to<_RANGES range_value_t<_Rng>>, _Alloc>; template <_RANGES input_range _Rng, _Allocator_for_container _Alloc> -unordered_multiset(from_range_t, _Rng&&, _Alloc) -> unordered_multiset<_RANGES range_value_t<_Rng>, - hash<_RANGES range_value_t<_Rng>>, equal_to<_RANGES range_value_t<_Rng>>, _Alloc>; +unordered_multiset( + from_range_t, _Rng&&, _Alloc) -> unordered_multiset<_RANGES range_value_t<_Rng>, hash<_RANGES range_value_t<_Rng>>, + equal_to<_RANGES range_value_t<_Rng>>, _Alloc>; template <_RANGES input_range _Rng, _Hasher_for_container _Hasher, _Allocator_for_container _Alloc> -unordered_multiset(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc>, _Hasher, _Alloc) - -> unordered_multiset<_RANGES range_value_t<_Rng>, _Hasher, equal_to<_RANGES range_value_t<_Rng>>, _Alloc>; +unordered_multiset(from_range_t, _Rng&&, _Guide_size_type_t<_Alloc>, _Hasher, + _Alloc) -> unordered_multiset<_RANGES range_value_t<_Rng>, _Hasher, equal_to<_RANGES range_value_t<_Rng>>, _Alloc>; #endif // _HAS_CXX23 #endif // _HAS_CXX17 diff --git a/stl/inc/utility b/stl/inc/utility index f86e318e398..c5f9265dcfa 100644 --- a/stl/inc/utility +++ b/stl/inc/utility @@ -71,8 +71,8 @@ _NODISCARD constexpr const _Ty&(max) (const _Ty& _Left _MSVC_LIFETIMEBOUND, cons #pragma warning(disable : 28285) // (syntax error in SAL annotation, occurs when _Ty is not an integral type) _EXPORT_STD template _NODISCARD _Post_equal_to_(_Left < _Right ? _Right : _Left) constexpr const _Ty& // - (max) (const _Ty& _Left _MSVC_LIFETIMEBOUND, const _Ty& _Right _MSVC_LIFETIMEBOUND) noexcept( - noexcept(_Left < _Right)) /* strengthened */ { + (max) (const _Ty& _Left _MSVC_LIFETIMEBOUND, const _Ty& _Right _MSVC_LIFETIMEBOUND) + noexcept(noexcept(_Left < _Right)) /* strengthened */ { // return larger of _Left and _Right return _Left < _Right ? _Right : _Left; } @@ -95,8 +95,8 @@ _NODISCARD constexpr const _Ty&(min) (const _Ty& _Left _MSVC_LIFETIMEBOUND, cons #pragma warning(disable : 28285) // (syntax error in SAL annotation, occurs when _Ty is not an integral type) _EXPORT_STD template _NODISCARD _Post_equal_to_(_Right < _Left ? _Right : _Left) constexpr const _Ty& // - (min) (const _Ty& _Left _MSVC_LIFETIMEBOUND, const _Ty& _Right _MSVC_LIFETIMEBOUND) noexcept( - noexcept(_Right < _Left)) /* strengthened */ { + (min) (const _Ty& _Left _MSVC_LIFETIMEBOUND, const _Ty& _Right _MSVC_LIFETIMEBOUND) + noexcept(noexcept(_Right < _Left)) /* strengthened */ { // return smaller of _Left and _Right return _Right < _Left ? _Right : _Left; } @@ -125,8 +125,8 @@ _EXPORT_STD template && is_ #else // ^^^ _HAS_CXX17 / !_HAS_CXX17 vvv template #endif // ^^^ !_HAS_CXX17 ^^^ -_CONSTEXPR20 void swap(_Ty& _Left, _Ty& _Right) noexcept( - is_nothrow_move_constructible_v<_Ty> && is_nothrow_move_assignable_v<_Ty>) { +_CONSTEXPR20 void swap(_Ty& _Left, _Ty& _Right) + noexcept(is_nothrow_move_constructible_v<_Ty> && is_nothrow_move_assignable_v<_Ty>) { _Ty _Tmp = _STD move(_Left); _Left = _STD move(_Right); _Right = _STD move(_Tmp); @@ -200,19 +200,21 @@ _NODISCARD constexpr const _Ty&& get(const array<_Ty, _Size>&& _Arr) noexcept; template concept _Different_from = !same_as, remove_cvref_t<_Ty2>>; -template -constexpr bool _Is_std_array_v = false; - -template -constexpr bool _Is_std_array_v> = true; - template constexpr bool _Is_subrange_v = false; #if _HAS_CXX23 -template -constexpr bool _Tuple_like_impl = - _Is_specialization_v<_Ty, tuple> || _Is_specialization_v<_Ty, pair> || _Is_std_array_v<_Ty> || _Is_subrange_v<_Ty>; +template +constexpr bool _Tuple_like_impl = false; + +template +constexpr bool _Tuple_like_impl> = true; + +template +constexpr bool _Tuple_like_impl> = true; + +template +constexpr bool _Tuple_like_impl> = true; template concept _Tuple_like = _Tuple_like_impl>; @@ -220,7 +222,7 @@ concept _Tuple_like = _Tuple_like_impl>; template concept _Pair_like = _Tuple_like<_Ty> && tuple_size_v> == 2; -#if defined(__clang__) || defined(__EDG__) // TRANSITION, LLVM-59827 and VSO-1900279 +#ifdef __EDG__ // TRANSITION, VSO-1900279 template concept _Can_construct_from_pair_like = _Pair_like<_PairLike> && !_Is_subrange_v> && is_constructible_v<_Ty1, decltype(_STD get<0>(_STD declval<_PairLike>()))> @@ -237,16 +239,15 @@ struct pair { // store a pair of values template , is_default_constructible<_Uty2>>, int> = 0> constexpr explicit( - !conjunction_v<_Is_implicitly_default_constructible<_Uty1>, _Is_implicitly_default_constructible<_Uty2>>) - pair() noexcept( - is_nothrow_default_constructible_v<_Uty1> && is_nothrow_default_constructible_v<_Uty2>) // strengthened + !conjunction_v<_Is_implicitly_default_constructible<_Uty1>, _Is_implicitly_default_constructible<_Uty2>>) pair() + noexcept(is_nothrow_default_constructible_v<_Uty1> && is_nothrow_default_constructible_v<_Uty2>) // strengthened : first(), second() {} template , is_copy_constructible<_Uty2>>, int> = 0> constexpr explicit(!conjunction_v, is_convertible>) - pair(const _Ty1& _Val1, const _Ty2& _Val2) noexcept( - is_nothrow_copy_constructible_v<_Uty1> && is_nothrow_copy_constructible_v<_Uty2>) // strengthened + pair(const _Ty1& _Val1, const _Ty2& _Val2) + noexcept(is_nothrow_copy_constructible_v<_Uty1> && is_nothrow_copy_constructible_v<_Uty2>) // strengthened : first(_Val1), second(_Val2) {} #if _HAS_CXX23 @@ -277,9 +278,9 @@ struct pair { // store a pair of values enable_if_t, is_constructible<_Ty2, const _Other2&>>, int> = 0> constexpr explicit(!conjunction_v, is_convertible>) - pair(const pair<_Other1, _Other2>& _Right) noexcept( - is_nothrow_constructible_v<_Ty1, const _Other1&> - && is_nothrow_constructible_v<_Ty2, const _Other2&>) // strengthened + pair(const pair<_Other1, _Other2>& _Right) + noexcept(is_nothrow_constructible_v<_Ty1, const _Other1&> + && is_nothrow_constructible_v<_Ty2, const _Other2&>) // strengthened : first(_Right.first), second(_Right.second) {} template requires is_constructible_v<_Ty1, const _Other1> && is_constructible_v<_Ty2, const _Other2> constexpr explicit(!conjunction_v, is_convertible>) - pair(const pair<_Other1, _Other2>&& _Right) noexcept( - is_nothrow_constructible_v<_Ty1, const _Other1> - && is_nothrow_constructible_v<_Ty2, const _Other2>) // strengthened + pair(const pair<_Other1, _Other2>&& _Right) + noexcept(is_nothrow_constructible_v<_Ty1, const _Other1> + && is_nothrow_constructible_v<_Ty2, const _Other2>) // strengthened : first(_STD forward(_Right.first)), second(_STD forward(_Right.second)) {} -#if defined(__clang__) || defined(__EDG__) // TRANSITION, LLVM-59827 (Clang), VSO-1900279 (EDG) +#ifdef __EDG__ // TRANSITION, VSO-1900279 template , int> = 0> #else // ^^^ workaround / no workaround vvv template <_Pair_like _Other> @@ -307,10 +308,9 @@ struct pair { // store a pair of values is_constructible<_Ty2, decltype(_STD get<1>(_STD declval<_Other>()))>> #endif // ^^^ no workaround ^^^ constexpr explicit(!conjunction_v(_STD declval<_Other>())), _Ty1>, - is_convertible(_STD declval<_Other>())), _Ty2>>) - pair(_Other&& _Right) noexcept( - is_nothrow_constructible_v<_Ty1, decltype(_STD get<0>(_STD declval<_Other>()))> - && is_nothrow_constructible_v<_Ty2, decltype(_STD get<1>(_STD declval<_Other>()))>) // strengthened + is_convertible(_STD declval<_Other>())), _Ty2>>) pair(_Other&& _Right) + noexcept(is_nothrow_constructible_v<_Ty1, decltype(_STD get<0>(_STD declval<_Other>()))> + && is_nothrow_constructible_v<_Ty2, decltype(_STD get<1>(_STD declval<_Other>()))>) // strengthened : first(_STD get<0>(_STD forward<_Other>(_Right))), second(_STD get<1>(_STD forward<_Other>(_Right))) { } #endif // _HAS_CXX23 @@ -330,8 +330,8 @@ struct pair { // store a pair of values enable_if_t, _Is_copy_assignable_no_precondition_check>, int> = 0> - _CONSTEXPR20 pair& operator=(_Identity_t _Right) noexcept( - conjunction_v, is_nothrow_copy_assignable<_Ty2>>) /* strengthened */ { + _CONSTEXPR20 pair& operator=(_Identity_t _Right) + noexcept(conjunction_v, is_nothrow_copy_assignable<_Ty2>>) /* strengthened */ { first = _Right.first; second = _Right.second; return *this; @@ -354,8 +354,8 @@ struct pair { // store a pair of values enable_if_t, _Is_move_assignable_no_precondition_check>, int> = 0> - _CONSTEXPR20 pair& operator=(_Identity_t<_Myself&&> _Right) noexcept( - conjunction_v, is_nothrow_move_assignable<_Ty2>>) /* strengthened */ { + _CONSTEXPR20 pair& operator=(_Identity_t<_Myself&&> _Right) + noexcept(conjunction_v, is_nothrow_move_assignable<_Ty2>>) /* strengthened */ { first = _STD forward<_Ty1>(_Right.first); second = _STD forward<_Ty2>(_Right.second); return *this; @@ -378,9 +378,9 @@ struct pair { // store a pair of values enable_if_t>>, is_assignable<_Ty1&, const _Other1&>, is_assignable<_Ty2&, const _Other2&>>, int> = 0> - _CONSTEXPR20 pair& operator=(const pair<_Other1, _Other2>& _Right) noexcept( - is_nothrow_assignable_v<_Ty1&, const _Other1&> - && is_nothrow_assignable_v<_Ty2&, const _Other2&>) /* strengthened */ { + _CONSTEXPR20 pair& operator=(const pair<_Other1, _Other2>& _Right) + noexcept(is_nothrow_assignable_v<_Ty1&, const _Other1&> + && is_nothrow_assignable_v<_Ty2&, const _Other2&>) /* strengthened */ { first = _Right.first; second = _Right.second; return *this; @@ -426,9 +426,9 @@ struct pair { // store a pair of values requires _Different_from<_Other, pair> && (!_Is_subrange_v>) && is_assignable_v<_Ty1&, decltype(_STD get<0>(_STD declval<_Other>()))> && is_assignable_v<_Ty2&, decltype(_STD get<1>(_STD declval<_Other>()))> - constexpr pair& operator=(_Other&& _Right) noexcept( - is_nothrow_assignable_v<_Ty1&, decltype(_STD get<0>(_STD declval<_Other>()))> - && is_nothrow_assignable_v<_Ty2&, decltype(_STD get<1>(_STD declval<_Other>()))>) /* strengthened */ { + constexpr pair& operator=(_Other&& _Right) + noexcept(is_nothrow_assignable_v<_Ty1&, decltype(_STD get<0>(_STD declval<_Other>()))> + && is_nothrow_assignable_v<_Ty2&, decltype(_STD get<1>(_STD declval<_Other>()))>) /* strengthened */ { first = _STD get<0>(_STD forward<_Other>(_Right)); second = _STD get<1>(_STD forward<_Other>(_Right)); return *this; @@ -447,8 +447,8 @@ struct pair { // store a pair of values } #endif // _HAS_CXX23 - _CONSTEXPR20 void swap(pair& _Right) noexcept( - _Is_nothrow_swappable<_Ty1>::value && _Is_nothrow_swappable<_Ty2>::value) { + _CONSTEXPR20 void swap(pair& _Right) + noexcept(_Is_nothrow_swappable<_Ty1>::value && _Is_nothrow_swappable<_Ty2>::value) { using _STD swap; swap(first, _Right.first); // intentional ADL swap(second, _Right.second); // intentional ADL @@ -482,8 +482,8 @@ _CONSTEXPR20 void swap(pair<_Ty1, _Ty2>& _Left, pair<_Ty1, _Ty2>& _Right) noexce #if _HAS_CXX23 _EXPORT_STD template requires is_swappable::value && is_swappable::value // TRANSITION, /permissive needs ::value -constexpr void swap(const pair<_Ty1, _Ty2>& _Left, const pair<_Ty1, _Ty2>& _Right) noexcept( - noexcept(_Left.swap(_Right))) { +constexpr void swap(const pair<_Ty1, _Ty2>& _Left, const pair<_Ty1, _Ty2>& _Right) + noexcept(noexcept(_Left.swap(_Right))) { _Left.swap(_Right); } #endif // _HAS_CXX23 @@ -562,9 +562,9 @@ template using _Unrefwrap_t = typename _Unrefwrap_helper>::type; _EXPORT_STD template -_NODISCARD constexpr pair<_Unrefwrap_t<_Ty1>, _Unrefwrap_t<_Ty2>> make_pair(_Ty1&& _Val1, _Ty2&& _Val2) noexcept( - is_nothrow_constructible_v<_Unrefwrap_t<_Ty1>, _Ty1> - && is_nothrow_constructible_v<_Unrefwrap_t<_Ty2>, _Ty2>) /* strengthened */ { +_NODISCARD constexpr pair<_Unrefwrap_t<_Ty1>, _Unrefwrap_t<_Ty2>> make_pair(_Ty1&& _Val1, _Ty2&& _Val2) + noexcept(is_nothrow_constructible_v<_Unrefwrap_t<_Ty1>, _Ty1> + && is_nothrow_constructible_v<_Unrefwrap_t<_Ty2>, _Ty2>) /* strengthened */ { // return pair composed from arguments using _Mypair = pair<_Unrefwrap_t<_Ty1>, _Unrefwrap_t<_Ty2>>; return _Mypair(_STD forward<_Ty1>(_Val1), _STD forward<_Ty2>(_Val2)); @@ -756,8 +756,8 @@ _NODISCARD constexpr const _Ty2&& get(const pair<_Ty1, _Ty2>&& _Pr) noexcept { } _EXPORT_STD template -_CONSTEXPR20 _Ty exchange(_Ty& _Val, _Other&& _New_val) noexcept( - conjunction_v, is_nothrow_assignable<_Ty&, _Other>>) { +_CONSTEXPR20 _Ty exchange(_Ty& _Val, _Other&& _New_val) + noexcept(conjunction_v, is_nothrow_assignable<_Ty&, _Other>>) { // assign _New_val to _Val, return previous _Val _Ty _Old_val = static_cast<_Ty&&>(_Val); _Val = static_cast<_Other&&>(_New_val); diff --git a/stl/inc/variant b/stl/inc/variant index 7ebf3b6cf60..ef2a1bf9a89 100644 --- a/stl/inc/variant +++ b/stl/inc/variant @@ -346,13 +346,13 @@ public: _CONSTEXPR20 _Variant_storage_() noexcept {} // no initialization (no active member) template - constexpr explicit _Variant_storage_(integral_constant, _Types&&... _Args) noexcept( - is_nothrow_constructible_v<_First, _Types...>) + constexpr explicit _Variant_storage_(integral_constant, _Types&&... _Args) + noexcept(is_nothrow_constructible_v<_First, _Types...>) : _Head(static_cast<_Types&&>(_Args)...) {} // initialize _Head with _Args... template 0), int> = 0> - constexpr explicit _Variant_storage_(integral_constant, _Types&&... _Args) noexcept( - is_nothrow_constructible_v<_Variant_storage<_Rest...>, integral_constant, _Types...>) + constexpr explicit _Variant_storage_(integral_constant, _Types&&... _Args) + noexcept(is_nothrow_constructible_v<_Variant_storage<_Rest...>, integral_constant, _Types...>) : _Tail(integral_constant{}, static_cast<_Types&&>(_Args)...) {} // initialize _Tail (recurse) _NODISCARD constexpr _First& _Get() & noexcept { @@ -378,7 +378,11 @@ public: _Variant_storage<_Rest...> _Tail; }; - _CONSTEXPR20 ~_Variant_storage_() noexcept { + _CONSTEXPR20 ~_Variant_storage_() +#ifndef __clang__ // TRANSITION, LLVM-59854 + noexcept +#endif // ^^^ no workaround ^^^ + { // explicitly non-trivial destructor (which would otherwise be defined as deleted // since the class has a variant member with a non-trivial destructor) } @@ -386,13 +390,13 @@ public: _CONSTEXPR20 _Variant_storage_() noexcept {} // no initialization (no active member) template - constexpr explicit _Variant_storage_(integral_constant, _Types&&... _Args) noexcept( - is_nothrow_constructible_v<_First, _Types...>) + constexpr explicit _Variant_storage_(integral_constant, _Types&&... _Args) + noexcept(is_nothrow_constructible_v<_First, _Types...>) : _Head(static_cast<_Types&&>(_Args)...) {} // initialize _Head with _Args... template 0), int> = 0> - constexpr explicit _Variant_storage_(integral_constant, _Types&&... _Args) noexcept( - is_nothrow_constructible_v<_Variant_storage<_Rest...>, integral_constant, _Types...>) + constexpr explicit _Variant_storage_(integral_constant, _Types&&... _Args) + noexcept(is_nothrow_constructible_v<_Variant_storage<_Rest...>, integral_constant, _Types...>) : _Tail(integral_constant{}, static_cast<_Types&&>(_Args)...) {} // initialize _Tail (recurse) _Variant_storage_(_Variant_storage_&&) = default; @@ -443,13 +447,13 @@ public: _CONSTEXPR20 _Variant_storage_() noexcept {} // no initialization (no active member) template - constexpr explicit _Variant_storage_(integral_constant, _Types&&... _Args) noexcept( - is_nothrow_constructible_v<_First ^, _Types...>) + constexpr explicit _Variant_storage_(integral_constant, _Types&&... _Args) + noexcept(is_nothrow_constructible_v<_First ^, _Types...>) : _Head(static_cast<_Types&&>(_Args)...) {} // initialize _Head with _Args... template 0), int> = 0> - constexpr explicit _Variant_storage_(integral_constant, _Types&&... _Args) noexcept( - is_nothrow_constructible_v<_Variant_storage<_Rest...>, integral_constant, _Types...>) + constexpr explicit _Variant_storage_(integral_constant, _Types&&... _Args) + noexcept(is_nothrow_constructible_v<_Variant_storage<_Rest...>, integral_constant, _Types...>) : _Tail(integral_constant{}, static_cast<_Types&&>(_Args)...) {} // initialize _Tail (recurse) _Variant_storage_(_Variant_storage_&&) = default; @@ -526,16 +530,16 @@ template using _Variant_raw_visit_t = decltype(_STD declval<_Fn>()(_STD declval<_Variant_tagged_ref_t<_Storage, 0>>())); template -_NODISCARD constexpr _Variant_raw_visit_t<_Fn, _Storage> _Variant_raw_visit_dispatch( - _Fn&& _Func, _Storage&& _Var) noexcept(is_nothrow_invocable_v<_Fn, _Variant_tagged_ref_t<_Storage, _Idx>>) { +_NODISCARD constexpr _Variant_raw_visit_t<_Fn, _Storage> _Variant_raw_visit_dispatch(_Fn&& _Func, _Storage&& _Var) + noexcept(is_nothrow_invocable_v<_Fn, _Variant_tagged_ref_t<_Storage, _Idx>>) { // call _Func with the _Idx-th element in _Storage (tagged with _Idx) return static_cast<_Fn&&>(_Func)( _Variant_tagged_ref_t<_Storage, _Idx>{_STD _Variant_raw_get<_Idx>(static_cast<_Storage&&>(_Var))}); } template -_NODISCARD constexpr _Variant_raw_visit_t<_Fn, _Storage> _Variant_raw_visit_valueless( - _Fn&& _Func, _Storage&& _Obj) noexcept(is_nothrow_invocable_v<_Fn, _Tagged<_Storage&&, variant_npos>>) { +_NODISCARD constexpr _Variant_raw_visit_t<_Fn, _Storage> _Variant_raw_visit_valueless(_Fn&& _Func, _Storage&& _Obj) + noexcept(is_nothrow_invocable_v<_Fn, _Tagged<_Storage&&, variant_npos>>) { // call _Func with _Storage (tagged with variant_npos) return static_cast<_Fn&&>(_Func)(_Tagged<_Storage&&, variant_npos>{static_cast<_Storage&&>(_Obj)}); } @@ -555,8 +559,8 @@ struct _Variant_raw_dispatch_table1; // undefined template struct _Variant_raw_dispatch_table1<_Fn, _Storage, index_sequence<_Idxs...>> { // map from canonical index to visitation target - using _Dispatch_t = _Variant_raw_visit_t<_Fn, _Storage> (*)(_Fn&&, _Storage&&) noexcept( - _Variant_raw_visit_noexcept<_Fn, _Storage>); + using _Dispatch_t = _Variant_raw_visit_t<_Fn, _Storage> (*)(_Fn&&, _Storage&&) + noexcept(_Variant_raw_visit_noexcept<_Fn, _Storage>); static constexpr _Dispatch_t _Array[] = { &_STD _Variant_raw_visit_valueless<_Fn, _Storage>, &_STD _Variant_raw_visit_dispatch<_Idxs, _Fn, _Storage>...}; }; @@ -567,8 +571,8 @@ struct _Variant_raw_visit1; template <> struct _Variant_raw_visit1<-1> { // Fallback case for variants too large for any of the following "switch" strategies template - _NODISCARD static constexpr _Variant_raw_visit_t<_Fn, _Storage> _Visit( - size_t _Idx, _Fn&& _Func, _Storage&& _Obj) noexcept(_Variant_raw_visit_noexcept<_Fn, _Storage>) { + _NODISCARD static constexpr _Variant_raw_visit_t<_Fn, _Storage> _Visit(size_t _Idx, _Fn&& _Func, _Storage&& _Obj) + noexcept(_Variant_raw_visit_noexcept<_Fn, _Storage>) { // dispatch a visitor for a _Variant_storage with many states constexpr size_t _Size = remove_reference_t<_Storage>::_Size; static_assert(_Size > 256); @@ -601,8 +605,8 @@ struct _Variant_raw_visit1<-1> { // Fallback case for variants too large for any template <> struct _Variant_raw_visit1<1> { template - _NODISCARD static constexpr _Variant_raw_visit_t<_Fn, _Storage> _Visit( - size_t _Idx, _Fn&& _Func, _Storage&& _Obj) noexcept(_Variant_raw_visit_noexcept<_Fn, _Storage>) { + _NODISCARD static constexpr _Variant_raw_visit_t<_Fn, _Storage> _Visit(size_t _Idx, _Fn&& _Func, _Storage&& _Obj) + noexcept(_Variant_raw_visit_noexcept<_Fn, _Storage>) { // dispatch a visitor for a _Variant_storage with at most 4^1 states _STL_STAMP(4, _STL_VISIT_STAMP); } @@ -611,8 +615,8 @@ struct _Variant_raw_visit1<1> { template <> struct _Variant_raw_visit1<2> { template - _NODISCARD static constexpr _Variant_raw_visit_t<_Fn, _Storage> _Visit( - size_t _Idx, _Fn&& _Func, _Storage&& _Obj) noexcept(_Variant_raw_visit_noexcept<_Fn, _Storage>) { + _NODISCARD static constexpr _Variant_raw_visit_t<_Fn, _Storage> _Visit(size_t _Idx, _Fn&& _Func, _Storage&& _Obj) + noexcept(_Variant_raw_visit_noexcept<_Fn, _Storage>) { // dispatch a visitor for a _Variant_storage with at most 4^2 states _STL_STAMP(16, _STL_VISIT_STAMP); } @@ -621,8 +625,8 @@ struct _Variant_raw_visit1<2> { template <> struct _Variant_raw_visit1<3> { template - _NODISCARD static constexpr _Variant_raw_visit_t<_Fn, _Storage> _Visit( - size_t _Idx, _Fn&& _Func, _Storage&& _Obj) noexcept(_Variant_raw_visit_noexcept<_Fn, _Storage>) { + _NODISCARD static constexpr _Variant_raw_visit_t<_Fn, _Storage> _Visit(size_t _Idx, _Fn&& _Func, _Storage&& _Obj) + noexcept(_Variant_raw_visit_noexcept<_Fn, _Storage>) { // dispatch a visitor for a _Variant_storage with at most 4^3 states _STL_STAMP(64, _STL_VISIT_STAMP); } @@ -631,8 +635,8 @@ struct _Variant_raw_visit1<3> { template <> struct _Variant_raw_visit1<4> { template - _NODISCARD static constexpr _Variant_raw_visit_t<_Fn, _Storage> _Visit( - size_t _Idx, _Fn&& _Func, _Storage&& _Obj) noexcept(_Variant_raw_visit_noexcept<_Fn, _Storage>) { + _NODISCARD static constexpr _Variant_raw_visit_t<_Fn, _Storage> _Visit(size_t _Idx, _Fn&& _Func, _Storage&& _Obj) + noexcept(_Variant_raw_visit_noexcept<_Fn, _Storage>) { // dispatch a visitor for a _Variant_storage with at most 4^4 states _STL_STAMP(256, _STL_VISIT_STAMP); } @@ -642,8 +646,8 @@ struct _Variant_raw_visit1<4> { #undef _STL_CASE template -_NODISCARD constexpr _Variant_raw_visit_t<_Fn, _Storage> _Variant_raw_visit( - size_t _Idx, _Storage&& _Obj, _Fn&& _Func) noexcept(_Variant_raw_visit_noexcept<_Fn, _Storage>) { +_NODISCARD constexpr _Variant_raw_visit_t<_Fn, _Storage> _Variant_raw_visit(size_t _Idx, _Storage&& _Obj, _Fn&& _Func) + noexcept(_Variant_raw_visit_noexcept<_Fn, _Storage>) { // Call _Func with _Storage if _Idx is variant_npos, and otherwise the _Idx-th element in _Storage. // pre: _Idx + 1 <= remove_reference_t<_Storage>::_Size constexpr size_t _Size = remove_reference_t<_Storage>::_Size; @@ -749,8 +753,8 @@ public: template , _Idx>, _UTypes...>, int> = 0> - constexpr explicit _Variant_base(in_place_index_t<_Idx>, _UTypes&&... _Args) noexcept( - is_nothrow_constructible_v<_Meta_at_c, _Idx>, _UTypes...>) + constexpr explicit _Variant_base(in_place_index_t<_Idx>, _UTypes&&... _Args) + noexcept(is_nothrow_constructible_v<_Meta_at_c, _Idx>, _UTypes...>) : _Storage_t(integral_constant{}, static_cast<_UTypes&&>(_Args)...), _Which{static_cast<_Index_t>(_Idx)} { // initialize alternative _Idx from _Args... } @@ -804,29 +808,29 @@ public: } } - _CONSTEXPR20 void _Construct_from(const _Variant_base& _That) noexcept( - conjunction_v...>) { + _CONSTEXPR20 void _Construct_from(const _Variant_base& _That) + noexcept(conjunction_v...>) { // copy _That's contained value into *this // pre: valueless_by_exception() _STD _Variant_raw_visit(_That.index(), _That._Storage(), _Variant_construct_visitor<_Types...>{*this}); } - _CONSTEXPR20 void _Construct_from(_Variant_base&& _That) noexcept( - conjunction_v...>) { + _CONSTEXPR20 void _Construct_from(_Variant_base&& _That) + noexcept(conjunction_v...>) { // move _That's contained value into *this // pre: valueless_by_exception() _STD _Variant_raw_visit( _That.index(), _STD move(_That)._Storage(), _Variant_construct_visitor<_Types...>{*this}); } - _CONSTEXPR20 void _Assign_from(const _Variant_base& _That) noexcept( - conjunction_v..., is_nothrow_copy_assignable<_Types>...>) { + _CONSTEXPR20 void _Assign_from(const _Variant_base& _That) + noexcept(conjunction_v..., is_nothrow_copy_assignable<_Types>...>) { // copy assign _That's contained value (if any) into *this _STD _Variant_raw_visit(_That.index(), _That._Storage(), _Variant_assign_visitor<_Types...>{*this}); } - _CONSTEXPR20 void _Assign_from(_Variant_base&& _That) noexcept( - conjunction_v..., is_nothrow_move_assignable<_Types>...>) { + _CONSTEXPR20 void _Assign_from(_Variant_base&& _That) + noexcept(conjunction_v..., is_nothrow_move_assignable<_Types>...>) { // move assign _That's contained value (if any) into *this _STD _Variant_raw_visit(_That.index(), _STD move(_That)._Storage(), _Variant_assign_visitor<_Types...>{*this}); } @@ -943,31 +947,31 @@ public: template , enable_if_t<_Idx::value != _Meta_npos && is_constructible_v<_Ty, _UTypes...>, int> = 0> - constexpr explicit variant(in_place_type_t<_Ty>, _UTypes&&... _Args) noexcept( - is_nothrow_constructible_v<_Ty, _UTypes...>) // strengthened + constexpr explicit variant(in_place_type_t<_Ty>, _UTypes&&... _Args) + noexcept(is_nothrow_constructible_v<_Ty, _UTypes...>) // strengthened : _Mybase(in_place_index<_Idx::value>, static_cast<_UTypes&&>(_Args)...) { // initialize alternative _Ty from _Args... } template , enable_if_t<_Idx::value != _Meta_npos && is_constructible_v<_Ty, initializer_list<_Elem>&, _UTypes...>, int> = 0> - constexpr explicit variant(in_place_type_t<_Ty>, initializer_list<_Elem> _Ilist, _UTypes&&... _Args) noexcept( - is_nothrow_constructible_v<_Ty, initializer_list<_Elem>&, _UTypes...>) // strengthened + constexpr explicit variant(in_place_type_t<_Ty>, initializer_list<_Elem> _Ilist, _UTypes&&... _Args) + noexcept(is_nothrow_constructible_v<_Ty, initializer_list<_Elem>&, _UTypes...>) // strengthened : _Mybase(in_place_index<_Idx::value>, _Ilist, static_cast<_UTypes&&>(_Args)...) { // initialize alternative _Ty from _Ilist and _Args... } template , _UTypes...>, int> = 0> - constexpr explicit variant(in_place_index_t<_Idx>, _UTypes&&... _Args) noexcept( - is_nothrow_constructible_v<_Meta_at_c, _UTypes...>) // strengthened + constexpr explicit variant(in_place_index_t<_Idx>, _UTypes&&... _Args) + noexcept(is_nothrow_constructible_v<_Meta_at_c, _UTypes...>) // strengthened : _Mybase(in_place_index<_Idx>, static_cast<_UTypes&&>(_Args)...) { // initialize alternative _Idx from _Args... } template , initializer_list<_Elem>&, _UTypes...>, int> = 0> - constexpr explicit variant(in_place_index_t<_Idx>, initializer_list<_Elem> _Ilist, _UTypes&&... _Args) noexcept( - is_constructible_v<_Meta_at_c, initializer_list<_Elem>&, _UTypes...>) // strengthened + constexpr explicit variant(in_place_index_t<_Idx>, initializer_list<_Elem> _Ilist, _UTypes&&... _Args) + noexcept(is_constructible_v<_Meta_at_c, initializer_list<_Elem>&, _UTypes...>) // strengthened : _Mybase(in_place_index<_Idx>, _Ilist, static_cast<_UTypes&&>(_Args)...) { // initialize alternative _Idx from _Ilist and _Args... } @@ -976,9 +980,9 @@ public: && is_constructible_v<_Variant_init_type<_Ty, _Types...>, _Ty> && is_assignable_v<_Variant_init_type<_Ty, _Types...>&, _Ty>, int> = 0> - _CONSTEXPR20 variant& operator=(_Ty&& _Obj) noexcept( - is_nothrow_assignable_v<_Variant_init_type<_Ty, _Types...>&, _Ty> - && is_nothrow_constructible_v<_Variant_init_type<_Ty, _Types...>, _Ty>) { + _CONSTEXPR20 variant& operator=(_Ty&& _Obj) + noexcept(is_nothrow_assignable_v<_Variant_init_type<_Ty, _Types...>&, _Ty> + && is_nothrow_constructible_v<_Variant_init_type<_Ty, _Types...>, _Ty>) { // assign/emplace the alternative chosen by overload resolution of _Obj with f(_Types)... constexpr size_t _TargetIdx = _Variant_init_index<_Ty, _Types...>::value; if (index() == _TargetIdx) { @@ -1003,16 +1007,16 @@ public: template ::value, enable_if_t<_Idx != _Meta_npos && is_constructible_v<_Ty, _ArgTypes...>, int> = 0> - _CONSTEXPR20 _Ty& emplace(_ArgTypes&&... _Args) noexcept( - is_nothrow_constructible_v<_Ty, _ArgTypes...>) /* strengthened */ { + _CONSTEXPR20 _Ty& emplace(_ArgTypes&&... _Args) + noexcept(is_nothrow_constructible_v<_Ty, _ArgTypes...>) /* strengthened */ { // emplace alternative _Ty from _Args... this->_Reset(); return _Emplace_valueless<_Idx>(static_cast<_ArgTypes&&>(_Args)...); } template ::value, enable_if_t<_Idx != _Meta_npos && is_constructible_v<_Ty, initializer_list<_Elem>&, _ArgTypes...>, int> = 0> - _CONSTEXPR20 _Ty& emplace(initializer_list<_Elem> _Ilist, _ArgTypes&&... _Args) noexcept( - is_nothrow_constructible_v<_Ty, initializer_list<_Elem>&, _ArgTypes...>) /* strengthened */ { + _CONSTEXPR20 _Ty& emplace(initializer_list<_Elem> _Ilist, _ArgTypes&&... _Args) + noexcept(is_nothrow_constructible_v<_Ty, initializer_list<_Elem>&, _ArgTypes...>) /* strengthened */ { // emplace alternative _Ty from _Ilist and _Args... this->_Reset(); return _Emplace_valueless<_Idx>(_Ilist, static_cast<_ArgTypes&&>(_Args)...); @@ -1020,16 +1024,16 @@ public: template , _ArgTypes...>, int> = 0> - _CONSTEXPR20 _Meta_at_c& emplace(_ArgTypes&&... _Args) noexcept( - is_nothrow_constructible_v<_Meta_at_c, _ArgTypes...>) /* strengthened */ { + _CONSTEXPR20 _Meta_at_c& emplace(_ArgTypes&&... _Args) + noexcept(is_nothrow_constructible_v<_Meta_at_c, _ArgTypes...>) /* strengthened */ { // emplace alternative _Idx from _Args... this->_Reset(); return _Emplace_valueless<_Idx>(static_cast<_ArgTypes&&>(_Args)...); } template , initializer_list<_Elem>&, _ArgTypes...>, int> = 0> - _CONSTEXPR20 _Meta_at_c& emplace(initializer_list<_Elem> _Ilist, _ArgTypes&&... _Args) noexcept( - is_nothrow_constructible_v<_Meta_at_c, initializer_list<_Elem>&, + _CONSTEXPR20 _Meta_at_c& emplace(initializer_list<_Elem> _Ilist, _ArgTypes&&... _Args) + noexcept(is_nothrow_constructible_v<_Meta_at_c, initializer_list<_Elem>&, _ArgTypes...>) /* strengthened */ { // emplace alternative _Idx from _Ilist and _Args... this->_Reset(); @@ -1043,8 +1047,8 @@ public: #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-lambda-capture" #endif // ^^^ workaround ^^^ - _CONSTEXPR20 void swap(variant& _That) noexcept( - conjunction_v..., is_nothrow_swappable<_Types>...>) { + _CONSTEXPR20 void swap(variant& _That) + noexcept(conjunction_v..., is_nothrow_swappable<_Types>...>) { // exchange the contained values if *this and _That hold the same alternative, otherwise exchange the values of // the variants themselves static_assert(conjunction_v...>, @@ -1107,8 +1111,8 @@ public: private: template - _CONSTEXPR20 _Meta_at_c& _Emplace_valueless(_ArgTypes&&... _Args) noexcept( - is_nothrow_constructible_v<_Meta_at_c, _ArgTypes...>) { + _CONSTEXPR20 _Meta_at_c& _Emplace_valueless(_ArgTypes&&... _Args) + noexcept(is_nothrow_constructible_v<_Meta_at_c, _ArgTypes...>) { // initialize alternative _Idx from _Args... _STL_INTERNAL_CHECK(valueless_by_exception()); _STD _Construct_in_place(_Storage(), integral_constant{}, static_cast<_ArgTypes&&>(_Args)...); @@ -1302,8 +1306,8 @@ _NODISCARD constexpr bool operator!=(const variant<_Types...>& _Left, const vari } _EXPORT_STD template -_NODISCARD constexpr bool operator<(const variant<_Types...>& _Left, const variant<_Types...>& _Right) noexcept( - conjunction_v, const _Types&, const _Types&>...>) /* strengthened */ { +_NODISCARD constexpr bool operator<(const variant<_Types...>& _Left, const variant<_Types...>& _Right) + noexcept(conjunction_v, const _Types&, const _Types&>...>) /* strengthened */ { // determine if _Left has a lesser index(), or equal index() and lesser // contained value than _Right using _Visitor = _Variant_relop_visitor2, bool, _Types...>; @@ -1356,14 +1360,14 @@ _NODISCARD constexpr bool operator>=(const variant<_Types...>& _Left, const vari #if _HAS_CXX20 _EXPORT_STD template requires (three_way_comparable<_Types> && ...) -_NODISCARD constexpr common_comparison_category_t...> - operator<=>(const variant<_Types...>& _Left, const variant<_Types...>& _Right) noexcept( - conjunction_v...>, +_NODISCARD constexpr common_comparison_category_t...> operator<=>( + const variant<_Types...>& _Left, const variant<_Types...>& _Right) + noexcept(conjunction_v...>, compare_three_way, const _Types&, const _Types&>...>) /* strengthened */ { // determine the three-way comparison of _Left's and _Right's index, if equal // return the three-way comparison of the contained values of _Left and _Right using _Visitor = _Variant_relop_visitor2...>, _Types...>; + common_comparison_category_t...>, _Types...>; const size_t _Left_offset = _Left.index() + 1; const size_t _Right_offset = _Right.index() + 1; const auto _Offset_order = _Left_offset <=> _Right_offset; @@ -1680,8 +1684,8 @@ struct _Variant_hash_visitor { // visitation function for hashing variants template struct hash> : _Conditionally_enabled_hash, conjunction_v>>...>> { - _NODISCARD static size_t _Do_hash(const variant<_Types...>& _Var) noexcept( - conjunction_v<_Is_nothrow_hashable>...>) { + _NODISCARD static size_t _Do_hash(const variant<_Types...>& _Var) + noexcept(conjunction_v<_Is_nothrow_hashable>...>) { // called from the CRTP base to hash _Var iff the hash is enabled return _STD _Variant_raw_visit(_Var.index(), _Var._Storage(), _Variant_hash_visitor{}); } diff --git a/stl/inc/vector b/stl/inc/vector index 141068db916..8a123af1f31 100644 --- a/stl/inc/vector +++ b/stl/inc/vector @@ -689,15 +689,15 @@ public: _CONSTEXPR20 vector(vector&& _Right) noexcept : _Mypair(_One_then_variadic_args_t{}, _STD move(_Right._Getal()), - _STD exchange(_Right._Mypair._Myval2._Myfirst, nullptr), - _STD exchange(_Right._Mypair._Myval2._Mylast, nullptr), - _STD exchange(_Right._Mypair._Myval2._Myend, nullptr)) { + _STD exchange(_Right._Mypair._Myval2._Myfirst, nullptr), + _STD exchange(_Right._Mypair._Myval2._Mylast, nullptr), + _STD exchange(_Right._Mypair._Myval2._Myend, nullptr)) { _Mypair._Myval2._Alloc_proxy(_GET_PROXY_ALLOCATOR(_Alty, _Getal())); _Mypair._Myval2._Swap_proxy_and_iterators(_Right._Mypair._Myval2); } - _CONSTEXPR20 vector(vector&& _Right, const _Identity_t<_Alloc>& _Al_) noexcept( - _Alty_traits::is_always_equal::value) // strengthened + _CONSTEXPR20 vector(vector&& _Right, const _Identity_t<_Alloc>& _Al_) + noexcept(_Alty_traits::is_always_equal::value) // strengthened : _Mypair(_One_then_variadic_args_t{}, _Al_) { _Alty& _Al = _Getal(); auto&& _Alproxy = _GET_PROXY_ALLOCATOR(_Alty, _Al); @@ -726,8 +726,8 @@ public: _Proxy._Release(); } - _CONSTEXPR20 vector& operator=(vector&& _Right) noexcept( - _Choose_pocma_v<_Alty> != _Pocma_values::_No_propagate_allocators) { + _CONSTEXPR20 vector& operator=(vector&& _Right) + noexcept(_Choose_pocma_v<_Alty> != _Pocma_values::_No_propagate_allocators) { if (this == _STD addressof(_Right)) { return *this; } @@ -1717,8 +1717,8 @@ public: --_Mylast; } - _CONSTEXPR20 iterator erase(const_iterator _Where) noexcept( - is_nothrow_move_assignable_v) /* strengthened */ { + _CONSTEXPR20 iterator erase(const_iterator _Where) + noexcept(is_nothrow_move_assignable_v) /* strengthened */ { const pointer _Whereptr = _Where._Ptr; auto& _My_data = _Mypair._Myval2; pointer& _Mylast = _My_data._Mylast; @@ -1737,8 +1737,8 @@ public: return iterator(_Whereptr, _STD addressof(_My_data)); } - _CONSTEXPR20 iterator erase(const_iterator _First, const_iterator _Last) noexcept( - is_nothrow_move_assignable_v) /* strengthened */ { + _CONSTEXPR20 iterator erase(const_iterator _First, const_iterator _Last) + noexcept(is_nothrow_move_assignable_v) /* strengthened */ { const pointer _Firstptr = _First._Ptr; const pointer _Lastptr = _Last._Ptr; auto& _My_data = _Mypair._Myval2; @@ -2807,8 +2807,8 @@ public: this->_Alloc_proxy(_GET_PROXY_ALLOCATOR(_Alvbase, _Getal())); } - _CONSTEXPR20 _Vb_val(_Vb_val&& _Right, const _Alloc& _Al) noexcept( - is_nothrow_constructible_v<_Vectype, _Vectype, _Alvbase>) + _CONSTEXPR20 _Vb_val(_Vb_val&& _Right, const _Alloc& _Al) + noexcept(is_nothrow_constructible_v<_Vectype, _Vectype, _Alvbase>) : _Myvec(_STD move(_Right._Myvec), static_cast<_Alvbase>(_Al)), _Mysize(_Right._Mysize) { if (_Right._Myvec.empty()) { // we took _Right's buffer, so zero out size @@ -2917,8 +2917,8 @@ public: this->_Swap_proxy_and_iterators(_Right); } - _CONSTEXPR20 vector(vector&& _Right, const _Identity_t<_Alloc>& _Al) noexcept( - is_nothrow_constructible_v<_Mybase, _Mybase, const _Alloc&>) // strengthened + _CONSTEXPR20 vector(vector&& _Right, const _Identity_t<_Alloc>& _Al) + noexcept(is_nothrow_constructible_v<_Mybase, _Mybase, const _Alloc&>) // strengthened : _Mybase(_STD move(_Right), _Al) { if constexpr (!_Alvbase_traits::is_always_equal::value) { if (this->_Getal() != _Right._Getal()) { @@ -2929,8 +2929,8 @@ public: this->_Swap_proxy_and_iterators(_Right); } - _CONSTEXPR20 vector& operator=(vector&& _Right) noexcept( - _Choose_pocma_v<_Alvbase> != _Pocma_values::_No_propagate_allocators) { + _CONSTEXPR20 vector& operator=(vector&& _Right) + noexcept(_Choose_pocma_v<_Alvbase> != _Pocma_values::_No_propagate_allocators) { if (this == _STD addressof(_Right)) { return *this; } @@ -3595,6 +3595,10 @@ public: return _Underlying.format(_Ref, _Ctx); } }; + +template + requires _Is_specialization_v<_Ty, _Vb_reference> +constexpr bool enable_nonlocking_formatter_optimization<_Ty> = true; #endif // _HAS_CXX23 template diff --git a/stl/inc/xcall_once.h b/stl/inc/xcall_once.h index 3a99d9bc033..5057ca65d18 100644 --- a/stl/inc/xcall_once.h +++ b/stl/inc/xcall_once.h @@ -89,8 +89,8 @@ struct _Init_once_completer { }; _EXPORT_STD template -void(call_once)(once_flag& _Once, _Fn&& _Fx, _Args&&... _Ax) noexcept( - noexcept(_STD invoke(_STD forward<_Fn>(_Fx), _STD forward<_Args>(_Ax)...))) /* strengthened */ { +void(call_once)(once_flag& _Once, _Fn&& _Fx, _Args&&... _Ax) + noexcept(noexcept(_STD invoke(_STD forward<_Fn>(_Fx), _STD forward<_Args>(_Ax)...))) /* strengthened */ { // call _Fx(_Ax...) once // parentheses against common "#define call_once(flag,func) pthread_once(flag,func)" int _Pending; diff --git a/stl/inc/xhash b/stl/inc/xhash index dfa0cf3f2b8..0581696c1af 100644 --- a/stl/inc/xhash +++ b/stl/inc/xhash @@ -132,16 +132,16 @@ public: bucket_size = 1 // 0 < bucket_size }; - _Uhash_compare() noexcept( - conjunction_v, is_nothrow_default_constructible<_Keyeq>>) + _Uhash_compare() + noexcept(conjunction_v, is_nothrow_default_constructible<_Keyeq>>) : _Mypair(_Zero_then_variadic_args_t{}, _Zero_then_variadic_args_t{}, 0.0f) {} - explicit _Uhash_compare(const _Hasher& _Hasharg) noexcept( - conjunction_v, is_nothrow_default_constructible<_Keyeq>>) + explicit _Uhash_compare(const _Hasher& _Hasharg) + noexcept(conjunction_v, is_nothrow_default_constructible<_Keyeq>>) : _Mypair(_One_then_variadic_args_t{}, _Hasharg, _Zero_then_variadic_args_t{}, 0.0f) {} - explicit _Uhash_compare(const _Hasher& _Hasharg, const _Keyeq& _Keyeqarg) noexcept( - conjunction_v, is_nothrow_copy_constructible<_Keyeq>>) + explicit _Uhash_compare(const _Hasher& _Hasharg, const _Keyeq& _Keyeqarg) + noexcept(conjunction_v, is_nothrow_copy_constructible<_Keyeq>>) : _Mypair(_One_then_variadic_args_t{}, _Hasharg, _One_then_variadic_args_t{}, _Keyeqarg, 0.0f) {} template @@ -165,8 +165,8 @@ public: return _Mypair._Myval2._Myval2; } - void swap(_Uhash_compare& _Rhs) noexcept( - conjunction_v<_Is_nothrow_swappable<_Hasher>, _Is_nothrow_swappable<_Keyeq>>) { + void swap(_Uhash_compare& _Rhs) + noexcept(conjunction_v<_Is_nothrow_swappable<_Hasher>, _Is_nothrow_swappable<_Keyeq>>) { using _STD swap; swap(_Mypair._Get_first(), _Rhs._Mypair._Get_first()); // intentional ADL auto& _Lsecond = _Mypair._Myval2; @@ -361,7 +361,7 @@ public: using const_iterator = typename _Mylist::const_iterator; using _Unchecked_iterator = conditional_t, - typename _Mylist::_Unchecked_const_iterator, typename _Mylist::_Unchecked_iterator>; + typename _Mylist::_Unchecked_const_iterator, typename _Mylist::_Unchecked_iterator>; using _Unchecked_const_iterator = typename _Mylist::_Unchecked_const_iterator; using _Aliter = _Rebind_alloc_t<_Alnode, _Unchecked_iterator>; @@ -1132,8 +1132,8 @@ public: return _List._Make_iter(_Unchecked_erase(_Plist._Ptr)); } - iterator erase(const_iterator _First, const_iterator _Last) noexcept( - _Nothrow_hash<_Traits, key_type>) /* strengthened */ { + iterator erase(const_iterator _First, const_iterator _Last) + noexcept(_Nothrow_hash<_Traits, key_type>) /* strengthened */ { return _List._Make_iter(_Unchecked_erase(_First._Ptr, _Last._Ptr)); } diff --git a/stl/inc/xkeycheck.h b/stl/inc/xkeycheck.h index 24c0d0c15f2..96a83a50013 100644 --- a/stl/inc/xkeycheck.h +++ b/stl/inc/xkeycheck.h @@ -13,13 +13,11 @@ #if !defined(_ALLOW_KEYWORD_MACROS) && !defined(__INTELLISENSE__) -// clang-format off // #if defined($KEYWORD) // #define $KEYWORD EMIT WARNING C4005 // #error The C++ Standard Library forbids macroizing the keyword "$KEYWORD". \ // Enable warning C4005 to find the forbidden define. // #endif // $KEYWORD -// clang-format on // *don't* check the "alternative token representations" diff --git a/stl/inc/xlocnum b/stl/inc/xlocnum index e06101f63e1..b9085095e02 100644 --- a/stl/inc/xlocnum +++ b/stl/inc/xlocnum @@ -970,7 +970,7 @@ private: *_Ptr++ = '0'; // save at least one leading digit for hex } - const char _Decimal_point = _CSTD localeconv()->decimal_point[0]; + const char _Decimal_point = (_CSTD localeconv())->decimal_point[0]; if (_First != _Last && *_First == _Punct_fac.decimal_point()) { // add . *_Ptr++ = _Decimal_point; ++_First; @@ -1487,7 +1487,7 @@ private: } const size_t _Eoff = _CSTD strcspn(&_Buf[0], _Exps); // find exponent char _Dp[2] = {"."}; - _Dp[0] = _CSTD localeconv()->decimal_point[0]; + _Dp[0] = (_CSTD localeconv())->decimal_point[0]; const size_t _Poff = _CSTD strcspn(&_Buf[0], &_Dp[0]); // find decimal point const ctype<_Elem>& _Ctype_fac = _STD use_facet>(_Iosbase.getloc()); diff --git a/stl/inc/xloctime b/stl/inc/xloctime index 6926937743d..1952685dddc 100644 --- a/stl/inc/xloctime +++ b/stl/inc/xloctime @@ -666,6 +666,115 @@ _NODISCARD constexpr bool _Is_valid_strftime_specifier(const char _Specifier) { return false; } +_NODISCARD constexpr bool _Is_valid_strftime_tm_sec(const tm* const _Pt) noexcept { + // seconds after the minute - [0, 60] including leap second + return _Pt->tm_sec >= 0 && _Pt->tm_sec <= 60; +} + +_NODISCARD constexpr bool _Is_valid_strftime_tm_min(const tm* const _Pt) noexcept { + // minutes after the hour - [0, 59] + return _Pt->tm_min >= 0 && _Pt->tm_min <= 59; +} + +_NODISCARD constexpr bool _Is_valid_strftime_tm_hour(const tm* const _Pt) noexcept { + // hours since midnight - [0, 23] + return _Pt->tm_hour >= 0 && _Pt->tm_hour <= 23; +} + +_NODISCARD constexpr bool _Is_valid_strftime_tm_mday(const tm* const _Pt) noexcept { + // day of the month - [1, 31] + return _Pt->tm_mday >= 1 && _Pt->tm_mday <= 31; +} + +_NODISCARD constexpr bool _Is_valid_strftime_tm_mon(const tm* const _Pt) noexcept { + // months since January - [0, 11] + return _Pt->tm_mon >= 0 && _Pt->tm_mon <= 11; +} + +_NODISCARD constexpr bool _Is_valid_strftime_tm_year(const tm* const _Pt) noexcept { + // years since 1900 - UCRT max range is up until 8099 + return _Pt->tm_year >= -1900 && _Pt->tm_year <= 8099; +} + +_NODISCARD constexpr bool _Is_valid_strftime_tm_wday(const tm* const _Pt) noexcept { + // days since Sunday - [0, 6] + return _Pt->tm_wday >= 0 && _Pt->tm_wday <= 6; +} + +_NODISCARD constexpr bool _Is_valid_strftime_tm_yday(const tm* const _Pt) noexcept { + // days since January 1 - [0, 365] + return _Pt->tm_yday >= 0 && _Pt->tm_yday <= 365; +} + +_NODISCARD constexpr bool _Is_valid_strftime_tm_data(const char _Specifier, const tm* const _Pt) noexcept { + if (!_Pt) { + return false; + } + + switch (_Specifier) { + case 'S': + return _Is_valid_strftime_tm_sec(_Pt); + case 'M': + return _Is_valid_strftime_tm_min(_Pt); + case 'H': + case 'I': + case 'p': + return _Is_valid_strftime_tm_hour(_Pt); + case 'd': + case 'e': + return _Is_valid_strftime_tm_mday(_Pt); + case 'b': + case 'B': + case 'm': + case 'h': + return _Is_valid_strftime_tm_mon(_Pt); + case 'C': + case 'y': + case 'Y': + return _Is_valid_strftime_tm_year(_Pt); + case 'j': + return _Is_valid_strftime_tm_yday(_Pt); + case 'a': + case 'A': + case 'u': + case 'w': + return _Is_valid_strftime_tm_wday(_Pt); + case 'U': // C23 7.29.3.5 "The strftime function"/3 says that %U and %W depend on tm_year, + case 'W': // but the UCRT neither uses nor validates it. + return _Is_valid_strftime_tm_wday(_Pt) && _Is_valid_strftime_tm_yday(_Pt); + case 'R': + return _Is_valid_strftime_tm_hour(_Pt) && _Is_valid_strftime_tm_min(_Pt); + case 'D': + case 'x': + case 'F': + return _Is_valid_strftime_tm_year(_Pt) && _Is_valid_strftime_tm_mon(_Pt) && _Is_valid_strftime_tm_mday(_Pt); + case 'g': + case 'G': + return _Is_valid_strftime_tm_year(_Pt) && _Is_valid_strftime_tm_wday(_Pt) && _Is_valid_strftime_tm_yday(_Pt); + case 'r': + case 'X': + case 'T': + return _Is_valid_strftime_tm_hour(_Pt) && _Is_valid_strftime_tm_min(_Pt) && _Is_valid_strftime_tm_sec(_Pt); + case 'c': + return _Is_valid_strftime_tm_wday(_Pt) && _Is_valid_strftime_tm_mon(_Pt) && _Is_valid_strftime_tm_mday(_Pt) + && _Is_valid_strftime_tm_hour(_Pt) && _Is_valid_strftime_tm_min(_Pt) && _Is_valid_strftime_tm_sec(_Pt) + && _Is_valid_strftime_tm_year(_Pt); + case 'V': // C23 7.29.3.5 "The strftime function"/3 says that %V depends on tm_year, tm_wday, and tm_yday. + // The UCRT uses them without validating them. + return true; + case 'z': // C23 7.29.3.5 "The strftime function"/3 says that %z and %Z depend on tm_isdst. + case 'Z': // The UCRT treats it as a boolean value, so there's no need for validation. + return true; + case 'n': // newline + case 't': // tab + return true; + default: + // We should have handled %% and called _Is_valid_strftime_specifier() before calling this function. + _STL_INTERNAL_CHECK(false); + return false; + } +} + _EXPORT_STD extern "C++" template >> class time_put : public locale::facet { // facet for converting encoded times to text public: @@ -713,7 +822,11 @@ public: } *_Dest++ = _Specifier; } else { - _Dest = do_put(_Dest, _Iosbase, _Fill, _Pt, _Specifier, _Modifier); // convert a single field + if (_Is_valid_strftime_tm_data(_Specifier, _Pt)) { + _Dest = do_put(_Dest, _Iosbase, _Fill, _Pt, _Specifier, _Modifier); // convert a single field + } else { + *_Dest++ = _Elem('?'); + } } } } @@ -849,7 +962,11 @@ public: } *_Dest++ = *_Fmtfirst; } else { - _Dest = do_put(_Dest, _Iosbase, _Fill, _Pt, _Specifier, _Modifier); // convert a single field + if (_Is_valid_strftime_tm_data(_Specifier, _Pt)) { + _Dest = do_put(_Dest, _Iosbase, _Fill, _Pt, _Specifier, _Modifier); // convert a single field + } else { + *_Dest++ = _Elem('?'); + } } } } @@ -994,7 +1111,11 @@ public: } *_Dest++ = *_Fmtfirst; } else { - _Dest = do_put(_Dest, _Iosbase, _Fill, _Pt, _Specifier, _Modifier); // convert a single field + if (_Is_valid_strftime_tm_data(_Specifier, _Pt)) { + _Dest = do_put(_Dest, _Iosbase, _Fill, _Pt, _Specifier, _Modifier); // convert a single field + } else { + *_Dest++ = _Elem('?'); + } } } } diff --git a/stl/inc/xmemory b/stl/inc/xmemory index 45913c396c3..4944352f3a6 100644 --- a/stl/inc/xmemory +++ b/stl/inc/xmemory @@ -97,7 +97,8 @@ struct _Default_allocate_traits { #ifdef __clang__ // Clang and MSVC implement P0784R7 differently; see GH-1532 _CONSTEXPR20 #endif // defined(__clang__) - void* _Allocate(const size_t _Bytes) { + void* + _Allocate(const size_t _Bytes) { return ::operator new(_Bytes); } @@ -106,7 +107,8 @@ struct _Default_allocate_traits { #ifdef __clang__ // Clang and MSVC implement P0784R7 differently; see GH-1532 _CONSTEXPR20 #endif // defined(__clang__) - void* _Allocate_aligned(const size_t _Bytes, const size_t _Align) { + void* + _Allocate_aligned(const size_t _Bytes, const size_t _Align) { #ifdef __clang__ // Clang and MSVC implement P0784R7 differently; see GH-1532 #if _HAS_CXX20 if (_STD is_constant_evaluated()) { @@ -547,13 +549,13 @@ struct _Normal_allocator_traits { // defines traits for allocators template using rebind_traits = allocator_traits>; - _NODISCARD_RAW_PTR_ALLOC static _CONSTEXPR20 __declspec(allocator) pointer - allocate(_Alloc& _Al, _CRT_GUARDOVERFLOW const size_type _Count) { + _NODISCARD_RAW_PTR_ALLOC static _CONSTEXPR20 __declspec(allocator) pointer allocate( + _Alloc& _Al, _CRT_GUARDOVERFLOW const size_type _Count) { return _Al.allocate(_Count); } - _NODISCARD_RAW_PTR_ALLOC static _CONSTEXPR20 __declspec(allocator) pointer - allocate(_Alloc& _Al, _CRT_GUARDOVERFLOW const size_type _Count, const const_void_pointer _Hint) { + _NODISCARD_RAW_PTR_ALLOC static _CONSTEXPR20 __declspec(allocator) pointer allocate( + _Alloc& _Al, _CRT_GUARDOVERFLOW const size_type _Count, const const_void_pointer _Hint) { if constexpr (_Has_allocate_hint<_Alloc, size_type, const_void_pointer>::value) { return _Al.allocate(_Count, _Hint); } else { @@ -644,8 +646,8 @@ struct _Default_allocator_traits { // traits for std::allocator template using rebind_traits = allocator_traits>; - _NODISCARD_RAW_PTR_ALLOC static _CONSTEXPR20 __declspec(allocator) pointer - allocate(_Alloc& _Al, _CRT_GUARDOVERFLOW const size_type _Count) { + _NODISCARD_RAW_PTR_ALLOC static _CONSTEXPR20 __declspec(allocator) pointer allocate( + _Alloc& _Al, _CRT_GUARDOVERFLOW const size_type _Count) { #if _HAS_CXX20 // TRANSITION, GH-1532 if (_STD is_constant_evaluated()) { return _Al.allocate(_Count); @@ -658,8 +660,8 @@ struct _Default_allocator_traits { // traits for std::allocator } } - _NODISCARD_RAW_PTR_ALLOC static _CONSTEXPR20 __declspec(allocator) pointer - allocate(_Alloc& _Al, _CRT_GUARDOVERFLOW const size_type _Count, const_void_pointer) { + _NODISCARD_RAW_PTR_ALLOC static _CONSTEXPR20 __declspec(allocator) pointer allocate( + _Alloc& _Al, _CRT_GUARDOVERFLOW const size_type _Count, const_void_pointer) { #if _HAS_CXX20 // TRANSITION, GH-1532 if (_STD is_constant_evaluated()) { return _Al.allocate(_Count); @@ -739,8 +741,8 @@ template constexpr _Pocma_values _Choose_pocma_v = allocator_traits<_Alloc>::is_always_equal::value ? _Pocma_values::_Equal_allocators : (allocator_traits<_Alloc>::propagate_on_container_move_assignment::value - ? _Pocma_values::_Propagate_allocators - : _Pocma_values::_No_propagate_allocators); + ? _Pocma_values::_Propagate_allocators + : _Pocma_values::_No_propagate_allocators); template using _Rebind_alloc_t = typename allocator_traits<_Alloc>::template rebind_alloc<_Value_type>; @@ -962,8 +964,8 @@ public: #endif // _HAS_CXX23 #if _HAS_DEPRECATED_ALLOCATOR_MEMBERS - _CXX17_DEPRECATE_OLD_ALLOCATOR_MEMBERS _NODISCARD_RAW_PTR_ALLOC __declspec(allocator) _Ty* allocate( - _CRT_GUARDOVERFLOW const size_t _Count, const void*) { + _CXX17_DEPRECATE_OLD_ALLOCATOR_MEMBERS _NODISCARD_RAW_PTR_ALLOC __declspec(allocator) + _Ty* allocate(_CRT_GUARDOVERFLOW const size_t _Count, const void*) { return allocate(_Count); } @@ -1080,8 +1082,8 @@ _CONSTEXPR20 void _Destroy_range(_NoThrowFwdIt _First, const _NoThrowSentinel _L } template -_NODISCARD constexpr _Size_type _Convert_size(const _Unsigned_type _Len) noexcept( - sizeof(_Unsigned_type) <= sizeof(_Size_type)) { +_NODISCARD constexpr _Size_type _Convert_size(const _Unsigned_type _Len) + noexcept(sizeof(_Unsigned_type) <= sizeof(_Size_type)) { // convert _Unsigned_type to _Size_type, avoiding truncation _STL_INTERNAL_STATIC_ASSERT(_Unsigned_type(-1) > 0); _STL_INTERNAL_STATIC_ASSERT(_Size_type(-1) > 0); @@ -1490,13 +1492,13 @@ public: using _Mybase = _Ty1; // for visualization template - constexpr explicit _Compressed_pair(_Zero_then_variadic_args_t, _Other2&&... _Val2) noexcept( - conjunction_v, is_nothrow_constructible<_Ty2, _Other2...>>) + constexpr explicit _Compressed_pair(_Zero_then_variadic_args_t, _Other2&&... _Val2) + noexcept(conjunction_v, is_nothrow_constructible<_Ty2, _Other2...>>) : _Ty1(), _Myval2(_STD forward<_Other2>(_Val2)...) {} template - constexpr _Compressed_pair(_One_then_variadic_args_t, _Other1&& _Val1, _Other2&&... _Val2) noexcept( - conjunction_v, is_nothrow_constructible<_Ty2, _Other2...>>) + constexpr _Compressed_pair(_One_then_variadic_args_t, _Other1&& _Val1, _Other2&&... _Val2) + noexcept(conjunction_v, is_nothrow_constructible<_Ty2, _Other2...>>) : _Ty1(_STD forward<_Other1>(_Val1)), _Myval2(_STD forward<_Other2>(_Val2)...) {} constexpr _Ty1& _Get_first() noexcept { @@ -1515,13 +1517,13 @@ public: _Ty2 _Myval2; template - constexpr explicit _Compressed_pair(_Zero_then_variadic_args_t, _Other2&&... _Val2) noexcept( - conjunction_v, is_nothrow_constructible<_Ty2, _Other2...>>) + constexpr explicit _Compressed_pair(_Zero_then_variadic_args_t, _Other2&&... _Val2) + noexcept(conjunction_v, is_nothrow_constructible<_Ty2, _Other2...>>) : _Myval1(), _Myval2(_STD forward<_Other2>(_Val2)...) {} template - constexpr _Compressed_pair(_One_then_variadic_args_t, _Other1&& _Val1, _Other2&&... _Val2) noexcept( - conjunction_v, is_nothrow_constructible<_Ty2, _Other2...>>) + constexpr _Compressed_pair(_One_then_variadic_args_t, _Other1&& _Val1, _Other2&&... _Val2) + noexcept(conjunction_v, is_nothrow_constructible<_Ty2, _Other2...>>) : _Myval1(_STD forward<_Other1>(_Val1)), _Myval2(_STD forward<_Other2>(_Val2)...) {} constexpr _Ty1& _Get_first() noexcept { @@ -2132,8 +2134,8 @@ struct _Alloc_temporary2 { #endif // ^^^ no workaround ^^^ template - _CONSTEXPR20 explicit _Alloc_temporary2(_Alloc& _Al_, _Args&&... _Vals) noexcept( - noexcept(_Traits::construct(_Al_, _STD addressof(_Get_value()), _STD forward<_Args>(_Vals)...))) + _CONSTEXPR20 explicit _Alloc_temporary2(_Alloc& _Al_, _Args&&... _Vals) + noexcept(noexcept(_Traits::construct(_Al_, _STD addressof(_Get_value()), _STD forward<_Args>(_Vals)...))) : _Al(_Al_) { _Traits::construct(_Al, _STD addressof(_Get_value()), _STD forward<_Args>(_Vals)...); } @@ -2503,7 +2505,7 @@ _EXPORT_STD inline constexpr from_range_t from_range; template concept _Container_compatible_range = - (_RANGES input_range<_Rng>) &&convertible_to<_RANGES range_reference_t<_Rng>, _Elem>; + (_RANGES input_range<_Rng>) && convertible_to<_RANGES range_reference_t<_Rng>, _Elem>; template <_RANGES input_range _Rng> using _Range_key_type = remove_const_t::first_type>; diff --git a/stl/inc/xsmf_control.h b/stl/inc/xsmf_control.h index 381f0499f7f..9f8b64aa487 100644 --- a/stl/inc/xsmf_control.h +++ b/stl/inc/xsmf_control.h @@ -24,8 +24,8 @@ struct _Non_trivial_copy : _Base { // non-trivial copy construction facade using _Base::_Base; _Non_trivial_copy() = default; - _CONSTEXPR20 _Non_trivial_copy(const _Non_trivial_copy& _That) noexcept( - noexcept(_Base::_Construct_from(static_cast(_That)))) { + _CONSTEXPR20 _Non_trivial_copy(const _Non_trivial_copy& _That) + noexcept(noexcept(_Base::_Construct_from(static_cast(_That)))) { _Base::_Construct_from(static_cast(_That)); } _Non_trivial_copy(_Non_trivial_copy&&) = default; @@ -55,8 +55,8 @@ struct _Non_trivial_move : _SMF_control_copy<_Base, _Types...> { // non-trivial _Non_trivial_move() = default; _Non_trivial_move(const _Non_trivial_move&) = default; - _CONSTEXPR20 _Non_trivial_move(_Non_trivial_move&& _That) noexcept( - noexcept(_Mybase::_Construct_from(static_cast<_Base&&>(_That)))) { + _CONSTEXPR20 _Non_trivial_move(_Non_trivial_move&& _That) + noexcept(noexcept(_Mybase::_Construct_from(static_cast<_Base&&>(_That)))) { _Mybase::_Construct_from(static_cast<_Base&&>(_That)); } _Non_trivial_move& operator=(const _Non_trivial_move&) = default; @@ -90,8 +90,8 @@ struct _Non_trivial_copy_assign : _SMF_control_move<_Base, _Types...> { // non-t _Non_trivial_copy_assign(const _Non_trivial_copy_assign&) = default; _Non_trivial_copy_assign(_Non_trivial_copy_assign&&) = default; - _CONSTEXPR20 _Non_trivial_copy_assign& operator=(const _Non_trivial_copy_assign& _That) noexcept( - noexcept(_Mybase::_Assign_from(static_cast(_That)))) { + _CONSTEXPR20 _Non_trivial_copy_assign& operator=(const _Non_trivial_copy_assign& _That) + noexcept(noexcept(_Mybase::_Assign_from(static_cast(_That)))) { _Mybase::_Assign_from(static_cast(_That)); return *this; } @@ -128,8 +128,8 @@ struct _Non_trivial_move_assign : _SMF_control_copy_assign<_Base, _Types...> { / _Non_trivial_move_assign(_Non_trivial_move_assign&&) = default; _Non_trivial_move_assign& operator=(const _Non_trivial_move_assign&) = default; - _CONSTEXPR20 _Non_trivial_move_assign& operator=(_Non_trivial_move_assign&& _That) noexcept( - noexcept(_Mybase::_Assign_from(static_cast<_Base&&>(_That)))) { + _CONSTEXPR20 _Non_trivial_move_assign& operator=(_Non_trivial_move_assign&& _That) + noexcept(noexcept(_Mybase::_Assign_from(static_cast<_Base&&>(_That)))) { _Mybase::_Assign_from(static_cast<_Base&&>(_That)); return *this; } diff --git a/stl/inc/xstring b/stl/inc/xstring index 7b458d16c5b..212d55880a5 100644 --- a/stl/inc/xstring +++ b/stl/inc/xstring @@ -520,7 +520,7 @@ struct _String_constructor_rvalue_allocator_tag { #if _HAS_CXX23 template concept _Contiguous_range_of = - (_RANGES contiguous_range<_Rng>) &&same_as>, _Ty>; + (_RANGES contiguous_range<_Rng>) && same_as>, _Ty>; #endif // _HAS_CXX23 _EXPORT_STD template , class _Alloc = allocator<_Elem>> @@ -1011,8 +1011,8 @@ public: _Take_contents(_Right); } - _CONSTEXPR20 basic_string(basic_string&& _Right, const _Alloc& _Al) noexcept( - _Alty_traits::is_always_equal::value) // strengthened + _CONSTEXPR20 basic_string(basic_string&& _Right, const _Alloc& _Al) + noexcept(_Alty_traits::is_always_equal::value) // strengthened : _Mypair(_One_then_variadic_args_t{}, _Al) { if constexpr (!_Alty_traits::is_always_equal::value) { if (_Getal() != _Right._Getal()) { @@ -1029,8 +1029,8 @@ public: _CONSTEXPR20 basic_string(_String_constructor_concat_tag, const basic_string& _Source_of_al, const _Elem* const _Left_ptr, const size_type _Left_size, const _Elem* const _Right_ptr, const size_type _Right_size) - : _Mypair( - _One_then_variadic_args_t{}, _Alty_traits::select_on_container_copy_construction(_Source_of_al._Getal())) { + : _Mypair(_One_then_variadic_args_t{}, + _Alty_traits::select_on_container_copy_construction(_Source_of_al._Getal())) { _STL_INTERNAL_CHECK(_Left_size <= max_size()); _STL_INTERNAL_CHECK(_Right_size <= max_size()); _STL_INTERNAL_CHECK(_Right_size <= max_size() - _Left_size); @@ -1208,8 +1208,8 @@ public: } #endif // _HAS_CXX20 - _CONSTEXPR20 basic_string& operator=(basic_string&& _Right) noexcept( - _Choose_pocma_v<_Alty> != _Pocma_values::_No_propagate_allocators) { + _CONSTEXPR20 basic_string& operator=(basic_string&& _Right) + noexcept(_Choose_pocma_v<_Alty> != _Pocma_values::_No_propagate_allocators) { if (this == _STD addressof(_Right)) { return *this; } @@ -3092,13 +3092,13 @@ private: #if _HAS_CXX17 template >, enable_if_t, _Is_allocator<_Alloc>>, int> = 0> -basic_string(_Iter, _Iter, _Alloc = _Alloc()) - -> basic_string<_Iter_value_t<_Iter>, char_traits<_Iter_value_t<_Iter>>, _Alloc>; +basic_string( + _Iter, _Iter, _Alloc = _Alloc()) -> basic_string<_Iter_value_t<_Iter>, char_traits<_Iter_value_t<_Iter>>, _Alloc>; template , enable_if_t<_Is_allocator<_Alloc>::value, int> = 0> -explicit basic_string(basic_string_view<_Elem, _Traits>, const _Alloc& = _Alloc()) - -> basic_string<_Elem, _Traits, _Alloc>; +explicit basic_string( + basic_string_view<_Elem, _Traits>, const _Alloc& = _Alloc()) -> basic_string<_Elem, _Traits, _Alloc>; template , enable_if_t<_Is_allocator<_Alloc>::value, int> = 0> @@ -3107,8 +3107,8 @@ basic_string(basic_string_view<_Elem, _Traits>, _Guide_size_type_t<_Alloc>, _Gui #if _HAS_CXX23 template <_RANGES input_range _Rng, _Allocator_for_container _Alloc = allocator<_RANGES range_value_t<_Rng>>> -basic_string(from_range_t, _Rng&&, _Alloc = _Alloc()) - -> basic_string<_RANGES range_value_t<_Rng>, char_traits<_RANGES range_value_t<_Rng>>, _Alloc>; +basic_string(from_range_t, _Rng&&, + _Alloc = _Alloc()) -> basic_string<_RANGES range_value_t<_Rng>, char_traits<_RANGES range_value_t<_Rng>>, _Alloc>; #endif // _HAS_CXX23 #endif // _HAS_CXX17 diff --git a/stl/inc/xtree b/stl/inc/xtree index 42c10a95341..f0848f56b4f 100644 --- a/stl/inc/xtree +++ b/stl/inc/xtree @@ -903,7 +903,7 @@ public: template _Tree(const _Tree& _Right, _Any_alloc&& _Al) : _Mypair(_One_then_variadic_args_t{}, _Right.key_comp(), _One_then_variadic_args_t{}, - _STD forward<_Any_alloc>(_Al)) { + _STD forward<_Any_alloc>(_Al)) { auto&& _Alproxy = _GET_PROXY_ALLOCATOR(_Alnode, _Getal()); const auto _Scary = _Get_scary(); _Container_proxy_ptr<_Alty> _Proxy(_Alproxy, *_Scary); @@ -915,14 +915,14 @@ public: _Tree(_Tree&& _Right) : _Mypair(_One_then_variadic_args_t{}, _Right.key_comp(), // intentionally copy comparator, see LWG-2227 - _One_then_variadic_args_t{}, _STD move(_Right._Getal())) { + _One_then_variadic_args_t{}, _STD move(_Right._Getal())) { _Alloc_sentinel_and_proxy(); _Swap_val_excluding_comp(_Right); } _Tree(_Tree&& _Right, const allocator_type& _Al) : _Mypair(_One_then_variadic_args_t{}, _Right.key_comp(), // intentionally copy comparator, see LWG-2227 - _One_then_variadic_args_t{}, _Al) { + _One_then_variadic_args_t{}, _Al) { if constexpr (!_Alnode_traits::is_always_equal::value) { if (_Getal() != _Right._Getal()) { auto&& _Alproxy = _GET_PROXY_ALLOCATOR(_Alnode, _Getal()); @@ -1350,8 +1350,8 @@ public: #if _HAS_CXX23 template - requires _Is_transparent_v - && (!is_convertible_v<_Kx, const_iterator>) && (!is_convertible_v<_Kx, iterator>) + requires _Is_transparent_v && (!is_convertible_v<_Kx, const_iterator>) + && (!is_convertible_v<_Kx, iterator>) size_type erase(_Kx&& _Keyval) noexcept(noexcept(_Eqrange(_Keyval))) /* strengthened */ { return _Erase(_Eqrange(_Keyval)); } @@ -1754,8 +1754,8 @@ public: #if _HAS_CXX23 template - requires _Is_transparent_v - && (!is_convertible_v<_Kx, const_iterator>) && (!is_convertible_v<_Kx, iterator>) + requires _Is_transparent_v && (!is_convertible_v<_Kx, const_iterator>) + && (!is_convertible_v<_Kx, iterator>) node_type extract(_Kx&& _Keyval) { const const_iterator _Where = find(_Keyval); if (_Where == end()) { diff --git a/stl/inc/xutility b/stl/inc/xutility index 110178e1416..6e791d549a9 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -12,6 +12,7 @@ #include #include #include +#include #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) @@ -78,20 +79,34 @@ __declspec(noalias) void __cdecl __std_reverse_trivially_swappable_8(void* _Firs __declspec(noalias) void __cdecl __std_swap_ranges_trivially_swappable_noalias( void* _First1, void* _Last1, void* _First2) noexcept; -__declspec(noalias) size_t - __stdcall __std_count_trivial_1(const void* _First, const void* _Last, uint8_t _Val) noexcept; -__declspec(noalias) size_t - __stdcall __std_count_trivial_2(const void* _First, const void* _Last, uint16_t _Val) noexcept; -__declspec(noalias) size_t - __stdcall __std_count_trivial_4(const void* _First, const void* _Last, uint32_t _Val) noexcept; -__declspec(noalias) size_t - __stdcall __std_count_trivial_8(const void* _First, const void* _Last, uint64_t _Val) noexcept; +__declspec(noalias) size_t __stdcall __std_count_trivial_1( + const void* _First, const void* _Last, uint8_t _Val) noexcept; +__declspec(noalias) size_t __stdcall __std_count_trivial_2( + const void* _First, const void* _Last, uint16_t _Val) noexcept; +__declspec(noalias) size_t __stdcall __std_count_trivial_4( + const void* _First, const void* _Last, uint32_t _Val) noexcept; +__declspec(noalias) size_t __stdcall __std_count_trivial_8( + const void* _First, const void* _Last, uint64_t _Val) noexcept; const void* __stdcall __std_find_trivial_1(const void* _First, const void* _Last, uint8_t _Val) noexcept; const void* __stdcall __std_find_trivial_2(const void* _First, const void* _Last, uint16_t _Val) noexcept; const void* __stdcall __std_find_trivial_4(const void* _First, const void* _Last, uint32_t _Val) noexcept; const void* __stdcall __std_find_trivial_8(const void* _First, const void* _Last, uint64_t _Val) noexcept; +const void* __stdcall __std_find_first_of_trivial_1( + const void* _First1, const void* _Last1, const void* _First2, const void* _Last2) noexcept; +const void* __stdcall __std_find_first_of_trivial_2( + const void* _First1, const void* _Last1, const void* _First2, const void* _Last2) noexcept; +const void* __stdcall __std_find_first_of_trivial_4( + const void* _First1, const void* _Last1, const void* _First2, const void* _Last2) noexcept; +const void* __stdcall __std_find_first_of_trivial_8( + const void* _First1, const void* _Last1, const void* _First2, const void* _Last2) noexcept; + +const void* __stdcall __std_search_1( + const void* _First1, const void* _Last1, const void* _First2, size_t _Count2) noexcept; +const void* __stdcall __std_search_2( + const void* _First1, const void* _Last1, const void* _First2, size_t _Count2) noexcept; + const void* __stdcall __std_min_element_1(const void* _First, const void* _Last, bool _Signed) noexcept; const void* __stdcall __std_min_element_2(const void* _First, const void* _Last, bool _Signed) noexcept; const void* __stdcall __std_min_element_4(const void* _First, const void* _Last, bool _Signed) noexcept; @@ -197,6 +212,42 @@ _Ty* _Find_vectorized(_Ty* const _First, _Ty* const _Last, const _TVal _Val) noe } } +// find_first_of vectorization is likely to be a win after this size (in elements) +_INLINE_VAR constexpr ptrdiff_t _Threshold_find_first_of = 16; + +template +_Ty1* _Find_first_of_vectorized( + _Ty1* const _First1, _Ty1* const _Last1, _Ty2* const _First2, _Ty2* const _Last2) noexcept { + _STL_INTERNAL_STATIC_ASSERT(sizeof(_Ty1) == sizeof(_Ty2)); + if constexpr (sizeof(_Ty1) == 1) { + return const_cast<_Ty1*>( + static_cast(::__std_find_first_of_trivial_1(_First1, _Last1, _First2, _Last2))); + } else if constexpr (sizeof(_Ty1) == 2) { + return const_cast<_Ty1*>( + static_cast(::__std_find_first_of_trivial_2(_First1, _Last1, _First2, _Last2))); + } else if constexpr (sizeof(_Ty1) == 4) { + return const_cast<_Ty1*>( + static_cast(::__std_find_first_of_trivial_4(_First1, _Last1, _First2, _Last2))); + } else if constexpr (sizeof(_Ty1) == 8) { + return const_cast<_Ty1*>( + static_cast(::__std_find_first_of_trivial_8(_First1, _Last1, _First2, _Last2))); + } else { + _STL_INTERNAL_STATIC_ASSERT(false); // unexpected size + } +} + +template +_Ty1* _Search_vectorized(_Ty1* const _First1, _Ty1* const _Last1, _Ty2* const _First2, const size_t _Count2) noexcept { + _STL_INTERNAL_STATIC_ASSERT(sizeof(_Ty1) == sizeof(_Ty2)); + if constexpr (sizeof(_Ty1) == 1) { + return const_cast<_Ty1*>(static_cast(::__std_search_1(_First1, _Last1, _First2, _Count2))); + } else if constexpr (sizeof(_Ty1) == 2) { + return const_cast<_Ty1*>(static_cast(::__std_search_2(_First1, _Last1, _First2, _Count2))); + } else { + _STL_INTERNAL_STATIC_ASSERT(false); // unexpected size + } +} + template _Ty* _Min_element_vectorized(_Ty* const _First, _Ty* const _Last) noexcept { constexpr bool _Signed = is_signed_v<_Ty>; @@ -387,15 +438,15 @@ _EXPORT_STD template requires requires(_Ty* _Location, _Types&&... _Args) { ::new (static_cast(_Location)) _Ty(_STD forward<_Types>(_Args)...); // per LWG-3888 } -constexpr _Ty* construct_at(_Ty* const _Location, _Types&&... _Args) noexcept( - noexcept(::new(static_cast(_Location)) _Ty(_STD forward<_Types>(_Args)...))) /* strengthened */ { +constexpr _Ty* construct_at(_Ty* const _Location, _Types&&... _Args) + noexcept(noexcept(::new (static_cast(_Location)) _Ty(_STD forward<_Types>(_Args)...))) /* strengthened */ { _MSVC_CONSTEXPR return ::new (static_cast(_Location)) _Ty(_STD forward<_Types>(_Args)...); } #endif // _HAS_CXX20 template -_CONSTEXPR20 void _Construct_in_place(_Ty& _Obj, _Types&&... _Args) noexcept( - is_nothrow_constructible_v<_Ty, _Types...>) { +_CONSTEXPR20 void _Construct_in_place(_Ty& _Obj, _Types&&... _Args) + noexcept(is_nothrow_constructible_v<_Ty, _Types...>) { #if _HAS_CXX20 if (_STD is_constant_evaluated()) { _STD construct_at(_STD addressof(_Obj), _STD forward<_Types>(_Args)...); @@ -422,8 +473,8 @@ struct _Ptr_traits_base { using _Reftype = conditional_t, char, _Elem>&; - _NODISCARD static _CONSTEXPR20 pointer pointer_to(_Reftype _Val) noexcept( - noexcept(_Ty::pointer_to(_Val))) /* strengthened */ { // Per LWG-3454 + _NODISCARD static _CONSTEXPR20 pointer pointer_to(_Reftype _Val) + noexcept(noexcept(_Ty::pointer_to(_Val))) /* strengthened */ { // Per LWG-3454 return _Ty::pointer_to(_Val); } }; @@ -710,8 +761,8 @@ _NODISCARD constexpr auto _Pass_fn(_Fn& _Func) noexcept { #if _HAS_CXX23 _EXPORT_STD template requires is_invocable_r_v<_Result_type, _Callable, _Types...> -_NODISCARD constexpr _Result_type invoke_r(_Callable&& _Obj, _Types&&... _Args) noexcept( - is_nothrow_invocable_r_v<_Result_type, _Callable, _Types...>) { +_NODISCARD constexpr _Result_type invoke_r(_Callable&& _Obj, _Types&&... _Args) + noexcept(is_nothrow_invocable_r_v<_Result_type, _Callable, _Types...>) { if constexpr (is_void_v<_Result_type>) { (void) _STD invoke(static_cast<_Callable&&>(_Obj), static_cast<_Types&&>(_Args)...); } else { @@ -785,7 +836,7 @@ namespace ranges { public: template requires (_Choice<_Ty>._Strategy != _St::_None) - _NODISCARD _STATIC_CALL_OPERATOR constexpr decltype(auto) operator()(_Ty && _Val) _CONST_CALL_OPERATOR + _NODISCARD _STATIC_CALL_OPERATOR constexpr decltype(auto) operator()(_Ty&& _Val) _CONST_CALL_OPERATOR noexcept(_Choice<_Ty>._No_throw) { constexpr _St _Strat = _Choice<_Ty>._Strategy; @@ -916,50 +967,45 @@ struct _Iter_concept_impl1 { template >, _It, iterator_traits<_It>>> using _Iter_concept = _Iter_concept_impl1<_Has_member_iterator_concept<_Traits>>::template _Apply<_It, _Traits>; -// clang-format off _EXPORT_STD template -concept input_iterator = input_or_output_iterator<_It> && indirectly_readable<_It> - && requires { typename _Iter_concept<_It>; } - && derived_from<_Iter_concept<_It>, input_iterator_tag>; +concept input_iterator = input_or_output_iterator<_It> && indirectly_readable<_It> && requires { + typename _Iter_concept<_It>; +} && derived_from<_Iter_concept<_It>, input_iterator_tag>; _EXPORT_STD template concept output_iterator = input_or_output_iterator<_It> && indirectly_writable<_It, _Ty> - && requires(_It __i, _Ty&& __t) { - *__i++ = static_cast<_Ty&&>(__t); - }; + && requires(_It __i, _Ty&& __t) { *__i++ = static_cast<_Ty&&>(__t); }; _EXPORT_STD template concept forward_iterator = input_iterator<_It> && derived_from<_Iter_concept<_It>, forward_iterator_tag> - && incrementable<_It> && sentinel_for<_It, _It>; + && incrementable<_It> && sentinel_for<_It, _It>; _EXPORT_STD template -concept bidirectional_iterator = forward_iterator<_It> && derived_from<_Iter_concept<_It>, bidirectional_iterator_tag> - && requires(_It __i) { +concept bidirectional_iterator = + forward_iterator<_It> && derived_from<_Iter_concept<_It>, bidirectional_iterator_tag> && requires(_It __i) { { --__i } -> same_as<_It&>; { __i-- } -> same_as<_It>; }; _EXPORT_STD template -concept random_access_iterator = bidirectional_iterator<_It> - && derived_from<_Iter_concept<_It>, random_access_iterator_tag> && totally_ordered<_It> +concept random_access_iterator = + bidirectional_iterator<_It> && derived_from<_Iter_concept<_It>, random_access_iterator_tag> && totally_ordered<_It> && sized_sentinel_for<_It, _It> && requires(_It __i, const _It __j, const iter_difference_t<_It> __n) { - { __i += __n } -> same_as<_It&>; - { __j + __n } -> same_as<_It>; - { __n + __j } -> same_as<_It>; - { __i -= __n } -> same_as<_It&>; - { __j - __n } -> same_as<_It>; - { __j[__n] } -> same_as>; - }; + { __i += __n } -> same_as<_It&>; + { __j + __n } -> same_as<_It>; + { __n + __j } -> same_as<_It>; + { __i -= __n } -> same_as<_It&>; + { __j - __n } -> same_as<_It>; + { __j[__n] } -> same_as>; + }; _EXPORT_STD template -concept contiguous_iterator = random_access_iterator<_It> - && derived_from<_Iter_concept<_It>, contiguous_iterator_tag> - && is_lvalue_reference_v> - && same_as, remove_cvref_t>> +concept contiguous_iterator = + random_access_iterator<_It> && derived_from<_Iter_concept<_It>, contiguous_iterator_tag> + && is_lvalue_reference_v> && same_as, remove_cvref_t>> && requires(const _It& __i) { - { _STD to_address(__i) } -> same_as>>; - }; -// clang-format on + { _STD to_address(__i) } -> same_as>>; + }; _EXPORT_STD template concept indirectly_unary_invocable = indirectly_readable<_It> && copy_constructible<_Fn> @@ -1052,30 +1098,24 @@ concept indirectly_movable_storable = _EXPORT_STD template concept indirectly_copyable = indirectly_readable<_In> && indirectly_writable<_Out, iter_reference_t<_In>>; -// clang-format off _EXPORT_STD template -concept indirectly_copyable_storable = indirectly_copyable<_In, _Out> - && indirectly_writable<_Out, iter_value_t<_In>&> - && indirectly_writable<_Out, const iter_value_t<_In>&> - && indirectly_writable<_Out, iter_value_t<_In>&&> - && indirectly_writable<_Out, const iter_value_t<_In>&&> - && copyable> +concept indirectly_copyable_storable = + indirectly_copyable<_In, _Out> && indirectly_writable<_Out, iter_value_t<_In>&> + && indirectly_writable<_Out, const iter_value_t<_In>&> && indirectly_writable<_Out, iter_value_t<_In>&&> + && indirectly_writable<_Out, const iter_value_t<_In>&&> && copyable> && constructible_from, iter_reference_t<_In>> && assignable_from&, iter_reference_t<_In>>; -// clang-format on namespace ranges { namespace _Iter_swap { template void iter_swap(_Ty1, _Ty2) = delete; - // clang-format off template - concept _Has_ADL = (_Has_class_or_enum_type<_Ty1> || _Has_class_or_enum_type<_Ty2>) - && requires(_Ty1&& __t1, _Ty2&& __t2) { + concept _Has_ADL = + (_Has_class_or_enum_type<_Ty1> || _Has_class_or_enum_type<_Ty2>) && requires(_Ty1&& __t1, _Ty2&& __t2) { iter_swap(static_cast<_Ty1&&>(__t1), static_cast<_Ty2&&>(__t2)); // intentional ADL }; - // clang-format on template concept _Can_swap_references = @@ -1088,8 +1128,8 @@ namespace ranges { && indirectly_movable_storable, remove_reference_t<_Ty1>>; template - _NODISCARD constexpr iter_value_t> _Iter_exchange_move(_Xty&& _XVal, - _Yty&& _YVal) noexcept(noexcept(iter_value_t>(_RANGES iter_move(_XVal)))) { + _NODISCARD constexpr iter_value_t> _Iter_exchange_move(_Xty&& _XVal, _Yty&& _YVal) + noexcept(noexcept(iter_value_t>(_RANGES iter_move(_XVal)))) { iter_value_t> _Tmp(_RANGES iter_move(_XVal)); *_XVal = _RANGES iter_move(_YVal); return _Tmp; @@ -1322,8 +1362,8 @@ constexpr bool _Has_nothrow_unwrapped<_Iter, void_t noexcept(_STD declval<_Iter>()._Unwrapped()); template -_NODISCARD constexpr decltype(auto) _Get_unwrapped(_Iter&& _It) noexcept( - !_Unwrappable_v<_Iter> || _Has_nothrow_unwrapped<_Iter>) { +_NODISCARD constexpr decltype(auto) _Get_unwrapped(_Iter&& _It) + noexcept(!_Unwrappable_v<_Iter> || _Has_nothrow_unwrapped<_Iter>) { // unwrap an iterator previously subjected to _Adl_verify_range or otherwise validated if constexpr (is_pointer_v>) { // special-case pointers and arrays return _It + 0; @@ -1538,8 +1578,8 @@ template constexpr bool _Debug_lt_pred_order_check_noexcept<_Pr, _Ty1, _Ty2, false> = true; template -_NODISCARD constexpr bool _Debug_lt_pred(_Pr&& _Pred, _Ty1&& _Left, _Ty2&& _Right) noexcept( - noexcept(_Pred(_Left, _Right)) && _Debug_lt_pred_order_check_noexcept<_Pr, _Ty1, _Ty2>) { +_NODISCARD constexpr bool _Debug_lt_pred(_Pr&& _Pred, _Ty1&& _Left, _Ty2&& _Right) + noexcept(noexcept(_Pred(_Left, _Right)) && _Debug_lt_pred_order_check_noexcept<_Pr, _Ty1, _Ty2>) { const auto _Result = static_cast(_Pred(_Left, _Right)); if constexpr (_Enable_debug_lt_pred_order_check<_Pr, _Ty1, _Ty2>) { @@ -1676,16 +1716,16 @@ public: _CONSTEXPR17 reverse_iterator() = default; - _CONSTEXPR17 explicit reverse_iterator(_BidIt _Right) noexcept( - is_nothrow_move_constructible_v<_BidIt>) // strengthened + _CONSTEXPR17 explicit reverse_iterator(_BidIt _Right) + noexcept(is_nothrow_move_constructible_v<_BidIt>) // strengthened : current(_STD move(_Right)) {} template #if _HAS_CXX20 requires (!is_same_v<_Other, _BidIt>) && convertible_to #endif // _HAS_CXX20 - _CONSTEXPR17 reverse_iterator(const reverse_iterator<_Other>& _Right) noexcept( - is_nothrow_constructible_v<_BidIt, const _Other&>) // strengthened + _CONSTEXPR17 reverse_iterator(const reverse_iterator<_Other>& _Right) + noexcept(is_nothrow_constructible_v<_BidIt, const _Other&>) // strengthened : current(_Right.current) { } @@ -1694,8 +1734,8 @@ public: requires (!is_same_v<_Other, _BidIt>) && convertible_to && assignable_from<_BidIt&, const _Other&> #endif // _HAS_CXX20 - _CONSTEXPR17 reverse_iterator& operator=(const reverse_iterator<_Other>& _Right) noexcept( - is_nothrow_assignable_v<_BidIt&, const _Other&>) /* strengthened */ { + _CONSTEXPR17 reverse_iterator& operator=(const reverse_iterator<_Other>& _Right) + noexcept(is_nothrow_assignable_v<_BidIt&, const _Other&>) /* strengthened */ { current = _Right.current; return *this; } @@ -1704,15 +1744,14 @@ public: return current; } - _NODISCARD _CONSTEXPR17 reference operator*() const noexcept(is_nothrow_copy_constructible_v<_BidIt> // - && noexcept(*--(_STD declval<_BidIt&>()))) /* strengthened */ { + _NODISCARD _CONSTEXPR17 reference operator*() const + noexcept(is_nothrow_copy_constructible_v<_BidIt> && noexcept(*--(_STD declval<_BidIt&>()))) /* strengthened */ { _BidIt _Tmp = current; return *--_Tmp; } _NODISCARD _CONSTEXPR17 pointer operator->() const - noexcept(is_nothrow_copy_constructible_v<_BidIt> // - && noexcept(--(_STD declval<_BidIt&>())) + noexcept(is_nothrow_copy_constructible_v<_BidIt> && noexcept(--(_STD declval<_BidIt&>())) && _Has_nothrow_operator_arrow<_BidIt&, pointer>) /* strengthened */ #if _HAS_CXX20 requires (is_pointer_v<_BidIt> || requires(const _BidIt __i) { __i.operator->(); }) @@ -1733,7 +1772,7 @@ public: } _CONSTEXPR17 reverse_iterator operator++(int) noexcept(is_nothrow_copy_constructible_v<_BidIt> // - && noexcept(--current)) /* strengthened */ { + && noexcept(--current)) /* strengthened */ { reverse_iterator _Tmp = *this; --current; return _Tmp; @@ -1745,7 +1784,7 @@ public: } _CONSTEXPR17 reverse_iterator operator--(int) noexcept(is_nothrow_copy_constructible_v<_BidIt> // - && noexcept(++current)) /* strengthened */ { + && noexcept(++current)) /* strengthened */ { reverse_iterator _Tmp = *this; ++current; return _Tmp; @@ -1756,8 +1795,8 @@ public: return reverse_iterator(current - _Off); } - _CONSTEXPR17 reverse_iterator& operator+=(const difference_type _Off) noexcept( - noexcept(current -= _Off)) /* strengthened */ { + _CONSTEXPR17 reverse_iterator& operator+=(const difference_type _Off) + noexcept(noexcept(current -= _Off)) /* strengthened */ { current -= _Off; return *this; } @@ -1767,8 +1806,8 @@ public: return reverse_iterator(current + _Off); } - _CONSTEXPR17 reverse_iterator& operator-=(const difference_type _Off) noexcept( - noexcept(current += _Off)) /* strengthened */ { + _CONSTEXPR17 reverse_iterator& operator-=(const difference_type _Off) + noexcept(noexcept(current += _Off)) /* strengthened */ { current += _Off; return *this; } @@ -1779,19 +1818,17 @@ public: } #if _HAS_CXX20 - _NODISCARD friend constexpr iter_rvalue_reference_t<_BidIt> iter_move(const reverse_iterator& _It) noexcept( - is_nothrow_copy_constructible_v<_BidIt> // - && noexcept(_RANGES iter_move(--_STD declval<_BidIt&>()))) { + _NODISCARD friend constexpr iter_rvalue_reference_t<_BidIt> iter_move(const reverse_iterator& _It) + noexcept(is_nothrow_copy_constructible_v<_BidIt> && noexcept(_RANGES iter_move(--_STD declval<_BidIt&>()))) { auto _Tmp = _It.current; --_Tmp; return _RANGES iter_move(_Tmp); } template _BidIt2> - friend constexpr void iter_swap(const reverse_iterator& _Left, const reverse_iterator<_BidIt2>& _Right) noexcept( - is_nothrow_copy_constructible_v<_BidIt> - && is_nothrow_copy_constructible_v<_BidIt2> // - && noexcept(_RANGES iter_swap(--_STD declval<_BidIt&>(), --_STD declval<_BidIt2&>()))) { + friend constexpr void iter_swap(const reverse_iterator& _Left, const reverse_iterator<_BidIt2>& _Right) + noexcept(is_nothrow_copy_constructible_v<_BidIt> && is_nothrow_copy_constructible_v<_BidIt2> + && noexcept(_RANGES iter_swap(--_STD declval<_BidIt&>(), --_STD declval<_BidIt2&>()))) { auto _LTmp = _Left.current; auto _RTmp = _Right.base(); --_LTmp; @@ -1841,9 +1878,8 @@ protected: }; _EXPORT_STD template -_NODISCARD _CONSTEXPR17 bool - operator==(const reverse_iterator<_BidIt1>& _Left, const reverse_iterator<_BidIt2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left._Get_current() == _Right._Get_current()))) /* strengthened */ +_NODISCARD _CONSTEXPR17 bool operator==(const reverse_iterator<_BidIt1>& _Left, const reverse_iterator<_BidIt2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left._Get_current() == _Right._Get_current()))) /* strengthened */ #if _HAS_CXX20 requires requires { { _Left._Get_current() == _Right._Get_current() } -> _Implicitly_convertible_to; @@ -1854,9 +1890,8 @@ _NODISCARD _CONSTEXPR17 bool } _EXPORT_STD template -_NODISCARD _CONSTEXPR17 bool - operator!=(const reverse_iterator<_BidIt1>& _Left, const reverse_iterator<_BidIt2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left._Get_current() != _Right._Get_current()))) /* strengthened */ +_NODISCARD _CONSTEXPR17 bool operator!=(const reverse_iterator<_BidIt1>& _Left, const reverse_iterator<_BidIt2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left._Get_current() != _Right._Get_current()))) /* strengthened */ #if _HAS_CXX20 requires requires { { _Left._Get_current() != _Right._Get_current() } -> _Implicitly_convertible_to; @@ -1867,9 +1902,8 @@ _NODISCARD _CONSTEXPR17 bool } _EXPORT_STD template -_NODISCARD _CONSTEXPR17 bool - operator<(const reverse_iterator<_BidIt1>& _Left, const reverse_iterator<_BidIt2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left._Get_current() > _Right._Get_current()))) /* strengthened */ +_NODISCARD _CONSTEXPR17 bool operator<(const reverse_iterator<_BidIt1>& _Left, const reverse_iterator<_BidIt2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left._Get_current() > _Right._Get_current()))) /* strengthened */ #if _HAS_CXX20 requires requires { { _Left._Get_current() > _Right._Get_current() } -> _Implicitly_convertible_to; @@ -1880,9 +1914,8 @@ _NODISCARD _CONSTEXPR17 bool } _EXPORT_STD template -_NODISCARD _CONSTEXPR17 bool - operator>(const reverse_iterator<_BidIt1>& _Left, const reverse_iterator<_BidIt2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left._Get_current() < _Right._Get_current()))) /* strengthened */ +_NODISCARD _CONSTEXPR17 bool operator>(const reverse_iterator<_BidIt1>& _Left, const reverse_iterator<_BidIt2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left._Get_current() < _Right._Get_current()))) /* strengthened */ #if _HAS_CXX20 requires requires { { _Left._Get_current() < _Right._Get_current() } -> _Implicitly_convertible_to; @@ -1893,9 +1926,8 @@ _NODISCARD _CONSTEXPR17 bool } _EXPORT_STD template -_NODISCARD _CONSTEXPR17 bool - operator<=(const reverse_iterator<_BidIt1>& _Left, const reverse_iterator<_BidIt2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left._Get_current() >= _Right._Get_current()))) /* strengthened */ +_NODISCARD _CONSTEXPR17 bool operator<=(const reverse_iterator<_BidIt1>& _Left, const reverse_iterator<_BidIt2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left._Get_current() >= _Right._Get_current()))) /* strengthened */ #if _HAS_CXX20 requires requires { { _Left._Get_current() >= _Right._Get_current() } -> _Implicitly_convertible_to; @@ -1906,9 +1938,8 @@ _NODISCARD _CONSTEXPR17 bool } _EXPORT_STD template -_NODISCARD _CONSTEXPR17 bool - operator>=(const reverse_iterator<_BidIt1>& _Left, const reverse_iterator<_BidIt2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left._Get_current() <= _Right._Get_current()))) /* strengthened */ +_NODISCARD _CONSTEXPR17 bool operator>=(const reverse_iterator<_BidIt1>& _Left, const reverse_iterator<_BidIt2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left._Get_current() <= _Right._Get_current()))) /* strengthened */ #if _HAS_CXX20 requires requires { { _Left._Get_current() <= _Right._Get_current() } -> _Implicitly_convertible_to; @@ -1920,17 +1951,16 @@ _NODISCARD _CONSTEXPR17 bool #if _HAS_CXX20 _EXPORT_STD template _BidIt2> -_NODISCARD constexpr compare_three_way_result_t<_BidIt1, _BidIt2> - operator<=>(const reverse_iterator<_BidIt1>& _Left, const reverse_iterator<_BidIt2>& _Right) noexcept( - noexcept(_Right._Get_current() <=> _Left._Get_current())) /* strengthened */ { +_NODISCARD constexpr compare_three_way_result_t<_BidIt1, _BidIt2> operator<=>( + const reverse_iterator<_BidIt1>& _Left, const reverse_iterator<_BidIt2>& _Right) + noexcept(noexcept(_Right._Get_current() <=> _Left._Get_current())) /* strengthened */ { return _Right._Get_current() <=> _Left._Get_current(); } #endif // _HAS_CXX20 _EXPORT_STD template -_NODISCARD _CONSTEXPR17 auto - operator-(const reverse_iterator<_BidIt1>& _Left, const reverse_iterator<_BidIt2>& _Right) noexcept( - noexcept(_Right._Get_current() - _Left._Get_current())) /* strengthened */ +_NODISCARD _CONSTEXPR17 auto operator-(const reverse_iterator<_BidIt1>& _Left, const reverse_iterator<_BidIt2>& _Right) + noexcept(noexcept(_Right._Get_current() - _Left._Get_current())) /* strengthened */ -> decltype(_Right._Get_current() - _Left._Get_current()) { return _Right._Get_current() - _Left._Get_current(); } @@ -1942,8 +1972,8 @@ _NODISCARD _CONSTEXPR17 reverse_iterator<_BidIt> operator+(typename reverse_iter } _EXPORT_STD template -_NODISCARD _CONSTEXPR17 reverse_iterator<_BidIt> make_reverse_iterator(_BidIt _Iter) noexcept( - is_nothrow_move_constructible_v<_BidIt>) /* strengthened */ { +_NODISCARD _CONSTEXPR17 reverse_iterator<_BidIt> make_reverse_iterator(_BidIt _Iter) + noexcept(is_nothrow_move_constructible_v<_BidIt>) /* strengthened */ { return reverse_iterator<_BidIt>(_STD move(_Iter)); } @@ -1988,14 +2018,14 @@ _NODISCARD constexpr _Ty* end(_Ty (&_Array)[_Size]) noexcept { } _EXPORT_STD template -_NODISCARD constexpr auto cbegin(const _Container& _Cont) noexcept(noexcept(_STD begin(_Cont))) - -> decltype(_STD begin(_Cont)) { +_NODISCARD constexpr auto cbegin(const _Container& _Cont) + noexcept(noexcept(_STD begin(_Cont))) -> decltype(_STD begin(_Cont)) { return _STD begin(_Cont); } _EXPORT_STD template -_NODISCARD constexpr auto cend(const _Container& _Cont) noexcept(noexcept(_STD end(_Cont))) - -> decltype(_STD end(_Cont)) { +_NODISCARD constexpr auto cend(const _Container& _Cont) + noexcept(noexcept(_STD end(_Cont))) -> decltype(_STD end(_Cont)) { return _STD end(_Cont); } @@ -2084,8 +2114,8 @@ _NODISCARD constexpr ptrdiff_t ssize(const _Ty (&)[_Size]) noexcept { #endif // _HAS_CXX20 _EXPORT_STD template -_NODISCARD_EMPTY_NON_MEMBER constexpr auto empty(const _Container& _Cont) noexcept( - noexcept(_Cont.empty())) /* strengthened */ +_NODISCARD_EMPTY_NON_MEMBER constexpr auto empty(const _Container& _Cont) + noexcept(noexcept(_Cont.empty())) /* strengthened */ -> decltype(_Cont.empty()) { return _Cont.empty(); } @@ -2190,22 +2220,22 @@ public: using value_type = iter_value_t<_Iter>; using difference_type = iter_difference_t<_Iter>; - // clang-format off - basic_const_iterator() requires default_initializable<_Iter> = default; - // clang-format on + basic_const_iterator() + requires default_initializable<_Iter> + = default; constexpr basic_const_iterator(_Iter _Current_) noexcept(is_nothrow_move_constructible_v<_Iter>) // strengthened : _Current(_STD move(_Current_)) {} template _Other> - constexpr basic_const_iterator(basic_const_iterator<_Other> _Current_) noexcept( - is_nothrow_constructible_v<_Iter, _Other>) // strengthened + constexpr basic_const_iterator(basic_const_iterator<_Other> _Current_) + noexcept(is_nothrow_constructible_v<_Iter, _Other>) // strengthened : _Current(_STD move(_Current_._Current)) {} template <_Different_from _Other> requires convertible_to<_Other, _Iter> - constexpr basic_const_iterator(_Other&& _Current_) noexcept( - is_nothrow_constructible_v<_Iter, _Other>) // strengthened + constexpr basic_const_iterator(_Other&& _Current_) + noexcept(is_nothrow_constructible_v<_Iter, _Other>) // strengthened : _Current(_STD forward<_Other>(_Current_)) {} _NODISCARD constexpr const _Iter& base() const& noexcept { @@ -2242,8 +2272,8 @@ public: ++_Current; } - constexpr basic_const_iterator operator++(int) noexcept( - noexcept(++*this) && is_nothrow_copy_constructible_v) // strengthened + constexpr basic_const_iterator operator++(int) + noexcept(noexcept(++*this) && is_nothrow_copy_constructible_v) // strengthened requires forward_iterator<_Iter> { auto _Tmp = *this; @@ -2258,8 +2288,8 @@ public: return *this; } - constexpr basic_const_iterator operator--(int) noexcept( - noexcept(--*this) && is_nothrow_copy_constructible_v) // strengthened + constexpr basic_const_iterator operator--(int) + noexcept(noexcept(--*this) && is_nothrow_copy_constructible_v) // strengthened requires bidirectional_iterator<_Iter> { auto _Tmp = *this; @@ -2267,16 +2297,16 @@ public: return _Tmp; } - constexpr basic_const_iterator& operator+=(const difference_type _Off) noexcept( - noexcept(_Current += _Off)) // strengthened + constexpr basic_const_iterator& operator+=(const difference_type _Off) + noexcept(noexcept(_Current += _Off)) // strengthened requires random_access_iterator<_Iter> { _Current += _Off; return *this; } - constexpr basic_const_iterator& operator-=(const difference_type _Off) noexcept( - noexcept(_Current -= _Off)) // strengthened + constexpr basic_const_iterator& operator-=(const difference_type _Off) + noexcept(noexcept(_Current -= _Off)) // strengthened requires random_access_iterator<_Iter> { _Current -= _Off; @@ -2382,29 +2412,29 @@ public: template <_Not_a_const_iterator _Other> requires random_access_iterator<_Iter> && totally_ordered_with<_Iter, _Other> - _NODISCARD friend constexpr bool operator<(const _Other& _Left, const basic_const_iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left < _Right._Current))) /* strengthened */ { + _NODISCARD friend constexpr bool operator<(const _Other& _Left, const basic_const_iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left < _Right._Current))) /* strengthened */ { return _Left < _Right._Current; } template <_Not_a_const_iterator _Other> requires random_access_iterator<_Iter> && totally_ordered_with<_Iter, _Other> - _NODISCARD friend constexpr bool operator>(const _Other& _Left, const basic_const_iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left > _Right._Current))) /* strengthened */ { + _NODISCARD friend constexpr bool operator>(const _Other& _Left, const basic_const_iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left > _Right._Current))) /* strengthened */ { return _Left > _Right._Current; } template <_Not_a_const_iterator _Other> requires random_access_iterator<_Iter> && totally_ordered_with<_Iter, _Other> - _NODISCARD friend constexpr bool operator<=(const _Other& _Left, const basic_const_iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left <= _Right._Current))) /* strengthened */ { + _NODISCARD friend constexpr bool operator<=(const _Other& _Left, const basic_const_iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left <= _Right._Current))) /* strengthened */ { return _Left <= _Right._Current; } template <_Not_a_const_iterator _Other> requires random_access_iterator<_Iter> && totally_ordered_with<_Iter, _Other> - _NODISCARD friend constexpr bool operator>=(const _Other& _Left, const basic_const_iterator& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left >= _Right._Current))) /* strengthened */ { + _NODISCARD friend constexpr bool operator>=(const _Other& _Left, const basic_const_iterator& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left >= _Right._Current))) /* strengthened */ { return _Left >= _Right._Current; } @@ -2437,13 +2467,13 @@ public: template <_Not_a_const_iterator _Sent> requires sized_sentinel_for<_Sent, _Iter> - _NODISCARD friend constexpr difference_type operator-(const _Sent& _Se, const basic_const_iterator& _It) noexcept( - noexcept(_Se - _It._Current)) /* strengthened */ { + _NODISCARD friend constexpr difference_type operator-(const _Sent& _Se, const basic_const_iterator& _It) + noexcept(noexcept(_Se - _It._Current)) /* strengthened */ { return _Se - _It._Current; } - _NODISCARD friend constexpr _Rvalue_reference iter_move(const basic_const_iterator& _It) noexcept( - noexcept(static_cast<_Rvalue_reference>(_RANGES iter_move(_It._Current)))) { + _NODISCARD friend constexpr _Rvalue_reference iter_move(const basic_const_iterator& _It) + noexcept(noexcept(static_cast<_Rvalue_reference>(_RANGES iter_move(_It._Current)))) { return static_cast<_Rvalue_reference>(_RANGES iter_move(_It._Current)); } }; @@ -2467,14 +2497,14 @@ struct common_type, basic_const_iterator<_Ty2>> { }; _EXPORT_STD template -_NODISCARD constexpr const_iterator<_Iter> make_const_iterator(_Iter _It) noexcept( - is_nothrow_constructible_v, _Iter&>) /* strengthened */ { +_NODISCARD constexpr const_iterator<_Iter> make_const_iterator(_Iter _It) + noexcept(is_nothrow_constructible_v, _Iter&>) /* strengthened */ { return _It; } _EXPORT_STD template -_NODISCARD constexpr const_sentinel<_Sent> make_const_sentinel(_Sent _Se) noexcept( - is_nothrow_constructible_v, _Sent&>) /* strengthened */ { +_NODISCARD constexpr const_sentinel<_Sent> make_const_sentinel(_Sent _Se) + noexcept(is_nothrow_constructible_v, _Sent&>) /* strengthened */ { return _Se; } #endif // _HAS_CXX23 @@ -2671,8 +2701,8 @@ namespace ranges { }; template - _NODISCARD constexpr decltype(auto) _Unwrap_iter(_Iter&& _It) noexcept( - !_Unwrappable_sentinel_for<_Sent, _Iter> || _Has_nothrow_unwrapped<_Iter>) { + _NODISCARD constexpr decltype(auto) _Unwrap_iter(_Iter&& _It) + noexcept(!_Unwrappable_sentinel_for<_Sent, _Iter> || _Has_nothrow_unwrapped<_Iter>) { _STL_INTERNAL_STATIC_ASSERT(sentinel_for, remove_cvref_t<_Iter>>); if constexpr (is_pointer_v>) { return _It + 0; @@ -2684,8 +2714,8 @@ namespace ranges { } template - _NODISCARD constexpr decltype(auto) _Unwrap_sent(_Sent&& _Se) noexcept( - !_Unwrappable_sentinel_for<_Sent, _Iter> || _Has_nothrow_unwrapped<_Sent>) { + _NODISCARD constexpr decltype(auto) _Unwrap_sent(_Sent&& _Se) + noexcept(!_Unwrappable_sentinel_for<_Sent, _Iter> || _Has_nothrow_unwrapped<_Sent>) { _STL_INTERNAL_STATIC_ASSERT(sentinel_for, remove_cvref_t<_Iter>>); if constexpr (is_pointer_v>) { return _Se + 0; @@ -2697,15 +2727,15 @@ namespace ranges { } template - _NODISCARD constexpr decltype(auto) _Unwrap_range_iter(_Iter&& _It) noexcept( - noexcept(_RANGES _Unwrap_iter>(static_cast<_Iter&&>(_It)))) { + _NODISCARD constexpr decltype(auto) _Unwrap_range_iter(_Iter&& _It) + noexcept(noexcept(_RANGES _Unwrap_iter>(static_cast<_Iter&&>(_It)))) { _STL_INTERNAL_STATIC_ASSERT(same_as, iterator_t<_Rng>>); return _RANGES _Unwrap_iter>(static_cast<_Iter&&>(_It)); } template - _NODISCARD constexpr decltype(auto) _Unwrap_range_sent(_Sent&& _Se) noexcept( - noexcept(_RANGES _Unwrap_sent>(static_cast<_Sent&&>(_Se)))) { + _NODISCARD constexpr decltype(auto) _Unwrap_range_sent(_Sent&& _Se) + noexcept(noexcept(_RANGES _Unwrap_sent>(static_cast<_Sent&&>(_Se)))) { _STL_INTERNAL_STATIC_ASSERT(same_as, sentinel_t<_Rng>>); return _RANGES _Unwrap_sent>(static_cast<_Sent&&>(_Se)); } @@ -3511,8 +3541,8 @@ namespace ranges { private: template - _NODISCARD static constexpr iter_difference_t<_It> _Distance_unchecked(_It _First, const _Se _Last) noexcept( - noexcept(++_First != _Last)) { + _NODISCARD static constexpr iter_difference_t<_It> _Distance_unchecked(_It _First, const _Se _Last) + noexcept(noexcept(++_First != _Last)) { _STL_INTERNAL_STATIC_ASSERT(sentinel_for<_Se, _It>); iter_difference_t<_It> _Count = 0; @@ -3926,9 +3956,9 @@ namespace ranges { } public: - // clang-format off - subrange() requires default_initializable<_It> = default; - // clang-format on + subrange() + requires default_initializable<_It> + = default; template <_Convertible_to_non_slicing<_It> _It2> constexpr subrange(_It2 _First_, _Se _Last_) @@ -4072,9 +4102,10 @@ namespace ranges { subrange(_It, _Se, _Make_unsigned_like_t>) -> subrange<_It, _Se, subrange_kind::sized>; template - subrange(_Rng&&) -> subrange, sentinel_t<_Rng>, - (sized_range<_Rng> || sized_sentinel_for, iterator_t<_Rng>>) ? subrange_kind::sized - : subrange_kind::unsized>; + subrange(_Rng&&) + -> subrange, sentinel_t<_Rng>, + (sized_range<_Rng> || sized_sentinel_for, iterator_t<_Rng>>) ? subrange_kind::sized + : subrange_kind::unsized>; template subrange(_Rng&&, _Make_unsigned_like_t>) @@ -4185,8 +4216,8 @@ public: #if _HAS_CXX20 requires (!is_same_v<_Other, _Iter>) && convertible_to #endif // _HAS_CXX20 - _CONSTEXPR17 move_iterator(const move_iterator<_Other>& _Right) noexcept( - is_nothrow_constructible_v<_Iter, const _Other&>) // strengthened + _CONSTEXPR17 move_iterator(const move_iterator<_Other>& _Right) + noexcept(is_nothrow_constructible_v<_Iter, const _Other&>) // strengthened : _Current(_Right.base()) { } @@ -4195,8 +4226,8 @@ public: requires (!is_same_v<_Other, _Iter>) && convertible_to && assignable_from<_Iter&, const _Other&> #endif // _HAS_CXX20 - _CONSTEXPR17 move_iterator& operator=(const move_iterator<_Other>& _Right) noexcept( - is_nothrow_assignable_v<_Iter&, const _Other&>) /* strengthened */ { + _CONSTEXPR17 move_iterator& operator=(const move_iterator<_Other>& _Right) + noexcept(is_nothrow_assignable_v<_Iter&, const _Other&>) /* strengthened */ { _Current = _Right.base(); return *this; } @@ -4237,7 +4268,7 @@ public: } _CONSTEXPR17 auto operator++(int) noexcept(is_nothrow_copy_constructible_v<_Iter> // - && noexcept(++_Current)) /* strengthened */ { + && noexcept(++_Current)) /* strengthened */ { #if _HAS_CXX20 if constexpr (forward_iterator<_Iter>) { #endif // _HAS_CXX20 @@ -4257,20 +4288,20 @@ public: } _CONSTEXPR17 move_iterator operator--(int) noexcept(is_nothrow_copy_constructible_v<_Iter> // - && noexcept(--_Current)) /* strengthened */ { + && noexcept(--_Current)) /* strengthened */ { move_iterator _Tmp = *this; --_Current; return _Tmp; } template - _NODISCARD auto operator==(_Default_sentinel _Sentinel) const noexcept + _NODISCARD auto operator==(_Default_sentinel _Sentinel) const noexcept // -> decltype(_STD declval() == _Sentinel) { return _Current == _Sentinel; } template - _NODISCARD auto operator!=(_Default_sentinel _Sentinel) const noexcept + _NODISCARD auto operator!=(_Default_sentinel _Sentinel) const noexcept // -> decltype(_STD declval() != _Sentinel) { return _Current != _Sentinel; } @@ -4280,8 +4311,8 @@ public: return move_iterator(_Current + _Off); } - _CONSTEXPR17 move_iterator& operator+=(const difference_type _Off) noexcept( - noexcept(_Current += _Off)) /* strengthened */ { + _CONSTEXPR17 move_iterator& operator+=(const difference_type _Off) + noexcept(noexcept(_Current += _Off)) /* strengthened */ { _Current += _Off; return *this; } @@ -4291,8 +4322,8 @@ public: return move_iterator(_Current - _Off); } - _CONSTEXPR17 move_iterator& operator-=(const difference_type _Off) noexcept( - noexcept(_Current -= _Off)) /* strengthened */ { + _CONSTEXPR17 move_iterator& operator-=(const difference_type _Off) + noexcept(noexcept(_Current -= _Off)) /* strengthened */ { _Current -= _Off; return *this; } @@ -4309,9 +4340,8 @@ public: #if _HAS_CXX20 template _Sent> - _NODISCARD friend constexpr bool - operator==(const move_iterator& _Left, const move_sentinel<_Sent>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left._Current == _Right._Get_last()))) /* strengthened */ { + _NODISCARD friend constexpr bool operator==(const move_iterator& _Left, const move_sentinel<_Sent>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left._Current == _Right._Get_last()))) /* strengthened */ { return _Left._Current == _Right._Get_last(); } @@ -4327,14 +4357,14 @@ public: return _Left._Current - _Right._Get_last(); } - _NODISCARD friend constexpr reference iter_move(const move_iterator& _It) noexcept( - noexcept(_RANGES iter_move(_It._Current))) { + _NODISCARD friend constexpr reference iter_move(const move_iterator& _It) + noexcept(noexcept(_RANGES iter_move(_It._Current))) { return _RANGES iter_move(_It._Current); } template _Iter2> - friend constexpr void iter_swap(const move_iterator& _Left, const move_iterator<_Iter2>& _Right) noexcept( - noexcept(_RANGES iter_swap(_Left._Current, _Right.base()))) { + friend constexpr void iter_swap(const move_iterator& _Left, const move_iterator<_Iter2>& _Right) + noexcept(noexcept(_RANGES iter_swap(_Left._Current, _Right.base()))) { _RANGES iter_swap(_Left._Current, _Right.base()); } #endif // _HAS_CXX20 @@ -4376,8 +4406,8 @@ public: _Current._Seek_to(_It._Get_current()); } template , int> = 0> - constexpr void _Seek_to(move_iterator<_Src>&& _It) noexcept( - noexcept(_Current._Seek_to(_STD move(_It)._Get_current()))) { + constexpr void _Seek_to(move_iterator<_Src>&& _It) + noexcept(noexcept(_Current._Seek_to(_STD move(_It)._Get_current()))) { _Current._Seek_to(_STD move(_It)._Get_current()); } @@ -4390,9 +4420,8 @@ public: }; _EXPORT_STD template -_NODISCARD _CONSTEXPR17 bool - operator==(const move_iterator<_Iter1>& _Left, const move_iterator<_Iter2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left.base() == _Right.base()))) /* strengthened */ +_NODISCARD _CONSTEXPR17 bool operator==(const move_iterator<_Iter1>& _Left, const move_iterator<_Iter2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left.base() == _Right.base()))) /* strengthened */ #if _HAS_CXX20 requires requires { { _Left.base() == _Right.base() } -> _Implicitly_convertible_to; @@ -4404,16 +4433,15 @@ _NODISCARD _CONSTEXPR17 bool #if !_HAS_CXX20 template -_NODISCARD _CONSTEXPR17 bool operator!=(const move_iterator<_Iter1>& _Left, - const move_iterator<_Iter2>& _Right) noexcept(noexcept(_Left == _Right)) /* strengthened */ { +_NODISCARD _CONSTEXPR17 bool operator!=(const move_iterator<_Iter1>& _Left, const move_iterator<_Iter2>& _Right) + noexcept(noexcept(_Left == _Right)) /* strengthened */ { return !(_Left == _Right); } #endif // !_HAS_CXX20 _EXPORT_STD template -_NODISCARD _CONSTEXPR17 bool - operator<(const move_iterator<_Iter1>& _Left, const move_iterator<_Iter2>& _Right) noexcept( - noexcept(_STD _Fake_copy_init(_Left.base() < _Right.base()))) /* strengthened */ +_NODISCARD _CONSTEXPR17 bool operator<(const move_iterator<_Iter1>& _Left, const move_iterator<_Iter2>& _Right) + noexcept(noexcept(_STD _Fake_copy_init(_Left.base() < _Right.base()))) /* strengthened */ #if _HAS_CXX20 requires requires { { _Left.base() < _Right.base() } -> _Implicitly_convertible_to; @@ -4424,8 +4452,8 @@ _NODISCARD _CONSTEXPR17 bool } _EXPORT_STD template -_NODISCARD _CONSTEXPR17 bool operator>(const move_iterator<_Iter1>& _Left, - const move_iterator<_Iter2>& _Right) noexcept(noexcept(_Right < _Left)) /* strengthened */ +_NODISCARD _CONSTEXPR17 bool operator>(const move_iterator<_Iter1>& _Left, const move_iterator<_Iter2>& _Right) + noexcept(noexcept(_Right < _Left)) /* strengthened */ #if _HAS_CXX20 requires requires { _Right < _Left; } #endif // _HAS_CXX20 @@ -4434,8 +4462,8 @@ _NODISCARD _CONSTEXPR17 bool operator>(const move_iterator<_Iter1>& _Left, } _EXPORT_STD template -_NODISCARD _CONSTEXPR17 bool operator<=(const move_iterator<_Iter1>& _Left, - const move_iterator<_Iter2>& _Right) noexcept(noexcept(_Right < _Left)) /* strengthened */ +_NODISCARD _CONSTEXPR17 bool operator<=(const move_iterator<_Iter1>& _Left, const move_iterator<_Iter2>& _Right) + noexcept(noexcept(_Right < _Left)) /* strengthened */ #if _HAS_CXX20 requires requires { _Right < _Left; } #endif // _HAS_CXX20 @@ -4444,8 +4472,8 @@ _NODISCARD _CONSTEXPR17 bool operator<=(const move_iterator<_Iter1>& _Left, } _EXPORT_STD template -_NODISCARD _CONSTEXPR17 bool operator>=(const move_iterator<_Iter1>& _Left, - const move_iterator<_Iter2>& _Right) noexcept(noexcept(_Left < _Right)) /* strengthened */ +_NODISCARD _CONSTEXPR17 bool operator>=(const move_iterator<_Iter1>& _Left, const move_iterator<_Iter2>& _Right) + noexcept(noexcept(_Left < _Right)) /* strengthened */ #if _HAS_CXX20 requires requires { _Left < _Right; } #endif // _HAS_CXX20 @@ -4462,16 +4490,16 @@ _NODISCARD constexpr compare_three_way_result_t<_Iter1, _Iter2> operator<=>(cons #endif // _HAS_CXX20 _EXPORT_STD template -_NODISCARD _CONSTEXPR17 auto operator-(const move_iterator<_Iter1>& _Left, - const move_iterator<_Iter2>& _Right) noexcept(noexcept(_Left.base() - _Right.base())) /* strengthened */ +_NODISCARD _CONSTEXPR17 auto operator-(const move_iterator<_Iter1>& _Left, const move_iterator<_Iter2>& _Right) + noexcept(noexcept(_Left.base() - _Right.base())) /* strengthened */ -> decltype(_Left.base() - _Right.base()) { return _Left.base() - _Right.base(); } _EXPORT_STD template -_NODISCARD _CONSTEXPR17 move_iterator<_Iter> - operator+(typename move_iterator<_Iter>::difference_type _Off, const move_iterator<_Iter>& _Right) noexcept( - noexcept(move_iterator<_Iter>(_Right.base() + _Off))) /* strengthened */ +_NODISCARD _CONSTEXPR17 move_iterator<_Iter> operator+( + typename move_iterator<_Iter>::difference_type _Off, const move_iterator<_Iter>& _Right) + noexcept(noexcept(move_iterator<_Iter>(_Right.base() + _Off))) /* strengthened */ #if _HAS_CXX20 requires requires { { _Right.base() + _Off } -> same_as<_Iter>; @@ -4482,8 +4510,8 @@ _NODISCARD _CONSTEXPR17 move_iterator<_Iter> } _EXPORT_STD template -_NODISCARD _CONSTEXPR17 move_iterator<_Iter> make_move_iterator(_Iter _It) noexcept( - is_nothrow_move_constructible_v<_Iter>) /* strengthened */ { +_NODISCARD _CONSTEXPR17 move_iterator<_Iter> make_move_iterator(_Iter _It) + noexcept(is_nothrow_move_constructible_v<_Iter>) /* strengthened */ { return move_iterator<_Iter>(_STD move(_It)); } @@ -4656,9 +4684,9 @@ _OutCtgIt _Copy_memmove(_CtgIt _First, _CtgIt _Last, _OutCtgIt _Dest) { const auto _Count = static_cast(_Last_ch - _First_ch); _CSTD memmove(_Dest_ch, _First_ch, _Count); if constexpr (is_pointer_v<_OutCtgIt>) { - return reinterpret_cast<_OutCtgIt>(_Dest_ch + _Count); + return reinterpret_cast<_OutCtgIt>(_Dest_ch + _Count); // lgtm [cpp/incorrect-string-type-conversion] } else { - return _Dest + (_LastPtr - _FirstPtr); + return _Dest + static_cast<_Iter_diff_t<_OutCtgIt>>(_LastPtr - _FirstPtr); } } @@ -4756,8 +4784,8 @@ _CONSTEXPR20 _OutIt copy(_InIt _First, _InIt _Last, _OutIt _Dest) { // copy [_Fi _STD _Adl_verify_range(_First, _Last); const auto _UFirst = _STD _Get_unwrapped(_First); const auto _ULast = _STD _Get_unwrapped(_Last); - const auto _UDest = _STD _Get_unwrapped_n(_Dest, _STD _Idl_distance<_InIt>(_UFirst, _ULast)); - _STD _Seek_wrapped(_Dest, _STD _Copy_unchecked(_UFirst, _ULast, _UDest)); + auto _UDest = _STD _Get_unwrapped_n(_STD move(_Dest), _STD _Idl_distance<_InIt>(_UFirst, _ULast)); + _STD _Seek_wrapped(_Dest, _STD _Copy_unchecked(_UFirst, _ULast, _STD move(_UDest))); return _Dest; } @@ -4983,7 +5011,7 @@ _CtgIt2 _Copy_backward_memmove(_CtgIt1 _First, _CtgIt1 _Last, _CtgIt2 _Dest) { if constexpr (is_pointer_v<_CtgIt2>) { return static_cast<_CtgIt2>(_Result); } else { - return _Dest - (_LastPtr - _FirstPtr); + return _Dest - static_cast<_Iter_diff_t<_CtgIt2>>(_LastPtr - _FirstPtr); } } @@ -5377,6 +5405,11 @@ template constexpr bool _Equal_memcmp_is_safe = _Equal_memcmp_is_safe_helper, remove_const_t<_Iter2>, remove_const_t<_Pr>>; +// Can we activate the vector algorithms for std::search? +template +constexpr bool _Vector_alg_in_search_is_safe = _Equal_memcmp_is_safe<_It1, _It2, _Pr> // can search bitwise + && sizeof(_Iter_value_t<_It1>) <= 2; // pcmpestri compatible element size + template _NODISCARD int _Memcmp_count(_CtgIt1 _First1, _CtgIt2 _First2, const size_t _Count) { _STL_INTERNAL_STATIC_ASSERT(sizeof(_Iter_value_t<_CtgIt1>) == sizeof(_Iter_value_t<_CtgIt2>)); @@ -6009,17 +6042,27 @@ _NODISCARD _CONSTEXPR20 _InIt _Find_unchecked(_InIt _First, const _InIt _Last, c return _First + (_Result - _First_ptr); } #else // ^^^ _USE_STD_VECTOR_ALGORITHMS / !_USE_STD_VECTOR_ALGORITHMS vvv - if constexpr (sizeof(_Iter_value_t<_InIt>) == 1) { + if constexpr (sizeof(_Iter_value_t<_InIt>) <= 2) { const auto _First_ptr = _STD _To_address(_First); - const auto _Result = static_cast>*>( - _CSTD memchr(_First_ptr, static_cast(_Val), static_cast(_Last - _First))); + const auto _Count = static_cast(_Last - _First); + + using _Ptr_t = remove_reference_t<_Iter_ref_t<_InIt>>*; + _Ptr_t _Result; + + if constexpr (sizeof(_Iter_value_t<_InIt>) == 1) { + _Result = static_cast<_Ptr_t>(_CSTD memchr(_First_ptr, static_cast(_Val), _Count)); + } else { + _STL_INTERNAL_STATIC_ASSERT(sizeof(_Iter_value_t<_InIt>) == 2); + _Result = reinterpret_cast<_Ptr_t>(const_cast(_CSTD wmemchr( + reinterpret_cast(_First_ptr), static_cast(_Val), _Count))); + } + if constexpr (is_pointer_v<_InIt>) { return _Result ? _Result : _Last; } else { return _Result ? _First + (_Result - _First_ptr) : _Last; } } - // TRANSITION, DevCom-1614562: not trying wmemchr #endif // ^^^ !_USE_STD_VECTOR_ALGORITHMS ^^^ } } @@ -6062,14 +6105,12 @@ namespace ranges { template _Se, class _Ty, class _Pj = identity> requires indirect_binary_predicate, const _Ty*> _NODISCARD constexpr _It _Find_unchecked(_It _First, const _Se _Last, const _Ty& _Val, _Pj _Proj = {}) { - // TRANSITION, DevCom-1614562: not trying wmemchr - // Only single-byte elements are suitable for unsized optimization - constexpr bool _Single_byte_elements = sizeof(_Iter_value_t<_It>) == 1; - constexpr bool _Is_sized = sized_sentinel_for<_Se, _It>; + constexpr bool _Elements_are_1_or_2_bytes = sizeof(_Iter_value_t<_It>) <= 2; + constexpr bool _Is_sized = sized_sentinel_for<_Se, _It>; if constexpr (_Vector_alg_in_find_is_safe<_It, _Ty> - && (_Single_byte_elements ? _Is_sized || same_as<_Se, unreachable_sentinel_t> - : _Is_sized && _USE_STD_VECTOR_ALGORITHMS) + && (_Elements_are_1_or_2_bytes ? _Is_sized || same_as<_Se, unreachable_sentinel_t> + : _Is_sized && _USE_STD_VECTOR_ALGORITHMS) && same_as<_Pj, identity>) { if (!_STD is_constant_evaluated()) { if (!_STD _Could_compare_equal_to_value_type<_It>(_Val)) { @@ -6087,13 +6128,13 @@ namespace ranges { _Ptr_t _Result; #if _USE_STD_VECTOR_ALGORITHMS if constexpr (_Is_sized) { - // When _Is_sized && _Single_byte_elements, prefer this over memchr() for performance + // When _Is_sized && _Elements_are_1_or_2_bytes, prefer this over memchr()/wmemchr() for performance const auto _Last_ptr = _First_ptr + (_Last - _First); _Result = _STD _Find_vectorized(_First_ptr, _Last_ptr, _Val); } else #endif // ^^^ _USE_STD_VECTOR_ALGORITHMS ^^^ { - _STL_INTERNAL_STATIC_ASSERT(_Single_byte_elements); + _STL_INTERNAL_STATIC_ASSERT(_Elements_are_1_or_2_bytes); size_t _Count; if constexpr (_Is_sized) { _Count = static_cast(_Last - _First); @@ -6101,7 +6142,14 @@ namespace ranges { _Count = SIZE_MAX; } - _Result = static_cast<_Ptr_t>(_CSTD memchr(_First_ptr, static_cast(_Val), _Count)); + if constexpr (sizeof(_Iter_value_t<_It>) == 1) { + _Result = + static_cast<_Ptr_t>(_CSTD memchr(_First_ptr, static_cast(_Val), _Count)); + } else { + _STL_INTERNAL_STATIC_ASSERT(sizeof(_Iter_value_t<_It>) == 2); + _Result = reinterpret_cast<_Ptr_t>(const_cast(_CSTD wmemchr( + reinterpret_cast(_First_ptr), static_cast(_Val), _Count))); + } if constexpr (_Is_sized) { if (_Result == nullptr) { @@ -6739,6 +6787,41 @@ namespace ranges { _STL_INTERNAL_CHECK(_RANGES distance(_First1, _Last1) == _Count1); _STL_INTERNAL_CHECK(_RANGES distance(_First2, _Last2) == _Count2); +#if _USE_STD_VECTOR_ALGORITHMS + if constexpr (_Vector_alg_in_search_is_safe<_It1, _It2, _Pr> && is_same_v<_Pj1, identity> + && is_same_v<_Pj2, identity>) { + if (!_STD is_constant_evaluated()) { + const auto _Ptr1 = _STD to_address(_First1); + const auto _Ptr2 = _STD to_address(_First2); + remove_const_t _Ptr_last1; + + if constexpr (is_same_v<_It1, _Se1>) { + _Ptr_last1 = _STD to_address(_Last1); + } else { + _Ptr_last1 = _Ptr1 + _Count1; + } + + const auto _Ptr_res1 = + _STD _Search_vectorized(_Ptr1, _Ptr_last1, _Ptr2, static_cast(_Count2)); + + if constexpr (is_pointer_v<_It1>) { + if (_Ptr_res1 != _Ptr_last1) { + return {_Ptr_res1, _Ptr_res1 + _Count2}; + } else { + return {_Ptr_res1, _Ptr_res1}; + } + } else { + _First1 += _Ptr_res1 - _Ptr1; + if (_First1 != _Last1) { + return {_First1, _First1 + static_cast>(_Count2)}; + } else { + return {_First1, _First1}; + } + } + } + } +#endif // _USE_STD_VECTOR_ALGORITHMS + for (; _Count1 >= _Count2; ++_First1, (void) --_Count1) { auto _Match_and_mid1 = _RANGES _Equal_rev_pred(_First1, _First2, _Last2, _Pred, _Proj1, _Proj2); if (_Match_and_mid1.first) { @@ -6801,6 +6884,24 @@ constexpr bool _Is_min_max_optimization_safe = // Activate the vector algorithms #endif // _HAS_CXX20 is_same<_Pr, less<>>, is_same<_Pr, less<_Elem>>>>; // predicate is less +// Unlike the position-based vectorized implementation, the value-based vectorized implementation +// does not always produce the expected results for floating-point types. +// +// Efficient vectorization needs to find the vertical minmax first, and then the horizontal one. +// This alters the order of comparison: index zero element is first compared against +// vector size equal index element and only in the end against index one element. +// With equivalent but distinguishable +0.0 and -0.0 values, the altered comparison order +// will not produce the expected result in some cases (will return +0.0 instead of -0.0 or the reverse). +// +// The result is still acceptable for /fp:fast when +0.0 / -0.0 are not expected to be properly distinguished, +// and the compiler itself takes advantage of it. +template > +constexpr bool _Is_min_max_value_optimization_safe = // Activate the vector algorithms for ranges::min/max? +#ifndef _M_FP_FAST + !is_floating_point_v<_Elem> && +#endif // ^^^ !defined(_M_FP_FAST) ^^^ + _Is_min_max_optimization_safe<_Iter, _Pr, _Elem>; + template constexpr _FwdIt _Max_element_unchecked(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find largest element #if _USE_STD_VECTOR_ALGORITHMS @@ -6931,7 +7032,7 @@ _NODISCARD constexpr _Ty(max)(initializer_list<_Ty> _Ilist, _Pr _Pred) { _STL_ASSERT( _Ilist.size() != 0, "An initializer_list passed to std::max must not be empty. (N4971 [alg.min.max]/13)"); #if _USE_STD_VECTOR_ALGORITHMS - if constexpr (_Is_min_max_optimization_safe) { + if constexpr (_Is_min_max_value_optimization_safe) { if (!_Is_constant_evaluated()) { return static_cast<_Ty>(_STD _Max_vectorized(_Ilist.begin(), _Ilist.end())); } @@ -6977,7 +7078,7 @@ namespace ranges { _STL_ASSERT(_First != _Last, "An initializer_list passed to std::ranges::max must not be empty. (N4971 [alg.min.max]/13)"); #if _USE_STD_VECTOR_ALGORITHMS - if constexpr (is_same_v<_Pj, identity> && _Is_min_max_optimization_safe) { + if constexpr (is_same_v<_Pj, identity> && _Is_min_max_value_optimization_safe) { if (!_STD is_constant_evaluated()) { return static_cast<_Ty>(_STD _Max_vectorized(_First, _Last)); } @@ -6996,7 +7097,7 @@ namespace ranges { _STL_ASSERT( _UFirst != _ULast, "A range passed to std::ranges::max must not be empty. (N4971 [alg.min.max]/13)"); #if _USE_STD_VECTOR_ALGORITHMS - if constexpr (is_same_v<_Pj, identity> && _Is_min_max_optimization_safe + if constexpr (is_same_v<_Pj, identity> && _Is_min_max_value_optimization_safe && sized_sentinel_for) { if (!_STD is_constant_evaluated()) { const auto _First_ptr = _STD to_address(_UFirst); @@ -7155,7 +7256,7 @@ _NODISCARD constexpr _Ty(min)(initializer_list<_Ty> _Ilist, _Pr _Pred) { _STL_ASSERT( _Ilist.size() != 0, "An initializer_list passed to std::min must not be empty. (N4971 [alg.min.max]/5)"); #if _USE_STD_VECTOR_ALGORITHMS - if constexpr (_Is_min_max_optimization_safe) { + if constexpr (_Is_min_max_value_optimization_safe) { if (!_Is_constant_evaluated()) { return static_cast<_Ty>(_STD _Min_vectorized(_Ilist.begin(), _Ilist.end())); } @@ -7195,7 +7296,7 @@ namespace ranges { _STL_ASSERT(_First != _Last, "An initializer_list passed to std::ranges::min must not be empty. (N4971 [alg.min.max]/5)"); #if _USE_STD_VECTOR_ALGORITHMS - if constexpr (is_same_v<_Pj, identity> && _Is_min_max_optimization_safe) { + if constexpr (is_same_v<_Pj, identity> && _Is_min_max_value_optimization_safe) { if (!_STD is_constant_evaluated()) { return static_cast<_Ty>(_STD _Min_vectorized(_First, _Last)); } @@ -7214,7 +7315,7 @@ namespace ranges { _STL_ASSERT( _UFirst != _ULast, "A range passed to std::ranges::min must not be empty. (N4971 [alg.min.max]/5)"); #if _USE_STD_VECTOR_ALGORITHMS - if constexpr (is_same_v<_Pj, identity> && _Is_min_max_optimization_safe + if constexpr (is_same_v<_Pj, identity> && _Is_min_max_value_optimization_safe && sized_sentinel_for) { if (!_STD is_constant_evaluated()) { const auto _First_ptr = _STD to_address(_UFirst); diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 5d37ddb35ec..bba7a4bf030 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -395,7 +395,10 @@ // P2833R2 Freestanding Library: inout expected span // (except for __cpp_lib_span which also covers C++26 span::at) // P2836R1 basic_const_iterator Should Follow Its Underlying Type's Convertibility +// P3107R5 Permit An Efficient Implementation Of // P3142R0 Printing Blank Lines With println() +// P3235R3 std::print More Types Faster With Less Memory +// (partial implementation; see GH-4924) // _HAS_CXX23 and _SILENCE_ALL_CXX23_DEPRECATION_WARNINGS control: // P1413R3 Deprecate aligned_storage And aligned_union @@ -885,7 +888,7 @@ #define _CPPLIB_VER 650 #define _MSVC_STL_VERSION 143 -#define _MSVC_STL_UPDATE 202408L +#define _MSVC_STL_UPDATE 202409L #ifndef _ALLOW_COMPILER_AND_STL_VERSION_MISMATCH #if defined(__CUDACC__) && defined(__CUDACC_VER_MAJOR__) @@ -895,8 +898,8 @@ _EMIT_STL_ERROR(STL1002, "Unexpected compiler version, expected CUDA 12.4 or new #elif defined(__EDG__) // not attempting to detect __EDG_VERSION__ being less than expected #elif defined(__clang__) -#if __clang_major__ < 17 -_EMIT_STL_ERROR(STL1000, "Unexpected compiler version, expected Clang 17.0.0 or newer."); +#if __clang_major__ < 18 +_EMIT_STL_ERROR(STL1000, "Unexpected compiler version, expected Clang 18.0.0 or newer."); #endif // ^^^ old Clang ^^^ #elif defined(_MSC_VER) #if _MSC_VER < 1941 // Coarse-grained, not inspecting _MSC_FULL_VER @@ -1769,7 +1772,7 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect #define __cpp_lib_mdspan 202207L #define __cpp_lib_move_only_function 202110L #define __cpp_lib_out_ptr 202311L -#define __cpp_lib_print 202207L +#define __cpp_lib_print 202406L #define __cpp_lib_ranges_as_const 202311L #define __cpp_lib_ranges_as_rvalue 202207L #define __cpp_lib_ranges_cartesian_product 202207L diff --git a/stl/src/StlLCMapStringA.cpp b/stl/src/StlLCMapStringA.cpp index 79cb518dc14..62305d9108f 100644 --- a/stl/src/StlLCMapStringA.cpp +++ b/stl/src/StlLCMapStringA.cpp @@ -82,10 +82,12 @@ extern "C" _CRTIMP2 int __cdecl __crtLCMapStringA(_In_opt_z_ LPCWSTR LocaleName, return retval; } + const auto wide_dest = reinterpret_cast(lpDestStr); // lgtm [cpp/incorrect-string-type-conversion] + // do string mapping if (0 - == LCMapStringEx(LocaleName, dwMapFlags, inwbuffer.get(), inbuff_size, - reinterpret_cast(lpDestStr), cchDest, nullptr, nullptr, 0)) { + == LCMapStringEx( + LocaleName, dwMapFlags, inwbuffer.get(), inbuff_size, wide_dest, cchDest, nullptr, nullptr, 0)) { return retval; } } diff --git a/stl/src/filesystem.cpp b/stl/src/filesystem.cpp index 5fdde72e6b7..4ea23edc592 100644 --- a/stl/src/filesystem.cpp +++ b/stl/src/filesystem.cpp @@ -142,7 +142,8 @@ namespace { BY_HANDLE_FILE_INFORMATION _Info; if (GetFileInformationByHandle(_Handle, &_Info)) { _Id->VolumeSerialNumber = _Info.dwVolumeSerialNumber; - _CSTD memcpy(&_Id->FileId.Identifier[0], &_Info.nFileIndexHigh, 8); // copying from 2 consecutive DWORDs + _CSTD memcpy(&_Id->FileId.Identifier[0], &_Info.nFileIndexHigh, 4); + _CSTD memcpy(&_Id->FileId.Identifier[4], &_Info.nFileIndexLow, 4); _CSTD memset(&_Id->FileId.Identifier[8], 0, 8); return __std_win_error::_Success; } diff --git a/stl/src/locale0.cpp b/stl/src/locale0.cpp index e25897acc9a..74ef152f0c3 100644 --- a/stl/src/locale0.cpp +++ b/stl/src/locale0.cpp @@ -30,7 +30,6 @@ struct _Fac_node { // node for lazy facet recording delete _Facptr->_Decref(); } -#ifdef _DEBUG void* operator new(size_t _Size) { // replace operator new void* _Ptr = _malloc_dbg(_Size > 0 ? _Size : 1, _CRT_BLOCK, __FILE__, __LINE__); if (!_Ptr) { @@ -43,7 +42,6 @@ struct _Fac_node { // node for lazy facet recording void operator delete(void* _Ptr) noexcept { // replace operator delete _free_dbg(_Ptr, _CRT_BLOCK); } -#endif // defined(_DEBUG) _Fac_node* _Next; _Facet_base* _Facptr; diff --git a/stl/src/print.cpp b/stl/src/print.cpp index fcd7d263e37..61efeec768e 100644 --- a/stl/src/print.cpp +++ b/stl/src/print.cpp @@ -57,27 +57,64 @@ extern "C" { namespace { class _Allocated_string { public: - _Allocated_string() = default; + _Allocated_string() noexcept { + _Buffer[0] = L'\0'; // Activate _Buffer + } - explicit _Allocated_string(__crt_unique_heap_ptr&& _Other_str, const size_t _Other_capacity) noexcept - : _Str(_STD move(_Other_str)), _Str_capacity(_Other_capacity) {} + ~_Allocated_string() { + if (_Using_heap()) { + _Str.~_Heap_string(); + } + } - [[nodiscard]] wchar_t* _Data() const noexcept { - return _Str.get(); + [[nodiscard]] wchar_t* _Data() noexcept { + return _Using_heap() ? _Str.get() : _Buffer; } [[nodiscard]] size_t _Capacity() const noexcept { return _Str_capacity; } - void _Reset() noexcept { - _Str.release(); - _Str_capacity = 0; + [[nodiscard]] bool _Grow(const size_t _Capacity) noexcept { + if (_Capacity <= _Str_capacity) { + return true; + } + + if (_Using_heap()) { + _Str.~_Heap_string(); + // We must not throw until restoring the invariant that: + // (_Str_capacity == _Buffer_size && _Buffer is active) || + // (_Str_capacity > _Buffer_size && _Str is active) + } + + ::new (&_Str) _Heap_string(_malloc_crt_t(wchar_t, _Capacity)); // Activate _Str + + if (!_Str) [[unlikely]] { + _Str_capacity = _Buffer_size; + _Buffer[0] = L'\0'; // Activate _Buffer + return false; + } + + _Str_capacity = _Capacity; + return true; } private: - __crt_unique_heap_ptr _Str; - size_t _Str_capacity = 0; + using _Heap_string = __crt_unique_heap_ptr; + + // Allows small formatted strings, such as those from _Print_to_unicode_console_it, to not allocate any extra + // internal transcoding buffer + static constexpr size_t _Buffer_size = 2048; + + [[nodiscard]] bool _Using_heap() const noexcept { + return _Str_capacity > _Buffer_size; + } + + size_t _Str_capacity = _Buffer_size; + union { + wchar_t _Buffer[_Buffer_size]; + _Heap_string _Str; + }; }; template @@ -187,15 +224,9 @@ namespace { return static_cast<__std_win_error>(GetLastError()); } - if (static_cast(_Num_chars_required) > _Dst_str._Capacity()) { - _Dst_str._Reset(); - - __crt_unique_heap_ptr _Wide_str{_malloc_crt_t(wchar_t, _Num_chars_required)}; - if (!_Wide_str) [[unlikely]] { - return __std_win_error::_Not_enough_memory; - } - - _Dst_str = _Allocated_string{_STD move(_Wide_str), static_cast(_Num_chars_required)}; + const bool _Has_space = _Dst_str._Grow(static_cast(_Num_chars_required)); + if (!_Has_space) [[unlikely]] { + return __std_win_error::_Not_enough_memory; } const int32_t _Conversion_result = MultiByteToWideChar(CP_UTF8, 0, _Src_str._Data(), diff --git a/stl/src/stacktrace.cpp b/stl/src/stacktrace.cpp index 3ba9652b515..3a67e4c9573 100644 --- a/stl/src/stacktrace.cpp +++ b/stl/src/stacktrace.cpp @@ -4,12 +4,10 @@ #include #include -// clang-format off -#include // should be before any header that includes +#include #include #include #include -// clang-format on // The below function pointer types must be in sync with diff --git a/stl/src/vector_algorithms.cpp b/stl/src/vector_algorithms.cpp index 44cca169203..657feab5478 100644 --- a/stl/src/vector_algorithms.cpp +++ b/stl/src/vector_algorithms.cpp @@ -9,6 +9,7 @@ #include <__msvc_minmax.hpp> #include #include +#include #include #ifndef _M_ARM64EC @@ -1415,8 +1416,8 @@ namespace { template static __m128 _H_func(const __m128 _Cur, _Fn _Funct) noexcept { __m128 _H_min_val = _Cur; - _H_min_val = _Funct(_H_min_val, _mm_shuffle_ps(_H_min_val, _H_min_val, _MM_SHUFFLE(1, 0, 3, 2))); - _H_min_val = _Funct(_H_min_val, _mm_shuffle_ps(_H_min_val, _H_min_val, _MM_SHUFFLE(2, 3, 0, 1))); + _H_min_val = _Funct(_mm_shuffle_ps(_H_min_val, _H_min_val, _MM_SHUFFLE(2, 3, 0, 1)), _H_min_val); + _H_min_val = _Funct(_mm_shuffle_ps(_H_min_val, _H_min_val, _MM_SHUFFLE(1, 0, 3, 2)), _H_min_val); return _H_min_val; } @@ -1457,11 +1458,11 @@ namespace { } static __m128 _Min(const __m128 _First, const __m128 _Second, __m128 = _mm_undefined_ps()) noexcept { - return _mm_min_ps(_First, _Second); + return _mm_min_ps(_Second, _First); } static __m128 _Max(const __m128 _First, const __m128 _Second, __m128 = _mm_undefined_ps()) noexcept { - return _mm_max_ps(_First, _Second); + return _mm_max_ps(_Second, _First); } static __m128i _Mask_cast(const __m128 _Mask) noexcept { @@ -1485,9 +1486,9 @@ namespace { template static __m256 _H_func(const __m256 _Cur, _Fn _Funct) noexcept { __m256 _H_min_val = _Cur; - _H_min_val = _Funct(_H_min_val, _mm256_permute2f128_ps(_H_min_val, _mm256_undefined_ps(), 0x01)); - _H_min_val = _Funct(_H_min_val, _mm256_shuffle_ps(_H_min_val, _H_min_val, _MM_SHUFFLE(1, 0, 3, 2))); - _H_min_val = _Funct(_H_min_val, _mm256_shuffle_ps(_H_min_val, _H_min_val, _MM_SHUFFLE(2, 3, 0, 1))); + _H_min_val = _Funct(_mm256_shuffle_ps(_H_min_val, _H_min_val, _MM_SHUFFLE(2, 3, 0, 1)), _H_min_val); + _H_min_val = _Funct(_mm256_shuffle_ps(_H_min_val, _H_min_val, _MM_SHUFFLE(1, 0, 3, 2)), _H_min_val); + _H_min_val = _Funct(_mm256_permute2f128_ps(_H_min_val, _mm256_undefined_ps(), 0x01), _H_min_val); return _H_min_val; } @@ -1528,11 +1529,11 @@ namespace { } static __m256 _Min(const __m256 _First, const __m256 _Second, __m256 = _mm256_undefined_ps()) noexcept { - return _mm256_min_ps(_First, _Second); + return _mm256_min_ps(_Second, _First); } static __m256 _Max(const __m256 _First, const __m256 _Second, __m256 = _mm256_undefined_ps()) noexcept { - return _mm256_max_ps(_First, _Second); + return _mm256_max_ps(_Second, _First); } static __m256i _Mask_cast(const __m256 _Mask) noexcept { @@ -1575,7 +1576,7 @@ namespace { template static __m128d _H_func(const __m128d _Cur, _Fn _Funct) noexcept { __m128d _H_min_val = _Cur; - _H_min_val = _Funct(_H_min_val, _mm_shuffle_pd(_H_min_val, _H_min_val, 1)); + _H_min_val = _Funct(_mm_shuffle_pd(_H_min_val, _H_min_val, 1), _H_min_val); return _H_min_val; } @@ -1615,11 +1616,11 @@ namespace { } static __m128d _Min(const __m128d _First, const __m128d _Second, __m128d = _mm_undefined_pd()) noexcept { - return _mm_min_pd(_First, _Second); + return _mm_min_pd(_Second, _First); } static __m128d _Max(const __m128d _First, const __m128d _Second, __m128d = _mm_undefined_pd()) noexcept { - return _mm_max_pd(_First, _Second); + return _mm_max_pd(_Second, _First); } static __m128i _Mask_cast(const __m128d _Mask) noexcept { @@ -1643,8 +1644,8 @@ namespace { template static __m256d _H_func(const __m256d _Cur, _Fn _Funct) noexcept { __m256d _H_min_val = _Cur; - _H_min_val = _Funct(_H_min_val, _mm256_permute4x64_pd(_H_min_val, _MM_SHUFFLE(1, 0, 3, 2))); - _H_min_val = _Funct(_H_min_val, _mm256_shuffle_pd(_H_min_val, _H_min_val, 0b0101)); + _H_min_val = _Funct(_mm256_shuffle_pd(_H_min_val, _H_min_val, 0b0101), _H_min_val); + _H_min_val = _Funct(_mm256_permute4x64_pd(_H_min_val, _MM_SHUFFLE(1, 0, 3, 2)), _H_min_val); return _H_min_val; } @@ -1685,11 +1686,11 @@ namespace { } static __m256d _Min(const __m256d _First, const __m256d _Second, __m256d = _mm256_undefined_pd()) noexcept { - return _mm256_min_pd(_First, _Second); + return _mm256_min_pd(_Second, _First); } static __m256d _Max(const __m256d _First, const __m256d _Second, __m256d = _mm256_undefined_pd()) noexcept { - return _mm256_max_pd(_First, _Second); + return _mm256_max_pd(_Second, _First); } static __m256i _Mask_cast(const __m256d _Mask) noexcept { @@ -2708,8 +2709,8 @@ namespace { }; template - __declspec(noalias) size_t - __stdcall __std_count_trivial_impl(const void* _First, const void* const _Last, const _Ty _Val) noexcept { + __declspec(noalias) size_t __stdcall __std_count_trivial_impl( + const void* _First, const void* const _Last, const _Ty _Val) noexcept { size_t _Result = 0; #ifndef _M_ARM64EC @@ -3260,6 +3261,154 @@ namespace { return _Result; } + + template + const void* __stdcall __std_search_impl( + const void* _First1, const void* const _Last1, const void* const _First2, const size_t _Count2) noexcept { + if (_Count2 == 0) { + return _First1; + } + + if (_Count2 == 1) { + return __std_find_trivial_impl<_Traits>(_First1, _Last1, *static_cast(_First2)); + } + + const size_t _Size_bytes_1 = _Byte_length(_First1, _Last1); + const size_t _Size_bytes_2 = _Count2 * sizeof(_Ty); + + if (_Size_bytes_1 < _Size_bytes_2) { + return _Last1; + } + +#ifndef _M_ARM64EC + if (_Use_sse42() && _Size_bytes_1 >= 16) { + constexpr int _Op = (sizeof(_Ty) == 1 ? _SIDD_UBYTE_OPS : _SIDD_UWORD_OPS) | _SIDD_CMP_EQUAL_ORDERED; + constexpr int _Part_size_el = sizeof(_Ty) == 1 ? 16 : 8; + + if (_Size_bytes_2 <= 16) { + const int _Size_el_2 = static_cast(_Size_bytes_2 / sizeof(_Ty)); + + const int _Max_full_match_pos = _Part_size_el - _Size_el_2; + + alignas(16) uint8_t _Tmp2[16]; + memcpy(_Tmp2, _First2, _Size_bytes_2); + const __m128i _Data2 = _mm_load_si128(reinterpret_cast(_Tmp2)); + + const void* _Stop1 = _First1; + _Advance_bytes(_Stop1, _Size_bytes_1 - 16); + + do { + const __m128i _Data1 = _mm_loadu_si128(static_cast(_First1)); + + if (!_mm_cmpestrc(_Data2, _Size_el_2, _Data1, _Part_size_el, _Op)) { + _Advance_bytes(_First1, 16); // No matches, next. + } else { + const int _Pos = _mm_cmpestri(_Data2, _Size_el_2, _Data1, _Part_size_el, _Op); + _Advance_bytes(_First1, _Pos * sizeof(_Ty)); + if (_Pos <= _Max_full_match_pos) { + // Full match. Return this match. + return _First1; + } + // Partial match. Search again from the match start. Will return it if it is full. + } + } while (_First1 <= _Stop1); + + const size_t _Size_bytes_1_tail = _Byte_length(_First1, _Last1); + if (_Size_bytes_1_tail != 0) { + const int _Size_el_1_tail = static_cast(_Size_bytes_1_tail / sizeof(_Ty)); + + alignas(16) uint8_t _Tmp1[16]; + memcpy(_Tmp1, _First1, _Size_bytes_1_tail); + const __m128i _Data1 = _mm_load_si128(reinterpret_cast(_Tmp1)); + + if (_mm_cmpestrc(_Data2, _Size_el_2, _Data1, _Size_el_1_tail, _Op)) { + const int _Pos = _mm_cmpestri(_Data2, _Size_el_2, _Data1, _Size_el_1_tail, _Op); + _Advance_bytes(_First1, _Pos * sizeof(_Ty)); + // Full match because size is less than 16. Return this match. + return _First1; + } + } + } else { + const __m128i _Data2 = _mm_loadu_si128(reinterpret_cast(_First2)); + const size_t _Max_pos = _Size_bytes_1 - _Size_bytes_2; + + const void* _Stop1 = _First1; + _Advance_bytes(_Stop1, _Max_pos); + + const void* _Tail2 = _First2; + _Advance_bytes(_Tail2, 16); + + do { + const __m128i _Data1 = _mm_loadu_si128(static_cast(_First1)); + if (!_mm_cmpestrc(_Data2, _Part_size_el, _Data1, _Part_size_el, _Op)) { + _Advance_bytes(_First1, 16); // No matches, next. + } else { + const int _Pos = _mm_cmpestri(_Data2, _Part_size_el, _Data1, _Part_size_el, _Op); + // Matched first 16 or less + if (_Pos != 0) { + _Advance_bytes(_First1, _Pos * sizeof(_Ty)); + + if (_First1 > _Stop1) { + break; // Oops, doesn't fit + } + + // Match not from the first byte, check 16 symbols + const __m128i _Match1 = _mm_loadu_si128(static_cast(_First1)); + const __m128i _Cmp = _mm_xor_si128(_Data2, _Match1); + if (!_mm_testz_si128(_Cmp, _Cmp)) { + // Start from the next element + _Advance_bytes(_First1, sizeof(_Ty)); + continue; + } + } + // Matched first 16, check the rest + + const void* _Tail1 = _First1; + _Advance_bytes(_Tail1, 16); + + if (memcmp(_Tail1, _Tail2, _Size_bytes_2 - 16) == 0) { + return _First1; + } + + // Start from the next element + _Advance_bytes(_First1, sizeof(_Ty)); + } + } while (_First1 <= _Stop1); + } + + return _Last1; + } else +#endif // !defined(_M_ARM64EC) + { + const size_t _Max_pos = _Size_bytes_1 - _Size_bytes_2 + sizeof(_Ty); + + auto _Ptr1 = static_cast(_First1); + const auto _Ptr2 = static_cast(_First2); + const void* _Stop1 = _Ptr1; + _Advance_bytes(_Stop1, _Max_pos); + + for (; _Ptr1 != _Stop1; ++_Ptr1) { + if (*_Ptr1 != *_Ptr2) { + continue; + } + + bool _Equal = true; + + for (size_t _Idx = 1; _Idx != _Count2; ++_Idx) { + if (_Ptr1[_Idx] != _Ptr2[_Idx]) { + _Equal = false; + break; + } + } + + if (_Equal) { + return _Ptr1; + } + } + + return _Last1; + } + } } // unnamed namespace extern "C" { @@ -3271,8 +3420,7 @@ const void* __stdcall __std_find_trivial_unsized_1(const void* const _First, con // TRANSITION, ABI: preserved for binary compatibility const void* __stdcall __std_find_trivial_unsized_2(const void* const _First, const uint16_t _Val) noexcept { - // TRANSITION, DevCom-1614562: not trying wmemchr - return __std_find_trivial_unsized_impl(_First, _Val); + return wmemchr(static_cast(_First), static_cast(_Val), SIZE_MAX); } // TRANSITION, ABI: preserved for binary compatibility @@ -3325,23 +3473,23 @@ const void* __stdcall __std_find_last_trivial_8( return __std_find_last_trivial_impl<_Find_traits_8>(_First, _Last, _Val); } -__declspec(noalias) size_t - __stdcall __std_count_trivial_1(const void* const _First, const void* const _Last, const uint8_t _Val) noexcept { +__declspec(noalias) size_t __stdcall __std_count_trivial_1( + const void* const _First, const void* const _Last, const uint8_t _Val) noexcept { return __std_count_trivial_impl<_Count_traits_1>(_First, _Last, _Val); } -__declspec(noalias) size_t - __stdcall __std_count_trivial_2(const void* const _First, const void* const _Last, const uint16_t _Val) noexcept { +__declspec(noalias) size_t __stdcall __std_count_trivial_2( + const void* const _First, const void* const _Last, const uint16_t _Val) noexcept { return __std_count_trivial_impl<_Count_traits_2>(_First, _Last, _Val); } -__declspec(noalias) size_t - __stdcall __std_count_trivial_4(const void* const _First, const void* const _Last, const uint32_t _Val) noexcept { +__declspec(noalias) size_t __stdcall __std_count_trivial_4( + const void* const _First, const void* const _Last, const uint32_t _Val) noexcept { return __std_count_trivial_impl<_Count_traits_4>(_First, _Last, _Val); } -__declspec(noalias) size_t - __stdcall __std_count_trivial_8(const void* const _First, const void* const _Last, const uint64_t _Val) noexcept { +__declspec(noalias) size_t __stdcall __std_count_trivial_8( + const void* const _First, const void* const _Last, const uint64_t _Val) noexcept { return __std_count_trivial_impl<_Count_traits_8>(_First, _Last, _Val); } @@ -3365,23 +3513,33 @@ const void* __stdcall __std_find_first_of_trivial_8( return __std_find_first_of::_Impl_4_8<__std_find_first_of::_Traits_8>(_First1, _Last1, _First2, _Last2); } -__declspec(noalias) size_t - __stdcall __std_mismatch_1(const void* const _First1, const void* const _First2, const size_t _Count) noexcept { +const void* __stdcall __std_search_1( + const void* const _First1, const void* const _Last1, const void* const _First2, const size_t _Count2) noexcept { + return __std_search_impl<_Find_traits_1, uint8_t>(_First1, _Last1, _First2, _Count2); +} + +const void* __stdcall __std_search_2( + const void* const _First1, const void* const _Last1, const void* const _First2, const size_t _Count2) noexcept { + return __std_search_impl<_Find_traits_2, uint16_t>(_First1, _Last1, _First2, _Count2); +} + +__declspec(noalias) size_t __stdcall __std_mismatch_1( + const void* const _First1, const void* const _First2, const size_t _Count) noexcept { return __std_mismatch_impl<_Find_traits_1, uint8_t>(_First1, _First2, _Count); } -__declspec(noalias) size_t - __stdcall __std_mismatch_2(const void* const _First1, const void* const _First2, const size_t _Count) noexcept { +__declspec(noalias) size_t __stdcall __std_mismatch_2( + const void* const _First1, const void* const _First2, const size_t _Count) noexcept { return __std_mismatch_impl<_Find_traits_2, uint16_t>(_First1, _First2, _Count); } -__declspec(noalias) size_t - __stdcall __std_mismatch_4(const void* const _First1, const void* const _First2, const size_t _Count) noexcept { +__declspec(noalias) size_t __stdcall __std_mismatch_4( + const void* const _First1, const void* const _First2, const size_t _Count) noexcept { return __std_mismatch_impl<_Find_traits_4, uint32_t>(_First1, _First2, _Count); } -__declspec(noalias) size_t - __stdcall __std_mismatch_8(const void* const _First1, const void* const _First2, const size_t _Count) noexcept { +__declspec(noalias) size_t __stdcall __std_mismatch_8( + const void* const _First1, const void* const _First2, const size_t _Count) noexcept { return __std_mismatch_impl<_Find_traits_8, uint64_t>(_First1, _First2, _Count); } diff --git a/stl/src/xfvalues.cpp b/stl/src/xfvalues.cpp index d0329ee4860..71f6af41bcd 100644 --- a/stl/src/xfvalues.cpp +++ b/stl/src/xfvalues.cpp @@ -13,10 +13,8 @@ // macros #define NBITS (16 + _FOFF) -#define INIT(w0) \ - { 0, w0 } -#define INIT2(w0, w1) \ - { w1, w0 } +#define INIT(w0) {0, w0} +#define INIT2(w0, w1) {w1, w0} _EXTERN_C_UNLESS_PURE diff --git a/stl/src/xlvalues.cpp b/stl/src/xlvalues.cpp index 7ec133738c2..06d08e1b71b 100644 --- a/stl/src/xlvalues.cpp +++ b/stl/src/xlvalues.cpp @@ -13,10 +13,8 @@ // macros -- 64-bit #define NBITS (48 + _DOFF) -#define INIT(w0) \ - { 0, 0, 0, w0 } -#define INIT2(w0, w1) \ - { w1, 0, 0, w0 } +#define INIT(w0) {0, 0, 0, w0} +#define INIT2(w0, w1) {w1, 0, 0, w0} // static data extern /* const */ _Dconst _LDenorm = {INIT2(0, 1)}; diff --git a/stl/src/xvalues.cpp b/stl/src/xvalues.cpp index 1d9a1fb1e30..83728371fba 100644 --- a/stl/src/xvalues.cpp +++ b/stl/src/xvalues.cpp @@ -14,10 +14,8 @@ // macros #define NBITS (48 + _DOFF) -#define INIT(w0) \ - { 0, 0, 0, w0 } -#define INIT2(w0, w1) \ - { w1, 0, 0, w0 } +#define INIT(w0) {0, 0, 0, w0} +#define INIT2(w0, w1) {w1, 0, 0, w0} // static data extern /* const */ _Dconst _Denorm = {INIT2(0, 1)}; diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index d1c69193af2..1303fc87102 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -34,21 +34,16 @@ std/utilities/format/format.range/format.range.formatter/format.functions.vforma std/utilities/format/format.range/format.range.fmtset/format.functions.format.pass.cpp FAIL std/utilities/format/format.range/format.range.fmtset/format.functions.vformat.pass.cpp FAIL -# LLVM-100498: [libc++][test] alg.find.last tests assume that std::array iterators are pointers -std/algorithms/alg.nonmodifying/alg.find.last/ranges.find_last.pass.cpp FAIL -std/algorithms/alg.nonmodifying/alg.find.last/ranges.find_last_if.pass.cpp FAIL -std/algorithms/alg.nonmodifying/alg.find.last/ranges.find_last_if_not.pass.cpp FAIL - -# LLVM-100502: [libc++][test] Bogus loops in time.cal.ymdlast.nonmembers/comparisons.pass.cpp -# Note: The :1 (ASAN) configuration doesn't run static analysis. -std/time/time.cal/time.cal.ymdlast/time.cal.ymdlast.nonmembers/comparisons.pass.cpp:0 FAIL - -# LLVM-100504: [libc++][test] Fix Clang -Wunused-variable warnings in time.zone.members/to_sys.pass.cpp -std/time/time.zone/time.zone.timezone/time.zone.members/to_sys.pass.cpp:2 FAIL - # LLVM-100506: [libc++][test] Precondition violation in rand.dist.uni.real/param_ctor.pass.cpp std/numerics/rand/rand.dist/rand.dist.uni/rand.dist.uni.real/param_ctor.pass.cpp FAIL +# LLVM-105878: [libc++][test] fp_compare.h includes non-portable <__config> +std/numerics/c.math/cmath.pass.cpp FAIL +std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp FAIL + +# LLVM-105966: [libc++][test] Fix is_always_lock_free test +std/atomics/atomics.lockfree/is_always_lock_free.cpp FAIL + # Non-Standard regex behavior. # "It seems likely that the test is still non-conforming due to how libc++ handles the 'w' character class." std/re/re.traits/lookup_classname.pass.cpp FAIL @@ -85,14 +80,15 @@ std/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp FAIL # Test expects __cpp_lib_chrono to have the old value 201611L for P0505R0; we define the C++20 value 201907L for P1466R3. std/language.support/support.limits/support.limits.general/chrono.version.compile.pass.cpp FAIL -# Test expects __cpp_lib_three_way_comparison to have the old value 201711L for P0768R1; we define the C++20 value 201907L for P1614R2. -std/language.support/support.limits/support.limits.general/compare.version.compile.pass.cpp FAIL - # Tests expect __cpp_lib_ranges to have the old value 201811L for P0896R4; we define the C++20 value 201911L for P1716R3. std/language.support/support.limits/support.limits.general/algorithm.version.compile.pass.cpp FAIL std/language.support/support.limits/support.limits.general/functional.version.compile.pass.cpp FAIL std/language.support/support.limits/support.limits.general/iterator.version.compile.pass.cpp FAIL +# Test expects __cpp_lib_print to have the old value 202207L for P2093R14; we define the C++23 value 202406L for P3235R3. +std/language.support/support.limits/support.limits.general/ostream.version.compile.pass.cpp FAIL +std/language.support/support.limits/support.limits.general/print.version.compile.pass.cpp FAIL + # libc++ tests strengthened assignment operators (not compatible with P2165R4: "Compatibility Between tuple, pair, And tuple-like Objects") std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp FAIL @@ -134,7 +130,7 @@ std/language.support/support.limits/support.limits.general/mdspan.version.compil std/language.support/support.limits/support.limits.general/cstring.version.compile.pass.cpp FAIL # Various bogosity (LLVM-D141004), warning C6011: Dereferencing NULL pointer -# Note: The :1 (ASAN) configuration doesn't run static analysis. +# Note: The :1 (ASan) configuration doesn't run static analysis. std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/construct_pair_const_lvalue_pair.pass.cpp:0 FAIL std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/construct_pair_values.pass.cpp:0 FAIL @@ -228,7 +224,7 @@ std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_strong.pa std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_weak.pass.cpp:1 SKIPPED std/input.output/syncstream/osyncstream/thread/several_threads.pass.cpp:1 SKIPPED -# VSO-2164191 "[ASAN][STL] Interception breaks strtoll" +# VSO-2164191 "[ASan][STL] Interception breaks strtoll" std/strings/string.conversions/stoll.pass.cpp:1 FAIL @@ -289,7 +285,7 @@ std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp:0 FAIL std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp:1 FAIL # VSO-1271673 "static analyzer doesn't know about short-circuiting" -# Note: The :1 (ASAN) configuration doesn't run static analysis. +# Note: The :1 (ASan) configuration doesn't run static analysis. std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp:0 FAIL std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp:0 FAIL @@ -319,7 +315,7 @@ std/algorithms/robust_re_difference_type.compile.pass.cpp:1 FAIL # DevCom-1638563 VSO-1457836: icky static analysis false positive # Resolved wontfix, need to report again. -# Note: The :1 (ASAN) configuration doesn't run static analysis. +# Note: The :1 (ASan) configuration doesn't run static analysis. std/language.support/support.coroutines/end.to.end/go.pass.cpp:0 FAIL # DevCom-1638496 VSO-1462745: C1XX doesn't properly reject int <=> unsigned @@ -360,12 +356,6 @@ std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp:1 FAIL std/language.support/support.rtti/type.info/type_info.equal.pass.cpp:0 FAIL std/language.support/support.rtti/type.info/type_info.equal.pass.cpp:1 FAIL -# VSO-2170500 C1XX's type trait optimization mishandles conjunction/disjunction with non-bool types -std/utilities/meta/meta.logical/conjunction.compile.pass.cpp:0 FAIL -std/utilities/meta/meta.logical/conjunction.compile.pass.cpp:1 FAIL -std/utilities/meta/meta.logical/disjunction.compile.pass.cpp:0 FAIL -std/utilities/meta/meta.logical/disjunction.compile.pass.cpp:1 FAIL - # *** CLANG COMPILER BUGS *** # LLVM-46207 Clang's tgmath.h interferes with the UCRT's tgmath.h @@ -373,6 +363,7 @@ std/depr/depr.c.headers/tgmath_h.pass.cpp:2 FAIL # LLVM-95311 [clang] __has_unique_object_representations gives inconsistent answer based on instantiation order # A libc++ product code workaround (using `remove_all_extents_t`) and test coverage were added by LLVM-95314. +# Fixed by LLVM-95432 in Clang 19. std/utilities/meta/meta.unary/meta.unary.prop/has_unique_object_representations.compile.pass.cpp:2 FAIL @@ -471,7 +462,7 @@ std/input.output/syncstream/syncbuf/syncstream.syncbuf.members/emit.pass.cpp FAI # *** VCRUNTIME BUGS *** # DevCom-10373274 VSO-1824997 "vcruntime nothrow array operator new falls back on the wrong function" -# This passes for the :1 (ASAN) configuration, surprisingly. +# This passes for the :1 (ASan) configuration, surprisingly. std/language.support/support.dynamic/new.delete/new.delete.array/new.size_nothrow.replace.indirect.pass.cpp:0 FAIL std/language.support/support.dynamic/new.delete/new.delete.array/new.size_nothrow.replace.indirect.pass.cpp:2 FAIL @@ -509,36 +500,6 @@ std/thread/futures/futures.async/async.pass.cpp SKIPPED std/thread/futures/futures.unique_future/wait_for.pass.cpp SKIPPED std/thread/thread.condition/thread.condition.condvarany/notify_one.pass.cpp SKIPPED std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp SKIPPED -std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp SKIPPED -std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp SKIPPED -std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp SKIPPED -std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp SKIPPED -std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp SKIPPED -std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/lock.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/try_lock.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/lock.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/try_lock.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock_shared.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/try_lock_shared.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/try_lock.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp SKIPPED -std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp SKIPPED # Not analyzed, likely bogus tests. Appears to be timing assumptions. std/thread/futures/futures.shared_future/get.pass.cpp SKIPPED @@ -609,12 +570,17 @@ std/input.output/filesystems/class.path/range_concept_conformance.compile.pass.c # This test is bogus according to the wording that was ultimately accepted for C++23. std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp FAIL -# contiguous_iterator requires to_address() which calls operator->(), but this bogus test uses an iterator that lacks operator->(). +# libc++ speculatively implements the proposed resolution for LWG-4058. std/iterators/iterator.requirements/iterator.concepts/iterator.concept.random.access/contiguous_iterator.compile.pass.cpp FAIL - -# Bogus test expects to_address() to SFINAE away for int. std/utilities/memory/pointer.conversion/to_address_without_pointer_traits.pass.cpp FAIL +# We disagree about whether various chrono types should be optimized, and the test is clearly wrong about vector::reference. +std/utilities/format/format.formatter/format.formatter.locking/enable_nonlocking_formatter_optimization.compile.pass.cpp FAIL + +# `increasing_allocator` calls `std::allocator::deallocate` with the wrong size +std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp FAIL +std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp FAIL + # *** LIKELY STL BUGS *** # Not analyzed, likely STL bugs. Various assertions. @@ -845,6 +811,8 @@ std/algorithms/robust_against_proxy_iterators_lifetime_bugs.pass.cpp FAIL # Not analyzed. Possible MSVC constexpr bug. # note: failure was caused by a read of a variable outside its lifetime +std/algorithms/alg.nonmodifying/alg.find.last/ranges.find_last.pass.cpp:0 FAIL +std/algorithms/alg.nonmodifying/alg.find.last/ranges.find_last.pass.cpp:1 FAIL std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp:0 FAIL std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp:1 FAIL std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp:0 FAIL @@ -938,6 +906,7 @@ std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requir std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/construct_piecewise_pair_evil.pass.cpp FAIL # Not analyzed, failing due to constexpr step limits. +std/algorithms/alg.nonmodifying/alg.contains/ranges.contains_subrange.pass.cpp:2 FAIL std/algorithms/alg.nonmodifying/alg.count/count.pass.cpp FAIL std/algorithms/alg.nonmodifying/alg.count/ranges.count.pass.cpp FAIL std/containers/sequences/vector.bool/append_range.pass.cpp FAIL @@ -994,7 +963,7 @@ std/utilities/format/format.tuple/format.pass.cpp FAIL # Not analyzed. Static analysis thinks that array indexing is out of bounds because it can't prove otherwise. # warning C28020: The expression '_Param_(1)<1' is not true at this call. -# Note: The :1 (ASAN) configuration doesn't run static analysis. +# Note: The :1 (ASan) configuration doesn't run static analysis. std/containers/views/mdspan/extents/ctor_default.pass.cpp:0 FAIL std/containers/views/mdspan/extents/ctor_from_array.pass.cpp:0 FAIL std/containers/views/mdspan/extents/ctor_from_integral.pass.cpp:0 FAIL @@ -1007,7 +976,7 @@ std/containers/views/mdspan/mdspan/ctor.dh_span.pass.cpp:0 FAIL # Not analyzed. Apparent false positives from static analysis where it thinks `new (std::nothrow)` could return null, despite an assert(). # warning C28182: Dereferencing NULL pointer. -# Note: The :1 (ASAN) configuration doesn't run static analysis. +# Note: The :1 (ASan) configuration doesn't run static analysis. std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align_nothrow.pass.cpp:0 FAIL std/language.support/support.dynamic/new.delete/new.delete.array/new.size_nothrow.pass.cpp:0 FAIL @@ -1045,11 +1014,6 @@ std/algorithms/alg.modifying.operations/alg.move/ranges.move_backward.segmented. std/algorithms/alg.modifying.operations/alg.move/ranges.move.segmented.pass.cpp:0 FAIL std/algorithms/alg.modifying.operations/alg.move/ranges.move.segmented.pass.cpp:1 FAIL -# Not analyzed. constexpr evaluation fails with note: subobject '_Val' is not initialized -std/ranges/range.adaptors/range.join/end.pass.cpp:2 FAIL -std/ranges/range.adaptors/range.join/range.join.sentinel/ctor.parent.pass.cpp:2 FAIL -std/ranges/range.adaptors/range.join/range.join.sentinel/eq.pass.cpp:2 FAIL - # Not analyzed. constexpr evaluation fails with note: failure was caused by out of range index MEOW; allowed range is 0 <= index < 2 std/ranges/range.adaptors/range.join/adaptor.pass.cpp:0 FAIL std/ranges/range.adaptors/range.join/adaptor.pass.cpp:1 FAIL @@ -1241,10 +1205,6 @@ std/atomics/atomics.ref/operator_plus_equals.pass.cpp SKIPPED std/atomics/atomics.ref/store.pass.cpp SKIPPED std/atomics/atomics.ref/wait.pass.cpp SKIPPED -# Not analyzed. Attempting to dereference `void *`. -std/utilities/memory/unique.ptr/noexcept_operator_star.compile.pass.cpp FAIL -std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.single.pass.cpp FAIL - # Not analyzed. Attempting to delete `nullptr_t`. std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp FAIL @@ -1257,19 +1217,19 @@ std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.nonmembers/ostream.pa # Not analyzed. static_assert(testComplexity()) is failing. std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_complexity.pass.cpp FAIL -# Not analyzed. -# MSVC constexpr error: failure was caused by unexpected deallocation count -# Clang assertion: _CrtIsValidHeapPointer(block) -std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp FAIL -std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp FAIL - # Not analyzed. # MSVC truncation warnings. # Clang assertion: std::hermite(n, +inf) == inf std/numerics/c.math/hermite.pass.cpp FAIL +# Not analyzed. Test coverage for LLVM-104496 uses span. +std/containers/views/views.span/span.cons/copy.pass.cpp FAIL + +# Not analyzed. LLVM-103409 added a test to verify that std::optional's internal constructors aren't visible to users. +std/utilities/optional/optional.object/optional.object.ctor/gh_101960_internal_ctor.compile.pass.cpp FAIL -# *** XFAILs WHICH PASS *** + +# *** XFAILS WHICH PASS *** # These tests contain `// XFAIL: msvc` comments, which accurately describe runtime failures for x86 and x64. # However, for ARM and ARM64, they successfully compile, then we don't run them. # Our test harness properly handles the ambiguity of whether a FAIL line in this file means "fails to compile" @@ -1280,7 +1240,7 @@ std/numerics/c.math/hermite.pass.cpp FAIL # In the meantime, because this is platform-dependent and we don't have a way to express that in this file, # we need to mark these tests as SKIPPED. # Finally, note that only :0 (MSVC) and :2 (Clang) configurations are mentioned here, -# because we don't run :1 (ASAN) for ARM and ARM64. +# because we don't run :1 (ASan) for ARM and ARM64. std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp:0 SKIPPED std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp:2 SKIPPED std/time/time.clock/time.clock.system/sys_date.ostream.pass.cpp:0 SKIPPED @@ -1321,6 +1281,17 @@ std/ranges/range.utility/range.utility.conv/to.pass.cpp:9 SKIPPED std/thread/thread.jthread/assign.move.pass.cpp:9 SKIPPED std/utilities/meta/meta.unary/dependent_return_type.compile.pass.cpp:9 SKIPPED +# These tests also need ADDITIONAL_COMPILE_FLAGS to silence warnings, but only for Clang 18. +# TRANSITION, Clang 19 +std/containers/associative/map/map.modifiers/insert_range.pass.cpp:9 SKIPPED +std/containers/associative/multimap/multimap.modifiers/insert_range.pass.cpp:9 SKIPPED +std/containers/associative/multiset/insert_range.pass.cpp:9 SKIPPED +std/containers/associative/set/insert_range.pass.cpp:9 SKIPPED +std/containers/unord/unord.map/unord.map.modifiers/insert_range.pass.cpp:9 SKIPPED +std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp:9 SKIPPED +std/containers/unord/unord.multiset/insert_range.pass.cpp:9 SKIPPED +std/containers/unord/unord.set/insert_range.pass.cpp:9 SKIPPED + # This test is marked as `XFAIL: msvc`, but the MSVC-internal test harness doesn't yet parse XFAIL. std/utilities/function.objects/func.wrap/func.wrap.func/noncopyable_return_type.pass.cpp:9 SKIPPED diff --git a/tests/std/include/range_algorithm_support.hpp b/tests/std/include/range_algorithm_support.hpp index b71b654f066..a94ef4ba0bc 100644 --- a/tests/std/include/range_algorithm_support.hpp +++ b/tests/std/include/range_algorithm_support.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -256,56 +257,66 @@ namespace test { return {ref_ >= that.peek()}; } - // clang-format off [[nodiscard]] friend constexpr boolish operator==(proxy_reference r, Value const& val) - requires CanEq { + requires CanEq + { return {r.ref_ == val}; } [[nodiscard]] friend constexpr boolish operator==(Value const& val, proxy_reference r) - requires CanEq { + requires CanEq + { return {r.ref_ == val}; } [[nodiscard]] friend constexpr boolish operator!=(proxy_reference r, Value const& val) - requires CanNEq { + requires CanNEq + { return {r.ref_ != val}; } [[nodiscard]] friend constexpr boolish operator!=(Value const& val, proxy_reference r) - requires CanNEq { + requires CanNEq + { return {r.ref_ != val}; } [[nodiscard]] friend constexpr boolish operator<(Value const& val, proxy_reference r) - requires CanLt { + requires CanLt + { return {val < r.ref_}; } [[nodiscard]] friend constexpr boolish operator<(proxy_reference r, Value const& val) - requires CanLt { + requires CanLt + { return {r.ref_ < val}; } [[nodiscard]] friend constexpr boolish operator>(Value const& val, proxy_reference r) - requires CanGt { + requires CanGt + { return {val > r.ref_}; } [[nodiscard]] friend constexpr boolish operator>(proxy_reference r, Value const& val) - requires CanGt { + requires CanGt + { return {r.ref_ > val}; } [[nodiscard]] friend constexpr boolish operator<=(Value const& val, proxy_reference r) - requires CanLtE { + requires CanLtE + { return {val <= r.ref_}; } [[nodiscard]] friend constexpr boolish operator<=(proxy_reference r, Value const& val) - requires CanLtE { + requires CanLtE + { return {r.ref_ <= val}; } [[nodiscard]] friend constexpr boolish operator>=(Value const& val, proxy_reference r) - requires CanGtE { + requires CanGtE + { return {val >= r.ref_}; } [[nodiscard]] friend constexpr boolish operator>=(proxy_reference r, Value const& val) - requires CanGtE { + requires CanGtE + { return {r.ref_ >= val}; } - // clang-format on [[nodiscard]] constexpr Element& peek() const noexcept { return ref_; @@ -419,9 +430,9 @@ namespace test { using Consterator = iterator; // output iterator operations - // clang-format off - iterator() requires at_least || (Eq == CanCompare::yes) = default; - // clang-format on + iterator() + requires at_least || (Eq == CanCompare::yes) + = default; constexpr explicit iterator(Element* ptr) noexcept : ptr_{ptr} {} @@ -525,8 +536,8 @@ namespace test { return std::move(*i.ptr_); } - friend constexpr void iter_swap(iterator const& x, iterator const& y) noexcept( - std::is_nothrow_swappable_v) + friend constexpr void iter_swap(iterator const& x, iterator const& y) + noexcept(std::is_nothrow_swappable_v) requires at_least && std::swappable { ranges::swap(*x.ptr_, *y.ptr_); @@ -542,10 +553,12 @@ namespace test { } // sentinel operations (implied by forward iterator): - // clang-format off - iterator(iterator const&) requires (to_bool(Eq)) = default; - iterator& operator=(iterator const&) requires (to_bool(Eq)) = default; - // clang-format on + iterator(iterator const&) + requires (to_bool(Eq)) + = default; + iterator& operator=(iterator const&) + requires (to_bool(Eq)) + = default; constexpr operator Consterator() const& noexcept requires (to_bool(Eq)) @@ -671,7 +684,7 @@ namespace test { } using unwrap = std::conditional_t, Element*, - iterator>; + iterator>; using unwrapping_ignorant = iterator; [[nodiscard]] constexpr auto _Unwrapped() const& noexcept @@ -744,7 +757,7 @@ template > { using pointer = ::test::iterator; + ::test::ProxyRef::no, Wrapped>; using element_type = Element; using difference_type = ptrdiff_t; @@ -935,6 +948,228 @@ namespace test { static_assert(false); } }; + + template + [[nodiscard]] constexpr auto to_unsigned(I n) noexcept { + if constexpr (std::signed_integral) { + return static_cast>(n); + } else { + return static_cast(n); + } + } + + template + struct redifference_iterator_category_base {}; + + template + requires std::signed_integral && requires { typename std::iterator_traits::iterator_category; } + struct redifference_iterator_category_base { + using iterator_category = std::iterator_traits::iterator_category; + using iterator_concept = decltype([] { + if constexpr (std::contiguous_iterator) { + return std::contiguous_iterator_tag{}; + } else if constexpr (std::random_access_iterator) { + return std::random_access_iterator_tag{}; + } else if constexpr (std::bidirectional_iterator) { + return std::bidirectional_iterator_tag{}; + } else if constexpr (std::forward_iterator) { + return std::forward_iterator_tag{}; + } else { + return std::input_iterator_tag{}; + } + }()); + }; + + template + class redifference_iterator : public redifference_iterator_category_base { + public: + using value_type = std::iter_value_t; + using difference_type = Diff; + + redifference_iterator() = default; + constexpr explicit redifference_iterator(It it) : i_{std::move(it)} {} + + [[nodiscard]] constexpr decltype(auto) operator*() const { + return *i_; + } + + constexpr decltype(auto) operator->() const + requires std::contiguous_iterator || (requires(const It& i) { i.operator->(); }) + { + if constexpr (std::contiguous_iterator) { + return std::to_address(i_); + } else { + return i_.operator->(); + } + } + + constexpr redifference_iterator& operator++() { + ++i_; + return *this; + } + + constexpr decltype(auto) operator++(int) { + if constexpr (std::is_same_v) { + return redifference_iterator{i_++}; + } else { + return i_++; + } + } + + constexpr redifference_iterator& operator--() + requires std::bidirectional_iterator + { + --i_; + return *this; + } + + constexpr redifference_iterator operator--(int) + requires std::bidirectional_iterator + { + return redifference_iterator{--i_}; + } + + constexpr redifference_iterator& operator+=(std::same_as auto n) + requires std::random_access_iterator + { + i_ += static_cast>(n); + return *this; + } + + constexpr redifference_iterator& operator-=(std::same_as auto n) + requires std::random_access_iterator + { + i_ -= static_cast>(n); + return *this; + } + + [[nodiscard]] constexpr decltype(auto) operator[](std::same_as auto n) const + requires std::random_access_iterator + { + return i_[static_cast>(n)]; + } + + [[nodiscard]] friend constexpr bool operator==(const redifference_iterator& i, const redifference_iterator& j) { + return i.i_ == j.i_; + } + + [[nodiscard]] friend constexpr redifference_iterator operator+( + const redifference_iterator& it, std::same_as auto n) + requires std::random_access_iterator + { + return redifference_iterator{it.i_ + static_cast>(n)}; + } + + [[nodiscard]] friend constexpr redifference_iterator operator+( + std::same_as auto n, const redifference_iterator& it) + requires std::random_access_iterator + { + return redifference_iterator{it.i_ + static_cast>(n)}; + } + + [[nodiscard]] friend constexpr redifference_iterator operator-( + const redifference_iterator& it, std::same_as auto n) + requires std::random_access_iterator + { + return redifference_iterator{it.i_ - static_cast>(n)}; + } + + [[nodiscard]] friend constexpr difference_type operator-( + const redifference_iterator& i, const redifference_iterator& j) + requires std::random_access_iterator + { + return static_cast(i.i_ - j.i_); + } + + [[nodiscard]] friend constexpr auto operator<=>(const redifference_iterator& i, const redifference_iterator& j) + requires std::random_access_iterator + { + if constexpr (std::three_way_comparable) { + return i.i_ <=> j.i_; + } else { + if (i.i_ < j.i_) { + return std::weak_ordering::less; + } else if (j.i_ < i.i_) { + return std::weak_ordering::greater; + } else { + return std::weak_ordering::equivalent; + } + } + } + + [[nodiscard]] friend constexpr bool operator<(const redifference_iterator& i, const redifference_iterator& j) + requires std::random_access_iterator + { + return i.i_ < j.i_; + } + + [[nodiscard]] friend constexpr bool operator>(const redifference_iterator& i, const redifference_iterator& j) + requires std::random_access_iterator + { + return j.i_ < i.i_; + } + + [[nodiscard]] friend constexpr bool operator<=(const redifference_iterator& i, const redifference_iterator& j) + requires std::random_access_iterator + { + return !(j.i_ < i.i_); + } + + [[nodiscard]] friend constexpr bool operator>=(const redifference_iterator& i, const redifference_iterator& j) + requires std::random_access_iterator + { + return !(i.i_ < j.i_); + } + + [[nodiscard]] constexpr const It& base() const noexcept { + return i_; + } + + private: + It i_; + }; + + template + struct redifference_sentinel { + S se_; + + template + requires std::sentinel_for + [[nodiscard]] friend constexpr bool operator==( + const redifference_iterator& i, const redifference_sentinel& s) { + return i.base() == s.se_; + } + + template + requires std::sized_sentinel_for + [[nodiscard]] friend constexpr Diff operator-( + const redifference_iterator& i, const redifference_sentinel& s) { + return static_cast(i.base() - s.se_); + } + template + requires std::sized_sentinel_for + [[nodiscard]] friend constexpr Diff operator-( + const redifference_sentinel& s, const redifference_iterator& i) { + return static_cast(s.se_ - i.base()); + } + }; + + template + [[nodiscard]] constexpr auto make_redifference_subrange(Rng&& r) { + constexpr bool is_sized = + ranges::sized_range || std::sized_sentinel_for, ranges::iterator_t>; + using rediff_iter = redifference_iterator>; + using rediff_sent = redifference_sentinel>; + + if constexpr (is_sized) { + const auto sz = to_unsigned(static_cast(ranges::distance(r))); + return ranges::subrange{ + rediff_iter{r.begin()}, rediff_sent{r.end()}, sz}; + } else { + return ranges::subrange{ + rediff_iter{r.begin()}, rediff_sent{r.end()}}; + } + } } // namespace test template (lcg); + assert(val >= 0.0); + assert(val < 1.0); +#endif // ^^^ no workaround ^^^ } void test_ranges() { @@ -744,17 +752,11 @@ constexpr bool impl_test_source_location() { assert(sl.line() == __LINE__ - 1); assert(sl.column() == 38); -#ifdef __EDG__ // TRANSITION, DevCom-10199227 -#define TEST_DETAILED_FUNCTION_NAME 0 -#else // ^^^ workaround / no workaround vvv -#define TEST_DETAILED_FUNCTION_NAME 1 -#endif // ^^^ no workaround ^^^ - -#if TEST_DETAILED_FUNCTION_NAME +#ifdef __EDG__ + assert(sl.function_name() == "bool impl_test_source_location()"sv); +#else // ^^^ EDG / Other vvv assert(sl.function_name() == "bool __cdecl impl_test_source_location(void)"sv); -#else // ^^^ detailed / basic vvv - assert(sl.function_name() == "impl_test_source_location"sv); -#endif // ^^^ basic ^^^ +#endif // ^^^ Other ^^^ assert(string_view{sl.file_name()}.ends_with("test_header_units_and_modules.hpp"sv)); return true; diff --git a/tests/std/include/test_min_max_element_support.hpp b/tests/std/include/test_min_max_element_support.hpp index a717c7ef85f..621c76fe960 100644 --- a/tests/std/include/test_min_max_element_support.hpp +++ b/tests/std/include/test_min_max_element_support.hpp @@ -5,7 +5,9 @@ #include #include +#include #include +#include #include #include @@ -116,6 +118,17 @@ void test_case_min_max_element(const std::vector& input) { assert(*expected_max == actual_max_value); assert(*expected_minmax.first == actual_minmax_value.min); assert(*expected_minmax.second == actual_minmax_value.max); + +#ifndef _M_FP_FAST + // With /fp:fast mode the compiler does not try to produce the code that correctly + // distinguishes +0.0 and -0.0, so the algorithms are not expected to either. + if constexpr (std::is_floating_point_v) { + assert(std::signbit(*expected_min) == std::signbit(actual_min_value)); + assert(std::signbit(*expected_max) == std::signbit(actual_max_value)); + assert(std::signbit(*expected_minmax.first) == std::signbit(actual_minmax_value.min)); + assert(std::signbit(*expected_minmax.second) == std::signbit(actual_minmax_value.max)); + } +#endif // !defined(_M_FP_FAST) } #endif // _HAS_CXX20 } diff --git a/tests/std/include/test_vector_algorithms_support.hpp b/tests/std/include/test_vector_algorithms_support.hpp new file mode 100644 index 00000000000..5cdffd9ffe4 --- /dev/null +++ b/tests/std/include/test_vector_algorithms_support.hpp @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +inline void initialize_randomness(std::mt19937_64& gen) { + constexpr std::size_t n = std::mt19937_64::state_size; + constexpr std::size_t w = std::mt19937_64::word_size; + static_assert(w % 32 == 0, "w should be evenly divisible by 32"); + constexpr std::size_t k = w / 32; + + std::vector vec(n * k); + + std::random_device rd; + std::generate(vec.begin(), vec.end(), std::ref(rd)); + + std::printf("This is a randomized test.\n"); + std::printf("DO NOT IGNORE/RERUN ANY FAILURES.\n"); + std::printf("You must report them to the STL maintainers.\n\n"); + + std::printf("Seed vector: "); + for (const auto& e : vec) { + std::printf("%u,", e); + } + std::printf("\n"); + + std::seed_seq seq(vec.cbegin(), vec.cend()); + gen.seed(seq); +} + +#if (defined(_M_IX86) || defined(_M_X64)) && !defined(_M_CEE_PURE) +extern "C" long __isa_enabled; + +inline void disable_instructions(ISA_AVAILABILITY isa) { + __isa_enabled &= ~(1UL << static_cast(isa)); +} +#endif // (defined(_M_IX86) || defined(_M_X64)) && !defined(_M_CEE_PURE) + +constexpr std::size_t dataCount = 1024; + +template +void run_randomized_tests_with_different_isa_levels(TestFunc tests) { + std::mt19937_64 gen; + initialize_randomness(gen); + + tests(gen); + +#if (defined(_M_IX86) || defined(_M_X64)) && !defined(_M_CEE_PURE) + disable_instructions(__ISA_AVAILABLE_AVX2); + tests(gen); + + disable_instructions(__ISA_AVAILABLE_SSE42); + tests(gen); +#endif // (defined(_M_IX86) || defined(_M_X64)) && !defined(_M_CEE_PURE) +} diff --git a/tests/std/run.pl b/tests/std/run.pl index 004ae4ce689..6258d2ebcb0 100644 --- a/tests/std/run.pl +++ b/tests/std/run.pl @@ -34,7 +34,7 @@ # add additional compiler flags if the compiler is cl.exe. if (not $ENV{PM_COMPILER}) { - $ENV{CL} .= " " . $ENV{PM_CL_MSVC}; + $ENV{PM_CL} .= " " . $ENV{PM_CL_MSVC}; } my $RunPL = ""; diff --git a/tests/std/test.lst b/tests/std/test.lst index 842124796c9..0dc08ee1a6e 100644 --- a/tests/std/test.lst +++ b/tests/std/test.lst @@ -230,6 +230,7 @@ tests\GH_003119_error_category_ctor tests\GH_003246_cmath_narrowing tests\GH_003570_allocate_at_least tests\GH_003617_vectorized_meow_element +tests\GH_003663_cast_contiguous_iterator_difference_type tests\GH_003676_format_large_hh_mm_ss_values tests\GH_003735_char_traits_signatures tests\GH_003840_tellg_when_reading_lf_file_in_text_mode @@ -261,6 +262,7 @@ tests\LWG3528_make_from_tuple_impl tests\LWG3545_pointer_traits_sfinae tests\LWG3561_discard_block_engine_counter tests\LWG3610_iota_view_size_and_integer_class +tests\LWG4105_ranges_ends_with_and_integer_class tests\P0009R18_mdspan_default_accessor tests\P0009R18_mdspan_extents tests\P0009R18_mdspan_extents_death @@ -677,6 +679,7 @@ tests\P2609R3_relaxing_ranges_just_a_smidge tests\P2693R1_ostream_and_thread_id tests\P2693R1_text_formatting_stacktrace tests\P2693R1_text_formatting_thread_id +tests\P3107R5_enabled_specializations tests\VSO_0000000_allocator_propagation tests\VSO_0000000_any_calling_conventions tests\VSO_0000000_c_math_functions @@ -710,6 +713,7 @@ tests\VSO_0000000_regex_use tests\VSO_0000000_string_view_idl tests\VSO_0000000_type_traits tests\VSO_0000000_vector_algorithms +tests\VSO_0000000_vector_algorithms_floats tests\VSO_0000000_wcfb01_idempotent_container_destructors tests\VSO_0000000_wchar_t_filebuf_xsmeown tests\VSO_0095468_clr_exception_ptr_bad_alloc @@ -760,5 +764,6 @@ tests\VSO_0849827_multicontainer_emplace_hint_position tests\VSO_0938757_attribute_order tests\VSO_0961751_hash_range_erase tests\VSO_0971246_legacy_await_headers +tests\VSO_1775715_user_defined_modules tests\VSO_1804139_static_analysis_warning_with_single_element_array tests\VSO_1925201_iter_traits diff --git a/tests/std/tests/Dev11_0289403_partition_point_complexity/test.cpp b/tests/std/tests/Dev11_0289403_partition_point_complexity/test.cpp index dd67957c7ba..5b53e6604ee 100644 --- a/tests/std/tests/Dev11_0289403_partition_point_complexity/test.cpp +++ b/tests/std/tests/Dev11_0289403_partition_point_complexity/test.cpp @@ -77,10 +77,8 @@ int main() { forward_list fl(v.begin(), v.end()); for (int x = 0; x <= k; ++x) { - test_partition_point( - v, [x](int e) { return e < x; }, x); - test_partition_point( - fl, [x](int e) { return e < x; }, x); + test_partition_point(v, [x](int e) { return e < x; }, x); + test_partition_point(fl, [x](int e) { return e < x; }, x); } } diff --git a/tests/std/tests/Dev11_0836436_get_time/test.cpp b/tests/std/tests/Dev11_0836436_get_time/test.cpp index ce5152ca1c9..6c05df8bd3f 100644 --- a/tests/std/tests/Dev11_0836436_get_time/test.cpp +++ b/tests/std/tests/Dev11_0836436_get_time/test.cpp @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include #include #include #include @@ -106,11 +107,11 @@ void test_DevDiv_990695(); void test_locale_russian(); void test_locale_german(); void test_locale_chinese(); -void test_invalid_argument(); void test_buffer_resizing(); void test_gh_2618(); void test_gh_2848(); void test_gh_4820(); +void test_gh_4882(); int main() { assert(read_hour("12 AM") == 0); @@ -154,11 +155,11 @@ int main() { test_locale_russian(); test_locale_german(); test_locale_chinese(); - test_invalid_argument(); test_buffer_resizing(); test_gh_2618(); test_gh_2848(); test_gh_4820(); + test_gh_4882(); } typedef istreambuf_iterator Iter; @@ -774,42 +775,6 @@ void test_locale_chinese() { assert(read_date_locale(L"2020-\x0031\x0032\x6708-31", "zh-CN") == make_tuple(31, 11, 120)); } -void test_invalid_parameter_handler(const wchar_t* const expression, const wchar_t* const function, - const wchar_t* const file, const unsigned int line, const uintptr_t reserved) { - (void) expression; - (void) reserved; - - static int num_called = 0; - if (++num_called > 10) { - wprintf( - L"Test Failed: Invalid parameter handler was called over 10 times by %s in %s:%u\n", function, file, line); - exit(1); - } -} - -void test_invalid_argument() { -#ifndef _M_CEE_PURE - _set_invalid_parameter_handler(test_invalid_parameter_handler); - - time_t t = time(nullptr); - tm currentTime; - localtime_s(¤tTime, &t); - currentTime.tm_hour = 25; // set invalid hour - - { - wstringstream wss; - wss << put_time(¤tTime, L"%Y-%m-%d-%H-%M"); - assert(wss.rdstate() == ios_base::badbit); - } - - { - stringstream ss; - ss << put_time(¤tTime, "%Y-%m-%d-%H-%M"); - assert(ss.rdstate() == ios_base::badbit); - } -#endif // _M_CEE_PURE -} - void test_buffer_resizing() { time_t t = time(nullptr); tm currentTime; @@ -944,3 +909,55 @@ void test_gh_4820() { assert(wss.str() == L"\x043a%\x043e%\x0448%E\x043a%O\x0430"); } } + +void test_gh_4882() { + // GH-4882 : std::put_time should not crash on invalid/out-of-range tm struct values + const auto fieldValidation = [](int tm::*const field, const int value, const string& fmt) { + time_t t = time(nullptr); + tm currentTime; + localtime_s(¤tTime, &t); + + currentTime.*field = value; + + stringstream ss; + ss << put_time(¤tTime, fmt.c_str()); + assert(ss.rdstate() == ios_base::goodbit); + const auto result = ss.str(); + assert(result.size() == fmt.size() / 2); + assert(all_of(result.cbegin(), result.cend(), [](const char c) { return c == '?'; })); + + // Narrow conversion is good enough for our ASCII only format strings + wstring wfmt(fmt.size(), L' '); + transform(fmt.cbegin(), fmt.cend(), wfmt.begin(), [](const char c) { return static_cast(c); }); + + wstringstream wss; + wss << put_time(¤tTime, wfmt.c_str()); + assert(wss.rdstate() == ios_base::goodbit); + const auto wresult = wss.str(); + assert(wresult.size() == fmt.size() / 2); + assert(all_of(wresult.cbegin(), wresult.cend(), [](const wchar_t c) { return c == L'?'; })); + }; + + struct FormatTestData { + int tm::*field; + int lo; + int hi; + string fmt; + }; + + const FormatTestData testDataList[] = { + {&tm::tm_sec, -1, 61, "%S%r%X%T%c"}, + {&tm::tm_min, -1, 60, "%M%R%r%X%T%c"}, + {&tm::tm_hour, -1, 24, "%H%I%p%R%r%X%T%c"}, + {&tm::tm_mday, 0, 32, "%d%e%D%x%F%c"}, + {&tm::tm_mon, -1, 12, "%b%B%m%h%D%x%F%c"}, + {&tm::tm_year, -1901, 8100, "%C%y%Y%D%x%F%g%G%c"}, + {&tm::tm_wday, -1, 7, "%a%A%u%w%U%W%g%G%c"}, + {&tm::tm_yday, -1, 366, "%j%U%W%g%G"}, + }; + + for (const auto& testData : testDataList) { + fieldValidation(testData.field, testData.lo, testData.fmt); + fieldValidation(testData.field, testData.hi, testData.fmt); + } +} diff --git a/tests/std/tests/GH_000140_adl_proof_comparison/test.compile.pass.cpp b/tests/std/tests/GH_000140_adl_proof_comparison/test.compile.pass.cpp index 70c5665ca46..4eeea842fd0 100644 --- a/tests/std/tests/GH_000140_adl_proof_comparison/test.compile.pass.cpp +++ b/tests/std/tests/GH_000140_adl_proof_comparison/test.compile.pass.cpp @@ -142,33 +142,33 @@ struct validating_iterator_provider::iterator { } template , int> = 0> - friend constexpr auto operator==(iterator i, OtherIter j) noexcept + friend constexpr auto operator==(iterator i, OtherIter j) noexcept // -> decltype(pointer{} == typename OtherIter::pointer{} ? placeholder_addr : nullptr) { return i.operator->() == j.operator->() ? placeholder_addr : nullptr; } template , int> = 0> - friend constexpr auto operator!=(iterator i, OtherIter j) noexcept + friend constexpr auto operator!=(iterator i, OtherIter j) noexcept // -> decltype(pointer{} != typename OtherIter::pointer{} ? placeholder_addr : nullptr) { return i.operator->() != j.operator->() ? placeholder_addr : nullptr; } template , int> = 0> - friend constexpr auto operator<(iterator i, OtherIter j) noexcept + friend constexpr auto operator<(iterator i, OtherIter j) noexcept // -> decltype(pointer{} < typename OtherIter::pointer{} ? placeholder_addr : nullptr) { return i.operator->() < j.operator->() ? placeholder_addr : nullptr; } template , int> = 0> - friend constexpr auto operator>(iterator i, OtherIter j) noexcept + friend constexpr auto operator>(iterator i, OtherIter j) noexcept // -> decltype(pointer{} > typename OtherIter::pointer{} ? placeholder_addr : nullptr) { return i.operator->() > j.operator->() ? placeholder_addr : nullptr; } template , int> = 0> - friend constexpr auto operator<=(iterator i, OtherIter j) noexcept + friend constexpr auto operator<=(iterator i, OtherIter j) noexcept // -> decltype(pointer{} <= typename OtherIter::pointer{} ? placeholder_addr : nullptr) { return i.operator->() <= j.operator->() ? placeholder_addr : nullptr; } template , int> = 0> - friend constexpr auto operator>=(iterator i, OtherIter j) noexcept + friend constexpr auto operator>=(iterator i, OtherIter j) noexcept // -> decltype(pointer{} >= typename OtherIter::pointer{} ? placeholder_addr : nullptr) { return i.operator->() >= j.operator->() ? placeholder_addr : nullptr; } diff --git a/tests/std/tests/GH_000431_lex_compare_memcmp_classify/env.lst b/tests/std/tests/GH_000431_lex_compare_memcmp_classify/env.lst index 00256420b81..a414ee43bda 100644 --- a/tests/std/tests/GH_000431_lex_compare_memcmp_classify/env.lst +++ b/tests/std/tests/GH_000431_lex_compare_memcmp_classify/env.lst @@ -3,5 +3,7 @@ RUNALL_INCLUDE ..\char8_t_matrix.lst RUNALL_CROSSLIST -* PM_CL="" # Test manual vectorization -* PM_CL="/D_USE_STD_VECTOR_ALGORITHMS=0" # Test memcmp optimization +# Test manual vectorization: +* PM_CL="" +# Test memcmp optimization: +* PM_CL="/D_USE_STD_VECTOR_ALGORITHMS=0" diff --git a/tests/std/tests/GH_001596_adl_proof_algorithms/test.compile.pass.cpp b/tests/std/tests/GH_001596_adl_proof_algorithms/test.compile.pass.cpp index cec3c700dec..4d4ff4c7094 100644 --- a/tests/std/tests/GH_001596_adl_proof_algorithms/test.compile.pass.cpp +++ b/tests/std/tests/GH_001596_adl_proof_algorithms/test.compile.pass.cpp @@ -40,7 +40,7 @@ struct tagged_less { template struct tagged_zero_equality { template - constexpr auto operator()(T&& t) const + constexpr auto operator()(T&& t) const // -> decltype(std::forward(t) == std::remove_cv_t>{}) { return std::forward(t) == std::remove_cv_t>{}; } diff --git a/tests/std/tests/GH_003663_cast_contiguous_iterator_difference_type/env.lst b/tests/std/tests/GH_003663_cast_contiguous_iterator_difference_type/env.lst new file mode 100644 index 00000000000..351a8293d9d --- /dev/null +++ b/tests/std/tests/GH_003663_cast_contiguous_iterator_difference_type/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_20_matrix.lst diff --git a/tests/std/tests/GH_003663_cast_contiguous_iterator_difference_type/test.compile.pass.cpp b/tests/std/tests/GH_003663_cast_contiguous_iterator_difference_type/test.compile.pass.cpp new file mode 100644 index 00000000000..29f60abbacf --- /dev/null +++ b/tests/std/tests/GH_003663_cast_contiguous_iterator_difference_type/test.compile.pass.cpp @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include + +class ContiguousIterator { +public: + using value_type = int; + using difference_type = int; + using iterator_category = std::contiguous_iterator_tag; + + value_type* operator->() const; + value_type& operator*() const; + value_type& operator[](difference_type) const; + ContiguousIterator& operator++(); + ContiguousIterator operator++(int); + ContiguousIterator& operator--(); + ContiguousIterator operator--(int); + ContiguousIterator& operator+=(difference_type); + ContiguousIterator& operator-=(difference_type); + friend auto operator<=>(ContiguousIterator, ContiguousIterator) = default; + friend difference_type operator-(ContiguousIterator, ContiguousIterator); + friend ContiguousIterator operator+(ContiguousIterator, difference_type); + friend ContiguousIterator operator-(ContiguousIterator, difference_type); + friend ContiguousIterator operator+(difference_type, ContiguousIterator); +}; + +static_assert(std::contiguous_iterator); + +// GH-3663 /: contiguous iterators with non-ptrdiff_t difference types +void test() { + int* p = nullptr; + std::copy(p, p, ContiguousIterator{}); + std::sort(ContiguousIterator{}, ContiguousIterator{}); +} diff --git a/tests/std/tests/GH_004845_logical_operator_traits_with_non_bool_constant/test.compile.pass.cpp b/tests/std/tests/GH_004845_logical_operator_traits_with_non_bool_constant/test.compile.pass.cpp index 0f621d7f99f..dfa927e2569 100644 --- a/tests/std/tests/GH_004845_logical_operator_traits_with_non_bool_constant/test.compile.pass.cpp +++ b/tests/std/tests/GH_004845_logical_operator_traits_with_non_bool_constant/test.compile.pass.cpp @@ -14,10 +14,8 @@ void test_base_derived() { using ValueType = typename Base::value_type; STATIC_ASSERT(is_same_v); STATIC_ASSERT(Base::value == Derived::type::value); -#if defined(__clang__) || defined(__EDG__) // TRANSITION, VSO-2170500 (C1XX type trait optimization) STATIC_ASSERT(is_same_v); STATIC_ASSERT(Base::value == Derived::value); -#endif // ^^^ no workaround ^^^ } template diff --git a/tests/std/tests/LWG4105_ranges_ends_with_and_integer_class/env.lst b/tests/std/tests/LWG4105_ranges_ends_with_and_integer_class/env.lst new file mode 100644 index 00000000000..b2dc2c0f570 --- /dev/null +++ b/tests/std/tests/LWG4105_ranges_ends_with_and_integer_class/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\strict_latest_matrix.lst diff --git a/tests/std/tests/LWG4105_ranges_ends_with_and_integer_class/test.cpp b/tests/std/tests/LWG4105_ranges_ends_with_and_integer_class/test.cpp new file mode 100644 index 00000000000..78137bcd5e0 --- /dev/null +++ b/tests/std/tests/LWG4105_ranges_ends_with_and_integer_class/test.cpp @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include +#include +#include +#include + +#include + +using namespace std; + +template +concept testable_range = ranges::input_range && (ranges::forward_range || ranges::sized_range); + +template +concept testable_sentinel = + ranges::input_range + && (ranges::forward_range || sized_sentinel_for, ranges::iterator_t>); + +struct instantiator { + static constexpr pair haystack[] = {{0, 42}, {1, 42}, {2, 42}, {4, 42}}; + static constexpr pair short_haystack[] = {{4, 42}}; + static constexpr pair long_needle[] = {{13, 1}, {13, 2}, {13, 4}}; + static constexpr pair short_needle[] = {{13, 2}, {13, 4}}; + static constexpr pair wrong_needle[] = {{13, 2}, {13, 3}}; + + template + static constexpr void test_range_rediff() { + using ranges::ends_with, ranges::equal_to; + + { + In1 r1{haystack}; + In2 r2{long_needle}; + const same_as auto match = ends_with(test::make_redifference_subrange(r1), + test::make_redifference_subrange(r2), equal_to{}, get_first, get_second); + assert(match); + } + { + In1 r1{haystack}; + In2 r2{short_needle}; + const same_as auto match = ends_with(test::make_redifference_subrange(r1), + test::make_redifference_subrange(r2), equal_to{}, get_first, get_second); + assert(match); + } + { + In1 r1{haystack}; + In2 r2{wrong_needle}; + const same_as auto match = ends_with(test::make_redifference_subrange(r1), + test::make_redifference_subrange(r2), equal_to{}, get_first, get_second); + assert(!match); + } + { + In1 r1{short_haystack}; + In2 r2{short_needle}; + const same_as auto match = ends_with(test::make_redifference_subrange(r1), + test::make_redifference_subrange(r2), equal_to{}, get_first, get_second); + assert(!match); + } + { + In1 r1{haystack}; + In2 r2{span, 0>{}}; + const same_as auto match = ends_with(test::make_redifference_subrange(r1), + test::make_redifference_subrange(r2), equal_to{}, get_first, get_second); + assert(match); + } + } + + template + static void call() { + if constexpr (testable_range && testable_range) { + using int_class = ranges::range_difference_t>; + + test_range_rediff(); + static_assert((test_range_rediff(), true)); + + test_range_rediff(); + static_assert((test_range_rediff(), true)); + } + } +}; + +#ifdef TEST_EVERYTHING +int main() { +#if !defined(_PREFAST_) && !defined(__EDG__) // TRANSITION, GH-1030 and GH-3567 + test_in_in, const pair>(); +#endif // ^^^ no workaround ^^^ +} +#else // ^^^ test all permutations of range properties / test only interesting permutations vvv +template +void run_tests_inner() { + instantiator::call, test::Sized::yes>>(); + instantiator::call, test::Sized::no>>(); + instantiator::call, test::Sized::yes>>(); + instantiator::call, test::Sized::no>>(); + instantiator::call, test::Sized::yes>>(); + instantiator::call, test::Sized::no>>(); + instantiator::call, test::Sized::yes>>(); + instantiator::call, test::Sized::no>>(); + instantiator::call, test::Sized::yes>>(); +} + +void run_tests() { + run_tests_inner, test::Sized::yes>>(); + run_tests_inner, test::Sized::no>>(); + run_tests_inner, test::Sized::yes>>(); + run_tests_inner, test::Sized::no>>(); + run_tests_inner, test::Sized::yes>>(); + run_tests_inner, test::Sized::no>>(); + run_tests_inner, test::Sized::yes>>(); + run_tests_inner, test::Sized::no>>(); + run_tests_inner, test::Sized::yes>>(); +} + +int main() { + run_tests(); +} +#endif // TEST_EVERYTHING diff --git a/tests/std/tests/P0088R3_variant/test.cpp b/tests/std/tests/P0088R3_variant/test.cpp index 58a54cbdaad..403a873116d 100644 --- a/tests/std/tests/P0088R3_variant/test.cpp +++ b/tests/std/tests/P0088R3_variant/test.cpp @@ -285,7 +285,9 @@ void test_const_lvalue_get() { { using V = std::variant; constexpr V v(42); - static_assert(noexcept(std::get<0>(v)) == is_permissive); +#if defined(_MSVC_INTERNAL_TESTING) || defined(__clang__) || defined(__EDG__) // TRANSITION, vs17.12p3 + ASSERT_NOT_NOEXCEPT(std::get<0>(v)); +#endif // ^^^ no workaround ^^^ ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &); static_assert(std::get<0>(v) == 42, ""); } @@ -299,7 +301,9 @@ void test_const_lvalue_get() { { using V = std::variant; constexpr V v(42l); - static_assert(noexcept(std::get<1>(v)) == is_permissive); +#if defined(_MSVC_INTERNAL_TESTING) || defined(__clang__) || defined(__EDG__) // TRANSITION, vs17.12p3 + ASSERT_NOT_NOEXCEPT(std::get<1>(v)); +#endif // ^^^ no workaround ^^^ ASSERT_SAME_TYPE(decltype(std::get<1>(v)), const long &); static_assert(std::get<1>(v) == 42, ""); } @@ -447,7 +451,9 @@ void test_const_lvalue_get() { { using V = std::variant; constexpr V v(42); - static_assert(noexcept(std::get(v)) == is_permissive); +#if defined(_MSVC_INTERNAL_TESTING) || defined(__clang__) || defined(__EDG__) // TRANSITION, vs17.12p3 + ASSERT_NOT_NOEXCEPT(std::get(v)); +#endif // ^^^ no workaround ^^^ ASSERT_SAME_TYPE(decltype(std::get(v)), const int &); static_assert(std::get(v) == 42, ""); } @@ -461,7 +467,9 @@ void test_const_lvalue_get() { { using V = std::variant; constexpr V v(42l); - static_assert(noexcept(std::get(v)) == is_permissive); +#if defined(_MSVC_INTERNAL_TESTING) || defined(__clang__) || defined(__EDG__) // TRANSITION, vs17.12p3 + ASSERT_NOT_NOEXCEPT(std::get(v)); +#endif // ^^^ no workaround ^^^ ASSERT_SAME_TYPE(decltype(std::get(v)), const long &); static_assert(std::get(v) == 42, ""); } diff --git a/tests/std/tests/P0088R3_variant_msvc/test.cpp b/tests/std/tests/P0088R3_variant_msvc/test.cpp index adcb2967aee..412d93d68e4 100644 --- a/tests/std/tests/P0088R3_variant_msvc/test.cpp +++ b/tests/std/tests/P0088R3_variant_msvc/test.cpp @@ -741,6 +741,89 @@ namespace msvc { } } // namespace gh2770 + namespace gh4901 { +#if _HAS_CXX20 +#define CONSTEXPR20 constexpr +#else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv +#define CONSTEXPR20 inline +#endif // ^^^ !_HAS_CXX20 ^^^ + struct X { + CONSTEXPR20 ~X() {} + }; + + struct Y { + X _; + }; + + struct ZA { + std::variant z; + }; + + struct ZB { + std::variant z; + }; + +#if _HAS_CXX20 + static_assert(ZA{0}.z.index() == 1); + static_assert(ZA{Y{}}.z.index() == 0); + static_assert(ZB{0}.z.index() == 0); + static_assert(ZB{Y{}}.z.index() == 1); +#endif // _HAS_CXX20 + + static_assert(std::is_nothrow_destructible_v); + static_assert(std::is_nothrow_destructible_v); + static_assert(std::is_nothrow_destructible_v>); + static_assert(std::is_nothrow_destructible_v>); + static_assert(std::is_nothrow_destructible_v); + static_assert(std::is_nothrow_destructible_v); + + // Verify that variant::~variant is noexcept even when an alternative has a potentially-throwing destructor, + // per N4988 [res.on.exception.handling]/3. + struct X2 { + CONSTEXPR20 ~X2() noexcept(false) {} + }; + + struct Y2 { + X2 _; + }; + + struct ZA2 { + std::variant z; + }; + + struct ZB2 { + std::variant z; + }; + +#if _HAS_CXX20 + static_assert(ZA2{0}.z.index() == 1); + static_assert(ZA2{Y2{}}.z.index() == 0); + static_assert(ZB2{0}.z.index() == 0); + static_assert(ZB2{Y2{}}.z.index() == 1); +#endif // _HAS_CXX20 + + static_assert(!std::is_nothrow_destructible_v); + static_assert(!std::is_nothrow_destructible_v); + static_assert(std::is_nothrow_destructible_v>); + static_assert(std::is_nothrow_destructible_v>); + static_assert(std::is_nothrow_destructible_v); + static_assert(std::is_nothrow_destructible_v); + + struct ZC { + std::variant z; + }; + +#if _HAS_CXX20 + static_assert(ZC{Y{}}.z.index() == 0); + static_assert(ZC{0}.z.index() == 1); + static_assert(ZC{Y2{}}.z.index() == 2); +#endif // _HAS_CXX20 + + static_assert(std::is_nothrow_destructible_v>); + static_assert(std::is_nothrow_destructible_v); +#undef CONSTEXPR20 + } // namespace gh4901 + namespace assign_cv { template struct TypeIdentityImpl { diff --git a/tests/std/tests/P0218R1_filesystem/test.cpp b/tests/std/tests/P0218R1_filesystem/test.cpp index c1c17d97412..7f656e02a74 100644 --- a/tests/std/tests/P0218R1_filesystem/test.cpp +++ b/tests/std/tests/P0218R1_filesystem/test.cpp @@ -1284,10 +1284,7 @@ void test_directory_iterator_common_parts(const string_view typeName) { EXPECT(throws_filesystem_error([&] { DirectoryIterator bad_dir{nonexistent}; }, typeName, nonexistent)); EXPECT(throws_filesystem_error( - [&] { - DirectoryIterator bad_dir{nonexistent, directory_options::none}; - }, - typeName, nonexistent)); + [&] { DirectoryIterator bad_dir{nonexistent, directory_options::none}; }, typeName, nonexistent)); } // Test VSO-844835 "directory_iterator constructed with empty path iterates over the current directory" @@ -3030,9 +3027,8 @@ void test_locale_conversions() { const path p4(utf8_koshka_cat.begin(), utf8_koshka_cat.end(), utf8_locale); EXPECT(p4.native() == utf16_koshka_cat); - EXPECT(throws_system_error([&] { - (void) path{utf8_koshka_cat.begin() + 1, utf8_koshka_cat.end(), utf8_locale}; - })); + EXPECT( + throws_system_error([&] { (void) path{utf8_koshka_cat.begin() + 1, utf8_koshka_cat.end(), utf8_locale}; })); } } diff --git a/tests/std/tests/P0323R12_expected/test.cpp b/tests/std/tests/P0323R12_expected/test.cpp index 1c97c0092c3..bd318ada308 100644 --- a/tests/std/tests/P0323R12_expected/test.cpp +++ b/tests/std/tests/P0323R12_expected/test.cpp @@ -409,9 +409,9 @@ namespace test_expected { template struct payload_destructor { constexpr payload_destructor(bool& destructor_called) : _destructor_called(destructor_called) {} - // clang-format off - constexpr ~payload_destructor() requires (IsYes(triviallyDestructible)) = default; - // clang-format on + constexpr ~payload_destructor() + requires (IsYes(triviallyDestructible)) + = default; constexpr ~payload_destructor() { _destructor_called = true; } @@ -475,14 +475,14 @@ namespace test_expected { struct payload_constructors { payload_constructors() = default; // Note clang does not accept local variables in explicit - constexpr explicit(IsYes(explicitConstructible)) - payload_constructors(const convertible&) noexcept(should_be_noexcept) + constexpr explicit(IsYes(explicitConstructible)) payload_constructors(const convertible&) + noexcept(should_be_noexcept) : _val(3) {} - constexpr explicit(IsYes(explicitConstructible)) - payload_constructors(convertible&&) noexcept(should_be_noexcept) + constexpr explicit(IsYes(explicitConstructible)) payload_constructors(convertible&&) + noexcept(should_be_noexcept) : _val(42) {} - constexpr explicit(IsYes(explicitConstructible)) - payload_constructors(initializer_list&, convertible) noexcept(should_be_noexcept) + constexpr explicit(IsYes(explicitConstructible)) payload_constructors(initializer_list&, convertible) + noexcept(should_be_noexcept) : _val(1337) {} [[nodiscard]] constexpr bool operator==(const int val) const noexcept { @@ -2232,8 +2232,8 @@ void test_reinit_regression() { } } -// Defend against regression of llvm-project#59854, in which clang is confused -// by the explicit `noexcept` on `expected`'s destructors. +// Defend against regression of LLVM-59854, in which clang is confused by the +// explicit `noexcept` on `expected`'s destructors. struct Data { vector vec_; constexpr Data(initializer_list il) : vec_(il) {} diff --git a/tests/std/tests/P0355R7_calendars_and_time_zones_clocks/test.cpp b/tests/std/tests/P0355R7_calendars_and_time_zones_clocks/test.cpp index a0b24b0b320..09cb4b1f4b2 100644 --- a/tests/std/tests/P0355R7_calendars_and_time_zones_clocks/test.cpp +++ b/tests/std/tests/P0355R7_calendars_and_time_zones_clocks/test.cpp @@ -7,10 +7,12 @@ #include #include #include +#include #include #include #include +#include #include using namespace std; @@ -383,9 +385,8 @@ tzdb copy_tzdb() { const auto& my_tzdb = get_tzdb_list().front(); vector zones; vector links; - transform(my_tzdb.zones.begin(), my_tzdb.zones.end(), back_inserter(zones), [](const auto& tz) { - return time_zone{_Secret_time_zone_construct_tag{}, tz.name()}; - }); + transform(my_tzdb.zones.begin(), my_tzdb.zones.end(), back_inserter(zones), + [](const auto& tz) { return time_zone{_Secret_time_zone_construct_tag{}, tz.name()}; }); transform(my_tzdb.links.begin(), my_tzdb.links.end(), back_inserter(links), [](const auto& link) { return time_zone_link{_Secret_time_zone_link_construct_tag{}, link.name(), link.target()}; }); @@ -475,6 +476,63 @@ void test() { } } +// LWG-4139 "[time.zone.leap] recursive constraint in <=>" +namespace lwg_4139 { + struct conv_to_leap_second : local_t { + operator leap_second() const noexcept; + }; + + static_assert(equality_comparable == is_permissive); + static_assert(equality_comparable_with == is_permissive); + static_assert(totally_ordered == is_permissive); + static_assert(totally_ordered_with == is_permissive); + static_assert(three_way_comparable == is_permissive); + static_assert(three_way_comparable_with == is_permissive); + + using ref_leap_second = reference_wrapper; + + static_assert(equality_comparable); + static_assert(equality_comparable_with); + static_assert(totally_ordered); + static_assert(totally_ordered_with); + static_assert(three_way_comparable); + static_assert(three_way_comparable_with); + + template + concept can_equality_compare_with = requires(const remove_reference_t& t, const remove_reference_t& u) { + t == u; + t != u; + u == t; + u != t; + }; + + template + concept can_relation_compare_with = requires(const remove_reference_t& t, const remove_reference_t& u) { + t < u; + t > u; + t <= u; + t >= u; + u < t; + u > t; + u <= t; + u >= t; + }; + + template + concept can_three_way_compare_with = requires(const remove_reference_t& t, const remove_reference_t& u) { + t <=> u; + u <=> t; + }; + + static_assert(!can_equality_compare_with); + static_assert(!can_relation_compare_with); + static_assert(!can_three_way_compare_with); + + static_assert(can_equality_compare_with); + static_assert(can_relation_compare_with); + static_assert(can_three_way_compare_with); +} // namespace lwg_4139 + int main() { run_tz_test([] { test(); }); } diff --git a/tests/std/tests/P0355R7_calendars_and_time_zones_io/test.cpp b/tests/std/tests/P0355R7_calendars_and_time_zones_io/test.cpp index 64fbc3c2292..8b394ab63ce 100644 --- a/tests/std/tests/P0355R7_calendars_and_time_zones_io/test.cpp +++ b/tests/std/tests/P0355R7_calendars_and_time_zones_io/test.cpp @@ -921,9 +921,8 @@ tzdb copy_tzdb() { const auto& my_tzdb = get_tzdb_list().front(); vector zones; vector links; - transform(my_tzdb.zones.begin(), my_tzdb.zones.end(), back_inserter(zones), [](const auto& tz) { - return time_zone{_Secret_time_zone_construct_tag{}, tz.name()}; - }); + transform(my_tzdb.zones.begin(), my_tzdb.zones.end(), back_inserter(zones), + [](const auto& tz) { return time_zone{_Secret_time_zone_construct_tag{}, tz.name()}; }); transform(my_tzdb.links.begin(), my_tzdb.links.end(), back_inserter(links), [](const auto& link) { return time_zone_link{_Secret_time_zone_link_construct_tag{}, link.name(), link.target()}; }); diff --git a/tests/std/tests/P0448R4_spanstream/test.cpp b/tests/std/tests/P0448R4_spanstream/test.cpp index cf97ba7f317..77f69db28d8 100644 --- a/tests/std/tests/P0448R4_spanstream/test.cpp +++ b/tests/std/tests/P0448R4_spanstream/test.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include #include #include @@ -29,6 +31,28 @@ constexpr array input_std_array{'1', ' ', '2', ' ', '3', ' ', '4', ' ', '5'}; template <> inline constexpr array input_std_array{L'1', L' ', L'2', L' ', L'3', L' ', L'4', L' ', L'5'}; +template +list li{}; +// Neither sized_range nor contiguous_range. +template +struct SpecialRange { + auto begin() { + return std::begin(li); + } + auto end() { + return std::end(li); + } + operator span() const { + return span(input_view); + } +}; +template +constexpr bool ranges::enable_borrowed_range> = true; + +static_assert(!ranges::sized_range>); +static_assert(!ranges::contiguous_range>); +static_assert(ranges::borrowed_range>); + template class basic_test_buf : public Spanbuf { public: @@ -626,6 +650,30 @@ void test_ispanstream() { assert(static_cast(range_constructed.rdbuf())->epptr() == nullptr); } + { // GH-4879 : The span constructed by basic_ispanstream's range constructor may be ill-formed + const CharT buffer[17]{}; + span span_const_elem{buffer}; + basic_ispanstream span_const_elem_constructed{span_const_elem}; + assert(span_const_elem_constructed.span().data() == buffer); + assert(static_cast(span_const_elem_constructed.rdbuf())->eback() == buffer); + assert(static_cast(span_const_elem_constructed.rdbuf())->gptr() == buffer); + assert(static_cast(span_const_elem_constructed.rdbuf())->egptr() == end(buffer)); + assert(static_cast(span_const_elem_constructed.rdbuf())->pbase() == nullptr); + assert(static_cast(span_const_elem_constructed.rdbuf())->pptr() == nullptr); + assert(static_cast(span_const_elem_constructed.rdbuf())->epptr() == nullptr); + + SpecialRange special_range{}; + auto rr = static_cast>(special_range); + basic_ispanstream special_range_constructed{special_range}; + assert(special_range_constructed.span().data() == rr.data()); + assert(static_cast(special_range_constructed.rdbuf())->eback() == rr.data()); + assert(static_cast(special_range_constructed.rdbuf())->gptr() == rr.data()); + assert(static_cast(special_range_constructed.rdbuf())->egptr() == rr.data() + rr.size()); + assert(static_cast(special_range_constructed.rdbuf())->pbase() == nullptr); + assert(static_cast(special_range_constructed.rdbuf())->pptr() == nullptr); + assert(static_cast(special_range_constructed.rdbuf())->epptr() == nullptr); + } + { // span CharT buffer[10]; basic_ispanstream is{span{buffer}}; @@ -646,6 +694,14 @@ void test_ispanstream() { assert(is.span().data() == input_range.data()); assert(is.span().size() == input_range.size()); + // also test GH-4879 for basic_ispanstream::span(ROS&&) + is.span(span{other_buffer}); + assert(is.span().data() == other_buffer); + assert(is.span().size() == size(other_buffer)); + is.span(SpecialRange{}); + assert(is.span().data() == input_range.data()); + assert(is.span().size() == input_range.size()); + if constexpr (is_same_v) { const char const_buffer[] = "1 2 3 4 5"; basic_ispanstream is_const_buffer{span{const_buffer}}; diff --git a/tests/std/tests/P0645R10_text_formatting_formatting/test.cpp b/tests/std/tests/P0645R10_text_formatting_formatting/test.cpp index c6295a44c3e..0b0b569f1c4 100644 --- a/tests/std/tests/P0645R10_text_formatting_formatting/test.cpp +++ b/tests/std/tests/P0645R10_text_formatting_formatting/test.cpp @@ -1520,6 +1520,26 @@ void test_gh_4319() { assert(format(STR("{:}"), 12345678.0) == STR("12345678")); } +// GH-4320: : crash when formatting a floating-point value with #/L and a large precision +template +void test_gh_4320() { + assert( + format(STR("{:#.1075e}"), 1.0) + == STR( + "1." + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000e+00")); +} + void test() { test_simple_formatting(); test_simple_formatting(); @@ -1604,6 +1624,8 @@ void test() { test_gh_4319(); test_gh_4319(); + test_gh_4320(); + test_gh_4320(); } int main() { diff --git a/tests/std/tests/P0768R1_spaceship_cpos/test.cpp b/tests/std/tests/P0768R1_spaceship_cpos/test.cpp index 350f7ec1ec7..5dab6aa5265 100644 --- a/tests/std/tests/P0768R1_spaceship_cpos/test.cpp +++ b/tests/std/tests/P0768R1_spaceship_cpos/test.cpp @@ -76,8 +76,8 @@ namespace TestAdl { }; template - [[nodiscard]] constexpr strong_ordering strong_order( - const StrongType& left, const StrongType& right) noexcept(NE) { + [[nodiscard]] constexpr strong_ordering strong_order(const StrongType& left, const StrongType& right) + noexcept(NE) { return left.val <=> right.val; } @@ -97,8 +97,8 @@ namespace TestAdl { }; template - [[nodiscard]] constexpr partial_ordering partial_order( - const PartialType& left, const PartialType& right) noexcept(NE) { + [[nodiscard]] constexpr partial_ordering partial_order(const PartialType& left, const PartialType& right) + noexcept(NE) { return left.val <=> right.val; } } // namespace TestAdl @@ -173,9 +173,9 @@ struct Fallback { // I == 2: E == F is ill-formed. // I == 3: E == F returns int. // I == 4: E == F returns void. - // clang-format off - constexpr auto operator==(const Fallback& other) const noexcept(I != 1) requires (I != 2) { - // clang-format on + constexpr auto operator==(const Fallback& other) const noexcept(I != 1) + requires (I != 2) + { const bool result{val == other.val && val != UnorderedVal}; if constexpr (I == 3) { @@ -191,9 +191,9 @@ struct Fallback { // I == 6: E < F is ill-formed. // I == 7: E < F returns int. // I == 8: E < F returns void. - // clang-format off - constexpr auto operator<(const Fallback& other) const noexcept(I != 5) requires (I != 6) { - // clang-format on + constexpr auto operator<(const Fallback& other) const noexcept(I != 5) + requires (I != 6) + { const bool result{val < other.val && val != UnorderedVal && other.val != UnorderedVal}; if constexpr (I == 7) { @@ -206,17 +206,17 @@ struct Fallback { } // I == 9: F < E is ill-formed. - // clang-format off - constexpr bool operator<(Fallback&) const noexcept requires (I == 9) = delete; - // clang-format on + constexpr bool operator<(Fallback&) const noexcept + requires (I == 9) + = delete; // I == 10: F < E can throw. // I == 11: F < E returns int. // I == 12: F < E returns void. // I == 13: F < E returns bool. - // clang-format off - constexpr auto operator<(Fallback& other) const noexcept(I != 10) requires (I >= 10 && I <= 13) { - // clang-format on + constexpr auto operator<(Fallback& other) const noexcept(I != 10) + requires (I >= 10 && I <= 13) + { const bool result{val < other.val && val != UnorderedVal && other.val != UnorderedVal}; if constexpr (I == 11) { diff --git a/tests/std/tests/P0896R4_ranges_alg_find_first_of/test.cpp b/tests/std/tests/P0896R4_ranges_alg_find_first_of/test.cpp index 6f3ede0113c..02e891e71bd 100644 --- a/tests/std/tests/P0896R4_ranges_alg_find_first_of/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_find_first_of/test.cpp @@ -73,8 +73,8 @@ int main() { #else // ^^^ test all range combinations / test only interesting range combos vvv constexpr bool run_tests() { // The algorithm is oblivious to anything except maybe proxies so take the bare minimum input/forward range - using in_test_range = test::range; + using in_test_range = test::range; using fwd_test_range = test::range; diff --git a/tests/std/tests/P0896R4_ranges_alg_inplace_merge/test.cpp b/tests/std/tests/P0896R4_ranges_alg_inplace_merge/test.cpp index bb0314722b4..3a9f6a495a4 100644 --- a/tests/std/tests/P0896R4_ranges_alg_inplace_merge/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_inplace_merge/test.cpp @@ -4,9 +4,11 @@ #include #include #include +#include #include #include #include +#include #include @@ -56,6 +58,26 @@ struct instantiator { } }; +// Test GH-4863: : ranges::inplace_merge doesn't seem to be able to utilize ranges::upper_bound +void test_gh_4863() { // COMPILE-ONLY + { + vector v; + auto cmp = [](int&, int&) { return false; }; + ranges::sort(v, cmp); + ranges::inplace_merge(v, v.begin(), cmp); + } + { + struct S { + operator nullptr_t() { + return nullptr; + } + }; + vector v; + auto cmp = [](const nullptr_t&, const nullptr_t&) { return false; }; + ranges::inplace_merge(v, v.begin(), cmp, [](int) { return S{}; }); + } +} + int main() { test_bidi(); } diff --git a/tests/std/tests/P0896R4_ranges_alg_is_permutation/test.cpp b/tests/std/tests/P0896R4_ranges_alg_is_permutation/test.cpp index c10fd58c638..8c20e4f0662 100644 --- a/tests/std/tests/P0896R4_ranges_alg_is_permutation/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_is_permutation/test.cpp @@ -131,8 +131,7 @@ struct instantiator { assert(!ranges::is_permutation(r1, r2)); assert(!ranges::is_permutation(r1, r2, {}, {}, [](int n) { return n - 1; })); assert(ranges::is_permutation(r1, r2, {}, {}, [](int n) { return n - 2; })); - assert(ranges::is_permutation( - r1, r2, {}, [](int n) { return n + 1; }, [](int n) { return n - 1; })); + assert(ranges::is_permutation(r1, r2, {}, [](int n) { return n + 1; }, [](int n) { return n - 1; })); } { // Test GH-2888: ``: `ranges::is_permutation`'s helper lambda does not specify return type struct NonCopyableBool { diff --git a/tests/std/tests/P0896R4_ranges_alg_partition_copy/test.cpp b/tests/std/tests/P0896R4_ranges_alg_partition_copy/test.cpp index b48007bfb7e..3af2b9d04d5 100644 --- a/tests/std/tests/P0896R4_ranges_alg_partition_copy/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_partition_copy/test.cpp @@ -74,8 +74,7 @@ struct partition_copy_test { ranges::fill(dest, P{-1, 13}); const R range{source}; - auto result = partition_copy( - range, O1{dest}, O2{dest + i}, [i](int x) { return x < i; }, get_first); + auto result = partition_copy(range, O1{dest}, O2{dest + i}, [i](int x) { return x < i; }, get_first); assert(result.in == range.end()); assert(result.out1.peek() == dest + i); assert(result.out2.peek() == dest + N); diff --git a/tests/std/tests/P0896R4_ranges_alg_search/test.cpp b/tests/std/tests/P0896R4_ranges_alg_search/test.cpp index 78fa57aff2f..cb860bfc05b 100644 --- a/tests/std/tests/P0896R4_ranges_alg_search/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_search/test.cpp @@ -159,8 +159,8 @@ constexpr bool run_tests() { { // Validate the memcmp optimization const int haystack[] = {1, 2, 3, 1, 2, 3, 1, 2, 3}; - const int needle[] = {1, 2, 3}; - const auto result = ranges::search(span{haystack}, needle); + const int needle[] = {1, 2, 3}; + const auto result = ranges::search(span{haystack}, needle); static_assert(same_as::iterator>>); assert(to_address(result.begin()) == haystack + 0); assert(to_address(result.end()) == haystack + 3); diff --git a/tests/std/tests/P0896R4_ranges_alg_uninitialized_copy/test.cpp b/tests/std/tests/P0896R4_ranges_alg_uninitialized_copy/test.cpp index fb707534e15..0c05bcbc0cf 100644 --- a/tests/std/tests/P0896R4_ranges_alg_uninitialized_copy/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_uninitialized_copy/test.cpp @@ -271,7 +271,7 @@ struct memcpy_test { template using test_input = test::range; + test::CanCompare::no, IsProxy>; using test_output = test::range; diff --git a/tests/std/tests/P0896R4_ranges_alg_uninitialized_copy_n/test.cpp b/tests/std/tests/P0896R4_ranges_alg_uninitialized_copy_n/test.cpp index 92d00374795..a21e074f572 100644 --- a/tests/std/tests/P0896R4_ranges_alg_uninitialized_copy_n/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_uninitialized_copy_n/test.cpp @@ -235,7 +235,7 @@ struct memcpy_test { template using test_input = test::range; + test::CanCompare::no, IsProxy>; using test_output = test::range; diff --git a/tests/std/tests/P0896R4_ranges_alg_uninitialized_move/test.cpp b/tests/std/tests/P0896R4_ranges_alg_uninitialized_move/test.cpp index dc5b5b6af74..8c9e27af3b1 100644 --- a/tests/std/tests/P0896R4_ranges_alg_uninitialized_move/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_uninitialized_move/test.cpp @@ -261,7 +261,7 @@ struct memcpy_test { template using test_input = test::range; + test::CanCompare::no, IsProxy>; using test_output = test::range; diff --git a/tests/std/tests/P0896R4_ranges_alg_uninitialized_move_n/test.cpp b/tests/std/tests/P0896R4_ranges_alg_uninitialized_move_n/test.cpp index e0bd3f4ba43..5878d39727d 100644 --- a/tests/std/tests/P0896R4_ranges_alg_uninitialized_move_n/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_uninitialized_move_n/test.cpp @@ -236,7 +236,7 @@ struct memcpy_test { template using test_input = test::range; + test::CanCompare::no, IsProxy>; using test_output = test::range; diff --git a/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp b/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp index 9814bc4feb6..82706244678 100644 --- a/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp +++ b/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp @@ -1227,13 +1227,11 @@ namespace iterator_cust_swap_test { // N4928 [iterator.cust.swap]/4.3: "Otherwise, if the types T1 and T2 of E1 and E2 model // indirectly_movable_storable and indirectly_movable_storable..." - // clang-format off template - concept bullet3 = !bullet1 && !bullet2 && indirectly_movable_storable - && indirectly_movable_storable; + concept bullet3 = + !bullet1 && !bullet2 && indirectly_movable_storable && indirectly_movable_storable; static_assert(bullet3 && can_iter_swap); - // clang-format on template struct unswap_proxy_ref { @@ -1281,9 +1279,7 @@ namespace iterator_cust_swap_test { static_assert(false); } - // clang-format off static_assert(bullet2 && can_iter_swap); - // clang-format on constexpr bool test() { { diff --git a/tests/std/tests/P0896R4_ranges_to_address/test.cpp b/tests/std/tests/P0896R4_ranges_to_address/test.cpp index 0e737e2286a..d0275b434d3 100644 --- a/tests/std/tests/P0896R4_ranges_to_address/test.cpp +++ b/tests/std/tests/P0896R4_ranges_to_address/test.cpp @@ -112,10 +112,9 @@ int main(int argc, char* argv[]) { test_positive_cases, false>(); }); - // clang-format off #if _ITERATOR_DEBUG_LEVEL != 0 exec.add_death_tests({ - // Tests for only vector: basic_string doesn't invalidate on element creation/destruction because POD. + // Tests for only vector: basic_string doesn't invalidate on element creation/destruction because POD. #if _ITERATOR_DEBUG_LEVEL == 2 test_invalidated_by_pop_back, false>, test_invalidated_by_pop_back, true>, @@ -134,7 +133,6 @@ int main(int argc, char* argv[]) { test_out_of_range, true>, }); #endif // _ITERATOR_DEBUG_LEVEL != 0 - // clang-format on return exec.run(argc, argv); } diff --git a/tests/std/tests/P0896R4_views_counted/test.cpp b/tests/std/tests/P0896R4_views_counted/test.cpp index c1ee0c5f498..a033fb72643 100644 --- a/tests/std/tests/P0896R4_views_counted/test.cpp +++ b/tests/std/tests/P0896R4_views_counted/test.cpp @@ -10,13 +10,9 @@ using namespace std; -// clang-format off template concept Countable = requires { typename iter_difference_t>; } - && requires(I&& i, iter_difference_t> n) { - views::counted(forward(i), n); - }; -// clang-format on + && requires(I&& i, iter_difference_t> n) { views::counted(forward(i), n); }; template struct convertible_difference { diff --git a/tests/std/tests/P0896R4_views_lazy_split/test.cpp b/tests/std/tests/P0896R4_views_lazy_split/test.cpp index ccbbfe4f358..e2aa5b8664e 100644 --- a/tests/std/tests/P0896R4_views_lazy_split/test.cpp +++ b/tests/std/tests/P0896R4_views_lazy_split/test.cpp @@ -56,7 +56,7 @@ constexpr void test_one(Base&& base, Delimiter&& delimiter, Expected&& expected) static_assert(CanViewLazySplit == (!is_view || copy_constructible>) ); if constexpr (CanViewLazySplit) { // Validate lvalue constexpr bool is_noexcept = - (!is_view || is_nothrow_copy_constructible_v>) &&is_nothrow_copy_constructible_v; + (!is_view || is_nothrow_copy_constructible_v>) && is_nothrow_copy_constructible_v; static_assert(same_as); static_assert(noexcept(views::lazy_split(base, delimiter)) == is_noexcept); diff --git a/tests/std/tests/P0896R4_views_split/test.cpp b/tests/std/tests/P0896R4_views_split/test.cpp index 2d0bcd18d80..2534520a7e9 100644 --- a/tests/std/tests/P0896R4_views_split/test.cpp +++ b/tests/std/tests/P0896R4_views_split/test.cpp @@ -58,7 +58,7 @@ constexpr void test_one(Base&& base, Delimiter&& delimiter, Expected&& expected) static_assert(CanViewSplit == (!is_view || copy_constructible>) ); if constexpr (CanViewSplit) { // Validate lvalue constexpr bool is_noexcept = - (!is_view || is_nothrow_copy_constructible_v>) &&is_nothrow_copy_constructible_v; + (!is_view || is_nothrow_copy_constructible_v>) && is_nothrow_copy_constructible_v; static_assert(same_as); static_assert(noexcept(views::split(base, delimiter)) == is_noexcept); diff --git a/tests/std/tests/P0896R4_views_transform/test.cpp b/tests/std/tests/P0896R4_views_transform/test.cpp index 0d0dd04bc63..eb2c729102d 100644 --- a/tests/std/tests/P0896R4_views_transform/test.cpp +++ b/tests/std/tests/P0896R4_views_transform/test.cpp @@ -180,7 +180,7 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) { } } - static_assert(CanMemberEmpty == ((sized_range || forward_range) &&const_invocable)); + static_assert(CanMemberEmpty == ((sized_range || forward_range) && const_invocable)); static_assert(CanBool == CanEmpty); if constexpr (CanMemberEmpty) { assert(as_const(r).empty() == is_empty); diff --git a/tests/std/tests/P0898R3_concepts/invocable_cc.hpp b/tests/std/tests/P0898R3_concepts/invocable_cc.hpp index c9846f969cc..fdafd627ff7 100644 --- a/tests/std/tests/P0898R3_concepts/invocable_cc.hpp +++ b/tests/std/tests/P0898R3_concepts/invocable_cc.hpp @@ -554,8 +554,8 @@ void NAME() { static_assert(test()); using PMF0RR = int (MCALLCONV S::*)()&&; - using PMF1RR = int* (MCALLCONV S::*) (long) &&; - using PMF2RR = int& (MCALLCONV S::*) (long, int) &&; + using PMF1RR = int* (MCALLCONV S::*) (long)&&; + using PMF2RR = int& (MCALLCONV S::*) (long, int)&&; using PMF1PRR = int const& (S::*) (int, ...)&&; static_assert(test()); static_assert(!test()); diff --git a/tests/std/tests/P0898R3_concepts/test.cpp b/tests/std/tests/P0898R3_concepts/test.cpp index 22b6dd0cddf..86aa9df97d1 100644 --- a/tests/std/tests/P0898R3_concepts/test.cpp +++ b/tests/std/tests/P0898R3_concepts/test.cpp @@ -3323,7 +3323,7 @@ namespace test_relation { struct Equivalent { template - constexpr decltype(auto) operator()(T && t, U && u) const + constexpr decltype(auto) operator()(T&& t, U&& u) const requires requires { static_cast(t) == static_cast(u); } { return static_cast(t) == static_cast(u); diff --git a/tests/std/tests/P1169R4_static_call_operator/test.compile.pass.cpp b/tests/std/tests/P1169R4_static_call_operator/test.compile.pass.cpp index 47b6bcd6374..ecd82ea1de6 100644 --- a/tests/std/tests/P1169R4_static_call_operator/test.compile.pass.cpp +++ b/tests/std/tests/P1169R4_static_call_operator/test.compile.pass.cpp @@ -43,10 +43,8 @@ void test_ctad() { static_assert(is_same_v>); static_assert(is_same_v>); -#if !(defined(__clang__) && defined(_M_IX86)) // TRANSITION, LLVM-62594, fixed in Clang 18 auto lambda = [](int* p, int** q) static { return *p + **q; }; static_assert(is_same_v>); -#endif // ^^^ no workaround ^^^ } void all_tests() { diff --git a/tests/std/tests/P1206R7_ranges_to_mappish/test.cpp b/tests/std/tests/P1206R7_ranges_to_mappish/test.cpp index 6ba6e3fa3bb..6fdf75de288 100644 --- a/tests/std/tests/P1206R7_ranges_to_mappish/test.cpp +++ b/tests/std/tests/P1206R7_ranges_to_mappish/test.cpp @@ -156,11 +156,13 @@ struct mappish_instantiator { assert(c5.get_allocator().state == 13); assert(ranges::is_permutation(c5, expected, any_pair_eq)); } +#if defined(_MSVC_INTERNAL_TESTING) || !defined(__EDG__) // TRANSITION, VS 17.12p3 { std::same_as auto c6 = R{some_pairs} | ranges::to(Alloc{13}); assert(c6.get_allocator().state == 13); assert(ranges::is_permutation(c6, expected, any_pair_eq)); } +#endif // ^^^ no workaround ^^^ { std::same_as auto c7 = R{some_pairs} | ranges::to(Alloc{13}); assert(c7.get_allocator().state == 13); diff --git a/tests/std/tests/P1206R7_ranges_to_misc/test.cpp b/tests/std/tests/P1206R7_ranges_to_misc/test.cpp index 0e433f419a4..d7e9bde2781 100644 --- a/tests/std/tests/P1206R7_ranges_to_misc/test.cpp +++ b/tests/std/tests/P1206R7_ranges_to_misc/test.cpp @@ -54,6 +54,7 @@ struct reservable { }; constexpr bool test_reservable() { +#if defined(_MSVC_INTERNAL_TESTING) || !defined(__EDG__) // TRANSITION, VS 17.12p3 int some_ints[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; { std::same_as auto r = some_ints | ranges::to(secret_key); @@ -61,6 +62,7 @@ constexpr bool test_reservable() { assert(r.cap_ == ranges::size(some_ints)); assert(r.reserved_ == ranges::size(some_ints)); } +#endif // ^^^ no workaround ^^^ return true; } @@ -91,12 +93,14 @@ constexpr bool test_common_constructible() { assert(c0.last_ == ranges::end(some_ints)); assert(c0.args_ == 3); } +#if defined(_MSVC_INTERNAL_TESTING) || !defined(__EDG__) // TRANSITION, VS 17.12p3 { std::same_as auto c1 = some_ints | ranges::to(secret_key); assert(c1.first_ == ranges::begin(some_ints)); assert(c1.last_ == ranges::end(some_ints)); assert(c1.args_ == 3); } +#endif // ^^^ no workaround ^^^ // Verify that more than one argument can be passed after the range: { @@ -105,12 +109,14 @@ constexpr bool test_common_constructible() { assert(c2.last_ == ranges::end(some_ints)); assert(c2.args_ == 4); } +#if defined(_MSVC_INTERNAL_TESTING) || !defined(__EDG__) // TRANSITION, VS 17.12p3 { std::same_as auto c3 = some_ints | ranges::to(secret_key, 3.14); assert(c3.first_ == ranges::begin(some_ints)); assert(c3.last_ == ranges::end(some_ints)); assert(c3.args_ == 4); } +#endif // ^^^ no workaround ^^^ return true; } @@ -233,8 +239,8 @@ class restricted_vector : private std::vector { constexpr restricted_vector(const size_type n, const T& val, const A& alloc = A()) : base_type(n, val, alloc) {} constexpr restricted_vector(const std::initializer_list il, const A& alloc = A()) : base_type(il, alloc) {} constexpr restricted_vector(const restricted_vector& other, const A& alloc) : base_type(other, alloc) {} - constexpr restricted_vector(restricted_vector&& other, const A& alloc) noexcept( - std::allocator_traits::is_always_equal::value) + constexpr restricted_vector(restricted_vector&& other, const A& alloc) + noexcept(std::allocator_traits::is_always_equal::value) : base_type(std::move(other), alloc) {} using base_type::begin; @@ -296,6 +302,7 @@ constexpr void test_lwg4016_per_kind() { std::same_as auto vec = std::views::iota(0, 42) | ranges::to(); assert(ranges::equal(vec, std::views::iota(0, 42))); } +#if defined(_MSVC_INTERNAL_TESTING) || !defined(__EDG__) // TRANSITION, VS 17.12p3 { std::same_as auto vec = std::views::iota(0, 42) | ranges::to(std::allocator{}); assert(ranges::equal(vec, std::views::iota(0, 42))); @@ -308,6 +315,7 @@ constexpr void test_lwg4016_per_kind() { std::same_as auto vec = std::views::empty | ranges::to(std::size_t{42}, std::allocator{}); assert(ranges::equal(vec, std::views::repeat(0, 42))); } +#endif // ^^^ no workaround ^^^ { std::same_as auto vec = ranges::to(std::views::iota(0, 42), std::initializer_list{-3, -2, -1}); assert(ranges::equal(vec, std::views::iota(-3, 42))); diff --git a/tests/std/tests/P1206R7_ranges_to_sequence/test.cpp b/tests/std/tests/P1206R7_ranges_to_sequence/test.cpp index 9ee7894d9f7..acb190e9c01 100644 --- a/tests/std/tests/P1206R7_ranges_to_sequence/test.cpp +++ b/tests/std/tests/P1206R7_ranges_to_sequence/test.cpp @@ -145,11 +145,13 @@ struct sequence_instantiator { assert(c5.get_allocator().state == 13); assert(ranges::equal(c5, meow)); } +#if defined(_MSVC_INTERNAL_TESTING) || !defined(__EDG__) // TRANSITION, VS 17.12p3 { std::same_as auto c6 = R{meow} | ranges::to(Alloc{13}); assert(c6.get_allocator().state == 13); assert(ranges::equal(c6, meow)); } +#endif // ^^^ no workaround ^^^ { std::same_as auto c7 = R{meow} | ranges::to(Alloc{13}); assert(c7.get_allocator().state == 13); diff --git a/tests/std/tests/P1206R7_ranges_to_settish/test.cpp b/tests/std/tests/P1206R7_ranges_to_settish/test.cpp index df56e6fccc5..71c733e486b 100644 --- a/tests/std/tests/P1206R7_ranges_to_settish/test.cpp +++ b/tests/std/tests/P1206R7_ranges_to_settish/test.cpp @@ -150,11 +150,13 @@ struct settish_instantiator { assert(c5.get_allocator().state == 13); assert(ranges::is_permutation(c5, expected)); } +#if defined(_MSVC_INTERNAL_TESTING) || !defined(__EDG__) // TRANSITION, VS 17.12p3 { std::same_as auto c6 = R{some_ints} | ranges::to(Alloc{13}); assert(c6.get_allocator().state == 13); assert(ranges::is_permutation(c6, expected)); } +#endif // ^^^ no workaround ^^^ { std::same_as auto c7 = R{some_ints} | ranges::to(Alloc{13}); assert(c7.get_allocator().state == 13); diff --git a/tests/std/tests/P1208R6_source_location/env.lst b/tests/std/tests/P1208R6_source_location/env.lst index 351a8293d9d..0cd551077fa 100644 --- a/tests/std/tests/P1208R6_source_location/env.lst +++ b/tests/std/tests/P1208R6_source_location/env.lst @@ -2,3 +2,6 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception RUNALL_INCLUDE ..\usual_20_matrix.lst +RUNALL_CROSSLIST +* PM_CL="" +* PM_CL="/D_USE_DETAILED_FUNCTION_NAME_IN_SOURCE_LOCATION=0" diff --git a/tests/std/tests/P1208R6_source_location/header.h b/tests/std/tests/P1208R6_source_location/header.h index 3369da4d637..36eb6bfcced 100644 --- a/tests/std/tests/P1208R6_source_location/header.h +++ b/tests/std/tests/P1208R6_source_location/header.h @@ -18,7 +18,11 @@ constexpr void header_test() { assert(x.column() == 37); #endif // ^^^ C1XX ^^^ #if _USE_DETAILED_FUNCTION_NAME_IN_SOURCE_LOCATION +#ifdef __EDG__ + assert(x.function_name() == "void header_test()"sv); +#else // ^^^ EDG / Other vvv assert(x.function_name() == "void __cdecl header_test(void)"sv); +#endif // ^^^ Other ^^^ #else // ^^^ detailed / basic vvv assert(x.function_name() == "header_test"sv); #endif // ^^^ basic ^^^ diff --git a/tests/std/tests/P1208R6_source_location/test.cpp b/tests/std/tests/P1208R6_source_location/test.cpp index 99d8da815af..e578bcd620c 100644 --- a/tests/std/tests/P1208R6_source_location/test.cpp +++ b/tests/std/tests/P1208R6_source_location/test.cpp @@ -68,7 +68,11 @@ constexpr void local_test() { assert(x.column() == 37); #endif // ^^^ C1XX ^^^ #if _USE_DETAILED_FUNCTION_NAME_IN_SOURCE_LOCATION +#ifdef __EDG__ + assert(x.function_name() == "void local_test()"sv); +#else // ^^^ EDG / Other vvv assert(x.function_name() == "void __cdecl local_test(void)"sv); +#endif // ^^^ Other ^^^ #else // ^^^ detailed / basic vvv assert(x.function_name() == "local_test"sv); #endif // ^^^ basic ^^^ @@ -80,7 +84,11 @@ constexpr void argument_test( assert(x.line() == line); assert(x.column() == column); #if _USE_DETAILED_FUNCTION_NAME_IN_SOURCE_LOCATION +#ifdef __EDG__ + assert(x.function_name() == "bool test()"sv); +#else // ^^^ EDG / Other vvv assert(x.function_name() == "bool __cdecl test(void)"sv); +#endif // ^^^ Other ^^^ #else // ^^^ detailed / basic vvv assert(x.function_name() == "test"sv); #endif // ^^^ basic ^^^ @@ -102,10 +110,21 @@ constexpr void sloc_constructor_test() { } else #endif // ^^^ workaround ^^^ { +#ifdef __EDG__ + assert(x.loc.function_name() == "void sloc_constructor_test()"sv); +#else // ^^^ EDG / Other vvv assert(x.loc.function_name() == "void __cdecl sloc_constructor_test(void)"sv); +#endif // ^^^ Other ^^^ } #else // ^^^ detailed / basic vvv - assert(x.loc.function_name() == "sloc_constructor_test"sv); +#if !defined(__clang__) && !defined(__EDG__) // TRANSITION, VSO-1285783 + if (is_constant_evaluated()) { + assert(x.loc.function_name() == "main"sv); + } else +#endif // ^^^ workaround ^^^ + { + assert(x.loc.function_name() == "sloc_constructor_test"sv); + } #endif // ^^^ basic ^^^ assert(string_view{x.loc.file_name()}.ends_with(test_cpp)); } @@ -121,7 +140,11 @@ constexpr void different_constructor_test() { assert(x.loc.column() == 5); #endif // ^^^ C1XX ^^^ #if _USE_DETAILED_FUNCTION_NAME_IN_SOURCE_LOCATION +#ifdef __EDG__ + assert(x.loc.function_name() == "s::s(int)"sv); +#else // ^^^ EDG / Other vvv assert(x.loc.function_name() == THISCALL_OR_CDECL " s::s(int)"sv); +#endif // ^^^ Other ^^^ #else // ^^^ detailed / basic vvv assert(x.loc.function_name() == "s"sv); #endif // ^^^ basic ^^^ @@ -143,10 +166,21 @@ constexpr void sub_member_test() { } else #endif // ^^^ workaround ^^^ { +#ifdef __EDG__ + assert(s.x.loc.function_name() == "void sub_member_test()"sv); +#else // ^^^ EDG / Other vvv assert(s.x.loc.function_name() == "void __cdecl sub_member_test(void)"sv); +#endif // ^^^ Other ^^^ } #else // ^^^ detailed / basic vvv - assert(s.x.loc.function_name() == "sub_member_test"sv); +#if !defined(__clang__) && !defined(__EDG__) // TRANSITION, VSO-1285783 + if (is_constant_evaluated()) { + assert(s.x.loc.function_name() == "main"sv); + } else +#endif // ^^^ workaround ^^^ + { + assert(s.x.loc.function_name() == "sub_member_test"sv); + } #endif // ^^^ basic ^^^ assert(string_view{s.x.loc.file_name()}.ends_with(test_cpp)); @@ -160,7 +194,11 @@ constexpr void sub_member_test() { assert(s_i.x.loc.column() == 5); #endif // ^^^ C1XX ^^^ #if _USE_DETAILED_FUNCTION_NAME_IN_SOURCE_LOCATION +#ifdef __EDG__ + assert(s_i.x.loc.function_name() == "s2::s2(int)"sv); +#else // ^^^ EDG / Other vvv assert(s_i.x.loc.function_name() == THISCALL_OR_CDECL " s2::s2(int)"sv); +#endif // ^^^ Other ^^^ #else // ^^^ detailed / basic vvv assert(s_i.x.loc.function_name() == "s2"sv); #endif // ^^^ basic ^^^ @@ -185,19 +223,29 @@ constexpr void lambda_test() { assert(x2.column() == 50); #endif // ^^^ C1XX ^^^ #if _USE_DETAILED_FUNCTION_NAME_IN_SOURCE_LOCATION +#ifdef __EDG__ + assert(x1.function_name() == "void lambda_test()"sv); +#else // ^^^ EDG / Other vvv assert(x1.function_name() == "void __cdecl lambda_test(void)"sv); +#endif // ^^^ Other ^^^ #else // ^^^ detailed / basic vvv assert(x1.function_name() == "lambda_test"sv); #endif // ^^^ basic ^^^ const string_view fun2{x2.function_name()}; #if !_USE_DETAILED_FUNCTION_NAME_IN_SOURCE_LOCATION +#if !defined(__clang__) && !defined(__EDG__) + assert(fun2 == "operator ()"sv); +#else // ^^^ C1XX / Other vvv assert(fun2 == "operator()"sv); +#endif // ^^^ Other ^^^ #elif defined(__clang__) // ^^^ basic / detailed Clang vvv assert(fun2 == "auto " THISCALL_OR_CDECL " lambda_test()::(anonymous class)::operator()(void) const"sv); -#else // ^^^ detailed Clang / detailed non-Clang vvv +#elif defined(__EDG__) // ^^^ detailed Clang / detailed __EDG__ vvv + assert(fun2 == "lambda []()->auto::operator()()->auto"sv); +#else // ^^^ detailed __EDG__ / detailed C1XX vvv assert(fun2.starts_with("struct std::source_location " THISCALL_OR_CDECL " lambda_test::()"sv); +#else // ^^^ detailed __EDG__ / detailed C1XX vvv assert(x1.function_name() == "struct std::source_location __cdecl function_template(void)"sv); -#endif // ^^^ detailed non-Clang ^^^ +#endif // ^^^ detailed C1XX ^^^ assert(string_view{x1.file_name()}.ends_with(test_cpp)); const auto x2 = function_template(); @@ -233,9 +283,11 @@ constexpr void function_template_test() { assert(x2.function_name() == "function_template"sv); #elif defined(__clang__) // ^^^ basic / detailed Clang vvv assert(x2.function_name() == "source_location __cdecl function_template(void) [T = int]"sv); -#else // ^^^ detailed Clang / detailed non-Clang vvv +#elif defined(__EDG__) // ^^^ detailed Clang / detailed __EDG__ vvv + assert(x2.function_name() == "std::source_location function_template()"sv); +#else // ^^^ detailed __EDG__ / detailed C1XX vvv assert(x2.function_name() == "struct std::source_location __cdecl function_template(void)"sv); -#endif // ^^^ detailed non-Clang ^^^ +#endif // ^^^ detailed C1XX ^^^ assert(string_view{x1.file_name()} == string_view{x2.file_name()}); } diff --git a/tests/std/tests/P1645R1_constexpr_numeric/test.cpp b/tests/std/tests/P1645R1_constexpr_numeric/test.cpp index e557580f550..8a5842a193e 100644 --- a/tests/std/tests/P1645R1_constexpr_numeric/test.cpp +++ b/tests/std/tests/P1645R1_constexpr_numeric/test.cpp @@ -11,21 +11,21 @@ using namespace std; struct not_std_plus { template - constexpr decltype(auto) operator()(T && t, U && u) const { + constexpr decltype(auto) operator()(T&& t, U&& u) const { return forward(t) + forward(u); } }; struct not_std_minus { template - constexpr decltype(auto) operator()(T && t, U && u) const { + constexpr decltype(auto) operator()(T&& t, U&& u) const { return forward(t) - forward(u); } }; struct not_std_multiplies { template - constexpr decltype(auto) operator()(T && t, U && u) const { + constexpr decltype(auto) operator()(T&& t, U&& u) const { return forward(t) * forward(u); } }; diff --git a/tests/std/tests/P2093R14_formatted_output/test.cpp b/tests/std/tests/P2093R14_formatted_output/test.cpp index 0cf92243096..d8944462de2 100644 --- a/tests/std/tests/P2093R14_formatted_output/test.cpp +++ b/tests/std/tests/P2093R14_formatted_output/test.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/std/tests/P2136R3_invoke_r/test.cpp b/tests/std/tests/P2136R3_invoke_r/test.cpp index 06f36ce8ed9..4da180d46a0 100644 --- a/tests/std/tests/P2136R3_invoke_r/test.cpp +++ b/tests/std/tests/P2136R3_invoke_r/test.cpp @@ -6,8 +6,6 @@ #include #include -#include - using namespace std; constexpr int square(int n) { @@ -50,9 +48,10 @@ constexpr bool test_invoke_r() { static_assert(is_same_v); static_assert(is_void_v(square, 1))>); - // TRANSITION, DevCom-1457457 - static_assert(noexcept(invoke_r(square, 3)) == is_permissive); - static_assert(noexcept(invoke(square, 3)) == is_permissive); +#if defined(_MSVC_INTERNAL_TESTING) || defined(__clang__) || defined(__EDG__) // TRANSITION, vs17.12p3 + static_assert(!noexcept(invoke_r(square, 3))); + static_assert(!noexcept(invoke(square, 3))); +#endif // ^^^ no workaround ^^^ constexpr bool has_noexcept_in_type = #ifdef __cpp_noexcept_function_type diff --git a/tests/std/tests/P2286R8_text_formatting_range_formatter/test.cpp b/tests/std/tests/P2286R8_text_formatting_range_formatter/test.cpp index a0f9d987226..38652a1fa63 100644 --- a/tests/std/tests/P2286R8_text_formatting_range_formatter/test.cpp +++ b/tests/std/tests/P2286R8_text_formatting_range_formatter/test.cpp @@ -44,9 +44,12 @@ struct std::formatter struct std::formatter, CharT> { +private: + formatter, CharT> underlying; + public: constexpr void set_debug_format() - requires requires { this->underlying.set_debug_format(); } + requires requires { underlying.set_debug_format(); } { underlying.set_debug_format(); } @@ -60,9 +63,6 @@ struct std::formatter, CharT> { auto format(const test::proxy_reference& proxy, FormatContext& ctx) const { return underlying.format(static_cast(proxy), ctx); } - -private: - formatter, CharT> underlying; }; struct FormatAsX {}; diff --git a/tests/std/tests/P2286R8_text_formatting_tuple/test.cpp b/tests/std/tests/P2286R8_text_formatting_tuple/test.cpp index 40e2c366df9..d5d11895780 100644 --- a/tests/std/tests/P2286R8_text_formatting_tuple/test.cpp +++ b/tests/std/tests/P2286R8_text_formatting_tuple/test.cpp @@ -379,17 +379,15 @@ void run_tests(TestFunction check, ExceptionTest check_exception) { test_escaping(check, make_tuple(CharT('*'), STR(""))); // Test const ref-qualified types. - // clang-format off - check(SV("(42)"), SV("{}"), tuple< int >{42}); - check(SV("(42)"), SV("{}"), tuple{42}); + check(SV("(42)"), SV("{}"), tuple{42}); + check(SV("(42)"), SV("{}"), tuple{42}); int answer = 42; - check(SV("(42)"), SV("{}"), tuple< int& >{answer}); - check(SV("(42)"), SV("{}"), tuple{answer}); + check(SV("(42)"), SV("{}"), tuple{answer}); + check(SV("(42)"), SV("{}"), tuple{answer}); - check(SV("(42)"), SV("{}"), tuple< int&&>{42}); + check(SV("(42)"), SV("{}"), tuple{42}); check(SV("(42)"), SV("{}"), tuple{42}); - // clang-format on } template diff --git a/tests/std/tests/P2321R2_views_zip/test.cpp b/tests/std/tests/P2321R2_views_zip/test.cpp index 4de54111c03..5f370874c83 100644 --- a/tests/std/tests/P2321R2_views_zip/test.cpp +++ b/tests/std/tests/P2321R2_views_zip/test.cpp @@ -703,7 +703,7 @@ class instantiator_impl : private range_type_solver { using differing_size_member_range_type = range_type; using differing_is_common_range_type = range_type; + (IsCommon == test::Common::yes ? test::Common::no : test::Common::yes), Diff>; using differing_iterator_sentinel_diff_range_type = range_type; diff --git a/tests/std/tests/P2321R2_views_zip_transform/test.cpp b/tests/std/tests/P2321R2_views_zip_transform/test.cpp index c48172ab605..dd08fcb1b90 100644 --- a/tests/std/tests/P2321R2_views_zip_transform/test.cpp +++ b/tests/std/tests/P2321R2_views_zip_transform/test.cpp @@ -139,8 +139,8 @@ constexpr bool validate_iterators_sentinels( if constexpr (ranges::forward_range) { same_as> auto duplicate_itr = itr++; assert(*duplicate_itr == *ranges::begin(transformed_elements)); - static_assert(noexcept(itr++) - == is_nothrow_copy_constructible_v>&& noexcept(++itr)); + static_assert(noexcept(itr++) == is_nothrow_copy_constructible_v> + && noexcept(++itr)); } else { itr++; static_assert(noexcept(itr++) == noexcept(++itr)); @@ -150,8 +150,8 @@ constexpr bool validate_iterators_sentinels( if constexpr (ranges::bidirectional_range) { assert(*itr-- == transformed_elements[2]); - static_assert(noexcept(itr--) - == is_nothrow_copy_constructible_v>&& noexcept(--itr)); + static_assert(noexcept(itr--) == is_nothrow_copy_constructible_v> + && noexcept(--itr)); assert(*--itr == transformed_elements[0]); static_assert(noexcept(--itr) == noexcept(--declval&>())); @@ -696,9 +696,9 @@ class instantiator_impl : private range_type_solver { range_type, forward_iterator_tag, input_iterator_tag>, const int, IsSized, IsCommon, Diff>; using differing_size_member_range_type = range_type; + (IsSized == test::Sized::yes ? test::Sized::no : test::Sized::yes), IsCommon, Diff>; using differing_is_common_range_type = range_type; + (IsCommon == test::Common::yes ? test::Common::no : test::Common::yes), Diff>; using differing_iterator_sentinel_diff_range_type = range_type; diff --git a/tests/std/tests/P2374R4_views_cartesian_product/test.cpp b/tests/std/tests/P2374R4_views_cartesian_product/test.cpp index afeff50be6f..1356bd4cd3e 100644 --- a/tests/std/tests/P2374R4_views_cartesian_product/test.cpp +++ b/tests/std/tests/P2374R4_views_cartesian_product/test.cpp @@ -57,10 +57,8 @@ concept UnsignedIntegerLike = _Integer_like && !_Signed_integer_like; template constexpr bool is_iter_move_nothrow() { - constexpr bool is_inner_iter_move_nothrow = - (noexcept(ranges::iter_move(declval&>())) - && ... // - && noexcept(ranges::iter_move(declval&>()))); + constexpr bool is_inner_iter_move_nothrow = (noexcept(ranges::iter_move(declval&>())) && ... + && noexcept(ranges::iter_move(declval&>()))); constexpr bool are_references_nothrow_movable = conjunction_v>, is_nothrow_move_constructible>...>; @@ -71,7 +69,7 @@ template constexpr bool is_iter_swap_nothrow() { return (noexcept(ranges::iter_swap(declval&>(), declval&>())) && ... // - && noexcept(ranges::iter_swap(declval&>(), declval&>()))); + && noexcept(ranges::iter_swap(declval&>(), declval&>()))); } template @@ -474,7 +472,7 @@ constexpr bool test_one(Expected&& expected_range, First&& first, Rest&&... rest if constexpr ((random_access_range && ... && random_access_range>) ) { // Check 3way comparisons using Cat = common_comparison_category_t>, - compare_three_way_result_t>>...>; + compare_three_way_result_t>>...>; auto i2 = r.begin(); same_as auto cmp1 = i <=> i2; assert(cmp1 == Cat::equivalent); @@ -791,7 +789,7 @@ constexpr void test_iter_swap(Rngs&... rngs) { } // Check iter_swap for cartesian_product_view::iterator - if constexpr (((CanMemberBegin && indirectly_swappable>) &&...)) { + if constexpr (((CanMemberBegin && indirectly_swappable>) && ...)) { using CVal = ranges::range_value_t; auto i = as_const(r).begin(); CVal first = *i; diff --git a/tests/std/tests/P2374R4_views_cartesian_product_recommended_practices/test.compile.pass.cpp b/tests/std/tests/P2374R4_views_cartesian_product_recommended_practices/test.compile.pass.cpp index 2263873c895..d742c9cb895 100644 --- a/tests/std/tests/P2374R4_views_cartesian_product_recommended_practices/test.compile.pass.cpp +++ b/tests/std/tests/P2374R4_views_cartesian_product_recommended_practices/test.compile.pass.cpp @@ -175,7 +175,11 @@ constexpr void check_single_view() { enum class CheckConstAdaptor : bool { no, yes }; +#ifdef __clang__ // TRANSITION, LLVM-104189 +template