◐ Shell
clean mode source ↗

std::meta::parameters_of - cppreference.com

From cppreference.com

consteval std::vector<std::meta::info> parameters_of( std::meta::info r );
(since C++26)

If r represents a function, returns a vector containing reflections of its function parameters. If r represents a function type, returns a vector containing reflections of its parameter types.

In both cases, the elements of the vector are in the order in which the parameters appear.

Parameters

r - a reflection that represents a function or function type

Return value

A std::vector of reflections.

Exceptions

Throws std::meta::exception if r does not represent a function or function type.

Notes

A reflection of function parameter can be queried for the parameter's type, identifier (if any), and list of annotations. To get the value of the parameter variable within the function body, see std::meta::variable_of.

The type of a parameter (as returned by std::meta::type_of) is cv-unqualified, which may differ from the type of the corresponding variable:

void f(const int x)
{
    constexpr auto rp = std::meta::parameters_of(^^f)[0];
    static_assert(std::meta::type_of(rp) == ^^int);

    constexpr auto rv = std::meta::variable_of(rp);
    static_assert(&[:rv:] == &x);
    static_assert(std::meta::type_of(rv) == ^^const int);
}

Example

See also

obtains the variable of the reflected function parameter in the function definition
(function) [edit]
obtains the return type of the reflected function
(function) [edit]