From af61334f2a5f9c0486210420e84110df0ed4faa7 Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Sat, 9 Apr 2022 13:26:42 +0200 Subject: [PATCH] Add some transition comments and paper number --- stl/inc/expected | 41 ++++++++----------- stl/inc/yvals_core.h | 1 + .../test.compile.pass.cpp | 2 +- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/stl/inc/expected b/stl/inc/expected index a4faadf49d..37f462a18e 100644 --- a/stl/inc/expected +++ b/stl/inc/expected @@ -29,13 +29,13 @@ _STD_BEGIN // [expected.un.object] // clang-format off -template +template // TRANSITION, LWG-3688 requires (is_object_v<_Err> && !is_array_v<_Err> && !is_volatile_v<_Err> && !is_const_v<_Err>) class unexpected { // clang-format on static_assert(!_Is_specialization_v<_Err, unexpected>, "E must not be a specialization of unexpected"); - template + template // TRANSITION, LWG-3688 friend class expected; public: @@ -61,8 +61,7 @@ public: // clang-format on // [expected.un.observe] - // TRANSITION, P2549 -#ifdef __cpp_explicit_this_parameter +#ifdef __cpp_explicit_this_parameter // TRANSITION, P2549 _NODISCARD constexpr decltype(auto) error(this unexpected&& _Self) noexcept { return _STD forward(_Self)._Unexpected; } @@ -126,8 +125,7 @@ public: __CLR_OR_THIS_CALL explicit bad_expected_access(_Err _Unex) noexcept(is_nothrow_move_constructible_v<_Err>) : _Unexpected(_STD move(_Unex)) {} -// TRANSITION, P2549 -#ifdef __cpp_explicit_this_parameter +#ifdef __cpp_explicit_this_parameter // TRANSITION, P2549 _NODISCARD constexpr decltype(auto) error(this unexpected&& _Self) noexcept { return _STD forward(_Self)._Unexpected; } @@ -156,9 +154,9 @@ struct unexpect_t { inline constexpr unexpect_t unexpect{}; -template +template // TRANSITION, LWG-3688 class expected { - template + template // TRANSITION, LWG-3688 friend class expected; public: @@ -525,7 +523,7 @@ public: return _STD addressof(_Value); } -#ifdef __cpp_explicit_this_parameter +#ifdef __cpp_explicit_this_parameter // TRANSITION, P2549 _NODISCARD constexpr decltype(auto) operator*(this expected&& _Self) { return _STD forward(_Self)._Value; } @@ -551,7 +549,7 @@ public: return _Has_value; } -#ifdef __cpp_explicit_this_parameter +#ifdef __cpp_explicit_this_parameter // TRANSITION, P2549 _NODISCARD constexpr decltype(auto) value(this expected&& _Self) { if (_Has_value) { return _STD forward(_Self)._Value; @@ -585,7 +583,7 @@ public: } #endif // !__cpp_explicit_this_parameter -#ifdef __cpp_explicit_this_parameter +#ifdef __cpp_explicit_this_parameter // TRANSITION, P2549 _NODISCARD constexpr decltype(auto) error(this expected&& _Self) noexcept { // strengthened return _STD forward(_Self)._Unexpected; } @@ -626,11 +624,7 @@ public: } // [expected.object.eq] -#ifdef __clang__ // TRANSITION, LLVM-XXXXX - template _UErr> -#else // ^^^ __clang__ ^^^ / vvv !__clang__ vvv template <_Weakly_equality_comparable_with<_Ty> _Uty, _Weakly_equality_comparable_with<_Err> _UErr> -#endif // !__clang__ _NODISCARD_FRIEND constexpr bool operator==(const expected& _Left, const expected<_Uty, _UErr>& _Right) noexcept( noexcept(_Implicitly_convert_to(_Left._Value == *_Right)) && noexcept( _Implicitly_convert_to(_Left._Unexpected == _Right.error()))) { // strengthened @@ -643,13 +637,12 @@ public: } } -#ifdef __clang__ // TRANSITION, LLVM-XXXXX + // clang-format off template -#else // ^^^ __clang__ ^^^ / vvv !__clang__ vvv - template <_Weakly_equality_comparable_with<_Ty> _Uty> -#endif // !__clang__ + requires (!same_as<_Uty, expected> && _Weakly_equality_comparable_with<_Ty, _Uty>) _NODISCARD_FRIEND constexpr bool operator==(const expected& _Left, const _Uty& _Right) noexcept( noexcept(_Implicitly_convert_to(_Left._Value == _Right))) { // strengthened + // clang-format on if (!_Left._Has_value) { return false; } else { @@ -668,7 +661,7 @@ public: } private: -#ifdef __cpp_explicit_this_parameter +#ifdef __cpp_explicit_this_parameter // TRANSITION, P2549 [[noreturn]] inline void _Throw_bad_expected_access(this expected&& _Self) { _THROW(bad_expected_access{_STD forward(_Self)._Unexpected}); } @@ -694,7 +687,7 @@ private: }; }; -template +template // TRANSITION, LWG-3688 requires is_void_v<_Ty> class expected<_Ty, _Err> { public: @@ -915,7 +908,7 @@ public: } constexpr void operator*() const noexcept {} -#ifdef __cpp_explicit_this_parameter +#ifdef __cpp_explicit_this_parameter // TRANSITION, P2549 _NODISCARD constexpr void value(this expected&& _Self) { if (!_Has_value) { _Throw_bad_expected_access(); @@ -944,7 +937,7 @@ public: } #endif // !__cpp_explicit_this_parameter -#ifdef __cpp_explicit_this_parameter +#ifdef __cpp_explicit_this_parameter // TRANSITION, P2549 _NODISCARD constexpr decltype(auto) error(this expected&& _Self) noexcept { // strengthened return _STD forward(_Self)._Unexpected; } @@ -985,7 +978,7 @@ public: } private: -#ifdef __cpp_explicit_this_parameter +#ifdef __cpp_explicit_this_parameter // TRANSITION, P2549 [[noreturn]] inline void _Throw_bad_expected_access(this expected&& _Self) { _THROW(bad_expected_access{_STD forward(_Self)._Unexpected}); } diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index a12ee701de..fd9e5c23cf 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -304,6 +304,7 @@ // P2186R2 Removing Garbage Collection Support // P2273R3 constexpr unique_ptr // P2443R1 views::chunk_by +// P2549R0 unexpected::error() // Parallel Algorithms Notes // C++ allows an implementation to implement parallel algorithms as calls to the serial algorithms. diff --git a/tests/std/tests/VSO_0157762_feature_test_macros/test.compile.pass.cpp b/tests/std/tests/VSO_0157762_feature_test_macros/test.compile.pass.cpp index 46b6d3a694..f0e4922c68 100644 --- a/tests/std/tests/VSO_0157762_feature_test_macros/test.compile.pass.cpp +++ b/tests/std/tests/VSO_0157762_feature_test_macros/test.compile.pass.cpp @@ -714,7 +714,7 @@ STATIC_ASSERT(__cpp_lib_execution == 201603L); #endif #endif -#if _HAS_CXX23 +#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, EDG concepts support #ifndef __cpp_lib_expected #error __cpp_lib_expected is not defined #elif __cpp_lib_expected != 202202L