SFINAE and enable_if<>¶
See:
Modern C++, Item 27 by Scott Meyers
Type alias, alias template¶
The keyword using
is a another way of creating a typedef, an alias of a type.
template<typename T> class Vector {
public:
using value_type = T; // Same as: typedef T value_type;
//...
};
Vector<int> v;
Vector<int>::value_type x = 10; // x is of type int.
using value_type = T;
is equivalent to typedef T value_type;
. There is also a form of using for use with templates. It can help to create, for example, more readable templates.
template<class T> struct Alloc {
//...
};
template<class T> using Vec = vector<T, Alloc<T>>; // type-id is vector<T, Alloc<T>>
Vec<int> v; // Vec<int> is the same as vector<int, Alloc<int>>
Vec
is an alias template, and Vec<int>
results in substituting int for T in template<typename T> vector<T, Alloc<T>>
. Thus, Vec<int>
is just an alias for vector<T, Alloc<T>>
.
Todo
Finish later.