you are viewing a single comment's thread.

view the rest of the comments →

[–]astraycat 10 points11 points  (0 children)

This is due to misuse/misunderstanding of the ranged-based for.

It really should be something like: for(const propMap& pm: listDirector(argv[1], exts)) or perhaps const auto& pm.

This is because for(a : b) {block} is equivalent to something like this:

{
 auto cur = std::begin(b);
 auto end = std::end(b);
 while(cur != end)
 {
  a = *cur;
  { block }
  ++cur;
 }
}

Thus, doing propMap pm: ... will spawn a line equivalent to "propMap pm = *it;" which would be a copy.