From 82b982b44902ad72ac5fb393be7d36fa8cd965d0 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Sun, 15 Aug 2021 13:43:42 +0700 Subject: [PATCH 1/7] Use "int = 0" SFINAE in --- stl/inc/memory | 61 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 10 deletions(-) diff --git a/stl/inc/memory b/stl/inc/memory index 88726d5ee6..57ae322347 100644 --- a/stl/inc/memory +++ b/stl/inc/memory @@ -3241,6 +3241,12 @@ private: _Compressed_pair<_Dx, pointer> _Mypair; }; +#ifdef __CUDACC__ // TRANSITION, CUDA +#define _USE_MEMORY_INT_0_SFINAE 0 +#else +#define _USE_MEMORY_INT_0_SFINAE 1 +#endif // __CUDACC__ + template class unique_ptr<_Ty[], _Dx> { // non-copyable pointer to an array object public: @@ -3254,22 +3260,41 @@ public: template > using _Enable_ctor_reset = enable_if_t // - || _Is_nullptr::value // - || (is_same_v // - && is_pointer_v<_Uty> // - && is_convertible_v (*)[], element_type (*)[]>)>; // TRANSITION, GH-248 - + || _Is_nullptr::value // + || (is_same_v // + && is_pointer_v<_Uty> // + && is_convertible_v (*)[], element_type (*)[]>), + int>; + +#if _USE_MEMORY_INT_0_SFINAE + template = 0, _Enable_ctor_reset<_Uty> = 0> +#else // ^^^ _USE_MEMORY_INT_0_SFINAE // !_USE_MEMORY_INT_0_SFINAE vvv template = 0, class = _Enable_ctor_reset<_Uty>> - explicit unique_ptr(_Uty _Ptr) noexcept : _Mypair(_Zero_then_variadic_args_t{}, _Ptr) {} +#endif // _USE_MEMORY_INT_0_SFINAE + explicit unique_ptr(_Uty _Ptr) noexcept : _Mypair(_Zero_then_variadic_args_t{}, _Ptr) { + } +#if _USE_MEMORY_INT_0_SFINAE + template , int> = 0, + _Enable_ctor_reset<_Uty> = 0> +#else // ^^^ _USE_MEMORY_INT_0_SFINAE // !_USE_MEMORY_INT_0_SFINAE vvv template , int> = 0, class = _Enable_ctor_reset<_Uty>> - unique_ptr(_Uty _Ptr, const _Dx& _Dt) noexcept : _Mypair(_One_then_variadic_args_t{}, _Dt, _Ptr) {} +#endif // _USE_MEMORY_INT_0_SFINAE + unique_ptr(_Uty _Ptr, const _Dx& _Dt) noexcept : _Mypair(_One_then_variadic_args_t{}, _Dt, _Ptr) { + } +#if _USE_MEMORY_INT_0_SFINAE + template >, is_constructible<_Dx2, _Dx2>>, int> = 0, + _Enable_ctor_reset<_Uty> = 0> +#else // ^^^ _USE_MEMORY_INT_0_SFINAE // !_USE_MEMORY_INT_0_SFINAE vvv template >, is_constructible<_Dx2, _Dx2>>, int> = 0, class = _Enable_ctor_reset<_Uty>> - unique_ptr(_Uty _Ptr, _Dx&& _Dt) noexcept : _Mypair(_One_then_variadic_args_t{}, _STD move(_Dt), _Ptr) {} +#endif // _USE_MEMORY_INT_0_SFINAE + unique_ptr(_Uty _Ptr, _Dx&& _Dt) noexcept : _Mypair(_One_then_variadic_args_t{}, _STD move(_Dt), _Ptr) { + } template , is_constructible<_Dx2, remove_reference_t<_Dx2>>>, int> = 0> @@ -3293,15 +3318,27 @@ public: class _UP_element_type = typename unique_ptr<_Uty, _Ex>::element_type> using _Enable_conversion = enable_if_t< conjunction_v, is_same, is_same<_UP_pointer, _UP_element_type*>, - is_convertible<_UP_element_type (*)[], element_type (*)[]>, _More>>; // TRANSITION, GH-248 + is_convertible<_UP_element_type (*)[], element_type (*)[]>, _More>, + int>; +#if _USE_MEMORY_INT_0_SFINAE + template , is_same<_Ex, _Dx>, is_convertible<_Ex, _Dx>>> = + 0> +#else // ^^^ _USE_MEMORY_INT_0_SFINAE // !_USE_MEMORY_INT_0_SFINAE vvv template , is_same<_Ex, _Dx>, is_convertible<_Ex, _Dx>>>> +#endif // _USE_MEMORY_INT_0_SFINAE unique_ptr(unique_ptr<_Uty, _Ex>&& _Right) noexcept - : _Mypair(_One_then_variadic_args_t{}, _STD forward<_Ex>(_Right.get_deleter()), _Right.release()) {} + : _Mypair(_One_then_variadic_args_t{}, _STD forward<_Ex>(_Right.get_deleter()), _Right.release()) { + } +#if _USE_MEMORY_INT_0_SFINAE + template > = 0> +#else // ^^^ _USE_MEMORY_INT_0_SFINAE // !_USE_MEMORY_INT_0_SFINAE vvv template >> +#endif // _USE_MEMORY_INT_0_SFINAE unique_ptr& operator=(unique_ptr<_Uty, _Ex>&& _Right) noexcept { reset(_Right.release()); _Mypair._Get_first() = _STD forward<_Ex>(_Right._Mypair._Get_first()); @@ -3355,7 +3392,11 @@ public: return _STD exchange(_Mypair._Myval2, nullptr); } +#if _USE_MEMORY_INT_0_SFINAE + template = 0> +#else // ^^^ _USE_MEMORY_INT_0_SFINAE // !_USE_MEMORY_INT_0_SFINAE vvv template > +#endif // _USE_MEMORY_INT_0_SFINAE void reset(_Uty _Ptr) noexcept { pointer _Old = _STD exchange(_Mypair._Myval2, _Ptr); if (_Old) { From 1db3aabfecac296338665f93634c2dd93bac0525 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Sat, 21 Aug 2021 21:00:55 +0700 Subject: [PATCH 2/7] undef macros --- stl/inc/functional | 2 ++ stl/inc/memory | 2 ++ 2 files changed, 4 insertions(+) diff --git a/stl/inc/functional b/stl/inc/functional index 2db14e9137..64cab72d61 100644 --- a/stl/inc/functional +++ b/stl/inc/functional @@ -2158,6 +2158,8 @@ namespace _DEPRECATE_TR1_NAMESPACE tr1 { } // namespace tr1 #endif // _HAS_TR1_NAMESPACE +#undef _USE_FUNCTION_INT_0_SFINAE + _STD_END #pragma pop_macro("new") diff --git a/stl/inc/memory b/stl/inc/memory index 57ae322347..902f4f1304 100644 --- a/stl/inc/memory +++ b/stl/inc/memory @@ -4304,6 +4304,8 @@ namespace _DEPRECATE_TR1_NAMESPACE tr1 { } // namespace tr1 #endif // _HAS_TR1_NAMESPACE +#undef _USE_MEMORY_INT_0_SFINAE + _STD_END #pragma pop_macro("new") _STL_RESTORE_CLANG_WARNINGS From e3dcf70c84eee9fa039c4a973f19e4845866e1a5 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Sat, 7 May 2022 20:20:20 +0700 Subject: [PATCH 3/7] delete an extra new line --- stl/inc/memory | 1 - 1 file changed, 1 deletion(-) diff --git a/stl/inc/memory b/stl/inc/memory index e33fce4ee5..4d3b25ace7 100644 --- a/stl/inc/memory +++ b/stl/inc/memory @@ -3341,7 +3341,6 @@ public: _CONSTEXPR23 unique_ptr(_Uty _Ptr, const _Dx& _Dt) noexcept : _Mypair(_One_then_variadic_args_t{}, _Dt, _Ptr) { } - #if _USE_MEMORY_INT_0_SFINAE template >, is_constructible<_Dx2, _Dx2>>, int> = 0, From cae7f5216ba867f2cbba67b839c3b7d270fe603e Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Mon, 9 May 2022 21:56:48 +0700 Subject: [PATCH 4/7] use only one macro `_USE_INT_0_SFINAE` for every header. --- stl/inc/functional | 25 +++++++++---------------- stl/inc/memory | 44 ++++++++++++++++++-------------------------- stl/inc/yvals_core.h | 6 ++++++ 3 files changed, 33 insertions(+), 42 deletions(-) diff --git a/stl/inc/functional b/stl/inc/functional index 57d8025231..319c5a67b3 100644 --- a/stl/inc/functional +++ b/stl/inc/functional @@ -853,11 +853,6 @@ private: _Callable _Callee; }; -#ifdef __CUDACC__ // TRANSITION, CUDA -#define _USE_FUNCTION_INT_0_SFINAE 0 -#else -#define _USE_FUNCTION_INT_0_SFINAE 1 -#endif // __CUDACC__ template class _Func_class : public _Arg_types<_Types...> { @@ -1042,11 +1037,11 @@ public: this->_Reset_copy(_Right); } -#if _USE_FUNCTION_INT_0_SFINAE +#if _USE_INT_0_SFINAE template = 0> -#else // ^^^ _USE_FUNCTION_INT_0_SFINAE // !_USE_FUNCTION_INT_0_SFINAE vvv +#else // ^^^ _USE_INT_0_SFINAE // !_USE_INT_0_SFINAE vvv template > -#endif // _USE_FUNCTION_INT_0_SFINAE +#endif // _USE_INT_0_SFINAE function(_Fx&& _Func) { this->_Reset(_STD forward<_Fx>(_Func)); } @@ -1063,11 +1058,11 @@ public: this->_Reset_alloc(_Right, _Ax); } -#if _USE_FUNCTION_INT_0_SFINAE +#if _USE_INT_0_SFINAE template = 0> -#else // ^^^ _USE_FUNCTION_INT_0_SFINAE // !_USE_FUNCTION_INT_0_SFINAE vvv +#else // ^^^ _USE_INT_0_SFINAE // !_USE_INT_0_SFINAE vvv template > -#endif // _USE_FUNCTION_INT_0_SFINAE +#endif // _USE_INT_0_SFINAE function(allocator_arg_t, const _Alloc& _Ax, _Fx&& _Func) { this->_Reset_alloc(_STD forward<_Fx>(_Func), _Ax); } @@ -1097,11 +1092,11 @@ public: return *this; } -#if _USE_FUNCTION_INT_0_SFINAE +#if _USE_INT_0_SFINAE template = 0> -#else // ^^^ _USE_FUNCTION_INT_0_SFINAE // !_USE_FUNCTION_INT_0_SFINAE vvv +#else // ^^^ _USE_INT_0_SFINAE // !_USE_INT_0_SFINAE vvv template > -#endif // _USE_FUNCTION_INT_0_SFINAE +#endif // _USE_INT_0_SFINAE function& operator=(_Fx&& _Func) { function(_STD forward<_Fx>(_Func)).swap(*this); return *this; @@ -2795,8 +2790,6 @@ namespace _DEPRECATE_TR1_NAMESPACE tr1 { } // namespace tr1 #endif // _HAS_TR1_NAMESPACE -#undef _USE_FUNCTION_INT_0_SFINAE - _STD_END #pragma pop_macro("new") diff --git a/stl/inc/memory b/stl/inc/memory index 4d3b25ace7..553c124a9c 100644 --- a/stl/inc/memory +++ b/stl/inc/memory @@ -3298,12 +3298,6 @@ private: _Compressed_pair<_Dx, pointer> _Mypair; }; -#ifdef __CUDACC__ // TRANSITION, CUDA -#define _USE_MEMORY_INT_0_SFINAE 0 -#else -#define _USE_MEMORY_INT_0_SFINAE 1 -#endif // __CUDACC__ - template class unique_ptr<_Ty[], _Dx> { // non-copyable pointer to an array object public: @@ -3323,33 +3317,33 @@ public: && is_convertible_v (*)[], element_type (*)[]>), int>; -#if _USE_MEMORY_INT_0_SFINAE +#if _USE_INT_0_SFINAE template = 0, _Enable_ctor_reset<_Uty> = 0> -#else // ^^^ _USE_MEMORY_INT_0_SFINAE // !_USE_MEMORY_INT_0_SFINAE vvv +#else // ^^^ _USE_INT_0_SFINAE // !_USE_INT_0_SFINAE vvv template = 0, class = _Enable_ctor_reset<_Uty>> -#endif // _USE_MEMORY_INT_0_SFINAE +#endif // _USE_INT_0_SFINAE _CONSTEXPR23 explicit unique_ptr(_Uty _Ptr) noexcept : _Mypair(_Zero_then_variadic_args_t{}, _Ptr) { } -#if _USE_MEMORY_INT_0_SFINAE +#if _USE_INT_0_SFINAE template , int> = 0, _Enable_ctor_reset<_Uty> = 0> -#else // ^^^ _USE_MEMORY_INT_0_SFINAE // !_USE_MEMORY_INT_0_SFINAE vvv +#else // ^^^ _USE_INT_0_SFINAE // !_USE_INT_0_SFINAE vvv template , int> = 0, class = _Enable_ctor_reset<_Uty>> -#endif // _USE_MEMORY_INT_0_SFINAE +#endif // _USE_INT_0_SFINAE _CONSTEXPR23 unique_ptr(_Uty _Ptr, const _Dx& _Dt) noexcept : _Mypair(_One_then_variadic_args_t{}, _Dt, _Ptr) { } -#if _USE_MEMORY_INT_0_SFINAE +#if _USE_INT_0_SFINAE template >, is_constructible<_Dx2, _Dx2>>, int> = 0, _Enable_ctor_reset<_Uty> = 0> -#else // ^^^ _USE_MEMORY_INT_0_SFINAE // !_USE_MEMORY_INT_0_SFINAE vvv +#else // ^^^ _USE_INT_0_SFINAE // !_USE_INT_0_SFINAE vvv template >, is_constructible<_Dx2, _Dx2>>, int> = 0, class = _Enable_ctor_reset<_Uty>> -#endif // _USE_MEMORY_INT_0_SFINAE +#endif // _USE_INT_0_SFINAE _CONSTEXPR23 unique_ptr(_Uty _Ptr, _Dx&& _Dt) noexcept : _Mypair(_One_then_variadic_args_t{}, _STD move(_Dt), _Ptr) { } @@ -3379,24 +3373,24 @@ public: is_convertible<_UP_element_type (*)[], element_type (*)[]>, _More>, int>; -#if _USE_MEMORY_INT_0_SFINAE +#if _USE_INT_0_SFINAE template , is_same<_Ex, _Dx>, is_convertible<_Ex, _Dx>>> = 0> -#else // ^^^ _USE_MEMORY_INT_0_SFINAE // !_USE_MEMORY_INT_0_SFINAE vvv +#else // ^^^ _USE_INT_0_SFINAE // !_USE_INT_0_SFINAE vvv template , is_same<_Ex, _Dx>, is_convertible<_Ex, _Dx>>>> -#endif // _USE_MEMORY_INT_0_SFINAE +#endif // _USE_INT_0_SFINAE _CONSTEXPR23 unique_ptr(unique_ptr<_Uty, _Ex>&& _Right) noexcept : _Mypair(_One_then_variadic_args_t{}, _STD forward<_Ex>(_Right.get_deleter()), _Right.release()) { } -#if _USE_MEMORY_INT_0_SFINAE +#if _USE_INT_0_SFINAE template > = 0> -#else // ^^^ _USE_MEMORY_INT_0_SFINAE // !_USE_MEMORY_INT_0_SFINAE vvv +#else // ^^^ _USE_INT_0_SFINAE // !_USE_INT_0_SFINAE vvv template >> -#endif // _USE_MEMORY_INT_0_SFINAE +#endif // _USE_INT_0_SFINAE _CONSTEXPR23 unique_ptr& operator=(unique_ptr<_Uty, _Ex>&& _Right) noexcept { reset(_Right.release()); _Mypair._Get_first() = _STD forward<_Ex>(_Right._Mypair._Get_first()); @@ -3450,11 +3444,11 @@ public: return _STD exchange(_Mypair._Myval2, nullptr); } -#if _USE_MEMORY_INT_0_SFINAE +#if _USE_INT_0_SFINAE template = 0> -#else // ^^^ _USE_MEMORY_INT_0_SFINAE // !_USE_MEMORY_INT_0_SFINAE vvv +#else // ^^^ _USE_INT_0_SFINAE // !_USE_INT_0_SFINAE vvv template > -#endif // _USE_MEMORY_INT_0_SFINAE +#endif // _USE_INT_0_SFINAE _CONSTEXPR23 void reset(_Uty _Ptr) noexcept { pointer _Old = _STD exchange(_Mypair._Myval2, _Ptr); if (_Old) { @@ -4366,8 +4360,6 @@ namespace _DEPRECATE_TR1_NAMESPACE tr1 { } // namespace tr1 #endif // _HAS_TR1_NAMESPACE -#undef _USE_MEMORY_INT_0_SFINAE - _STD_END #pragma pop_macro("new") _STL_RESTORE_CLANG_WARNINGS diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 68f36b0dbd..d51efe4e3b 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -1552,5 +1552,11 @@ compiler option, or define _ALLOW_RTCc_IN_STL to acknowledge that you have recei #define _MSVC_CONSTEXPR #endif +#ifdef __CUDACC__ // TRANSITION, CUDA +#define _USE_INT_0_SFINAE 0 +#else +#define _USE_INT_0_SFINAE 1 +#endif // __CUDACC__ + #endif // _STL_COMPILER_PREPROCESSOR #endif // _YVALS_CORE_H_ From c8d3a534b0548933121e62aa828c620b56ff63f1 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Mon, 9 May 2022 21:59:56 +0700 Subject: [PATCH 5/7] remove new line --- stl/inc/functional | 1 - 1 file changed, 1 deletion(-) diff --git a/stl/inc/functional b/stl/inc/functional index 319c5a67b3..903cb4189a 100644 --- a/stl/inc/functional +++ b/stl/inc/functional @@ -853,7 +853,6 @@ private: _Callable _Callee; }; - template class _Func_class : public _Arg_types<_Types...> { public: From 1b5a8c3a9533721508335c8f2f81518f950cedad Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Sat, 18 Jun 2022 23:46:00 +0700 Subject: [PATCH 6/7] it seems cuda 11.6 doesn't have the bug --- stl/inc/functional | 12 ------------ stl/inc/memory | 41 ++++------------------------------------- stl/inc/yvals_core.h | 6 ------ 3 files changed, 4 insertions(+), 55 deletions(-) diff --git a/stl/inc/functional b/stl/inc/functional index 48b5ef3751..fefcb6c39b 100644 --- a/stl/inc/functional +++ b/stl/inc/functional @@ -1036,11 +1036,7 @@ public: this->_Reset_copy(_Right); } -#if _USE_INT_0_SFINAE template = 0> -#else // ^^^ _USE_INT_0_SFINAE // !_USE_INT_0_SFINAE vvv - template > -#endif // _USE_INT_0_SFINAE function(_Fx&& _Func) { this->_Reset(_STD forward<_Fx>(_Func)); } @@ -1057,11 +1053,7 @@ public: this->_Reset_alloc(_Right, _Ax); } -#if _USE_INT_0_SFINAE template = 0> -#else // ^^^ _USE_INT_0_SFINAE // !_USE_INT_0_SFINAE vvv - template > -#endif // _USE_INT_0_SFINAE function(allocator_arg_t, const _Alloc& _Ax, _Fx&& _Func) { this->_Reset_alloc(_STD forward<_Fx>(_Func), _Ax); } @@ -1091,11 +1083,7 @@ public: return *this; } -#if _USE_INT_0_SFINAE template = 0> -#else // ^^^ _USE_INT_0_SFINAE // !_USE_INT_0_SFINAE vvv - template > -#endif // _USE_INT_0_SFINAE function& operator=(_Fx&& _Func) { function(_STD forward<_Fx>(_Func)).swap(*this); return *this; diff --git a/stl/inc/memory b/stl/inc/memory index c19e11fd9a..00f66429f1 100644 --- a/stl/inc/memory +++ b/stl/inc/memory @@ -3317,36 +3317,18 @@ public: && is_convertible_v (*)[], element_type (*)[]>), int>; -#if _USE_INT_0_SFINAE template = 0, _Enable_ctor_reset<_Uty> = 0> -#else // ^^^ _USE_INT_0_SFINAE // !_USE_INT_0_SFINAE vvv - template = 0, class = _Enable_ctor_reset<_Uty>> -#endif // _USE_INT_0_SFINAE - _CONSTEXPR23 explicit unique_ptr(_Uty _Ptr) noexcept : _Mypair(_Zero_then_variadic_args_t{}, _Ptr) { - } + _CONSTEXPR23 explicit unique_ptr(_Uty _Ptr) noexcept : _Mypair(_Zero_then_variadic_args_t{}, _Ptr) {} -#if _USE_INT_0_SFINAE template , int> = 0, _Enable_ctor_reset<_Uty> = 0> -#else // ^^^ _USE_INT_0_SFINAE // !_USE_INT_0_SFINAE vvv - template , int> = 0, - class = _Enable_ctor_reset<_Uty>> -#endif // _USE_INT_0_SFINAE - _CONSTEXPR23 unique_ptr(_Uty _Ptr, const _Dx& _Dt) noexcept : _Mypair(_One_then_variadic_args_t{}, _Dt, _Ptr) { - } + _CONSTEXPR23 unique_ptr(_Uty _Ptr, const _Dx& _Dt) noexcept : _Mypair(_One_then_variadic_args_t{}, _Dt, _Ptr) {} -#if _USE_INT_0_SFINAE template >, is_constructible<_Dx2, _Dx2>>, int> = 0, _Enable_ctor_reset<_Uty> = 0> -#else // ^^^ _USE_INT_0_SFINAE // !_USE_INT_0_SFINAE vvv - template >, is_constructible<_Dx2, _Dx2>>, int> = 0, - class = _Enable_ctor_reset<_Uty>> -#endif // _USE_INT_0_SFINAE _CONSTEXPR23 unique_ptr(_Uty _Ptr, _Dx&& _Dt) noexcept - : _Mypair(_One_then_variadic_args_t{}, _STD move(_Dt), _Ptr) { - } + : _Mypair(_One_then_variadic_args_t{}, _STD move(_Dt), _Ptr) {} template , is_constructible<_Dx2, remove_reference_t<_Dx2>>>, int> = 0> @@ -3373,24 +3355,13 @@ public: is_convertible<_UP_element_type (*)[], element_type (*)[]>, _More>, int>; -#if _USE_INT_0_SFINAE template , is_same<_Ex, _Dx>, is_convertible<_Ex, _Dx>>> = 0> -#else // ^^^ _USE_INT_0_SFINAE // !_USE_INT_0_SFINAE vvv - template , is_same<_Ex, _Dx>, is_convertible<_Ex, _Dx>>>> -#endif // _USE_INT_0_SFINAE _CONSTEXPR23 unique_ptr(unique_ptr<_Uty, _Ex>&& _Right) noexcept - : _Mypair(_One_then_variadic_args_t{}, _STD forward<_Ex>(_Right.get_deleter()), _Right.release()) { - } + : _Mypair(_One_then_variadic_args_t{}, _STD forward<_Ex>(_Right.get_deleter()), _Right.release()) {} -#if _USE_INT_0_SFINAE template > = 0> -#else // ^^^ _USE_INT_0_SFINAE // !_USE_INT_0_SFINAE vvv - template >> -#endif // _USE_INT_0_SFINAE _CONSTEXPR23 unique_ptr& operator=(unique_ptr<_Uty, _Ex>&& _Right) noexcept { reset(_Right.release()); _Mypair._Get_first() = _STD forward<_Ex>(_Right._Mypair._Get_first()); @@ -3444,11 +3415,7 @@ public: return _STD exchange(_Mypair._Myval2, nullptr); } -#if _USE_INT_0_SFINAE template = 0> -#else // ^^^ _USE_INT_0_SFINAE // !_USE_INT_0_SFINAE vvv - template > -#endif // _USE_INT_0_SFINAE _CONSTEXPR23 void reset(_Uty _Ptr) noexcept { pointer _Old = _STD exchange(_Mypair._Myval2, _Ptr); if (_Old) { diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index db3436d1e3..f0f9f46f74 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -1621,11 +1621,5 @@ compiler option, or define _ALLOW_RTCc_IN_STL to acknowledge that you have recei #define _STL_INTERNAL_STATIC_ASSERT(...) #endif // _ENABLE_STL_INTERNAL_CHECK -#ifdef __CUDACC__ // TRANSITION, CUDA -#define _USE_INT_0_SFINAE 0 -#else -#define _USE_INT_0_SFINAE 1 -#endif // __CUDACC__ - #endif // _STL_COMPILER_PREPROCESSOR #endif // _YVALS_CORE_H_ From 7361da6725f3e17bdf177a2d00f75dd9fd8b5f40 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Thu, 18 Aug 2022 19:32:13 -0700 Subject: [PATCH 7/7] Work around VSO-1595465 "/clr /std:c++17 ICE with `int = 0` SFINAE". --- stl/inc/memory | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/stl/inc/memory b/stl/inc/memory index 0b3224512f..299c13f783 100644 --- a/stl/inc/memory +++ b/stl/inc/memory @@ -3278,18 +3278,33 @@ public: && is_convertible_v (*)[], element_type (*)[]>), int>; +#ifdef _M_CEE // TRANSITION, VSO-1595465 + template = 0, class = _Enable_ctor_reset<_Uty>> +#else // ^^^ workaround / no workaround vvv template = 0, _Enable_ctor_reset<_Uty> = 0> - _CONSTEXPR23 explicit unique_ptr(_Uty _Ptr) noexcept : _Mypair(_Zero_then_variadic_args_t{}, _Ptr) {} +#endif // ^^^ no workaround ^^^ + _CONSTEXPR23 explicit unique_ptr(_Uty _Ptr) noexcept : _Mypair(_Zero_then_variadic_args_t{}, _Ptr) { + } template , int> = 0, +#ifdef _M_CEE // TRANSITION, VSO-1595465 + class = _Enable_ctor_reset<_Uty>> +#else // ^^^ workaround / no workaround vvv _Enable_ctor_reset<_Uty> = 0> - _CONSTEXPR23 unique_ptr(_Uty _Ptr, const _Dx& _Dt) noexcept : _Mypair(_One_then_variadic_args_t{}, _Dt, _Ptr) {} +#endif // ^^^ no workaround ^^^ + _CONSTEXPR23 unique_ptr(_Uty _Ptr, const _Dx& _Dt) noexcept : _Mypair(_One_then_variadic_args_t{}, _Dt, _Ptr) { + } template >, is_constructible<_Dx2, _Dx2>>, int> = 0, - _Enable_ctor_reset<_Uty> = 0> +#ifdef _M_CEE // TRANSITION, VSO-1595465 + class = _Enable_ctor_reset<_Uty>> +#else // ^^^ workaround / no workaround vvv + _Enable_ctor_reset<_Uty> = 0> +#endif // ^^^ no workaround ^^^ _CONSTEXPR23 unique_ptr(_Uty _Ptr, _Dx&& _Dt) noexcept - : _Mypair(_One_then_variadic_args_t{}, _STD move(_Dt), _Ptr) {} + : _Mypair(_One_then_variadic_args_t{}, _STD move(_Dt), _Ptr) { + } template , is_constructible<_Dx2, remove_reference_t<_Dx2>>>, int> = 0> @@ -3317,12 +3332,22 @@ public: int>; template , is_same<_Ex, _Dx>, is_convertible<_Ex, _Dx>>>> +#else // ^^^ workaround / no workaround vvv _Enable_conversion<_Uty, _Ex, conditional_t, is_same<_Ex, _Dx>, is_convertible<_Ex, _Dx>>> = 0> +#endif // ^^^ no workaround ^^^ _CONSTEXPR23 unique_ptr(unique_ptr<_Uty, _Ex>&& _Right) noexcept - : _Mypair(_One_then_variadic_args_t{}, _STD forward<_Ex>(_Right.get_deleter()), _Right.release()) {} + : _Mypair(_One_then_variadic_args_t{}, _STD forward<_Ex>(_Right.get_deleter()), _Right.release()) { + } +#ifdef _M_CEE // TRANSITION, VSO-1595465 + template >> +#else // ^^^ workaround / no workaround vvv template > = 0> +#endif // ^^^ no workaround ^^^ _CONSTEXPR23 unique_ptr& operator=(unique_ptr<_Uty, _Ex>&& _Right) noexcept { reset(_Right.release()); _Mypair._Get_first() = _STD forward<_Ex>(_Right._Mypair._Get_first()); @@ -3376,7 +3401,11 @@ public: return _STD exchange(_Mypair._Myval2, nullptr); } +#ifdef _M_CEE // TRANSITION, VSO-1595465 + template > +#else // ^^^ workaround / no workaround vvv template = 0> +#endif // ^^^ no workaround ^^^ _CONSTEXPR23 void reset(_Uty _Ptr) noexcept { pointer _Old = _STD exchange(_Mypair._Myval2, _Ptr); if (_Old) {