Question Details

No question body available.

Tags

c++ c++26

Answers (1)

Accepted Answer Available
Accepted Answer
February 7, 2026 Score: 4 Rep: 313,119 Quality: Expert Completeness: 60%

In this loop:

template for (constexpr std::meta::info MemberInfo : / non-static data members /) { using MemberType = [:MemberInfo:];

MemberInfo is a reflection which represents a non-static data member - it can only be spliced in certain contexts. Like obj.[:MemberInfo:] or &[:MemberInfo:]. It does not represent a type, which is what you need on the right-hand side of an alias declaration.

Hopefully a production implementation will provide a clear error message in this context, since it certainly can, but the one you're using is an experimental one. That will all get better over time.

What you need is a type — specifically a reflection representing a type. That is:

using MemberType = [: type_of(MemberInfo) :]; // ^~~~~~~

With that change, your code compiles.


Conceptually, you can think of this as the category error of writing this:

using MemberType = Position::X; // error: not a type

instead of this:

using MemberType = decltype(Position::X); // ok