Created on 2008-10-07.00:00:00 last changed 161 months ago
Proposed resolution:
In [ratio] p.3 change as indicated:
// ratio arithmetic template <class R1, class R2>structusing ratio_add = see below; template <class R1, class R2>structusing ratio_subtract = see below; template <class R1, class R2>structusing ratio_multiply = see below; template <class R1, class R2>structusing ratio_divide = see below;
In [ratio.ratio], change as indicated:
namespace std { template <intmax_t N, intmax_t D = 1> class ratio { public: typedef ratio type; static const intmax_t num; static const intmax_t den; }; }
In [ratio.arithmetic] change as indicated:
template <class R1, class R2>structusing ratio_add = see below{ typedef see below type; };1 The
nested typedeftype ratio_add<R1, R2> shall be a synonym for ratio<T1, T2> where T1 has the value R1::num * R2::den + R2::num * R1::den and T2 has the value R1::den * R2::den.
template <class R1, class R2>structusing ratio_subtract = see below{ typedef see below type; };2 The
nested typedeftype ratio_subtract<R1, R2> shall be a synonym for ratio<T1, T2> where T1 has the value R1::num * R2::den - R2::num * R1::den and T2 has the value R1::den * R2::den.
template <class R1, class R2>structusing ratio_multiply = see below{ typedef see below type; };3 The
nested typedeftype ratio_multiply<R1, R2> shall be a synonym for ratio<T1, T2> where T1 has the value R1::num * R2::num and T2 has the value R1::den * R2::den.
template <class R1, class R2>structusing ratio_divide = see below{ typedef see below type; };4 The
nested typedeftype ratio_divide<R1, R2> shall be a synonym for ratio<T1, T2> where T1 has the value R1::num * R2::den and T2 has the value R1::den * R2::num.
In [time.duration.cons] p.4 change as indicated:
Requires: treat_as_floating_point<rep>::value shall be true or ratio_divide<Period2, period>::
type::den shall be 1.[..]
In [time.duration.cast] p.2 change as indicated:
Returns: Let CF be ratio_divide<Period, typename ToDuration::period>
::type, and [..]
[ 2009-10 Santa Cruz: ]
Move to Ready.
[ 2009-07-21 Alisdair adds: ]
See 1121 for a potentially incompatible proposal.
[ Batavia (2009-05): ]
Bill asks for additional discussion in the issue that spells out more details of the implementation. Howard points us to issue 948 which has at least most of the requested details. Tom is strongly in favor of overflow-checking at compile time. Pete points out that there is no change of functionality implied. We agree with the proposed resolution, but recommend moving the issue to Review to allow time to improve the discussion if needed.
[ 2009-05-11 Pablo adds: ]
The addition of type to the ratio template allows the previous style (i.e., in the prototype implementations) to remain valid and permits the use of transitional library implementations for C++03 compilers. I do not feel strongly about its inclusion, however, and leave it up to the reviewers to decide.
[ 2009-05-11 Daniel adds: ]
Personally I'm not in favor for the addition of:
typedef ratio type;For a reader of the standard it's usage or purpose is unclear. I haven't seen similar examples of attempts to satisfy non-feature complete compilers.
[ Post Summit: ]
Jens: not a complete proposed resolution: "would need to make similar change"
Consensus: We agree with the direction of the issue.
Recommend Open.
The compile-time functions that operate on ratio<N,D> require the cumbersome and error-prone "evaluation" of a type member using a meta-programming style that predates the invention of template aliases. Thus, multiplying three ratios a, b, and c requires the expression:
ratio_multiply<a, ratio_multiply<b, c>::type>::type
The simpler expression:
ratio_multiply<a, ratio_multiply<b, c>>
Could be used by if template aliases were employed in the definitions.
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: + msg4382 |
2010-10-21 18:28:33 | admin | set | messages: + msg4381 |
2010-10-21 18:28:33 | admin | set | messages: + msg4380 |
2010-10-21 18:28:33 | admin | set | messages: + msg4379 |
2010-10-21 18:28:33 | admin | set | messages: + msg4378 |
2010-10-21 18:28:33 | admin | set | messages: + msg4377 |
2010-10-21 18:28:33 | admin | set | messages: + msg4376 |
2008-10-07 00:00:00 | admin | create |