b1850c617b
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. |
||
---|---|---|
.. | ||
arithmetic | ||
comparison_operators | ||
cons | ||
literals | ||
requirements |