Debian Codegraph @

libcxx/test/std/time/time.cal/time.cal.year/time.cal.year.nonmembers/literals.pass.cpp

raw
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
9
10 // <chrono>
11 // class year;
12
13 // constexpr year operator""y(unsigned long long y) noexcept;
14
15 #include <chrono>
16 #include <type_traits>
17 #include <cassert>
18
19 #include "test_macros.h"
20
21 int main(int, char**)
22 {
23 {
24 using namespace std::chrono;
25 ASSERT_NOEXCEPT(4y);
26
27 static_assert( 2017y == year(2017), "");
28 year y1 = 2018y;
29 assert (y1 == year(2018));
30 }
31
32 {
33 using namespace std::literals;
34 ASSERT_NOEXCEPT(4d);
35
36 static_assert( 2017y == std::chrono::year(2017), "");
37
38 std::chrono::year y1 = 2020y;
39 assert (y1 == std::chrono::year(2020));
40 }
41
42 return 0;
43 }