fork(1) download
  1. #include <iostream>
  2.  
  3. struct execute {
  4. const unsigned long long n;
  5.  
  6. template<typename Callable>
  7. void operator() (Callable what) {
  8. for (auto i = 0; i < n; i++)
  9. what();
  10. }
  11. };
  12.  
  13. execute operator"" _times(unsigned long long n) {
  14. return execute{n};
  15. }
  16.  
  17. int main() {
  18. 3_times([]{
  19. std::cout << "bla" << std::endl;
  20. });
  21.  
  22. auto twice = 2_times;
  23.  
  24. twice([]{
  25. std::cout << "blup" << std::endl;
  26. });
  27. }
  28.  
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
bla
bla
bla
blup
blup