Created on 2008-12-20.00:00:00 last changed 170 months ago
[ 2009-10 Santa Cruz: ]
Mark
NAD EditorialResolved, fixed by 1177.
[ 2009-07-27 Howard adds: ]
I've addressed this issue under the proposed wording for 1177 which cleans up several places under [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.
[ Batavia (2009-05): ]
Move to Open, pending proposed wording (and preferably an implementation).
[ Howard adds: ]
Please see the thread starting with c++std-lib-22980 for more information.
In [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.
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-11-19 19:04:45 | admin | set | status: nad editorial -> resolved |
2010-10-21 18:28:33 | admin | set | messages: + msg4495 |
2010-10-21 18:28:33 | admin | set | messages: + msg4494 |
2010-10-21 18:28:33 | admin | set | messages: + msg4493 |
2010-10-21 18:28:33 | admin | set | messages: + msg4492 |
2008-12-20 00:00:00 | admin | create |