From Jason Turner

[valarray.access]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp8c8sd2iv/{from.md → to.md} +20 -19
tmp/tmp8c8sd2iv/{from.md → to.md} RENAMED
@@ -1,33 +1,34 @@
1
  #### `valarray` element access <a id="valarray.access">[[valarray.access]]</a>
2
 
3
  ``` cpp
4
- const T& operator[](size_t) const;
5
- T& operator[](size_t);
6
  ```
7
 
8
- The subscript operator returns a reference to the corresponding element
9
- of the array.
10
 
11
- Thus, the expression `(a[i] = q, a[i]) == q` evaluates as true for any
12
- non-constant `valarray<T> a`, any `T q`, and for any `size_t i` such
13
- that the value of `i` is less than the length of `a`.
14
 
15
- The expression `&a[i+j] == &a[i] + j` evaluates as true for all
16
- `size_t i` and `size_t j` such that `i+j` is less than the length of the
17
- array `a`.
 
18
 
19
- Likewise, the expression `&a[i] != &b[j]` evaluates as `true` for any
20
- two arrays `a` and `b` and for any `size_t i` and `size_t j` such that
21
- `i` is less than the length of `a` and `j` is less than the length of
22
- `b`. This property indicates an absence of aliasing and may be used to
23
- advantage by optimizing compilers.[^13]
 
 
 
 
 
 
 
24
 
25
  The reference returned by the subscript operator for an array shall be
26
  valid until the member function
27
  `resize(size_t, T)` ([[valarray.members]]) is called for that array or
28
  until the lifetime of that array ends, whichever happens first.
29
 
30
- If the subscript operator is invoked with a `size_t` argument whose
31
- value is not less than the length of the array, the behavior is
32
- undefined.
33
-
 
1
  #### `valarray` element access <a id="valarray.access">[[valarray.access]]</a>
2
 
3
  ``` cpp
4
+ const T& operator[](size_t n) const;
5
+ T& operator[](size_t n);
6
  ```
7
 
8
+ *Requires:* `n < size()`.
 
9
 
10
+ *Returns:* A reference to the corresponding element of the array.
 
 
11
 
12
+ [*Note 1*: The expression `(a[i] = q, a[i]) == q` evaluates to `true`
13
+ for any non-constant `valarray<T> a`, any `T q`, and for any `size_t i`
14
+ such that the value of `i` is less than the length of
15
+ `a`. — *end note*]
16
 
17
+ *Remarks:* The expression `&a[i+j] == &a[i] + j` evaluates to `true` for
18
+ all `size_t i` and `size_t j` such that `i+j < a.size()`.
19
+
20
+ The expression `&a[i] != &b[j]` evaluates to `true` for any two arrays
21
+ `a` and `b` and for any `size_t i` and `size_t j` such that
22
+ `i < a.size()` and `j < b.size()`.
23
+
24
+ [*Note 2*: This property indicates an absence of aliasing and may be
25
+ used to advantage by optimizing compilers. Compilers may take advantage
26
+ of inlining, constant propagation, loop fusion, tracking of pointers
27
+ obtained from `operator new`, and other techniques to generate efficient
28
+ `valarray`s. — *end note*]
29
 
30
  The reference returned by the subscript operator for an array shall be
31
  valid until the member function
32
  `resize(size_t, T)` ([[valarray.members]]) is called for that array or
33
  until the lifetime of that array ends, whichever happens first.
34