From Jason Turner

[basic.type.qualifier]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpe5zr9bkp/{from.md → to.md} +29 -19
tmp/tmpe5zr9bkp/{from.md → to.md} RENAMED
@@ -4,32 +4,33 @@ A type mentioned in  [[basic.fundamental]] and  [[basic.compound]] is a
4
  *cv-unqualified type*. Each type which is a cv-unqualified complete or
5
  incomplete object type or is `void` ([[basic.types]]) has three
6
  corresponding cv-qualified versions of its type: a *const-qualified*
7
  version, a *volatile-qualified* version, and a
8
  *const-volatile-qualified* version. The term *object type* (
9
- [[intro.object]]) includes the cv-qualifiers specified when the object
10
- is created. The presence of a `const` specifier in a
11
- *decl-specifier-seq* declares an object of *const-qualified object
12
- type*; such object is called a *const object*. The presence of a
13
- `volatile` specifier in a *decl-specifier-seq* declares an object of
14
- *volatile-qualified* *object type*; such object is called a *volatile
15
- object*. The presence of both *cv-qualifiers* in a *decl-specifier-seq*
16
- declares an object of *const-volatile-qualified object type*; such
17
- object is called a *const volatile object*. The cv-qualified or
18
- cv-unqualified versions of a type are distinct types; however, they
19
- shall have the same representation and alignment requirements (
20
- [[basic.types]]).[^27]
 
 
 
 
 
21
 
22
  A compound type ([[basic.compound]]) is not cv-qualified by the
23
  cv-qualifiers (if any) of the types from which it is compounded. Any
24
  cv-qualifiers applied to an array type affect the array element type,
25
  not the array type ([[dcl.array]]).
26
 
27
- Each non-static, non-mutable, non-reference data member of a
28
- const-qualified class object is const-qualified, each non-static,
29
- non-reference data member of a volatile-qualified class object is
30
- volatile-qualified and similarly for members of a const-volatile class.
31
  See  [[dcl.fct]] and  [[class.this]] regarding function types that have
32
  *cv-qualifier*s.
33
 
34
  There is a partial ordering on cv-qualifiers, so that a type can be said
35
  to be *more cv-qualified* than another. Table 
@@ -51,9 +52,18 @@ In this International Standard, the notation *cv* (or *cv1*, *cv2*,
51
  etc.), used in the description of types, represents an arbitrary set of
52
  cv-qualifiers, i.e., one of {`const`}, {`volatile`}, {`const`,
53
  `volatile`}, or the empty set. Cv-qualifiers applied to an array type
54
  attach to the underlying element type, so the notation “*cv* `T`,” where
55
  `T` is an array type, refers to an array whose elements are
56
- so-qualified. Such array types can be said to be more (or less)
57
- cv-qualified than other types based on the cv-qualification of the
58
- underlying element types.
 
 
 
 
 
 
 
 
 
59
 
 
4
  *cv-unqualified type*. Each type which is a cv-unqualified complete or
5
  incomplete object type or is `void` ([[basic.types]]) has three
6
  corresponding cv-qualified versions of its type: a *const-qualified*
7
  version, a *volatile-qualified* version, and a
8
  *const-volatile-qualified* version. The term *object type* (
9
+ [[intro.object]]) includes the cv-qualifiers specified in the
10
+ *decl-specifier-seq* ([[dcl.spec]]), *declarator* (Clause 
11
+ [[dcl.decl]]), *type-id* ([[dcl.name]]), or *new-type-id* (
12
+ [[expr.new]]) when the object is created.
13
+
14
+ - A *const object* is an object of type `const T` or a non-mutable
15
+ subobject of such an object.
16
+ - A *volatile object* is an object of type `volatile T`, a subobject of
17
+ such an object, or a mutable subobject of a const volatile object.
18
+ - A *const volatile object* is an object of type `const volatile T`, a
19
+ non-mutable subobject of such an object, a const subobject of a
20
+ volatile object, or a non-mutable volatile subobject of a const
21
+ object.
22
+
23
+ The cv-qualified or cv-unqualified versions of a type are distinct
24
+ types; however, they shall have the same representation and alignment
25
+ requirements ([[basic.align]]).[^29]
26
 
27
  A compound type ([[basic.compound]]) is not cv-qualified by the
28
  cv-qualifiers (if any) of the types from which it is compounded. Any
29
  cv-qualifiers applied to an array type affect the array element type,
30
  not the array type ([[dcl.array]]).
31
 
 
 
 
 
32
  See  [[dcl.fct]] and  [[class.this]] regarding function types that have
33
  *cv-qualifier*s.
34
 
35
  There is a partial ordering on cv-qualifiers, so that a type can be said
36
  to be *more cv-qualified* than another. Table 
 
52
  etc.), used in the description of types, represents an arbitrary set of
53
  cv-qualifiers, i.e., one of {`const`}, {`volatile`}, {`const`,
54
  `volatile`}, or the empty set. Cv-qualifiers applied to an array type
55
  attach to the underlying element type, so the notation “*cv* `T`,” where
56
  `T` is an array type, refers to an array whose elements are
57
+ so-qualified. An array type whose elements are cv-qualified is also
58
+ considered to have the same cv-qualifications as its elements.
59
+
60
+ ``` cpp
61
+ typedef char CA[5];
62
+ typedef const char CC;
63
+ CC arr1[5] = { 0 };
64
+ const CA arr2 = { 0 };
65
+ ```
66
+
67
+ The type of both `arr1` and `arr2` is “array of 5 `const char`,” and the
68
+ array type is considered to be `const`-qualified.
69