On Sat, Nov 15, 2025 at 08:47:10AM +0000, Jonathan Wakely wrote:
> On Fri, 14 Nov 2025 at 19:37 -0500, Marek Polacek wrote:
> > This contains the libstdc++ bits (including <meta>).
> 
> Excliting! A few small changes requested below ...

Thanks, I've added changes to https://forge.sourceware.org/marek/gcc/pulls/109

> > +#ifdef _GLIBCXX_SYSHDR
> > +#pragma GCC system_header
> > +#endif
> > +
> > +#include <array>
> > +#include <initializer_list>
> > +#include <optional>
> > +#include <source_location>
> > +#include <span>
> > +#include <string>
> > +#include <string_view>
> > +#include <vector>
> 
> We could move all these headers after the #if below, so that we don't
> include anything if this is going to be an empty file. I don't think
> we're consistent about how we do that elsewhere though, so it's not
> important to change now.

The bits/version.h part needs to stay before the #if because
otherwise it would need to repeat the bits/version.h conditionals.

> > +
> > +#define __glibcxx_want_reflection
> > +#include <bits/version.h>
> > +
> > +#if __glibcxx_reflection >= 202506L // C++ >= 26 && __cpp_impl_reflection

> > +  namespace meta
> > +  {
> > +    using std::meta::info;
> > +    using std::meta::exception;
> > +    using std::meta::operators;
> > +    using enum std::meta::operators;
> 
> This is enough to export all the enumerators of this enum, right?

Yes.  Initially I had it commented out with TODO, but then tried
it on a small testcase:

module;
namespace N { enum class A { A1, A2, A3 }; using enum A; }
export module a1;
export namespace N { using N::A; using enum N::A; }

and

import a1;
int main ()
{
  N::A a = N::A::A1;
  N::A b = N::A2;
}

and it worked, so then did the above and it worked too for
import std;
std::meta::operators a = std::meta::op_plus_plus;
too.  Not added to testsuite because I thought we don't have a single
import std; test anywhere.
git grep shows now
gcc/testsuite/g++.dg/modules/stdns_b.C:import std;
gcc/testsuite/g++.dg/modules/using-22_b.C:import std;
Though with reflection it is more complicated because normally built
std module with just -std=c++26 won't export reflection stuff, one
needs to build the std module with -std=c++26 -freflection.

        Jakub

Reply via email to