[clang] [clang]: implement std::meta::is_type (PR #211653)
Louis Dionne via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 25 12:55:50 PST 2026
================
@@ -0,0 +1,37 @@
+/*===---- meta - header for reflection metafunctions -----------------------===
+ *
+ * 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 __CLANG_META
+#define __CLANG_META
+
+#if !defined(__clang__)
+#error "this <meta> header is part of Clang and can only be used when compiling with Clang"
+#elif !defined(__cplusplus)
+#error "<meta> is only available in C++ mode"
+#elif !defined(__CLANG_CXX_REFLECTION__)
+#error "<meta> is only available when -freflection is enabled"
+#else
+
+
+namespace std {
+namespace meta {
+
+using info = decltype(^^int);
+
+/// \return \c true if \p __r represents an entity whose underlying entity is a type; \c false otherwise.
+consteval bool is_type(info __r) {
+ return __builtin_meta_is_type(__r);
+}
----------------
ldionne wrote:
@cor3ntin @AaronBallman @changkhothuychung Is the intent that we'll do something like `#include_next <meta>` from libc++?
Actually, is there a reason why these public library APIs are being implemented inside Clang builtin headers as opposed to libc++? I think it would make more sense to make them part of libc++, since they are just calling builtins anyway?
https://github.com/llvm/llvm-project/pull/211653
More information about the cfe-commits
mailing list