op_++int.pass.cpp 907 B

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