gpt4 book ai didi

c++ - const_iterator 错误的间接运算符

转载 作者:行者123 更新时间:2023-11-28 03:17:01 25 4
gpt4 key购买 nike

这段代码

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

最佳答案

清理,重启 XCode,清理,然后重建。

关于c++ - const_iterator 错误的间接运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16574133/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com