tmp/tmpe70_60ru/{from.md → to.md}
RENAMED
|
@@ -1,83 +1,82 @@
|
|
| 1 |
### CV-qualifiers <a id="basic.type.qualifier">[[basic.type.qualifier]]</a>
|
| 2 |
|
| 3 |
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`
|
| 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 type of an object
|
| 9 |
-
[[intro.object]]
|
| 10 |
-
*decl-specifier-seq*
|
| 11 |
-
[[dcl.
|
| 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
|
| 16 |
-
- A *volatile object* is an object of type `volatile T`
|
| 17 |
-
|
| 18 |
- A *const volatile object* is an object of type `const volatile T`, a
|
| 19 |
-
non-mutable subobject of
|
| 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
|
| 26 |
|
| 27 |
-
|
| 28 |
-
cv-qualifiers (if any) of the types from which it is
|
| 29 |
-
|
| 30 |
-
[[dcl.array]]).
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.
|
| 37 |
-
|
| 38 |
-
constitute this ordering.
|
| 39 |
|
| 40 |
-
**Table: Relations on `const` and `volatile`** <a id="
|
| 41 |
|
| 42 |
| | | |
|
| 43 |
| --------------- | --- | ---------------- |
|
| 44 |
| no cv-qualifier | < | `const` |
|
| 45 |
| no cv-qualifier | < | `volatile` |
|
| 46 |
| no cv-qualifier | < | `const volatile` |
|
| 47 |
| `const` | < | `const volatile` |
|
| 48 |
| `volatile` | < | `const volatile` |
|
| 49 |
|
| 50 |
|
| 51 |
-
In this
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
|
| 57 |
-
[*Example
|
| 58 |
no top-level cv-qualifiers. The type corresponding to the *type-id*
|
| 59 |
`volatile int * const` has the top-level cv-qualifier `const`. For a
|
| 60 |
class type `C`, the type corresponding to the *type-id*
|
| 61 |
`void (C::* volatile)(int) const` has the top-level cv-qualifier
|
| 62 |
`volatile`. — *end example*]
|
| 63 |
|
| 64 |
-
Cv-qualifiers applied to an array type attach to the underlying element
|
| 65 |
-
type, so the notation “cv `T`”, where `T` is an array type, refers to an
|
| 66 |
-
array whose elements are so-qualified. An array type whose elements are
|
| 67 |
-
cv-qualified is also considered to have the same cv-qualifications as
|
| 68 |
-
its elements.
|
| 69 |
-
|
| 70 |
-
[*Example 2*:
|
| 71 |
-
|
| 72 |
-
``` cpp
|
| 73 |
-
typedef char CA[5];
|
| 74 |
-
typedef const char CC;
|
| 75 |
-
CC arr1[5] = { 0 };
|
| 76 |
-
const CA arr2 = { 0 };
|
| 77 |
-
```
|
| 78 |
-
|
| 79 |
-
The type of both `arr1` and `arr2` is “array of 5 `const char`”, and the
|
| 80 |
-
array type is considered to be const-qualified.
|
| 81 |
-
|
| 82 |
-
— *end example*]
|
| 83 |
-
|
|
|
|
| 1 |
### CV-qualifiers <a id="basic.type.qualifier">[[basic.type.qualifier]]</a>
|
| 2 |
|
| 3 |
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 type of an object
|
| 9 |
+
[[intro.object]] includes the *cv-qualifier*s specified in the
|
| 10 |
+
*decl-specifier-seq* [[dcl.spec]], *declarator* [[dcl.decl]], *type-id*
|
| 11 |
+
[[dcl.name]], or *new-type-id* [[expr.new]] when the object is created.
|
|
|
|
| 12 |
|
| 13 |
- A *const object* is an object of type `const T` or a non-mutable
|
| 14 |
+
subobject of a const object.
|
| 15 |
+
- A *volatile object* is an object of type `volatile T` or a subobject
|
| 16 |
+
of a volatile object.
|
| 17 |
- A *const volatile object* is an object of type `const volatile T`, a
|
| 18 |
+
non-mutable subobject of a const volatile object, a const subobject of
|
| 19 |
+
a volatile object, or a non-mutable volatile subobject of a const
|
| 20 |
object.
|
| 21 |
|
| 22 |
The cv-qualified or cv-unqualified versions of a type are distinct
|
| 23 |
types; however, they shall have the same representation and alignment
|
| 24 |
+
requirements [[basic.align]].[^25]
|
| 25 |
|
| 26 |
+
Except for array types, a compound type [[basic.compound]] is not
|
| 27 |
+
cv-qualified by the cv-qualifiers (if any) of the types from which it is
|
| 28 |
+
compounded.
|
|
|
|
| 29 |
|
| 30 |
+
An array type whose elements are cv-qualified is also considered to have
|
| 31 |
+
the same cv-qualifications as its elements.
|
| 32 |
+
|
| 33 |
+
[*Note 1*: Cv-qualifiers applied to an array type attach to the
|
| 34 |
+
underlying element type, so the notation “cv `T`”, where `T` is an array
|
| 35 |
+
type, refers to an array whose elements are so-qualified
|
| 36 |
+
[[dcl.array]]. — *end note*]
|
| 37 |
+
|
| 38 |
+
[*Example 1*:
|
| 39 |
+
|
| 40 |
+
``` cpp
|
| 41 |
+
typedef char CA[5];
|
| 42 |
+
typedef const char CC;
|
| 43 |
+
CC arr1[5] = { 0 };
|
| 44 |
+
const CA arr2 = { 0 };
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
The type of both `arr1` and `arr2` is “array of 5 `const char`”, and the
|
| 48 |
+
array type is considered to be const-qualified.
|
| 49 |
+
|
| 50 |
+
— *end example*]
|
| 51 |
+
|
| 52 |
+
[*Note 2*: See [[dcl.fct]] and [[class.this]] regarding function
|
| 53 |
+
types that have *cv-qualifier*s. — *end note*]
|
| 54 |
|
| 55 |
There is a partial ordering on cv-qualifiers, so that a type can be said
|
| 56 |
+
to be *more cv-qualified* than another. [[basic.type.qualifier.rel]]
|
| 57 |
+
shows the relations that constitute this ordering.
|
|
|
|
| 58 |
|
| 59 |
+
**Table: Relations on `const` and `volatile`** <a id="basic.type.qualifier.rel">[basic.type.qualifier.rel]</a>
|
| 60 |
|
| 61 |
| | | |
|
| 62 |
| --------------- | --- | ---------------- |
|
| 63 |
| no cv-qualifier | < | `const` |
|
| 64 |
| no cv-qualifier | < | `volatile` |
|
| 65 |
| no cv-qualifier | < | `const volatile` |
|
| 66 |
| `const` | < | `const volatile` |
|
| 67 |
| `volatile` | < | `const volatile` |
|
| 68 |
|
| 69 |
|
| 70 |
+
In this document, the notation cv (or *cv1*, *cv2*, etc.), used in the
|
| 71 |
+
description of types, represents an arbitrary set of cv-qualifiers,
|
| 72 |
+
i.e., one of {`const`}, {`volatile`}, {`const`, `volatile`}, or the
|
| 73 |
+
empty set. For a type cv `T`, the *top-level cv-qualifiers* of that type
|
| 74 |
+
are those denoted by cv.
|
| 75 |
|
| 76 |
+
[*Example 2*: The type corresponding to the *type-id* `const int&` has
|
| 77 |
no top-level cv-qualifiers. The type corresponding to the *type-id*
|
| 78 |
`volatile int * const` has the top-level cv-qualifier `const`. For a
|
| 79 |
class type `C`, the type corresponding to the *type-id*
|
| 80 |
`void (C::* volatile)(int) const` has the top-level cv-qualifier
|
| 81 |
`volatile`. — *end example*]
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|