1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17
13 // constexpr year operator+(const year& x, const years& y) noexcept;
14 // Returns: year(int{x} + y.count()).
16 // constexpr year operator+(const years& x, const year& y) noexcept;
20 #include <type_traits>
23 #include "test_macros.h"
25 using year
= std::chrono::year
;
26 using years
= std::chrono::years
;
28 constexpr bool test() {
30 for (int i
= 1100; i
<= 1110; ++i
) {
31 year y1
= y
+ years
{i
};
32 year y2
= years
{i
} + y
;
34 assert(static_cast<int>(y1
) == i
+ 1223);
35 assert(static_cast<int>(y2
) == i
+ 1223);
41 int main(int, char**) {
42 ASSERT_NOEXCEPT(std::declval
<year
>() + std::declval
<years
>());
43 ASSERT_SAME_TYPE(year
, decltype(std::declval
<year
>() + std::declval
<years
>()));
45 ASSERT_NOEXCEPT(std::declval
<years
>() + std::declval
<year
>());
46 ASSERT_SAME_TYPE(year
, decltype(std::declval
<years
>() + std::declval
<year
>()));
49 static_assert(test());