This patch series reworks the handling of the empty chron-spec when
formatting calendar types. For all types except duration with custom
representation, the implementation no-longer delegates to operator<<,
and instead configures formatter _M_chron_spec accordingly, and follows
with normal format routine.

This patch series should not introduce functional changes, and passes
an existing extensive test suite for empty chron-spec, in
testsuite/std/time/format/empty_spec.cc.

We introduce to new features to the format-spec, that are available
only internally:
 - producing "is not a valid sth" output, by setting _M_debug flag
 - producing weekday index
For the later, we need a new specifier, and '%\0' (embeded null
terminator) was used for that purpose. This disallows conflicts with 
future extension.

An alternative, that I would like to inquery, is to reserve '%v'
(currently unused) for that purpose. The _M_parse will still reject that
format specifier, but we will _M_format would recognize it. And we 
could add it into _M_parse in future. 
Use of 'v' seem to be fitting, as close values 'w', 'u' are used
to print weekday index, and 'U', 'V', 'W' are used for weeks number of
the year.

Finally, this patch does not deduplicate the code between the formatters
and existing operators<<. Such change may be desired, but as far as I
know can be made later without changing the ABI. Most notably, operator<<
would benefit from specialized sink that would output to ostream directly.
Such _Sink would also be useful for std::print overload accepting
ostream.

Reply via email to