fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. #define ForEach(container) for(auto &element : container) element
  5.  
  6. struct Object
  7. {
  8. void DoSomething(int x, std::string str) { std::cout << "x = " << x << ", \"" << str << "\"" << std::endl; }
  9. };
  10.  
  11. int main()
  12. {
  13. std::vector<Object> arrayOfObjects(5);
  14.  
  15. ForEach(arrayOfObjects).DoSomething(17, "Test");
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
x = 17, "Test"
x = 17, "Test"
x = 17, "Test"
x = 17, "Test"
x = 17, "Test"