This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Resolved status.
Section: 29.5.6 [time.duration.nonmember] Status: Resolved Submitter: Pete Becker Opened: 2008-12-20 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [time.duration.nonmember].
View all issues with Resolved status.
Discussion:
In 29.5.6 [time.duration.nonmember], paragraph 8 says that calling dur / rep when rep is an instantiation of duration requires a diagnostic. That's followed by an operator/ that takes two durations. So dur1 / dur2 is legal under the second version, but requires a diagnostic under the first.
[ Howard adds: ]
Please see the thread starting with c++std-lib-22980 for more information.
[ Batavia (2009-05): ]
Move to Open, pending proposed wording (and preferably an implementation).
[ 2009-07-27 Howard adds: ]
I've addressed this issue under the proposed wording for 1177 which cleans up several places under 29.5 [time.duration] which used the phrase "diagnostic required".
For clarity's sake, here is an example implementation of the constrained operator/:
template <class _Duration, class _Rep, bool = __is_duration<_Rep>::value> struct __duration_divide_result { }; template <class _Duration, class _Rep2, bool = is_convertible<_Rep2, typename common_type<typename _Duration::rep, _Rep2>::type>::value> struct __duration_divide_imp { }; template <class _Rep1, class _Period, class _Rep2> struct __duration_divide_imp<duration<_Rep1, _Period>, _Rep2, true> { typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period> type; }; template <class _Rep1, class _Period, class _Rep2> struct __duration_divide_result<duration<_Rep1, _Period>, _Rep2, false> : __duration_divide_imp<duration<_Rep1, _Period>, _Rep2> { }; template <class _Rep1, class _Period, class _Rep2> inline typename __duration_divide_result<duration<_Rep1, _Period>, _Rep2>::type operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { typedef typename common_type<_Rep1, _Rep2>::type _Cr; duration<_Cr, _Period> __r = __d; __r /= static_cast<_Cr>(__s); return __r; }__duration_divide_result is basically a custom-built enable_if that will contain type only if Rep2 is not a duration and if Rep2 is implicitly convertible to common_type<typename Duration::rep, Rep2>::type. __is_duration is simply a private trait that answers false, but is specialized for duration to answer true.
The constrained operator% works identically.
[ 2009-10 Santa Cruz: ]
Mark
NAD EditorialResolved, fixed by 1177.
Proposed resolution: