テンプレート エイリアスで引数の型を指定したテンプレート クラスのテンプレート メソッドを宣言すると、コンパイル エラーが発生します。テンプレート クラスをクラスに変更すると、コンパイルされます。テンプレート エイリアスを実際の型 (ここではTempl<bool>
) に置き換えると、それもコンパイルされます。テンプレート クラスで、引数の型がテンプレート エイリアスの場合、なぜ機能しないのですか?
コンパイラは gcc バージョン 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>;