Class template alias

Consider an alias template, such as Ain the code below. Now let it be Ban alias template A.

In the code below, these patterns are used as template arguments for a structure Cthat specializes in only one name ( A). clang -std=c++11exists with error: implicit instantiation of undefined template 'C<B>'indicating that another specialization is required for B.

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 the fact that specialization of aliases is not allowed - Aand Bare treated as different class templates? Is there a workaround that allows me to rename a long template without causing this problem?

+4
1

CWG № 1286, :

template<template<class> class TT> struct X { };
template<class> struct Y { };
template<class T> using Z = Y<T>;
X<Y> y;
X<Z> z;

, y z .

, , clang . [temp.alias] :

, - .

, A<X> B<X> ( X!), , A B. - , B A . , , .

+4

Source: https://habr.com/ru/post/1608557/


All Articles