[libcxx-commits] [libcxx] [libc++] Extend is_trivially_equality_comparable to integral types with the same signedness and size (PR #70344)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Oct 26 09:10:29 PDT 2023


================
@@ -38,6 +40,12 @@ static_assert(!std::__libcpp_is_trivially_equality_comparable<float, float>::val
 static_assert(!std::__libcpp_is_trivially_equality_comparable<double, double>::value, "");
 static_assert(!std::__libcpp_is_trivially_equality_comparable<long double, long double>::value, "");
 
+static_assert(std::__libcpp_is_trivially_equality_comparable<
+                  char,
+                  typename std::conditional<std::is_signed<char>::value, signed char, unsigned char>::type>::value,
+              "");
+static_assert(std::__libcpp_is_trivially_equality_comparable<char16_t, unsigned short>::value, "");
----------------
ldionne wrote:

I don't think this is portable, `short` technically doesn't need to be 2 bytes. We should use [std::uint_least16_t](https://en.cppreference.com/w/cpp/language/types#char16_t) instead, since it is specified to have the same size, signedness etc as `char16_t`. Good find BTW.

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


More information about the libcxx-commits mailing list