Namespaces
Variants

std::meta::info

From cppreference.com
< cpp | meta
 
 
 
Reflection library
 
Reflection types and queries
Type properties
Type property queries
 
Defined in header <meta>
using info = decltype(^^::);
(since C++26)

std::meta::info is the type of reflection values. It is a distinct fundamental type. There exists a unique null reflection; every other reflection represents:

For the purpose of argument-dependent lookup, the namespace std::meta is an associated namespace of this type.

Values of type std::meta::info are equality-comparable. Note that a reflection of a type alias compares unequal to a reflection of the aliased type.

Example

#include <meta>
#include <print>

// Obtain reflection object
constexpr std::meta::info r{^^int};

// Define a variable from reflection object “r”
constexpr typename [:r:] x{42};
static_assert(x == 42);

// std::meta::info objects are equality-comparable
static_assert(^^int == ^^int);
static_assert(^^int != ^^char);

// Reflection of type alias compares unequal to a reflection of the aliased type
using Int = int;
using INT = Int;
static_assert(^^int != ^^INT);

// Dealiasing can be used to reach to underlying type reflection
static_assert(^^int == std::meta::dealias(^^INT));

int main()
{
    std::print("{}\n", std::meta::display_string_of(^^int));
    std::print("{}\n", std::meta::display_string_of(dealias(^^INT))); // ADL
    std::print("{}\n", std::meta::display_string_of(^^Int));
    std::print("{}\n", std::meta::display_string_of(std::meta::info()));
}

Possible output:

int
int
Int {aka int}
<null reflection>

See also