Namespaces
Variants

std::meta::template_arguments_of

From cppreference.com
< cpp | meta
 
 
 
Reflection library
 
Reflection types and queries
Reflection queries
Reflection layout queries
Type properties
Type property queries
 
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 A is a type or type alias, R represents the type.
  • Otherwise, if A is a class template, variable template, concept, or alias template, R represents the template.
  • Otherwise (A is a non-type template argument), let P be the corresponding template parameter.
  • If P has reference type, R represents the object or function referred to by A.
  • If P has class type, R represents the corresponding template parameter object.
  • Otherwise, R represents the value of A.

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

checks if reflected entity is a template
(function) [edit]
checks if reflected entity is produced by substituting template arguments into a template
(function) [edit]
Morty Proxy This is a proxified and sanitized view of the page, visit original site.