8
8
| ---- | ------ | ----------- |
9
9
| Jan 16, 2025 | Carson Radtke (Microsoft) | Initial draft. |
10
10
11
- A specification to guide the implementation of ` gsl::dyn_array ` . This is a dynamic array
12
- that is intended to be a replacement for slinging around raw pointers and sizes.
13
- Notably, it _ owns_ all of its elements. It can be thought of like a...
11
+ ` gsl::dyn_array ` is a dynamic array that is intended to be a replacement for slinging
12
+ around raw pointers and sizes. Notably, it _ owns_ all of its elements. It should replace
13
+ the following idioms:
14
+
15
+ * Replace ` new T[n] ` with ` gsl::dyn_array<T>(n) ` .
16
+ * Replace both ` foo(T*, size_t) ` and ` foo(unique_ptr<T[]>&, size_t) ` with
17
+ ` foo(gsl::dyn_array<T>&) ` .
18
+
19
+ It can be thought of like a...
14
20
15
21
* ` std::array ` except the size is specified at runtime.
16
22
* ` std::vector ` except it can neither shrink nor grow.
17
23
18
24
### Container Named Requirements
19
25
In order to allow element access using iterators and to align with various container
20
- idioms, ` gsl::dyn_array ` should satisfy the following named requirements:
26
+ idioms for ` std:: ` algorithms, ` gsl::dyn_array ` should satisfy the following named
27
+ requirements:
21
28
22
29
* Container ([ link] ( https://en.cppreference.com/w/cpp/named_req/Container ) )
23
30
* ReversibleContainer ([ link] ( https://en.cppreference.com/w/cpp/named_req/ReversibleContainer ) )
@@ -29,9 +36,14 @@ idioms, `gsl::dyn_array` should satisfy the following named requirements:
29
36
In addition to the constructors required by the named requirements (default, copy, and
30
37
move), ` gsl::dyn_array ` will support the following constructors:
31
38
39
+ * Construct a ` dyn_array ` with ` n ` default constructed elements:
40
+ ``` c++
41
+ constexpr explicit dyn_array (size_t n, const Allocator & alloc = Allocator());
42
+ ```
43
+
32
44
* Construct a `dyn_array` with `n` elements, each copy constructed from `arg`:
33
45
```c++
34
- constexpr explicit dyn_array (size_t n, const T& arg, const Allocator & alloc = Allocator());
46
+ constexpr dyn_array(size_t n, const T& arg, const Allocator & alloc = Allocator());
35
47
```
36
48
37
49
* Construct a ` dyn_array ` with elements from the range ` [first, last) ` :
0 commit comments