Advertisement
Guest User

Untitled

a guest
Apr 25th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. std::multimap<int, std::pair<std::function<...>, bool>> target_subs{};
  2.  
  3. //...
  4. // various insertions and deletions...
  5. //...
  6.  
  7. for (auto sub = begin(target_subs); sub != end(target_subs); ) {
  8. if (sub->second.second) {
  9. (sub++)->second.first(evt);
  10.  
  11. } else {
  12. sub->second.first(evt);
  13. ++sub;
  14. }
  15. }
  16.  
  17. size_t valid_passes{0};
  18.  
  19. for (auto sub = begin(target_subs); sub != end(target_subs); ) {
  20. if (sub->second.second) {
  21. (sub++)->second.first(evt);
  22. if (target_subs.size() < valid_passes) { break; } // Not very useful...
  23. // possible to erase all elements and insert the same number back in
  24.  
  25. } else {
  26. sub->second.first(evt);
  27. ++sub;
  28. }
  29.  
  30. ++valid_passes;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement