alias of class template

前端 未结 1 1906
春和景丽
春和景丽 2021-01-06 01:53

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 te

相关标签:
1条回答
  • 2021-01-06 02:24

    This is CWG issue #1286, which deals with this example:

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

    questioning whether or not y and z have the same type.

    Basically, according to the Standard, clang is correct in rejecting the code. All [temp.alias] tells us is:

    When a template-id refers to the specialization of an alias template, it is equivalent to the associated type obtained by substitution of its template-arguments for the template-parameters in the type-id of the alias template.

    So while A<X> is equivalent to B<X> (for all X!), there is no wording that A is equivalent to B. But on some level that doesn't really make any sense since B and A should be equivalent. There is a proposed resolution that would make them so, but it has not yet been approved.

    0 讨论(0)
提交回复
热议问题