我有以下模板方法,
template <class T> void Class::setData( vector<T> data ) { vector<T>::iterator it; }
我得到以下编译错误(XCode / gcc)
error: expected `;’ before ‘it’
我发现其他人有类似的问题here (read down to see it’s the same even though it starts out with a different issue),但他们似乎已通过更新Visual Studio解决.这让我觉得它是一个编译器问题而且它应该编译,这是正确的吗?通过索引从0到大小的迭代工作,但它不是我更喜欢实现此功能的方式.还有另一种方法吗?
谢谢