]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/std/time/syn_c++20.cc
dd9e4059c1bc8a2eb68eaca3da99ddd496ba50de
1 // Copyright (C) 2020-2023 Free Software Foundation, Inc.
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)
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.
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/>.
18 // { dg-do compile { target c++20 } }
19 // { dg-add-options no_pch }
23 #ifndef __cpp_lib_chrono
24 # error "Feature test macro for chrono is missing in <chrono>"
25 #elif __cpp_lib_chrono < 201907L
26 # error "Feature test macro for chrono has wrong value in <chrono>"
31 // Check for the new additions to <chrono> in C++20
33 using std::chrono::is_clock
;
34 using std::chrono::is_clock_v
;
36 using std::chrono::days
;
37 using std::chrono::weeks
;
38 using std::chrono::years
;
39 using std::chrono::months
;
41 using std::chrono::sys_time
;
42 using std::chrono::sys_seconds
;
43 using std::chrono::sys_days
;
45 using std::chrono::utc_clock
;
46 using std::chrono::utc_time
;
47 using std::chrono::utc_seconds
;
49 using std::chrono::leap_second_info
;
50 using std::chrono::get_leap_second_info
;
52 using std::chrono::tai_clock
;
53 using std::chrono::tai_time
;
54 using std::chrono::tai_seconds
;
56 using std::chrono::gps_clock
;
57 using std::chrono::gps_time
;
58 using std::chrono::gps_seconds
;
60 using std::chrono::file_clock
;
61 using std::chrono::file_time
;
63 using std::chrono::local_t
;
64 using std::chrono::local_time
;
65 using std::chrono::local_seconds
;
66 using std::chrono::local_days
;
68 using std::chrono::clock_time_conversion
;
69 using std::chrono::clock_cast
;
71 using std::chrono::last_spec
;
73 using std::chrono::day
;
74 using std::chrono::month
;
75 using std::chrono::year
;
76 using std::chrono::weekday
;
77 using std::chrono::weekday_indexed
;
78 using std::chrono::weekday_last
;
79 using std::chrono::month_day
;
80 using std::chrono::month_day_last
;
81 using std::chrono::month_weekday
;
82 using std::chrono::month_weekday_last
;
83 using std::chrono::year_month
;
84 using std::chrono::year_month_day
;
85 using std::chrono::year_month_day_last
;
86 using std::chrono::year_month_weekday
;
87 using std::chrono::year_month_weekday_last
;
88 using std::chrono::year_month
;
89 using std::chrono::year_month_day
;
91 using std::chrono::hh_mm_ss
;
92 using std::chrono::is_am
;
93 using std::chrono::is_pm
;
94 using std::chrono::make12
;
95 using std::chrono::make24
;
97 #if _GLIBCXX_USE_CXX11_ABI
98 using std::chrono::tzdb
;
99 using std::chrono::tzdb_list
;
100 using std::chrono::get_tzdb
;
101 using std::chrono::get_tzdb_list
;
102 using std::chrono::locate_zone
;
103 using std::chrono::current_zone
;
105 using std::chrono::reload_tzdb
;
106 using std::chrono::remote_version
;
108 using std::chrono::nonexistent_local_time
;
109 using std::chrono::ambiguous_local_time
;
111 using std::chrono::sys_info
;
112 using std::chrono::local_info
;
114 using std::chrono::choose
;
115 using std::chrono::time_zone
;
117 using std::chrono::zoned_traits
;
118 using std::chrono::zoned_time
;
119 using std::chrono::zoned_seconds
;
121 using std::chrono::leap_second
;
123 using std::chrono::time_zone_link
;
126 using std::chrono::local_time_format
;
128 using std::chrono::from_stream
;
129 using std::chrono::parse
;
131 using std::chrono::last
;
132 using std::chrono::Sunday
;
133 using std::chrono::Monday
;
134 using std::chrono::Tuesday
;
135 using std::chrono::Wednesday
;
136 using std::chrono::Thursday
;
137 using std::chrono::Friday
;
138 using std::chrono::Saturday
;
140 using std::chrono::January
;
141 using std::chrono::February
;
142 using std::chrono::March
;
143 using std::chrono::April
;
144 using std::chrono::May
;
145 using std::chrono::June
;
146 using std::chrono::July
;
147 using std::chrono::August
;
148 using std::chrono::September
;
149 using std::chrono::October
;
150 using std::chrono::November
;
151 using std::chrono::December
;
153 using std::chrono_literals::operator""d
;
154 using std::chrono_literals::operator""y
;
157 constexpr bool is_duration
= false;
158 template<typename R
, typename P
>
159 constexpr bool is_duration
<std::chrono::duration
<R
, P
>> = true;
161 static_assert( is_duration
<days
> );
162 static_assert( is_duration
<weeks
> );
163 static_assert( is_duration
<years
> );
164 static_assert( is_duration
<months
> );
166 template<typename D
, typename P
>
167 constexpr bool has_period
= std::is_same_v
<typename
D::period
, P
>;
170 using std::ratio_multiply
;
171 using std::ratio_divide
;
172 using std::chrono::hours
;
173 static_assert( has_period
<days
, ratio_multiply
<ratio
<24>, hours::period
>> );
174 static_assert( has_period
<weeks
, ratio_multiply
<ratio
<7>, days::period
>> );
175 static_assert( has_period
<years
,
176 ratio_multiply
<ratio
<146097, 400>, days::period
>> );
177 static_assert( has_period
<months
, ratio_divide
<years::period
, ratio
<12>>> );
180 constexpr bool is_time_point
= false;
181 template<typename C
, typename D
>
182 constexpr bool is_time_point
<std::chrono::time_point
<C
, D
>> = true;
184 static_assert( is_time_point
<sys_time
<std::chrono::milliseconds
>> );
185 static_assert( is_time_point
<sys_seconds
> );
186 static_assert( is_time_point
<sys_days
> );
188 static_assert( std::is_class_v
<local_t
> );
189 static_assert( is_time_point
<local_time
<std::chrono::milliseconds
>> );
190 static_assert( is_time_point
<local_seconds
> );
191 static_assert( is_time_point
<local_days
> );
193 static_assert( std::is_class_v
<file_clock
> );
194 static_assert( is_time_point
<file_time
<std::chrono::milliseconds
>> );