From 53715c161529653951ff0ecdb22cc4f568f119e1 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Wed, 5 Apr 2023 01:55:21 +0800 Subject: [PATCH 01/14] `` reduction --- stl/inc/bit | 1 + stl/inc/functional | 25 ++- stl/inc/iosfwd | 2 +- stl/inc/limits | 2 +- stl/inc/optional | 8 +- stl/inc/type_traits | 181 ++++++++++++++++++++ stl/inc/utility | 6 +- stl/inc/variant | 6 +- stl/inc/xlocinfo | 1 - stl/inc/xmemory | 10 ++ stl/inc/xstddef | 400 +------------------------------------------- stl/inc/xutility | 189 +++++++++++++++++++++ 12 files changed, 410 insertions(+), 421 deletions(-) diff --git a/stl/inc/bit b/stl/inc/bit index 24830c31f6..9cdacbb050 100644 --- a/stl/inc/bit +++ b/stl/inc/bit @@ -14,6 +14,7 @@ _EMIT_STL_WARNING(STL4038, "The contents of are available only with C++20 #include #include +#include #include #include _STL_INTRIN_HEADER diff --git a/stl/inc/functional b/stl/inc/functional index f88728cca7..03ee01e6f8 100644 --- a/stl/inc/functional +++ b/stl/inc/functional @@ -12,7 +12,6 @@ #include #include #include -#include #if _HAS_CXX17 #ifdef _LEGACY_CODE_ASSUMES_FUNCTIONAL_INCLUDES_MEMORY #include @@ -31,7 +30,7 @@ _STL_DISABLE_CLANG_WARNINGS #undef new _STD_BEGIN -// plus, minus, and multiplies are defined in +// plus, minus, and multiplies are defined in _EXPORT_STD template struct divides { @@ -65,7 +64,8 @@ struct negate { } }; -// equal_to, not_equal_to, greater, less, greater_equal, and less_equal are defined in +// less is defined in +// equal_to, not_equal_to, greater, greater_equal, and less_equal are defined in _EXPORT_STD template struct logical_and { @@ -142,7 +142,7 @@ struct bit_not { } }; -// void specializations of plus, minus, and multiplies are defined in +// void specializations of plus, minus, and multiplies are defined in template <> struct divides { @@ -175,8 +175,8 @@ struct negate { using is_transparent = int; }; - -// void specializations of equal_to, not_equal_to, greater, less, greater_equal, and less_equal are defined in +// void specializations of less is defined in +// void specializations of equal_to, not_equal_to, greater, greater_equal, and less_equal are defined in template <> struct logical_and { @@ -302,6 +302,19 @@ _STL_RESTORE_DEPRECATED_WARNING #if _HAS_AUTO_PTR_ETC _STL_DISABLE_DEPRECATED_WARNING +_EXPORT_STD template +struct unary_function { // base class for unary functions + using argument_type = _Arg; + using result_type = _Result; +}; + +_EXPORT_STD template +struct binary_function { // base class for binary functions + using first_argument_type = _Arg1; + using second_argument_type = _Arg2; + using result_type = _Result; +}; + _EXPORT_STD template class binder1st : public unary_function { // functor adapter _Func(stored, right) diff --git a/stl/inc/iosfwd b/stl/inc/iosfwd index 05734747e5..e6aa40d5af 100644 --- a/stl/inc/iosfwd +++ b/stl/inc/iosfwd @@ -12,7 +12,7 @@ #include #include #include -#include +#include #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) diff --git a/stl/inc/limits b/stl/inc/limits index 45a3d0e4ab..cd4bbf056f 100644 --- a/stl/inc/limits +++ b/stl/inc/limits @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include _STL_INTRIN_HEADER diff --git a/stl/inc/optional b/stl/inc/optional index a9a4ee0294..839b192d28 100644 --- a/stl/inc/optional +++ b/stl/inc/optional @@ -11,15 +11,9 @@ #if !_HAS_CXX17 _EMIT_STL_WARNING(STL4038, "The contents of are available only with C++17 or later."); #else // ^^^ !_HAS_CXX17 / _HAS_CXX17 vvv -#if _HAS_CXX20 -#include -#endif // _HAS_CXX20 #include -#include -#include -#include -#include #include +#include #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) diff --git a/stl/inc/type_traits b/stl/inc/type_traits index 679c42f7a1..f4df46e650 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -384,6 +384,133 @@ struct is_compound : bool_constant> {}; // determine whet _EXPORT_STD template _INLINE_VAR constexpr bool is_compound_v = !is_fundamental_v<_Ty>; +#define _EMIT_CDECL(FUNC, OPT1, OPT2, OPT3) FUNC(__cdecl, OPT1, OPT2, OPT3) + +#ifdef _M_CEE +#define _EMIT_CLRCALL(FUNC, OPT1, OPT2, OPT3) FUNC(__clrcall, OPT1, OPT2, OPT3) + +#else // _M_CEE +#define _EMIT_CLRCALL(FUNC, OPT1, OPT2, OPT3) +#endif // _M_CEE + +#if defined(_M_IX86) && !defined(_M_CEE) +#define _EMIT_FASTCALL(FUNC, OPT1, OPT2, OPT3) FUNC(__fastcall, OPT1, OPT2, OPT3) + +#else // defined(_M_IX86) && !defined(_M_CEE) +#define _EMIT_FASTCALL(FUNC, OPT1, OPT2, OPT3) +#endif // defined(_M_IX86) && !defined(_M_CEE) + +#ifdef _M_IX86 +#define _EMIT_STDCALL(FUNC, OPT1, OPT2, OPT3) FUNC(__stdcall, OPT1, OPT2, OPT3) +#define _EMIT_THISCALL(FUNC, OPT1, OPT2, OPT3) FUNC(__thiscall, OPT1, OPT2, OPT3) + +#else // _M_IX86 +#define _EMIT_STDCALL(FUNC, OPT1, OPT2, OPT3) +#define _EMIT_THISCALL(FUNC, OPT1, OPT2, OPT3) +#endif // _M_IX86 + +#if ((defined(_M_IX86) && _M_IX86_FP >= 2) || defined(_M_X64)) && !defined(_M_CEE) +#define _EMIT_VECTORCALL(FUNC, OPT1, OPT2, OPT3) FUNC(__vectorcall, OPT1, OPT2, OPT3) + +#else // defined(_M_IX86) && _M_IX86_FP >= 2 etc. +#define _EMIT_VECTORCALL(FUNC, OPT1, OPT2, OPT3) +#endif // defined(_M_IX86) && _M_IX86_FP >= 2 etc. + +#define _NON_MEMBER_CALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ + _EMIT_CDECL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ + _EMIT_CLRCALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ + _EMIT_FASTCALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ + _EMIT_STDCALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ + _EMIT_VECTORCALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) + +#define _NON_MEMBER_CALL_CV(FUNC, REF_OPT, NOEXCEPT_OPT) \ + _NON_MEMBER_CALL(FUNC, , REF_OPT, NOEXCEPT_OPT) \ + _NON_MEMBER_CALL(FUNC, const, REF_OPT, NOEXCEPT_OPT) \ + _NON_MEMBER_CALL(FUNC, volatile, REF_OPT, NOEXCEPT_OPT) \ + _NON_MEMBER_CALL(FUNC, const volatile, REF_OPT, NOEXCEPT_OPT) + +#define _NON_MEMBER_CALL_CV_REF(FUNC, NOEXCEPT_OPT) \ + _NON_MEMBER_CALL_CV(FUNC, , NOEXCEPT_OPT) \ + _NON_MEMBER_CALL_CV(FUNC, &, NOEXCEPT_OPT) \ + _NON_MEMBER_CALL_CV(FUNC, &&, NOEXCEPT_OPT) + +#ifdef __cpp_noexcept_function_type +#define _NON_MEMBER_CALL_CV_REF_NOEXCEPT(FUNC) \ + _NON_MEMBER_CALL_CV_REF(FUNC, ) \ + _NON_MEMBER_CALL_CV_REF(FUNC, noexcept) +#else // __cpp_noexcept_function_type +#define _NON_MEMBER_CALL_CV_REF_NOEXCEPT(FUNC) _NON_MEMBER_CALL_CV_REF(FUNC, ) +#endif // __cpp_noexcept_function_type + +#define _MEMBER_CALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ + _EMIT_CDECL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ + _EMIT_CLRCALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ + _EMIT_FASTCALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ + _EMIT_STDCALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ + _EMIT_THISCALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ + _EMIT_VECTORCALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) + +#define _MEMBER_CALL_CV(FUNC, REF_OPT, NOEXCEPT_OPT) \ + _MEMBER_CALL(FUNC, , REF_OPT, NOEXCEPT_OPT) \ + _MEMBER_CALL(FUNC, const, REF_OPT, NOEXCEPT_OPT) \ + _MEMBER_CALL(FUNC, volatile, REF_OPT, NOEXCEPT_OPT) \ + _MEMBER_CALL(FUNC, const volatile, REF_OPT, NOEXCEPT_OPT) + +#define _MEMBER_CALL_CV_REF(FUNC, NOEXCEPT_OPT) \ + _MEMBER_CALL_CV(FUNC, , NOEXCEPT_OPT) \ + _MEMBER_CALL_CV(FUNC, &, NOEXCEPT_OPT) \ + _MEMBER_CALL_CV(FUNC, &&, NOEXCEPT_OPT) + +#ifdef __cpp_noexcept_function_type +#define _MEMBER_CALL_CV_REF_NOEXCEPT(FUNC) \ + _MEMBER_CALL_CV_REF(FUNC, ) \ + _MEMBER_CALL_CV_REF(FUNC, noexcept) +#else // __cpp_noexcept_function_type +#define _MEMBER_CALL_CV_REF_NOEXCEPT(FUNC) _MEMBER_CALL_CV_REF(FUNC, ) +#endif // __cpp_noexcept_function_type + +#ifdef __cpp_noexcept_function_type +#define _CLASS_DEFINE_CV_REF_NOEXCEPT(CLASS) \ + CLASS(_EMPTY_ARGUMENT) \ + CLASS(const) \ + CLASS(volatile) \ + CLASS(const volatile) \ + CLASS(&) \ + CLASS(const&) \ + CLASS(volatile&) \ + CLASS(const volatile&) \ + CLASS(&&) \ + CLASS(const&&) \ + CLASS(volatile&&) \ + CLASS(const volatile&&) \ + CLASS(noexcept) \ + CLASS(const noexcept) \ + CLASS(volatile noexcept) \ + CLASS(const volatile noexcept) \ + CLASS(&noexcept) \ + CLASS(const& noexcept) \ + CLASS(volatile& noexcept) \ + CLASS(const volatile& noexcept) \ + CLASS(&&noexcept) \ + CLASS(const&& noexcept) \ + CLASS(volatile&& noexcept) \ + CLASS(const volatile&& noexcept) +#else // __cpp_noexcept_function_type +#define _CLASS_DEFINE_CV_REF_NOEXCEPT(CLASS) \ + CLASS(_EMPTY_ARGUMENT) \ + CLASS(const) \ + CLASS(volatile) \ + CLASS(const volatile) \ + CLASS(&) \ + CLASS(const&) \ + CLASS(volatile&) \ + CLASS(const volatile&) \ + CLASS(&&) \ + CLASS(const&&) \ + CLASS(volatile&&) \ + CLASS(const volatile&&) +#endif // __cpp_noexcept_function_type + template struct _Arg_types {}; // provide argument_type, etc. when sizeof...(_Types) is 1 or 2 @@ -1471,6 +1598,14 @@ _NODISCARD _MSVC_INTRINSIC constexpr // return _STD move(_Arg); } +_EXPORT_STD template +_NODISCARD constexpr _Ty* addressof(_Ty& _Val) noexcept { + return __builtin_addressof(_Val); +} + +_EXPORT_STD template +const _Ty* addressof(const _Ty&&) = delete; + _EXPORT_STD template class reference_wrapper; @@ -1644,6 +1779,28 @@ _EXPORT_STD template using is_nothrow_convertible = _Is_nothrow_convertible<_From, _To>; #endif // _HAS_CXX20 +#pragma warning(push) +#pragma warning(disable : 5215) // '%s' a function parameter with a volatile qualified type is deprecated in C++20 +#pragma warning(disable : 5216) // '%s' a volatile qualified return type is deprecated in C++20 + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-volatile" +#endif // __clang__ + +template +_NODISCARD _Ty _Fake_copy_init(_Ty) noexcept; +// _Fake_copy_init(E): +// (1) has type T [decay_t if T is deduced], +// (2) is well-formed if and only if E is implicitly convertible to T and T is destructible, and +// (3) is non-throwing if and only if both conversion from decltype((E)) to T and destruction of T are non-throwing. + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif // __clang__ + +#pragma warning(pop) + template struct _Invoke_convertible : false_type {}; @@ -2294,6 +2451,30 @@ template struct _Is_nothrow_hashable<_Kty, void_t{}(_STD declval()))>> : bool_constant{}(_STD declval()))> {}; +_EXPORT_STD template +struct less { + using _FIRST_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + using _SECOND_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + using _RESULT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = bool; + + _NODISCARD constexpr bool operator()(const _Ty& _Left, const _Ty& _Right) const + noexcept(noexcept(_Fake_copy_init(_Left < _Right))) /* strengthened */ { + return _Left < _Right; + } +}; + +template <> +struct less { + template + _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const + noexcept(noexcept(static_cast<_Ty1&&>(_Left) < static_cast<_Ty2&&>(_Right))) // strengthened + -> decltype(static_cast<_Ty1&&>(_Left) < static_cast<_Ty2&&>(_Right)) { + return static_cast<_Ty1&&>(_Left) < static_cast<_Ty2&&>(_Right); + } + + using is_transparent = int; +}; + // vvvvvvvvvv DERIVED FROM corecrt_internal_fltintrn.h vvvvvvvvvv template diff --git a/stl/inc/utility b/stl/inc/utility index 7bd0866585..d16740f2c7 100644 --- a/stl/inc/utility +++ b/stl/inc/utility @@ -8,8 +8,8 @@ #define _UTILITY_ #include #if _STL_COMPILER_PREPROCESSOR +#include #include -#include #ifdef __cpp_lib_concepts #include @@ -19,6 +19,10 @@ #include #endif // _HAS_CXX20 +#if _HAS_CXX23 +#include +#endif // _HAS_CXX23 + #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) #pragma warning(disable : _STL_DISABLED_WARNINGS) diff --git a/stl/inc/variant b/stl/inc/variant index 670c5b4af3..fe9fdf12f3 100644 --- a/stl/inc/variant +++ b/stl/inc/variant @@ -13,12 +13,8 @@ _EMIT_STL_WARNING(STL4038, "The contents of are available only with C++17 or later."); #else // ^^^ !_HAS_CXX17 / _HAS_CXX17 vvv #include -#include -#include -#include -#include #include -#include +#include #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) diff --git a/stl/inc/xlocinfo b/stl/inc/xlocinfo index 8396fe52b5..746407ce2a 100644 --- a/stl/inc/xlocinfo +++ b/stl/inc/xlocinfo @@ -14,7 +14,6 @@ #include // TRANSITION, VSO-661721 #include #include -#include #include #pragma pack(push, _CRT_PACKING) diff --git a/stl/inc/xmemory b/stl/inc/xmemory index 6f2a28fb78..5739937806 100644 --- a/stl/inc/xmemory +++ b/stl/inc/xmemory @@ -27,6 +27,16 @@ _STL_DISABLE_CLANG_WARNINGS #undef new _STD_BEGIN +template +_NODISCARD constexpr auto _Unfancy(_Ptrty _Ptr) noexcept { // converts from a fancy pointer to a plain pointer + return _STD addressof(*_Ptr); +} + +template +_NODISCARD constexpr _Ty* _Unfancy(_Ty* _Ptr) noexcept { // do nothing for plain pointers + return _Ptr; +} + template struct _NODISCARD _Tidy_guard { // class with destructor that calls _Tidy _Ty* _Target; diff --git a/stl/inc/xstddef b/stl/inc/xstddef index 12ef3fb712..ffa37dfcc0 100644 --- a/stl/inc/xstddef +++ b/stl/inc/xstddef @@ -9,8 +9,6 @@ #include #if _STL_COMPILER_PREPROCESSOR #include -#include -#include #include #pragma pack(push, _CRT_PACKING) @@ -22,406 +20,10 @@ _STL_DISABLE_CLANG_WARNINGS _STD_BEGIN template -// false value attached to a dependent name (for static_assert) +// TRANSITION, CWG-2518: false value attached to a dependent name (for static_assert) _INLINE_VAR constexpr bool _Always_false = false; - -// stuff from -#if _HAS_AUTO_PTR_ETC -_EXPORT_STD template -struct unary_function { // base class for unary functions - using argument_type = _Arg; - using result_type = _Result; -}; - -_EXPORT_STD template -struct binary_function { // base class for binary functions - using first_argument_type = _Arg1; - using second_argument_type = _Arg2; - using result_type = _Result; -}; -#endif // _HAS_AUTO_PTR_ETC - -#pragma warning(push) -#pragma warning(disable : 5215) // '%s' a function parameter with a volatile qualified type is deprecated in C++20 -#pragma warning(disable : 5216) // '%s' a volatile qualified return type is deprecated in C++20 - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-volatile" -#endif // __clang__ - -template -_NODISCARD _Ty _Fake_copy_init(_Ty) noexcept; -// _Fake_copy_init(E): -// (1) has type T [decay_t if T is deduced], -// (2) is well-formed if and only if E is implicitly convertible to T and T is destructible, and -// (3) is non-throwing if and only if both conversion from decltype((E)) to T and destruction of T are non-throwing. - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif // __clang__ - -#pragma warning(pop) - -_EXPORT_STD template -struct plus { - using _FIRST_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - using _SECOND_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - using _RESULT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - - _NODISCARD constexpr _Ty operator()(const _Ty& _Left, const _Ty& _Right) const { - return _Left + _Right; - } -}; - -_EXPORT_STD template -struct minus { - using _FIRST_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - using _SECOND_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - using _RESULT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - - _NODISCARD constexpr _Ty operator()(const _Ty& _Left, const _Ty& _Right) const { - return _Left - _Right; - } -}; - -_EXPORT_STD template -struct multiplies { - using _FIRST_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - using _SECOND_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - using _RESULT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - - _NODISCARD constexpr _Ty operator()(const _Ty& _Left, const _Ty& _Right) const { - return _Left * _Right; - } -}; - -_EXPORT_STD template -struct equal_to { - using _FIRST_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - using _SECOND_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - using _RESULT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = bool; - - _NODISCARD constexpr bool operator()(const _Ty& _Left, const _Ty& _Right) const - noexcept(noexcept(_Fake_copy_init(_Left == _Right))) /* strengthened */ { - return _Left == _Right; - } -}; - -_EXPORT_STD template -struct not_equal_to { - using _FIRST_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - using _SECOND_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - using _RESULT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = bool; - - _NODISCARD constexpr bool operator()(const _Ty& _Left, const _Ty& _Right) const - noexcept(noexcept(_Fake_copy_init(_Left != _Right))) /* strengthened */ { - return _Left != _Right; - } -}; - -_EXPORT_STD template -struct greater { - using _FIRST_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - using _SECOND_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - using _RESULT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = bool; - - _NODISCARD constexpr bool operator()(const _Ty& _Left, const _Ty& _Right) const - noexcept(noexcept(_Fake_copy_init(_Left > _Right))) /* strengthened */ { - return _Left > _Right; - } -}; - -_EXPORT_STD template -struct less { - using _FIRST_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - using _SECOND_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - using _RESULT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = bool; - - _NODISCARD constexpr bool operator()(const _Ty& _Left, const _Ty& _Right) const - noexcept(noexcept(_Fake_copy_init(_Left < _Right))) /* strengthened */ { - return _Left < _Right; - } -}; - -_EXPORT_STD template -struct greater_equal { - using _FIRST_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - using _SECOND_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - using _RESULT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = bool; - - _NODISCARD constexpr bool operator()(const _Ty& _Left, const _Ty& _Right) const - noexcept(noexcept(_Fake_copy_init(_Left >= _Right))) /* strengthened */ { - return _Left >= _Right; - } -}; - -_EXPORT_STD template -struct less_equal { - using _FIRST_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - using _SECOND_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; - using _RESULT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = bool; - - _NODISCARD constexpr bool operator()(const _Ty& _Left, const _Ty& _Right) const - noexcept(noexcept(_Fake_copy_init(_Left <= _Right))) /* strengthened */ { - return _Left <= _Right; - } -}; - -template <> -struct plus { - template - _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const - noexcept(noexcept(static_cast<_Ty1&&>(_Left) + static_cast<_Ty2&&>(_Right))) // strengthened - -> decltype(static_cast<_Ty1&&>(_Left) + static_cast<_Ty2&&>(_Right)) { - return static_cast<_Ty1&&>(_Left) + static_cast<_Ty2&&>(_Right); - } - - using is_transparent = int; -}; - -template <> -struct minus { - template - _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const - noexcept(noexcept(static_cast<_Ty1&&>(_Left) - static_cast<_Ty2&&>(_Right))) // strengthened - -> decltype(static_cast<_Ty1&&>(_Left) - static_cast<_Ty2&&>(_Right)) { - return static_cast<_Ty1&&>(_Left) - static_cast<_Ty2&&>(_Right); - } - - using is_transparent = int; -}; - -template <> -struct multiplies { - template - _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const - noexcept(noexcept(static_cast<_Ty1&&>(_Left) * static_cast<_Ty2&&>(_Right))) // strengthened - -> decltype(static_cast<_Ty1&&>(_Left) * static_cast<_Ty2&&>(_Right)) { - return static_cast<_Ty1&&>(_Left) * static_cast<_Ty2&&>(_Right); - } - - using is_transparent = int; -}; - -template <> -struct equal_to { - template - _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const - noexcept(noexcept(static_cast<_Ty1&&>(_Left) == static_cast<_Ty2&&>(_Right))) // strengthened - -> decltype(static_cast<_Ty1&&>(_Left) == static_cast<_Ty2&&>(_Right)) { - return static_cast<_Ty1&&>(_Left) == static_cast<_Ty2&&>(_Right); - } - - using is_transparent = int; -}; - -template <> -struct not_equal_to { - template - _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const - noexcept(noexcept(static_cast<_Ty1&&>(_Left) != static_cast<_Ty2&&>(_Right))) // strengthened - -> decltype(static_cast<_Ty1&&>(_Left) != static_cast<_Ty2&&>(_Right)) { - return static_cast<_Ty1&&>(_Left) != static_cast<_Ty2&&>(_Right); - } - - using is_transparent = int; -}; - -template <> -struct greater { - template - _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const - noexcept(noexcept(static_cast<_Ty1&&>(_Left) > static_cast<_Ty2&&>(_Right))) // strengthened - -> decltype(static_cast<_Ty1&&>(_Left) > static_cast<_Ty2&&>(_Right)) { - return static_cast<_Ty1&&>(_Left) > static_cast<_Ty2&&>(_Right); - } - - using is_transparent = int; -}; - -template <> -struct less { - template - _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const - noexcept(noexcept(static_cast<_Ty1&&>(_Left) < static_cast<_Ty2&&>(_Right))) // strengthened - -> decltype(static_cast<_Ty1&&>(_Left) < static_cast<_Ty2&&>(_Right)) { - return static_cast<_Ty1&&>(_Left) < static_cast<_Ty2&&>(_Right); - } - - using is_transparent = int; -}; - -template <> -struct greater_equal { - template - _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const - noexcept(noexcept(static_cast<_Ty1&&>(_Left) >= static_cast<_Ty2&&>(_Right))) // strengthened - -> decltype(static_cast<_Ty1&&>(_Left) >= static_cast<_Ty2&&>(_Right)) { - return static_cast<_Ty1&&>(_Left) >= static_cast<_Ty2&&>(_Right); - } - - using is_transparent = int; -}; - -template <> -struct less_equal { - template - _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const - noexcept(noexcept(static_cast<_Ty1&&>(_Left) <= static_cast<_Ty2&&>(_Right))) // strengthened - -> decltype(static_cast<_Ty1&&>(_Left) <= static_cast<_Ty2&&>(_Right)) { - return static_cast<_Ty1&&>(_Left) <= static_cast<_Ty2&&>(_Right); - } - - using is_transparent = int; -}; - -_EXPORT_STD template -_NODISCARD constexpr _Ty* addressof(_Ty& _Val) noexcept { - return __builtin_addressof(_Val); -} - -_EXPORT_STD template -const _Ty* addressof(const _Ty&&) = delete; - -template -_NODISCARD constexpr auto _Unfancy(_Ptrty _Ptr) noexcept { // converts from a fancy pointer to a plain pointer - return _STD addressof(*_Ptr); -} - -template -_NODISCARD constexpr _Ty* _Unfancy(_Ty* _Ptr) noexcept { // do nothing for plain pointers - return _Ptr; -} _STD_END -#define _EMIT_CDECL(FUNC, OPT1, OPT2, OPT3) FUNC(__cdecl, OPT1, OPT2, OPT3) - -#ifdef _M_CEE -#define _EMIT_CLRCALL(FUNC, OPT1, OPT2, OPT3) FUNC(__clrcall, OPT1, OPT2, OPT3) - -#else // _M_CEE -#define _EMIT_CLRCALL(FUNC, OPT1, OPT2, OPT3) -#endif // _M_CEE - -#if defined(_M_IX86) && !defined(_M_CEE) -#define _EMIT_FASTCALL(FUNC, OPT1, OPT2, OPT3) FUNC(__fastcall, OPT1, OPT2, OPT3) - -#else // defined(_M_IX86) && !defined(_M_CEE) -#define _EMIT_FASTCALL(FUNC, OPT1, OPT2, OPT3) -#endif // defined(_M_IX86) && !defined(_M_CEE) - -#ifdef _M_IX86 -#define _EMIT_STDCALL(FUNC, OPT1, OPT2, OPT3) FUNC(__stdcall, OPT1, OPT2, OPT3) -#define _EMIT_THISCALL(FUNC, OPT1, OPT2, OPT3) FUNC(__thiscall, OPT1, OPT2, OPT3) - -#else // _M_IX86 -#define _EMIT_STDCALL(FUNC, OPT1, OPT2, OPT3) -#define _EMIT_THISCALL(FUNC, OPT1, OPT2, OPT3) -#endif // _M_IX86 - -#if ((defined(_M_IX86) && _M_IX86_FP >= 2) || defined(_M_X64)) && !defined(_M_CEE) -#define _EMIT_VECTORCALL(FUNC, OPT1, OPT2, OPT3) FUNC(__vectorcall, OPT1, OPT2, OPT3) - -#else // defined(_M_IX86) && _M_IX86_FP >= 2 etc. -#define _EMIT_VECTORCALL(FUNC, OPT1, OPT2, OPT3) -#endif // defined(_M_IX86) && _M_IX86_FP >= 2 etc. - -#define _NON_MEMBER_CALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ - _EMIT_CDECL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ - _EMIT_CLRCALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ - _EMIT_FASTCALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ - _EMIT_STDCALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ - _EMIT_VECTORCALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) - -#define _NON_MEMBER_CALL_CV(FUNC, REF_OPT, NOEXCEPT_OPT) \ - _NON_MEMBER_CALL(FUNC, , REF_OPT, NOEXCEPT_OPT) \ - _NON_MEMBER_CALL(FUNC, const, REF_OPT, NOEXCEPT_OPT) \ - _NON_MEMBER_CALL(FUNC, volatile, REF_OPT, NOEXCEPT_OPT) \ - _NON_MEMBER_CALL(FUNC, const volatile, REF_OPT, NOEXCEPT_OPT) - -#define _NON_MEMBER_CALL_CV_REF(FUNC, NOEXCEPT_OPT) \ - _NON_MEMBER_CALL_CV(FUNC, , NOEXCEPT_OPT) \ - _NON_MEMBER_CALL_CV(FUNC, &, NOEXCEPT_OPT) \ - _NON_MEMBER_CALL_CV(FUNC, &&, NOEXCEPT_OPT) - -#ifdef __cpp_noexcept_function_type -#define _NON_MEMBER_CALL_CV_REF_NOEXCEPT(FUNC) \ - _NON_MEMBER_CALL_CV_REF(FUNC, ) \ - _NON_MEMBER_CALL_CV_REF(FUNC, noexcept) -#else // __cpp_noexcept_function_type -#define _NON_MEMBER_CALL_CV_REF_NOEXCEPT(FUNC) _NON_MEMBER_CALL_CV_REF(FUNC, ) -#endif // __cpp_noexcept_function_type - -#define _MEMBER_CALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ - _EMIT_CDECL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ - _EMIT_CLRCALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ - _EMIT_FASTCALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ - _EMIT_STDCALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ - _EMIT_THISCALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ - _EMIT_VECTORCALL(FUNC, CV_OPT, REF_OPT, NOEXCEPT_OPT) - -#define _MEMBER_CALL_CV(FUNC, REF_OPT, NOEXCEPT_OPT) \ - _MEMBER_CALL(FUNC, , REF_OPT, NOEXCEPT_OPT) \ - _MEMBER_CALL(FUNC, const, REF_OPT, NOEXCEPT_OPT) \ - _MEMBER_CALL(FUNC, volatile, REF_OPT, NOEXCEPT_OPT) \ - _MEMBER_CALL(FUNC, const volatile, REF_OPT, NOEXCEPT_OPT) - -#define _MEMBER_CALL_CV_REF(FUNC, NOEXCEPT_OPT) \ - _MEMBER_CALL_CV(FUNC, , NOEXCEPT_OPT) \ - _MEMBER_CALL_CV(FUNC, &, NOEXCEPT_OPT) \ - _MEMBER_CALL_CV(FUNC, &&, NOEXCEPT_OPT) - -#ifdef __cpp_noexcept_function_type -#define _MEMBER_CALL_CV_REF_NOEXCEPT(FUNC) \ - _MEMBER_CALL_CV_REF(FUNC, ) \ - _MEMBER_CALL_CV_REF(FUNC, noexcept) -#else // __cpp_noexcept_function_type -#define _MEMBER_CALL_CV_REF_NOEXCEPT(FUNC) _MEMBER_CALL_CV_REF(FUNC, ) -#endif // __cpp_noexcept_function_type - -#ifdef __cpp_noexcept_function_type -#define _CLASS_DEFINE_CV_REF_NOEXCEPT(CLASS) \ - CLASS(_EMPTY_ARGUMENT) \ - CLASS(const) \ - CLASS(volatile) \ - CLASS(const volatile) \ - CLASS(&) \ - CLASS(const&) \ - CLASS(volatile&) \ - CLASS(const volatile&) \ - CLASS(&&) \ - CLASS(const&&) \ - CLASS(volatile&&) \ - CLASS(const volatile&&) \ - CLASS(noexcept) \ - CLASS(const noexcept) \ - CLASS(volatile noexcept) \ - CLASS(const volatile noexcept) \ - CLASS(&noexcept) \ - CLASS(const& noexcept) \ - CLASS(volatile& noexcept) \ - CLASS(const volatile& noexcept) \ - CLASS(&&noexcept) \ - CLASS(const&& noexcept) \ - CLASS(volatile&& noexcept) \ - CLASS(const volatile&& noexcept) -#else // __cpp_noexcept_function_type -#define _CLASS_DEFINE_CV_REF_NOEXCEPT(CLASS) \ - CLASS(_EMPTY_ARGUMENT) \ - CLASS(const) \ - CLASS(volatile) \ - CLASS(const volatile) \ - CLASS(&) \ - CLASS(const&) \ - CLASS(volatile&) \ - CLASS(const volatile&) \ - CLASS(&&) \ - CLASS(const&&) \ - CLASS(volatile&&) \ - CLASS(const volatile&&) -#endif // __cpp_noexcept_function_type - #pragma pop_macro("new") _STL_RESTORE_CLANG_WARNINGS #pragma warning(pop) diff --git a/stl/inc/xutility b/stl/inc/xutility index 398013dc7e..40e39a09a6 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -353,6 +353,195 @@ _EXPORT_STD struct identity { }; #endif // _HAS_CXX20 +_EXPORT_STD template +struct plus { + using _FIRST_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + using _SECOND_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + using _RESULT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + + _NODISCARD constexpr _Ty operator()(const _Ty& _Left, const _Ty& _Right) const { + return _Left + _Right; + } +}; + +_EXPORT_STD template +struct minus { + using _FIRST_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + using _SECOND_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + using _RESULT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + + _NODISCARD constexpr _Ty operator()(const _Ty& _Left, const _Ty& _Right) const { + return _Left - _Right; + } +}; + +_EXPORT_STD template +struct multiplies { + using _FIRST_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + using _SECOND_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + using _RESULT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + + _NODISCARD constexpr _Ty operator()(const _Ty& _Left, const _Ty& _Right) const { + return _Left * _Right; + } +}; + +_EXPORT_STD template +struct equal_to { + using _FIRST_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + using _SECOND_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + using _RESULT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = bool; + + _NODISCARD constexpr bool operator()(const _Ty& _Left, const _Ty& _Right) const + noexcept(noexcept(_Fake_copy_init(_Left == _Right))) /* strengthened */ { + return _Left == _Right; + } +}; + +_EXPORT_STD template +struct not_equal_to { + using _FIRST_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + using _SECOND_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + using _RESULT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = bool; + + _NODISCARD constexpr bool operator()(const _Ty& _Left, const _Ty& _Right) const + noexcept(noexcept(_Fake_copy_init(_Left != _Right))) /* strengthened */ { + return _Left != _Right; + } +}; + +_EXPORT_STD template +struct greater { + using _FIRST_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + using _SECOND_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + using _RESULT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = bool; + + _NODISCARD constexpr bool operator()(const _Ty& _Left, const _Ty& _Right) const + noexcept(noexcept(_Fake_copy_init(_Left > _Right))) /* strengthened */ { + return _Left > _Right; + } +}; + +_EXPORT_STD template +struct greater_equal { + using _FIRST_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + using _SECOND_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + using _RESULT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = bool; + + _NODISCARD constexpr bool operator()(const _Ty& _Left, const _Ty& _Right) const + noexcept(noexcept(_Fake_copy_init(_Left >= _Right))) /* strengthened */ { + return _Left >= _Right; + } +}; + +_EXPORT_STD template +struct less_equal { + using _FIRST_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + using _SECOND_ARGUMENT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = _Ty; + using _RESULT_TYPE_NAME _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS = bool; + + _NODISCARD constexpr bool operator()(const _Ty& _Left, const _Ty& _Right) const + noexcept(noexcept(_Fake_copy_init(_Left <= _Right))) /* strengthened */ { + return _Left <= _Right; + } +}; + +template <> +struct plus { + template + _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const + noexcept(noexcept(static_cast<_Ty1&&>(_Left) + static_cast<_Ty2&&>(_Right))) // strengthened + -> decltype(static_cast<_Ty1&&>(_Left) + static_cast<_Ty2&&>(_Right)) { + return static_cast<_Ty1&&>(_Left) + static_cast<_Ty2&&>(_Right); + } + + using is_transparent = int; +}; + +template <> +struct minus { + template + _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const + noexcept(noexcept(static_cast<_Ty1&&>(_Left) - static_cast<_Ty2&&>(_Right))) // strengthened + -> decltype(static_cast<_Ty1&&>(_Left) - static_cast<_Ty2&&>(_Right)) { + return static_cast<_Ty1&&>(_Left) - static_cast<_Ty2&&>(_Right); + } + + using is_transparent = int; +}; + +template <> +struct multiplies { + template + _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const + noexcept(noexcept(static_cast<_Ty1&&>(_Left) * static_cast<_Ty2&&>(_Right))) // strengthened + -> decltype(static_cast<_Ty1&&>(_Left) * static_cast<_Ty2&&>(_Right)) { + return static_cast<_Ty1&&>(_Left) * static_cast<_Ty2&&>(_Right); + } + + using is_transparent = int; +}; + +template <> +struct equal_to { + template + _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const + noexcept(noexcept(static_cast<_Ty1&&>(_Left) == static_cast<_Ty2&&>(_Right))) // strengthened + -> decltype(static_cast<_Ty1&&>(_Left) == static_cast<_Ty2&&>(_Right)) { + return static_cast<_Ty1&&>(_Left) == static_cast<_Ty2&&>(_Right); + } + + using is_transparent = int; +}; + +template <> +struct not_equal_to { + template + _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const + noexcept(noexcept(static_cast<_Ty1&&>(_Left) != static_cast<_Ty2&&>(_Right))) // strengthened + -> decltype(static_cast<_Ty1&&>(_Left) != static_cast<_Ty2&&>(_Right)) { + return static_cast<_Ty1&&>(_Left) != static_cast<_Ty2&&>(_Right); + } + + using is_transparent = int; +}; + +template <> +struct greater { + template + _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const + noexcept(noexcept(static_cast<_Ty1&&>(_Left) > static_cast<_Ty2&&>(_Right))) // strengthened + -> decltype(static_cast<_Ty1&&>(_Left) > static_cast<_Ty2&&>(_Right)) { + return static_cast<_Ty1&&>(_Left) > static_cast<_Ty2&&>(_Right); + } + + using is_transparent = int; +}; + +template <> +struct greater_equal { + template + _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const + noexcept(noexcept(static_cast<_Ty1&&>(_Left) >= static_cast<_Ty2&&>(_Right))) // strengthened + -> decltype(static_cast<_Ty1&&>(_Left) >= static_cast<_Ty2&&>(_Right)) { + return static_cast<_Ty1&&>(_Left) >= static_cast<_Ty2&&>(_Right); + } + + using is_transparent = int; +}; + +template <> +struct less_equal { + template + _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const + noexcept(noexcept(static_cast<_Ty1&&>(_Left) <= static_cast<_Ty2&&>(_Right))) // strengthened + -> decltype(static_cast<_Ty1&&>(_Left) <= static_cast<_Ty2&&>(_Right)) { + return static_cast<_Ty1&&>(_Left) <= static_cast<_Ty2&&>(_Right); + } + + using is_transparent = int; +}; + template struct _Ref_fn { // pass function object by value as a reference template From a90cab91f03dbbc3132b1eb60800a17916730510 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Wed, 5 Apr 2023 01:56:53 +0800 Subject: [PATCH 02/14] Reduce `` dependency for `` --- stl/inc/limits | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/stl/inc/limits b/stl/inc/limits index cd4bbf056f..c81b427ba0 100644 --- a/stl/inc/limits +++ b/stl/inc/limits @@ -10,7 +10,6 @@ #if _STL_COMPILER_PREPROCESSOR #include #include -#include #include #include @@ -459,11 +458,11 @@ template <> class numeric_limits : public _Num_int_base { public: _NODISCARD static constexpr wchar_t(min)() noexcept { - return WCHAR_MIN; + return 0; } _NODISCARD static constexpr wchar_t(max)() noexcept { - return WCHAR_MAX; + return 0xffff; } _NODISCARD static constexpr wchar_t lowest() noexcept { From 89f275137aece7054c64fa6765c6445c7a64f547 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Sun, 2 Apr 2023 13:50:00 +0800 Subject: [PATCH 03/14] Move `_Char_traits_eq` & `_Char_traits_lt` to `` --- stl/inc/regex | 34 ++++++++++++++++++- stl/inc/xstring | 32 ----------------- .../test.compile.pass.cpp | 1 + .../test.compile.pass.cpp | 1 + 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/stl/inc/regex b/stl/inc/regex index 05cb7465d3..3c7aedf1c1 100644 --- a/stl/inc/regex +++ b/stl/inc/regex @@ -16,12 +16,12 @@ #include #include #include -#include #include #include #include #include #include +#include #if _HAS_CXX17 #include @@ -178,6 +178,38 @@ struct _Cl_names { // structure to associate class name with mask value } }; +template +struct _Char_traits_eq { + using _Elem = typename _Traits::char_type; + + bool operator()(_Elem _Left, _Elem _Right) const noexcept { + return _Traits::eq(_Left, _Right); + } +}; + +template +struct _Char_traits_lt { + using _Elem = typename _Traits::char_type; + + bool operator()(_Elem _Left, _Elem _Right) const noexcept { + return _Traits::lt(_Left, _Right); + } +}; + +// library-provided char_traits::eq behaves like equal_to<_Elem> +// TRANSITION: This should not be activated for user-defined specializations of char_traits +template +_INLINE_VAR constexpr bool _Can_memcmp_elements_with_pred<_Elem, _Elem, _Char_traits_eq>> = + _Can_memcmp_elements<_Elem, _Elem>; + +// library-provided char_traits::lt behaves like less> +// TRANSITION: This should not be activated for user-defined specializations of char_traits +template +struct _Lex_compare_memcmp_classify_pred<_Elem, _Elem, _Char_traits_lt>> { + using _UElem = make_unsigned_t<_Elem>; + using _Pred = conditional_t<_Lex_compare_memcmp_classify_elements<_UElem, _UElem>, less, void>; +}; + template struct _Cmp_cs { // functor to compare two character values for equality using _Elem = typename _RxTraits::char_type; diff --git a/stl/inc/xstring b/stl/inc/xstring index 80453b0d41..aacda3476e 100644 --- a/stl/inc/xstring +++ b/stl/inc/xstring @@ -535,38 +535,6 @@ basic_ostream<_Elem, _Traits>& _Insert_string( return _Ostr; } -template -struct _Char_traits_eq { - using _Elem = typename _Traits::char_type; - - bool operator()(_Elem _Left, _Elem _Right) const noexcept { - return _Traits::eq(_Left, _Right); - } -}; - -template -struct _Char_traits_lt { - using _Elem = typename _Traits::char_type; - - bool operator()(_Elem _Left, _Elem _Right) const noexcept { - return _Traits::lt(_Left, _Right); - } -}; - -// library-provided char_traits::eq behaves like equal_to<_Elem> -// TRANSITION: This should not be activated for user-defined specializations of char_traits -template -_INLINE_VAR constexpr bool _Can_memcmp_elements_with_pred<_Elem, _Elem, _Char_traits_eq>> = - _Can_memcmp_elements<_Elem, _Elem>; - -// library-provided char_traits::lt behaves like less> -// TRANSITION: This should not be activated for user-defined specializations of char_traits -template -struct _Lex_compare_memcmp_classify_pred<_Elem, _Elem, _Char_traits_lt>> { - using _UElem = make_unsigned_t<_Elem>; - using _Pred = conditional_t<_Lex_compare_memcmp_classify_elements<_UElem, _UElem>, less, void>; -}; - template using _Traits_ch_t = typename _Traits::char_type; diff --git a/tests/std/tests/GH_000431_equal_memcmp_is_safe/test.compile.pass.cpp b/tests/std/tests/GH_000431_equal_memcmp_is_safe/test.compile.pass.cpp index 7d1a69b6dd..5159486e50 100644 --- a/tests/std/tests/GH_000431_equal_memcmp_is_safe/test.compile.pass.cpp +++ b/tests/std/tests/GH_000431_equal_memcmp_is_safe/test.compile.pass.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/std/tests/GH_000431_lex_compare_memcmp_classify/test.compile.pass.cpp b/tests/std/tests/GH_000431_lex_compare_memcmp_classify/test.compile.pass.cpp index 84aabcc341..2d0e1b7717 100644 --- a/tests/std/tests/GH_000431_lex_compare_memcmp_classify/test.compile.pass.cpp +++ b/tests/std/tests/GH_000431_lex_compare_memcmp_classify/test.compile.pass.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include From 38d9e7d5ed44c835801a358181fd93397cd7149a Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Sun, 2 Apr 2023 13:50:27 +0800 Subject: [PATCH 04/14] Reduce `` dependency in `` --- stl/inc/chrono | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/stl/inc/chrono b/stl/inc/chrono index ce864da018..202b9aa847 100644 --- a/stl/inc/chrono +++ b/stl/inc/chrono @@ -18,7 +18,6 @@ #if _HAS_CXX20 #include <__msvc_tzdb.hpp> -#include #include #include #include @@ -2250,14 +2249,19 @@ namespace chrono { auto [_Leap_sec, _All_ls_positive] = _Tzdb_generate_leap_seconds(_Tzdb_list.front().leap_seconds.size()); if (!_Leap_sec.empty()) { const auto& _Tzdb = _Tzdb_list.front(); + vector _Zones; - _STD transform(_Tzdb.zones.begin(), _Tzdb.zones.end(), _STD back_inserter(_Zones), - [](const auto& _Tz) { return time_zone{_Tz.name()}; }); + _Zones.reserve(_Tzdb.zones.size()); + for (const auto& _Tz : _Tzdb.zones) { + _Zones.emplace_back(_Tz.name()); + } + vector _Links; - _STD transform( - _Tzdb.links.begin(), _Tzdb.links.end(), _STD back_inserter(_Links), [](const auto& _Link) { - return time_zone_link{_Link.name(), _Link.target()}; - }); + _Links.reserve(_Tzdb.links.size()); + for (const auto& _Link : _Tzdb.links) { + _Links.emplace_back(_Link.name(), _Link.target()); + } + auto _Version = _Tzdb_update_version(_Tzdb.version, _Leap_sec.size()); _Tzdb_list.emplace_front(tzdb{ _STD move(_Version), _STD move(_Zones), _STD move(_Links), _STD move(_Leap_sec), _All_ls_positive}); From d20d56e4e62278322c9ca388d322e15cf9dc9aff Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Sun, 2 Apr 2023 13:51:28 +0800 Subject: [PATCH 05/14] Reduce ``/`` dependency in `` --- stl/inc/compare | 9 ++++----- stl/inc/format | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/stl/inc/compare b/stl/inc/compare index b556d80516..c71fad3b01 100644 --- a/stl/inc/compare +++ b/stl/inc/compare @@ -13,7 +13,6 @@ _EMIT_STL_WARNING(STL4038, "The contents of are available only with C++20 or later."); #else // ^^^ !_HAS_CXX20 / _HAS_CXX20 vvv #ifdef __cpp_lib_concepts -#include #include #else // ^^^ __cpp_lib_concepts / !__cpp_lib_concepts vvv #include @@ -427,8 +426,8 @@ namespace _Strong_order { using _Uint_type = typename _Traits::_Uint_type; using _Sint_type = make_signed_t<_Uint_type>; - const auto _Left_uint = _STD bit_cast<_Uint_type>(_Left); - const auto _Right_uint = _STD bit_cast<_Uint_type>(_Right); + const auto _Left_uint = __builtin_bit_cast(_Uint_type, _Left); + const auto _Right_uint = __builtin_bit_cast(_Uint_type, _Right); // 1. Ultra-fast path: equal representations are equal. if (_Left_uint == _Right_uint) { @@ -534,8 +533,8 @@ namespace _Weak_order { using _Uint_type = typename _Traits::_Uint_type; using _Sint_type = make_signed_t<_Uint_type>; - auto _Left_uint = _STD bit_cast<_Uint_type>(_Left); - auto _Right_uint = _STD bit_cast<_Uint_type>(_Right); + auto _Left_uint = __builtin_bit_cast(_Uint_type, _Left); + auto _Right_uint = __builtin_bit_cast(_Uint_type, _Right); // 1. Ultra-fast path: equal representations are equivalent. if (_Left_uint == _Right_uint) { diff --git a/stl/inc/format b/stl/inc/format index 9c0121b7fe..ead13721b1 100644 --- a/stl/inc/format +++ b/stl/inc/format @@ -1982,7 +1982,7 @@ private: template _NODISCARD static auto _Get_value_from_memory(const unsigned char* const _Val) noexcept { auto& _Temp = *reinterpret_cast(_Val); - return _Bit_cast<_Ty>(_Temp); + return _STD bit_cast<_Ty>(_Temp); } size_t _Num_args = 0; From f01cc035171c56f6d2f3998aea10beb2c43242e4 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Wed, 5 Apr 2023 02:00:47 +0800 Subject: [PATCH 06/14] Fix inclusion order for `` --- stl/inc/bit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/bit b/stl/inc/bit index 9cdacbb050..430454a863 100644 --- a/stl/inc/bit +++ b/stl/inc/bit @@ -12,9 +12,9 @@ _EMIT_STL_WARNING(STL4038, "The contents of are available only with C++20 or later."); #else // ^^^ !_HAS_CXX20 / _HAS_CXX20 vvv +#include #include #include -#include #include #include _STL_INTRIN_HEADER From a0374b2280f04cf0e0b620cbf1cd8866e1cb9483 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Wed, 5 Apr 2023 02:22:13 +0800 Subject: [PATCH 07/14] Restore accidentally dropped inclusion --- stl/inc/exception | 1 + stl/inc/format | 1 + 2 files changed, 2 insertions(+) diff --git a/stl/inc/exception b/stl/inc/exception index a635cdee18..4d3e300521 100644 --- a/stl/inc/exception +++ b/stl/inc/exception @@ -9,6 +9,7 @@ #include #if _STL_COMPILER_PREPROCESSOR +#include #include #pragma pack(push, _CRT_PACKING) diff --git a/stl/inc/format b/stl/inc/format index ead13721b1..8787d5857a 100644 --- a/stl/inc/format +++ b/stl/inc/format @@ -44,6 +44,7 @@ _EMIT_STL_WARNING(STL4038, "The contents of are available only with C++ #else // ^^^ !defined(__cpp_lib_concepts) / defined(__cpp_lib_concepts) vvv #include <__msvc_format_ucd_tables.hpp> +#include #include #include #include From 6b21cee9e0062af0e18be867d8fe3809b2bf79ad Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Wed, 5 Apr 2023 02:38:34 +0800 Subject: [PATCH 08/14] Revert mis-reduction for `` --- stl/inc/regex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/regex b/stl/inc/regex index 3c7aedf1c1..7053b6173f 100644 --- a/stl/inc/regex +++ b/stl/inc/regex @@ -16,12 +16,12 @@ #include #include #include +#include #include #include #include #include #include -#include #if _HAS_CXX17 #include From 2a05ea442dee8c4ec3460c6a67d3d287ec7420ac Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Wed, 5 Apr 2023 03:02:00 +0800 Subject: [PATCH 09/14] Fix misplaced `_Fake_copy_init` --- stl/inc/type_traits | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/stl/inc/type_traits b/stl/inc/type_traits index f4df46e650..02e72e2b16 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -1606,6 +1606,26 @@ _NODISCARD constexpr _Ty* addressof(_Ty& _Val) noexcept { _EXPORT_STD template const _Ty* addressof(const _Ty&&) = delete; +#pragma warning(push) +#pragma warning(disable : 5215) // '%s' a function parameter with a volatile qualified type is deprecated in C++20 +#pragma warning(disable : 5216) // '%s' a volatile qualified return type is deprecated in C++20 + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-volatile" +#endif // __clang__ + +template +_NODISCARD _Ty _Fake_copy_init(_Ty) noexcept; +// _Fake_copy_init(E): +// (1) has type T [decay_t if T is deduced], +// (2) is well-formed if and only if E is implicitly convertible to T and T is destructible, and +// (3) is non-throwing if and only if both conversion from decltype((E)) to T and destruction of T are non-throwing. + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif // __clang__ + _EXPORT_STD template class reference_wrapper; @@ -1779,26 +1799,6 @@ _EXPORT_STD template using is_nothrow_convertible = _Is_nothrow_convertible<_From, _To>; #endif // _HAS_CXX20 -#pragma warning(push) -#pragma warning(disable : 5215) // '%s' a function parameter with a volatile qualified type is deprecated in C++20 -#pragma warning(disable : 5216) // '%s' a volatile qualified return type is deprecated in C++20 - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-volatile" -#endif // __clang__ - -template -_NODISCARD _Ty _Fake_copy_init(_Ty) noexcept; -// _Fake_copy_init(E): -// (1) has type T [decay_t if T is deduced], -// (2) is well-formed if and only if E is implicitly convertible to T and T is destructible, and -// (3) is non-throwing if and only if both conversion from decltype((E)) to T and destruction of T are non-throwing. - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif // __clang__ - #pragma warning(pop) template From 9f64d2f9c9b79f3a6633abf8941ae79906533a8c Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Wed, 5 Apr 2023 16:32:32 +0800 Subject: [PATCH 10/14] Separate changes into other PRs --- stl/inc/chrono | 18 ++++------- stl/inc/compare | 9 +++--- stl/inc/format | 3 +- stl/inc/limits | 5 +-- stl/inc/optional | 8 ++++- stl/inc/regex | 32 ------------------- stl/inc/variant | 6 +++- stl/inc/xstring | 32 +++++++++++++++++++ .../test.compile.pass.cpp | 1 - .../test.compile.pass.cpp | 1 - 10 files changed, 60 insertions(+), 55 deletions(-) diff --git a/stl/inc/chrono b/stl/inc/chrono index 202b9aa847..ce864da018 100644 --- a/stl/inc/chrono +++ b/stl/inc/chrono @@ -18,6 +18,7 @@ #if _HAS_CXX20 #include <__msvc_tzdb.hpp> +#include #include #include #include @@ -2249,19 +2250,14 @@ namespace chrono { auto [_Leap_sec, _All_ls_positive] = _Tzdb_generate_leap_seconds(_Tzdb_list.front().leap_seconds.size()); if (!_Leap_sec.empty()) { const auto& _Tzdb = _Tzdb_list.front(); - vector _Zones; - _Zones.reserve(_Tzdb.zones.size()); - for (const auto& _Tz : _Tzdb.zones) { - _Zones.emplace_back(_Tz.name()); - } - + _STD transform(_Tzdb.zones.begin(), _Tzdb.zones.end(), _STD back_inserter(_Zones), + [](const auto& _Tz) { return time_zone{_Tz.name()}; }); vector _Links; - _Links.reserve(_Tzdb.links.size()); - for (const auto& _Link : _Tzdb.links) { - _Links.emplace_back(_Link.name(), _Link.target()); - } - + _STD transform( + _Tzdb.links.begin(), _Tzdb.links.end(), _STD back_inserter(_Links), [](const auto& _Link) { + return time_zone_link{_Link.name(), _Link.target()}; + }); auto _Version = _Tzdb_update_version(_Tzdb.version, _Leap_sec.size()); _Tzdb_list.emplace_front(tzdb{ _STD move(_Version), _STD move(_Zones), _STD move(_Links), _STD move(_Leap_sec), _All_ls_positive}); diff --git a/stl/inc/compare b/stl/inc/compare index c71fad3b01..b556d80516 100644 --- a/stl/inc/compare +++ b/stl/inc/compare @@ -13,6 +13,7 @@ _EMIT_STL_WARNING(STL4038, "The contents of are available only with C++20 or later."); #else // ^^^ !_HAS_CXX20 / _HAS_CXX20 vvv #ifdef __cpp_lib_concepts +#include #include #else // ^^^ __cpp_lib_concepts / !__cpp_lib_concepts vvv #include @@ -426,8 +427,8 @@ namespace _Strong_order { using _Uint_type = typename _Traits::_Uint_type; using _Sint_type = make_signed_t<_Uint_type>; - const auto _Left_uint = __builtin_bit_cast(_Uint_type, _Left); - const auto _Right_uint = __builtin_bit_cast(_Uint_type, _Right); + const auto _Left_uint = _STD bit_cast<_Uint_type>(_Left); + const auto _Right_uint = _STD bit_cast<_Uint_type>(_Right); // 1. Ultra-fast path: equal representations are equal. if (_Left_uint == _Right_uint) { @@ -533,8 +534,8 @@ namespace _Weak_order { using _Uint_type = typename _Traits::_Uint_type; using _Sint_type = make_signed_t<_Uint_type>; - auto _Left_uint = __builtin_bit_cast(_Uint_type, _Left); - auto _Right_uint = __builtin_bit_cast(_Uint_type, _Right); + auto _Left_uint = _STD bit_cast<_Uint_type>(_Left); + auto _Right_uint = _STD bit_cast<_Uint_type>(_Right); // 1. Ultra-fast path: equal representations are equivalent. if (_Left_uint == _Right_uint) { diff --git a/stl/inc/format b/stl/inc/format index 8787d5857a..9c0121b7fe 100644 --- a/stl/inc/format +++ b/stl/inc/format @@ -44,7 +44,6 @@ _EMIT_STL_WARNING(STL4038, "The contents of are available only with C++ #else // ^^^ !defined(__cpp_lib_concepts) / defined(__cpp_lib_concepts) vvv #include <__msvc_format_ucd_tables.hpp> -#include #include #include #include @@ -1983,7 +1982,7 @@ private: template _NODISCARD static auto _Get_value_from_memory(const unsigned char* const _Val) noexcept { auto& _Temp = *reinterpret_cast(_Val); - return _STD bit_cast<_Ty>(_Temp); + return _Bit_cast<_Ty>(_Temp); } size_t _Num_args = 0; diff --git a/stl/inc/limits b/stl/inc/limits index c81b427ba0..cd4bbf056f 100644 --- a/stl/inc/limits +++ b/stl/inc/limits @@ -10,6 +10,7 @@ #if _STL_COMPILER_PREPROCESSOR #include #include +#include #include #include @@ -458,11 +459,11 @@ template <> class numeric_limits : public _Num_int_base { public: _NODISCARD static constexpr wchar_t(min)() noexcept { - return 0; + return WCHAR_MIN; } _NODISCARD static constexpr wchar_t(max)() noexcept { - return 0xffff; + return WCHAR_MAX; } _NODISCARD static constexpr wchar_t lowest() noexcept { diff --git a/stl/inc/optional b/stl/inc/optional index 839b192d28..a9a4ee0294 100644 --- a/stl/inc/optional +++ b/stl/inc/optional @@ -11,9 +11,15 @@ #if !_HAS_CXX17 _EMIT_STL_WARNING(STL4038, "The contents of are available only with C++17 or later."); #else // ^^^ !_HAS_CXX17 / _HAS_CXX17 vvv +#if _HAS_CXX20 +#include +#endif // _HAS_CXX20 #include +#include +#include +#include +#include #include -#include #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) diff --git a/stl/inc/regex b/stl/inc/regex index 7053b6173f..05cb7465d3 100644 --- a/stl/inc/regex +++ b/stl/inc/regex @@ -178,38 +178,6 @@ struct _Cl_names { // structure to associate class name with mask value } }; -template -struct _Char_traits_eq { - using _Elem = typename _Traits::char_type; - - bool operator()(_Elem _Left, _Elem _Right) const noexcept { - return _Traits::eq(_Left, _Right); - } -}; - -template -struct _Char_traits_lt { - using _Elem = typename _Traits::char_type; - - bool operator()(_Elem _Left, _Elem _Right) const noexcept { - return _Traits::lt(_Left, _Right); - } -}; - -// library-provided char_traits::eq behaves like equal_to<_Elem> -// TRANSITION: This should not be activated for user-defined specializations of char_traits -template -_INLINE_VAR constexpr bool _Can_memcmp_elements_with_pred<_Elem, _Elem, _Char_traits_eq>> = - _Can_memcmp_elements<_Elem, _Elem>; - -// library-provided char_traits::lt behaves like less> -// TRANSITION: This should not be activated for user-defined specializations of char_traits -template -struct _Lex_compare_memcmp_classify_pred<_Elem, _Elem, _Char_traits_lt>> { - using _UElem = make_unsigned_t<_Elem>; - using _Pred = conditional_t<_Lex_compare_memcmp_classify_elements<_UElem, _UElem>, less, void>; -}; - template struct _Cmp_cs { // functor to compare two character values for equality using _Elem = typename _RxTraits::char_type; diff --git a/stl/inc/variant b/stl/inc/variant index fe9fdf12f3..670c5b4af3 100644 --- a/stl/inc/variant +++ b/stl/inc/variant @@ -13,8 +13,12 @@ _EMIT_STL_WARNING(STL4038, "The contents of are available only with C++17 or later."); #else // ^^^ !_HAS_CXX17 / _HAS_CXX17 vvv #include +#include +#include +#include +#include #include -#include +#include #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) diff --git a/stl/inc/xstring b/stl/inc/xstring index aacda3476e..80453b0d41 100644 --- a/stl/inc/xstring +++ b/stl/inc/xstring @@ -535,6 +535,38 @@ basic_ostream<_Elem, _Traits>& _Insert_string( return _Ostr; } +template +struct _Char_traits_eq { + using _Elem = typename _Traits::char_type; + + bool operator()(_Elem _Left, _Elem _Right) const noexcept { + return _Traits::eq(_Left, _Right); + } +}; + +template +struct _Char_traits_lt { + using _Elem = typename _Traits::char_type; + + bool operator()(_Elem _Left, _Elem _Right) const noexcept { + return _Traits::lt(_Left, _Right); + } +}; + +// library-provided char_traits::eq behaves like equal_to<_Elem> +// TRANSITION: This should not be activated for user-defined specializations of char_traits +template +_INLINE_VAR constexpr bool _Can_memcmp_elements_with_pred<_Elem, _Elem, _Char_traits_eq>> = + _Can_memcmp_elements<_Elem, _Elem>; + +// library-provided char_traits::lt behaves like less> +// TRANSITION: This should not be activated for user-defined specializations of char_traits +template +struct _Lex_compare_memcmp_classify_pred<_Elem, _Elem, _Char_traits_lt>> { + using _UElem = make_unsigned_t<_Elem>; + using _Pred = conditional_t<_Lex_compare_memcmp_classify_elements<_UElem, _UElem>, less, void>; +}; + template using _Traits_ch_t = typename _Traits::char_type; diff --git a/tests/std/tests/GH_000431_equal_memcmp_is_safe/test.compile.pass.cpp b/tests/std/tests/GH_000431_equal_memcmp_is_safe/test.compile.pass.cpp index 5159486e50..7d1a69b6dd 100644 --- a/tests/std/tests/GH_000431_equal_memcmp_is_safe/test.compile.pass.cpp +++ b/tests/std/tests/GH_000431_equal_memcmp_is_safe/test.compile.pass.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/tests/std/tests/GH_000431_lex_compare_memcmp_classify/test.compile.pass.cpp b/tests/std/tests/GH_000431_lex_compare_memcmp_classify/test.compile.pass.cpp index 2d0e1b7717..84aabcc341 100644 --- a/tests/std/tests/GH_000431_lex_compare_memcmp_classify/test.compile.pass.cpp +++ b/tests/std/tests/GH_000431_lex_compare_memcmp_classify/test.compile.pass.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include From fea5cb2811b9b319dd25f776cc86451be77d5b9c Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Wed, 5 Apr 2023 17:08:11 +0800 Subject: [PATCH 11/14] Skip one libc++ test And reorder the skipping for LWG-3865 --- tests/libcxx/expected_results.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index a1fe83c556..5066b3be08 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -132,6 +132,9 @@ std/strings/string.view/string.view.cons/from_range.pass.cpp FAIL std/strings/string.view/string.view.cons/from_string1.compile.fail.cpp FAIL std/strings/string.view/string.view.cons/from_string2.compile.fail.cpp FAIL +# libc++ doesn't implement LWG-3865 Sorting a range of pairs +std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp FAIL + # libc++ doesn't implement LWG-3870 std/utilities/memory/specialized.algorithms/specialized.construct/ranges_construct_at.pass.cpp FAIL std/utilities/memory/specialized.algorithms/uninitialized.construct.default/ranges_uninitialized_default_construct.pass.cpp FAIL @@ -173,9 +176,6 @@ std/ranges/range.adaptors/range.join.view/sentinel/eq.pass.cpp FAIL std/re/re.iter/re.regiter/iterator_concept_conformance.compile.pass.cpp FAIL std/re/re.iter/re.tokiter/iterator_concept_conformance.compile.pass.cpp FAIL -# libc++ doesn't implement LWG-3865 Sorting a range of pairs -std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp FAIL - # *** INTERACTIONS WITH CONTEST / C1XX THAT UPSTREAM LIKELY WON'T FIX *** # Tracked by VSO-593630 " Enable libcxx filesystem tests" @@ -338,6 +338,9 @@ std/algorithms/algorithms.results/no_unique_address.compile.pass.cpp SKIPPED # *** MISSING LWG ISSUE RESOLUTIONS *** +# LWG-2192 "Validity and return type of std::abs(0u) is unclear" (resolution is missing in UCRT, DevCom-10331466) +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 From 008f4df46b754cadec234c7ef5cde7d8d960bf6b Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 7 Apr 2023 09:17:56 +0800 Subject: [PATCH 12/14] Fix misplaced `#pragma warning(pop)` --- stl/inc/type_traits | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/type_traits b/stl/inc/type_traits index 02e72e2b16..2d8396cf45 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -1626,6 +1626,8 @@ _NODISCARD _Ty _Fake_copy_init(_Ty) noexcept; #pragma clang diagnostic pop #endif // __clang__ +#pragma warning(pop) + _EXPORT_STD template class reference_wrapper; @@ -1799,8 +1801,6 @@ _EXPORT_STD template using is_nothrow_convertible = _Is_nothrow_convertible<_From, _To>; #endif // _HAS_CXX20 -#pragma warning(pop) - template struct _Invoke_convertible : false_type {}; From e419d11866ee9e6bdd7983227e98a5f59b6856aa Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sun, 9 Apr 2023 15:29:22 -0700 Subject: [PATCH 13/14] "void specialization of less", singular. --- stl/inc/functional | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/functional b/stl/inc/functional index 03ee01e6f8..192837072f 100644 --- a/stl/inc/functional +++ b/stl/inc/functional @@ -175,7 +175,7 @@ struct negate { using is_transparent = int; }; -// void specializations of less is defined in +// void specialization of less is defined in // void specializations of equal_to, not_equal_to, greater, greater_equal, and less_equal are defined in template <> From 3272b81a5d7fbc92cbdbfca3e3778ce91bb96ab9 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sun, 9 Apr 2023 15:29:47 -0700 Subject: [PATCH 14/14] Keep `_STL_DISABLE_DEPRECATED_WARNING` immediately before `binder1st`. --- stl/inc/functional | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/functional b/stl/inc/functional index 192837072f..92390d2684 100644 --- a/stl/inc/functional +++ b/stl/inc/functional @@ -301,7 +301,6 @@ _STL_RESTORE_DEPRECATED_WARNING #endif // _HAS_DEPRECATED_NEGATORS #if _HAS_AUTO_PTR_ETC -_STL_DISABLE_DEPRECATED_WARNING _EXPORT_STD template struct unary_function { // base class for unary functions using argument_type = _Arg; @@ -315,6 +314,7 @@ struct binary_function { // base class for binary functions using result_type = _Result; }; +_STL_DISABLE_DEPRECATED_WARNING _EXPORT_STD template class binder1st : public unary_function { // functor adapter _Func(stored, right)