This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.

3226. zoned_time constructor from string_view should accept zoned_time<Duration2, TimeZonePtr2>

Section: 29.11.7.2 [time.zone.zonedtime.ctor] Status: C++20 Submitter: Tomasz Kamiński Opened: 2019-06-23 Last modified: 2021-02-25

Priority: 2

View all other issues in [time.zone.zonedtime.ctor].

View all issues with C++20 status.

Discussion:

zoned_time constructors with string_view and another zoned_time are not accepting zoned_time instances that use a different time zone representation (TimeZonePtr parameter):

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

This makes them inconsistent with the constructors from TimeZonePtr and zoned_time, that they delegate to:

template<class Duration2, class TimeZonePtr2>
  zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& zt);
template<class Duration2, class TimeZonePtr2>
  zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& zt, choose);

Furthermore it forces the creation of a temporary zoned_time object in case when the source uses the same TimeZonePtr, but different Duration.

Previous resolution [SUPERSEDED]:

This wording is relative to N4820.

  1. Modify 29.11.7.1 [time.zone.zonedtime.overview], class template zoned_time synopsis, as indicated:

    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);
  2. Modify 29.11.7.2 [time.zone.zonedtime.ctor] as indicated:

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

    -32- Remarks: This constructor does not participate in overload resolution unless zoned_time is constructible from the return type of traits::locate_zone(name) and zoned_time<Duration2, TimeZonePtr2>.

    -33- 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>& y, choose c););
    

    -34- 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.

    -35- Effects: Equivalent to construction with {traits::locate_zone(name), y, c}.

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

[2020-02-13, Prague]

During LWG discussions it was suggested to rebase the wording to reduce the chances for confusion.

[2020-02 Status to Immediate on Thursday morning in Prague.]

Proposed resolution:

This wording is relative to N4849.

  1. Modify 29.11.7.1 [time.zone.zonedtime.overview], class template zoned_time synopsis, as indicated:

    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);
  2. Modify 29.11.7.2 [time.zone.zonedtime.ctor] as indicated:

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

    -32- Constraints: zoned_time is constructible from the return type of traits::locate_zone(name) and zoned_time<Duration2, TimeZonePtr2>.

    -33- 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>& y, choose c););
    

    -34- Constraints: zoned_time is constructible from the return type of traits::locate_zone(name), zoned_time<Duration2, TimeZonePtr2>, and choose.

    -35- Effects: Equivalent to construction with {traits::locate_zone(name), y, c}.

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