comparison libstdc++-v3/testsuite/std/time/syn_c++20.cc @ 19:2b5abeee2509 default tip

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents
children
comparison
equal deleted inserted replaced
18:1830386684a0 19:2b5abeee2509
1 // Copyright (C) 2020 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
79 using std::chrono::day;
80 using std::chrono::month;
81 using std::chrono::year;
82 using std::chrono::weekday;
83 using std::chrono::weekday_indexed;
84 using std::chrono::weekday_last;
85 using std::chrono::month_day;
86 using std::chrono::month_day_last;
87 using std::chrono::month_weekday;
88 using std::chrono::month_weekday_last;
89 using std::chrono::year_month;
90 using std::chrono::year_month_day;
91 using std::chrono::year_month_day_last;
92 using std::chrono::year_month_weekday;
93 using std::chrono::year_month_weekday_last;
94 using std::chrono::year_month;
95 using std::chrono::year_month_day;
96
97 using std::chrono::hh_mm_ss;
98 using std::chrono::is_am;
99 using std::chrono::is_pm;
100 using std::chrono::make12;
101 using std::chrono::make24;
102
103 using std::chrono::tzdb;
104 using std::chrono::tzdb_list;
105 using std::chrono::get_tzdb;
106 using std::chrono::get_tzdb_list;
107 using std::chrono::locate_zone;
108 using std::chrono::current_zone;
109
110 using std::chrono::reload_tzdb;
111 using std::chrono::remote_version;
112
113 using std::chrono::nonexistent_local_time;
114 using std::chrono::ambiguous_local_time;
115
116 using std::chrono::sys_info;
117 using std::chrono::local_info;
118
119 using std::chrono::choose;
120 using std::chrono::time_zone;
121
122 using std::chrono::zoned_traits;
123 using std::chrono::zoned_time;
124 using std::chrono::zoned_seconds;
125
126 using std::chrono::leap_second;
127
128 using std::chrono::time_zone_link;
129
130 using std::chrono::local_time_format;
131
132 using std::chrono::parse;
133
134 using std::chrono::last;
135 using std::chrono::Sunday;
136 using std::chrono::Monday;
137 using std::chrono::Tuesday;
138 using std::chrono::Wednesday;
139 using std::chrono::Thursday;
140 using std::chrono::Friday;
141 using std::chrono::Saturday;
142
143 using std::chrono::January;
144 using std::chrono::February;
145 using std::chrono::March;
146 using std::chrono::April;
147 using std::chrono::May;
148 using std::chrono::June;
149 using std::chrono::July;
150 using std::chrono::August;
151 using std::chrono::September;
152 using std::chrono::October;
153 using std::chrono::November;
154 using std::chrono::December;
155
156 using std::chrono_literals::operator""d;
157 using std::chrono_literals::operator""y;
158 #endif
159
160 template<typename>
161 constexpr bool is_duration = false;
162 template<typename R, typename P>
163 constexpr bool is_duration<std::chrono::duration<R, P>> = true;
164
165 static_assert( is_duration<days> );
166 static_assert( is_duration<weeks> );
167 static_assert( is_duration<years> );
168 static_assert( is_duration<months> );
169
170 template<typename D, typename P>
171 constexpr bool has_period = std::is_same_v<typename D::period, P>;
172
173 using std::ratio;
174 using std::ratio_multiply;
175 using std::ratio_divide;
176 using std::chrono::hours;
177 static_assert( has_period<days, ratio_multiply<ratio<24>, hours::period>> );
178 static_assert( has_period<weeks, ratio_multiply<ratio<7>, days::period>> );
179 static_assert( has_period<years,
180 ratio_multiply<ratio<146097, 400>, days::period>> );
181 static_assert( has_period<months, ratio_divide<years::period, ratio<12>>> );
182
183 template<typename>
184 constexpr bool is_time_point = false;
185 template<typename C, typename D>
186 constexpr bool is_time_point<std::chrono::time_point<C, D>> = true;
187
188 static_assert( is_time_point<sys_time<std::chrono::milliseconds>> );
189 static_assert( is_time_point<sys_seconds> );
190 static_assert( is_time_point<sys_days> );
191
192 static_assert( std::is_class_v<local_t> );
193 static_assert( is_time_point<local_time<std::chrono::milliseconds>> );
194 static_assert( is_time_point<local_seconds> );
195 static_assert( is_time_point<local_days> );
196
197 static_assert( std::is_class_v<file_clock> );
198 static_assert( is_time_point<file_time<std::chrono::milliseconds>> );
199 }