[英]Indirection operator on const_iterator error
这段代码
std::ostream& operator<<( std::ostream& output, const Array& a) {
if (a.empty()) {
output << Structural::BEGIN_ARRAY << Structural::END_ARRAY;
} else {
output << Structural::BEGIN_ARRAY << std::endl;
OutputFilter<Indenter> indent(output.rdbuf());
output.rdbuf(&indent);
for (Array::const_iterator i = a.begin(); i != a.end(); ++i) {
if (i != a.begin()) {
output << Structural::VALUE_SEPARATOR << std::endl;
}
output << *i; // <--- Error is here...
}
output.rdbuf(indent.getDestination());
output << std::endl << Structural::END_ARRAY;
}
return output;
}
Apple LLVM编译器4.2中产生以下错误:
Indirection requires pointer operand ('Array::const_iterator' (aka 'int') invalid)
但是,如果我在LLVM GCC 4.2中编译此代码,它可以正常工作。 有任何想法吗?
看起来像Array::const_iterator
是int
类型。 您不能取消引用int
(与指针或STL迭代器相反)。
清理,重新启动XCode,清理,然后重建。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.