fork download
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4.  
  5.  
  6. struct WithLogging {};
  7. struct WithoutLogging {};
  8.  
  9.  
  10. auto
  11. function(WithLogging)
  12. {
  13. std::cout << "Entered function" << std::endl;
  14. std::srand(std::time(0));
  15. auto result = std::rand();
  16. std::cout << "result is: " << result << std::endl;
  17. return result;
  18. }
  19.  
  20.  
  21. auto
  22. function(WithoutLogging)
  23. {
  24. return std::rand();
  25. }
  26.  
  27.  
  28. int
  29. main()
  30. {
  31. auto a = function(WithLogging{});
  32. return 0;
  33. }
  34.  
  35.  
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
Entered function
result is: 1461651947