Template alias does not work in template template argument

When I declare a template method of a template class whose argument type is specified by a template alias, I get a compilation error. If I change the template class to a class, it compiles. If I replaced the template alias with the actual type (here Templ<bool> ), it will compile too. Why does this not work when it is a template class and the argument type is an alias of the template?

The compiler is gcc version 4.8.0 (Ubuntu / Linaro 4.8.0-2ubuntu2 ~ 12.04).

 template <template <typename T> class Templ> using Bool = Templ<bool>; template <typename T> class Foo { private: public: template<template<typename U> class Templ> void method(Bool<Templ> boolTempl); }; template <typename T> template <template <typename U> class Templ> void Foo<T>::method(Bool<Templ> boolTempl) { } int main() { Foo<char> foo; return 0; } g++ templTest12.C -o templTest12 -std=c++11 templTest12.C: In substitution of `template<template<class T> class Templ> using Bool = Templ<bool> [with Templ = Templ]': templTest12.C:17:6: required from `class Foo<char>' templTest12.C:30:12: required from here templTest12.C:2:25: error: `template<class U> class Templ' is not a template using Bool = Templ<bool>; 
+4
source share
1 answer

This seems to be a regression in gcc 4.8.0 because gcc 4.7.2 compiles both versions without errors. Standard 14.1 / 2 specifically states that

There is no semantic difference between the class and typename in the template parameters.

+3
source

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


All Articles