【发布时间】:2013-05-08 01:28:38
【问题描述】:
当我声明参数类型由模板别名指定的模板类的模板方法时,我收到编译错误。如果我将模板类更改为一个类,它会编译。如果我将模板别名替换为实际类型(此处为 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>;
【问题讨论】:
标签: c++ templates gcc c++11 template-aliases