Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Row_event_iterator unusable in for loop #2

Open
andoryu- opened this issue Oct 17, 2017 · 0 comments
Open

Row_event_iterator unusable in for loop #2

andoryu- opened this issue Oct 17, 2017 · 0 comments

Comments

@andoryu-
Copy link

andoryu- commented Oct 17, 2017

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());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant