88| ---- | ------ | ----------- |
99| Jan 16, 2025 | Carson Radtke (Microsoft) | Initial draft. |
1010
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...
1420
1521* ` std::array ` except the size is specified at runtime.
1622* ` std::vector ` except it can neither shrink nor grow.
1723
1824### Container Named Requirements
1925In 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:
2128
2229* Container ([ link] ( https://en.cppreference.com/w/cpp/named_req/Container ) )
2330* 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:
2936In addition to the constructors required by the named requirements (default, copy, and
3037move), ` gsl::dyn_array ` will support the following constructors:
3138
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+
3244* Construct a `dyn_array` with `n` elements, each copy constructed from `arg`:
3345```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());
3547```
3648
3749* Construct a ` dyn_array ` with elements from the range ` [first, last) ` :
0 commit comments