这段代码
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 中编译此代码,它就可以正常工作。有任何想法吗?