我编写了一个小型库,它使用了大量的C ++ 11元编程技术和CRTP,它与g ++ 4.7.2编译得很好。
现在,我尝试用Intel icpc 13.0.0.079编译它,它会产生数百个错误。所以我试着一个接一个地隔离问题。
所以,首先,考虑一下这个代码,它在g ++ 4.7.2下编译没有问题
#include <iostream>
template<template<typename> class Crtp, typename Type>
struct Base {};
template<typename Type>
struct Derived : public Base<Derived, Type>
{
Derived(): Base<Derived, Type>() {;}
};
int main()
{
Derived<int> x;
return 0;
}
icpc和clang都无法编译此代码:
test_crtp.cpp(26): error: type "Derived<Type>::Derived" is not a class template
Derived(): Base<Derived, Type>() {;}
^
test_crtp.cpp(26): error: "Base" is not a nonstatic data member or base class of class "Derived<int>"
Derived(): Base<Derived, Type>() {;}
^
detected during instantiation of "Derived<Type>::Derived() [with Type=int]" at line 31
compilation aborted for test_crtp.cpp (code 2)
那么它是英特尔和铿锵,还是用g ++中的错误?如果它是英特尔和铿锵的,你认为它将在未来的版本中得到解决吗?