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