op_--.pass.cpp 887 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. // constexpr duration& operator--(); // 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 h(3);
  18. return (--h).count() == 2;
  19. }
  20. #endif
  21. int main(int, char**)
  22. {
  23. {
  24. std::chrono::hours h(3);
  25. std::chrono::hours& href = --h;
  26. assert(&href == &h);
  27. assert(h.count() == 2);
  28. }
  29. #if TEST_STD_VER > 14
  30. static_assert(test_constexpr(), "");
  31. #endif
  32. return 0;
  33. }