[PATCH] c++, libstdc++, v2: Implement P3856R8 - New reflection metafunction - is_structural_type

Jakub Jelinek jakub@redhat.com
Sat Mar 28 17:58:04 GMT 2026


On Sat, Mar 28, 2026 at 05:46:07PM +0000, Jonathan Wakely wrote:
> > +ftms = {
> > +  name = is_structural;
> > +  values = {
> > +    v = 202603;
> > +    cxxmin = 26;
> > +    extra_cond = "__has_builtin(__builtin_is_structural)";
> 
> Hmm, we always use __has_builtin directly in <version>, which I guess
> isn't ideal. But it's consistent with the other feature test macros.

Guess if we want to change it, we should change all of them.

> > --- libstdc++-v3/include/std/meta.jj    2026-03-25 20:19:53.791992428 +0100
> > +++ libstdc++-v3/include/std/meta       2026-03-26 17:39:52.979042203 +0100
> > @@ -466,6 +466,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> >      consteval bool is_final_type(info);
> >      consteval bool is_aggregate_type(info);
> >      consteval bool is_consteval_only_type(info);
> > +    consteval bool is_structural_type(info);
> 
> Does this not check the feature test macro because <meta> is coupled
> to the compiler, and only works with GCC not Clang, and we know GCC
> supports this metafunction?

I think at this point is a big unknown what we'll need to do in <meta> for
other compilers.
Either they decide to use at least mostly similar strategy as GCC (consteval
declarations without definitions in <meta>, compiler provides everything;
we've tried with Marek to convince them for this path a few weeks ago),
or they decide to put a lot of stuff in the header and use some builtins in
there (that is what is on Dan's clang fork and some clang developers prefer
that; in that case I think cleanest would be #include <bits/clang_meta.h>
or something similar to only load up large chunks of clang specific code
when compilining by that compiler), something else.

But sure, if you want a FTM around it (it would need to be the __glibcxx_*
one) to make it clear that it is a metafn added for non-reflection paper
with its own FTM, I can add it here and in std.cc.in.

> >      consteval bool is_signed_type(info);
> >      consteval bool is_unsigned_type(info);
> >      consteval bool is_bounded_array_type(info);
> > --- libstdc++-v3/src/c++23/std.cc.in.jj 2026-03-19 17:37:36.261809242 +0100
> > +++ libstdc++-v3/src/c++23/std.cc.in    2026-03-26 15:18:55.819857691 +0100
> > @@ -2251,6 +2251,7 @@ export namespace std
> >      using std::meta::is_final_type;
> >      using std::meta::is_aggregate_type;
> >      using std::meta::is_consteval_only_type;
> > +    using std::meta::is_structural_type;
> >      using std::meta::is_signed_type;
> >      using std::meta::is_unsigned_type;
> >      using std::meta::is_bounded_array_type;

	Jakub



More information about the Libstdc++ mailing list