op_++int.pass.cpp 944 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. // constexpr duration operator++(int); // constexpr in C++17
  11. #include <chrono>
  12. #include <cassert>
  13. #include "test_macros.h"
  14. #if TEST_STD_VER > 14
  15. constexpr bool test_constexpr()
  16. {
  17. std::chrono::hours h1(3);
  18. std::chrono::hours h2 = h1++;
  19. return h1.count() == 4 && h2.count() == 3;
  20. }
  21. #endif
  22. int main(int, char**)
  23. {
  24. {
  25. std::chrono::hours h1(3);
  26. std::chrono::hours h2 = h1++;
  27. assert(h1.count() == 4);
  28. assert(h2.count() == 3);
  29. }
  30. #if TEST_STD_VER > 14
  31. static_assert(test_constexpr(), "");
  32. #endif
  33. return 0;
  34. }