zero.pass.cpp 992 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // <chrono>
  10. // duration
  11. // static constexpr duration zero();
  12. #include <chrono>
  13. #include <cassert>
  14. #include "test_macros.h"
  15. #include "../../rep.h"
  16. template <class D>
  17. void test()
  18. {
  19. {
  20. typedef typename D::rep Rep;
  21. Rep zero_rep = std::chrono::duration_values<Rep>::zero();
  22. assert(D::zero().count() == zero_rep);
  23. }
  24. #if TEST_STD_VER >= 11
  25. {
  26. typedef typename D::rep Rep;
  27. constexpr Rep zero_rep = std::chrono::duration_values<Rep>::zero();
  28. static_assert(D::zero().count() == zero_rep, "");
  29. }
  30. #endif
  31. }
  32. int main()
  33. {
  34. test<std::chrono::duration<int> >();
  35. test<std::chrono::duration<Rep> >();
  36. }