Range based for loop on temporary

Viewed 3043

Consider

std::vector<abc> fun() { return a;}
..
..

for( auto itr = fun().begin(); itr< fun().end(); ++itr) //A
 {
  ..
 }
for( auto & itr : fun()) //B
 {
 }

Are both loops here are unsafe? (iterators not being compatible?)

1 Answers
Related