Skip to content

Commit a41191f

Browse files
Tyler WhitneyTyler Whitney
authored andcommitted
a little wordsmithing
1 parent a67cefb commit a41191f

3 files changed

Lines changed: 52 additions & 50 deletions

File tree

docs/standard-library/span-class.md

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ helpviewer_keywords: ["std::span [C++]", "std::span [C++], const_pointer", "std:
77
---
88
# span Class (C++ Standard Library)
99

10-
Provides a lightweight view over a contiguous sequence of objects. A span provides a safe way to iterate over, and index into, objects that are arranged back-to-back in memory (for example, objects stored in a built-in array, `std::array`, or `std::vector`).
10+
Provides a lightweight view over a contiguous sequence of objects. A span provides a safe way to iterate over, and index into, objects that are arranged back-to-back in memory such as objects stored in a built-in array, `std::array`, or `std::vector`.
1111

12-
If you typically access a sequence of back-to-back objects using a pointer and an index, span is a safer, lightweight alternative.
12+
If you typically access a sequence of back-to-back objects using a pointer and an index, a `span` is a safer, lightweight alternative.
1313

14-
A span's size is determined at compile time by specifying it as a template argument, or at runtime by specifying `dynamic_extent`.
14+
The size of a `span` can be set at compile time by specifying it as a template argument, or at runtime by specifying `dynamic_extent`.
1515

1616
## Syntax
1717

@@ -42,30 +42,30 @@ class span;
4242
| [reference](#reference) | The type of a reference to an element. |
4343
| [reverse_iterator](#reverse_iterator) | The type of a reverse iterator for a span. |
4444
| [size_type](#size_type) | The type for the result of the unsigned distance between two elements in the span. |
45-
| [value_type](#value_type) | The type of an element without `const` or `volatile` qualifications. |
45+
| [value_type](#value_type) | The type of an element, without `const` or `volatile` qualifications. |
4646
| **Constructors** | **Description** |
47-
|[span](#span)| Constructs a `span`.|
47+
|[span](#span)| Construct a `span`.|
4848
| **Iterator support** | **Description** |
49-
|[begin](#begin) | Returns an iterator pointing to the first element in the span.|
50-
|[end](#end) | Returns an iterator pointing to the end of the span. |
51-
|[rbegin](#rbegin) | Returns a reverse iterator pointing to the last element of the span; that is, the beginning of the reversed span.|
52-
|[rend](#rend) | Returns a reverse iterator pointing to the front of the span; that is, the end of the reversed span.|
49+
|[begin](#begin) | Get an iterator pointing to the first element in the span.|
50+
|[end](#end) | Get an iterator pointing to the end of the span. |
51+
|[rbegin](#rbegin) | Get a reverse iterator pointing to the last element of the span; that is, the beginning of the reversed span.|
52+
|[rend](#rend) | Get a reverse iterator pointing to the front of the span; that is, the end of the reversed span.|
5353
| **Access elements**| **Description** |
5454
|[back](#back) | Get the last element in the span.|
5555
|[data](#data) | Get the address of the first element in the span.|
5656
|[front](#front) | Get the first element in the span.|
5757
|[operator\[\]](#op_at) | Access an element at a specified position.|
5858
| **Observers** | **Description** |
59-
|[empty](#empty)| Tests whether the span is empty.|
60-
|[size](#size) | Returns the number of elements in the span.|
61-
|[size_bytes](#size_bytes) | Returns the size of the span in bytes.|
59+
|[empty](#empty)| Test whether the span is empty.|
60+
|[size](#size) | Get the number of elements in the span.|
61+
|[size_bytes](#size_bytes) | Get the size of the span in bytes.|
6262
| **Subviews** | **Description**|
6363
| [first](#first_view) | Get a subspan from the front of the span.|
6464
| [last](#last_view) | Get a subspan from the back of the span.|
65-
| [subspan](#sub_view) | Gets a subspan from anywhere in the span.|
65+
| [subspan](#sub_view) | Get a subspan from anywhere in the span.|
6666
| **Operators** | **Description** |
67-
|[span::operator=](#op_eq)| Replaces the span.|
68-
|[span::operator\[\]](#op_at)| Access an element at a specified position. |
67+
|[span::operator=](#op_eq)| Replace the span.|
68+
|[span::operator\[\]](#op_at)| Get the element at the specified position. |
6969
7070
## Remarks
7171
@@ -83,7 +83,7 @@ Unlike `array` or `vector`, a span doesn't "own" the elements inside it. A span
8383
8484
## <a name="back"></a> `span::back`
8585
86-
Returns the last element in the span.
86+
Get the last element in the span.
8787
8888
```cpp
8989
constexpr reference back() const noexcept;
@@ -116,15 +116,15 @@ int main()
116116

117117
## <a name="begin"></a> `span::begin`
118118

119-
Returns an iterator pointing at the first element in the span.
119+
Get an iterator pointing at the first element in the span.
120120

121121
```cpp
122122
constexpr iterator begin() const noexcept;
123123
```
124124

125125
### Return value
126126

127-
An iterator that starts with the first element in the span.
127+
An iterator pointing at the first element in the span.
128128

129129
### Example
130130

@@ -150,7 +150,7 @@ int main()
150150

151151
## <a name="data"></a> `span::data`
152152

153-
Returns a pointer to the beginning of the span data.
153+
Get a pointer to the beginning of the span data.
154154

155155
```cpp
156156
constexpr pointer data() const noexcept;
@@ -183,7 +183,7 @@ int main()
183183

184184
## <a name="difference_type"></a> `span::difference_type`
185185

186-
This type represents the number of elements between two elements in a span.
186+
The number of elements between two elements in a span.
187187

188188
```cpp
189189
using difference_type = std::ptrdiff_t;
@@ -273,21 +273,21 @@ int main()
273273

274274
## <a name="end"></a> `span::end`
275275

276-
Returns an iterator to the end of the span.
276+
Get an iterator to the end of the span.
277277

278278
```cpp
279279
constexpr iterator end() const noexcept;
280280
```
281281

282282
### Return Value
283283

284-
An iterator to just beyond the end of the span.
284+
An iterator pointing just beyond the end of the span.
285285

286286
### Remarks
287287

288288
`end` is used to test whether an iterator has passed the end of its range.
289289

290-
Don't dereference the value returned by the iterator. Use it to identify whether the iterator has reached beyond the last element in the span.
290+
Don't dereference the value returned by this iterator. Use it to identify whether the iterator has reached beyond the last element in the span.
291291

292292
### Example
293293

@@ -320,7 +320,7 @@ A span that contains `count` elements from the front of this span.
320320
321321
### Remarks
322322
323-
A template version of this function can be used to validate the count at compile time, and to preserve info about the span by returning a span of fixed extent when possible.
323+
Use the template version of this function when possible to validate the `count` at compile time, and to preserve info about the span since it returns a span of fixed extent.
324324
325325
### Example
326326
@@ -358,7 +358,7 @@ mySpan.first<2>: 01
358358

359359
## <a name="front"></a> `span::front`
360360

361-
Returns the first element in the span.
361+
Get the first element in the span.
362362

363363
```cpp
364364
constexpr reference front() const noexcept;
@@ -445,7 +445,7 @@ A span containing the last `count` elements from this span.
445445
446446
### Remarks
447447
448-
A template version of this function can be used instead to check the count at compile time. The template version also preserves info about the span by returning a span of fixed extent, when possible.
448+
Use the template version of this function when possible to validate the `count` at compile time, and to preserve info about the span since it returns a span of fixed extent.
449449
450450
### Example
451451
@@ -483,7 +483,7 @@ mySpan.last<2>: 12
483483

484484
## <a name="op_at"></a> `span::operator[]`
485485

486-
Access an element in the span at a specified position.
486+
Get the element in the span at a specified position.
487487

488488
```cpp
489489
constexpr reference operator[](size_type offset) const;
@@ -537,7 +537,7 @@ The span to assign to this one.
537537

538538
### Remarks
539539

540-
Assignment does a shallow copy of the data pointer and the size. A shallow copy is safe because spans don't allocate memory for the elements they contain.
540+
Assignment does a shallow copy of the data pointer and the size. A shallow copy is safe because a `span` doesn't allocate memory for the elements it contains.
541541

542542
### Example
543543

@@ -566,7 +566,7 @@ int main()
566566

567567
## <a name="pointer"></a> `span::pointer`
568568

569-
The types for a pointer and `const` pointer to a span element.
569+
The types for a pointer, and `const` pointer, to a span element.
570570

571571
```cpp
572572
using pointer = T*;
@@ -677,7 +677,7 @@ int main()
677677

678678
## <a name="rend"></a> `span::rend`
679679

680-
Get a random-access iterator to just beyond the end of the reversed span.
680+
Get a random-access iterator that points just beyond the end of the reversed span.
681681

682682
```cpp
683683
constexpr reverse_iterator rend() const noexcept;
@@ -783,7 +783,7 @@ constexpr size_type size_bytes() const noexcept;
783783

784784
### Return Value
785785

786-
The number of bytes that all of the elements in the span take up; that is, `sizeof(element_type)` multiplied by the number of elements in the span.
786+
The number of bytes that all of the elements in the span occupy; that is, `sizeof(element_type)` multiplied by the number of elements in the span.
787787

788788
### Example
789789

@@ -881,7 +881,7 @@ span(const span<T, OtherExtent>& other) noexcept
881881
### Parameters
882882
883883
*arr*\
884-
Construct a span from this array.
884+
Construct a span from an array.
885885
886886
*count*\
887887
Number of elements that will be in the span.
@@ -896,7 +896,7 @@ Iterator to just past the last element in the span.
896896
The number of elements that will be in the span.
897897
898898
*other*\
899-
Copy from this span.
899+
Make a copy of this span.
900900
901901
*r*\
902902
Construct a span from this range.
@@ -907,13 +907,13 @@ A span doesn't free storage for items in the span because it doesn't own the sto
907907
908908
|Constructor | Description |
909909
|---------|---------|
910-
|`span()` | Constructs an empty span. Only considered during overload resolution when the template parameter `Extent` is `0` or `dynamic_extent`.|
911-
|`span(It first, size_type count)` | Constructs a span from the first `count` elements from iterator `first`. Only considered during overload resolution when template parameter `Extent` isn't `dynamic_extent`. |
912-
|`span(It first, End last)` | Constructs a span from the elements in iterator `first` until the end `last` is reached. Only considered during overload resolution when template parameter `Extent` isn't `dynamic_extent`. `It` must be a `contiguous_iterator`. |
913-
|`span(array<T, N>& arr) noexcept;`<br /><br />`span(const array<T, N>& arr) noexcept;`<br /><br />`span(type_identity_t<element_type> (&arr)[N]) noexcept;` | Constructs a span from `N` elements of the specified array. Only considered during overload resolution when template parameter `Extent` is `dynamic_extent` or equals `N`. |
914-
|`span(R&& r)` | Constructs a span from a range. Only participates in overload resolution if template parameter `Extent` isn't `dynamic_extent`.|
910+
|`span()` | Construct an empty span. Only considered during overload resolution when the template parameter `Extent` is `0` or `dynamic_extent`.|
911+
|`span(It first, size_type count)` | Construct a span from the first `count` elements from iterator `first`. Only considered during overload resolution when template parameter `Extent` isn't `dynamic_extent`. |
912+
|`span(It first, End last)` | Construct a span from the elements in iterator `first` until the end `last` is reached. Only considered during overload resolution when template parameter `Extent` isn't `dynamic_extent`. `It` must be a `contiguous_iterator`. |
913+
|`span(array<T, N>& arr) noexcept;`<br /><br />`span(const array<T, N>& arr) noexcept;`<br /><br />`span(type_identity_t<element_type> (&arr)[N]) noexcept;` | Construct a span from `N` elements of the specified array. Only considered during overload resolution when template parameter `Extent` is `dynamic_extent` or equals `N`. |
914+
|`span(R&& r)` | Construct a span from a range. Only participates in overload resolution if template parameter `Extent` isn't `dynamic_extent`.|
915915
|`span(const span& other)` | The compiler-generated copy constructor. A shallow copy of the data pointer is safe because the span doesn't allocate the memory to hold the elements. |
916-
|`span(const span<OtherElementType, OtherExtent>& s) noexcept;` | Converting constructor: constructs a span from another span. Only participates in overload resolution if template parameter `Extent` is `dynamic_extent`, or `N` is `dynamic_extent` or equals `Extent`.|
916+
|`span(const span<OtherElementType, OtherExtent>& s) noexcept;` | Converting constructor: construct a span from another span. Only participates in overload resolution if template parameter `Extent` is `dynamic_extent`, or `N` is `dynamic_extent` or equals `Extent`.|
917917
918918
### Example
919919
@@ -953,18 +953,18 @@ constexpr auto subspan() const noexcept
953953
### Parameters
954954
955955
*count*\
956-
The number of elements to put in the subspan. If `count` is `dynamic_extent` (the default value), then gets the subspan from `offset` to the end of this span.
956+
The number of elements to put in the subspan. If `count` is `dynamic_extent` (the default value), then the subspan is taken from `offset` to the end of this span.
957957
958958
*offset*\
959959
The location in this span to start the subspan.
960960
961961
### Return Value
962962
963-
A span starting at `offset` in this span, containing `count` elements.
963+
A span starting at `offset` in this span. Contains `count` elements.
964964
965965
### Remarks
966966
967-
A template version of this function is available that checks the count at compile time, and that preserves information about the span by returning a span of fixed extent, when possible.
967+
A template version of this function is available that checks the count at compile time, which preserves information about the span by returning a span of fixed extent.
968968
969969
### Example
970970
@@ -1005,7 +1005,7 @@ mySpan.subspan<1>: 12
10051005

10061006
## <a name="value_type"></a> `span::value_type`
10071007

1008-
The type of the element in the span but without any `const` or `volatile` qualifications.
1008+
The type of the element in the span, without `const` or `volatile` qualifications.
10091009

10101010
```cpp
10111011
using value_type = std::remove_cv_t<T>;

docs/standard-library/span-functions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The \<span> header includes the following non-member functions that operate on *
1111
| **Non-member functions** | **Description** |
1212
|-|-|
1313
|[as_bytes](#as_bytes) | Get a read-only view of the object representation of the elements in the span. |
14-
|[as_writable_bytes](#as_writable_bytes) | Get a read/write view to the object representation of the elements in the span. |
14+
|[as_writable_bytes](#as_writable_bytes) | Get a read/write view of the object representation of the elements in the span. |
1515

1616
## <a name="as_bytes"></a>`as_bytes`
1717

@@ -55,7 +55,7 @@ void main()
5555

5656
## <a name="as_writable_bytes"></a>`as_writable_bytes`
5757

58-
If `T` isn't `const`, gets a read/write view to the raw byte representation of the elements in the span.
58+
If `T` isn't `const`, gets a read/write view of the raw byte representation of the elements in the span.
5959

6060
```cpp
6161
template <class T, size_t Extent>

docs/standard-library/span.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ See [span class](span-class.md) for detailed information. Here's an example of h
1515
#include <span>
1616
#include <iostream>
1717

18+
u
19+
1820
void Show(std::span<int> someValues)
1921
{
2022
// show values in reverse
@@ -50,28 +52,28 @@ int main()
5052
### Classes
5153
5254
|||
53-
|-|-|
55+
|-|:-|
5456
|[span](span-class.md)| Provides a view over a contiguous sequence of objects. |
5557
5658
### Operators
5759
5860
|||
59-
|-|-|
61+
|-|:-|
6062
|[operator=](span-class.md#op_eq)| Span assignment |
6163
|[operator\[\]](span-class.md#op_at)| Element access |
6264
6365
### Functions
6466
6567
|||
66-
|-|-|
68+
|-|:-|
6769
| [as_bytes](span-functions.md#as_bytes)| Get the underlying read-only bytes of the span. |
6870
| [as_writable_bytes](span-functions.md#as_writable_bytes) | Get the underlying bytes of the span. |
6971
7072
### Constants
7173
7274
|||
73-
|-|-|
74-
| **dynamic_extent** | Indicates that the span size is determined at runtime rather than compile time. When the number of elements in the span is known at compile time, it's specified as the `Extent` template parameter. When the number isn't known until runtime, `dynamic_extent` is specified instead. |
75+
|-|:-|
76+
| **dynamic_extent** | Indicates that the span size is determined at runtime rather than compile time. When the number of elements in the span is known at compile time, it's specified as the `Extent` template parameter. When the number isn't known until runtime, specify `dynamic_extent` instead. |
7577
7678
## See also
7779

0 commit comments

Comments
 (0)