fork download
  1. #include <chrono>
  2. #include <ratio>
  3. #include <stdexcept>
  4. #include <iostream>
  5.  
  6. int main() {
  7. try {
  8. // Uncomment any of the following checks for a particular resolution in question
  9. if(std::ratio_less_equal<std::nano,std::chrono::system_clock::period>::value) {
  10. // if(std::ratio_less_equal<std::micro,std::chrono::system_clock::period>::value) {
  11. // if(std::ratio_less_equal<std::milli,std::chrono::system_clock::period>::value) {
  12. // if(std::ratio_less_equal<std::centi, std::chrono::system_clock::period>::value) {
  13. throw std::runtime_error
  14. ("Clock doesn't meet the actual resolution requirements.");
  15. }
  16. }
  17. catch(const std::exception& ex) {
  18. std::cout << "Exception: '" << ex.what() << "'" << std::endl;
  19. }
  20. std::cout << "The curently available resolution is: "
  21. << std::chrono::system_clock::period::num << "/"
  22. << std::chrono::system_clock::period::den
  23. << " seconds" << std::endl;
  24. }
  25.  
Success #stdin #stdout 0s 3272KB
stdin
Standard input is empty
stdout
Exception: 'Clock doesn't meet the actual resolution requirements.'
The curently available resolution is: 1/1000000000 seconds