An Alias Template Specialization
Get an overview of how an alias template specialization should name a type.
We'll cover the following
Create a template alias
To show that a concept can be used to make sure that an alias template specialization names a type, let’s create a template alias, ValueTypeOf
:
template<typename T> using ValueTypeOf = T::value_type;
Let’s use it in the concept TypeRequirement
:
template<typename T>
concept TypeRequirement = requires {
typename ValueTypeOf<T>;
};
Use the defined constraints
Let’s declare two variables with the constraint that we just defined, a vector of int
values and an int
.
Get hands-on with 1200+ tech skills courses.