tmp/tmp1vhe9ulg/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Overview <a id="span.overview">[[span.overview]]</a>
|
| 2 |
+
|
| 3 |
+
A `span` is a view over a contiguous sequence of objects, the storage of
|
| 4 |
+
which is owned by some other object.
|
| 5 |
+
|
| 6 |
+
All member functions of `span` have constant time complexity.
|
| 7 |
+
|
| 8 |
+
``` cpp
|
| 9 |
+
namespace std {
|
| 10 |
+
template<class ElementType, size_t Extent = dynamic_extent>
|
| 11 |
+
class span {
|
| 12 |
+
public:
|
| 13 |
+
// constants and types
|
| 14 |
+
using element_type = ElementType;
|
| 15 |
+
using value_type = remove_cv_t<ElementType>;
|
| 16 |
+
using size_type = size_t;
|
| 17 |
+
using difference_type = ptrdiff_t;
|
| 18 |
+
using pointer = element_type*;
|
| 19 |
+
using const_pointer = const element_type*;
|
| 20 |
+
using reference = element_type&;
|
| 21 |
+
using const_reference = const element_type&;
|
| 22 |
+
using iterator = implementation-defined // type of span::iterator; // see [span.iterators]
|
| 23 |
+
using reverse_iterator = std::reverse_iterator<iterator>;
|
| 24 |
+
static constexpr size_type extent = Extent;
|
| 25 |
+
|
| 26 |
+
// [span.cons], constructors, copy, and assignment
|
| 27 |
+
constexpr span() noexcept;
|
| 28 |
+
template<class It>
|
| 29 |
+
constexpr explicit(extent != dynamic_extent) span(It first, size_type count);
|
| 30 |
+
template<class It, class End>
|
| 31 |
+
constexpr explicit(extent != dynamic_extent) span(It first, End last);
|
| 32 |
+
template<size_t N>
|
| 33 |
+
constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept;
|
| 34 |
+
template<class T, size_t N>
|
| 35 |
+
constexpr span(array<T, N>& arr) noexcept;
|
| 36 |
+
template<class T, size_t N>
|
| 37 |
+
constexpr span(const array<T, N>& arr) noexcept;
|
| 38 |
+
template<class R>
|
| 39 |
+
constexpr explicit(extent != dynamic_extent) span(R&& r);
|
| 40 |
+
constexpr span(const span& other) noexcept = default;
|
| 41 |
+
template<class OtherElementType, size_t OtherExtent>
|
| 42 |
+
constexpr explicit(see below) span(const span<OtherElementType, OtherExtent>& s) noexcept;
|
| 43 |
+
|
| 44 |
+
~span() noexcept = default;
|
| 45 |
+
|
| 46 |
+
constexpr span& operator=(const span& other) noexcept = default;
|
| 47 |
+
|
| 48 |
+
// [span.sub], subviews
|
| 49 |
+
template<size_t Count>
|
| 50 |
+
constexpr span<element_type, Count> first() const;
|
| 51 |
+
template<size_t Count>
|
| 52 |
+
constexpr span<element_type, Count> last() const;
|
| 53 |
+
template<size_t Offset, size_t Count = dynamic_extent>
|
| 54 |
+
constexpr span<element_type, see below> subspan() const;
|
| 55 |
+
|
| 56 |
+
constexpr span<element_type, dynamic_extent> first(size_type count) const;
|
| 57 |
+
constexpr span<element_type, dynamic_extent> last(size_type count) const;
|
| 58 |
+
constexpr span<element_type, dynamic_extent> subspan(
|
| 59 |
+
size_type offset, size_type count = dynamic_extent) const;
|
| 60 |
+
|
| 61 |
+
// [span.obs], observers
|
| 62 |
+
constexpr size_type size() const noexcept;
|
| 63 |
+
constexpr size_type size_bytes() const noexcept;
|
| 64 |
+
[[nodiscard]] constexpr bool empty() const noexcept;
|
| 65 |
+
|
| 66 |
+
// [span.elem], element access
|
| 67 |
+
constexpr reference operator[](size_type idx) const;
|
| 68 |
+
constexpr reference front() const;
|
| 69 |
+
constexpr reference back() const;
|
| 70 |
+
constexpr pointer data() const noexcept;
|
| 71 |
+
|
| 72 |
+
// [span.iterators], iterator support
|
| 73 |
+
constexpr iterator begin() const noexcept;
|
| 74 |
+
constexpr iterator end() const noexcept;
|
| 75 |
+
constexpr reverse_iterator rbegin() const noexcept;
|
| 76 |
+
constexpr reverse_iterator rend() const noexcept;
|
| 77 |
+
|
| 78 |
+
private:
|
| 79 |
+
pointer data_; // exposition only
|
| 80 |
+
size_type size_; // exposition only
|
| 81 |
+
};
|
| 82 |
+
|
| 83 |
+
template<class It, class EndOrSize>
|
| 84 |
+
span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
|
| 85 |
+
template<class T, size_t N>
|
| 86 |
+
span(T (&)[N]) -> span<T, N>;
|
| 87 |
+
template<class T, size_t N>
|
| 88 |
+
span(array<T, N>&) -> span<T, N>;
|
| 89 |
+
template<class T, size_t N>
|
| 90 |
+
span(const array<T, N>&) -> span<const T, N>;
|
| 91 |
+
template<class R>
|
| 92 |
+
span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
|
| 93 |
+
}
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
`ElementType` is required to be a complete object type that is not an
|
| 97 |
+
abstract class type.
|
| 98 |
+
|