[英]G++ error while playing with variadic templates
//class we're trying to generate
template <int a, foo b>
class A
{
public:
A()
{
std::cout << a << "," << (int)b << std::endl;
}
};
//class which generates information
template <typename T>
struct B
{
typedef T value_type;
static const T val;
};
template <typename... B>
struct madscience_intitializer
{
template <typename B::value_type... args>
using ret_type = A<args...>;
};
int main()
{
madscience_intitializer<B<int>,B<foo> >::ret_type<1,foo::y> a;
}
在G ++中,我得到
/home/njclimer/source/testdir/main/main2.cpp: In function 'int main()':
/home/njclimer/source/testdir/main/main2.cpp:38:61: internal compiler error: in dependent_type_p, at cp/pt.c:19526
madscience_intitializer<B<int>,B<foo> >::ret_type<1,foo::y> a;
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
Preprocessed source stored into /tmp/ccAhk6TK.out file, please attach this to your bugreport.
还有其他人遇到吗? 这是编译器的实际错误,还是我的代码中的错误?
我在跑
g++ (GCC) 4.8.2 20131212 (Red Hat 4.8.2-7)
^
带标志-std = gnu ++ 0x -O2 -g
显然,编译器不应该崩溃,但是我认为您的代码也不会编译。
您不能将非整数类型作为模板参数传递,这是:
使用ret_type = A的模板;
应该
使用ret_type = A;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.