fork(3) download
  1. #include <iostream>
  2. #include <utility>
  3.  
  4. template <typename F, typename...Args>
  5. void ForEach(F&& f, Args&&...args)
  6. {
  7. auto wrapper = [&](auto&& t){ f(std::forward<decltype(t)>(t)); return 0; };
  8. std::initializer_list<int>{ wrapper(std::forward<Args>(args))... };
  9. }
  10.  
  11. int main()
  12. {
  13. ForEach([](auto&& t){ std::cout << t; }, "Pi = ", 3.14);
  14. }
  15.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Pi = 3.14