[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time constructors. (PR #95010)
Louis Dionne via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jun 18 09:00:01 PDT 2024
================
@@ -76,12 +81,71 @@ class zoned_time {
_LIBCPP_HIDE_FROM_ABI explicit zoned_time(string_view __name)
requires(requires { __traits::locate_zone(string_view{}); } &&
- // constructible_from<zoned_time, decltype(__traits::locate_zone(string_view{}))>
- // would create a dependency on itself. Instead depend on the fact
- // a constructor taking a _TimeZonePtr exists.
constructible_from<_TimeZonePtr, decltype(__traits::locate_zone(string_view{}))>)
: __zone_{__traits::locate_zone(__name)}, __tp_{} {}
+ template <class _Duration2>
+ _LIBCPP_HIDE_FROM_ABI zoned_time(const zoned_time<_Duration2, _TimeZonePtr>& __zt)
+ requires is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>>
+ : __zone_{__zt.get_time_zone()}, __tp_{__zt.get_sys_time()} {}
+
+ _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const sys_time<_Duration>& __tp)
+ : __zone_{std::move(__zone)}, __tp_{__tp} {}
+
+ _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const sys_time<_Duration>& __tp)
+ requires requires { _TimeZonePtr{__traits::locate_zone(string_view{})}; }
+ : zoned_time{__traits::locate_zone(__name), __tp} {}
+
+ _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const local_time<_Duration>& __tp)
+ requires(is_convertible_v<decltype(std::declval<_TimeZonePtr&>() -> to_sys(local_time<_Duration>{})),
+ sys_time<duration>>)
+ : __zone_{std::move(__zone)}, __tp_{__zone_->to_sys(__tp)} {}
+
+ _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const local_time<_Duration>& __tp)
+ requires(requires {
+ _TimeZonePtr{__traits::locate_zone(string_view{})};
+ } && is_convertible_v<decltype(std::declval<_TimeZonePtr&>() -> to_sys(local_time<_Duration>{})),
+ sys_time<duration>>)
+ : zoned_time{__traits::locate_zone(__name), __tp} {}
+
+ _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const local_time<_Duration>& __tp, choose __c)
+ requires(is_convertible_v<
+ decltype(std::declval<_TimeZonePtr&>() -> to_sys(local_time<_Duration>{}, choose::earliest)),
+ sys_time<duration>>)
+ : __zone_{std::move(__zone)}, __tp_{__zone_->to_sys(__tp, __c)} {}
+
+ _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const local_time<_Duration>& __tp, choose __c)
+ requires(requires {
----------------
ldionne wrote:
Constraint.
https://github.com/llvm/llvm-project/pull/95010
More information about the llvm-branch-commits
mailing list