SOFA API  f37305c1
Open source framework for multi-physics simuation
sofa::type::trait::is_specialization_of< T, Template > Struct Template Reference

#include <is_specialization_of.h>

Trait to check if a type T is a specialization of a given template class Template. More...

Inheritance diagram for sofa::type::trait::is_specialization_of< T, Template >:

Detailed Description

template<typename T, template< typename... > class Template>
struct sofa::type::trait::is_specialization_of< T, Template >

Trait to check if a type T is a specialization of a given template class Template.

The is_specialization_of trait is a compile-time check to determine if a type T is a specialization of a particular template class Template. This trait works with template classes that accept any number of template parameters.

Example usage:

template <typename T1, typename T2>
class Foo {};
template <typename T>
class Bar {};
class Baz {};
static_assert(is_specialization_of<Foo<int, double>, Foo>::value, "Foo<int, double> is a Foo!");
static_assert(is_specialization_of<Bar<int>, Bar>::value, "Bar<int> is a Bar!");
static_assert(!is_specialization_of<int, Foo>::value, "int is not a Foo specialization.");
static_assert(!is_specialization_of<Baz, Bar>::value, "Baz is not a Bar specialization.");
Template Parameters
TThe type to be checked. This is the type that you want to determine whether it is a specialization of Template.
TemplateThe template class to check against. This can be any template class that accepts one or more template parameters.