tmp/tmpzwnm4qqn/{from.md → to.md}
RENAMED
|
@@ -15,35 +15,47 @@ requirements:[^1]
|
|
| 15 |
- If `T` is a class, it has a public destructor;
|
| 16 |
- If `T` is a class, it has a public assignment operator whose signature
|
| 17 |
is either `T& T::operator=(const T&)` or `T& T::operator=(T)`
|
| 18 |
- If `T` is a class, its assignment operator, copy and default
|
| 19 |
constructors, and destructor shall correspond to each other in the
|
| 20 |
-
following sense:
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
differences in the semantics of initialization versus assignment. This
|
| 27 |
gives an implementation considerable flexibility in how arrays are
|
| 28 |
-
initialized.
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
- If `T` is a class, it does not overload unary `operator&`.
|
| 38 |
|
| 39 |
If any operation on `T` throws an exception the effects are undefined.
|
| 40 |
|
| 41 |
In addition, many member and related functions of `valarray<T>` can be
|
| 42 |
successfully instantiated and will exhibit well-defined behavior if and
|
| 43 |
only if `T` satisfies additional requirements specified for each such
|
| 44 |
member or related function.
|
| 45 |
|
| 46 |
-
It is valid to instantiate `valarray<complex>`, but
|
| 47 |
-
not be successfully instantiated for
|
| 48 |
-
`complex` does not have any ordering
|
|
|
|
| 49 |
|
|
|
|
| 15 |
- If `T` is a class, it has a public destructor;
|
| 16 |
- If `T` is a class, it has a public assignment operator whose signature
|
| 17 |
is either `T& T::operator=(const T&)` or `T& T::operator=(T)`
|
| 18 |
- If `T` is a class, its assignment operator, copy and default
|
| 19 |
constructors, and destructor shall correspond to each other in the
|
| 20 |
+
following sense:
|
| 21 |
+
- Initialization of raw storage using the copy constructor on the
|
| 22 |
+
value of `T()`, however obtained, is semantically equivalent to
|
| 23 |
+
value-initialization of the same raw storage.
|
| 24 |
+
- Initialization of raw storage using the default constructor,
|
| 25 |
+
followed by assignment, is semantically equivalent to initialization
|
| 26 |
+
of raw storage using the copy constructor.
|
| 27 |
+
- Destruction of an object, followed by initialization of its raw
|
| 28 |
+
storage using the copy constructor, is semantically equivalent to
|
| 29 |
+
assignment to the original object.
|
| 30 |
+
|
| 31 |
+
\[*Note 1*:
|
| 32 |
+
This rule states, in part, that there shall not be any subtle
|
| 33 |
differences in the semantics of initialization versus assignment. This
|
| 34 |
gives an implementation considerable flexibility in how arrays are
|
| 35 |
+
initialized.
|
| 36 |
+
\[*Example 1*:
|
| 37 |
+
An implementation is allowed to initialize a `valarray` by allocating
|
| 38 |
+
storage using the `new` operator (which implies a call to the default
|
| 39 |
+
constructor for each element) and then assigning each element its
|
| 40 |
+
value. Or the implementation can allocate raw storage and use the copy
|
| 41 |
+
constructor to initialize each element.
|
| 42 |
+
— *end example*]
|
| 43 |
+
If the distinction between initialization and assignment is important
|
| 44 |
+
for a class, or if it fails to satisfy any of the other conditions
|
| 45 |
+
listed above, the programmer should use `vector` ([[vector]]) instead
|
| 46 |
+
of `valarray` for that class.
|
| 47 |
+
— *end note*]
|
| 48 |
- If `T` is a class, it does not overload unary `operator&`.
|
| 49 |
|
| 50 |
If any operation on `T` throws an exception the effects are undefined.
|
| 51 |
|
| 52 |
In addition, many member and related functions of `valarray<T>` can be
|
| 53 |
successfully instantiated and will exhibit well-defined behavior if and
|
| 54 |
only if `T` satisfies additional requirements specified for each such
|
| 55 |
member or related function.
|
| 56 |
|
| 57 |
+
[*Example 2*: It is valid to instantiate `valarray<complex>`, but
|
| 58 |
+
`operator>()` will not be successfully instantiated for
|
| 59 |
+
`valarray<complex>` operands, since `complex` does not have any ordering
|
| 60 |
+
operators. — *end example*]
|
| 61 |
|