I ran to some problems with c++11 alias templates. As you can see below, I want to create an alias to A::B from class C. Before instantiation is made the compiler (gcc 6.1) cannot assert that V has a member type B, therefore giving the error:
error: expected ‘;’ before ‘<’ token
template<typename ValueT> using B = typename V::B<ValueT>;
Does not his go against the usual way templates are dealt with in C++, that is assuming that the template type provides all necessary functionalities until proven otherwise by an instantiation?
template<typename T> class A{
T a;
public:
template <typename ValueT> class B {
ValueT b;
};
};
template <typename V = A<int>> class C {
public:
template<typename ValueT> using B = typename V::B<ValueT>;
};
Aucun commentaire:
Enregistrer un commentaire