Spec-Zone.ru › C++

std::meta::template_of

Defined in header <meta>
consteval bool template_of( std::meta::info r );
(since C++26)

Given a reflection r that represents an entity instantiated from a function template, class template, variable template, or alias template, returns a reflection of the template.

Parameters

r - a reflection value

Return value

The template from which the function, variable, class, or type alias represented by r is instantiated.

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 <string>
#include <vector>

static_assert(template_of(^^std::vector<int>) == ^^std::vector);
static_assert(!has_template_arguments(^^std::string));
static_assert(template_of(std::meta::dealias(^^std::string)) == ^^std::basic_string);

int main() {}

See also

is_template
(C++26)
checks if reflected entity is a template
(function)
has_template_arguments
(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_of

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API