Section: 30.4.1 [time.traits.is.fp] Status: C++11 Submitter: Pete Becker Opened: 2009-01-07 Last modified: 2021-06-06
Priority: Not Prioritized
View all issues with C++11 status.
Discussion:
Related to 953.
[time.traits.is_fp] says that the type Rep "is
assumed to be ... a class emulating an integral type." What are the
requirements for such a type?
[ 2009-05-10 Howard adds: ]
IntegralLike.
[ Batavia (2009-05): ]
As with issue 953, we recommend this issue be addressed in the context of providing concepts for the entire
threadheader.We look forward to proposed wording.
Move to Open.
[ 2009-08-01 Howard adds: ]
I have surveyed all clauses of [time.traits.duration_values], 30.4.3 [time.traits.specializations] and 30.5 [time.duration]. I can not find any clause which involves the use of a
duration::reptype where the requirements on thereptype are not clearly spelled out. These requirements were carefully crafted to allow any arithmetic type, or any user-defined type emulating an arithmetic type.Indeed,
treat_as_floating_pointbecomes completely superfluous ifduration::repcan never be a class type.There will be some
Reptypes which will not meet the requirements of everydurationoperation. This is no different than the fact thatvector<T>can easily be used for typesTwhich are notDefaultConstructible, even though some members ofvector<T>requireTto beDefaultConstructible. This is why the requirements onRepare specified for each operation individually.In [time.traits.is_fp] p1:
template <class Rep> struct treat_as_floating_point : is_floating_point<Rep> { };The
durationtemplate uses thetreat_as_floating_pointtrait to help determine if adurationobject can be converted to anotherdurationwith a different tick period. Iftreat_as_floating_point<Rep>::valueistrue, thenRepis a floating-point type and implicit conversions are allowed amongdurations. Otherwise, the implicit convertibility depends on the tick periods of thedurations. IfRepis a class type which emulates a floating-point type, the author ofRepcan specializetreat_as_floating_pointso thatdurationwill treat thisRepas if it were a floating-point type. OtherwiseRepis assumed to be an integral type or a class emulating an integral type.The phrases "a class type which emulates a floating-point type" and "a class emulating an integral type" are clarifying phrases which refer to the summation of all the requirements on the
Reptype specified in detail elsewhere (and should not be repeated here).This specification has been implemented, now multiple times, and the experience has been favorable. The current specification clearly specifies the requirements at each point of use (though I'd be happy to fix any place I may have missed, but none has been pointed out).
I am amenable to improved wording of this paragraph (and any others), but do not have any suggestions for improved wording at this time. I am strongly opposed to changes which would significantly alter the semantics of the specification under 30 [time] without firmly grounded and documented rationale, example implementation, testing, and user experience which relates a positive experience.
I recommend NAD unless someone wants to produce some clarifying wording.
[ 2009-10 Santa Cruz: ]
Stefanus to provide wording to turn this into a note.
[ 2010-02-11 Stefanus provided wording. ]
[ 2010 Rapperswil: ]
Move to Ready.
[ Adopted at 2010-11 Batavia ]
Proposed resolution:
Change [time.traits.is_fp]/1:
1 The
durationtemplate uses thetreat_as_floating_pointtrait to help determine if adurationobject can be converted to anotherdurationwith a different tick period. Iftreat_as_floating_point<Rep>::valueistrue, thenimplicit conversions are allowed amongRepis a floating-point type anddurations. Otherwise, the implicit convertibility depends on the tick periods of thedurations.If[Note: The intention of this trait is to indicate whether a given class behaves like a floating point type, and thus allows division of one value by another with acceptable loss of precision. IfRepis a class type which emulates a floating-point type, the author ofRepcan specializetreat_as_floating_pointso that duration will treat thisRepas if it were a floating-point type. OtherwiseRepis assumed to be an integral type or a class emulating an integral type.treat_as_floating_point<Rep>::valueisfalse,Repwill be treated as if it behaved like an integral type for the purpose of these conversions. — end note]