Thursday, 15 March 2012

c++ - Iterate multiple maps with single loop -



c++ - Iterate multiple maps with single loop -

i trying iterate 2 maps 1 loop. works fine 1 map. when add together sec map(see code below) gives me error "cannot deduce 'auto' type"

both variables of same type.

what best way iterate 2 maps.

( auto& insertentry = insertedinstances.begin(), auto& updateentry = toupdateinstances.begin(); insertentry != insertedinstances.end(); insertentry++,updateentry++ ) { //do }

it equivalent

for(int i=0, j=0; i<10;i++) { //do }

so remove auto&

for ( auto insertentry = insertedinstances.begin(), updateentry = toupdateinstances.begin(); insertentry != insertedinstances.end(); ++insertentry , ++updateentry //pre-increment might produce improve code ) { //do }

you can not utilize same type twice comma operator.

c++ stl

No comments:

Post a Comment