[libcxx-commits] [libcxx] f900f70 - [libc++] Remove the _LIBCPP_BOOL_CONSTANT macro

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 25 05:46:23 PDT 2022


Author: Louis Dionne
Date: 2022-03-25T08:46:14-04:00
New Revision: f900f7025c7baf4f24dd6425cf0609182ee7efd5

URL: https://github.com/llvm/llvm-project/commit/f900f7025c7baf4f24dd6425cf0609182ee7efd5
DIFF: https://github.com/llvm/llvm-project/commit/f900f7025c7baf4f24dd6425cf0609182ee7efd5.diff

LOG: [libc++] Remove the _LIBCPP_BOOL_CONSTANT macro

I suspect this is a remnant of the times when we were not comfortable
using Clang's C++11/14 extensions everywhere, but now we do, so we can
use _BoolConstant instead and get rid of the macro.

Differential Revision: https://reviews.llvm.org/D122351

Added: 
    

Modified: 
    libcxx/include/exception
    libcxx/include/ratio
    libcxx/include/type_traits

Removed: 
    


################################################################################
diff  --git a/libcxx/include/exception b/libcxx/include/exception
index 5460b73e86f46..a60c8e61b3c42 100644
--- a/libcxx/include/exception
+++ b/libcxx/include/exception
@@ -300,10 +300,10 @@ throw_with_nested(_Tp&& __t)
 }
 
 template <class _From, class _To>
-struct __can_dynamic_cast : public _LIBCPP_BOOL_CONSTANT(
+struct __can_dynamic_cast : _BoolConstant<
               is_polymorphic<_From>::value &&
                  (!is_base_of<_To, _From>::value ||
-                   is_convertible<const _From*, const _To*>::value)) {};
+                   is_convertible<const _From*, const _To*>::value)> {};
 
 template <class _Ep>
 inline _LIBCPP_INLINE_VISIBILITY

diff  --git a/libcxx/include/ratio b/libcxx/include/ratio
index 8970ba36934c1..07376bf8d7134 100644
--- a/libcxx/include/ratio
+++ b/libcxx/include/ratio
@@ -416,11 +416,11 @@ struct _LIBCPP_TEMPLATE_VIS ratio_subtract
 
 template <class _R1, class _R2>
 struct _LIBCPP_TEMPLATE_VIS ratio_equal
-    : public _LIBCPP_BOOL_CONSTANT((_R1::num == _R2::num && _R1::den == _R2::den)) {};
+    : _BoolConstant<(_R1::num == _R2::num && _R1::den == _R2::den)> {};
 
 template <class _R1, class _R2>
 struct _LIBCPP_TEMPLATE_VIS ratio_not_equal
-    : public _LIBCPP_BOOL_CONSTANT((!ratio_equal<_R1, _R2>::value)) {};
+    : _BoolConstant<!ratio_equal<_R1, _R2>::value> {};
 
 // ratio_less
 
@@ -479,19 +479,19 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL>
 
 template <class _R1, class _R2>
 struct _LIBCPP_TEMPLATE_VIS ratio_less
-    : public _LIBCPP_BOOL_CONSTANT((__ratio_less<_R1, _R2>::value)) {};
+    : _BoolConstant<__ratio_less<_R1, _R2>::value> {};
 
 template <class _R1, class _R2>
 struct _LIBCPP_TEMPLATE_VIS ratio_less_equal
-    : public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R2, _R1>::value)) {};
+    : _BoolConstant<!ratio_less<_R2, _R1>::value> {};
 
 template <class _R1, class _R2>
 struct _LIBCPP_TEMPLATE_VIS ratio_greater
-    : public _LIBCPP_BOOL_CONSTANT((ratio_less<_R2, _R1>::value)) {};
+    : _BoolConstant<ratio_less<_R2, _R1>::value> {};
 
 template <class _R1, class _R2>
 struct _LIBCPP_TEMPLATE_VIS ratio_greater_equal
-    : public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R1, _R2>::value)) {};
+    : _BoolConstant<!ratio_less<_R1, _R2>::value> {};
 
 template <class _R1, class _R2>
 struct __ratio_gcd

diff  --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index 6504040ec2021..0ecb0f97205b1 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -450,9 +450,6 @@ _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
 #if _LIBCPP_STD_VER > 14
 template <bool __b>
 using bool_constant = integral_constant<bool, __b>;
-#define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
-#else
-#define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
 #endif
 
 template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
@@ -464,8 +461,8 @@ template <bool _Bp, class _Tp = void> using __enable_if_t _LIBCPP_NODEBUG = type
 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
 #endif
 
-typedef _LIBCPP_BOOL_CONSTANT(true)  true_type;
-typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
+typedef integral_constant<bool, true>  true_type;
+typedef integral_constant<bool, false> false_type;
 
 template <bool _Val>
 using _BoolConstant _LIBCPP_NODEBUG = integral_constant<bool, _Val>;
@@ -1354,7 +1351,7 @@ inline constexpr bool is_signed_v = __is_signed(_Tp);
 #else // __has_keyword(__is_signed)
 
 template <class _Tp, bool = is_integral<_Tp>::value>
-struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
+struct __libcpp_is_signed_impl : public _BoolConstant<(_Tp(-1) < _Tp(0))> {};
 
 template <class _Tp>
 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {};  // floating point
@@ -1392,7 +1389,7 @@ inline constexpr bool is_unsigned_v = __is_unsigned(_Tp);
 #else // __has_keyword(__is_unsigned)
 
 template <class _Tp, bool = is_integral<_Tp>::value>
-struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
+struct __libcpp_is_unsigned_impl : public _BoolConstant<(_Tp(0) < _Tp(-1))> {};
 
 template <class _Tp>
 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {};  // floating point


        


More information about the libcxx-commits mailing list