zoned_time
constructor from string_view
should accept
zoned_time<Duration2, TimeZonePtr2>
Section: 30.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
.
This wording is relative to N4820.
Modify 30.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);Modify 30.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
-33- Effects: Equivalent to construction withzoned_time
is constructible from the return type oftraits::locate_zone(name)
andzoned_time<Duration2, TimeZonePtr2>
.{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
-35- Effects: Equivalent to construction withzoned_time
is constructible from the return type oftraits::locate_zone(name)
,zoned_time<Duration2, TimeZonePtr2>
, andchoose
.{traits::locate_zone(name), y, c}
. -36- [Note: Thechoose
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.
Modify 30.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);
Modify 30.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:
-33- Effects: Equivalent to construction withzoned_time
is constructible from the return type oftraits::locate_zone(name)
andzoned_time<Duration2, TimeZonePtr2>
.{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:
-35- Effects: Equivalent to construction withzoned_time
is constructible from the return type oftraits::locate_zone(name)
,zoned_time<Duration2, TimeZonePtr2>
, andchoose
.{traits::locate_zone(name), y, c}
. -36- [Note: Thechoose
parameter has no effect. — end note]