[clang] [clang]: implement std::meta::is_type (PR #211653)
Hristo Hristov via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 26 22:09:56 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);
+}
----------------
Zingam wrote:
> @Zingam Hi!
>
> The decision for now is that meta header will be provided in Clang. The latest status is in [this PR ](https://github.com/llvm/llvm-project/pull/237637)
>
> Regarding the nodiscard, I will sync with the core maintainers and give you an update. Thanks!
I did most of the work on applying `[[nodiscard]]` to libc++, which should now be complete: https://github.com/llvm/llvm-project/issues/172124 CC @frederick-vs-ja as the main reviewer.
https://github.com/llvm/llvm-project/pull/211653
More information about the cfe-commits
mailing list