Skip to content

Conversation

@Tsche
Copy link

@Tsche Tsche commented Jul 17, 2025

is_reflection_type currently compares a reflection against the type alias std::meta::info instead of the aliased reflection type. We need to dealias it to check against the aliased type instead of the alias itself.

Consider the following example:

static_assert(is_reflection_type(^^std::meta::info)); // passes, we are comparing aliases
static_assert(not is_reflection_type(type_of(reflect_constant(^^int)))); // oops
static_assert(not is_reflection_type(^^decltype(^^int))); // oops

Dealiasing both the reflection r and std::meta::info makes all these assertions pass as expected:

consteval auto is_reflection_type(info r) -> bool {
  return dealias(r) == dealias(^^info);
}

// correct behavior: 
static_assert(is_reflection_type(^^std::meta::info));
static_assert(is_reflection_type(type_of(reflect_constant(^^int))));
static_assert(is_reflection_type(^^decltype(^^int)));

Run on Compiler Explorer

std::meta::info is an alias. We need to dealias it to check against the aliased type instead of the alias itself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant