]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix common_type specializations for duration
authorJonathan Wakely <jwakely@redhat.com>
Fri, 28 Aug 2020 22:41:13 +0000 (23:41 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 28 Aug 2020 22:41:13 +0000 (23:41 +0100)
commitf2f48b68a6a586f40dd8ae0e6d391b7f88756eec
tree8fcc850276bf8a3648a74a78f4d9fb4a71a95a1e
parent82db1a42e9254c9009bbf8ac01366da4d1ab6df5
libstdc++: Fix common_type specializations for duration

My recent change to implement P0548 ("common_type and duration") was not
correct. The result of common_type_t<duration<R,P>, duration<R,P>>
should be duration<common_type_t<R>, P::type>, not duration<R, P::type>.
The common_type specialization for two different duration types was
correct, but the specializations for a single duration type (which only
exist to optimize compilation time) were wrong.

This fixes the partial specializations of common_type for a single
duration type, and also the return types of duration::operator+ and
duration::operator- which are supposed to use common_type_t<duration>.

libstdc++-v3/ChangeLog:

* include/std/chrono (common_type): Fix partial specializations
for a single duration type to use the common_type of the rep.
(duration::operator+, duration::operator-): Fix return types
to also use the common_type of the rep.
* testsuite/20_util/duration/requirements/reduced_period.cc:
Check duration using a rep that has common_type specialized.
libstdc++-v3/include/std/chrono
libstdc++-v3/testsuite/20_util/duration/requirements/reduced_period.cc