| 1 |
// { dg-do compile { target c++20 } } |
| 2 |
// { dg-require-effective-target cxx11_abi } |
| 3 |
|
| 4 |
#include <chrono> |
| 5 |
|
| 6 |
using namespace std::chrono; |
| 7 |
|
| 8 |
struct local_tz : time_zone { local_tz(); }; |
| 9 |
|
| 10 |
template<> struct std::chrono::zoned_traits<const local_tz*> |
| 11 |
{ |
| 12 |
static auto default_zone() { return current_zone(); } |
| 13 |
|
| 14 |
static auto locate_zone(std::string_view name) |
| 15 |
{ return std::chrono::locate_zone(name); } |
| 16 |
}; |
| 17 |
|
| 18 |
void |
| 19 |
test_ctad() |
| 20 |
{ |
| 21 |
zoned_time z1; |
| 22 |
static_assert( std::is_same_v<decltype(z1), zoned_time<seconds>> ); |
| 23 |
zoned_time z2 = z1; |
| 24 |
static_assert( std::is_same_v<decltype(z2), decltype(z1)> ); |
| 25 |
|
| 26 |
zoned_time z3 = sys_time<milliseconds>(); |
| 27 |
static_assert( std::is_same_v<decltype(z3), zoned_time<milliseconds>> ); |
| 28 |
|
| 29 |
const local_tz ltz; |
| 30 |
zoned_time z4(<z); |
| 31 |
static_assert( std::is_same_v<decltype(z4), |
| 32 |
zoned_time<seconds, const local_tz*>> ); |
| 33 |
|
| 34 |
zoned_time z5("GMT"); |
| 35 |
static_assert( std::is_same_v<decltype(z5), zoned_time<seconds>> ); |
| 36 |
|
| 37 |
zoned_time z6(<z, sys_time<minutes>()); |
| 38 |
static_assert( std::is_same_v<decltype(z6), |
| 39 |
zoned_time<seconds, const local_tz*>> ); |
| 40 |
|
| 41 |
zoned_time z7(<z, sys_time<milliseconds>()); |
| 42 |
static_assert( std::is_same_v<decltype(z7), |
| 43 |
zoned_time<milliseconds, const local_tz*>> ); |
| 44 |
|
| 45 |
zoned_time z8("GMT", sys_time<minutes>()); |
| 46 |
static_assert( std::is_same_v<decltype(z8), zoned_time<seconds>> ); |
| 47 |
|
| 48 |
zoned_time z9("GMT", sys_time<microseconds>()); |
| 49 |
static_assert( std::is_same_v<decltype(z9), zoned_time<microseconds>> ); |
| 50 |
|
| 51 |
zoned_time z10(<z, local_time<minutes>()); |
| 52 |
static_assert( std::is_same_v<decltype(z10), |
| 53 |
zoned_time<seconds, const local_tz*>> ); |
| 54 |
|
| 55 |
zoned_time z11(<z, local_time<nanoseconds>(), choose::earliest); |
| 56 |
static_assert( std::is_same_v<decltype(z11), |
| 57 |
zoned_time<nanoseconds, const local_tz*>> ); |
| 58 |
|
| 59 |
zoned_time z12("GMT", local_time<minutes>()); |
| 60 |
static_assert( std::is_same_v<decltype(z12), zoned_time<seconds>> ); |
| 61 |
|
| 62 |
zoned_time z13("GMT", local_time<nanoseconds>(), choose::earliest); |
| 63 |
static_assert( std::is_same_v<decltype(z13), zoned_time<nanoseconds>> ); |
| 64 |
|
| 65 |
zoned_time z14(<z, z13); |
| 66 |
static_assert( std::is_same_v<decltype(z14), |
| 67 |
zoned_time<nanoseconds, const local_tz*>> ); |
| 68 |
|
| 69 |
zoned_time z15(<z, z12, choose::earliest); |
| 70 |
static_assert( std::is_same_v<decltype(z15), |
| 71 |
zoned_time<seconds, const local_tz*>> ); |
| 72 |
|
| 73 |
zoned_time z16("GMT", z14); |
| 74 |
static_assert( std::is_same_v<decltype(z16), zoned_time<nanoseconds>> ); |
| 75 |
|
| 76 |
zoned_time z17("GMT", z12, choose::earliest); |
| 77 |
static_assert( std::is_same_v<decltype(z17), zoned_time<seconds>> ); |
| 78 |
} |