Doc. no.: | N4389 |
---|---|
Date: | 2015-02-23 |
Project: | Programming Language C++, Library Working Group |
Revises: | N4334 |
Reply-to: | Zhihao Yuan <zy at miator dot net> |
Rationale see https://issues.isocpp.org/show_bug.cgi?id=51.
This paper consolidates N4334 with LWG’s wording improvements to <ratio>
.
This wording is relative to N4296.
Modify 20.10.2 [meta.type.synop]:
namespace std {
// 20.10.3, helper class:
template <class T, T v> struct integral_constant;
…
Modify 20.10.3 [meta.help]:
namespace std {
template <class T, T v>
struct integral_constant {
…
};
}
The class template
integral_constant
, alias template bool_constant, and its associated typedefstrue_type
andfalse_type
are used as base classes to define the interface for various type traits.
Modify Table 49 in 20.10.4.3 [meta.unary.prop]:
template <class T> struct is_signed; |
If is_arithmetic<T>::value is true, the same result as
|
|
template <class T> struct is_unsigned; |
If is_arithmetic<T>::value is true, the same result as
|
Modify 20.11.5 [ratio.comparison]:
template <class R1, class R2> struct ratio_equal
If R1::num == R2::num and R1::den == R2::den, ratio_equal<R1, R2> shall be derived from integral_constant<bool, true> ; otherwise it shall be derived from integral_constant<bool, false> .
template <class R1, class R2> struct ratio_not_equal
template <class R1, class R2> struct ratio_less
If
R1::num * R2::den < R2::num * R1::denR1::num × R2::den is less than R2::num × R1::den ,ratio_less<R1, R2>
shall be derived fromintegral_constant<bool, true>bool_constant<true> ; otherwise it shall be derived fromintegral_constant<bool, false>bool_constant<false> . Implementations may use other algorithms to compute this relationship to avoid overflow. If overflow occurs, the program is ill-formed.
Thanks Tony Van Eerd for bringing this to the reflector.