C++ Logo

std-proposals

Advanced search

Re: [std-proposals] New draft proposal: Add "%s" (two-digit truncated-integer seconds) as a std::format conversion specifier for std::chrono time types.

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Wed, 3 May 2023 11:43:16 +0100
> The currently required method may have the potential to be less efficient
because it *requires* a conversion in user code, (and it's not easy for a
user to determine whether this conversion is trivial). This is unlikely to
be very important, however, as it's unlikely this function will be called
often enough to noticeably affect performance.

Why would it be any more efficient for std::format to do
chrono::duration_cast<seconds> (or chrono::floor) than for the user code to
do it?

I don't really see a pressing need for this. If you don't want fractional
seconds, don't use a representation that has subsecond resolution. One of
the strengths of the std::chrono API is that you can choose your resolution
and easily convert between them. I don't think std::format needs to provide
that conversion as well.

Received on 2023-05-03 10:43:31