Created on 2010-03-20.00:00:00 last changed 131 months ago
[Moved to DR at the October, 2012 meeting.]
Proposed resolution (December, 2011):
Change 6.8.5 [basic.type.qualifier] paragraph 5 as follows:
...Cv-qualifiers applied to an array type attach to the underlying element type, so the notation “cv T,” where T is an array type, refers to an array whose elements are so-qualified.Such array types can be said to be more (or less) cv-qualified than other types based on the cv-qualification of the underlying element types.An array type whose elements are cv-qualified is also considered to have the same cv-qualification as its elements. [Example:typedef char CA[5]; typedef const char CC; CC arr1[5] = { 0 }; const CA arr2 = { 0 };The type of both arr1 and arr2 is “array of 5 const char,” and the array type is considered to be const-qualified. —end example]
Change 7.2.1 [basic.lval] paragraph 4 as follows:
Class and array prvalues can have cv-qualified types;non-classother prvalues always have cv-unqualified types. Unless otherwise indicated...
In spite of the resolution of issue 112, the exact relationship between cv-qualifiers and array types is not clear. There does not appear to be a definitive normative statement answering the question of whether an array with a const-qualified element type is itself const-qualified; the statement in 6.8.5 [basic.type.qualifier] paragraph 5,
Cv-qualifiers applied to an array type attach to the underlying element type, so the notation “cv T,” where T is an array type, refers to an array whose elements are so-qualified. Such array types can be said to be more (or less) cv-qualified than other types based on the cv-qualification of the underlying element types.
hints at an answer but is hardly decisive. For example, is the following example well-formed?
template <class T> struct is_const { static const bool value = false; }; template <class T> struct is_const<const T> { static const bool value = true; }; template <class T> void f(T &) { char checker[is_const<T>::value]; } int const arr[1] = {}; int main() { f(arr); }
Also, when 7.2.1 [basic.lval] paragraph 4 says,
Class prvalues can have cv-qualified types; non-class prvalues always have cv-unqualified types.
does this apply to array rvalues, as it appears? That is, given
struct S { const int arr[10]; };
is the array rvalue S().arr an array of int or an array of const int?
(The more general question is, when the Standard refers to non-class types, should it be considered to include array types? Or perhaps only arrays of non-class types?)
History | |||
---|---|---|---|
Date | User | Action | Args |
2014-03-03 00:00:00 | admin | set | status: drwp -> cd3 |
2013-05-03 00:00:00 | admin | set | status: dr -> drwp |
2012-11-03 00:00:00 | admin | set | messages: + msg4122 |
2012-11-03 00:00:00 | admin | set | status: ready -> dr |
2012-02-27 00:00:00 | admin | set | status: tentatively ready -> ready |
2012-01-17 00:00:00 | admin | set | messages: + msg3597 |
2012-01-17 00:00:00 | admin | set | status: drafting -> tentatively ready |
2010-08-23 00:00:00 | admin | set | status: open -> drafting |
2010-03-20 00:00:00 | admin | create |