fork download
  1. #include <cstdint>
  2.  
  3. constexpr uint32_t ticksPerSecond = 100000;
  4.  
  5. struct timemeasure {
  6. constexpr explicit timemeasure(uint64_t c) : ticks(c) { }
  7. uint64_t ticks;
  8. constexpr timemeasure() : ticks(0) { }
  9. };
  10.  
  11. struct time : timemeasure {
  12. static volatile time now;
  13.  
  14. constexpr time() : timemeasure() { }
  15. explicit time(uint64_t c) : timemeasure(c) { }
  16.  
  17. // Needed for `x = time::now`
  18. explicit time(const volatile time &t) : timemeasure(t.ticks) { }
  19. time& operator=(volatile time t) { ticks = t.ticks; return *this; }
  20. };
  21.  
  22. inline time foo(const time& t) { return time(t.ticks + 1); }
  23.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘time foo(const time&)’:
prog.cpp:22:57: error: no matching function for call to ‘time::time(time)’
prog.cpp:22:57: note: candidate is:
prog.cpp:14:15: note: constexpr time::time()
prog.cpp:14:15: note:   candidate expects 0 arguments, 1 provided
stdout
Standard output is empty