]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/std/time/syn_c++20.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / std / time / syn_c++20.cc
1 // Copyright (C) 2020-2022 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
7 // any later version.
8
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
17
18 // { dg-options "-std=gnu++2a" }
19 // { dg-do compile { target c++2a } }
20
21 #include <chrono>
22
23 #ifndef __cpp_lib_chrono
24 # error "Feature test macro for chrono is missing in <chrono>"
25 // FIXME
26 // #elif __cpp_lib_chrono < 201907L
27 // # error "Feature test macro for chrono has wrong value in <chrono>"
28 #endif
29
30 namespace __gnu_test
31 {
32 // Check for the new additions to <chrono> in C++20
33
34 using std::chrono::is_clock;
35 using std::chrono::is_clock_v;
36
37 using std::chrono::days;
38 using std::chrono::weeks;
39 using std::chrono::years;
40 using std::chrono::months;
41
42 using std::chrono::sys_time;
43 using std::chrono::sys_seconds;
44 using std::chrono::sys_days;
45
46 // FIXME
47 #if 0
48 using std::chrono::utc_clock;
49 using std::chrono::utc_time;
50 using std::chrono::utc_seconds;
51
52 using std::chrono::leap_second_info;
53 using std::chrono::get_leap_second_info;
54
55 using std::chrono::tai_clock;
56 using std::chrono::tai_time;
57 using std::chrono::tai_seconds;
58
59 using std::chrono::gps_clock;
60 using std::chrono::gps_time;
61 using std::chrono::gps_seconds;
62 #endif
63
64 using std::chrono::file_clock;
65 using std::chrono::file_time;
66
67 using std::chrono::local_t;
68 using std::chrono::local_time;
69 using std::chrono::local_seconds;
70 using std::chrono::local_days;
71
72 // FIXME
73 #if 0
74 using std::chrono::clock_time_conversion;
75 using std::chrono::clock_cast;
76
77 using std::chrono::last_spec;
78 #endif
79
80 using std::chrono::day;
81 using std::chrono::month;
82 using std::chrono::year;
83 using std::chrono::weekday;
84 using std::chrono::weekday_indexed;
85 using std::chrono::weekday_last;
86 using std::chrono::month_day;
87 using std::chrono::month_day_last;
88 using std::chrono::month_weekday;
89 using std::chrono::month_weekday_last;
90 using std::chrono::year_month;
91 using std::chrono::year_month_day;
92 using std::chrono::year_month_day_last;
93 using std::chrono::year_month_weekday;
94 using std::chrono::year_month_weekday_last;
95 using std::chrono::year_month;
96 using std::chrono::year_month_day;
97
98 using std::chrono::hh_mm_ss;
99 using std::chrono::is_am;
100 using std::chrono::is_pm;
101 using std::chrono::make12;
102 using std::chrono::make24;
103
104 // FIXME
105 #if 0
106 using std::chrono::tzdb;
107 using std::chrono::tzdb_list;
108 using std::chrono::get_tzdb;
109 using std::chrono::get_tzdb_list;
110 using std::chrono::locate_zone;
111 using std::chrono::current_zone;
112
113 using std::chrono::reload_tzdb;
114 using std::chrono::remote_version;
115
116 using std::chrono::nonexistent_local_time;
117 using std::chrono::ambiguous_local_time;
118
119 using std::chrono::sys_info;
120 using std::chrono::local_info;
121
122 using std::chrono::choose;
123 using std::chrono::time_zone;
124
125 using std::chrono::zoned_traits;
126 using std::chrono::zoned_time;
127 using std::chrono::zoned_seconds;
128
129 using std::chrono::leap_second;
130
131 using std::chrono::time_zone_link;
132
133 using std::chrono::local_time_format;
134
135 using std::chrono::parse;
136 #endif
137
138 using std::chrono::last;
139 using std::chrono::Sunday;
140 using std::chrono::Monday;
141 using std::chrono::Tuesday;
142 using std::chrono::Wednesday;
143 using std::chrono::Thursday;
144 using std::chrono::Friday;
145 using std::chrono::Saturday;
146
147 using std::chrono::January;
148 using std::chrono::February;
149 using std::chrono::March;
150 using std::chrono::April;
151 using std::chrono::May;
152 using std::chrono::June;
153 using std::chrono::July;
154 using std::chrono::August;
155 using std::chrono::September;
156 using std::chrono::October;
157 using std::chrono::November;
158 using std::chrono::December;
159
160 using std::chrono_literals::operator""d;
161 using std::chrono_literals::operator""y;
162
163 template<typename>
164 constexpr bool is_duration = false;
165 template<typename R, typename P>
166 constexpr bool is_duration<std::chrono::duration<R, P>> = true;
167
168 static_assert( is_duration<days> );
169 static_assert( is_duration<weeks> );
170 static_assert( is_duration<years> );
171 static_assert( is_duration<months> );
172
173 template<typename D, typename P>
174 constexpr bool has_period = std::is_same_v<typename D::period, P>;
175
176 using std::ratio;
177 using std::ratio_multiply;
178 using std::ratio_divide;
179 using std::chrono::hours;
180 static_assert( has_period<days, ratio_multiply<ratio<24>, hours::period>> );
181 static_assert( has_period<weeks, ratio_multiply<ratio<7>, days::period>> );
182 static_assert( has_period<years,
183 ratio_multiply<ratio<146097, 400>, days::period>> );
184 static_assert( has_period<months, ratio_divide<years::period, ratio<12>>> );
185
186 template<typename>
187 constexpr bool is_time_point = false;
188 template<typename C, typename D>
189 constexpr bool is_time_point<std::chrono::time_point<C, D>> = true;
190
191 static_assert( is_time_point<sys_time<std::chrono::milliseconds>> );
192 static_assert( is_time_point<sys_seconds> );
193 static_assert( is_time_point<sys_days> );
194
195 static_assert( std::is_class_v<local_t> );
196 static_assert( is_time_point<local_time<std::chrono::milliseconds>> );
197 static_assert( is_time_point<local_seconds> );
198 static_assert( is_time_point<local_days> );
199
200 static_assert( std::is_class_v<file_clock> );
201 static_assert( is_time_point<file_time<std::chrono::milliseconds>> );
202 }