[英]Indirection operator on const_iterator error
This code 这段代码
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;
}
produces the following error in Apple LLVM compiler 4.2: Apple LLVM编译器4.2中产生以下错误:
Indirection requires pointer operand ('Array::const_iterator' (aka 'int') invalid)
However, if I compile this code in LLVM GCC 4.2, it works fine. 但是,如果我在LLVM GCC 4.2中编译此代码,它可以正常工作。 Any ideas? 有任何想法吗?
It looks like Array::const_iterator
is of type int
. 看起来像Array::const_iterator
是int
类型。 You cannot dereference an int
(in contrast to a pointer or STL iterator). 您不能取消引用int
(与指针或STL迭代器相反)。
清理,重新启动XCode,清理,然后重建。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.