From 32e65ac3e54a7150202cc9b3cc4de7330d58d24e Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Sat, 27 Jan 2024 02:24:31 -0800 Subject: [PATCH 1/8] ARM64 test improvements (#4341) --- .../tests/Dev09_056375_locale_cleanup/custombuild.pl | 7 +++++-- .../tests/GH_002030_asan_annotate_string/notarget.lst | 5 +++++ .../tests/GH_002030_asan_annotate_vector/notarget.lst | 5 +++++ .../std/tests/P0226R1_math_special_functions/test.cpp | 4 ++-- tests/std/tests/P0881R7_stacktrace/test.cpp | 2 ++ tests/std/tests/usual_17_matrix.lst | 10 +++++----- tests/std/tests/usual_20_matrix.lst | 6 +++--- tests/std/tests/usual_latest_matrix.lst | 6 +++--- tests/std/tests/usual_matrix.lst | 11 ++++++----- 9 files changed, 36 insertions(+), 20 deletions(-) create mode 100644 tests/std/tests/GH_002030_asan_annotate_string/notarget.lst create mode 100644 tests/std/tests/GH_002030_asan_annotate_vector/notarget.lst diff --git a/tests/std/tests/Dev09_056375_locale_cleanup/custombuild.pl b/tests/std/tests/Dev09_056375_locale_cleanup/custombuild.pl index 74863cccb12..263b73f4931 100644 --- a/tests/std/tests/Dev09_056375_locale_cleanup/custombuild.pl +++ b/tests/std/tests/Dev09_056375_locale_cleanup/custombuild.pl @@ -6,7 +6,10 @@ sub CustomBuildHook() { my $cwd = Run::GetCWDName(); - Run::ExecuteCL("TestDll.cpp /FeTestDll.DLL /link /DLL"); - Run::ExecuteCL("Test.cpp /Fe$cwd.exe"); + my $machine = $ENV{'TARGET_ARCHITECTURE'}; + Run::ExecuteCL("TestDll.cpp /c"); + Run::ExecuteLink("/machine:$machine /out:TestDll.DLL /DLL TestDll.obj"); + Run::ExecuteCL("Test.cpp /c"); + Run::ExecuteLink("/machine:$machine /out:$cwd.exe Test.obj"); } 1 diff --git a/tests/std/tests/GH_002030_asan_annotate_string/notarget.lst b/tests/std/tests/GH_002030_asan_annotate_string/notarget.lst new file mode 100644 index 00000000000..0027fd085c1 --- /dev/null +++ b/tests/std/tests/GH_002030_asan_annotate_string/notarget.lst @@ -0,0 +1,5 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +## TRANSITION, VSO-1938218 ASAN is not yet supported on arm64 +arm64 diff --git a/tests/std/tests/GH_002030_asan_annotate_vector/notarget.lst b/tests/std/tests/GH_002030_asan_annotate_vector/notarget.lst new file mode 100644 index 00000000000..0027fd085c1 --- /dev/null +++ b/tests/std/tests/GH_002030_asan_annotate_vector/notarget.lst @@ -0,0 +1,5 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +## TRANSITION, VSO-1938218 ASAN is not yet supported on arm64 +arm64 diff --git a/tests/std/tests/P0226R1_math_special_functions/test.cpp b/tests/std/tests/P0226R1_math_special_functions/test.cpp index aa0993a7f54..ca2280ad60e 100644 --- a/tests/std/tests/P0226R1_math_special_functions/test.cpp +++ b/tests/std/tests/P0226R1_math_special_functions/test.cpp @@ -261,9 +261,9 @@ void test_cyl_neumann() { assert(isclose(cyl_neumannl(0.5L, 0.333L), -1.30'671'255'810'072'199L, 2)); } { - assert(isclose(cyl_neumann(0.5, 0.666), -0.768'760'134'281'402'040)); + assert(isclose(cyl_neumann(0.5, 0.666), -0.768'760'134'281'402'040, 2)); assert(isclose(cyl_neumannf(0.5f, 0.666f), -0.768'760'134'281'402'040f)); - assert(isclose(cyl_neumannl(0.5L, 0.666L), -0.768'760'134'281'402'040L)); + assert(isclose(cyl_neumannl(0.5L, 0.666L), -0.768'760'134'281'402'040L, 2)); } } diff --git a/tests/std/tests/P0881R7_stacktrace/test.cpp b/tests/std/tests/P0881R7_stacktrace/test.cpp index 17cf3864e2d..09ae2968ec6 100644 --- a/tests/std/tests/P0881R7_stacktrace/test.cpp +++ b/tests/std/tests/P0881R7_stacktrace/test.cpp @@ -311,6 +311,8 @@ void test_impl() { } int main() { +#if !(defined(__clang__) && defined(_M_ARM64)) // TRANSITION, LLVM-74530 jthread t{test_impl}; test_impl(); +#endif } diff --git a/tests/std/tests/usual_17_matrix.lst b/tests/std/tests/usual_17_matrix.lst index 517a5d38ae8..13bb00d662b 100644 --- a/tests/std/tests/usual_17_matrix.lst +++ b/tests/std/tests/usual_17_matrix.lst @@ -47,8 +47,8 @@ PM_CL="/BE /c /EHsc /MD /std:c++latest /permissive-" PM_CL="/BE /c /EHsc /MDd /std:c++17 /permissive-" PM_CL="/BE /c /EHsc /MT /std:c++20 /permissive-" PM_CL="/BE /c /EHsc /MTd /std:c++latest /permissive-" -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MD /std:c++latest /permissive-" -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MDd /std:c++17" -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive-" -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MTd /std:c++latest /permissive- /fp:strict" -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MD /std:c++latest /permissive- --start-no-unused-arguments" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MDd /std:c++17 --start-no-unused-arguments" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive- --start-no-unused-arguments" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MTd /std:c++latest /permissive- /fp:strict --start-no-unused-arguments" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined --start-no-unused-arguments" diff --git a/tests/std/tests/usual_20_matrix.lst b/tests/std/tests/usual_20_matrix.lst index be4602dcfbe..8964140309b 100644 --- a/tests/std/tests/usual_20_matrix.lst +++ b/tests/std/tests/usual_20_matrix.lst @@ -35,6 +35,6 @@ PM_CL="/clr /MD /std:c++20" PM_CL="/clr /MDd /std:c++20" PM_CL="/BE /c /EHsc /MD /std:c++20 /permissive-" PM_CL="/BE /c /EHsc /MTd /std:c++latest /permissive-" -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++20 /permissive- /MD" -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++latest /permissive- /MTd /fp:strict" -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++latest /permissive- /MT /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++20 /permissive- /MD --start-no-unused-arguments" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++latest /permissive- /MTd /fp:strict --start-no-unused-arguments" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++latest /permissive- /MT /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined --start-no-unused-arguments" diff --git a/tests/std/tests/usual_latest_matrix.lst b/tests/std/tests/usual_latest_matrix.lst index 20dbef6af61..1e3d4da8cd9 100644 --- a/tests/std/tests/usual_latest_matrix.lst +++ b/tests/std/tests/usual_latest_matrix.lst @@ -33,6 +33,6 @@ PM_CL="/MTd /D_ITERATOR_DEBUG_LEVEL=2 /permissive- /analyze:only /analyze:autolo ASAN PM_CL="/MTd /permissive- /analyze:only /analyze:autolog- -fsanitize=address /Zi" PM_LINK="/debug" PM_CL="/BE /c /MD /permissive-" PM_CL="/BE /c /MTd /permissive-" -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /permissive- /MD" -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /permissive- /MTd /fp:strict" -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /permissive- /MT /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /permissive- /MD --start-no-unused-arguments" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /permissive- /MTd /fp:strict --start-no-unused-arguments" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /permissive- /MT /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined --start-no-unused-arguments" diff --git a/tests/std/tests/usual_matrix.lst b/tests/std/tests/usual_matrix.lst index 97f067fd5d6..b8200e3ad22 100644 --- a/tests/std/tests/usual_matrix.lst +++ b/tests/std/tests/usual_matrix.lst @@ -49,8 +49,9 @@ PM_CL="/BE /c /EHsc /MD /std:c++14 /w14640 /Zc:threadSafeInit-" PM_CL="/BE /c /EHsc /MDd /std:c++17 /permissive- /w14640 /Zc:threadSafeInit-" PM_CL="/BE /c /EHsc /MT /std:c++20 /permissive- /w14640 /Zc:threadSafeInit-" PM_CL="/BE /c /EHsc /MTd /std:c++latest /permissive- /w14640 /Zc:threadSafeInit-" -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MD /std:c++14 /w14640 /Zc:threadSafeInit-" -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MDd /std:c++17 /w14640 /Zc:threadSafeInit-" -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive- /w14640 /Zc:threadSafeInit-" -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MTd /std:c++latest /permissive- /fp:strict /w14640 /Zc:threadSafeInit-" -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict /w14640 /Zc:threadSafeInit- -fsanitize=undefined -fno-sanitize-recover=undefined" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MD /std:c++14 /w14640 /Zc:threadSafeInit- --start-no-unused-arguments" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MDd /std:c++17 /w14640 /Zc:threadSafeInit- --start-no-unused-arguments" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive- /w14640 /Zc:threadSafeInit- --start-no-unused-arguments" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MTd /std:c++latest /permissive- /fp:strict /w14640 /Zc:threadSafeInit- --start-no-unused-arguments" +# TRANSITION, GH-3568 +# PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict /w14640 /Zc:threadSafeInit- -fsanitize=undefined -fno-sanitize-recover=undefined --start-no-unused-arguments" From 63e4c2f59f55d210c91edd8cce0abf0a570c5f96 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Tue, 30 Jan 2024 22:06:45 +0200 Subject: [PATCH 2/8] SSE2 vectorization for `bitset::to_string` (#3960) Co-authored-by: Alcaro Co-authored-by: Stephan T. Lavavej --- stl/inc/bitset | 26 +++++ stl/src/vector_algorithms.cpp | 110 ++++++++++++++++++ .../VSO_0000000_vector_algorithms/test.cpp | 73 ++++++++++++ 3 files changed, 209 insertions(+) diff --git a/stl/inc/bitset b/stl/inc/bitset index 826752bd49e..627bf330601 100644 --- a/stl/inc/bitset +++ b/stl/inc/bitset @@ -18,6 +18,15 @@ _STL_DISABLE_CLANG_WARNINGS #pragma push_macro("new") #undef new +#if _USE_STD_VECTOR_ALGORITHMS +extern "C" { +__declspec(noalias) void __stdcall __std_bitset_to_string_1( + char* _Dest, const void* _Src, size_t _Size_bits, char _Elem0, char _Elem1) noexcept; +__declspec(noalias) void __stdcall __std_bitset_to_string_2( + wchar_t* _Dest, const void* _Src, size_t _Size_bits, wchar_t _Elem0, wchar_t _Elem1) noexcept; +} // extern "C" +#endif // _USE_STD_VECTOR_ALGORITHMS + _STD_BEGIN _EXPORT_STD template class bitset { // store fixed-length sequence of Boolean elements @@ -348,6 +357,23 @@ public: // convert bitset to string basic_string<_Elem, _Tr, _Alloc> _Str; _Str._Resize_and_overwrite(_Bits, [this, _Elem0, _Elem1](_Elem* _Buf, size_t _Len) { +#if _USE_STD_VECTOR_ALGORITHMS + constexpr size_t _Bitset_vector_threshold = 32; + if constexpr (_Bits >= _Bitset_vector_threshold && is_integral_v<_Elem> && sizeof(_Elem) <= 2) { + if (!_Is_constant_evaluated()) { + if constexpr (sizeof(_Elem) == 1) { + __std_bitset_to_string_1(reinterpret_cast(_Buf), _Array, _Len, static_cast(_Elem0), + static_cast(_Elem1)); + } else { + _STL_INTERNAL_STATIC_ASSERT(sizeof(_Elem) == 2); + __std_bitset_to_string_2(reinterpret_cast(_Buf), _Array, _Len, + static_cast(_Elem0), static_cast(_Elem1)); + } + return _Len; + } + } +#endif // _USE_STD_VECTOR_ALGORITHMS + for (size_t _Pos = 0; _Pos < _Len; ++_Pos) { _Buf[_Pos] = _Subscript(_Len - 1 - _Pos) ? _Elem1 : _Elem0; } diff --git a/stl/src/vector_algorithms.cpp b/stl/src/vector_algorithms.cpp index d18b740304e..70a4e5b45aa 100644 --- a/stl/src/vector_algorithms.cpp +++ b/stl/src/vector_algorithms.cpp @@ -7,6 +7,7 @@ #if defined(_M_IX86) || defined(_M_X64) // NB: includes _M_ARM64EC #include +#include #ifndef _M_ARM64EC #include #include @@ -1563,5 +1564,114 @@ __declspec(noalias) size_t return __std_count_trivial_impl<_Find_traits_8>(_First, _Last, _Val); } +} // extern "C" + +#ifndef _M_ARM64EC +namespace { + __m128i __forceinline _Bitset_to_string_1_step(const uint16_t _Val, const __m128i _Px0, const __m128i _Px1) { + const __m128i _Vx0 = _mm_cvtsi32_si128(_Val); + const __m128i _Vx1 = _mm_unpacklo_epi8(_Vx0, _Vx0); + const __m128i _Vx2 = _mm_unpacklo_epi8(_Vx1, _Vx1); + const __m128i _Vx3 = _mm_shuffle_epi32(_Vx2, _MM_SHUFFLE(0, 0, 1, 1)); + const __m128i _Msk = _mm_and_si128(_Vx3, _mm_set1_epi64x(0x0102040810204080)); + const __m128i _Ex0 = _mm_cmpeq_epi8(_Msk, _mm_setzero_si128()); + const __m128i _Ex1 = _mm_xor_si128(_mm_and_si128(_Ex0, _Px0), _Px1); + return _Ex1; + } + + __m128i __forceinline _Bitset_to_string_2_step(const uint8_t _Val, const __m128i _Px0, const __m128i _Px1) { + const __m128i _Vx = _mm_set1_epi16(_Val); + const __m128i _Msk = _mm_and_si128(_Vx, _mm_set_epi64x(0x0001000200040008, 0x0010002000400080)); + const __m128i _Ex0 = _mm_cmpeq_epi16(_Msk, _mm_setzero_si128()); + const __m128i _Ex1 = _mm_xor_si128(_mm_and_si128(_Ex0, _Px0), _Px1); + return _Ex1; + } +} // unnamed namespace +#endif // !defined(_M_ARM64EC) + +extern "C" { + +__declspec(noalias) void __stdcall __std_bitset_to_string_1( + char* const _Dest, const void* _Src, size_t _Size_bits, const char _Elem0, const char _Elem1) noexcept { +#ifndef _M_ARM64EC + if (_Use_sse2()) { + const __m128i _Px0 = _mm_set1_epi8(_Elem0 ^ _Elem1); + const __m128i _Px1 = _mm_set1_epi8(_Elem1); + if (_Size_bits >= 16) { + char* _Pos = _Dest + _Size_bits; + _Size_bits &= 0xF; + char* const _Stop_at = _Dest + _Size_bits; + do { + uint16_t _Val; + memcpy(&_Val, _Src, 2); + const __m128i _Elems = _Bitset_to_string_1_step(_Val, _Px0, _Px1); + _Pos -= 16; + _mm_storeu_si128(reinterpret_cast<__m128i*>(_Pos), _Elems); + _Advance_bytes(_Src, 2); + } while (_Pos != _Stop_at); + } + + if (_Size_bits > 0) { + __assume(_Size_bits < 16); + uint16_t _Val; + if (_Size_bits > 8) { + memcpy(&_Val, _Src, 2); + } else { + _Val = *reinterpret_cast(_Src); + } + const __m128i _Elems = _Bitset_to_string_1_step(_Val, _Px0, _Px1); + char _Tmp[16]; + _mm_storeu_si128(reinterpret_cast<__m128i*>(_Tmp), _Elems); + const char* const _Tmpd = _Tmp + (16 - _Size_bits); + for (size_t _Ix = 0; _Ix < _Size_bits; ++_Ix) { + _Dest[_Ix] = _Tmpd[_Ix]; + } + } + } +#endif // !defined(_M_ARM64EC) + const auto _Arr = reinterpret_cast(_Src); + for (size_t _Ix = 0; _Ix < _Size_bits; ++_Ix) { + _Dest[_Size_bits - 1 - _Ix] = ((_Arr[_Ix >> 3] >> (_Ix & 7)) & 1) != 0 ? _Elem1 : _Elem0; + } +} + +__declspec(noalias) void __stdcall __std_bitset_to_string_2( + wchar_t* const _Dest, const void* _Src, size_t _Size_bits, const wchar_t _Elem0, const wchar_t _Elem1) noexcept { +#ifndef _M_ARM64EC + if (_Use_sse2()) { + const __m128i _Px0 = _mm_set1_epi16(_Elem0 ^ _Elem1); + const __m128i _Px1 = _mm_set1_epi16(_Elem1); + if (_Size_bits >= 8) { + wchar_t* _Pos = _Dest + _Size_bits; + _Size_bits &= 0x7; + wchar_t* const _Stop_at = _Dest + _Size_bits; + do { + const uint8_t _Val = *reinterpret_cast(_Src); + const __m128i _Elems = _Bitset_to_string_2_step(_Val, _Px0, _Px1); + _Pos -= 8; + _mm_storeu_si128(reinterpret_cast<__m128i*>(_Pos), _Elems); + _Advance_bytes(_Src, 1); + } while (_Pos != _Stop_at); + } + + if (_Size_bits > 0) { + __assume(_Size_bits < 8); + const uint8_t _Val = *reinterpret_cast(_Src); + const __m128i _Elems = _Bitset_to_string_2_step(_Val, _Px0, _Px1); + wchar_t _Tmp[8]; + _mm_storeu_si128(reinterpret_cast<__m128i*>(_Tmp), _Elems); + const wchar_t* const _Tmpd = _Tmp + (8 - _Size_bits); + for (size_t _Ix = 0; _Ix < _Size_bits; ++_Ix) { + _Dest[_Ix] = _Tmpd[_Ix]; + } + } + } +#endif // !defined(_M_ARM64EC) + const auto _Arr = reinterpret_cast(_Src); + for (size_t _Ix = 0; _Ix < _Size_bits; ++_Ix) { + _Dest[_Size_bits - 1 - _Ix] = ((_Arr[_Ix >> 3] >> (_Ix & 7)) & 1) != 0 ? _Elem1 : _Elem0; + } +} + } // extern "C" #endif // defined(_M_IX86) || defined(_M_X64) diff --git a/tests/std/tests/VSO_0000000_vector_algorithms/test.cpp b/tests/std/tests/VSO_0000000_vector_algorithms/test.cpp index 383a9120b74..a0ad56a434c 100644 --- a/tests/std/tests/VSO_0000000_vector_algorithms/test.cpp +++ b/tests/std/tests/VSO_0000000_vector_algorithms/test.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include +#include #include #include #include @@ -12,6 +13,7 @@ #include #include #include +#include #include #include @@ -443,6 +445,73 @@ void test_one_container() { test_two_containers>(); } +void test_bitset(mt19937_64& gen) { + assert(bitset<0>(0x0ULL).to_string() == ""); + assert(bitset<0>(0xFEDCBA9876543210ULL).to_string() == ""); + assert(bitset<15>(0x6789ULL).to_string() == "110011110001001"); + assert(bitset<15>(0xFEDCBA9876543210ULL).to_string() == "011001000010000"); + assert(bitset<32>(0xABCD1234ULL).to_string() == "10101011110011010001001000110100"); + assert(bitset<32>(0xFEDCBA9876543210ULL).to_string() == "01110110010101000011001000010000"); + assert(bitset<45>(0x1701D1729FFFULL).to_string() == "101110000000111010001011100101001111111111111"); + assert(bitset<45>(0xFEDCBA9876543210ULL).to_string() == "110101001100001110110010101000011001000010000"); + assert(bitset<64>(0xFEDCBA9876543210ULL).to_string() + == "1111111011011100101110101001100001110110010101000011001000010000"); + assert(bitset<75>(0xFEDCBA9876543210ULL).to_string() + == "000000000001111111011011100101110101001100001110110010101000011001000010000"); + + assert(bitset<0>(0x0ULL).to_string() == L""); + assert(bitset<0>(0xFEDCBA9876543210ULL).to_string() == L""); + assert(bitset<15>(0x6789ULL).to_string() == L"110011110001001"); + assert(bitset<15>(0xFEDCBA9876543210ULL).to_string() == L"011001000010000"); + assert(bitset<32>(0xABCD1234ULL).to_string() == L"10101011110011010001001000110100"); + assert(bitset<32>(0xFEDCBA9876543210ULL).to_string() == L"01110110010101000011001000010000"); + assert(bitset<45>(0x1701D1729FFFULL).to_string() == L"101110000000111010001011100101001111111111111"); + assert(bitset<45>(0xFEDCBA9876543210ULL).to_string() == L"110101001100001110110010101000011001000010000"); + assert(bitset<64>(0xFEDCBA9876543210ULL).to_string() + == L"1111111011011100101110101001100001110110010101000011001000010000"); + assert(bitset<75>(0xFEDCBA9876543210ULL).to_string() + == L"000000000001111111011011100101110101001100001110110010101000011001000010000"); + + assert(bitset<64>(0xFEDCBA9876543210ULL).to_string('o', 'x') + == "xxxxxxxoxxoxxxooxoxxxoxoxooxxooooxxxoxxooxoxoxooooxxooxooooxoooo"); + assert(bitset<64>(0xFEDCBA9876543210ULL).to_string(L'o', L'x') + == L"xxxxxxxoxxoxxxooxoxxxoxoxooxxooooxxxoxxooxoxoxooooxxooxooooxoooo"); + +#ifdef __cpp_lib_char8_t + assert(bitset<75>(0xFEDCBA9876543210ULL).to_string() + == u8"000000000001111111011011100101110101001100001110110010101000011001000010000"); +#endif // __cpp_lib_char8_t + assert(bitset<75>(0xFEDCBA9876543210ULL).to_string() + == u"000000000001111111011011100101110101001100001110110010101000011001000010000"); + assert(bitset<75>(0xFEDCBA9876543210ULL).to_string() + == U"000000000001111111011011100101110101001100001110110010101000011001000010000"); // not vectorized + + { + constexpr size_t N = 2048; + + string str; + wstring wstr; + str.reserve(N); + wstr.reserve(N); + + while (str.size() != N) { + uint64_t random_value = gen(); + + for (int bits = 0; bits < 64; ++bits) { + const auto character = '0' + (random_value & 1); + str.push_back(static_cast(character)); + wstr.push_back(static_cast(character)); + random_value >>= 1; + } + } + + const bitset b(str); + + assert(b.to_string() == str); + assert(b.to_string() == wstr); + } +} + void test_various_containers() { test_one_container>(); // contiguous, vectorizable test_one_container>(); // random-access, not vectorizable @@ -524,20 +593,24 @@ int main() { test_vector_algorithms(gen); test_various_containers(); + test_bitset(gen); #ifndef _M_CEE_PURE #if defined(_M_IX86) || defined(_M_X64) disable_instructions(__ISA_AVAILABLE_AVX2); test_vector_algorithms(gen); test_various_containers(); + test_bitset(gen); disable_instructions(__ISA_AVAILABLE_SSE42); test_vector_algorithms(gen); test_various_containers(); + test_bitset(gen); #endif // defined(_M_IX86) || defined(_M_X64) #if defined(_M_IX86) disable_instructions(__ISA_AVAILABLE_SSE2); test_vector_algorithms(gen); test_various_containers(); + test_bitset(gen); #endif // defined(_M_IX86) #endif // _M_CEE_PURE } From 46402aa2d7f76b60767ed09ecc63d47300e95b19 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Wed, 31 Jan 2024 04:10:15 +0800 Subject: [PATCH 3/8] ``: Make `deque::shrink_to_fit` never relocate elements (#4091) Co-authored-by: achabense <60953653+achabense@users.noreply.github.com> Co-authored-by: Stephan T. Lavavej --- stl/inc/deque | 105 ++++++++++++++---- .../test.cpp | 45 ++++++++ .../test.cpp | 2 +- 3 files changed, 131 insertions(+), 21 deletions(-) diff --git a/stl/inc/deque b/stl/inc/deque index 3ce93fd2e3f..ba0794eb243 100644 --- a/stl/inc/deque +++ b/stl/inc/deque @@ -989,19 +989,74 @@ public: } void shrink_to_fit() { - size_type _Oldcapacity = _Block_size * _Mapsize(); - size_type _Newcapacity = _Oldcapacity / 2; + if (empty()) { + if (_Map() != nullptr) { + _Reset_map(); + } + return; + } + + const auto _Mask = static_cast(_Mapsize() - 1); + + const auto _First_used_block_idx = static_cast(_Myoff() / _Block_size); + + // (_Myoff() + _Mysize() - 1) is for the last element, i.e. the back() of the deque. + // Divide by _Block_size to get the unmasked index of the last used block. + // Add 1 to get the unmasked index of the first unused block. + const auto _Unmasked_first_unused_block_idx = + static_cast(((_Myoff() + _Mysize() - 1) / _Block_size) + 1); + + const auto _First_unused_block_idx = static_cast(_Unmasked_first_unused_block_idx & _Mask); + + // deallocate unused blocks, traversing over the circular buffer until the first used block index + for (auto _Block_idx = _First_unused_block_idx; _Block_idx != _First_used_block_idx; + _Block_idx = static_cast((_Block_idx + 1) & _Mask)) { + auto& _Block_ptr = _Map()[static_cast<_Map_difference_type>(_Block_idx)]; + if (_Block_ptr != nullptr) { + _Getal().deallocate(_Block_ptr, _Block_size); + _Block_ptr = nullptr; + } + } + + const auto _Used_block_count = static_cast(_Unmasked_first_unused_block_idx - _First_used_block_idx); + + size_type _New_block_count = _Minimum_map_size; // should be power of 2 + + while (_New_block_count < _Used_block_count) { + _New_block_count *= 2; + } + + if (_New_block_count >= _Mapsize()) { + return; + } + + // worth shrinking the internal map, do it + + _Alpty _Almap(_Getal()); + const auto _New_map = _Almap.allocate(_New_block_count); - if (_Newcapacity < _Block_size * _Minimum_map_size) { - _Newcapacity = _Block_size * _Minimum_map_size; + _Orphan_all(); // the map can be shrunk, invalidate all iterators + + // transfer the ownership of blocks to pointers in the new map + for (size_type _Block = 0; _Block != _Used_block_count; ++_Block) { + const auto _New_block_idx = static_cast<_Map_difference_type>(_Block); + const auto _Old_block_idx = static_cast<_Map_difference_type>((_First_used_block_idx + _Block) & _Mask); + _STD _Construct_in_place(_New_map[_New_block_idx], _Map()[_Old_block_idx]); } - if ((empty() && _Mapsize() > 0) - || (!empty() && size() <= _Newcapacity && _Newcapacity < _Oldcapacity)) { // worth shrinking, do it - deque _Tmp( - _STD make_move_iterator(_Unchecked_begin()), _STD make_move_iterator(_Unchecked_end()), _Getal()); - swap(_Tmp); + // null out the rest of the new map + _STD _Uninitialized_value_construct_n_unchecked1( + _New_map + static_cast<_Map_difference_type>(_Used_block_count), _New_block_count - _Used_block_count); + + for (auto _Block = _Map_distance(); _Block > 0;) { + --_Block; + _STD _Destroy_in_place(_Map()[_Block]); // destroy pointer to block } + _Almap.deallocate(_Map(), _Mapsize()); // free storage for map + + _Map() = _New_map; + _Mapsize() = _New_block_count; + _Myoff() %= _Block_size; // the first element is within block index 0 of the new map } _NODISCARD const_reference operator[](size_type _Pos) const noexcept /* strengthened */ { @@ -1591,27 +1646,37 @@ private: _Mapsize() += _Count; } + void _Reset_map() noexcept { + // pre: each block pointer is either null or pointing to a block without constructed elements + + for (auto _Block = _Map_distance(); _Block > 0;) { // free storage for a block and destroy pointer + --_Block; + auto& _Block_ptr = _Map()[_Block]; + if (_Block_ptr) { // free block + _Getal().deallocate(_Block_ptr, _Block_size); + } + _STD _Destroy_in_place(_Block_ptr); // destroy pointer to block + } + + _Alpty _Almap(_Getal()); + _Almap.deallocate(_Map(), _Mapsize()); // free storage for map + + _Map() = nullptr; + _Mapsize() = 0; + } + void _Tidy() noexcept { // free all storage _Orphan_all(); - _Alpty _Almap(_Getal()); while (!empty()) { pop_back(); } if (_Map() != nullptr) { - for (auto _Block = _Map_distance(); _Block > 0;) { // free storage for a block and destroy pointer - if (_Map()[--_Block]) { // free block - _Getal().deallocate(_Map()[_Block], _Block_size); - } - _Destroy_in_place(_Map()[_Block]); // destroy pointer to block - } - - _Almap.deallocate(_Map(), _Mapsize()); // free storage for map + _Reset_map(); } - _Mapsize() = 0; - _Map() = nullptr; + _STL_INTERNAL_CHECK(_Mapsize() == 0); // null map should always be paired with zero mapsize } #if _ITERATOR_DEBUG_LEVEL == 2 diff --git a/tests/std/tests/Dev10_860421_deque_push_back_pop_front/test.cpp b/tests/std/tests/Dev10_860421_deque_push_back_pop_front/test.cpp index 4e21193d429..fd362b915da 100644 --- a/tests/std/tests/Dev10_860421_deque_push_back_pop_front/test.cpp +++ b/tests/std/tests/Dev10_860421_deque_push_back_pop_front/test.cpp @@ -259,6 +259,49 @@ void test_exception_safety_for_throwing_movable() { assert(d == d_orig); } +// Also test GH-4072: : shrink_to_fit() should follow the Standard +void test_gh_4072() { + { + constexpr int removed_count = 768; + + deque d; + for (int i = 0; i < 1729; ++i) { + d.emplace_back(i); + } + + for (int i = 0; i < removed_count; ++i) { + d.pop_front(); + d.pop_back(); + } + + deque d2; + for (int i = removed_count; i < 1729 - removed_count; ++i) { + d2.emplace_back(i); + } + + d.shrink_to_fit(); // ensures that no constructor or assignment operator of the element type is called + assert(d == d2); + } + + // ensure that the circular buffer is correctly handled + { + deque deq(128); + deq.pop_back(); + deq.emplace_front(0); + deq.shrink_to_fit(); + } + { + deque deq(128); + for (int i = 0; i < 120; ++i) { + deq.pop_back(); + } + for (int i = 0; i < 5; ++i) { + deq.emplace_front(0); + } + deq.shrink_to_fit(); + } +} + int main() { test_push_back_pop_front(); @@ -266,4 +309,6 @@ int main() { test_exception_safety_for_nonswappable_movable(); test_exception_safety_for_throwing_movable(); + + test_gh_4072(); } diff --git a/tests/std/tests/VSO_0000000_allocator_propagation/test.cpp b/tests/std/tests/VSO_0000000_allocator_propagation/test.cpp index 7622338207b..c0e775c77f0 100644 --- a/tests/std/tests/VSO_0000000_allocator_propagation/test.cpp +++ b/tests/std/tests/VSO_0000000_allocator_propagation/test.cpp @@ -501,7 +501,7 @@ void test_deque_shrink_to_fit_per_alloc() { } } -void test_deque_shrink_to_fit() { // MSVC STL's deque::shrink_to_fit relies on swap +void test_deque_shrink_to_fit() { // regression test: MSVC STL's deque::shrink_to_fit used to rely on swap test_deque_shrink_to_fit_per_alloc>(); test_deque_shrink_to_fit_per_alloc>(); test_deque_shrink_to_fit_per_alloc>(); From 9c10c1a23299f8b0e314cc3be8eae0571aca066e Mon Sep 17 00:00:00 2001 From: Tomasz Konojacki Date: Tue, 30 Jan 2024 21:16:20 +0100 Subject: [PATCH 4/8] ``: Preallocate memory in `path::operator/` (#4136) Co-authored-by: Stephan T. Lavavej Co-authored-by: Casey Carter --- stl/inc/filesystem | 29 +++++++++++++++++++++ tests/std/tests/P0218R1_filesystem/test.cpp | 22 ++++++++++++---- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/stl/inc/filesystem b/stl/inc/filesystem index 4b2ad4ce9b8..a08e435d4cc 100644 --- a/stl/inc/filesystem +++ b/stl/inc/filesystem @@ -1377,6 +1377,35 @@ namespace filesystem { #endif // ^^^ !_HAS_CXX20 ^^^ _NODISCARD_FRIEND path operator/(const path& _Left, const path& _Right) { // append a pair of paths together + const auto _Right_size = _Right._Text.size(); + const auto _Right_first = _Right._Text.data(); + const auto _Right_last = _Right_first + _Right_size; + + // Handle the most common case: !has_root_name(_Right) && !has_root_directory(_Right) + if (_Right_size != 0 && !_Has_drive_letter_prefix(_Right_first, _Right_last) && !_Is_slash(*_Right_first)) { + const auto _Left_size = _Left._Text.size(); + const auto _Left_first = _Left._Text.data(); + const auto _Left_last = _Left_first + _Left_size; + + // Appending a slash to "X:" would make it an absolute path + const bool _Left_is_just_drive = _Left_size == 2 && _Is_drive_prefix(_Left_first); + const bool _Is_slash_needed = _Left_size != 0 && !_Left_is_just_drive && !_Is_slash(_Left_last[-1]); + + const auto _Total_size = _Left_size + static_cast(_Is_slash_needed) + _Right_size; + + path _Tmp; + _Tmp._Text._Resize_and_overwrite(_Total_size, [=](wchar_t* _Ptr, const size_t _Size) { + _CSTD memcpy(_Ptr, _Left_first, _Left_size * sizeof(wchar_t)); + _Ptr += _Left_size; + if (_Is_slash_needed) { + *_Ptr++ = preferred_separator; + } + _CSTD memcpy(_Ptr, _Right_first, _Right_size * sizeof(wchar_t)); + return _Size; + }); + return _Tmp; + } + path _Tmp = _Left; _Tmp /= _Right; return _Tmp; diff --git a/tests/std/tests/P0218R1_filesystem/test.cpp b/tests/std/tests/P0218R1_filesystem/test.cpp index d3ea57bbbc8..e2d66ba01b2 100644 --- a/tests/std/tests/P0218R1_filesystem/test.cpp +++ b/tests/std/tests/P0218R1_filesystem/test.cpp @@ -544,6 +544,7 @@ struct slash_test_case { }; constexpr slash_test_case slashTestCases[] = { + {L""sv, L""sv, L""sv}, {L"relative"sv, L"other"sv, LR"(relative\other)"sv}, {L"//server"sv, L"share"sv, LR"(//server\share)"sv}, {L"//server/"sv, L"share"sv, LR"(//server/share)"sv}, @@ -555,6 +556,7 @@ constexpr slash_test_case slashTestCases[] = { {L""sv, L"cat"sv, L"cat"sv}, {L"./"sv, L"cat"sv, L"./cat"sv}, // original test case catching a bug in the above {L"c:"sv, L""sv, L"c:"sv}, + {L"c:"sv, L"dog"sv, L"c:dog"sv}, {L"c:cat"sv, L"/dog"sv, L"c:/dog"sv}, {L"c:/cat"sv, L"/dog"sv, L"c:/dog"sv}, {L"c:cat"sv, L"c:dog"sv, LR"(c:cat\dog)"sv}, @@ -568,13 +570,23 @@ constexpr slash_test_case slashTestCases[] = { bool run_slash_test_case(const slash_test_case& testCase) { path p(testCase.a); p /= testCase.b; - if (p.native() == testCase.expected) { - return true; + + if (p.native() != testCase.expected) { + wcerr << L"With operator/=, expected " << testCase.a << L" / " << testCase.b << L" to be " << testCase.expected + << L" but it was " << p.native() << L"\n"; + return false; } - wcerr << L"Expected " << testCase.a << L" / " << testCase.b << L" to be " << testCase.expected << L" but it was " - << p.native() << L"\n"; - return false; + // Also test operator/, which was optimized by GH-4136. + p = path{testCase.a} / path{testCase.b}; + + if (p.native() != testCase.expected) { + wcerr << L"With operator/, expected " << testCase.a << L" / " << testCase.b << L" to be " << testCase.expected + << L" but it was " << p.native() << L"\n"; + return false; + } + + return true; } void test_iterators() { From c0da2af3d28e521e69bc3afd1e1418246ca074cf Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Wed, 31 Jan 2024 04:25:25 +0800 Subject: [PATCH 5/8] ``: Add different control block types for `allocate_shared_for_overwrite` (#4274) Co-authored-by: Stephan T. Lavavej --- stl/debugger/STL.natvis | 104 ++++++++++++++++ stl/inc/memory | 198 +++++++++++++++++++++++++----- tests/libcxx/expected_results.txt | 3 - 3 files changed, 272 insertions(+), 33 deletions(-) diff --git a/stl/debugger/STL.natvis b/stl/debugger/STL.natvis index a3047ef51d3..01e8dd606b6 100644 --- a/stl/debugger/STL.natvis +++ b/stl/debugger/STL.natvis @@ -362,6 +362,35 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + + + make_shared<T[N]> + + _Storage._Value + + + + + + + + make_shared<T[]> + + + size() + data() + + + + + + + make_shared<T[]> + + _Storage._Value + + + allocate_shared @@ -386,6 +415,81 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + + + + + + + allocate_shared<T[N]> + + _Storage._Value + allocator() + + + + + + + + + + + + allocate_shared<T[]> + + allocator() + + size() + data() + + + + + + + + + + + allocate_shared_for_overwrite + + ($T1 *) &_Storage + allocator() + + + + + + + + + + allocate_shared_for_overwrite<T[N]> + + _Storage._Value + allocator() + + + + + + + + + + + + allocate_shared_for_overwrite<T[]> + + allocator() + + size() + data() + + + + custom deleter diff --git a/stl/inc/memory b/stl/inc/memory index 8b528752403..8ad20eb7cde 100644 --- a/stl/inc/memory +++ b/stl/inc/memory @@ -1821,7 +1821,7 @@ private: template friend shared_ptr<_Ty0> _Make_shared_unbounded_array(size_t _Count, const _ArgTypes&... _Args); - template + template friend shared_ptr<_Ty0> _Allocate_shared_unbounded_array( const _Alloc& _Al, size_t _Count, const _ArgTypes&... _Args); #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv @@ -2461,16 +2461,14 @@ public: template explicit _Ref_count_obj_alloc3(const _Alloc& _Al_arg, _Types&&... _Args) : _Ebco_base<_Rebound>(_Al_arg), _Ref_count_base() { -#if _HAS_CXX20 - if constexpr (sizeof...(_Types) == 1 && (is_same_v<_For_overwrite_tag, remove_cvref_t<_Types>> && ...)) { - _Default_construct_in_place(_Storage._Value); - ((void) _Args, ...); - } else -#endif // _HAS_CXX20 - { - allocator_traits<_Rebound>::construct( - this->_Get_val(), _STD addressof(_Storage._Value), _STD forward<_Types>(_Args)...); +#if _HAS_CXX20 && defined(_ENABLE_STL_INTERNAL_CHECK) + if constexpr (sizeof...(_Types) == 1) { + // allocate_shared_for_overwrite should use another type for the control block + _STL_INTERNAL_STATIC_ASSERT(!(is_same_v<_For_overwrite_tag, remove_cvref_t<_Types>> && ...)); } +#endif // _HAS_CXX20 && defined(_ENABLE_STL_INTERNAL_CHECK) + allocator_traits<_Rebound>::construct( + this->_Get_val(), _STD addressof(_Storage._Value), _STD forward<_Types>(_Args)...); } union { @@ -2496,6 +2494,44 @@ private: }; #if _HAS_CXX20 +template +class _Ref_count_obj_alloc_for_overwrite : public _Ebco_base<_Rebind_alloc_t<_Alloc, _Ty>>, public _Ref_count_base { + // handle reference counting for object in control block, allocator + // initialize and destroy objects by the default mechanism +private: + static_assert(is_same_v<_Ty, remove_cv_t<_Ty>>, "allocate_shared_for_overwrite should remove_cv_t"); + + using _Rebound = _Rebind_alloc_t<_Alloc, _Ty>; + +public: + template + explicit _Ref_count_obj_alloc_for_overwrite(const _Alloc& _Al_arg) + : _Ebco_base<_Rebound>(_Al_arg), _Ref_count_base() { + _Default_construct_in_place(_Storage._Value); + } + + union { + _Wrap<_Ty> _Storage; + }; + +private: + ~_Ref_count_obj_alloc_for_overwrite() noexcept override { // TRANSITION, should be non-virtual + // nothing to do; _Storage._Value already destroyed by _Destroy() + + // See N4964 [class.dtor]/7. + } + + void _Destroy() noexcept override { // destroy managed resource + _Destroy_in_place(_Storage._Value); // use the default mechanism per LWG-4024 + } + + void _Delete_this() noexcept override { // destroy self + _Rebind_alloc_t<_Alloc, _Ref_count_obj_alloc_for_overwrite> _Al(this->_Get_val()); + this->~_Ref_count_obj_alloc_for_overwrite(); + _Deallocate_plain(_Al, this); + } +}; + template class _NODISCARD _Uninitialized_rev_destroying_backout_al { // class to undo partially constructed ranges in _Uninitialized_xxx_al algorithms @@ -2647,11 +2683,10 @@ public: template explicit _Ref_count_unbounded_array_alloc(const _Alloc& _Al_arg, const size_t _Count, const _Arg& _Val) : _Ebco_base<_Rebound>(_Al_arg), _Ref_count_base(), _Size(_Count) { - if constexpr (is_same_v<_For_overwrite_tag, _Arg>) { - _Uninitialized_default_construct_multidimensional_n(_Get_ptr(), _Size); // the allocator isn't needed - } else { - _Uninitialized_fill_multidimensional_n_al(_Get_ptr(), _Size, _Val, this->_Get_val()); - } + // allocate_shared_for_overwrite should use another type for the control block + _STL_INTERNAL_STATIC_ASSERT(!is_same_v<_For_overwrite_tag, _Arg>); + + _Uninitialized_fill_multidimensional_n_al(_Get_ptr(), _Size, _Val, this->_Get_val()); } _NODISCARD auto _Get_ptr() noexcept { @@ -2694,6 +2729,65 @@ private: } }; +template +class _Ref_count_unbounded_array_alloc_for_overwrite + : public _Ebco_base<_Rebind_alloc_t<_Alloc, remove_all_extents_t<_Ty>>>, + public _Ref_count_base { + // handle reference counting for unbounded array in control block, allocator + // initialize and destroy objects by the default mechanism +private: + static_assert(is_unbounded_array_v<_Ty>); + static_assert(is_same_v<_Ty, remove_cv_t<_Ty>>, "allocate_shared_for_overwrite should remove_cv_t"); + + using _Item = remove_all_extents_t<_Ty>; + using _Rebound = _Rebind_alloc_t<_Alloc, _Item>; + +public: + using _Element_type = remove_extent_t<_Ty>; + + explicit _Ref_count_unbounded_array_alloc_for_overwrite(const _Alloc& _Al_arg, const size_t _Count) + : _Ebco_base<_Rebound>(_Al_arg), _Ref_count_base(), _Size(_Count) { + _Uninitialized_default_construct_multidimensional_n(_Get_ptr(), _Size); // the allocator isn't needed + } + + _NODISCARD auto _Get_ptr() noexcept { + return _STD addressof(_Storage._Value); + } + +private: + size_t _Size; + + union { + _Wrap<_Element_type> _Storage; // flexible array must be last member + }; + + ~_Ref_count_unbounded_array_alloc_for_overwrite() noexcept override { // TRANSITION, should be non-virtual + // nothing to do; _Storage._Value already destroyed by _Destroy() + + // See N4964 [class.dtor]/7. + } + + void _Destroy() noexcept override { // destroy managed resource + _Reverse_destroy_multidimensional_n(_Get_ptr(), _Size); // use the default mechanism per LWG-4024 + } + + void _Delete_this() noexcept override { // destroy self + constexpr size_t _Align = alignof(_Ref_count_unbounded_array_alloc_for_overwrite); + using _Storage = _Alignas_storage_unit<_Align>; + using _Rebound_alloc = _Rebind_alloc_t<_Alloc, _Storage>; + + _Rebound_alloc _Al(this->_Get_val()); + const size_t _Bytes = _Calculate_bytes_for_flexible_array< // + _Ref_count_unbounded_array_alloc_for_overwrite, _Check_overflow::_Nope>(_Size); + const size_t _Storage_units = _Bytes / sizeof(_Storage); + + this->~_Ref_count_unbounded_array_alloc_for_overwrite(); + + _Al.deallocate(_STD _Refancy<_Alloc_ptr_t<_Rebound_alloc>>(reinterpret_cast<_Storage*>(this)), + static_cast<_Alloc_size_t<_Rebound_alloc>>(_Storage_units)); + } +}; + template class _Ref_count_bounded_array_alloc : public _Ebco_base<_Rebind_alloc_t<_Alloc, remove_all_extents_t<_Ty>>>, public _Ref_count_base { @@ -2714,12 +2808,10 @@ public: template explicit _Ref_count_bounded_array_alloc(const _Alloc& _Al_arg, const _Arg& _Val) : _Ebco_base<_Rebound>(_Al_arg), _Ref_count_base() { // don't value-initialize _Storage - if constexpr (is_same_v<_For_overwrite_tag, _Arg>) { - _Uninitialized_default_construct_multidimensional_n( - _Storage._Value, extent_v<_Ty>); // the allocator isn't needed - } else { - _Uninitialized_fill_multidimensional_n_al(_Storage._Value, extent_v<_Ty>, _Val, this->_Get_val()); - } + // allocate_shared_for_overwrite should use another type for the control block + _STL_INTERNAL_STATIC_ASSERT(!is_same_v<_For_overwrite_tag, _Arg>); + + _Uninitialized_fill_multidimensional_n_al(_Storage._Value, extent_v<_Ty>, _Val, this->_Get_val()); } union { @@ -2745,6 +2837,50 @@ private: _Deallocate_plain(_Al, this); } }; + +template +class _Ref_count_bounded_array_alloc_for_overwrite + : public _Ebco_base<_Rebind_alloc_t<_Alloc, remove_all_extents_t<_Ty>>>, + public _Ref_count_base { + // handle reference counting for bounded array in control block, allocator + // initialize and destroy objects by the default mechanism +private: + static_assert(is_bounded_array_v<_Ty>); + static_assert(is_same_v<_Ty, remove_cv_t<_Ty>>, "allocate_shared_for_overwrite should remove_cv_t"); + + using _Item = remove_all_extents_t<_Ty>; + using _Rebound = _Rebind_alloc_t<_Alloc, _Item>; + +public: + explicit _Ref_count_bounded_array_alloc_for_overwrite(const _Alloc& _Al_arg) + : _Ebco_base<_Rebound>(_Al_arg), _Ref_count_base() { // don't value-initialize _Storage + _Uninitialized_default_construct_multidimensional_n( + _Storage._Value, extent_v<_Ty>); // the allocator isn't needed + } + + union { + _Wrap<_Ty> _Storage; + }; + +private: + ~_Ref_count_bounded_array_alloc_for_overwrite() noexcept override { // TRANSITION, should be non-virtual + // nothing to do; _Storage._Value already destroyed by _Destroy() + + // See N4964 [class.dtor]/7. + } + + void _Destroy() noexcept override { // destroy managed resource + // not _Storage._Value as _Ty is an array type (not a class type or a scalar type), + // and thus cannot be used as a pseudo-destructor (N4964 [expr.prim.id.dtor]). + _Destroy_in_place(_Storage); // use the default mechanism per LWG-4024 + } + + void _Delete_this() noexcept override { // destroy self + _Rebind_alloc_t<_Alloc, _Ref_count_bounded_array_alloc_for_overwrite> _Al(this->_Get_val()); + this->~_Ref_count_bounded_array_alloc_for_overwrite(); + _Deallocate_plain(_Al, this); + } +}; #endif // _HAS_CXX20 _EXPORT_STD template @@ -2884,12 +3020,14 @@ struct _Allocate_n_ptr { _Allocate_n_ptr& operator=(const _Allocate_n_ptr&) = delete; }; -_EXPORT_STD /* TRANSITION, VSO-1538698 */ template +_EXPORT_STD /* TRANSITION, VSO-1538698 */ template _NODISCARD shared_ptr<_Ty> _Allocate_shared_unbounded_array( const _Alloc& _Al, const size_t _Count, const _ArgTypes&... _Args) { // make a shared_ptr to an unbounded array static_assert(is_unbounded_array_v<_Ty>); - using _Refc = _Ref_count_unbounded_array_alloc, _Alloc>; + using _Refc = conditional_t<_IsForOverwrite, // + _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); @@ -2907,13 +3045,13 @@ _NODISCARD shared_ptr<_Ty> _Allocate_shared_unbounded_array( _EXPORT_STD template _NODISCARD_SMART_PTR_ALLOC enable_if_t, shared_ptr<_Ty>> allocate_shared( const _Alloc& _Al, const size_t _Count) { - return _Allocate_shared_unbounded_array<_Ty>(_Al, _Count); + return _Allocate_shared_unbounded_array(_Al, _Count); } _EXPORT_STD template _NODISCARD_SMART_PTR_ALLOC enable_if_t, shared_ptr<_Ty>> allocate_shared( const _Alloc& _Al, const size_t _Count, const remove_extent_t<_Ty>& _Val) { - return _Allocate_shared_unbounded_array<_Ty>(_Al, _Count, _Val); + return _Allocate_shared_unbounded_array(_Al, _Count, _Val); } _EXPORT_STD template @@ -2953,22 +3091,22 @@ _NODISCARD_SMART_PTR_ALLOC enable_if_t, shared_ptr<_T shared_ptr<_Ty> _Ret; if constexpr (is_array_v<_Ty>) { // make a shared_ptr to a bounded array - using _Refc = _Ref_count_bounded_array_alloc, _Alloc>; + using _Refc = _Ref_count_bounded_array_alloc_for_overwrite, _Alloc>; using _Alblock = _Rebind_alloc_t<_Alloc, _Refc>; _Alblock _Rebound(_Al); _Alloc_construct_ptr _Constructor{_Rebound}; _Constructor._Allocate(); - ::new (_STD _Voidify_unfancy(_Constructor._Ptr)) _Refc(_Al, _For_overwrite_tag{}); + ::new (_STD _Voidify_unfancy(_Constructor._Ptr)) _Refc(_Al); const auto _Ptr = static_cast*>(_Constructor._Ptr->_Storage._Value); _Ret._Set_ptr_rep_and_enable_shared(_Ptr, _STD _Unfancy(_Constructor._Release())); } else { // make a shared_ptr to non-array object - using _Refoa = _Ref_count_obj_alloc3, _Alloc>; + using _Refoa = _Ref_count_obj_alloc_for_overwrite, _Alloc>; using _Alblock = _Rebind_alloc_t<_Alloc, _Refoa>; _Alblock _Rebound(_Al); _Alloc_construct_ptr<_Alblock> _Constructor{_Rebound}; _Constructor._Allocate(); - _STD _Construct_in_place(*_Constructor._Ptr, _Al, _For_overwrite_tag{}); + _STD _Construct_in_place(*_Constructor._Ptr, _Al); const auto _Ptr = reinterpret_cast<_Ty*>(_STD addressof(_Constructor._Ptr->_Storage._Value)); _Ret._Set_ptr_rep_and_enable_shared(_Ptr, _STD _Unfancy(_Constructor._Release())); } @@ -2979,7 +3117,7 @@ _NODISCARD_SMART_PTR_ALLOC enable_if_t, shared_ptr<_T _EXPORT_STD template _NODISCARD_SMART_PTR_ALLOC enable_if_t, shared_ptr<_Ty>> allocate_shared_for_overwrite( const _Alloc& _Al, const size_t _Count) { - return _Allocate_shared_unbounded_array<_Ty>(_Al, _Count, _For_overwrite_tag{}); + return _Allocate_shared_unbounded_array(_Al, _Count); } #endif // _HAS_CXX20 diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index b5780ecd5ed..248dd417440 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -1155,9 +1155,6 @@ std/localization/locales/locale/locale.cons/name_construction.pass.cpp FAIL # Not analyzed. After LLVM-74630 fixes LLVM-74214, will be blocked by our ctype_base deriving from locale::facet. std/localization/locale.categories/category.numeric/locale.num.get/user_defined_char_type.pass.cpp FAIL -# Not analyzed. Assertion failed: alloc_stats.destroy_count == 0 -std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_for_overwrite.pass.cpp FAIL - # Not analyzed. Assertion failed: res == cvt.ok std/localization/codecvt_unicode.pass.cpp FAIL From c5e9583748acdbcc77223d1f0007e20d6bc28ef6 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Wed, 31 Jan 2024 04:30:32 +0800 Subject: [PATCH 6/8] ``: Remove non-conforming extension `ios_base::hexfloat` (#4345) --- stl/inc/ios | 4 ++-- stl/inc/xiosbase | 2 -- stl/inc/xlocnum | 6 +++--- tests/tr1/tests/ios/test.cpp | 18 ++++++++---------- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/stl/inc/ios b/stl/inc/ios index 881c292ba29..24353546712 100644 --- a/stl/inc/ios +++ b/stl/inc/ios @@ -206,8 +206,8 @@ _EXPORT_STD inline ios_base& __CLRCALL_OR_CDECL hex(ios_base& _Iosbase) { // set return _Iosbase; } -_EXPORT_STD inline ios_base& __CLRCALL_OR_CDECL hexfloat(ios_base& _Iosbase) { // set floatfield to hexfloat - _Iosbase.setf(ios_base::hexfloat, ios_base::floatfield); +_EXPORT_STD inline ios_base& __CLRCALL_OR_CDECL hexfloat(ios_base& _Iosbase) { // set floatfield to (scientific | fixed) + _Iosbase.setf(ios_base::scientific | ios_base::fixed, ios_base::floatfield); return _Iosbase; } diff --git a/stl/inc/xiosbase b/stl/inc/xiosbase index a1b5ff24ae3..af192b61692 100644 --- a/stl/inc/xiosbase +++ b/stl/inc/xiosbase @@ -42,8 +42,6 @@ public: static constexpr int scientific = 0x1000; static constexpr int fixed = 0x2000; - static constexpr int hexfloat = 0x3000; // TRANSITION, ABI, GH-3296 - static constexpr int boolalpha = 0x4000; static constexpr int adjustfield = left | right | internal; static constexpr int basefield = dec | oct | hex; diff --git a/stl/inc/xlocnum b/stl/inc/xlocnum index cb0ddec7575..619596ea9d1 100644 --- a/stl/inc/xlocnum +++ b/stl/inc/xlocnum @@ -1441,7 +1441,7 @@ private: if (_Flags & ios_base::uppercase) { if (_Ffl == ios_base::fixed) { _Ch = 'f'; - } else if (_Ffl == ios_base::hexfloat) { + } else if (_Ffl == (ios_base::scientific | ios_base::fixed)) { _Ch = 'A'; // added with TR1 } else if (_Ffl == ios_base::scientific) { _Ch = 'E'; @@ -1451,7 +1451,7 @@ private: } else { if (_Ffl == ios_base::fixed) { _Ch = 'f'; - } else if (_Ffl == ios_base::hexfloat) { + } else if (_Ffl == (ios_base::scientific | ios_base::fixed)) { _Ch = 'a'; // added with TR1 } else if (_Ffl == ios_base::scientific) { _Ch = 'e'; @@ -1475,7 +1475,7 @@ private: bool _Is_finite_val) const { // put formatted floating-point to _Dest auto _Prefix = static_cast(0 < _Count && (*_Buf == '+' || *_Buf == '-')); const char* _Exps; - if ((_Iosbase.flags() & ios_base::floatfield) != ios_base::hexfloat) { + if ((_Iosbase.flags() & ios_base::floatfield) != (ios_base::scientific | ios_base::fixed)) { _Exps = "eE"; } else { // correct for hexadecimal floating-point _Exps = "pP"; diff --git a/tests/tr1/tests/ios/test.cpp b/tests/tr1/tests/ios/test.cpp index 43cb33b11be..f425e7e7ba1 100644 --- a/tests/tr1/tests/ios/test.cpp +++ b/tests/tr1/tests/ios/test.cpp @@ -12,11 +12,11 @@ #include // static data -static const STD ios_base::fmtflags ffl[] = {STD ios_base::hexfloat, STD ios_base::dec, STD ios_base::fixed, - STD ios_base::hex, STD ios_base::internal, STD ios_base::left, STD ios_base::oct, STD ios_base::right, - STD ios_base::scientific, STD ios_base::showbase, STD ios_base::showpoint, STD ios_base::showpos, - STD ios_base::skipws, STD ios_base::unitbuf, STD ios_base::uppercase, STD ios_base::boolalpha, - STD ios_base::adjustfield, STD ios_base::basefield, STD ios_base::floatfield}; +static const STD ios_base::fmtflags ffl[] = {STD ios_base::dec, STD ios_base::fixed, STD ios_base::hex, + STD ios_base::internal, STD ios_base::left, STD ios_base::oct, STD ios_base::right, STD ios_base::scientific, + STD ios_base::showbase, STD ios_base::showpoint, STD ios_base::showpos, STD ios_base::skipws, STD ios_base::unitbuf, + STD ios_base::uppercase, STD ios_base::boolalpha, STD ios_base::adjustfield, STD ios_base::basefield, + STD ios_base::floatfield}; static const STD ios_base::iostate ifl[] = { STD ios_base::badbit, STD ios_base::eofbit, STD ios_base::failbit, STD ios_base::goodbit}; @@ -86,8 +86,6 @@ void test_main() { // test basic workings of ios definitions CHECK_INT(STD ios_base::dec | STD ios_base::oct | STD ios_base::hex, STD ios_base::basefield); CHECK_INT(STD ios_base::scientific | STD ios_base::fixed, STD ios_base::floatfield); - CHECK_INT(STD ios_base::scientific | STD ios_base::fixed, STD ios_base::hexfloat); - // test assignment and control functions CHECK(x && true); CHECK(!x == 0); @@ -170,7 +168,7 @@ void test_main() { // test basic workings of ios definitions CHECK_INT(x.flags(), STD ios_base::scientific | STD ios_base::unitbuf); x.clear(STD ios_base::floatfield); - x.setf(STD ios_base::hexfloat); + x.setf(STD ios_base::scientific | STD ios_base::fixed); CHECK_INT(x.flags(), STD ios_base::scientific | STD ios_base::fixed | STD ios_base::unitbuf); CHECK_INT(x.precision(INT_MIN), 6); @@ -216,13 +214,13 @@ void test_main() { // test basic workings of ios definitions CHECK_INT(po->flags(), STD ios_base::oct | STD ios_base::right | STD ios_base::scientific); STD hexfloat(*po); - CHECK_INT(po->flags(), STD ios_base::oct | STD ios_base::right | STD ios_base::hexfloat); + CHECK_INT(po->flags(), STD ios_base::oct | STD ios_base::right | STD ios_base::scientific | STD ios_base::fixed); STD defaultfloat(*po); CHECK_INT(po->flags(), STD ios_base::oct | STD ios_base::right); STD hexfloat(*po); - CHECK_INT(po->flags(), STD ios_base::oct | STD ios_base::right | STD ios_base::hexfloat); + CHECK_INT(po->flags(), STD ios_base::oct | STD ios_base::right | STD ios_base::scientific | STD ios_base::fixed); STD error_code ec1 = STD make_error_code(STD io_errc::stream); CHECK(ec1.value() == (int) STD io_errc::stream); From b89a78038285c852b52633e65d304a4f2cceea2d Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Wed, 31 Jan 2024 04:48:52 +0800 Subject: [PATCH 7/8] ADL-proof implementation of [alg.merge], [alg.set.operations], [alg.heap.operations], and [alg.permutation.generators] (#4347) Co-authored-by: Stephan T. Lavavej --- stl/inc/algorithm | 546 +++++++++--------- stl/inc/execution | 68 +-- stl/inc/xmemory | 22 +- stl/inc/xutility | 20 +- .../test.compile.pass.cpp | 78 +++ .../test.compile.pass.cpp | 78 +++ 6 files changed, 491 insertions(+), 321 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index e793f01a441..47f957d9ed2 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -150,7 +150,7 @@ struct _Optimistic_temporary_buffer { // temporary storage with _alloca-like att } // less heap space than stack space, give up and use stack instead - _Return_temporary_buffer(_Raw.first); + _STD _Return_temporary_buffer(_Raw.first); _Data = reinterpret_cast<_Ty*>(&_Stack_space[0]); _Capacity = _Optimistic_count; } @@ -160,7 +160,7 @@ struct _Optimistic_temporary_buffer { // temporary storage with _alloca-like att ~_Optimistic_temporary_buffer() noexcept { if (static_cast(_Capacity) > _Optimistic_count) { - _Return_temporary_buffer(_Data); + _STD _Return_temporary_buffer(_Data); } } @@ -5956,7 +5956,7 @@ _BidIt _Buffered_rotate_unchecked(const _BidIt _First, const _BidIt _Mid, const if (_Count2 <= _Capacity) { // buffer right range, then copy parts _Uninitialized_backout<_Iter_value_t<_BidIt>*> _Backout{ _Temp_ptr, _STD _Uninitialized_move_unchecked(_Mid, _Last, _Temp_ptr)}; - _Move_backward_unchecked(_First, _Mid, _Last); + _STD _Move_backward_unchecked(_First, _Mid, _Last); return _STD _Move_unchecked(_Backout._First, _Backout._Last, _First); // ditto _Backout destroys elements } @@ -6316,14 +6316,14 @@ _CONSTEXPR20 void _Push_heap_by_index( _EXPORT_STD template _CONSTEXPR20 void push_heap(_RanIt _First, _RanIt _Last, _Pr _Pred) { // push *(_Last - 1) onto heap at [_First, _Last - 1) - _Adl_verify_range(_First, _Last); - const auto _UFirst = _Get_unwrapped(_First); - auto _ULast = _Get_unwrapped(_Last); + _STD _Adl_verify_range(_First, _Last); + const auto _UFirst = _STD _Get_unwrapped(_First); + auto _ULast = _STD _Get_unwrapped(_Last); using _Diff = _Iter_diff_t<_RanIt>; _Diff _Count = _ULast - _UFirst; if (2 <= _Count) { _Iter_value_t<_RanIt> _Val(_STD move(*--_ULast)); - _STD _Push_heap_by_index(_UFirst, --_Count, _Diff(0), _STD move(_Val), _Pass_fn(_Pred)); + _STD _Push_heap_by_index(_UFirst, --_Count, _Diff(0), _STD move(_Val), _STD _Pass_fn(_Pred)); } } @@ -6360,11 +6360,11 @@ namespace ranges { template _Se, class _Pr = ranges::less, class _Pj = identity> requires sortable<_It, _Pr, _Pj> constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { - _Adl_verify_range(_First, _Last); - auto _UFirst = _Unwrap_iter<_Se>(_STD move(_First)); - auto _ULast = _Get_final_iterator_unwrapped<_It>(_UFirst, _STD move(_Last)); - _Seek_wrapped(_First, _ULast); - _Push_heap_unchecked(_STD move(_UFirst), _STD move(_ULast), _Pass_fn(_Pred), _Pass_fn(_Proj)); + _STD _Adl_verify_range(_First, _Last); + auto _UFirst = _RANGES _Unwrap_iter<_Se>(_STD move(_First)); + auto _ULast = _RANGES _Get_final_iterator_unwrapped<_It>(_UFirst, _STD move(_Last)); + _STD _Seek_wrapped(_First, _ULast); + _Push_heap_unchecked(_STD move(_UFirst), _STD move(_ULast), _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); return _First; } @@ -6372,12 +6372,12 @@ namespace ranges { requires sortable, _Pr, _Pj> constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { if constexpr (common_range<_Rng>) { - _Push_heap_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); + _Push_heap_unchecked(_Ubegin(_Range), _Uend(_Range), _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); return _RANGES end(_Range); } else { - auto _ULast = _Get_final_iterator_unwrapped(_Range); - _Push_heap_unchecked(_Ubegin(_Range), _ULast, _Pass_fn(_Pred), _Pass_fn(_Proj)); - return _Rewrap_iterator(_Range, _STD move(_ULast)); + auto _ULast = _RANGES _Get_final_iterator_unwrapped(_Range); + _Push_heap_unchecked(_Ubegin(_Range), _ULast, _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); + return _RANGES _Rewrap_iterator(_Range, _STD move(_ULast)); } } @@ -6457,8 +6457,8 @@ _CONSTEXPR20 void _Pop_heap_unchecked(_RanIt _First, _RanIt _Last, _Pr _Pred) { _EXPORT_STD template _CONSTEXPR20 void pop_heap(_RanIt _First, _RanIt _Last, _Pr _Pred) { // pop *_First to *(_Last - 1) and reheap - _Adl_verify_range(_First, _Last); - _STD _Pop_heap_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred)); + _STD _Adl_verify_range(_First, _Last); + _STD _Pop_heap_unchecked(_STD _Get_unwrapped(_First), _STD _Get_unwrapped(_Last), _STD _Pass_fn(_Pred)); } _EXPORT_STD template @@ -6537,11 +6537,12 @@ namespace ranges { template _Se, class _Pr = ranges::less, class _Pj = identity> requires sortable<_It, _Pr, _Pj> constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { - _Adl_verify_range(_First, _Last); - auto _UFirst = _Unwrap_iter<_Se>(_STD move(_First)); - auto _ULast = _Get_final_iterator_unwrapped<_It>(_UFirst, _STD move(_Last)); - _Seek_wrapped(_First, _ULast); - _RANGES _Pop_heap_unchecked(_STD move(_UFirst), _STD move(_ULast), _Pass_fn(_Pred), _Pass_fn(_Proj)); + _STD _Adl_verify_range(_First, _Last); + auto _UFirst = _RANGES _Unwrap_iter<_Se>(_STD move(_First)); + auto _ULast = _RANGES _Get_final_iterator_unwrapped<_It>(_UFirst, _STD move(_Last)); + _STD _Seek_wrapped(_First, _ULast); + _RANGES _Pop_heap_unchecked( + _STD move(_UFirst), _STD move(_ULast), _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); return _First; } @@ -6549,11 +6550,11 @@ namespace ranges { requires sortable, _Pr, _Pj> constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { if constexpr (common_range<_Rng>) { - _RANGES _Pop_heap_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); + _RANGES _Pop_heap_unchecked(_Ubegin(_Range), _Uend(_Range), _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); return _RANGES end(_Range); } else { auto _ULast = _Get_final_iterator_unwrapped(_Range); - _RANGES _Pop_heap_unchecked(_Ubegin(_Range), _ULast, _Pass_fn(_Pred), _Pass_fn(_Proj)); + _RANGES _Pop_heap_unchecked(_Ubegin(_Range), _ULast, _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); return _Rewrap_iterator(_Range, _STD move(_ULast)); } } @@ -6578,8 +6579,8 @@ _CONSTEXPR20 void _Make_heap_unchecked(_RanIt _First, _RanIt _Last, _Pr _Pred) { _EXPORT_STD template _CONSTEXPR20 void make_heap(_RanIt _First, _RanIt _Last, _Pr _Pred) { // make [_First, _Last) into a heap - _Adl_verify_range(_First, _Last); - _Make_heap_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred)); + _STD _Adl_verify_range(_First, _Last); + _STD _Make_heap_unchecked(_STD _Get_unwrapped(_First), _STD _Get_unwrapped(_Last), _STD _Pass_fn(_Pred)); } _EXPORT_STD template @@ -6609,11 +6610,12 @@ namespace ranges { template _Se, class _Pr = ranges::less, class _Pj = identity> requires sortable<_It, _Pr, _Pj> constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { - _Adl_verify_range(_First, _Last); - auto _UFirst = _Unwrap_iter<_Se>(_STD move(_First)); - auto _ULast = _Get_final_iterator_unwrapped<_It>(_UFirst, _STD move(_Last)); - _Seek_wrapped(_First, _ULast); - _Make_heap_common(_STD move(_UFirst), _STD move(_ULast), _Pass_fn(_Pred), _Pass_fn(_Proj)); + _STD _Adl_verify_range(_First, _Last); + auto _UFirst = _RANGES _Unwrap_iter<_Se>(_STD move(_First)); + auto _ULast = _RANGES _Get_final_iterator_unwrapped<_It>(_UFirst, _STD move(_Last)); + _STD _Seek_wrapped(_First, _ULast); + _RANGES _Make_heap_common( + _STD move(_UFirst), _STD move(_ULast), _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); return _First; } @@ -6621,12 +6623,12 @@ namespace ranges { requires sortable, _Pr, _Pj> constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { if constexpr (common_range<_Rng>) { - _Make_heap_common(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); + _RANGES _Make_heap_common(_Ubegin(_Range), _Uend(_Range), _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); return _RANGES end(_Range); } else { - auto _ULast = _Get_final_iterator_unwrapped(_Range); - _Make_heap_common(_Ubegin(_Range), _ULast, _Pass_fn(_Pred), _Pass_fn(_Proj)); - return _Rewrap_iterator(_Range, _STD move(_ULast)); + auto _ULast = _RANGES _Get_final_iterator_unwrapped(_Range); + _RANGES _Make_heap_common(_Ubegin(_Range), _ULast, _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); + return _RANGES _Rewrap_iterator(_Range, _STD move(_ULast)); } } }; @@ -6652,19 +6654,19 @@ _CONSTEXPR20 _RanIt _Is_heap_until_unchecked(_RanIt _First, _RanIt _Last, _Pr _P _EXPORT_STD template _NODISCARD _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last, _Pr _Pred) { // find extent of range that is a heap - _Adl_verify_range(_First, _Last); - _Seek_wrapped( - _First, _STD _Is_heap_until_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred))); + _STD _Adl_verify_range(_First, _Last); + _STD _Seek_wrapped(_First, + _STD _Is_heap_until_unchecked(_STD _Get_unwrapped(_First), _STD _Get_unwrapped(_Last), _STD _Pass_fn(_Pred))); return _First; } _EXPORT_STD template _NODISCARD _CONSTEXPR20 bool is_heap(_RanIt _First, _RanIt _Last, _Pr _Pred) { // test if range is a heap - _Adl_verify_range(_First, _Last); - const auto _UFirst = _Get_unwrapped(_First); - const auto _ULast = _Get_unwrapped(_Last); - return _STD _Is_heap_until_unchecked(_UFirst, _ULast, _Pass_fn(_Pred)) == _ULast; + _STD _Adl_verify_range(_First, _Last); + const auto _UFirst = _STD _Get_unwrapped(_First); + const auto _ULast = _STD _Get_unwrapped(_Last); + return _STD _Is_heap_until_unchecked(_UFirst, _ULast, _STD _Pass_fn(_Pred)) == _ULast; } _EXPORT_STD template @@ -6685,7 +6687,7 @@ _NODISCARD _RanIt is_heap_until(_ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _EXPORT_STD template = 0> _NODISCARD bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept /* terminates */ { // test if range is a heap - return _STD is_heap_until(_STD forward<_ExPo>(_Exec), _First, _Last, _Pass_fn(_Pred)) == _Last; + return _STD is_heap_until(_STD forward<_ExPo>(_Exec), _First, _Last, _STD _Pass_fn(_Pred)) == _Last; } _EXPORT_STD template = 0> @@ -6731,12 +6733,12 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { - _Adl_verify_range(_First, _Last); - auto _UFirst = _Unwrap_iter<_Se>(_STD move(_First)); - const auto _ULast = _Unwrap_sent<_It>(_STD move(_Last)); + _STD _Adl_verify_range(_First, _Last); + auto _UFirst = _RANGES _Unwrap_iter<_Se>(_STD move(_First)); + const auto _ULast = _RANGES _Unwrap_sent<_It>(_STD move(_Last)); const auto _Size = _RANGES distance(_UFirst, _ULast); const auto _UResult = - _RANGES _Is_heap_until_unchecked(_STD move(_UFirst), _Size, _Pass_fn(_Pred), _Pass_fn(_Proj)); + _RANGES _Is_heap_until_unchecked(_STD move(_UFirst), _Size, _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); return _UResult == _ULast; } @@ -6745,7 +6747,7 @@ namespace ranges { _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Size = _RANGES distance(_Range); const auto _UResult = - _RANGES _Is_heap_until_unchecked(_Ubegin(_Range), _Size, _Pass_fn(_Pred), _Pass_fn(_Proj)); + _RANGES _Is_heap_until_unchecked(_Ubegin(_Range), _Size, _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); return _UResult == _Uend(_Range); } }; @@ -6757,12 +6759,12 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> _NODISCARD constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { - _Adl_verify_range(_First, _Last); - auto _UFirst = _Unwrap_iter<_Se>(_STD move(_First)); - const auto _Size = _RANGES distance(_UFirst, _Unwrap_sent<_It>(_STD move(_Last))); + _STD _Adl_verify_range(_First, _Last); + auto _UFirst = _RANGES _Unwrap_iter<_Se>(_STD move(_First)); + const auto _Size = _RANGES distance(_UFirst, _RANGES _Unwrap_sent<_It>(_STD move(_Last))); auto _UResult = - _RANGES _Is_heap_until_unchecked(_STD move(_UFirst), _Size, _Pass_fn(_Pred), _Pass_fn(_Proj)); - _Seek_wrapped(_First, _STD move(_UResult)); + _RANGES _Is_heap_until_unchecked(_STD move(_UFirst), _Size, _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); + _STD _Seek_wrapped(_First, _STD move(_UResult)); return _First; } @@ -6770,8 +6772,9 @@ namespace ranges { indirect_strict_weak_order, _Pj>> _Pr = ranges::less> _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Size = _RANGES distance(_Range); - auto _UResult = _RANGES _Is_heap_until_unchecked(_Ubegin(_Range), _Size, _Pass_fn(_Pred), _Pass_fn(_Proj)); - return _Rewrap_iterator(_Range, _STD move(_UResult)); + auto _UResult = + _RANGES _Is_heap_until_unchecked(_Ubegin(_Range), _Size, _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); + return _RANGES _Rewrap_iterator(_Range, _STD move(_UResult)); } }; @@ -6790,16 +6793,16 @@ _CONSTEXPR20 void _Sort_heap_unchecked(_RanIt _First, _RanIt _Last, _Pr _Pred) { _EXPORT_STD template _CONSTEXPR20 void sort_heap(_RanIt _First, _RanIt _Last, _Pr _Pred) { // order heap by repeatedly popping - _Adl_verify_range(_First, _Last); - const auto _UFirst = _Get_unwrapped(_First); - const auto _ULast = _Get_unwrapped(_Last); + _STD _Adl_verify_range(_First, _Last); + const auto _UFirst = _STD _Get_unwrapped(_First); + const auto _ULast = _STD _Get_unwrapped(_Last); #if _ITERATOR_DEBUG_LEVEL == 2 - const auto _Counterexample = _STD _Is_heap_until_unchecked(_UFirst, _ULast, _Pass_fn(_Pred)); + const auto _Counterexample = _STD _Is_heap_until_unchecked(_UFirst, _ULast, _STD _Pass_fn(_Pred)); if (_Counterexample != _ULast) { _STL_REPORT_ERROR("invalid heap in sort_heap()"); } #endif // _ITERATOR_DEBUG_LEVEL == 2 - _Sort_heap_unchecked(_UFirst, _ULast, _Pass_fn(_Pred)); + _STD _Sort_heap_unchecked(_UFirst, _ULast, _STD _Pass_fn(_Pred)); } _EXPORT_STD template @@ -6823,11 +6826,12 @@ namespace ranges { template _Se, class _Pr = ranges::less, class _Pj = identity> requires sortable<_It, _Pr, _Pj> constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { - _Adl_verify_range(_First, _Last); - auto _UFirst = _Unwrap_iter<_Se>(_STD move(_First)); - auto _ULast = _Get_final_iterator_unwrapped<_It>(_UFirst, _STD move(_Last)); - _Seek_wrapped(_First, _ULast); - _Sort_heap_common(_STD move(_UFirst), _STD move(_ULast), _Pass_fn(_Pred), _Pass_fn(_Proj)); + _STD _Adl_verify_range(_First, _Last); + auto _UFirst = _RANGES _Unwrap_iter<_Se>(_STD move(_First)); + auto _ULast = _RANGES _Get_final_iterator_unwrapped<_It>(_UFirst, _STD move(_Last)); + _STD _Seek_wrapped(_First, _ULast); + _RANGES _Sort_heap_common( + _STD move(_UFirst), _STD move(_ULast), _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); return _First; } @@ -6835,12 +6839,12 @@ namespace ranges { requires sortable, _Pr, _Pj> constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { if constexpr (common_range<_Rng>) { - _Sort_heap_common(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); + _RANGES _Sort_heap_common(_Ubegin(_Range), _Uend(_Range), _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); return _RANGES end(_Range); } else { - auto _ULast = _Get_final_iterator_unwrapped(_Range); - _Sort_heap_common(_Ubegin(_Range), _ULast, _Pass_fn(_Pred), _Pass_fn(_Proj)); - return _Rewrap_iterator(_Range, _STD move(_ULast)); + auto _ULast = _RANGES _Get_final_iterator_unwrapped(_Range); + _RANGES _Sort_heap_common(_Ubegin(_Range), _ULast, _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); + return _RANGES _Rewrap_iterator(_Range, _STD move(_ULast)); } } }; @@ -7124,17 +7128,17 @@ _NODISCARD constexpr auto _Idl_dist_add(_Diff1 _Lhs, _Diff2 _Rhs) { _EXPORT_STD template _CONSTEXPR20 _OutIt merge(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2, _OutIt _Dest, _Pr _Pred) { // copy merging ranges - _Adl_verify_range(_First1, _Last1); - _Adl_verify_range(_First2, _Last2); - auto _UFirst1 = _Get_unwrapped(_First1); - const auto _ULast1 = _Get_unwrapped(_Last1); - auto _UFirst2 = _Get_unwrapped(_First2); - const auto _ULast2 = _Get_unwrapped(_Last2); + _STD _Adl_verify_range(_First1, _Last1); + _STD _Adl_verify_range(_First2, _Last2); + auto _UFirst1 = _STD _Get_unwrapped(_First1); + const auto _ULast1 = _STD _Get_unwrapped(_Last1); + auto _UFirst2 = _STD _Get_unwrapped(_First2); + const auto _ULast2 = _STD _Get_unwrapped(_Last2); _DEBUG_ORDER_SET_UNWRAPPED(_InIt2, _UFirst1, _ULast1, _Pred); _DEBUG_ORDER_SET_UNWRAPPED(_InIt1, _UFirst2, _ULast2, _Pred); - const auto _Count1 = _Idl_distance<_InIt1>(_UFirst1, _ULast1); - const auto _Count2 = _Idl_distance<_InIt2>(_UFirst2, _ULast2); - auto _UDest = _Get_unwrapped_n(_Dest, _Idl_dist_add(_Count1, _Count2)); + const auto _Count1 = _STD _Idl_distance<_InIt1>(_UFirst1, _ULast1); + const auto _Count2 = _STD _Idl_distance<_InIt2>(_UFirst2, _ULast2); + auto _UDest = _STD _Get_unwrapped_n(_Dest, _Idl_dist_add(_Count1, _Count2)); if (_UFirst1 != _ULast1 && _UFirst2 != _ULast2) { for (;;) { if (_DEBUG_LT_PRED(_Pred, *_UFirst2, *_UFirst1)) { @@ -7158,7 +7162,7 @@ _CONSTEXPR20 _OutIt merge(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 } _UDest = _STD _Copy_unchecked(_UFirst1, _ULast1, _UDest); // copy any tail - _Seek_wrapped(_Dest, _STD _Copy_unchecked(_UFirst2, _ULast2, _UDest)); + _STD _Seek_wrapped(_Dest, _STD _Copy_unchecked(_UFirst2, _ULast2, _UDest)); return _Dest; } @@ -7178,7 +7182,7 @@ _FwdIt3 merge(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); _REQUIRE_CPP17_MUTABLE_ITERATOR(_FwdIt3); - return _STD merge(_First1, _Last1, _First2, _Last2, _Dest, _Pass_fn(_Pred)); + return _STD merge(_First1, _Last1, _First2, _Last2, _Dest, _STD _Pass_fn(_Pred)); } _EXPORT_STD template constexpr merge_result<_It1, _It2, _Out> operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Out _Result, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { - _Adl_verify_range(_First1, _Last1); - _Adl_verify_range(_First2, _Last2); - auto _UResult = - _Merge_unchecked(_Unwrap_iter<_Se1>(_STD move(_First1)), _Unwrap_sent<_It1>(_STD move(_Last1)), - _Unwrap_iter<_Se2>(_STD move(_First2)), _Unwrap_sent<_It2>(_STD move(_Last2)), _STD move(_Result), - _Pass_fn(_Pred), _Pass_fn(_Proj1), _Pass_fn(_Proj2)); - _Seek_wrapped(_First1, _STD move(_UResult.in1)); - _Seek_wrapped(_First2, _STD move(_UResult.in2)); + _STD _Adl_verify_range(_First1, _Last1); + _STD _Adl_verify_range(_First2, _Last2); + auto _UResult = _Merge_unchecked(_RANGES _Unwrap_iter<_Se1>(_STD move(_First1)), + _RANGES _Unwrap_sent<_It1>(_STD move(_Last1)), _RANGES _Unwrap_iter<_Se2>(_STD move(_First2)), + _RANGES _Unwrap_sent<_It2>(_STD move(_Last2)), _STD move(_Result), _STD _Pass_fn(_Pred), + _STD _Pass_fn(_Proj1), _STD _Pass_fn(_Proj2)); + _STD _Seek_wrapped(_First1, _STD move(_UResult.in1)); + _STD _Seek_wrapped(_First2, _STD move(_UResult.in2)); return {_STD move(_First1), _STD move(_First2), _STD move(_UResult.out)}; } @@ -7223,11 +7227,11 @@ namespace ranges { _Rng1&& _Range1, _Rng2&& _Range2, _Out _Result, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { auto _First1 = _RANGES begin(_Range1); auto _First2 = _RANGES begin(_Range2); - auto _UResult = _Merge_unchecked(_Unwrap_range_iter<_Rng1>(_STD move(_First1)), _Uend(_Range1), - _Unwrap_range_iter<_Rng2>(_STD move(_First2)), _Uend(_Range2), _STD move(_Result), _Pass_fn(_Pred), - _Pass_fn(_Proj1), _Pass_fn(_Proj2)); - _Seek_wrapped(_First1, _STD move(_UResult.in1)); - _Seek_wrapped(_First2, _STD move(_UResult.in2)); + auto _UResult = _Merge_unchecked(_RANGES _Unwrap_range_iter<_Rng1>(_STD move(_First1)), _Uend(_Range1), + _RANGES _Unwrap_range_iter<_Rng2>(_STD move(_First2)), _Uend(_Range2), _STD move(_Result), + _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj1), _STD _Pass_fn(_Proj2)); + _STD _Seek_wrapped(_First1, _STD move(_UResult.in1)); + _STD _Seek_wrapped(_First2, _STD move(_UResult.in2)); return {_STD move(_First1), _STD move(_First2), _STD move(_UResult.out)}; } @@ -7284,7 +7288,7 @@ void _Rotate_one_right(_BidIt _First, _BidIt _Mid, _BidIt _Last) { // exchanges the range [_First, _Mid) with [_Mid, _Last) // pre: distance(_Mid, _Last) is 1 _Iter_value_t<_BidIt> _Temp(_STD move(*_Mid)); - _Move_backward_unchecked(_First, _Mid, _Last); + _STD _Move_backward_unchecked(_First, _Mid, _Last); *_First = _STD move(_Temp); } @@ -7346,7 +7350,7 @@ void _Inplace_merge_buffer_right( *--_Last = _STD move(*_Mid); if (_First == _Mid) { *--_Last = _STD move(*_Right_last); // to make [_Right_first, _Right_last) a half-open range - _Move_backward_unchecked(_Right_first, _Right_last, _Last); // move any head (and lowest element) + _STD _Move_backward_unchecked(_Right_first, _Right_last, _Last); // move any head (and lowest element) return; } @@ -7356,7 +7360,7 @@ void _Inplace_merge_buffer_right( --_Right_last; if (_Right_first == _Right_last) { // we can't compare with *_Right_first, but we know it is lowest *--_Last = _STD move(*_Mid); // restore half-open range [_First, _Mid) - _Move_backward_unchecked(_First, _Mid, _Last); + _STD _Move_backward_unchecked(_First, _Mid, _Last); *_First = _STD move(*_Right_first); return; } @@ -7374,11 +7378,11 @@ void _Buffered_inplace_merge_divide_and_conquer2(_BidIt _First, _BidIt _Mid, _Bi _BidIt _Firstn, _BidIt _Lastn, _Iter_diff_t<_BidIt> _Count1n, _Iter_diff_t<_BidIt> _Count2n) { // common block of _Buffered_inplace_merge_divide_and_conquer, below using _Diff = _Iter_diff_t<_BidIt>; - _BidIt _Midn = _Buffered_rotate_unchecked(_Firstn, _Mid, _Lastn, static_cast<_Diff>(_Count1 - _Count1n), _Count2n, - _Temp_ptr, _Capacity); // rearrange middle - _Buffered_inplace_merge_unchecked( + _BidIt _Midn = _STD _Buffered_rotate_unchecked(_Firstn, _Mid, _Lastn, static_cast<_Diff>(_Count1 - _Count1n), + _Count2n, _Temp_ptr, _Capacity); // rearrange middle + _STD _Buffered_inplace_merge_unchecked( _First, _Firstn, _Midn, _Count1n, _Count2n, _Temp_ptr, _Capacity, _Pred); // merge each new part - _Buffered_inplace_merge_unchecked(_Midn, _Lastn, _Last, static_cast<_Diff>(_Count1 - _Count1n), + _STD _Buffered_inplace_merge_unchecked(_Midn, _Lastn, _Last, static_cast<_Diff>(_Count1 - _Count1n), static_cast<_Diff>(_Count2 - _Count2n), _Temp_ptr, _Capacity, _Pred); } @@ -7441,7 +7445,7 @@ void _Buffered_inplace_merge_unchecked(_BidIt _First, _BidIt _Mid, _BidIt _Last, --_Count1; } - const auto _Highest = _Prev_iter(_Mid); + const auto _Highest = _STD _Prev_iter(_Mid); do { --_Last; --_Count2; @@ -7459,17 +7463,17 @@ void _Buffered_inplace_merge_unchecked(_BidIt _First, _BidIt _Mid, _BidIt _Last, return; } - _Buffered_inplace_merge_unchecked_impl(_First, _Mid, _Last, _Count1, _Count2, _Temp_ptr, _Capacity, _Pred); + _STD _Buffered_inplace_merge_unchecked_impl(_First, _Mid, _Last, _Count1, _Count2, _Temp_ptr, _Capacity, _Pred); } _EXPORT_STD template void inplace_merge(_BidIt _First, _BidIt _Mid, _BidIt _Last, _Pr _Pred) { // merge [_First, _Mid) with [_Mid, _Last) - _Adl_verify_range(_First, _Mid); - _Adl_verify_range(_Mid, _Last); - auto _UFirst = _Get_unwrapped(_First); - auto _UMid = _Get_unwrapped(_Mid); - auto _ULast = _Get_unwrapped(_Last); + _STD _Adl_verify_range(_First, _Mid); + _STD _Adl_verify_range(_Mid, _Last); + auto _UFirst = _STD _Get_unwrapped(_First); + auto _UMid = _STD _Get_unwrapped(_Mid); + auto _ULast = _STD _Get_unwrapped(_Last); _DEBUG_ORDER_UNWRAPPED(_UFirst, _UMid, _Pred); // establish the usual invariants: @@ -7489,7 +7493,7 @@ void inplace_merge(_BidIt _First, _BidIt _Mid, _BidIt _Last, _Pr _Pred) { ++_UFirst; } - const auto _Highest = _Prev_iter(_UMid); + const auto _Highest = _STD _Prev_iter(_UMid); do { --_ULast; if (_UMid == _ULast) { // rotate only element remaining in right partition to the beginning, without allocating @@ -7509,8 +7513,8 @@ void inplace_merge(_BidIt _First, _BidIt _Mid, _BidIt _Last, _Pr _Pred) { const _Diff _Count2 = _STD distance(_UMid, _ULast); _Optimistic_temporary_buffer<_Iter_value_t<_BidIt>> _Temp_buf{(_STD min)(_Count1, _Count2)}; - _Buffered_inplace_merge_unchecked_impl( - _UFirst, _UMid, _ULast, _Count1, _Count2, _Temp_buf._Data, _Temp_buf._Capacity, _Pass_fn(_Pred)); + _STD _Buffered_inplace_merge_unchecked_impl( + _UFirst, _UMid, _ULast, _Count1, _Count2, _Temp_buf._Data, _Temp_buf._Capacity, _STD _Pass_fn(_Pred)); } _EXPORT_STD template @@ -7525,7 +7529,7 @@ void inplace_merge(_ExPo&&, _BidIt _First, _BidIt _Mid, _BidIt _Last, _Pr _Pred) // merge [_First, _Mid) with [_Mid, _Last) // not parallelized at present, parallelism expected to be feasible in a future release _REQUIRE_CPP17_MUTABLE_BIDIRECTIONAL_ITERATOR(_BidIt); - _STD inplace_merge(_First, _Mid, _Last, _Pass_fn(_Pred)); + _STD inplace_merge(_First, _Mid, _Last, _STD _Pass_fn(_Pred)); } _EXPORT_STD template = 0> @@ -7760,15 +7764,15 @@ namespace ranges { template _Se, class _Pr = ranges::less, class _Pj = identity> requires sortable<_It, _Pr, _Pj> _It operator()(_It _First, _It _Mid, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { - _Adl_verify_range(_First, _Mid); - _Adl_verify_range(_Mid, _Last); + _STD _Adl_verify_range(_First, _Mid); + _STD _Adl_verify_range(_Mid, _Last); - auto _UFirst = _Unwrap_iter<_Se>(_STD move(_First)); - auto _ULast = _Get_final_iterator_unwrapped<_It>(_UFirst, _STD move(_Last)); - _Seek_wrapped(_First, _ULast); + auto _UFirst = _RANGES _Unwrap_iter<_Se>(_STD move(_First)); + auto _ULast = _RANGES _Get_final_iterator_unwrapped<_It>(_UFirst, _STD move(_Last)); + _STD _Seek_wrapped(_First, _ULast); - _Inplace_merge_common(_STD move(_UFirst), _Unwrap_iter<_Se>(_STD move(_Mid)), _STD move(_ULast), - _Pass_fn(_Pred), _Pass_fn(_Proj)); + _Inplace_merge_common(_STD move(_UFirst), _RANGES _Unwrap_iter<_Se>(_STD move(_Mid)), _STD move(_ULast), + _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); return _First; } @@ -7779,15 +7783,15 @@ namespace ranges { auto _First = _RANGES begin(_Range); auto _Last = _RANGES end(_Range); - _Adl_verify_range(_First, _Mid); - _Adl_verify_range(_Mid, _Last); + _STD _Adl_verify_range(_First, _Mid); + _STD _Adl_verify_range(_Mid, _Last); - auto _UFirst = _Unwrap_range_iter<_Rng>(_STD move(_First)); - auto _ULast = _Get_final_iterator_unwrapped>(_UFirst, _STD move(_Last)); - _Seek_wrapped(_First, _ULast); + auto _UFirst = _RANGES _Unwrap_range_iter<_Rng>(_STD move(_First)); + auto _ULast = _RANGES _Get_final_iterator_unwrapped>(_UFirst, _STD move(_Last)); + _STD _Seek_wrapped(_First, _ULast); - _Inplace_merge_common(_STD move(_UFirst), _Unwrap_range_iter<_Rng>(_STD move(_Mid)), _STD move(_ULast), - _Pass_fn(_Pred), _Pass_fn(_Proj)); + _Inplace_merge_common(_STD move(_UFirst), _RANGES _Unwrap_range_iter<_Rng>(_STD move(_Mid)), + _STD move(_ULast), _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); return _First; } @@ -9088,12 +9092,12 @@ namespace ranges { _EXPORT_STD template _NODISCARD _CONSTEXPR20 bool includes(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2, _Pr _Pred) { // test if every element in sorted [_First2, _Last2) is in sorted [_First1, _Last1) - _Adl_verify_range(_First1, _Last1); - _Adl_verify_range(_First2, _Last2); - auto _UFirst1 = _Get_unwrapped(_First1); - const auto _ULast1 = _Get_unwrapped(_Last1); - auto _UFirst2 = _Get_unwrapped(_First2); - const auto _ULast2 = _Get_unwrapped(_Last2); + _STD _Adl_verify_range(_First1, _Last1); + _STD _Adl_verify_range(_First2, _Last2); + auto _UFirst1 = _STD _Get_unwrapped(_First1); + const auto _ULast1 = _STD _Get_unwrapped(_Last1); + auto _UFirst2 = _STD _Get_unwrapped(_First2); + const auto _ULast2 = _STD _Get_unwrapped(_Last2); _DEBUG_ORDER_SET_UNWRAPPED(_InIt2, _UFirst1, _ULast1, _Pred); _DEBUG_ORDER_SET_UNWRAPPED(_InIt1, _UFirst2, _ULast2, _Pred); for (; _UFirst1 != _ULast1 && _UFirst2 != _ULast2; ++_UFirst1) { @@ -9123,7 +9127,7 @@ _NODISCARD bool includes(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _Firs // not parallelized at present, parallelism expected to be feasible in a future release _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); - return _STD includes(_First1, _Last1, _First2, _Last2, _Pass_fn(_Pred)); + return _STD includes(_First1, _Last1, _First2, _Last2, _STD _Pass_fn(_Pred)); } _EXPORT_STD template = 0> @@ -9145,11 +9149,12 @@ namespace ranges { indirect_strict_weak_order, projected<_It2, _Pj2>> _Pr = ranges::less> _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { - _Adl_verify_range(_First1, _Last1); - _Adl_verify_range(_First2, _Last2); - return _Includes_unchecked(_Unwrap_iter<_Se1>(_STD move(_First1)), _Unwrap_sent<_It1>(_STD move(_Last1)), - _Unwrap_iter<_Se2>(_STD move(_First2)), _Unwrap_sent<_It2>(_STD move(_Last2)), _Pass_fn(_Pred), - _Pass_fn(_Proj1), _Pass_fn(_Proj2)); + _STD _Adl_verify_range(_First1, _Last1); + _STD _Adl_verify_range(_First2, _Last2); + return _Includes_unchecked(_RANGES _Unwrap_iter<_Se1>(_STD move(_First1)), + _RANGES _Unwrap_sent<_It1>(_STD move(_Last1)), _RANGES _Unwrap_iter<_Se2>(_STD move(_First2)), + _RANGES _Unwrap_sent<_It2>(_STD move(_Last2)), _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj1), + _STD _Pass_fn(_Proj2)); } template _CONSTEXPR20 _OutIt set_union(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2, _OutIt _Dest, _Pr _Pred) { // OR sets [_First1, _Last1) and [_First2, _Last2) - _Adl_verify_range(_First1, _Last1); - _Adl_verify_range(_First2, _Last2); - auto _UFirst1 = _Get_unwrapped(_First1); - const auto _ULast1 = _Get_unwrapped(_Last1); - auto _UFirst2 = _Get_unwrapped(_First2); - const auto _ULast2 = _Get_unwrapped(_Last2); + _STD _Adl_verify_range(_First1, _Last1); + _STD _Adl_verify_range(_First2, _Last2); + auto _UFirst1 = _STD _Get_unwrapped(_First1); + const auto _ULast1 = _STD _Get_unwrapped(_Last1); + auto _UFirst2 = _STD _Get_unwrapped(_First2); + const auto _ULast2 = _STD _Get_unwrapped(_Last2); _DEBUG_ORDER_SET_UNWRAPPED(_InIt2, _UFirst1, _ULast1, _Pred); _DEBUG_ORDER_SET_UNWRAPPED(_InIt1, _UFirst2, _ULast2, _Pred); - auto _UDest = _Get_unwrapped_unverified(_Dest); + auto _UDest = _STD _Get_unwrapped_unverified(_Dest); for (; _UFirst1 != _ULast1 && _UFirst2 != _ULast2; ++_UDest) { if (_DEBUG_LT_PRED(_Pred, *_UFirst1, *_UFirst2)) { // copy first *_UDest = *_UFirst1; @@ -9234,7 +9239,7 @@ _CONSTEXPR20 _OutIt set_union(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _In } _UDest = _STD _Copy_unchecked(_UFirst1, _ULast1, _UDest); - _Seek_wrapped(_Dest, _STD _Copy_unchecked(_UFirst2, _ULast2, _UDest)); + _STD _Seek_wrapped(_Dest, _STD _Copy_unchecked(_UFirst2, _ULast2, _UDest)); return _Dest; } @@ -9254,7 +9259,7 @@ _FwdIt3 set_union(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Fw _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); _REQUIRE_CPP17_MUTABLE_ITERATOR(_FwdIt3); - return _STD set_union(_First1, _Last1, _First2, _Last2, _Dest, _Pass_fn(_Pred)); + return _STD set_union(_First1, _Last1, _First2, _Last2, _Dest, _STD _Pass_fn(_Pred)); } _EXPORT_STD template constexpr set_union_result<_It1, _It2, _Out> operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Out _Result, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { - _Adl_verify_range(_First1, _Last1); - _Adl_verify_range(_First2, _Last2); - auto _UResult = - _Set_union_unchecked(_Unwrap_iter<_Se1>(_STD move(_First1)), _Unwrap_sent<_It1>(_STD move(_Last1)), - _Unwrap_iter<_Se2>(_STD move(_First2)), _Unwrap_sent<_It2>(_STD move(_Last2)), - _Get_unwrapped_unverified(_STD move(_Result)), _Pass_fn(_Pred), _Pass_fn(_Proj1), _Pass_fn(_Proj2)); - _Seek_wrapped(_First1, _STD move(_UResult.in1)); - _Seek_wrapped(_First2, _STD move(_UResult.in2)); - _Seek_wrapped(_Result, _STD move(_UResult.out)); + _STD _Adl_verify_range(_First1, _Last1); + _STD _Adl_verify_range(_First2, _Last2); + auto _UResult = _Set_union_unchecked(_RANGES _Unwrap_iter<_Se1>(_STD move(_First1)), + _RANGES _Unwrap_sent<_It1>(_STD move(_Last1)), _RANGES _Unwrap_iter<_Se2>(_STD move(_First2)), + _RANGES _Unwrap_sent<_It2>(_STD move(_Last2)), _STD _Get_unwrapped_unverified(_STD move(_Result)), + _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj1), _STD _Pass_fn(_Proj2)); + _STD _Seek_wrapped(_First1, _STD move(_UResult.in1)); + _STD _Seek_wrapped(_First2, _STD move(_UResult.in2)); + _STD _Seek_wrapped(_Result, _STD move(_UResult.out)); return {_STD move(_First1), _STD move(_First2), _STD move(_Result)}; } @@ -9300,12 +9305,13 @@ namespace ranges { _Rng1&& _Range1, _Rng2&& _Range2, _Out _Result, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { auto _First1 = _RANGES begin(_Range1); auto _First2 = _RANGES begin(_Range2); - auto _UResult = _Set_union_unchecked(_Unwrap_range_iter<_Rng1>(_STD move(_First1)), _Uend(_Range1), - _Unwrap_range_iter<_Rng2>(_STD move(_First2)), _Uend(_Range2), - _Get_unwrapped_unverified(_STD move(_Result)), _Pass_fn(_Pred), _Pass_fn(_Proj1), _Pass_fn(_Proj2)); - _Seek_wrapped(_First1, _STD move(_UResult.in1)); - _Seek_wrapped(_First2, _STD move(_UResult.in2)); - _Seek_wrapped(_Result, _STD move(_UResult.out)); + auto _UResult = _Set_union_unchecked(_RANGES _Unwrap_range_iter<_Rng1>(_STD move(_First1)), _Uend(_Range1), + _RANGES _Unwrap_range_iter<_Rng2>(_STD move(_First2)), _Uend(_Range2), + _STD _Get_unwrapped_unverified(_STD move(_Result)), _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj1), + _STD _Pass_fn(_Proj2)); + _STD _Seek_wrapped(_First1, _STD move(_UResult.in1)); + _STD _Seek_wrapped(_First2, _STD move(_UResult.in2)); + _STD _Seek_wrapped(_Result, _STD move(_UResult.out)); return {_STD move(_First1), _STD move(_First2), _STD move(_Result)}; } @@ -9348,15 +9354,15 @@ _EXPORT_STD template _CONSTEXPR20 _OutIt set_intersection( _InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2, _OutIt _Dest, _Pr _Pred) { // AND sets [_First1, _Last1) and [_First2, _Last2) - _Adl_verify_range(_First1, _Last1); - _Adl_verify_range(_First2, _Last2); - auto _UFirst1 = _Get_unwrapped(_First1); - const auto _ULast1 = _Get_unwrapped(_Last1); - auto _UFirst2 = _Get_unwrapped(_First2); - const auto _ULast2 = _Get_unwrapped(_Last2); + _STD _Adl_verify_range(_First1, _Last1); + _STD _Adl_verify_range(_First2, _Last2); + auto _UFirst1 = _STD _Get_unwrapped(_First1); + const auto _ULast1 = _STD _Get_unwrapped(_Last1); + auto _UFirst2 = _STD _Get_unwrapped(_First2); + const auto _ULast2 = _STD _Get_unwrapped(_Last2); _DEBUG_ORDER_SET_UNWRAPPED(_InIt2, _UFirst1, _ULast1, _Pred); _DEBUG_ORDER_SET_UNWRAPPED(_InIt1, _UFirst2, _ULast2, _Pred); - auto _UDest = _Get_unwrapped_unverified(_Dest); + auto _UDest = _STD _Get_unwrapped_unverified(_Dest); while (_UFirst1 != _ULast1 && _UFirst2 != _ULast2) { if (_DEBUG_LT_PRED(_Pred, *_UFirst1, *_UFirst2)) { ++_UFirst1; @@ -9370,7 +9376,7 @@ _CONSTEXPR20 _OutIt set_intersection( } } - _Seek_wrapped(_Dest, _UDest); + _STD _Seek_wrapped(_Dest, _UDest); return _Dest; } @@ -9406,15 +9412,15 @@ namespace ranges { requires mergeable<_It1, _It2, _Out, _Pr, _Pj1, _Pj2> constexpr set_intersection_result<_It1, _It2, _Out> operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Out _Result, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { - _Adl_verify_range(_First1, _Last1); - _Adl_verify_range(_First2, _Last2); - auto _UResult = _Set_intersection_unchecked(_Unwrap_iter<_Se1>(_STD move(_First1)), - _Unwrap_sent<_It1>(_STD move(_Last1)), _Unwrap_iter<_Se2>(_STD move(_First2)), - _Unwrap_sent<_It2>(_STD move(_Last2)), _Get_unwrapped_unverified(_STD move(_Result)), _Pass_fn(_Pred), - _Pass_fn(_Proj1), _Pass_fn(_Proj2)); - _Seek_wrapped(_First1, _STD move(_UResult.in1)); - _Seek_wrapped(_First2, _STD move(_UResult.in2)); - _Seek_wrapped(_Result, _STD move(_UResult.out)); + _STD _Adl_verify_range(_First1, _Last1); + _STD _Adl_verify_range(_First2, _Last2); + auto _UResult = _Set_intersection_unchecked(_RANGES _Unwrap_iter<_Se1>(_STD move(_First1)), + _RANGES _Unwrap_sent<_It1>(_STD move(_Last1)), _RANGES _Unwrap_iter<_Se2>(_STD move(_First2)), + _RANGES _Unwrap_sent<_It2>(_STD move(_Last2)), _STD _Get_unwrapped_unverified(_STD move(_Result)), + _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj1), _STD _Pass_fn(_Proj2)); + _STD _Seek_wrapped(_First1, _STD move(_UResult.in1)); + _STD _Seek_wrapped(_First2, _STD move(_UResult.in2)); + _STD _Seek_wrapped(_Result, _STD move(_UResult.out)); return {_STD move(_First1), _STD move(_First2), _STD move(_Result)}; } @@ -9425,12 +9431,13 @@ namespace ranges { _Rng1&& _Range1, _Rng2&& _Range2, _Out _Result, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { auto _First1 = _RANGES begin(_Range1); auto _First2 = _RANGES begin(_Range2); - auto _UResult = _Set_intersection_unchecked(_Unwrap_range_iter<_Rng1>(_STD move(_First1)), _Uend(_Range1), - _Unwrap_range_iter<_Rng2>(_STD move(_First2)), _Uend(_Range2), - _Get_unwrapped_unverified(_STD move(_Result)), _Pass_fn(_Pred), _Pass_fn(_Proj1), _Pass_fn(_Proj2)); - _Seek_wrapped(_First1, _STD move(_UResult.in1)); - _Seek_wrapped(_First2, _STD move(_UResult.in2)); - _Seek_wrapped(_Result, _STD move(_UResult.out)); + auto _UResult = _Set_intersection_unchecked(_RANGES _Unwrap_range_iter<_Rng1>(_STD move(_First1)), + _Uend(_Range1), _RANGES _Unwrap_range_iter<_Rng2>(_STD move(_First2)), _Uend(_Range2), + _STD _Get_unwrapped_unverified(_STD move(_Result)), _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj1), + _STD _Pass_fn(_Proj2)); + _STD _Seek_wrapped(_First1, _STD move(_UResult.in1)); + _STD _Seek_wrapped(_First2, _STD move(_UResult.in2)); + _STD _Seek_wrapped(_Result, _STD move(_UResult.out)); return {_STD move(_First1), _STD move(_First2), _STD move(_Result)}; } @@ -9479,15 +9486,15 @@ _EXPORT_STD template _CONSTEXPR20 _OutIt set_difference( _InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2, _OutIt _Dest, _Pr _Pred) { // take set [_First2, _Last2) from [_First1, _Last1) - _Adl_verify_range(_First1, _Last1); - _Adl_verify_range(_First2, _Last2); - auto _UFirst1 = _Get_unwrapped(_First1); - const auto _ULast1 = _Get_unwrapped(_Last1); - auto _UFirst2 = _Get_unwrapped(_First2); - const auto _ULast2 = _Get_unwrapped(_Last2); + _STD _Adl_verify_range(_First1, _Last1); + _STD _Adl_verify_range(_First2, _Last2); + auto _UFirst1 = _STD _Get_unwrapped(_First1); + const auto _ULast1 = _STD _Get_unwrapped(_Last1); + auto _UFirst2 = _STD _Get_unwrapped(_First2); + const auto _ULast2 = _STD _Get_unwrapped(_Last2); _DEBUG_ORDER_SET_UNWRAPPED(_InIt2, _UFirst1, _ULast1, _Pred); _DEBUG_ORDER_SET_UNWRAPPED(_InIt1, _UFirst2, _ULast2, _Pred); - auto _UDest = _Get_unwrapped_unverified(_Dest); + auto _UDest = _STD _Get_unwrapped_unverified(_Dest); while (_UFirst1 != _ULast1 && _UFirst2 != _ULast2) { if (_DEBUG_LT_PRED(_Pred, *_UFirst1, *_UFirst2)) { // copy first *_UDest = *_UFirst1; @@ -9502,7 +9509,7 @@ _CONSTEXPR20 _OutIt set_difference( } } - _Seek_wrapped(_Dest, _STD _Copy_unchecked(_UFirst1, _ULast1, _UDest)); + _STD _Seek_wrapped(_Dest, _STD _Copy_unchecked(_UFirst1, _ULast1, _UDest)); return _Dest; } @@ -9538,14 +9545,14 @@ namespace ranges { requires mergeable<_It1, _It2, _Out, _Pr, _Pj1, _Pj2> constexpr set_difference_result<_It1, _Out> operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Out _Result, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { - _Adl_verify_range(_First1, _Last1); - _Adl_verify_range(_First2, _Last2); - auto _UResult = - _Set_difference_unchecked(_Unwrap_iter<_Se1>(_STD move(_First1)), _Unwrap_sent<_It1>(_STD move(_Last1)), - _Unwrap_iter<_Se2>(_STD move(_First2)), _Unwrap_sent<_It2>(_STD move(_Last2)), - _Get_unwrapped_unverified(_STD move(_Result)), _Pass_fn(_Pred), _Pass_fn(_Proj1), _Pass_fn(_Proj2)); - _Seek_wrapped(_First1, _STD move(_UResult.in)); - _Seek_wrapped(_Result, _STD move(_UResult.out)); + _STD _Adl_verify_range(_First1, _Last1); + _STD _Adl_verify_range(_First2, _Last2); + auto _UResult = _Set_difference_unchecked(_RANGES _Unwrap_iter<_Se1>(_STD move(_First1)), + _RANGES _Unwrap_sent<_It1>(_STD move(_Last1)), _RANGES _Unwrap_iter<_Se2>(_STD move(_First2)), + _RANGES _Unwrap_sent<_It2>(_STD move(_Last2)), _STD _Get_unwrapped_unverified(_STD move(_Result)), + _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj1), _STD _Pass_fn(_Proj2)); + _STD _Seek_wrapped(_First1, _STD move(_UResult.in)); + _STD _Seek_wrapped(_Result, _STD move(_UResult.out)); return {_STD move(_First1), _STD move(_Result)}; } @@ -9555,11 +9562,11 @@ namespace ranges { constexpr set_difference_result, _Out> operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Out _Result, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { auto _First1 = _RANGES begin(_Range1); - auto _UResult = _Set_difference_unchecked(_Unwrap_range_iter<_Rng1>(_STD move(_First1)), _Uend(_Range1), - _Ubegin(_Range2), _Uend(_Range2), _Get_unwrapped_unverified(_STD move(_Result)), _Pass_fn(_Pred), - _Pass_fn(_Proj1), _Pass_fn(_Proj2)); - _Seek_wrapped(_First1, _STD move(_UResult.in)); - _Seek_wrapped(_Result, _STD move(_UResult.out)); + auto _UResult = _Set_difference_unchecked(_RANGES _Unwrap_range_iter<_Rng1>(_STD move(_First1)), + _Uend(_Range1), _Ubegin(_Range2), _Uend(_Range2), _STD _Get_unwrapped_unverified(_STD move(_Result)), + _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj1), _STD _Pass_fn(_Proj2)); + _STD _Seek_wrapped(_First1, _STD move(_UResult.in)); + _STD _Seek_wrapped(_Result, _STD move(_UResult.out)); return {_STD move(_First1), _STD move(_Result)}; } @@ -9607,15 +9614,15 @@ _EXPORT_STD template _CONSTEXPR20 _OutIt set_symmetric_difference( _InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2, _OutIt _Dest, _Pr _Pred) { // XOR sets [_First1, _Last1) and [_First2, _Last2) - _Adl_verify_range(_First1, _Last1); - _Adl_verify_range(_First2, _Last2); - auto _UFirst1 = _Get_unwrapped(_First1); - const auto _ULast1 = _Get_unwrapped(_Last1); - auto _UFirst2 = _Get_unwrapped(_First2); - const auto _ULast2 = _Get_unwrapped(_Last2); + _STD _Adl_verify_range(_First1, _Last1); + _STD _Adl_verify_range(_First2, _Last2); + auto _UFirst1 = _STD _Get_unwrapped(_First1); + const auto _ULast1 = _STD _Get_unwrapped(_Last1); + auto _UFirst2 = _STD _Get_unwrapped(_First2); + const auto _ULast2 = _STD _Get_unwrapped(_Last2); _DEBUG_ORDER_SET_UNWRAPPED(_InIt2, _UFirst1, _ULast1, _Pred); _DEBUG_ORDER_SET_UNWRAPPED(_InIt1, _UFirst2, _ULast2, _Pred); - auto _UDest = _Get_unwrapped_unverified(_Dest); + auto _UDest = _STD _Get_unwrapped_unverified(_Dest); while (_UFirst1 != _ULast1 && _UFirst2 != _ULast2) { if (_DEBUG_LT_PRED(_Pred, *_UFirst1, *_UFirst2)) { // copy first *_UDest = *_UFirst1; @@ -9632,7 +9639,7 @@ _CONSTEXPR20 _OutIt set_symmetric_difference( } _UDest = _STD _Copy_unchecked(_UFirst1, _ULast1, _UDest); - _Seek_wrapped(_Dest, _STD _Copy_unchecked(_UFirst2, _ULast2, _UDest)); + _STD _Seek_wrapped(_Dest, _STD _Copy_unchecked(_UFirst2, _ULast2, _UDest)); return _Dest; } @@ -9653,7 +9660,7 @@ _FwdIt3 set_symmetric_difference(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdI _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); _REQUIRE_CPP17_MUTABLE_ITERATOR(_FwdIt3); - return _STD set_symmetric_difference(_First1, _Last1, _First2, _Last2, _Dest, _Pass_fn(_Pred)); + return _STD set_symmetric_difference(_First1, _Last1, _First2, _Last2, _Dest, _STD _Pass_fn(_Pred)); } _EXPORT_STD template constexpr set_symmetric_difference_result<_It1, _It2, _Out> operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Out _Result, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { - _Adl_verify_range(_First1, _Last1); - _Adl_verify_range(_First2, _Last2); - auto _UResult = _Set_symmetric_difference_unchecked(_Unwrap_iter<_Se1>(_STD move(_First1)), - _Unwrap_sent<_It1>(_STD move(_Last1)), _Unwrap_iter<_Se2>(_STD move(_First2)), - _Unwrap_sent<_It2>(_STD move(_Last2)), _Get_unwrapped_unverified(_STD move(_Result)), _Pass_fn(_Pred), - _Pass_fn(_Proj1), _Pass_fn(_Proj2)); - _Seek_wrapped(_First1, _STD move(_UResult.in1)); - _Seek_wrapped(_First2, _STD move(_UResult.in2)); - _Seek_wrapped(_Result, _STD move(_UResult.out)); + _STD _Adl_verify_range(_First1, _Last1); + _STD _Adl_verify_range(_First2, _Last2); + auto _UResult = _Set_symmetric_difference_unchecked(_RANGES _Unwrap_iter<_Se1>(_STD move(_First1)), + _RANGES _Unwrap_sent<_It1>(_STD move(_Last1)), _RANGES _Unwrap_iter<_Se2>(_STD move(_First2)), + _RANGES _Unwrap_sent<_It2>(_STD move(_Last2)), _STD _Get_unwrapped_unverified(_STD move(_Result)), + _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj1), _STD _Pass_fn(_Proj2)); + _STD _Seek_wrapped(_First1, _STD move(_UResult.in1)); + _STD _Seek_wrapped(_First2, _STD move(_UResult.in2)); + _STD _Seek_wrapped(_Result, _STD move(_UResult.out)); return {_STD move(_First1), _STD move(_First2), _STD move(_Result)}; } @@ -9700,12 +9707,13 @@ namespace ranges { _Pj2 _Proj2 = {}) const { auto _First1 = _RANGES begin(_Range1); auto _First2 = _RANGES begin(_Range2); - auto _UResult = _Set_symmetric_difference_unchecked(_Unwrap_range_iter<_Rng1>(_STD move(_First1)), - _Uend(_Range1), _Unwrap_range_iter<_Rng2>(_STD move(_First2)), _Uend(_Range2), - _Get_unwrapped_unverified(_STD move(_Result)), _Pass_fn(_Pred), _Pass_fn(_Proj1), _Pass_fn(_Proj2)); - _Seek_wrapped(_First1, _STD move(_UResult.in1)); - _Seek_wrapped(_First2, _STD move(_UResult.in2)); - _Seek_wrapped(_Result, _STD move(_UResult.out)); + auto _UResult = _Set_symmetric_difference_unchecked(_RANGES _Unwrap_range_iter<_Rng1>(_STD move(_First1)), + _Uend(_Range1), _RANGES _Unwrap_range_iter<_Rng2>(_STD move(_First2)), _Uend(_Range2), + _STD _Get_unwrapped_unverified(_STD move(_Result)), _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj1), + _STD _Pass_fn(_Proj2)); + _STD _Seek_wrapped(_First1, _STD move(_UResult.in1)); + _STD _Seek_wrapped(_First2, _STD move(_UResult.in2)); + _STD _Seek_wrapped(_Result, _STD move(_UResult.out)); return {_STD move(_First1), _STD move(_First2), _STD move(_Result)}; } @@ -10147,9 +10155,9 @@ namespace ranges { _EXPORT_STD template _CONSTEXPR20 bool next_permutation(_BidIt _First, _BidIt _Last, _Pr _Pred) { // permute and test for pure ascending - _Adl_verify_range(_First, _Last); - auto _UFirst = _Get_unwrapped(_First); - const auto _ULast = _Get_unwrapped(_Last); + _STD _Adl_verify_range(_First, _Last); + auto _UFirst = _STD _Get_unwrapped(_First); + const auto _ULast = _STD _Get_unwrapped(_Last); auto _UNext = _ULast; if (_UFirst == _ULast || _UFirst == --_UNext) { return false; @@ -10191,12 +10199,12 @@ namespace ranges { template _Se, class _Pr = ranges::less, class _Pj = identity> requires sortable<_It, _Pr, _Pj> constexpr next_permutation_result<_It> operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { - _Adl_verify_range(_First, _Last); - auto _UFirst = _Unwrap_iter<_Se>(_STD move(_First)); - auto _ULast = _Get_final_iterator_unwrapped<_It>(_UFirst, _STD move(_Last)); - _Seek_wrapped(_First, _ULast); - const bool _Found = - _Next_permutation_common(_STD move(_UFirst), _STD move(_ULast), _Pass_fn(_Pred), _Pass_fn(_Proj)); + _STD _Adl_verify_range(_First, _Last); + auto _UFirst = _RANGES _Unwrap_iter<_Se>(_STD move(_First)); + auto _ULast = _RANGES _Get_final_iterator_unwrapped<_It>(_UFirst, _STD move(_Last)); + _STD _Seek_wrapped(_First, _ULast); + const bool _Found = _Next_permutation_common( + _STD move(_UFirst), _STD move(_ULast), _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); return {_STD move(_First), _Found}; } @@ -10204,9 +10212,10 @@ namespace ranges { requires sortable, _Pr, _Pj> constexpr next_permutation_result> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { - auto _ULast = _Get_final_iterator_unwrapped(_Range); - const bool _Found = _Next_permutation_common(_Ubegin(_Range), _ULast, _Pass_fn(_Pred), _Pass_fn(_Proj)); - return {_Rewrap_iterator(_Range, _STD move(_ULast)), _Found}; + auto _ULast = _RANGES _Get_final_iterator_unwrapped(_Range); + const bool _Found = + _Next_permutation_common(_Ubegin(_Range), _ULast, _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); + return {_RANGES _Rewrap_iterator(_Range, _STD move(_ULast)), _Found}; } private: @@ -10230,12 +10239,12 @@ namespace ranges { } while (!_STD invoke(_Pred, _STD invoke(_Proj, *_Next), _STD invoke(_Proj, *_Mid))); _RANGES iter_swap(_Next, _Mid); - _Reverse_common(_STD move(_Next1), _STD move(_Last)); + _RANGES _Reverse_common(_STD move(_Next1), _STD move(_Last)); return true; } if (_Next == _First) { // pure descending, flip all - _Reverse_common(_STD move(_First), _STD move(_Last)); + _RANGES _Reverse_common(_STD move(_First), _STD move(_Last)); return false; } } @@ -10249,9 +10258,9 @@ namespace ranges { _EXPORT_STD template _CONSTEXPR20 bool prev_permutation(_BidIt _First, _BidIt _Last, _Pr _Pred) { // reverse permute and test for pure descending - _Adl_verify_range(_First, _Last); - auto _UFirst = _Get_unwrapped(_First); - const auto _ULast = _Get_unwrapped(_Last); + _STD _Adl_verify_range(_First, _Last); + auto _UFirst = _STD _Get_unwrapped(_First); + const auto _ULast = _STD _Get_unwrapped(_Last); auto _UNext = _ULast; if (_UFirst == _ULast || _UFirst == --_UNext) { return false; @@ -10293,12 +10302,12 @@ namespace ranges { template _Se, class _Pr = ranges::less, class _Pj = identity> requires sortable<_It, _Pr, _Pj> constexpr prev_permutation_result<_It> operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { - _Adl_verify_range(_First, _Last); - auto _UFirst = _Unwrap_iter<_Se>(_STD move(_First)); - auto _ULast = _Get_final_iterator_unwrapped<_It>(_UFirst, _STD move(_Last)); - _Seek_wrapped(_First, _ULast); - const bool _Found = - _Prev_permutation_common(_STD move(_UFirst), _STD move(_ULast), _Pass_fn(_Pred), _Pass_fn(_Proj)); + _STD _Adl_verify_range(_First, _Last); + auto _UFirst = _RANGES _Unwrap_iter<_Se>(_STD move(_First)); + auto _ULast = _RANGES _Get_final_iterator_unwrapped<_It>(_UFirst, _STD move(_Last)); + _STD _Seek_wrapped(_First, _ULast); + const bool _Found = _Prev_permutation_common( + _STD move(_UFirst), _STD move(_ULast), _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); return {_STD move(_First), _Found}; } @@ -10306,9 +10315,10 @@ namespace ranges { requires sortable, _Pr, _Pj> constexpr prev_permutation_result> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { - auto _ULast = _Get_final_iterator_unwrapped(_Range); - const bool _Found = _Prev_permutation_common(_Ubegin(_Range), _ULast, _Pass_fn(_Pred), _Pass_fn(_Proj)); - return {_Rewrap_iterator(_Range, _STD move(_ULast)), _Found}; + auto _ULast = _RANGES _Get_final_iterator_unwrapped(_Range); + const bool _Found = + _Prev_permutation_common(_Ubegin(_Range), _ULast, _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); + return {_RANGES _Rewrap_iterator(_Range, _STD move(_ULast)), _Found}; } private: @@ -10332,12 +10342,12 @@ namespace ranges { } while (!_STD invoke(_Pred, _STD invoke(_Proj, *_Mid), _STD invoke(_Proj, *_Next))); _RANGES iter_swap(_Next, _Mid); - _Reverse_common(_STD move(_Next1), _STD move(_Last)); + _RANGES _Reverse_common(_STD move(_Next1), _STD move(_Last)); return true; } if (_Next == _First) { // pure ascending, flip all - _Reverse_common(_STD move(_First), _STD move(_Last)); + _RANGES _Reverse_common(_STD move(_First), _STD move(_Last)); return false; } } @@ -10351,9 +10361,9 @@ namespace ranges { _EXPORT_STD template _NODISCARD _CONSTEXPR20 _FwdIt is_sorted_until(const _FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find extent of range that is ordered by predicate - _Adl_verify_range(_First, _Last); - auto _UFirst = _Get_unwrapped(_First); - auto _ULast = _Get_unwrapped(_Last); + _STD _Adl_verify_range(_First, _Last); + auto _UFirst = _STD _Get_unwrapped(_First); + auto _ULast = _STD _Get_unwrapped(_Last); if (_UFirst != _ULast) { for (auto _UNext = _UFirst; ++_UNext != _ULast; ++_UFirst) { if (_DEBUG_LT_PRED(_Pred, *_UNext, *_UFirst)) { @@ -10363,17 +10373,17 @@ _NODISCARD _CONSTEXPR20 _FwdIt is_sorted_until(const _FwdIt _First, _FwdIt _Last } } - _Seek_wrapped(_Last, _ULast); + _STD _Seek_wrapped(_Last, _ULast); return _Last; } _EXPORT_STD template _NODISCARD _CONSTEXPR20 bool is_sorted(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // test if range is ordered by predicate - _Adl_verify_range(_First, _Last); - const auto _UFirst = _Get_unwrapped(_First); - const auto _ULast = _Get_unwrapped(_Last); - return _STD is_sorted_until(_UFirst, _ULast, _Pass_fn(_Pred)) == _ULast; + _STD _Adl_verify_range(_First, _Last); + const auto _UFirst = _STD _Get_unwrapped(_First); + const auto _ULast = _STD _Get_unwrapped(_Last); + return _STD is_sorted_until(_UFirst, _ULast, _STD _Pass_fn(_Pred)) == _ULast; } _EXPORT_STD template @@ -10394,7 +10404,7 @@ _NODISCARD _FwdIt is_sorted_until(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pre _EXPORT_STD template = 0> _NODISCARD bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // test if range is ordered by predicate - return _STD is_sorted_until(_STD forward<_ExPo>(_Exec), _First, _Last, _Pass_fn(_Pred)) == _Last; + return _STD is_sorted_until(_STD forward<_ExPo>(_Exec), _First, _Last, _STD _Pass_fn(_Pred)) == _Last; } _EXPORT_STD template = 0> diff --git a/stl/inc/execution b/stl/inc/execution index c40636af786..6daa8a156ad 100644 --- a/stl/inc/execution +++ b/stl/inc/execution @@ -3286,7 +3286,7 @@ struct _Static_partitioned_is_heap_until2 { static void __stdcall _Threadpool_callback( __std_PTP_CALLBACK_INSTANCE, void* const _Context, __std_PTP_WORK) noexcept /* terminates */ { - _Run_available_chunked_work(*static_cast<_Static_partitioned_is_heap_until2*>(_Context)); + _STD _Run_available_chunked_work(*static_cast<_Static_partitioned_is_heap_until2*>(_Context)); } }; @@ -3294,18 +3294,19 @@ _EXPORT_STD template ::_Parallelize) { const size_t _Hw_threads = __std_parallel_algorithms_hw_threads(); if (_Hw_threads > 1) { // parallelize on multiprocessor machines const auto _Count = _ULast - _UFirst; if (_Count >= 3) { // ... with at least 3 elements _TRY_BEGIN - _Static_partitioned_is_heap_until2 _Operation{_UFirst, _ULast, _Hw_threads, _Count, _Pass_fn(_Pred)}; - _Run_chunked_parallel_work(_Hw_threads, _Operation); - _Seek_wrapped(_First, _Operation._Results._Get_result()); + _Static_partitioned_is_heap_until2 _Operation{ + _UFirst, _ULast, _Hw_threads, _Count, _STD _Pass_fn(_Pred)}; + _STD _Run_chunked_parallel_work(_Hw_threads, _Operation); + _STD _Seek_wrapped(_First, _Operation._Results._Get_result()); return _First; _CATCH(const _Parallelism_resources_exhausted&) // fall through to serial case below @@ -3314,7 +3315,7 @@ _NODISCARD _RanIt is_heap_until(_ExPo&&, _RanIt _First, _RanIt _Last, _Pr _Pred) } } - _Seek_wrapped(_First, _STD is_heap_until(_UFirst, _ULast, _Pass_fn(_Pred))); + _STD _Seek_wrapped(_First, _STD is_heap_until(_UFirst, _ULast, _STD _Pass_fn(_Pred))); return _First; } @@ -3765,7 +3766,7 @@ struct _Static_partitioned_set_subtraction { // Get chunk in _Range2 that corresponds to our current chunk from _Range1 auto _Range2_chunk_first = _STD lower_bound(_Range2._First, _Range2._Last, *_Range1_chunk_first, _Pred); auto _Range2_chunk_last = - _STD upper_bound(_Range2_chunk_first, _Range2._Last, *_Prev_iter(_Range1_chunk_last), _Pred); + _STD upper_bound(_Range2_chunk_first, _Range2._Last, *_STD _Prev_iter(_Range1_chunk_last), _Pred); // Publish results to rest of chunks. if (_Chunk_number == 0) { @@ -3816,14 +3817,14 @@ struct _Static_partitioned_set_subtraction { // Place elements from _Range1 in _Dest according to the offsets previously calculated. auto _Chunk_specific_dest = _Dest + static_cast<_Iter_diff_t<_RanIt3>>(_Prev_chunk_sum); - _Place_elements_from_indices( + _STD _Place_elements_from_indices( _Range1_chunk_first, _Chunk_specific_dest, _Index_chunk_first, static_cast(_Num_results)); return _Cancellation_status::_Running; } static void __stdcall _Threadpool_callback( __std_PTP_CALLBACK_INSTANCE, void* const _Context, __std_PTP_WORK) noexcept /* terminates */ { - _Run_available_chunked_work(*static_cast<_Static_partitioned_set_subtraction*>(_Context)); + _STD _Run_available_chunked_work(*static_cast<_Static_partitioned_set_subtraction*>(_Context)); } }; @@ -3877,13 +3878,13 @@ _FwdIt3 set_intersection(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _Firs _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); _REQUIRE_CPP17_MUTABLE_ITERATOR(_FwdIt3); - _Adl_verify_range(_First1, _Last1); - _Adl_verify_range(_First2, _Last2); - auto _UFirst1 = _Get_unwrapped(_First1); - const auto _ULast1 = _Get_unwrapped(_Last1); - auto _UFirst2 = _Get_unwrapped(_First2); - const auto _ULast2 = _Get_unwrapped(_Last2); - auto _UDest = _Get_unwrapped_unverified(_Dest); + _STD _Adl_verify_range(_First1, _Last1); + _STD _Adl_verify_range(_First2, _Last2); + auto _UFirst1 = _STD _Get_unwrapped(_First1); + const auto _ULast1 = _STD _Get_unwrapped(_Last1); + auto _UFirst2 = _STD _Get_unwrapped(_First2); + const auto _ULast2 = _STD _Get_unwrapped(_Last2); + auto _UDest = _STD _Get_unwrapped_unverified(_Dest); using _Diff = _Common_diff_t<_FwdIt1, _FwdIt2, _FwdIt3>; if constexpr (remove_reference_t<_ExPo>::_Parallelize && _Is_ranges_random_iter_v<_FwdIt1> && _Is_ranges_random_iter_v<_FwdIt2> && _Is_cpp17_random_iter_v<_FwdIt3>) { @@ -3895,10 +3896,10 @@ _FwdIt3 set_intersection(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _Firs if (_Count1 >= 2 && _Count2 >= 2) { // ... with each range containing at least 2 elements _TRY_BEGIN _Static_partitioned_set_subtraction _Operation(_Hw_threads, _Count1, _UFirst1, _UFirst2, _ULast2, - _UDest, _Pass_fn(_Pred), _Set_intersection_per_chunk()); - _Run_chunked_parallel_work(_Hw_threads, _Operation); + _UDest, _STD _Pass_fn(_Pred), _Set_intersection_per_chunk()); + _STD _Run_chunked_parallel_work(_Hw_threads, _Operation); _UDest += static_cast<_Iter_diff_t<_FwdIt3>>(_Operation._Lookback.back()._Sum._Ref()); - _Seek_wrapped(_Dest, _UDest); + _STD _Seek_wrapped(_Dest, _UDest); return _Dest; _CATCH(const _Parallelism_resources_exhausted&) // fall through to serial case below @@ -3907,7 +3908,8 @@ _FwdIt3 set_intersection(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _Firs } } - _Seek_wrapped(_Dest, _STD set_intersection(_UFirst1, _ULast1, _UFirst2, _ULast2, _UDest, _Pass_fn(_Pred))); + _STD _Seek_wrapped( + _Dest, _STD set_intersection(_UFirst1, _ULast1, _UFirst2, _ULast2, _UDest, _STD _Pass_fn(_Pred))); return _Dest; } @@ -3967,13 +3969,13 @@ _FwdIt3 set_difference(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2 _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); _REQUIRE_CPP17_MUTABLE_ITERATOR(_FwdIt3); - _Adl_verify_range(_First1, _Last1); - _Adl_verify_range(_First2, _Last2); - auto _UFirst1 = _Get_unwrapped(_First1); - const auto _ULast1 = _Get_unwrapped(_Last1); - auto _UFirst2 = _Get_unwrapped(_First2); - const auto _ULast2 = _Get_unwrapped(_Last2); - auto _UDest = _Get_unwrapped_unverified(_Dest); + _STD _Adl_verify_range(_First1, _Last1); + _STD _Adl_verify_range(_First2, _Last2); + auto _UFirst1 = _STD _Get_unwrapped(_First1); + const auto _ULast1 = _STD _Get_unwrapped(_Last1); + auto _UFirst2 = _STD _Get_unwrapped(_First2); + const auto _ULast2 = _STD _Get_unwrapped(_Last2); + auto _UDest = _STD _Get_unwrapped_unverified(_Dest); using _Diff = _Common_diff_t<_FwdIt1, _FwdIt2, _FwdIt3>; if constexpr (remove_reference_t<_ExPo>::_Parallelize && _Is_ranges_random_iter_v<_FwdIt1> && _Is_ranges_random_iter_v<_FwdIt2> && _Is_cpp17_random_iter_v<_FwdIt3>) { @@ -3984,10 +3986,10 @@ _FwdIt3 set_difference(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2 if (_Count >= 2) { // ... with at least 2 elements in [_First1, _Last1) _TRY_BEGIN _Static_partitioned_set_subtraction _Operation(_Hw_threads, _Count, _UFirst1, _UFirst2, _ULast2, _UDest, - _Pass_fn(_Pred), _Set_difference_per_chunk()); - _Run_chunked_parallel_work(_Hw_threads, _Operation); + _STD _Pass_fn(_Pred), _Set_difference_per_chunk()); + _STD _Run_chunked_parallel_work(_Hw_threads, _Operation); _UDest += static_cast<_Iter_diff_t<_FwdIt3>>(_Operation._Lookback.back()._Sum._Ref()); - _Seek_wrapped(_Dest, _UDest); + _STD _Seek_wrapped(_Dest, _UDest); return _Dest; _CATCH(const _Parallelism_resources_exhausted&) // fall through to serial case below @@ -3996,7 +3998,7 @@ _FwdIt3 set_difference(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2 } } - _Seek_wrapped(_Dest, _STD set_difference(_UFirst1, _ULast1, _UFirst2, _ULast2, _UDest, _Pass_fn(_Pred))); + _STD _Seek_wrapped(_Dest, _STD set_difference(_UFirst1, _ULast1, _UFirst2, _ULast2, _UDest, _STD _Pass_fn(_Pred))); return _Dest; } diff --git a/stl/inc/xmemory b/stl/inc/xmemory index 7d709382ebd..2839843709c 100644 --- a/stl/inc/xmemory +++ b/stl/inc/xmemory @@ -1636,13 +1636,13 @@ struct _NODISCARD _Uninitialized_backout { _Uninitialized_backout& operator=(const _Uninitialized_backout&) = delete; _CONSTEXPR20 ~_Uninitialized_backout() { - _Destroy_range(_First, _Last); + _STD _Destroy_range(_First, _Last); } template _CONSTEXPR20 void _Emplace_back(_Types&&... _Vals) { // construct a new element at *_Last and increment - _Construct_in_place(*_Last, _STD forward<_Types>(_Vals)...); + _STD _Construct_in_place(*_Last, _STD forward<_Types>(_Vals)...); ++_Last; } @@ -1660,7 +1660,7 @@ _CONSTEXPR20 _NoThrowFwdIt _Uninitialized_move_unchecked(_InIt _First, const _In if (!_STD is_constant_evaluated()) #endif // _HAS_CXX20 { - return _Copy_memmove(_First, _Last, _Dest); + return _STD _Copy_memmove(_First, _Last, _Dest); } } _Uninitialized_backout<_NoThrowFwdIt> _Backout{_Dest}; @@ -1746,10 +1746,10 @@ namespace ranges { template in_out_result<_InIt, _OutIt> _Copy_memcpy_common( _InIt _IFirst, _InIt _ILast, _OutIt _OFirst, _OutIt _OLast) noexcept { - const auto _IFirstPtr = _To_address(_IFirst); - const auto _ILastPtr = _To_address(_ILast); - const auto _OFirstPtr = _To_address(_OFirst); - const auto _OLastPtr = _To_address(_OLast); + const auto _IFirstPtr = _STD _To_address(_IFirst); + const auto _ILastPtr = _STD _To_address(_ILast); + const auto _OFirstPtr = _STD _To_address(_OFirst); + const auto _OLastPtr = _STD _To_address(_OLast); const auto _IFirst_ch = const_cast(reinterpret_cast(_IFirstPtr)); const auto _ILast_ch = const_cast(reinterpret_cast(_ILastPtr)); const auto _OFirst_ch = const_cast(reinterpret_cast(_OFirstPtr)); @@ -1783,12 +1783,14 @@ namespace ranges { if constexpr (_Iter_move_cat<_It, _Out>::_Bitcopy_constructible && _Sized_or_unreachable_sentinel_for<_Se, _It> && _Sized_or_unreachable_sentinel_for<_OSe, _Out>) { if constexpr (_Is_sized1 && _Is_sized2) { - return _Copy_memcpy_common(_IFirst, _RANGES next(_IFirst, _STD move(_ILast)), _OFirst, + return _RANGES _Copy_memcpy_common(_IFirst, _RANGES next(_IFirst, _STD move(_ILast)), _OFirst, _RANGES next(_OFirst, _STD move(_OLast))); } else if constexpr (_Is_sized1) { - return _Copy_memcpy_distance(_IFirst, _OFirst, _IFirst, _RANGES next(_IFirst, _STD move(_ILast))); + return _RANGES _Copy_memcpy_distance( + _IFirst, _OFirst, _IFirst, _RANGES next(_IFirst, _STD move(_ILast))); } else if constexpr (_Is_sized2) { - return _Copy_memcpy_distance(_IFirst, _OFirst, _OFirst, _RANGES next(_OFirst, _STD move(_OLast))); + return _RANGES _Copy_memcpy_distance( + _IFirst, _OFirst, _OFirst, _RANGES next(_OFirst, _STD move(_OLast))); } else { _STL_ASSERT(false, "Tried to uninitialized_move two ranges with unreachable sentinels"); } diff --git a/stl/inc/xutility b/stl/inc/xutility index 20cdaefd7e5..b8a1b6995ef 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -6978,22 +6978,22 @@ namespace ranges { _EXPORT_STD template _NODISCARD _CONSTEXPR20 _FwdIt lower_bound(_FwdIt _First, const _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { // find first element not before _Val - _Adl_verify_range(_First, _Last); - auto _UFirst = _Get_unwrapped(_First); - _Iter_diff_t<_FwdIt> _Count = _STD distance(_UFirst, _Get_unwrapped(_Last)); + _STD _Adl_verify_range(_First, _Last); + auto _UFirst = _STD _Get_unwrapped(_First); + _Iter_diff_t<_FwdIt> _Count = _STD distance(_UFirst, _STD _Get_unwrapped(_Last)); while (0 < _Count) { // divide and conquer, find half that contains answer const _Iter_diff_t<_FwdIt> _Count2 = _Count / 2; const auto _UMid = _STD next(_UFirst, _Count2); if (_Pred(*_UMid, _Val)) { // try top half - _UFirst = _Next_iter(_UMid); + _UFirst = _STD _Next_iter(_UMid); _Count -= _Count2 + 1; } else { _Count = _Count2; } } - _Seek_wrapped(_First, _UFirst); + _STD _Seek_wrapped(_First, _UFirst); return _First; } @@ -7006,9 +7006,9 @@ _NODISCARD _CONSTEXPR20 _FwdIt lower_bound(_FwdIt _First, _FwdIt _Last, const _T _EXPORT_STD template _NODISCARD _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { // find first element that _Val is before - _Adl_verify_range(_First, _Last); - auto _UFirst = _Get_unwrapped(_First); - _Iter_diff_t<_FwdIt> _Count = _STD distance(_UFirst, _Get_unwrapped(_Last)); + _STD _Adl_verify_range(_First, _Last); + auto _UFirst = _STD _Get_unwrapped(_First); + _Iter_diff_t<_FwdIt> _Count = _STD distance(_UFirst, _STD _Get_unwrapped(_Last)); while (0 < _Count) { // divide and conquer, find half that contains answer _Iter_diff_t<_FwdIt> _Count2 = _Count / 2; @@ -7016,12 +7016,12 @@ _NODISCARD _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _T if (_Pred(_Val, *_UMid)) { _Count = _Count2; } else { // try top half - _UFirst = _Next_iter(_UMid); + _UFirst = _STD _Next_iter(_UMid); _Count -= _Count2 + 1; } } - _Seek_wrapped(_First, _UFirst); + _STD _Seek_wrapped(_First, _UFirst); return _First; } 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 248f6473289..12a478f4185 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 @@ -263,6 +263,48 @@ void test_algorithms() { // (void) std::shift_right(varr, varr, 0); // requires Cpp17ValueSwappable #endif // _HAS_CXX20 + int iarr3[1]{}; + validator varr3[1]{}; + + (void) std::merge(varr, varr, varr2, varr2, varr3); + (void) std::merge(iarr, iarr, iarr2, iarr2, iarr3, validating_less{}); + + // std::inplace_merge(varr, varr, varr); // requires Cpp17ValueSwappable + std::inplace_merge(iarr, iarr, iarr, validating_less{}); + + (void) std::includes(varr, varr, varr, varr); + (void) std::includes(iarr, iarr, iarr, iarr, validating_less{}); + + (void) std::set_union(varr, varr, varr, varr, varr3); + (void) std::set_union(iarr, iarr, iarr, iarr, iarr3, validating_less{}); + + (void) std::set_intersection(varr, varr, varr, varr, varr3); + (void) std::set_intersection(iarr, iarr, iarr, iarr, iarr3, validating_less{}); + + (void) std::set_difference(varr, varr, varr, varr, varr3); + (void) std::set_difference(iarr, iarr, iarr, iarr, iarr3, validating_less{}); + + (void) std::set_symmetric_difference(varr, varr, varr, varr, varr3); + (void) std::set_symmetric_difference(iarr, iarr, iarr, iarr, iarr3, validating_less{}); + + std::push_heap(varr3, varr3 + 1); // requires Cpp17ValueSwappable + std::push_heap(iarr3, iarr3 + 1, validating_less{}); + + std::pop_heap(varr3, varr3 + 1); // requires Cpp17ValueSwappable + std::pop_heap(iarr3, iarr3 + 1, validating_less{}); + + std::make_heap(varr3, varr3 + 1); // requires Cpp17ValueSwappable + std::make_heap(iarr3, iarr3 + 1, validating_less{}); + + std::sort_heap(varr3, varr3 + 1); // requires Cpp17ValueSwappable + std::sort_heap(iarr3, iarr3 + 1, validating_less{}); + + (void) std::is_heap(varr3, varr3 + 1); + (void) std::is_heap(iarr3, iarr3 + 1, validating_less{}); + + (void) std::is_heap_until(varr3, varr3 + 1); + (void) std::is_heap_until(iarr3, iarr3 + 1, validating_less{}); + (void) std::min(+varr, +varr); (void) std::min(+iarr, +iarr, validating_less{}); (void) std::min({+varr, +varr}); @@ -299,6 +341,12 @@ void test_algorithms() { (void) std::lexicographical_compare_three_way(varr, varr, varr, varr); (void) std::lexicographical_compare_three_way(iarr, iarr, iarr, iarr, validating_compare_three_way{}); #endif // _HAS_CXX20 && defined(__cpp_lib_concepts) + + // (void) std::next_permutation(varr, varr); // requires Cpp17ValueSwappable + (void) std::next_permutation(iarr, iarr, validating_less{}); + + // (void) std::prev_permutation(varr, varr); // requires Cpp17ValueSwappable + (void) std::prev_permutation(iarr, iarr, validating_less{}); } #if _HAS_CXX17 @@ -431,6 +479,36 @@ void test_per_execution_policy() { // (void) std::shift_right(ExecutionPolicy, varr, varr, 0); // requires Cpp17ValueSwappable #endif // _HAS_CXX20 + int iarr3[2]{}; + validator varr3[2]{}; + + (void) std::merge(ExecutionPolicy, varr, varr, varr2, varr2, varr3); + (void) std::merge(ExecutionPolicy, iarr, iarr, iarr2, iarr2, iarr3, validating_less{}); + + // std::inplace_merge(ExecutionPolicy, varr, varr, varr); // requires Cpp17ValueSwappable + std::inplace_merge(ExecutionPolicy, iarr, iarr, iarr, validating_less{}); + + (void) std::includes(ExecutionPolicy, varr, varr, varr, varr); + (void) std::includes(ExecutionPolicy, iarr, iarr, iarr, iarr, validating_less{}); + + (void) std::set_union(ExecutionPolicy, varr, varr, varr, varr, varr3); + (void) std::set_union(ExecutionPolicy, iarr, iarr, iarr, iarr, iarr3, validating_less{}); + + (void) std::set_intersection(ExecutionPolicy, varr, varr, varr, varr, varr3); + (void) std::set_intersection(ExecutionPolicy, iarr, iarr, iarr, iarr, iarr3, validating_less{}); + + (void) std::set_difference(ExecutionPolicy, varr, varr, varr, varr, varr3); + (void) std::set_difference(ExecutionPolicy, iarr, iarr, iarr, iarr, iarr3, validating_less{}); + + (void) std::set_symmetric_difference(ExecutionPolicy, varr, varr, varr, varr, varr3); + (void) std::set_symmetric_difference(ExecutionPolicy, iarr, iarr, iarr, iarr, iarr3, validating_less{}); + + (void) std::is_heap(ExecutionPolicy, varr3, varr3 + 1); + (void) std::is_heap(ExecutionPolicy, iarr3, iarr3 + 1, validating_less{}); + + (void) std::is_heap_until(ExecutionPolicy, varr3, varr3 + 1); + (void) std::is_heap_until(ExecutionPolicy, iarr3, iarr3 + 1, validating_less{}); + (void) std::min_element(ExecutionPolicy, varr, varr + 1); (void) std::min_element(ExecutionPolicy, iarr, iarr + 1, validating_less{}); diff --git a/tests/std/tests/P2538R1_adl_proof_std_projected/test.compile.pass.cpp b/tests/std/tests/P2538R1_adl_proof_std_projected/test.compile.pass.cpp index ccd04fec14e..c9ec1c4ae15 100644 --- a/tests/std/tests/P2538R1_adl_proof_std_projected/test.compile.pass.cpp +++ b/tests/std/tests/P2538R1_adl_proof_std_projected/test.compile.pass.cpp @@ -279,6 +279,74 @@ void test_ranges_algorithms() { (void) unique_copy(iarr, iarr, iarr2, {}, validating_identity{}); (void) unique_copy(iarr, iarr2, {}, validating_identity{}); + int iarr3[2]{}; + validator varr3[2]{}; + + (void) merge(varr, varr, varr2, varr2, varr3); + (void) merge(varr, varr2, varr3); + (void) merge(iarr, iarr, iarr2, iarr2, iarr3, validating_less{}); + (void) merge(iarr, iarr2, iarr3, validating_less{}); + + (void) inplace_merge(varr, varr, varr); + (void) inplace_merge(varr, varr); + (void) inplace_merge(iarr, iarr, iarr, validating_less{}); + (void) inplace_merge(iarr, iarr, {}, validating_identity{}); + + (void) includes(varr, varr, varr, varr); + (void) includes(varr, varr); + (void) includes(iarr, iarr, iarr, iarr, validating_less{}); + (void) includes(iarr, iarr, validating_less{}); + + (void) set_union(varr, varr, varr, varr, varr3); + (void) set_union(varr, varr, varr3); + (void) set_union(iarr, iarr, iarr, iarr, iarr3, validating_less{}); + (void) set_union(iarr, iarr, iarr3, validating_less{}); + + (void) set_intersection(varr, varr, varr, varr, varr3); + (void) set_intersection(varr, varr, varr3); + (void) set_intersection(iarr, iarr, iarr, iarr, iarr3, validating_less{}); + (void) set_intersection(iarr, iarr, iarr3, validating_less{}); + + (void) set_difference(varr, varr, varr, varr, varr3); + (void) set_difference(varr, varr, varr3); + (void) set_difference(iarr, iarr, iarr, iarr, iarr3, validating_less{}); + (void) set_difference(iarr, iarr, iarr3, validating_less{}); + + (void) set_symmetric_difference(varr, varr, varr, varr, varr3); + (void) set_symmetric_difference(varr, varr, varr3); + (void) set_symmetric_difference(iarr, iarr, iarr, iarr, iarr3, validating_less{}); + (void) set_symmetric_difference(iarr, iarr, iarr3, validating_less{}); + + (void) push_heap(varr3, varr3 + 1); + (void) push_heap(varr3); + (void) push_heap(iarr3, iarr3 + 1, validating_less{}); + (void) push_heap(iarr3, {}, validating_identity{}); + + (void) pop_heap(varr3, varr3 + 1); + (void) pop_heap(varr3); + (void) pop_heap(iarr3, iarr3 + 1, validating_less{}); + (void) pop_heap(iarr3, {}, validating_identity{}); + + (void) make_heap(varr3, varr3 + 1); + (void) make_heap(varr3); + (void) make_heap(iarr3, iarr3 + 1, validating_less{}); + (void) make_heap(iarr3, {}, validating_identity{}); + + (void) sort_heap(varr3, varr3 + 1); + (void) sort_heap(varr3); + (void) sort_heap(iarr3, iarr3 + 1, validating_less{}); + (void) sort_heap(iarr3, {}, validating_identity{}); + + (void) is_heap(varr3, varr3 + 1); + (void) is_heap(varr3); + (void) is_heap(iarr3, iarr3 + 1, validating_less{}); + (void) is_heap(iarr3, {}, validating_identity{}); + + (void) is_heap_until(varr3, varr3 + 1); + (void) is_heap_until(varr3); + (void) is_heap_until(iarr3, iarr3 + 1, validating_less{}); + (void) is_heap_until(iarr3, {}, validating_identity{}); + (void) min(+varr, +varr); (void) min({+varr, +varr}); (void) min(varr); @@ -322,6 +390,16 @@ void test_ranges_algorithms() { (void) lexicographical_compare(varr, varr); (void) lexicographical_compare(iarr, iarr, iarr, iarr, validating_less{}); (void) lexicographical_compare(iarr, iarr, validating_less{}); + + (void) next_permutation(varr, varr); + (void) next_permutation(varr); + (void) next_permutation(iarr, iarr, validating_less{}); + (void) next_permutation(iarr, {}, validating_identity{}); + + (void) prev_permutation(varr, varr); + (void) prev_permutation(varr); + (void) prev_permutation(iarr, iarr, validating_less{}); + (void) prev_permutation(iarr, {}, validating_identity{}); } // Separated test for ranges::count and equality From 202e3820d6390505855ce9a58a4bcee4f28feacd Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 30 Jan 2024 12:55:19 -0800 Subject: [PATCH 8/8] llvm-project Mini-Update (#4348) --- llvm-project | 2 +- tests/libcxx/expected_results.txt | 108 +++++++++++++++++++--------- tools/scripts/check_libcxx_paths.py | 40 +++++++++++ 3 files changed, 117 insertions(+), 33 deletions(-) create mode 100644 tools/scripts/check_libcxx_paths.py diff --git a/llvm-project b/llvm-project index 57f42a8765c..2e2b6b53f5f 160000 --- a/llvm-project +++ b/llvm-project @@ -1 +1 @@ -Subproject commit 57f42a8765cd3d878be4fb59ad44c85f8a7ca223 +Subproject commit 2e2b6b53f5f63179b52168ee156df7c76b90bc71 diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index 248dd417440..4b413af66aa 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -22,10 +22,6 @@ std/time/time.syn/formatter.year_month_day_last.pass.cpp:1 FAIL std/time/time.syn/formatter.year_month_weekday.pass.cpp:0 FAIL std/time/time.syn/formatter.year_month_weekday.pass.cpp:1 FAIL -# LLVM-73849: [libc++][test] Streaming out floating-point sys_time and local_time is bogus -std/time/time.clock/time.clock.local/ostream.pass.cpp FAIL -std/time/time.clock/time.clock.system/ostream.pass.cpp FAIL - # LLVM-74221: [libc++][test] nasty_char_traits::move is incompatible with constexpr std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp:2 FAIL std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp:2 FAIL @@ -34,13 +30,8 @@ std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp:2 FAIL std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp FAIL std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move.pass.cpp FAIL -# LLVM-75611: [libc++] views::take behaves incorrectly for iota_view -std/ranges/range.adaptors/range.take/adaptor.pass.cpp FAIL - -# LLVM-78661: [libc++][test] Move format.functions ASCII tests to libcxx/test/libcxx -# These test libc++'s non-standard "ascii" mode. -std/utilities/format/format.functions/ascii.pass.cpp SKIPPED -std/utilities/format/format.functions/escaped_output.ascii.pass.cpp SKIPPED +# LLVM-79783: [libc++][test] array/size_and_alignment.compile.pass.cpp includes non-Standard <__type_traits/datasizeof.h> +std/containers/sequences/array/size_and_alignment.compile.pass.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." @@ -62,8 +53,6 @@ std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp FAIL # The SKIPPED tests contain `XFAIL: msvc`, which is not well understood by the test harness. std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp SKIPPED std/language.support/support.exception/propagation/current_exception.pass.cpp SKIPPED -std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp FAIL -std/language.support/support.exception/propagation/rethrow_exception.pass.cpp FAIL # Testing nonstandard behavior std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp FAIL @@ -171,9 +160,6 @@ std/utilities/memory/specialized.algorithms/uninitialized.fill.n/ranges_uninitia std/utilities/memory/specialized.algorithms/uninitialized.move/ranges_uninitialized_move.pass.cpp FAIL std/utilities/memory/specialized.algorithms/uninitialized.move/ranges_uninitialized_move_n.pass.cpp FAIL -# libc++ doesn't implement LWG-3940 -std/utilities/expected/expected.void/observers/value.pass.cpp FAIL - # If any feature-test macro test is failing, this consolidated test will also fail. std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp FAIL @@ -229,7 +215,28 @@ std/strings/c.strings/cuchar.compile.pass.cpp FAIL std/language.support/support.limits/support.limits.general/cmath.version.compile.pass.cpp FAIL std/language.support/support.limits/support.limits.general/cstdlib.version.compile.pass.cpp FAIL +# P0543R3 Saturation Arithmetic +std/language.support/support.limits/support.limits.general/numeric.version.compile.pass.cpp FAIL +std/numerics/numeric.ops/numeric.ops.sat/add_sat.compile.pass.cpp FAIL +std/numerics/numeric.ops/numeric.ops.sat/add_sat.pass.cpp FAIL +std/numerics/numeric.ops/numeric.ops.sat/div_sat.compile.pass.cpp FAIL +std/numerics/numeric.ops/numeric.ops.sat/div_sat.pass.cpp FAIL +std/numerics/numeric.ops/numeric.ops.sat/mul_sat.compile.pass.cpp FAIL +std/numerics/numeric.ops/numeric.ops.sat/mul_sat.pass.cpp FAIL +std/numerics/numeric.ops/numeric.ops.sat/saturate_cast.compile.pass.cpp FAIL +std/numerics/numeric.ops/numeric.ops.sat/saturate_cast.pass.cpp FAIL +std/numerics/numeric.ops/numeric.ops.sat/sub_sat.compile.pass.cpp FAIL +std/numerics/numeric.ops/numeric.ops.sat/sub_sat.pass.cpp FAIL + # P1759R6 Native Handles And File Streams +std/input.output/file.streams/fstreams/filebuf.members/native_handle.pass.cpp FAIL +std/input.output/file.streams/fstreams/filebuf/types.pass.cpp FAIL +std/input.output/file.streams/fstreams/fstream.members/native_handle.pass.cpp FAIL +std/input.output/file.streams/fstreams/fstream/types.pass.cpp FAIL +std/input.output/file.streams/fstreams/ifstream.members/native_handle.pass.cpp FAIL +std/input.output/file.streams/fstreams/ifstream/types.pass.cpp FAIL +std/input.output/file.streams/fstreams/ofstream.members/native_handle.pass.cpp FAIL +std/input.output/file.streams/fstreams/ofstream/types.pass.cpp FAIL std/language.support/support.limits/support.limits.general/fstream.version.compile.pass.cpp FAIL # P2255R2 "Type Traits To Detect References Binding To Temporaries" @@ -245,6 +252,7 @@ std/containers/sequences/vector.bool/vector.bool.fmt/format.functions.format.pas std/containers/sequences/vector.bool/vector.bool.fmt/format.functions.vformat.pass.cpp FAIL std/containers/sequences/vector.bool/vector.bool.fmt/format.pass.cpp FAIL std/containers/sequences/vector.bool/vector.bool.fmt/parse.pass.cpp FAIL +std/input.output/iostream.format/print.fun/includes.compile.pass.cpp FAIL std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp FAIL std/utilities/format/format.range/format.range.fmtdef/format.pass.cpp FAIL std/utilities/format/format.range/format.range.fmtdef/parse.pass.cpp FAIL @@ -289,6 +297,7 @@ std/language.support/support.limits/support.limits.general/optional.version.comp std/language.support/support.limits/support.limits.general/string_view.version.compile.pass.cpp FAIL # P2447R6 Constructing span From initializer_list +std/containers/views/views.span/span.cons/initializer_list.pass.cpp FAIL std/language.support/support.limits/support.limits.general/span.version.compile.pass.cpp FAIL # P2495R3 Interfacing stringstreams With string_view @@ -302,6 +311,11 @@ std/utilities/charconv/charconv.syn/to_chars_result.operator_bool.pass.cpp FAIL # P2587R3 Redefining to_string To Use to_chars std/language.support/support.limits/support.limits.general/string.version.compile.pass.cpp FAIL +# P2637R3 Member visit +std/utilities/variant/variant.visit.member/robust_against_adl.pass.cpp FAIL +std/utilities/variant/variant.visit.member/visit_return_type.pass.cpp FAIL +std/utilities/variant/variant.visit.member/visit.pass.cpp FAIL + # P2697R1 Interfacing bitset With string_view std/language.support/support.limits/support.limits.general/bitset.version.compile.pass.cpp FAIL std/utilities/template.bitset/bitset.cons/string_view_ctor.pass.cpp FAIL @@ -313,6 +327,9 @@ std/language.support/support.limits/support.limits.general/ratio.version.compile std/language.support/support.limits/support.limits.general/tuple.version.compile.pass.cpp FAIL std/language.support/support.limits/support.limits.general/utility.version.compile.pass.cpp FAIL +# P2821R5 span::at() +std/containers/views/views.span/span.elem/at.pass.cpp FAIL + # P2833R2 Freestanding Library: inout expected span std/language.support/support.limits/support.limits.general/expected.version.compile.pass.cpp FAIL std/language.support/support.limits/support.limits.general/mdspan.version.compile.pass.cpp FAIL @@ -342,6 +359,7 @@ std/depr/depr.c.headers/stdlib_h.pass.cpp FAIL # LWG-2503 "multiline option should be added to syntax_option_type" std/re/re.const/re.matchflag/match_multiline.pass.cpp FAIL +std/re/re.const/re.matchflag/match_not_eol.pass.cpp FAIL # LWG-2532 "Satisfying a promise at thread exit" (Open) # WCFB02 implements the proposed resolution for this issue @@ -412,6 +430,11 @@ std/containers/views/mdspan/mdspan/ctor.dh_integers.pass.cpp:1 FAIL std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp:0 FAIL std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp:1 FAIL +# DevCom-10439137 VSO-1869865: Discarded id-expression causes unnecessary reading +# Also: LLVM-79793 [libc++][test] Fix MSVC warning C4127 in array.cons/initialization.pass.cpp +std/containers/sequences/array/array.cons/initialization.pass.cpp:0 FAIL +std/containers/sequences/array/array.cons/initialization.pass.cpp:1 FAIL + # VSO-1923988: constexpr evaluation performs an assignment with a derived type when it should use a base type std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp:0 FAIL std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp:1 FAIL @@ -532,6 +555,10 @@ std/input.output/string.streams/stringbuf/stringbuf.members/view.pass.cpp FAIL std/input.output/syncstream/syncbuf/syncstream.syncbuf.cons/dtor.pass.cpp FAIL std/input.output/syncstream/syncbuf/syncstream.syncbuf.members/emit.pass.cpp FAIL +# GH-4316: : The width of output is miscalculated when formatting a floating-point number in the locale-specific form +std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.print/locale-specific_form.pass.cpp FAIL +std/utilities/format/format.functions/locale-specific_form.pass.cpp FAIL + # *** VCRUNTIME BUGS *** # DevCom-10373274 VSO-1824997 "vcruntime nothrow array operator new falls back on the wrong function" @@ -631,9 +658,6 @@ std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.c std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp SKIPPED # Not analyzed, likely bogus tests. Various assertions, probably POSIX assumptions. -std/diagnostics/syserr/syserr.compare/eq_error_code_error_code.pass.cpp FAIL -std/diagnostics/syserr/syserr.errcat/syserr.errcat.derived/message.pass.cpp FAIL -std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp FAIL std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_const_char_pointer.pass.cpp FAIL std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_string.pass.cpp FAIL std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code.pass.cpp FAIL @@ -705,9 +729,6 @@ std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get # 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 -# This test assumes that array is not const-default-constructible. -std/concepts/concepts.lang/concept.default.init/default_initializable.compile.pass.cpp FAIL - # contiguous_iterator requires to_address() which calls operator->(), but this bogus test uses an iterator that lacks operator->(). std/iterators/iterator.requirements/iterator.concepts/iterator.concept.random.access/contiguous_iterator.compile.pass.cpp FAIL @@ -966,9 +987,6 @@ std/algorithms/algorithms.results/min_max_result.pass.cpp:1 FAIL # Not analyzed. std/algorithms/robust_against_proxy_iterators_lifetime_bugs.pass.cpp FAIL -# Not analyzed. MSVC doesn't define __SIZE_WIDTH__. Clang does, but this is inspecting sizeof(deque) which is non-portable. -std/containers/sequences/deque/abi.compile.pass.cpp FAIL - # Not analyzed. Possible MSVC constexpr bug. # note: failure was caused by a read of a variable outside its lifetime std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp:0 FAIL @@ -1027,9 +1045,6 @@ std/ranges/range.adaptors/range.lazy.split/range.lazy.split.inner/iter_swap.pass # Not analyzed. Checking whether packaged_task is constructible from an allocator and a packaged_task of a different type. std/thread/futures/futures.task/futures.task.members/ctor2.compile.pass.cpp FAIL -# Not analyzed. MSVC emits truncation warnings, Clang fails a runtime assertion. -std/utilities/format/format.functions/locale-specific_form.pass.cpp FAIL - # Not analyzed. # MSVC warning C4305: 'specialization': truncation from 'const int' to 'bool' # Clang error: non-type template argument evaluates to -1, which cannot be narrowed to type 'bool' [-Wc++11-narrowing] @@ -1331,6 +1346,16 @@ std/input.output/filesystems/fs.op.funcs/fs.op.symlink_status/symlink_status.pas std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp SKIPPED std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp SKIPPED +# Not analyzed. +# MSVC error C2719: '_Fun_': formal parameter with requested alignment of 128 won't be aligned +# Clang error: unknown attribute 'no_unique_address' ignored [-Werror,-Wunknown-attributes] +std/ranges/ranges_robust_against_no_unique_address.pass.cpp FAIL + +# Not analyzed. Runtime assertion, we appear to be ignoring stream width. +std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.print/print.pass.cpp FAIL +std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.print/vprint_nonunicode.pass.cpp FAIL +std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.print/vprint_unicode.pass.cpp FAIL + # *** XFAILs WHICH PASS *** # These tests contain `// XFAIL: msvc` comments, which accurately describe runtime failures for x86 and x64. @@ -1346,6 +1371,8 @@ std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical # 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 +std/time/time.clock/time.clock.system/sys_date.ostream.pass.cpp:2 SKIPPED std/time/time.syn/formatter.day.pass.cpp:0 SKIPPED std/time/time.syn/formatter.day.pass.cpp:2 SKIPPED std/time/time.syn/formatter.month_day.pass.cpp:0 SKIPPED @@ -1367,10 +1394,12 @@ std/algorithms/alg.modifying.operations/alg.replace/ranges.replace.pass.cpp:9 SK std/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp:9 SKIPPED std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp:9 SKIPPED std/algorithms/alg.nonmodifying/alg.find/ranges.find.pass.cpp:9 SKIPPED +std/algorithms/alg.nonmodifying/alg.fold/left_folds.pass.cpp:9 SKIPPED std/depr/depr.c.headers/setjmp_h.compile.pass.cpp:9 SKIPPED std/input.output/file.streams/fstreams/ifstream.members/buffered_reads.pass.cpp:9 SKIPPED std/input.output/file.streams/fstreams/ofstream.members/buffered_writes.pass.cpp:9 SKIPPED std/language.support/support.runtime/csetjmp.pass.cpp:9 SKIPPED +std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.pointer.pass.cpp:9 SKIPPED std/ranges/range.adaptors/range.lazy.split/constraints.compile.pass.cpp:9 SKIPPED std/ranges/range.utility/range.utility.conv/to.pass.cpp:9 SKIPPED std/thread/thread.jthread/assign.move.pass.cpp:9 SKIPPED @@ -1394,8 +1423,23 @@ std/input.output/string.streams/stringstream/stringstream.members/gcount.pass.cp # Similarly, this test is marked as `REQUIRES: 32-bit-pointer`. std/iterators/iterator.container/ssize.LWG3207.compile.pass.cpp:9 SKIPPED -# LLVM-75577 [libc++][test] support.limits.general/.version.compile.pass.cpp is malformed -std/language.support/support.limits/support.limits.general/.version.compile.pass.cpp:9 SKIPPED - -# x86chk ICE not yet reported. Assertion failed: isIndirection() +# VSO-1948221 x86chk ICE with constexpr type_info: Assertion failed: isIndirection() std/language.support/support.rtti/type.info/type_info.equal.pass.cpp:9 SKIPPED + +# These tests are marked as "UNSUPPORTED: !has-unix-headers" with comments saying: +# "`check_assertion.h` requires Unix headers". +std/algorithms/alg.modifying.operations/alg.fill/pstl.exception_handling.pass.cpp:9 SKIPPED +std/algorithms/alg.modifying.operations/alg.move/pstl.exception_handling.pass.cpp:9 SKIPPED +std/algorithms/alg.modifying.operations/alg.replace/pstl.exception_handling.pass.cpp:9 SKIPPED +std/algorithms/alg.modifying.operations/alg.rotate/pstl.exception_handling.pass.cpp:9 SKIPPED +std/algorithms/alg.modifying.operations/alg.transform/pstl.exception_handling.pass.cpp:9 SKIPPED +std/algorithms/alg.nonmodifying/alg.all_of/pstl.exception_handling.pass.cpp:9 SKIPPED +std/algorithms/alg.nonmodifying/alg.any_of/pstl.exception_handling.pass.cpp:9 SKIPPED +std/algorithms/alg.nonmodifying/alg.equal/pstl.exception_handling.pass.cpp:9 SKIPPED +std/algorithms/alg.nonmodifying/alg.find/pstl.exception_handling.pass.cpp:9 SKIPPED +std/algorithms/alg.nonmodifying/alg.foreach/pstl.exception_handling.pass.cpp:9 SKIPPED +std/algorithms/alg.nonmodifying/alg.none_of/pstl.exception_handling.pass.cpp:9 SKIPPED +std/algorithms/alg.sorting/alg.merge/pstl.exception_handling.pass.cpp:9 SKIPPED +std/algorithms/alg.sorting/alg.sort/stable.sort/pstl.exception_handling.pass.cpp:9 SKIPPED +std/algorithms/numeric.ops/reduce/pstl.exception_handling.pass.cpp:9 SKIPPED +std/algorithms/numeric.ops/transform.reduce/pstl.exception_handling.pass.cpp:9 SKIPPED diff --git a/tools/scripts/check_libcxx_paths.py b/tools/scripts/check_libcxx_paths.py new file mode 100644 index 00000000000..93a4f34b351 --- /dev/null +++ b/tools/scripts/check_libcxx_paths.py @@ -0,0 +1,40 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# This script checks tests/libcxx/expected_results.txt for nonexistent test paths. + +from pathlib import Path +import re +import sys + +if __name__ == "__main__": + if len(sys.argv) != 1: + sys.exit(f"Usage: python {sys.argv[0]}") + + # Use the location of this script to find the base of the repo. + absolute_repo_path = Path(sys.argv[0]).absolute().parents[2] + + # Tests can be mentioned multiple times for different configurations. + # Build up a unique set before checking for existence. + unique_tests = set() + + with open(absolute_repo_path / "tests/libcxx/expected_results.txt") as file: + for line in map(lambda x: x.strip(), file): + if line and not line.startswith("#"): # Ignore empty lines and comments. + unique_tests.add(re.sub(r"(:\d+)? (FAIL|SKIPPED)$", "", line)) + + # Build up a list of nonexistent tests so they can be printed in sorted order. + nonexistent_tests = [] + + for str in unique_tests: + if not (absolute_repo_path / "llvm-project/libcxx/test" / str).is_file(): + nonexistent_tests.append(str) + + if nonexistent_tests: + print(f"Failure, found {len(nonexistent_tests)} nonexistent test paths:") + nonexistent_tests.sort() + for str in nonexistent_tests: + print(f"{str}") + sys.exit(1) + + print("Success, all test paths exist.")