aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2020-09-01 18:18:26 +0100
committerJonathan Wakely <jwakely@redhat.com>2020-09-01 18:18:26 +0100
commitb1850c617b14eedaf60b358f3b7d4707cff73b8a (patch)
tree8c960987dcbd6e7fe0f0b3e060ec9bb3f1643de7 /gcc
parent49bfbf18c0bb9d83934f0ce765dc031ebfbda38e (diff)
downloadgcc-b1850c617b14eedaf60b358f3b7d4707cff73b8a.zip
gcc-b1850c617b14eedaf60b358f3b7d4707cff73b8a.tar.gz
gcc-b1850c617b14eedaf60b358f3b7d4707cff73b8a.tar.bz2
libstdc++: Constrain chrono::duration conversions [LWG 2094]
The chrono::duration constructor that converts from another duration type is meant to be constrained so that it doesn't participate in overload resolution if the ratio of the periods cannot be represented as a std::ratio. Because our std::ratio_divide is not SFINAE-friendly the evaluation of __is_harmonic results in an error outside the immediate context when an overflow occurs. I intend to make ratio_divide (and ratio_multiply) SFINAE-friendly in a future patch, but for now this patch just introduces a new SFINAE-friendly alias template for the division. The standard doesn't require it, but it also seems right to constrain the constructor with std::is_convertible_v<_Rep2, rep>. libstdc++-v3/ChangeLog: * include/std/chrono (duration::_S_gcd(intmax_t, intmax_t)): New helper function for finding GCD of two positive intmax_t values. (duration::__divide): New helper alias for dividing one period by another. (duration::__is_harmonic): Use __divide not ratio_divide. (duration(const duration<R2, P2>&)): Require the duration rep types to be convertible. * testsuite/20_util/duration/cons/dr2094.cc: New test. * testsuite/20_util/duration/requirements/reduced_period.cc: Fix definition of unused member functions in test type. * testsuite/20_util/duration/requirements/typedefs_neg2.cc: Adjust expected errors.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions