在编译TNT 库,即 Template Numerical Toolkit 时,XCode 会引发此错误:
tnt/tnt_array1d_utils.h:33:9: Expected unqualified-id
受影响的代码片段:
namespace TNT
{
template <class T>
std::ostream& operator<<(std::ostream &s, const Array1D<T> &A)
{
int N=A.dim1(); /// <--- this line 33:9
#ifdef TNT_DEBUG
s << "addr: " << (void *) &A[0] << "\n";
#endif
s << N << "\n";
for (int j=0; j<N; j++)
{
s << A[j] << "\n";
}
s << "\n";
return s;
}
整个 TNT 标头在这里
尝试添加分号“;” 到每个模板的末尾都不起作用:
namespace TNT
{
template <class T>
std::ostream& operator<<(std::ostream &s, const Array3D<T> &A)
{
int M=A.dim1();
int N=A.dim2();
int K=A.dim3();
s << M << " " << N << " " << K << "\n";
for (int i=0; i<M; i++)
{
for (int j=0; j<N; j++)
{
for (int k=0; k<K; k++)
s << A[i][j][k] << " ";
s << "\n";
}
s << "\n";
}
return s;
};
我在用着
XCode5 GNU++11 libC++
也试过 libstdc++