diff --git a/include/cuda/std/detail/libcxx/include/__type_traits/common_reference.h b/include/cuda/std/detail/libcxx/include/__type_traits/common_reference.h index 7649c31afd..baf289cf1c 100644 --- a/include/cuda/std/detail/libcxx/include/__type_traits/common_reference.h +++ b/include/cuda/std/detail/libcxx/include/__type_traits/common_reference.h @@ -4,6 +4,7 @@ // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) Microsoft Corporation. // //===----------------------------------------------------------------------===// @@ -15,11 +16,16 @@ #endif // __cuda_std__ #include "../__type_traits/common_type.h" +#include "../__type_traits/conditional.h" #include "../__type_traits/copy_cv.h" #include "../__type_traits/copy_cvref.h" +#include "../__type_traits/disjunction.h" #include "../__type_traits/enable_if.h" +#include "../__type_traits/is_array.h" #include "../__type_traits/is_convertible.h" #include "../__type_traits/is_reference.h" +#include "../__type_traits/is_same.h" +#include "../__type_traits/is_scalar.h" #include "../__type_traits/remove_reference.h" #include "../__type_traits/remove_cvref.h" #include "../__type_traits/void_t.h" @@ -35,9 +41,30 @@ _LIBCUDACXX_BEGIN_NAMESPACE_STD #if _LIBCUDACXX_STD_VER > 11 // Let COND_RES(X, Y) be: +#ifdef _LIBCUDACXX_COMPILER_MSVC // Workaround for DevCom-1627396 +template +using __cond_res_if_right = + decltype(false ? _CUDA_VSTD::declval<_Xp(&)()>()() : _CUDA_VSTD::declval<_Yp(&)()>()()); + +template +struct __cond_res_workaround {}; + +template +struct __cond_res_workaround<_Tp, _Up, void_t<__cond_res_if_right<_Tp, _Up>>> { + using _RTp = remove_cvref_t<_Tp>; + using type = conditional_t> && + (is_scalar_v<_RTp> || is_array_v<_RTp>) && + ((is_lvalue_reference_v<_Tp> && is_rvalue_reference_v<_Up>) || (is_rvalue_reference_v<_Tp> && is_lvalue_reference_v<_Up>)), + decay_t<__copy_cv_t, remove_reference_t<_Up>>>, __cond_res_if_right<_Tp, _Up>>; +}; + +template +using __cond_res = typename __cond_res_workaround<_Xp, _Yp>::type; +#else // ^^^ MSVC ^^^ / vvv !MSVC vvv template using __cond_res = decltype(false ? _CUDA_VSTD::declval<_Xp(&)()>()() : _CUDA_VSTD::declval<_Yp(&)()>()()); +#endif // !MSVC // Let `XREF(A)` denote a unary alias template `T` such that `T` denotes the same type as `U` // with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type diff --git a/include/cuda/std/detail/libcxx/include/__type_traits/is_convertible.h b/include/cuda/std/detail/libcxx/include/__type_traits/is_convertible.h index fe70cd5f80..785f170924 100644 --- a/include/cuda/std/detail/libcxx/include/__type_traits/is_convertible.h +++ b/include/cuda/std/detail/libcxx/include/__type_traits/is_convertible.h @@ -4,6 +4,7 @@ // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) Microsoft Corporation. // //===----------------------------------------------------------------------===// @@ -38,6 +39,32 @@ template _LIBCUDACXX_INLINE_VAR constexpr bool is_convertible_v = _LIBCUDACXX_IS_CONVERTIBLE_TO(_T1, _T2); #endif +#ifdef _LIBCUDACXX_COMPILER_MSVC // Workaround for DevCom-1627396 +template +struct is_convertible<_Ty&, volatile _Ty&> : true_type {}; + +template +struct is_convertible : true_type {}; + +template +struct is_convertible<_Ty&, const volatile _Ty&> : true_type {}; + +template +struct is_convertible : true_type {}; + +template +_INLINE_VAR constexpr bool is_convertible_v<_Ty&, volatile _Ty&> = true; + +template +_INLINE_VAR constexpr bool is_convertible_v = true; + +template +_INLINE_VAR constexpr bool is_convertible_v<_Ty&, const volatile _Ty&> = true; + +template +_INLINE_VAR constexpr bool is_convertible_v = true; +#endif // _LIBCUDACXX_COMPILER_MSVC + #else // __has_builtin(__is_convertible_to) && !defined(_LIBCUDACXX_USE_IS_CONVERTIBLE_FALLBACK) namespace __is_convertible_imp