tomaszkam / date

A date and time library based on the C++11/14/17 <chrono> header
Other
0 stars 0 forks source link

[LWG3226] zoned_time constructor from string_view should accept zoned_time<Duration2, TimeZonePtr2> #18

Closed tomaszkam closed 5 years ago

tomaszkam commented 5 years ago

Original comment:

Change:

zoned_time(string_view name, const zoned_time& zt); zoned_time(string_view name, const zoned_time& zt, choose);

to:

zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& zt); zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& zt, choose);

E-mail conversation: [isocpp-lib] zoned_time issues

tomaszkam commented 5 years ago

Discussion: zoned_time constructors from string_view and other zoned_time are not accepting zoned_time instances, that use different time zone representation (TimeZonePtr parameter). This make them inconsistent with constructors from TimeZonePtr and zoned_time, that they delegate to. Furthermore it forces creation of temporary zoned_time object in case if source uses the same TimeZonePtr, but different Duration.

Proposed wording: Apply the following changes to [time.zone.zonedtime.overview]:

template<class Duration2, class TimeZonePtr2>
  zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& zt);
template<class Duration2, class TimeZonePtr2>
  zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& zt, choose)

Apply the following changes to [time.zone.zonedtime.ctor]:

template<class Duration2, class TimeZonePtr2>
  zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& zt);

Remarks: This constructor does not participate in overload resolution unless zoned­time is constructible from the return type of traits::locate­zone(name) and zonedtime<Duration2, TimeZonePtr2>. Effects: Equivalent to construction with {traits::locate­zone(name), y}.

template<class Duration2, class TimeZonePtr2>
  zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& zt, choose)

Remarks: This constructor does not participate in overload resolution unless zoned­time is constructible from the return type of traits::locate­zone(name), zoned_­time<Duration2, TimeZonePtr2>, and choose.

Effects: Equivalent to construction with {traits::locate_­zone(name), y, c}.

[ Note: The choose parameter has no effect. — end note  ]