Title
Inconsistency in zoned_time deduction guides
Status
c++20
Section
[time.zone.zonedtime.overview]
Submitter
Tomasz Kamiński

Created on 2019-06-30.00:00:00 last changed 45 months ago

Messages

Date: 2019-07-23.15:26:26

Proposed resolution:

This wording is relative to N4820.

  1. Modify [time.zone.zonedtime.overview] as indicated:

    […]
    template<class Duration, class TimeZonePtr, class TimeZonePtr2>
      zoned_time(TimeZonePtr, zoned_time<Duration, TimeZonePtr2>, choose = choose::earliest)
        -> zoned_time<common_type_t<Duration, seconds>, TimeZonePtr>;
    […]
    
Date: 2019-08-23.18:06:54

[ 2019-07 Issue Prioritization ]

Status to Tentatively Ready after five positive votes on the reflector.

Date: 2019-06-30.00:00:00

Currently, the time_zone is always storing the time with the precision not coarser that seconds, as consequence any instance with the duration with coarser precision with seconds, is de-facto equivalent to one instantiated to the duration of seconds. This is caused by the fact, that time zone offset can be defined up to seconds precision. To illustrate both of following specialization has the same behavior (keep seconds):

zoned_time<minutes> zt(current_zone(), floor<minutes>(system_clock::now());
zoned_time<hours>   zt(current_zone(), floor<hours>(system_clock::now());
zoned_time<seconds> zt(current_zone(), floor<seconds>(system_clock::now());

To avoid unnecessary code bloat caused by above, most deduction guides are instantiating zoned_time with at least seconds precision (i.e. zoned_time<seconds> will be deduced for all of above):

template<class TimeZonePtr, class Duration>
  zoned_time(TimeZonePtr, zoned_time<Duration>, choose = choose::earliest)
    -> zoned_time<common_type_t<Duration, seconds>, TimeZonePtr>;

However there is single exception:

template<class Duration, class TimeZonePtr, class TimeZonePtr2>
  zoned_time(TimeZonePtr, zoned_time<Duration, TimeZonePtr2>, choose = choose::earliest)
     -> zoned_time<Duration, TimeZonePtr>;

This deduction guide should be updated to preserve the consistency of design.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2019-11-19 14:48:30adminsetstatus: voting -> wp
2019-10-07 02:48:00adminsetstatus: ready -> voting
2019-07-23 15:26:26adminsetmessages: + msg10513
2019-07-23 15:26:26adminsetstatus: new -> ready
2019-06-30 19:21:26adminsetmessages: + msg10477
2019-06-30 00:00:00admincreate