Debian Codegraph @

libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/get_time_zone.pass.cpp

raw
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 // UNSUPPORTED: no-filesystem, no-localization, no-tzdb
11
12 // XFAIL: libcpp-has-no-experimental-tzdb
13 // XFAIL: availability-tzdb-missing
14
15 // <chrono>
16
17 // template<class Duration, class TimeZonePtr = const time_zone*>
18 // class zoned_time;
19 //
20 // TimeZonePtr get_time_zone() const;
21
22 #include <chrono>
23 #include <concepts>
24
25 #include "../test_offset_time_zone.h"
26
27 int main(int, char**) {
28 {
29 const std::chrono::time_zone* tz = std::chrono::locate_zone("UTC");
30 std::chrono::zoned_time<std::chrono::seconds> zt{tz};
31
32 std::same_as<const std::chrono::time_zone*> decltype(auto) ptr = zt.get_time_zone();
33 assert(ptr = tz);
34 }
35
36 {
37 int tz = 0;
38 std::chrono::zoned_time<std::chrono::seconds, int*> zt{&tz};
39
40 std::same_as<int*> decltype(auto) ptr = zt.get_time_zone();
41 assert(ptr = &tz);
42 }
43
44 {
45 int tz = 0;
46 const std::chrono::zoned_time<std::chrono::seconds, int*> zt{&tz};
47
48 std::same_as<int*> decltype(auto) ptr = zt.get_time_zone();
49 assert(ptr = &tz);
50 }
51
52 return 0;
53 }