op_++.pass.cpp 850 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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++(); // 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 h(3);
  19. return (++h).count() == 4;
  20. }
  21. #endif
  22. int main()
  23. {
  24. {
  25. std::chrono::hours h(3);
  26. std::chrono::hours& href = ++h;
  27. assert(&href == &h);
  28. assert(h.count() == 4);
  29. }
  30. #if TEST_STD_VER > 14
  31. static_assert(test_constexpr(), "");
  32. #endif
  33. }