rep.pass.cpp 1006 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // <chrono>
  9. // duration
  10. // template <class Rep2>
  11. // explicit duration(const Rep2& r);
  12. #include <chrono>
  13. #include <cassert>
  14. #include "test_macros.h"
  15. #include "../../rep.h"
  16. template <class D, class R>
  17. void
  18. test(R r)
  19. {
  20. D d(r);
  21. assert(d.count() == r);
  22. #if TEST_STD_VER >= 11
  23. constexpr D d2(R(2));
  24. static_assert(d2.count() == 2, "");
  25. #endif
  26. }
  27. int main(int, char**)
  28. {
  29. test<std::chrono::duration<int> >(5);
  30. test<std::chrono::duration<int, std::ratio<3, 2> > >(5);
  31. test<std::chrono::duration<Rep, std::ratio<3, 2> > >(Rep(3));
  32. test<std::chrono::duration<double, std::ratio<2, 3> > >(5.5);
  33. return 0;
  34. }