diff --git a/stl/inc/bit b/stl/inc/bit index 24830c31f6..430454a863 100644 --- a/stl/inc/bit +++ b/stl/inc/bit @@ -12,6 +12,7 @@ _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 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/functional b/stl/inc/functional index f88728cca7..92390d2684 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 specialization 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 { @@ -301,6 +301,19 @@ _STL_RESTORE_DEPRECATED_WARNING #endif // _HAS_DEPRECATED_NEGATORS #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; +}; + _STL_DISABLE_DEPRECATED_WARNING _EXPORT_STD template class binder1st : public unary_function #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/type_traits b/stl/inc/type_traits index 749ce928c2..c51ef667b2 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,36 @@ _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; + +#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 class reference_wrapper; @@ -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/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 047456fe00..9ed0ea2df9 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -345,6 +345,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 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