Consider an alias template like the A in the code below. Now let B be an alias template of A.
In the code below these class templates are used as template arguments for a struct C which is only specialized for one typename (A). clang -std=c++11 exists with error: implicit instantiation of undefined template 'C<B>' indicating that another specialization for B is needed.
template<int N>
using A = int;
template<int N>
using B = A<N>;
template<template<int> class I>
struct C;
template<>
struct C<A> {};
int main() {
C<A> c;
C<B> d; // clang error: implicit instantiation
}
Why (if even) is it that - despite not allowing specializations of aliases - A and B are treated as different class templates? Is there a workaround allowing me to rename a lengthy template without incurring this problem?
Aucun commentaire:
Enregistrer un commentaire