[libcxx] [mlir] [llvm] [libc++][concepts] Implements concept helper `__libcpp_integer` (PR #78086)

Mark de Wever via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 14 05:27:47 PST 2024


================
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+#include <concepts>
+
+struct SomeObject {};
+
+// Concept helpers for the internal type traits for the fundamental types.
+
+// template <class _Tp>
+// concept __libcpp_unsigned_integer;
+
+// Unsigned
+static_assert(std::__libcpp_unsigned_integer<unsigned char>);
+static_assert(std::__libcpp_unsigned_integer<unsigned short int>);
+static_assert(std::__libcpp_unsigned_integer<unsigned int>);
+static_assert(std::__libcpp_unsigned_integer<unsigned long int>);
+static_assert(std::__libcpp_unsigned_integer<unsigned long long int>);
+static_assert(std::__libcpp_unsigned_integer<unsigned short int>);
+#ifndef _LIBCPP_HAS_NO_INT128
+static_assert(std::__libcpp_unsigned_integer<__uint128_t>);
+#endif
+// Signed
+static_assert(!std::__libcpp_unsigned_integer<signed char>);
+static_assert(!std::__libcpp_unsigned_integer<short int>);
+static_assert(!std::__libcpp_unsigned_integer<int>);
+static_assert(!std::__libcpp_unsigned_integer<long int>);
+static_assert(!std::__libcpp_unsigned_integer<long long int>);
+static_assert(!std::__libcpp_unsigned_integer<short int>);
+#ifndef _LIBCPP_HAS_NO_INT128
+static_assert(!std::__libcpp_unsigned_integer<__int128_t>);
+#endif
+// Non-integer
+static_assert(!std::__libcpp_unsigned_integer<bool>);
----------------
mordante wrote:

Please add `char` and `wchar_t` here too, for completeness adding pointer type and enumerate and scoped enumerate would be nice.

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


More information about the llvm-commits mailing list