[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / time / time.cal / time.cal.year / time.cal.year.nonmembers / minus.pass.cpp
blob9c382a2ef77c4954e9a6485328b3ddae5b6f550b
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 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 // <chrono>
11 // class year;
13 // constexpr year operator-(const year& x, const years& y) noexcept;
14 // Returns: x + -y.
16 // constexpr years operator-(const year& x, const year& y) noexcept;
17 // Returns: If x.ok() == true and y.ok() == true, returns a value m in the range
18 // [years{0}, years{11}] satisfying y + m == x.
19 // Otherwise the value returned is unspecified.
20 // [Example: January - February == years{11}. -end example]
22 #include <chrono>
23 #include <type_traits>
24 #include <cassert>
26 #include "test_macros.h"
28 using year = std::chrono::year;
29 using years = std::chrono::years;
31 constexpr bool test() {
32 year y{1223};
33 for (int i = 1100; i <= 1110; ++i) {
34 year y1 = y - years{i};
35 years ys1 = y - year{i};
36 assert(static_cast<int>(y1) == 1223 - i);
37 assert(ys1.count() == 1223 - i);
40 return true;
43 int main(int, char**) {
44 ASSERT_NOEXCEPT(std::declval<year>() - std::declval<years>());
45 ASSERT_SAME_TYPE(year, decltype(std::declval<year>() - std::declval<years>()));
47 ASSERT_NOEXCEPT(std::declval<year>() - std::declval<year>());
48 ASSERT_SAME_TYPE(years, decltype(std::declval<year>() - std::declval<year>()));
50 test();
51 static_assert(test());
53 return 0;