]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix chrono::__detail::ceil to work with C++11
authorJonathan Wakely <jwakely@redhat.com>
Fri, 11 Sep 2020 18:59:11 +0000 (19:59 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 11 Sep 2020 18:59:11 +0000 (19:59 +0100)
commit53ad6b1979f4bd7121e977c4a44151b14d8a0147
treeb9df4a7e55c89def26e5bb75cba2870e2bf1263f
parent40e99ed5f4e59c6d0a8e81cd6544c9b4e7ec2fe7
libstdc++: Fix chrono::__detail::ceil to work with C++11

In C++11 constexpr functions can only have a return statement, so we
need to fix __detail::ceil to make it valid in C++11. This can be done
by moving the comparison and increment into a new function, __ceil_impl,
and calling that with the result of the duration_cast.

This would mean the standard C++17 std::chrono::ceil function would make
two further calls, which would add too much overhead when not inlined.
For C++17 and later use a using-declaration to add chrono::ceil to
namespace __detail. For C++11 and C++14 define chrono::__detail::__ceil
as a C++11-compatible constexpr function template.

libstdc++-v3/ChangeLog:

* include/std/chrono [C++17] (chrono::__detail::ceil): Add
using declaration to make chrono::ceil available for internal
use with a consistent name.
(chrono::__detail::__ceil_impl): New function template.
(chrono::__detail::ceil): Use __ceil_impl to compare and
increment the value. Remove SFINAE constraint.
libstdc++-v3/include/std/chrono