convert_exact.pass.cpp 938 B

123456789101112131415161718192021222324252627282930313233343536373839
  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, class Period2>
  11. // duration(const duration<Rep2, Period2>& d);
  12. // exact conversions allowed for integral reps
  13. #include <chrono>
  14. #include <cassert>
  15. #include "test_macros.h"
  16. int main(int, char**)
  17. {
  18. {
  19. std::chrono::milliseconds ms(1);
  20. std::chrono::microseconds us = ms;
  21. assert(us.count() == 1000);
  22. }
  23. #if TEST_STD_VER >= 11
  24. {
  25. constexpr std::chrono::milliseconds ms(1);
  26. constexpr std::chrono::microseconds us = ms;
  27. static_assert(us.count() == 1000, "");
  28. }
  29. #endif
  30. return 0;
  31. }