std::meta::template_arguments_of
Defined in header <meta> | ||
|---|---|---|
consteval std::vector<std::meta::info> template_arguments_of( std::meta::info r ); | (since C++26) |
Returns a vector containing reflections of the template arguments used to instantiate the entity represented by r, in the order in which they appear in the template argument list.
For a given template argument A, the corresponding reflection value R is determined as follows:
- If
Ais a type or type alias,Rrepresents the type. - Otherwise, if
Ais a class template, variable template, concept, or alias template,Rrepresents the template. - Otherwise (
Ais a non-type template argument), letPbe the corresponding template parameter. - If
Phas reference type,Rrepresents the object or function referred to byA. - If
Phas class type,Rrepresents the corresponding template parameter object. - Otherwise,
Rrepresents the value ofA.
Parameters
| r | - | a reflection value |
Return value
A vector containing reflections of the template arguments of what r represents.
Exceptions
Throws std::meta::exception unless std::meta::has_template_arguments(r) is true (i.e. r represents an entity instantiated from a template).
Example
#include <meta>
#include <type_traits>
static_assert(template_arguments_of(^^std::void_t<int>)[0] == ^^int);
static_assert(template_arguments_of(^^std::enable_if<true>).size() == 2);
static_assert(template_arguments_of(^^std::enable_if<true>)[0] ==
std::meta::reflect_constant(true));
static_assert(template_arguments_of(^^std::enable_if<true>)[1] == ^^void);
int main() {}
See also
|
(C++26) | checks if reflected entity is a template (function) |
|
(C++26) | checks if reflected entity is produced by substituting template arguments into a template (function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/meta/template_arguments_of