Created on 2008-11-30.00:00:00 last changed 174 months ago
Proposed resolution:
Add to the synopsis in [time]:
template <class Rep1, class Period, class Rep2> duration<typename common_type<Rep1, Rep2>::type, Period> operator%(const duration<Rep1, Period>& d, const Rep2& s); template <class Rep1, class Period1, class Rep2, class Period2> typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
Add to the synopsis of duration in [time.duration]:
template <class Rep, class Period = ratio<1>>
class duration {
public:
...
duration& operator%=(const rep& rhs);
duration& operator%=(const duration& d);
...
};
Add to [time.duration.arithmetic]:
duration& operator%=(const rep& rhs);Effects: rep_ %= rhs.
Returns: *this.
duration& operator%=(const duration& d);Effects: rep_ %= d.count().
Returns: *this.
Add to [time.duration.nonmember]:
template <class Rep1, class Period, class Rep2> duration<typename common_type<Rep1, Rep2>::type, Period> operator%(const duration<Rep1, Period>& d, const Rep2& s);Requires: Rep2 shall be implicitly convertible to CR(Rep1, Rep2) and Rep2 shall not be an instantiation of duration. Diagnostic required.
Returns: duration<CR, Period>(d) %= s.
template <class Rep1, class Period1, class Rep2, class Period2> typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);Returns: common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type(lhs) %= rhs.
[ 2009-07 Frankfurt ]
Moved from Tentatively Ready to Open only because the wording needs to be improved for enable_if type constraining, possibly following Robert's formula.
[ Batavia (2009-05): ]
We agree with the proposed resolution. Move to Tentatively Ready.
[ Summit: ]
Agree except that there is a typo in the proposed resolution. The member operators should be operator%=.
Addresses US 81
duration is missing operator%. This operator is convenient for computing where in a time frame a given duration lies. A motivating example is converting a duration into a "broken-down" time duration such as hours::minutes::seconds:
class ClockTime
{
typedef std::chrono::hours hours;
typedef std::chrono::minutes minutes;
typedef std::chrono::seconds seconds;
public:
hours hours_;
minutes minutes_;
seconds seconds_;
template <class Rep, class Period>
explicit ClockTime(const std::chrono::duration<Rep, Period>& d)
: hours_ (std::chrono::duration_cast<hours> (d)),
minutes_(std::chrono::duration_cast<minutes>(d % hours(1))),
seconds_(std::chrono::duration_cast<seconds>(d % minutes(1)))
{}
};
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2011-08-23 20:07:26 | admin | set | status: wp -> c++11 |
| 2010-10-21 18:28:33 | admin | set | messages: + msg4447 |
| 2010-10-21 18:28:33 | admin | set | messages: + msg4446 |
| 2010-10-21 18:28:33 | admin | set | messages: + msg4445 |
| 2010-10-21 18:28:33 | admin | set | messages: + msg4444 |
| 2010-10-21 18:28:33 | admin | set | messages: + msg4443 |
| 2008-11-30 00:00:00 | admin | create | |