Оператор косвенности при ошибке const_iterator

Этот код

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, он будет работать нормально. Любые идеи?


person Nathan Wehr    schedule 15.05.2013    source источник
comment
Какое определение для Array?   -  person Yakk - Adam Nevraumont    schedule 16.05.2013
comment
typedef std::deque‹Value› Массив;   -  person Nathan Wehr    schedule 16.05.2013


Ответы (2)


Очистите, перезапустите XCode, очистите, затем перестройте.

person Kevin H. Patterson    schedule 16.05.2013
comment
Мне также пришлось выбрать диалект языка по умолчанию и стандартную библиотеку по умолчанию (если используется компилятор по умолчанию). - person Nathan Wehr; 17.05.2013

Похоже, что Array::const_iterator относится к типу int. Вы не можете разыменовать int (в отличие от указателя или итератора STL).

person Marc Claesen    schedule 15.05.2013