2

trying to iterate a multi_index struct in my contract. I can iterate it brute force like this:

            studentIndex students(_self, _self);
            auto itr = students.upper_bound(0);
            print("fn:",(*itr).ssn);
            print("res:",(*itr).result);
            print("equal?", itr == students.end());

            auto itr1 = itr++;
            print("fn:",(*itr1).ssn);
            print("res:",(*itr1).result);
            print("equal?", itr1 == students.end());

            auto itr2 = itr1++;
            print("fn:",(*itr2).ssn);
            print("res:",(*itr2).result);
            print("equal?", itr2 == students.end());

            auto itr3 = itr2++;
            print("fn:",(*itr3).ssn);
            print("res:",(*itr3).result);
            print("equal?", itr3 == students.end());

However, when I try to iterate it like this it seems to be caught in an infinite loop.

     for (auto itr = students.begin(); itr != students.end(); itr++) {
                print("fn:",(*itr).ssn);
                print("res:",(*itr).result);
            }
1

Apparently this was an issue and it's resolved in master: https://github.com/EOSIO/eos/issues/2787

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.