clock_name.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // stopclock_perf.cpp ---------------------------------------------------//
  2. // Copyright 2009 Vicente J. Botet Escriba
  3. // Copyright 2009 Howard Hinnant
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // See http://www.boost.org/LICENSE_1_0.txt
  6. // See http://www.boost.org/libs/chrono for documentation.
  7. #ifndef BOOST_CHRONO_CLOCK_NAME_HPP
  8. #define BOOST_CHRONO_CLOCK_NAME_HPP
  9. #include <boost/chrono/chrono.hpp>
  10. #include <boost/type_traits/is_same.hpp>
  11. template <typename Clock,
  12. bool = boost::is_same<Clock, boost::chrono::system_clock>::value,
  13. #ifdef BOOST_CHRONO_HAS_CLOCK_STEADY
  14. bool = boost::is_same<Clock, boost::chrono::steady_clock>::value,
  15. #else
  16. bool = false,
  17. #endif
  18. bool = boost::is_same<Clock, boost::chrono::high_resolution_clock>::value
  19. >
  20. struct name;
  21. template <typename Clock>
  22. struct name<Clock, false, false, false> {
  23. static const char* apply() { return "unknown clock";}
  24. };
  25. template <typename Clock>
  26. struct name<Clock, true, false, false> {
  27. static const char* apply() { return "system_clock";}
  28. };
  29. template <typename Clock>
  30. struct name<Clock, false, true, false> {
  31. static const char* apply() { return "steady_clock";}
  32. };
  33. template <typename Clock>
  34. struct name<Clock, false, false, true> {
  35. static const char* apply() { return "high_resolution_clock";}
  36. };
  37. template <typename Clock>
  38. struct name<Clock, false, true, true> {
  39. static const char* apply() { return "steady_clock and high_resolution_clock";}
  40. };
  41. template <typename Clock>
  42. struct name<Clock, true, false, true> {
  43. static const char* apply() { return "system_clock and high_resolution_clock";}
  44. };
  45. template <typename Clock>
  46. struct name<Clock, true, true, false> {
  47. static const char* apply() { return "system_clock and steady_clock";}
  48. };
  49. template <typename Clock>
  50. struct name<Clock, true, true, true> {
  51. static const char* apply() { return "system_clock, steady_clock and high_resolution_clock";}
  52. };
  53. #endif