close
Namespaces
Variants

std::meta::parameters_of

From cppreference.com
< cpp | meta
 
 
Metaprogramming library
Type traits
Type categories
(C++11)
(C++11)(DR*)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11) 
(C++11)
(C++11)
Type properties
(C++11)
(C++11)
(C++14)
(C++11)(deprecated in C++26)
(C++11)(until C++20*)
(C++11)(deprecated in C++20)
(C++11)
Type trait constants
Metafunctions
(C++17)
Supported operations
Relationships and property queries
Type modifications
(C++11)(C++11)(C++11)
Type transformations
(C++11)(deprecated in C++23)
(C++11)(deprecated in C++23)
(C++11)
(C++11)(until C++20*)(C++17)

(C++11)
(C++17)
Compile-time rational arithmetic
Compile-time integer sequences
 
Defined in header <meta>
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