Title
numeric_limits<const T>
Status
cd1
Section
[numeric.limits]
Submitter
Martin Sebor

Created on 2006-02-19.00:00:00 last changed 172 months ago

Messages

Date: 2010-10-21.18:28:33

[ Portland: Martin will clarify that user-defined types get cv-specializations automatically. ]

Date: 2010-10-21.18:28:33

Proposed resolution:

Add to the synopsis of the <limits> header, immediately below the declaration of the primary template, the following:


template <class T> class numeric_limits<const T>;
template <class T> class numeric_limits<volatile T>;
template <class T> class numeric_limits<const volatile T>;

Add a new paragraph to the end of [numeric.limits], with the following text:

-new-para- The value of each member of a numeric_limits specialization on a cv-qualified T is equal to the value of the same member of numeric_limits<T>.

Date: 2006-02-19.00:00:00

[limits], p2 requires implementations to provide specializations of the numeric_limits template for each scalar type. While this could be interepreted to include cv-qualified forms of such types such an interepretation is not reflected in the synopsis of the <limits> header.

The absence of specializations of the template on cv-qualified forms of fundamental types makes numeric_limits difficult to use in generic code where the constness (or volatility) of a type is not always immediately apparent. In such contexts, the primary template ends up being instantiated instead of the provided specialization, typically yielding unexpected behavior.

Require that specializations of numeric_limits on cv-qualified fundamental types have the same semantics as those on the unqualifed forms of the same types.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg3059
2010-10-21 18:28:33adminsetmessages: + msg3058
2006-02-19 00:00:00admincreate