[libcxx-commits] [libcxx] [libc++] Remove dead implementation of is_nothrow_convertible and merge the remaining code into is_convertible.h (PR #137717)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Mon Apr 28 14:49:58 PDT 2025


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/137717

None

>From d32f84e04e7ec1151b2571e8dbf0d47382f9b38b Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Mon, 28 Apr 2025 23:49:34 +0200
Subject: [PATCH] [libc++] Remove dead implementation of is_nothrow_convertible
 and merge the remaining code into is_convertible.h

---
 libcxx/include/CMakeLists.txt                 |  1 -
 libcxx/include/__type_traits/is_convertible.h | 10 +++
 .../__type_traits/is_nothrow_convertible.h    | 62 -------------------
 libcxx/include/module.modulemap.in            |  4 --
 libcxx/include/type_traits                    |  1 -
 5 files changed, 10 insertions(+), 68 deletions(-)
 delete mode 100644 libcxx/include/__type_traits/is_nothrow_convertible.h

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index f1bdf684a8549..0277382cc84dd 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -835,7 +835,6 @@ set(files
   __type_traits/is_member_pointer.h
   __type_traits/is_nothrow_assignable.h
   __type_traits/is_nothrow_constructible.h
-  __type_traits/is_nothrow_convertible.h
   __type_traits/is_nothrow_destructible.h
   __type_traits/is_null_pointer.h
   __type_traits/is_object.h
diff --git a/libcxx/include/__type_traits/is_convertible.h b/libcxx/include/__type_traits/is_convertible.h
index cef3c4a764914..f0a859f9cc16d 100644
--- a/libcxx/include/__type_traits/is_convertible.h
+++ b/libcxx/include/__type_traits/is_convertible.h
@@ -26,6 +26,16 @@ template <class _From, class _To>
 _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_convertible_v = __is_convertible(_From, _To);
 #endif
 
+#if _LIBCPP_STD_VER >= 20
+
+template <class _Tp, class _Up>
+struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_convertible : bool_constant<__is_nothrow_convertible(_Tp, _Up)> {};
+
+template <class _Tp, class _Up>
+_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_convertible_v = __is_nothrow_convertible(_Tp, _Up);
+
+#endif // _LIBCPP_STD_VER >= 20
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif // _LIBCPP___TYPE_TRAITS_IS_CONVERTIBLE_H
diff --git a/libcxx/include/__type_traits/is_nothrow_convertible.h b/libcxx/include/__type_traits/is_nothrow_convertible.h
deleted file mode 100644
index f114619296437..0000000000000
--- a/libcxx/include/__type_traits/is_nothrow_convertible.h
+++ /dev/null
@@ -1,62 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H
-#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H
-
-#include <__config>
-#include <__type_traits/conjunction.h>
-#include <__type_traits/disjunction.h>
-#include <__type_traits/integral_constant.h>
-#include <__type_traits/is_convertible.h>
-#include <__type_traits/is_void.h>
-#include <__type_traits/lazy.h>
-#include <__utility/declval.h>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#  pragma GCC system_header
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-#if _LIBCPP_STD_VER >= 20
-
-#  if __has_builtin(__is_nothrow_convertible)
-
-template <class _Tp, class _Up>
-struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_convertible : bool_constant<__is_nothrow_convertible(_Tp, _Up)> {};
-
-template <class _Tp, class _Up>
-_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_convertible_v = __is_nothrow_convertible(_Tp, _Up);
-
-#  else // __has_builtin(__is_nothrow_convertible)
-
-template <typename _Tp>
-void __test_noexcept(_Tp) noexcept;
-
-template <typename _Fm, typename _To>
-bool_constant<noexcept(std::__test_noexcept<_To>(std::declval<_Fm>()))> __is_nothrow_convertible_test();
-
-template <typename _Fm, typename _To>
-struct __is_nothrow_convertible_helper : decltype(std::__is_nothrow_convertible_test<_Fm, _To>()) {};
-
-template <typename _Fm, typename _To>
-struct is_nothrow_convertible
-    : _Or<_And<is_void<_To>, is_void<_Fm>>,
-          _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To> > >::type {};
-
-template <typename _Fm, typename _To>
-inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value;
-
-#  endif // __has_builtin(__is_nothrow_convertible)
-
-#endif // _LIBCPP_STD_VER >= 20
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index af928a63f2315..7260c3a5d51f3 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -232,10 +232,6 @@ module std_core [system] {
       header "__type_traits/is_nothrow_constructible.h"
       export std_core.type_traits.integral_constant
     }
-    module is_nothrow_convertible {
-      header "__type_traits/is_nothrow_convertible.h"
-      export std_core.type_traits.integral_constant
-    }
     module is_nothrow_destructible {
       header "__type_traits/is_nothrow_destructible.h"
       export std_core.type_traits.integral_constant
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index b63f61cfefe8e..9db7b2afb0cf3 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -549,7 +549,6 @@ namespace std
 #    include <__type_traits/common_reference.h>
 #    include <__type_traits/is_bounded_array.h>
 #    include <__type_traits/is_constant_evaluated.h>
-#    include <__type_traits/is_nothrow_convertible.h>
 #    include <__type_traits/is_unbounded_array.h>
 #    include <__type_traits/type_identity.h>
 #    include <__type_traits/unwrap_ref.h>



More information about the libcxx-commits mailing list