foreach - Why does c++ range based for loop calls destructor at every iteration? -


i using range based loop read (and parse) file using iterator. loop looks this:

for (auto record : reader) {     if (even)         record.reverse_complement();     cout << record.write();     = !even; }  

i have added outputs constructor , destructors of iterator , looks destructor beign called on iterator returned end() in every iteration of loop.

calling fq_iter full constructor  calling fq_iter default constructor  calling fq_iter destructor on 0 calling fq_iter destructor on 0 calling fq_iter destructor on 0 calling fq_iter destructor on 0 calling fq_iter destructor on 0 calling fq_iter destructor on 0 calling fq_iter destructor on 0 calling fq_reader destructor on 0 

these classes using parse , iterate on file, idea why destructor being called @ every iteration? (other that, produces correct output).

according section 6.5.4 of c++ standard, compiler not supposed that. instead, it's supposed cache end iterator in unnameable local.

does operator!= make copy of iterator (accidental pass-by-value)?


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -