Skip to content

Commit 15f45f9

Browse files
committed
some wording improvements
1 parent 4dea8f9 commit 15f45f9

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

docs/dyn_array.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,23 @@
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
1925
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:
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:
2936
In addition to the constructors required by the named requirements (default, copy, and
3037
move), `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

Comments
 (0)