當編譯TNT library即模板數值工具包,XCode中引發此錯誤:的XCode預期不合格-ID TNT(模板數值工具包)
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頭here
試圖添加一個分號「;」每個模板的結尾沒有工作:
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++
我在某處找到了有關添加機箱和;問題在C++模板上。我做到了,但沒有結果。 – loretoparisi