tmp/tmpm2b8uaw1/{from.md → to.md}
RENAMED
|
@@ -1,52 +1,60 @@
|
|
| 1 |
## Initializer lists <a id="support.initlist">[[support.initlist]]</a>
|
| 2 |
|
| 3 |
The header `<initializer_list>` defines a class template and several
|
| 4 |
support functions related to list-initialization (see
|
| 5 |
-
[[dcl.init.list]]).
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
``` cpp
|
| 8 |
namespace std {
|
| 9 |
template<class E> class initializer_list {
|
| 10 |
public:
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
|
| 19 |
constexpr initializer_list() noexcept;
|
| 20 |
|
| 21 |
constexpr size_t size() const noexcept; // number of elements
|
| 22 |
constexpr const E* begin() const noexcept; // first element
|
| 23 |
constexpr const E* end() const noexcept; // one past the last element
|
| 24 |
};
|
| 25 |
|
| 26 |
-
// [support.initlist.range] initializer list range access
|
| 27 |
template<class E> constexpr const E* begin(initializer_list<E> il) noexcept;
|
| 28 |
template<class E> constexpr const E* end(initializer_list<E> il) noexcept;
|
| 29 |
}
|
| 30 |
```
|
| 31 |
|
| 32 |
An object of type `initializer_list<E>` provides access to an array of
|
| 33 |
-
objects of type `const E`.
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
### Initializer list constructors <a id="support.initlist.cons">[[support.initlist.cons]]</a>
|
| 40 |
|
| 41 |
``` cpp
|
| 42 |
constexpr initializer_list() noexcept;
|
| 43 |
```
|
| 44 |
|
| 45 |
-
*Effects:*
|
| 46 |
|
| 47 |
-
`size() == 0`
|
| 48 |
|
| 49 |
### Initializer list access <a id="support.initlist.access">[[support.initlist.access]]</a>
|
| 50 |
|
| 51 |
``` cpp
|
| 52 |
constexpr const E* begin() const noexcept;
|
|
@@ -58,11 +66,11 @@ identical.
|
|
| 58 |
|
| 59 |
``` cpp
|
| 60 |
constexpr const E* end() const noexcept;
|
| 61 |
```
|
| 62 |
|
| 63 |
-
*Returns:* `begin() + size()`
|
| 64 |
|
| 65 |
``` cpp
|
| 66 |
constexpr size_t size() const noexcept;
|
| 67 |
```
|
| 68 |
|
|
|
|
| 1 |
## Initializer lists <a id="support.initlist">[[support.initlist]]</a>
|
| 2 |
|
| 3 |
The header `<initializer_list>` defines a class template and several
|
| 4 |
support functions related to list-initialization (see
|
| 5 |
+
[[dcl.init.list]]). All functions specified in this subclause are
|
| 6 |
+
signal-safe ([[csignal.syn]]).
|
| 7 |
+
|
| 8 |
+
### Header `<initializer_list>` synopsis <a id="initializer_list.syn">[[initializer_list.syn]]</a>
|
| 9 |
|
| 10 |
``` cpp
|
| 11 |
namespace std {
|
| 12 |
template<class E> class initializer_list {
|
| 13 |
public:
|
| 14 |
+
using value_type = E;
|
| 15 |
+
using reference = const E&;
|
| 16 |
+
using const_reference = const E&;
|
| 17 |
+
using size_type = size_t;
|
| 18 |
|
| 19 |
+
using iterator = const E*;
|
| 20 |
+
using const_iterator = const E*;
|
| 21 |
|
| 22 |
constexpr initializer_list() noexcept;
|
| 23 |
|
| 24 |
constexpr size_t size() const noexcept; // number of elements
|
| 25 |
constexpr const E* begin() const noexcept; // first element
|
| 26 |
constexpr const E* end() const noexcept; // one past the last element
|
| 27 |
};
|
| 28 |
|
| 29 |
+
// [support.initlist.range], initializer list range access
|
| 30 |
template<class E> constexpr const E* begin(initializer_list<E> il) noexcept;
|
| 31 |
template<class E> constexpr const E* end(initializer_list<E> il) noexcept;
|
| 32 |
}
|
| 33 |
```
|
| 34 |
|
| 35 |
An object of type `initializer_list<E>` provides access to an array of
|
| 36 |
+
objects of type `const E`.
|
| 37 |
+
|
| 38 |
+
[*Note 1*: A pair of pointers or a pointer plus a length would be
|
| 39 |
+
obvious representations for `initializer_list`. `initializer_list` is
|
| 40 |
+
used to implement initializer lists as specified in [[dcl.init.list]].
|
| 41 |
+
Copying an initializer list does not copy the underlying
|
| 42 |
+
elements. — *end note*]
|
| 43 |
+
|
| 44 |
+
If an explicit specialization or partial specialization of
|
| 45 |
+
`initializer_list` is declared, the program is ill-formed.
|
| 46 |
|
| 47 |
### Initializer list constructors <a id="support.initlist.cons">[[support.initlist.cons]]</a>
|
| 48 |
|
| 49 |
``` cpp
|
| 50 |
constexpr initializer_list() noexcept;
|
| 51 |
```
|
| 52 |
|
| 53 |
+
*Effects:* Constructs an empty `initializer_list` object.
|
| 54 |
|
| 55 |
+
*Postconditions:* `size() == 0`.
|
| 56 |
|
| 57 |
### Initializer list access <a id="support.initlist.access">[[support.initlist.access]]</a>
|
| 58 |
|
| 59 |
``` cpp
|
| 60 |
constexpr const E* begin() const noexcept;
|
|
|
|
| 66 |
|
| 67 |
``` cpp
|
| 68 |
constexpr const E* end() const noexcept;
|
| 69 |
```
|
| 70 |
|
| 71 |
+
*Returns:* `begin() + size()`.
|
| 72 |
|
| 73 |
``` cpp
|
| 74 |
constexpr size_t size() const noexcept;
|
| 75 |
```
|
| 76 |
|