Im playing around with reflection (GCC16) and I ran into the following problem:
When using std::meta::define_aggregateto complete an annotated nested class, the annotation is removed, iff the enclosing class is templated.
Below is a minimal reproducible example (Godbolt link).
I would expect both assertions to succeed, but they don't. There is also GCC PR124399, which addresses a related problem, but I'm not sure if this is the same underlying problem. Its not the same bug, since it's fixed.
Is this a bug, or am I overlooking/misunderstanding some template instantiation rules?
#include <meta>
// Works: ordinary forward declaration.
struct [[=42]] Ordinary;
static_assert(std::meta::annotations_of(^^Ordinary).size() == 1);
// Fails: forward declaration inside a class template.
template <typename T>
struct Outer {
struct [[=42]] Inner;
};
static_assert(sizeof(Outer<int>) > 0);
static_assert(std::meta::annotations_of(^^Outer<int>::Inner).size() == 1);
Context: I'm experimenting with rust-like derive(debug) functionality using annotations, combined with structural type transformations (similar to AoS to SoA). I originally encountered this while trying to propagate annotations to a generated type, before reducing it to the example above.