0

这段代码

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

4

2 回答 2

1

看起来Array::const_iterator是 type int。您不能取消引用 an int(与指针或 STL 迭代器相反)。

于 2013-05-15T20:24:20.063 回答
1

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

于 2013-05-16T20:29:58.900 回答