Skip to content

Row_event_iterator unusable in for loop #2

Description

@andoryu-

EXAMPLE:

Row_event_set::iterator rows_itr = rowset.begin();
for (; rows_itr != rowset.end(); ++rows_itr) {
    // never reach here
    Row_of_fields rof(*rows_itr);
    std::cout << "\ncurrent row change:";
    //...
}

CAUSE:
Row_event_set::begin() & Row_event_set::end() returns nontrivially constructed and trivially constructed Row_event_iterator respectively.
However nontrivially constructed Row_event_iterator compares the same as trivially constructed one, making the first for loop exit directly as inequality test fails.
WORKAROUND:
Row_event_iterator is usable in do..while loop, as the first star operator call modifies its internal state and make it compare different from trivially constructed one.

Row_event_set::iterator rows_itr = rowset.begin();
do {
    Row_of_fields rof(*rows_itr);
    std::cout << "\ncurrent row change:";
    //...
} while (++rows_itr != rowset.end());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions