[libcxx-commits] [libcxx] [libc++] P2944R3: Constrained comparisons - `optional` (PR #144249)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 10 18:25:33 PDT 2025


================
@@ -24,20 +24,23 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 // and __is_core_convertible<immovable-type,immovable-type> is true in C++17 and later.
 
 template <class _Tp, class _Up, class = void>
-struct __is_core_convertible : false_type {};
+inline const bool __is_core_convertible_v = false;
 
 template <class _Tp, class _Up>
-struct __is_core_convertible<_Tp, _Up, decltype(static_cast<void (*)(_Up)>(0)(static_cast<_Tp (*)()>(0)()))>
-    : true_type {};
+inline const bool
+    __is_core_convertible_v<_Tp, _Up, decltype(static_cast<void (*)(_Up)>(0)(static_cast<_Tp (*)()>(0)()))> = true;
+
+template <class _Tp, class _Up>
+using __is_core_convertible _LIBCPP_NODEBUG = integral_constant<bool, __is_core_convertible_v<_Tp, _Up> >;
----------------
frederick-vs-ja wrote:

It's a bit unusual to just use an alias template instead of inheritance from the `bool_constant`. But this should be fine since no compilation failures happens, and is possibly better due to reduction of instantiation.

https://github.com/llvm/llvm-project/pull/144249


More information about the libcxx-commits mailing list