Init
This commit is contained in:
364
cppdraft/span/cons.md
Normal file
364
cppdraft/span/cons.md
Normal file
@@ -0,0 +1,364 @@
|
||||
[span.cons]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.7 Views [[views]](views#span.cons)
|
||||
|
||||
### 23.7.2 Contiguous access [[views.contiguous]](views.contiguous#span.cons)
|
||||
|
||||
#### 23.7.2.2 Class template span [[views.span]](views.span#span.cons)
|
||||
|
||||
#### 23.7.2.2.2 Constructors, copy, and assignment [span.cons]
|
||||
|
||||
[ð](#lib:span,constructor)
|
||||
|
||||
`constexpr span() noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20344)
|
||||
|
||||
*Constraints*: Extent == dynamic_extent || Extent == 0 is true[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20348)
|
||||
|
||||
*Postconditions*: size() == 0 && data() == nullptr[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:span,constructor_)
|
||||
|
||||
`template<class It>
|
||||
constexpr explicit(extent != dynamic_extent) span(It first, size_type count);
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20361)
|
||||
|
||||
*Constraints*: Let U be remove_reference_t<iter_reference_t<It>>[.](#3.sentence-1)
|
||||
|
||||
- [(3.1)](#3.1)
|
||||
|
||||
It satisfies [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14 Concept contiguous_iterator [iterator.concept.contiguous]")[.](#3.1.sentence-1)
|
||||
|
||||
- [(3.2)](#3.2)
|
||||
|
||||
is_convertible_v<U(*)[], element_type(*)[]> is true[.](#3.2.sentence-1)
|
||||
[*Note [1](#note-1)*:
|
||||
The intent is to allow only qualification conversions
|
||||
of the iterator reference type to element_type[.](#3.2.sentence-2)
|
||||
â *end note*]
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20374)
|
||||
|
||||
*Preconditions*:
|
||||
|
||||
- [(4.1)](#4.1)
|
||||
|
||||
[first, first + count) is a valid range[.](#4.1.sentence-1)
|
||||
|
||||
- [(4.2)](#4.2)
|
||||
|
||||
It models [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14 Concept contiguous_iterator [iterator.concept.contiguous]")[.](#4.2.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20381)
|
||||
|
||||
*Hardened preconditions*: If extent is not equal to dynamic_extent,
|
||||
then count == extent is true[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20386)
|
||||
|
||||
*Effects*: Initializes *data_* with to_address(first) and*size_* with count[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20391)
|
||||
|
||||
*Throws*: Nothing[.](#7.sentence-1)
|
||||
|
||||
[ð](#lib:span,constructor__)
|
||||
|
||||
`template<class It, class End>
|
||||
constexpr explicit(extent != dynamic_extent) span(It first, End last);
|
||||
`
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20403)
|
||||
|
||||
*Constraints*: Let U be remove_reference_t<iter_reference_t<It>>[.](#8.sentence-1)
|
||||
|
||||
- [(8.1)](#8.1)
|
||||
|
||||
is_convertible_v<U(*)[], element_type(*)[]> is true[.](#8.1.sentence-1)
|
||||
[*Note [2](#note-2)*:
|
||||
The intent is to allow only qualification conversions
|
||||
of the iterator reference type to element_type[.](#8.1.sentence-2)
|
||||
â *end note*]
|
||||
|
||||
- [(8.2)](#8.2)
|
||||
|
||||
It satisfies [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14 Concept contiguous_iterator [iterator.concept.contiguous]")[.](#8.2.sentence-1)
|
||||
|
||||
- [(8.3)](#8.3)
|
||||
|
||||
End satisfies [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<It>[.](#8.3.sentence-1)
|
||||
|
||||
- [(8.4)](#8.4)
|
||||
|
||||
is_convertible_v<End, size_t> is false[.](#8.4.sentence-1)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20418)
|
||||
|
||||
*Preconditions*:
|
||||
|
||||
- [(9.1)](#9.1)
|
||||
|
||||
[first, last) is a valid range[.](#9.1.sentence-1)
|
||||
|
||||
- [(9.2)](#9.2)
|
||||
|
||||
It models [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14 Concept contiguous_iterator [iterator.concept.contiguous]")[.](#9.2.sentence-1)
|
||||
|
||||
- [(9.3)](#9.3)
|
||||
|
||||
End models [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<It>[.](#9.3.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20426)
|
||||
|
||||
*Hardened preconditions*: If extent is not equal to dynamic_extent,
|
||||
then (last - first) == extent is true[.](#10.sentence-1)
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20431)
|
||||
|
||||
*Effects*: Initializes *data_* with to_address(first) and*size_* with last - first[.](#11.sentence-1)
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20436)
|
||||
|
||||
*Throws*: When and what last - first throws[.](#12.sentence-1)
|
||||
|
||||
[ð](#lib:span,constructor___)
|
||||
|
||||
`template<size_t N> constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept;
|
||||
template<class T, size_t N> constexpr span(array<T, N>& arr) noexcept;
|
||||
template<class T, size_t N> constexpr span(const array<T, N>& arr) noexcept;
|
||||
`
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20449)
|
||||
|
||||
*Constraints*: Let U be remove_pointer_t<decltype(std::data(arr))>[.](#13.sentence-1)
|
||||
|
||||
- [(13.1)](#13.1)
|
||||
|
||||
extent == dynamic_extent || N == extent is true, and
|
||||
|
||||
- [(13.2)](#13.2)
|
||||
|
||||
is_convertible_v<U(*)[], element_type(*)[]> is true. [*Note [3](#note-3)*:
|
||||
The intent is to allow only qualification conversions
|
||||
of the array element type to element_type[.](#13.2.sentence-2)
|
||||
â *end note*]
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20461)
|
||||
|
||||
*Effects*: Constructs a span that is a view over the supplied array[.](#14.sentence-1)
|
||||
|
||||
[*Note [4](#note-4)*:
|
||||
|
||||
type_identity_t affects class template argument deduction[.](#14.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20468)
|
||||
|
||||
*Postconditions*: size() == N && data() == std::data(arr) is true[.](#15.sentence-1)
|
||||
|
||||
[ð](#lib:span,constructor____)
|
||||
|
||||
`template<class R> constexpr explicit(extent != dynamic_extent) span(R&& r);
|
||||
`
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20479)
|
||||
|
||||
*Constraints*: Let U be remove_reference_t<ranges::range_reference_t<R>>[.](#16.sentence-1)
|
||||
|
||||
- [(16.1)](#16.1)
|
||||
|
||||
R satisfies ranges::[contiguous_range](range.refinements#concept:contiguous_range "25.4.6 Other range refinements [range.refinements]") and ranges::[sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]")[.](#16.1.sentence-1)
|
||||
|
||||
- [(16.2)](#16.2)
|
||||
|
||||
Either R satisfies ranges::[borrowed_range](range.range#concept:borrowed_range "25.4.2 Ranges [range.range]") oris_const_v<element_type> is true[.](#16.2.sentence-1)
|
||||
|
||||
- [(16.3)](#16.3)
|
||||
|
||||
remove_cvref_t<R> is not a specialization of span[.](#16.3.sentence-1)
|
||||
|
||||
- [(16.4)](#16.4)
|
||||
|
||||
remove_cvref_t<R> is not a specialization of array[.](#16.4.sentence-1)
|
||||
|
||||
- [(16.5)](#16.5)
|
||||
|
||||
is_array_v<remove_cvref_t<R>> is false[.](#16.5.sentence-1)
|
||||
|
||||
- [(16.6)](#16.6)
|
||||
|
||||
is_convertible_v<U(*)[], element_type(*)[]> is true[.](#16.6.sentence-1)
|
||||
[*Note [5](#note-5)*:
|
||||
The intent is to allow only qualification conversions
|
||||
of the range reference type to element_type[.](#16.6.sentence-2)
|
||||
â *end note*]
|
||||
|
||||
[17](#17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20498)
|
||||
|
||||
*Preconditions*:
|
||||
|
||||
- [(17.1)](#17.1)
|
||||
|
||||
R models ranges::[contiguous_range](range.refinements#concept:contiguous_range "25.4.6 Other range refinements [range.refinements]") andranges::[sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]")[.](#17.1.sentence-1)
|
||||
|
||||
- [(17.2)](#17.2)
|
||||
|
||||
If is_const_v<element_type> is false,R models ranges::[borrowed_range](range.range#concept:borrowed_range "25.4.2 Ranges [range.range]")[.](#17.2.sentence-1)
|
||||
|
||||
[18](#18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20507)
|
||||
|
||||
*Hardened preconditions*: If extent is not equal to dynamic_extent,
|
||||
then ranges::size(r) == extent is true[.](#18.sentence-1)
|
||||
|
||||
[19](#19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20512)
|
||||
|
||||
*Effects*: Initializes *data_* with ranges::data(r) and*size_* with ranges::size(r)[.](#19.sentence-1)
|
||||
|
||||
[20](#20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20517)
|
||||
|
||||
*Throws*: What and when ranges::data(r) and ranges::size(r) throw[.](#20.sentence-1)
|
||||
|
||||
[ð](#lib:span,constructor_____)
|
||||
|
||||
`constexpr explicit(extent != dynamic_extent) span(std::initializer_list<value_type> il);
|
||||
`
|
||||
|
||||
[21](#21)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20528)
|
||||
|
||||
*Constraints*: is_const_v<element_type> is true[.](#21.sentence-1)
|
||||
|
||||
[22](#22)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20532)
|
||||
|
||||
*Hardened preconditions*: If extent is not equal to dynamic_extent,
|
||||
then il.size() == extent is true[.](#22.sentence-1)
|
||||
|
||||
[23](#23)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20537)
|
||||
|
||||
*Effects*: Initializes *data_* with il.begin() and*size_* with il.size()[.](#23.sentence-1)
|
||||
|
||||
[ð](#lib:span,constructor______)
|
||||
|
||||
`constexpr span(const span& other) noexcept = default;
|
||||
`
|
||||
|
||||
[24](#24)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20549)
|
||||
|
||||
*Postconditions*: other.size() == size() && other.data() == data()[.](#24.sentence-1)
|
||||
|
||||
[ð](#lib:span,constructor_______)
|
||||
|
||||
`template<class OtherElementType, size_t OtherExtent>
|
||||
constexpr explicit(see below) span(const span<OtherElementType, OtherExtent>& s) noexcept;
|
||||
`
|
||||
|
||||
[25](#25)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20561)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(25.1)](#25.1)
|
||||
|
||||
extent == dynamic_extent || OtherExtent == dynamic_extent || extent == OtherExtent is true, and
|
||||
|
||||
- [(25.2)](#25.2)
|
||||
|
||||
is_convertible_v<OtherElementType(*)[], element_type(*)[]> is true[.](#25.sentence-1)
|
||||
[*Note [6](#note-6)*:
|
||||
The intent is to allow only qualification conversions
|
||||
of the OtherElementType to element_type[.](#25.2.sentence-2)
|
||||
â *end note*]
|
||||
|
||||
[26](#26)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20572)
|
||||
|
||||
*Hardened preconditions*: If extent is not equal to dynamic_extent,
|
||||
then s.size() == extent is true[.](#26.sentence-1)
|
||||
|
||||
[27](#27)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20577)
|
||||
|
||||
*Effects*: Constructs a span that is a view over the range
|
||||
[s.data(), s.data() + s.size())[.](#27.sentence-1)
|
||||
|
||||
[28](#28)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20582)
|
||||
|
||||
*Postconditions*: size() == s.size() && data() == s.data()[.](#28.sentence-1)
|
||||
|
||||
[29](#29)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20586)
|
||||
|
||||
*Remarks*: The expression inside explicit is equivalent to:extent != dynamic_extent && OtherExtent == dynamic_extent
|
||||
|
||||
[ð](#lib:operator=,span)
|
||||
|
||||
`constexpr span& operator=(const span& other) noexcept = default;
|
||||
`
|
||||
|
||||
[30](#30)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20600)
|
||||
|
||||
*Postconditions*: size() == other.size() && data() == other.data()[.](#30.sentence-1)
|
||||
36
cppdraft/span/deduct.md
Normal file
36
cppdraft/span/deduct.md
Normal file
@@ -0,0 +1,36 @@
|
||||
[span.deduct]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.7 Views [[views]](views#span.deduct)
|
||||
|
||||
### 23.7.2 Contiguous access [[views.contiguous]](views.contiguous#span.deduct)
|
||||
|
||||
#### 23.7.2.2 Class template span [[views.span]](views.span#span.deduct)
|
||||
|
||||
#### 23.7.2.2.3 Deduction guides [span.deduct]
|
||||
|
||||
[ð](#lib:span,deduction_guide)
|
||||
|
||||
`template<class It, class EndOrSize>
|
||||
span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>,
|
||||
[maybe-static-ext](span.syn#concept:maybe-static-ext "23.7.2.1 Header <span> synopsis [span.syn]")<EndOrSize>>;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20615)
|
||||
|
||||
*Constraints*: It satisfies [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14 Concept contiguous_iterator [iterator.concept.contiguous]")[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:span,deduction_guide_)
|
||||
|
||||
`template<class R>
|
||||
span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20627)
|
||||
|
||||
*Constraints*: R satisfies ranges::[contiguous_range](range.refinements#concept:contiguous_range "25.4.6 Other range refinements [range.refinements]")[.](#2.sentence-1)
|
||||
108
cppdraft/span/elem.md
Normal file
108
cppdraft/span/elem.md
Normal file
@@ -0,0 +1,108 @@
|
||||
[span.elem]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.7 Views [[views]](views#span.elem)
|
||||
|
||||
### 23.7.2 Contiguous access [[views.contiguous]](views.contiguous#span.elem)
|
||||
|
||||
#### 23.7.2.2 Class template span [[views.span]](views.span#span.elem)
|
||||
|
||||
#### 23.7.2.2.6 Element access [span.elem]
|
||||
|
||||
[ð](#lib:operator%5b%5d,span)
|
||||
|
||||
`constexpr reference operator[](size_type idx) const;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20808)
|
||||
|
||||
*Hardened preconditions*: idx < size() is true[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20812)
|
||||
|
||||
*Returns*: *(data() + idx)[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20816)
|
||||
|
||||
*Throws*: Nothing[.](#3.sentence-1)
|
||||
|
||||
[ð](#lib:span,at)
|
||||
|
||||
`constexpr reference at(size_type idx) const;
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20827)
|
||||
|
||||
*Returns*: *(data() + idx)[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20831)
|
||||
|
||||
*Throws*: out_of_range if idx >= size() is true[.](#5.sentence-1)
|
||||
|
||||
[ð](#lib:span,front)
|
||||
|
||||
`constexpr reference front() const;
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20842)
|
||||
|
||||
*Hardened preconditions*: empty() is false[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20846)
|
||||
|
||||
*Returns*: *data()[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20850)
|
||||
|
||||
*Throws*: Nothing[.](#8.sentence-1)
|
||||
|
||||
[ð](#lib:span,back)
|
||||
|
||||
`constexpr reference back() const;
|
||||
`
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20861)
|
||||
|
||||
*Hardened preconditions*: empty() is false[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20865)
|
||||
|
||||
*Returns*: *(data() + (size() - 1))[.](#10.sentence-1)
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20869)
|
||||
|
||||
*Throws*: Nothing[.](#11.sentence-1)
|
||||
|
||||
[ð](#lib:span,data)
|
||||
|
||||
`constexpr pointer data() const noexcept;
|
||||
`
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20880)
|
||||
|
||||
*Returns*: *data_*[.](#12.sentence-1)
|
||||
82
cppdraft/span/iterators.md
Normal file
82
cppdraft/span/iterators.md
Normal file
@@ -0,0 +1,82 @@
|
||||
[span.iterators]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.7 Views [[views]](views#span.iterators)
|
||||
|
||||
### 23.7.2 Contiguous access [[views.contiguous]](views.contiguous#span.iterators)
|
||||
|
||||
#### 23.7.2.2 Class template span [[views.span]](views.span#span.iterators)
|
||||
|
||||
#### 23.7.2.2.7 Iterator support [span.iterators]
|
||||
|
||||
[ð](#lib:iterator,span)
|
||||
|
||||
`using iterator = implementation-defined;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20893)
|
||||
|
||||
The type
|
||||
models [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14 Concept contiguous_iterator [iterator.concept.contiguous]") ([[iterator.concept.contiguous]](iterator.concept.contiguous "24.3.4.14 Concept contiguous_iterator")),
|
||||
meets the *Cpp17RandomAccessIterator* requirements ([[random.access.iterators]](random.access.iterators "24.3.5.7 Random access iterators")),
|
||||
and
|
||||
meets the requirements for
|
||||
constexpr iterators ([[iterator.requirements.general]](iterator.requirements.general "24.3.1 General")),
|
||||
whose value type is value_type and
|
||||
whose reference type is reference[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20904)
|
||||
|
||||
All requirements on container iterators ([[container.reqmts]](container.reqmts "23.2.2.2 Container requirements")) apply tospan::iterator as well[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:span,begin)
|
||||
|
||||
`constexpr iterator begin() const noexcept;
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20915)
|
||||
|
||||
*Returns*: An iterator referring to the first element in the span[.](#3.sentence-1)
|
||||
|
||||
If empty() is true, then it returns the
|
||||
same value as end()[.](#3.sentence-2)
|
||||
|
||||
[ð](#lib:span,end)
|
||||
|
||||
`constexpr iterator end() const noexcept;
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20928)
|
||||
|
||||
*Returns*: An iterator which is the past-the-end value[.](#4.sentence-1)
|
||||
|
||||
[ð](#lib:span,rbegin)
|
||||
|
||||
`constexpr reverse_iterator rbegin() const noexcept;
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20939)
|
||||
|
||||
*Effects*: Equivalent to: return reverse_iterator(end());
|
||||
|
||||
[ð](#lib:span,rend)
|
||||
|
||||
`constexpr reverse_iterator rend() const noexcept;
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20950)
|
||||
|
||||
*Effects*: Equivalent to: return reverse_iterator(begin());
|
||||
41
cppdraft/span/objectrep.md
Normal file
41
cppdraft/span/objectrep.md
Normal file
@@ -0,0 +1,41 @@
|
||||
[span.objectrep]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.7 Views [[views]](views#span.objectrep)
|
||||
|
||||
### 23.7.2 Contiguous access [[views.contiguous]](views.contiguous#span.objectrep)
|
||||
|
||||
#### 23.7.2.3 Views of object representation [span.objectrep]
|
||||
|
||||
[ð](#lib:as_bytes)
|
||||
|
||||
`template<class ElementType, size_t Extent>
|
||||
span<const byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
|
||||
as_bytes(span<ElementType, Extent> s) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20965)
|
||||
|
||||
*Effects*: Equivalent to: return R{reinterpret_cast<const byte*>(s.data()), s.size_bytes()}; where R is the return type[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:as_writable_bytes)
|
||||
|
||||
`template<class ElementType, size_t Extent>
|
||||
span<byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
|
||||
as_writable_bytes(span<ElementType, Extent> s) noexcept;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20979)
|
||||
|
||||
*Constraints*: is_const_v<ElementType> is false[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20983)
|
||||
|
||||
*Effects*: Equivalent to: return R{reinterpret_cast<byte*>(s.data()), s.size_bytes()}; where R is the return type[.](#3.sentence-1)
|
||||
44
cppdraft/span/obs.md
Normal file
44
cppdraft/span/obs.md
Normal file
@@ -0,0 +1,44 @@
|
||||
[span.obs]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.7 Views [[views]](views#span.obs)
|
||||
|
||||
### 23.7.2 Contiguous access [[views.contiguous]](views.contiguous#span.obs)
|
||||
|
||||
#### 23.7.2.2 Class template span [[views.span]](views.span#span.obs)
|
||||
|
||||
#### 23.7.2.2.5 Observers [span.obs]
|
||||
|
||||
[ð](#lib:span,size)
|
||||
|
||||
`constexpr size_type size() const noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20773)
|
||||
|
||||
*Effects*: Equivalent to: return *size_*;
|
||||
|
||||
[ð](#lib:span,size_bytes)
|
||||
|
||||
`constexpr size_type size_bytes() const noexcept;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20784)
|
||||
|
||||
*Effects*: Equivalent to: return size() * sizeof(element_type);
|
||||
|
||||
[ð](#lib:span,empty)
|
||||
|
||||
`constexpr bool empty() const noexcept;
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20795)
|
||||
|
||||
*Effects*: Equivalent to: return size() == 0;
|
||||
51
cppdraft/span/overview.md
Normal file
51
cppdraft/span/overview.md
Normal file
@@ -0,0 +1,51 @@
|
||||
[span.overview]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.7 Views [[views]](views#span.overview)
|
||||
|
||||
### 23.7.2 Contiguous access [[views.contiguous]](views.contiguous#span.overview)
|
||||
|
||||
#### 23.7.2.2 Class template span [[views.span]](views.span#span.overview)
|
||||
|
||||
#### 23.7.2.2.1 Overview [span.overview]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20218)
|
||||
|
||||
A span is a view over a contiguous sequence of objects,
|
||||
the storage of which is owned by some other object[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20223)
|
||||
|
||||
All member functions of span have constant time complexity[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:span_)
|
||||
|
||||
namespace std {template<class ElementType, size_t Extent = dynamic_extent>class span {public:// constants and typesusing element_type = ElementType; using value_type = remove_cv_t<ElementType>; using size_type = size_t; using difference_type = ptrdiff_t; using pointer = element_type*; using const_pointer = const element_type*; using reference = element_type&; using const_reference = const element_type&; using iterator = *implementation-defined*; // see [[span.iterators]](span.iterators "23.7.2.2.7 Iterator support")using const_iterator = std::const_iterator<iterator>; using reverse_iterator = std::reverse_iterator<iterator>; using const_reverse_iterator = std::const_iterator<reverse_iterator>; static constexpr size_type extent = Extent; // [[span.cons]](span.cons "23.7.2.2.2 Constructors, copy, and assignment"), constructors, copy, and assignmentconstexpr span() noexcept; template<class It>constexpr explicit(extent != dynamic_extent) span(It first, size_type count); template<class It, class End>constexpr explicit(extent != dynamic_extent) span(It first, End last); template<size_t N>constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept; template<class T, size_t N>constexpr span(array<T, N>& arr) noexcept; template<class T, size_t N>constexpr span(const array<T, N>& arr) noexcept; template<class R>constexpr explicit(extent != dynamic_extent) span(R&& r); constexpr explicit(extent != dynamic_extent) span(std::initializer_list<value_type> il); constexpr span(const span& other) noexcept = default; template<class OtherElementType, size_t OtherExtent>constexpr explicit(*see below*) span(const span<OtherElementType, OtherExtent>& s) noexcept; constexpr span& operator=(const span& other) noexcept = default; // [[span.sub]](span.sub "23.7.2.2.4 Subviews"), subviewstemplate<size_t Count>constexpr span<element_type, Count> first() const; template<size_t Count>constexpr span<element_type, Count> last() const; template<size_t Offset, size_t Count = dynamic_extent>constexpr span<element_type, *see below*> subspan() const; constexpr span<element_type, dynamic_extent> first(size_type count) const; constexpr span<element_type, dynamic_extent> last(size_type count) const; constexpr span<element_type, dynamic_extent> subspan( size_type offset, size_type count = dynamic_extent) const; // [[span.obs]](span.obs "23.7.2.2.5 Observers"), observersconstexpr size_type size() const noexcept; constexpr size_type size_bytes() const noexcept; constexpr bool empty() const noexcept; // [[span.elem]](span.elem "23.7.2.2.6 Element access"), element accessconstexpr reference operator[](size_type idx) const; constexpr reference at(size_type idx) const; // freestanding-deletedconstexpr reference front() const; constexpr reference back() const; constexpr pointer data() const noexcept; // [[span.iterators]](span.iterators "23.7.2.2.7 Iterator support"), iterator supportconstexpr iterator begin() const noexcept; constexpr iterator end() const noexcept; constexpr const_iterator cbegin() const noexcept { return begin(); }constexpr const_iterator cend() const noexcept { return end(); }constexpr reverse_iterator rbegin() const noexcept; constexpr reverse_iterator rend() const noexcept; constexpr const_reverse_iterator crbegin() const noexcept { return rbegin(); }constexpr const_reverse_iterator crend() const noexcept { return rend(); }private: pointer *data_*; // *exposition only* size_type *size_*; // *exposition only*}; template<class It, class EndOrSize> span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>, [*maybe-static-ext*](span.syn#concept:maybe-static-ext "23.7.2.1 Header <span> synopsis [span.syn]")<EndOrSize>>; template<class T, size_t N> span(T (&)[N]) -> span<T, N>; template<class T, size_t N> span(array<T, N>&) -> span<T, N>; template<class T, size_t N> span(const array<T, N>&) -> span<const T, N>; template<class R> span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;}
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20322)
|
||||
|
||||
span<ElementType, Extent> is
|
||||
a trivially copyable type ([[basic.types.general]](basic.types.general#term.trivially.copyable.type "6.9.1 General"))[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20326)
|
||||
|
||||
ElementType is required to be
|
||||
a complete object type that is not an abstract class type[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20330)
|
||||
|
||||
For a span s,
|
||||
any operation that invalidates a pointer in
|
||||
the range [s.data(), s.data() + s.size())
|
||||
invalidates pointers, iterators, and references to elements of s[.](#5.sentence-1)
|
||||
720
cppdraft/span/streams.md
Normal file
720
cppdraft/span/streams.md
Normal file
@@ -0,0 +1,720 @@
|
||||
[span.streams]
|
||||
|
||||
# 31 Input/output library [[input.output]](./#input.output)
|
||||
|
||||
## 31.9 Span-based streams [span.streams]
|
||||
|
||||
### [31.9.1](#overview) Overview [[span.streams.overview]](span.streams.overview)
|
||||
|
||||
[1](#overview-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10001)
|
||||
|
||||
The header <spanstream> defines class templates and types
|
||||
that associate stream buffers with objects whose types are
|
||||
specializations of span as described in [[views.span]](views.span "23.7.2.2 Class template span")[.](#overview-1.sentence-1)
|
||||
|
||||
[*Note [1](#overview-note-1)*:
|
||||
|
||||
A user of these classes is responsible for ensuring
|
||||
that the character sequence represented by the given span outlives the use of the sequence by objects of the classes in [span.streams][.](#overview-1.sentence-2)
|
||||
|
||||
Using multiple basic_spanbuf objects
|
||||
referring to overlapping underlying sequences from different threads,
|
||||
where at least one basic_spanbuf object is used
|
||||
for writing to the sequence,
|
||||
results in a data race[.](#overview-1.sentence-3)
|
||||
|
||||
â *end note*]
|
||||
|
||||
### [31.9.2](#spanstream.syn) Header <spanstream> synopsis [[spanstream.syn]](spanstream.syn)
|
||||
|
||||
[ð](#lib:spanbuf)
|
||||
|
||||
namespace std {// [[spanbuf]](#spanbuf "31.9.3 Class template basic_spanbuf"), class template basic_spanbuftemplate<class charT, class traits = char_traits<charT>>class basic_spanbuf; template<class charT, class traits>void swap(basic_spanbuf<charT, traits>& x, basic_spanbuf<charT, traits>& y); using spanbuf = basic_spanbuf<char>; using wspanbuf = basic_spanbuf<wchar_t>; // [[ispanstream]](#ispanstream "31.9.4 Class template basic_ispanstream"), class template basic_ispanstreamtemplate<class charT, class traits = char_traits<charT>>class basic_ispanstream; template<class charT, class traits>void swap(basic_ispanstream<charT, traits>& x, basic_ispanstream<charT, traits>& y); using ispanstream = basic_ispanstream<char>; using wispanstream = basic_ispanstream<wchar_t>; // [[ospanstream]](#ospanstream "31.9.5 Class template basic_ospanstream"), class template basic_ospanstreamtemplate<class charT, class traits = char_traits<charT>>class basic_ospanstream; template<class charT, class traits>void swap(basic_ospanstream<charT, traits>& x, basic_ospanstream<charT, traits>& y); using ospanstream = basic_ospanstream<char>; using wospanstream = basic_ospanstream<wchar_t>; // [[spanstream]](#spanstream "31.9.6 Class template basic_spanstream"), class template basic_spanstreamtemplate<class charT, class traits = char_traits<charT>>class basic_spanstream; template<class charT, class traits>void swap(basic_spanstream<charT, traits>& x, basic_spanstream<charT, traits>& y); using spanstream = basic_spanstream<char>; using wspanstream = basic_spanstream<wchar_t>;}
|
||||
|
||||
### [31.9.3](#spanbuf) Class template basic_spanbuf [[spanbuf]](spanbuf)
|
||||
|
||||
#### [31.9.3.1](#spanbuf.general) General [[spanbuf.general]](spanbuf.general)
|
||||
|
||||
[ð](#lib:basic_spanbuf)
|
||||
|
||||
namespace std {template<class charT, class traits = char_traits<charT>>class basic_spanbuf : public basic_streambuf<charT, traits> {public:using char_type = charT; using int_type = typename traits::int_type; using pos_type = typename traits::pos_type; using off_type = typename traits::off_type; using traits_type = traits; // [[spanbuf.cons]](#spanbuf.cons "31.9.3.2 Constructors"), constructors basic_spanbuf() : basic_spanbuf(ios_base::in | ios_base::out) {}explicit basic_spanbuf(ios_base::openmode which): basic_spanbuf(std::span<charT>(), which) {}explicit basic_spanbuf(std::span<charT> s,
|
||||
ios_base::openmode which = ios_base::in | ios_base::out);
|
||||
basic_spanbuf(const basic_spanbuf&) = delete;
|
||||
basic_spanbuf(basic_spanbuf&& rhs); // [[spanbuf.assign]](#spanbuf.assign "31.9.3.3 Assignment and swap"), assignment and swap basic_spanbuf& operator=(const basic_spanbuf&) = delete;
|
||||
basic_spanbuf& operator=(basic_spanbuf&& rhs); void swap(basic_spanbuf& rhs); // [[spanbuf.members]](#spanbuf.members "31.9.3.4 Member functions"), member functions std::span<charT> span() const noexcept; void span(std::span<charT> s) noexcept; protected:// [[spanbuf.virtuals]](#spanbuf.virtuals "31.9.3.5 Overridden virtual functions"), overridden virtual functions basic_streambuf<charT, traits>* setbuf(charT*, streamsize) override;
|
||||
pos_type seekoff(off_type off, ios_base::seekdir way,
|
||||
ios_base::openmode which = ios_base::in | ios_base::out) override;
|
||||
pos_type seekpos(pos_type sp,
|
||||
ios_base::openmode which = ios_base::in | ios_base::out) override; private: ios_base::openmode *mode*; // *exposition only* std::span<charT> *buf*; // *exposition only*};}
|
||||
|
||||
[1](#spanbuf.general-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10120)
|
||||
|
||||
The class template basic_spanbuf is derived from basic_streambuf to associate possibly the input sequence and possibly the output sequence
|
||||
with a sequence of arbitrary characters[.](#spanbuf.general-1.sentence-1)
|
||||
|
||||
The sequence is provided by an object of class span<charT>[.](#spanbuf.general-1.sentence-2)
|
||||
|
||||
[2](#spanbuf.general-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10126)
|
||||
|
||||
For the sake of exposition, the maintained data is presented here as:
|
||||
|
||||
- [(2.1)](#spanbuf.general-2.1)
|
||||
|
||||
ios_base::openmode *mode*, hasin set if the input sequence can be read, andout set if the output sequence can be written[.](#spanbuf.general-2.1.sentence-1)
|
||||
|
||||
- [(2.2)](#spanbuf.general-2.2)
|
||||
|
||||
std::span<charT> *buf* is the view to
|
||||
the underlying character sequence[.](#spanbuf.general-2.2.sentence-1)
|
||||
|
||||
#### [31.9.3.2](#spanbuf.cons) Constructors [[spanbuf.cons]](spanbuf.cons)
|
||||
|
||||
[ð](#lib:basic_spanbuf,constructor)
|
||||
|
||||
`explicit basic_spanbuf(std::span<charT> s,
|
||||
ios_base::openmode which = ios_base::in | ios_base::out);
|
||||
`
|
||||
|
||||
[1](#spanbuf.cons-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10147)
|
||||
|
||||
*Effects*: Initializes the base class with basic_streambuf() ([[streambuf.cons]](streambuf.cons "31.6.3.2 Constructors")),
|
||||
and *mode* with which[.](#spanbuf.cons-1.sentence-1)
|
||||
|
||||
Initializes the internal pointers as if calling span(s)[.](#spanbuf.cons-1.sentence-2)
|
||||
|
||||
[ð](#lib:basic_spanbuf,constructor_)
|
||||
|
||||
`basic_spanbuf(basic_spanbuf&& rhs);
|
||||
`
|
||||
|
||||
[2](#spanbuf.cons-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10160)
|
||||
|
||||
*Effects*: Initializes the base class with std::move(rhs) and*mode* with std::move(rhs.*mode*) and*buf* with std::move(rhs.*buf*)[.](#spanbuf.cons-2.sentence-1)
|
||||
|
||||
The sequence pointers in *this (eback(), gptr(), egptr(),pbase(), pptr(), epptr())
|
||||
obtain the values which rhs had[.](#spanbuf.cons-2.sentence-2)
|
||||
|
||||
It isimplementation-defined
|
||||
whether rhs.*buf*.empty() returns true after the move[.](#spanbuf.cons-2.sentence-3)
|
||||
|
||||
[3](#spanbuf.cons-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10173)
|
||||
|
||||
*Postconditions*: Let rhs_p refer to the state of rhs just prior to this construction[.](#spanbuf.cons-3.sentence-1)
|
||||
|
||||
- [(3.1)](#spanbuf.cons-3.1)
|
||||
|
||||
span().data() == rhs_p.span().data()
|
||||
|
||||
- [(3.2)](#spanbuf.cons-3.2)
|
||||
|
||||
span().size() == rhs_p.span().size()
|
||||
|
||||
- [(3.3)](#spanbuf.cons-3.3)
|
||||
|
||||
eback() == rhs_p.eback()
|
||||
|
||||
- [(3.4)](#spanbuf.cons-3.4)
|
||||
|
||||
gptr() == rhs_p.gptr()
|
||||
|
||||
- [(3.5)](#spanbuf.cons-3.5)
|
||||
|
||||
egptr() == rhs_p.egptr()
|
||||
|
||||
- [(3.6)](#spanbuf.cons-3.6)
|
||||
|
||||
pbase() == rhs_p.pbase()
|
||||
|
||||
- [(3.7)](#spanbuf.cons-3.7)
|
||||
|
||||
pptr() == rhs_p.pptr()
|
||||
|
||||
- [(3.8)](#spanbuf.cons-3.8)
|
||||
|
||||
epptr() == rhs_p.epptr()
|
||||
|
||||
- [(3.9)](#spanbuf.cons-3.9)
|
||||
|
||||
getloc() == rhs_p.getloc()
|
||||
|
||||
#### [31.9.3.3](#spanbuf.assign) Assignment and swap [[spanbuf.assign]](spanbuf.assign)
|
||||
|
||||
[ð](#lib:operator=,basic_spanbuf)
|
||||
|
||||
`basic_spanbuf& operator=(basic_spanbuf&& rhs);
|
||||
`
|
||||
|
||||
[1](#spanbuf.assign-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10198)
|
||||
|
||||
*Effects*: Equivalent to:basic_spanbuf tmp{std::move(rhs)};this->swap(tmp);return *this;
|
||||
|
||||
[ð](#lib:swap,basic_spanbuf)
|
||||
|
||||
`void swap(basic_spanbuf& rhs);
|
||||
`
|
||||
|
||||
[2](#spanbuf.assign-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10214)
|
||||
|
||||
*Effects*: Equivalent to:basic_streambuf<charT, traits>::swap(rhs);
|
||||
std::swap(*mode*, rhs.*mode*);
|
||||
std::swap(*buf*, rhs.*buf*);
|
||||
|
||||
[ð](#lib:swap,basic_spanbuf_)
|
||||
|
||||
`template<class charT, class traits>
|
||||
void swap(basic_spanbuf<charT, traits>& x, basic_spanbuf<charT, traits>& y);
|
||||
`
|
||||
|
||||
[3](#spanbuf.assign-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10231)
|
||||
|
||||
*Effects*: Equivalent to x.swap(y)[.](#spanbuf.assign-3.sentence-1)
|
||||
|
||||
#### [31.9.3.4](#spanbuf.members) Member functions [[spanbuf.members]](spanbuf.members)
|
||||
|
||||
[ð](#lib:span,basic_spanbuf)
|
||||
|
||||
`std::span<charT> span() const noexcept;
|
||||
`
|
||||
|
||||
[1](#spanbuf.members-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10244)
|
||||
|
||||
*Returns*: If ios_base::out is set in *mode*,
|
||||
returns std::span<charT>(pbase(), pptr()),
|
||||
otherwise returns *buf*[.](#spanbuf.members-1.sentence-1)
|
||||
|
||||
[*Note [1](#spanbuf.members-note-1)*:
|
||||
|
||||
In contrast to basic_stringbuf,
|
||||
the underlying sequence never grows and is not owned[.](#spanbuf.members-1.sentence-2)
|
||||
|
||||
An owning copy can be obtained
|
||||
by converting the result to basic_string<charT>[.](#spanbuf.members-1.sentence-3)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[ð](#lib:span,basic_spanbuf_)
|
||||
|
||||
`void span(std::span<charT> s) noexcept;
|
||||
`
|
||||
|
||||
[2](#spanbuf.members-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10264)
|
||||
|
||||
*Effects*: *buf* = s[.](#spanbuf.members-2.sentence-1)
|
||||
|
||||
Initializes the input and output sequences according to *mode*[.](#spanbuf.members-2.sentence-2)
|
||||
|
||||
[3](#spanbuf.members-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10269)
|
||||
|
||||
*Postconditions*:
|
||||
|
||||
- [(3.1)](#spanbuf.members-3.1)
|
||||
|
||||
If ios_base::out is set in *mode*,pbase() == s.data() && epptr() == pbase() + s.size() is true;
|
||||
* [(3.1.1)](#spanbuf.members-3.1.1)
|
||||
|
||||
in addition, if ios_base::ate is set in *mode*,pptr() == pbase() + s.size() is true,
|
||||
|
||||
* [(3.1.2)](#spanbuf.members-3.1.2)
|
||||
|
||||
otherwise pptr() == pbase() is true[.](#spanbuf.members-3.1.sentence-1)
|
||||
|
||||
- [(3.2)](#spanbuf.members-3.2)
|
||||
|
||||
If ios_base::in is set in *mode*,eback() == s.data() && gptr() == eback() && egptr() == eback() + s.size() is true[.](#spanbuf.members-3.2.sentence-1)
|
||||
|
||||
#### [31.9.3.5](#spanbuf.virtuals) Overridden virtual functions [[spanbuf.virtuals]](spanbuf.virtuals)
|
||||
|
||||
[1](#spanbuf.virtuals-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10292)
|
||||
|
||||
[*Note [1](#spanbuf.virtuals-note-1)*:
|
||||
|
||||
Because the underlying buffer is of fixed size,
|
||||
neither overflow, underflow, nor pbackfail can provide useful behavior[.](#spanbuf.virtuals-1.sentence-1)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[ð](#lib:seekoff,basic_spanbuf)
|
||||
|
||||
`pos_type seekoff(off_type off, ios_base::seekdir way,
|
||||
ios_base::openmode which = ios_base::in | ios_base::out) override;
|
||||
`
|
||||
|
||||
[2](#spanbuf.virtuals-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10306)
|
||||
|
||||
*Effects*: Alters the stream position within one or both of the
|
||||
controlled sequences, if possible, as follows:
|
||||
|
||||
- [(2.1)](#spanbuf.virtuals-2.1)
|
||||
|
||||
If ios_base::in is set in which, positions the input sequence;xnext is gptr(), xbeg is eback()[.](#spanbuf.virtuals-2.1.sentence-1)
|
||||
|
||||
- [(2.2)](#spanbuf.virtuals-2.2)
|
||||
|
||||
If ios_base::out is set in which, positions the output sequence;xnext is pptr(), xbeg is pbase()[.](#spanbuf.virtuals-2.2.sentence-1)
|
||||
|
||||
[3](#spanbuf.virtuals-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10319)
|
||||
|
||||
If both ios_base::in and ios_base::out are set in which and way is ios_base::cur,
|
||||
the positioning operation fails[.](#spanbuf.virtuals-3.sentence-1)
|
||||
|
||||
[4](#spanbuf.virtuals-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10324)
|
||||
|
||||
For a sequence to be positioned,
|
||||
if its next pointer xnext (either gptr() or pptr())
|
||||
is a null pointer and
|
||||
the new offset newoff as computed below is nonzero,
|
||||
the positioning operation fails[.](#spanbuf.virtuals-4.sentence-1)
|
||||
|
||||
Otherwise, the function determines baseoff as a value of type off_type as follows:
|
||||
|
||||
- [(4.1)](#spanbuf.virtuals-4.1)
|
||||
|
||||
0 when way is ios_base::beg;
|
||||
|
||||
- [(4.2)](#spanbuf.virtuals-4.2)
|
||||
|
||||
(pptr() - pbase()) for the output sequence, or(gptr() - eback()) for the input sequence
|
||||
when way is ios_base::cur;
|
||||
|
||||
- [(4.3)](#spanbuf.virtuals-4.3)
|
||||
|
||||
when way is ios_base::end :
|
||||
* [(4.3.1)](#spanbuf.virtuals-4.3.1)
|
||||
|
||||
(pptr() - pbase()) if ios_base::out is set in *mode* andios_base::in is not set in *mode*,
|
||||
|
||||
* [(4.3.2)](#spanbuf.virtuals-4.3.2)
|
||||
|
||||
*buf*.size() otherwise[.](#spanbuf.virtuals-4.sentence-2)
|
||||
|
||||
[5](#spanbuf.virtuals-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10351)
|
||||
|
||||
If baseoff+off would overflow, or
|
||||
if baseoff+off is less than zero, or
|
||||
if baseoff+off is greater than *buf*.size(),
|
||||
the positioning operation fails[.](#spanbuf.virtuals-5.sentence-1)
|
||||
|
||||
Otherwise, the function computesoff_type newoff = baseoff + off; and assigns xbeg + newoff to the next pointer xnext[.](#spanbuf.virtuals-5.sentence-2)
|
||||
|
||||
[6](#spanbuf.virtuals-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10362)
|
||||
|
||||
*Returns*: pos_type(off_type(-1)) if the positioning operation fails;pos_type(newoff) otherwise[.](#spanbuf.virtuals-6.sentence-1)
|
||||
|
||||
[ð](#lib:seekpos,basic_spanbuf)
|
||||
|
||||
`pos_type seekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out) override;
|
||||
`
|
||||
|
||||
[7](#spanbuf.virtuals-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10374)
|
||||
|
||||
*Effects*: Equivalent to:return seekoff(off_type(sp), ios_base::beg, which);
|
||||
|
||||
[ð](#lib:setbuf,basic_spanbuf)
|
||||
|
||||
`basic_streambuf<charT, traits>* setbuf(charT* s, streamsize n) override;
|
||||
`
|
||||
|
||||
[8](#spanbuf.virtuals-8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10388)
|
||||
|
||||
*Effects*: Equivalent to:this->span(std::span<charT>(s, n));return this;
|
||||
|
||||
### [31.9.4](#ispanstream) Class template basic_ispanstream [[ispanstream]](ispanstream)
|
||||
|
||||
#### [31.9.4.1](#ispanstream.general) General [[ispanstream.general]](ispanstream.general)
|
||||
|
||||
[ð](#lib:basic_ispanstream)
|
||||
|
||||
namespace std {template<class charT, class traits = char_traits<charT>>class basic_ispanstream : public basic_istream<charT, traits> {public:using char_type = charT; using int_type = typename traits::int_type; using pos_type = typename traits::pos_type; using off_type = typename traits::off_type; using traits_type = traits; // [[ispanstream.cons]](#ispanstream.cons "31.9.4.2 Constructors"), constructorsexplicit basic_ispanstream(std::span<charT> s,
|
||||
ios_base::openmode which = ios_base::in);
|
||||
basic_ispanstream(const basic_ispanstream&) = delete;
|
||||
basic_ispanstream(basic_ispanstream&& rhs); template<class ROS> explicit basic_ispanstream(ROS&& s);
|
||||
|
||||
basic_ispanstream& operator=(const basic_ispanstream&) = delete;
|
||||
basic_ispanstream& operator=(basic_ispanstream&& rhs); // [[ispanstream.swap]](#ispanstream.swap "31.9.4.3 Swap"), swapvoid swap(basic_ispanstream& rhs); // [[ispanstream.members]](#ispanstream.members "31.9.4.4 Member functions"), member functions basic_spanbuf<charT, traits>* rdbuf() const noexcept;
|
||||
|
||||
std::span<const charT> span() const noexcept; void span(std::span<charT> s) noexcept; template<class ROS> void span(ROS&& s) noexcept; private: basic_spanbuf<charT, traits> *sb*; // *exposition only*};}
|
||||
|
||||
[1](#ispanstream.general-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10440)
|
||||
|
||||
[*Note [1](#ispanstream.general-note-1)*:
|
||||
|
||||
Constructing an ispanstream from a [*string-literal*](lex.string#nt:string-literal "5.13.5 String literals [lex.string]") includes the termination character '\0' in the underlying spanbuf[.](#ispanstream.general-1.sentence-1)
|
||||
|
||||
â *end note*]
|
||||
|
||||
#### [31.9.4.2](#ispanstream.cons) Constructors [[ispanstream.cons]](ispanstream.cons)
|
||||
|
||||
[ð](#lib:basic_ispanstream,constructor)
|
||||
|
||||
`explicit basic_ispanstream(std::span<charT> s, ios_base::openmode which = ios_base::in);
|
||||
`
|
||||
|
||||
[1](#ispanstream.cons-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10455)
|
||||
|
||||
*Effects*: Initializes the base class withbasic_istream<charT, traits>(addressof(*sb*)) and *sb* withbasic_spanbuf<charT, traits>(s, which | ios_base::in) ([[spanbuf.cons]](#spanbuf.cons "31.9.3.2 Constructors"))[.](#ispanstream.cons-1.sentence-1)
|
||||
|
||||
[ð](#lib:basic_ispanstream,constructor_)
|
||||
|
||||
`basic_ispanstream(basic_ispanstream&& rhs);
|
||||
`
|
||||
|
||||
[2](#ispanstream.cons-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10469)
|
||||
|
||||
*Effects*: Initializes the base class with std::move(rhs) and *sb* with std::move(rhs.*sb*)[.](#ispanstream.cons-2.sentence-1)
|
||||
|
||||
Next, basic_istream<charT, traits>::set_rdbuf(addressof(*sb*)) is called
|
||||
to install the contained basic_spanbuf[.](#ispanstream.cons-2.sentence-2)
|
||||
|
||||
[ð](#lib:basic_ispanstream,constructor__)
|
||||
|
||||
`template<class ROS> explicit basic_ispanstream(ROS&& s)
|
||||
`
|
||||
|
||||
[3](#ispanstream.cons-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10483)
|
||||
|
||||
*Constraints*: ROS models ranges::[borrowed_range](range.range#concept:borrowed_range "25.4.2 Ranges [range.range]")[.](#ispanstream.cons-3.sentence-1)
|
||||
|
||||
<ROS, std::span<charT>> && [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_to [concept.convertible]")<ROS, std::span<charT const>> is true[.](#ispanstream.cons-3.sentence-2)
|
||||
|
||||
[4](#ispanstream.cons-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10489)
|
||||
|
||||
*Effects*: Let sp be std::span<const charT>(std::forward<ROS>(s))[.](#ispanstream.cons-4.sentence-1)
|
||||
|
||||
Equivalent to:basic_ispanstream(std::span<charT>(const_cast<charT*>(sp.data()), sp.size()))
|
||||
|
||||
#### [31.9.4.3](#ispanstream.swap) Swap [[ispanstream.swap]](ispanstream.swap)
|
||||
|
||||
[ð](#lib:swap,basic_ispanstream)
|
||||
|
||||
`void swap(basic_ispanstream& rhs);
|
||||
`
|
||||
|
||||
[1](#ispanstream.swap-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10506)
|
||||
|
||||
*Effects*: Equivalent to:basic_istream<charT, traits>::swap(rhs);*sb*.swap(rhs.*sb*);
|
||||
|
||||
[ð](#lib:swap,basic_ispanstream_)
|
||||
|
||||
`template<class charT, class traits>
|
||||
void swap(basic_ispanstream<charT, traits>& x, basic_ispanstream<charT, traits>& y);
|
||||
`
|
||||
|
||||
[2](#ispanstream.swap-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10522)
|
||||
|
||||
*Effects*: Equivalent to x.swap(y)[.](#ispanstream.swap-2.sentence-1)
|
||||
|
||||
#### [31.9.4.4](#ispanstream.members) Member functions [[ispanstream.members]](ispanstream.members)
|
||||
|
||||
[ð](#lib:rdbuf,basic_ispanstream)
|
||||
|
||||
`basic_spanbuf<charT, traits>* rdbuf() const noexcept;
|
||||
`
|
||||
|
||||
[1](#ispanstream.members-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10535)
|
||||
|
||||
*Effects*: Equivalent to:return const_cast<basic_spanbuf<charT, traits>*>(addressof(*sb*));
|
||||
|
||||
[ð](#lib:span,basic_ispanstream)
|
||||
|
||||
`std::span<const charT> span() const noexcept;
|
||||
`
|
||||
|
||||
[2](#ispanstream.members-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10549)
|
||||
|
||||
*Effects*: Equivalent to: return rdbuf()->span();
|
||||
|
||||
[ð](#lib:span,basic_ispanstream_)
|
||||
|
||||
`void span(std::span<charT> s) noexcept;
|
||||
`
|
||||
|
||||
[3](#ispanstream.members-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10560)
|
||||
|
||||
*Effects*: Equivalent to rdbuf()->span(s)[.](#ispanstream.members-3.sentence-1)
|
||||
|
||||
[ð](#ispanstream.members-itemdecl:4)
|
||||
|
||||
`template<class ROS> void span(ROS&& s) noexcept;
|
||||
`
|
||||
|
||||
[4](#ispanstream.members-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10570)
|
||||
|
||||
*Constraints*: ROS models ranges::[borrowed_range](range.range#concept:borrowed_range "25.4.2 Ranges [range.range]")[.](#ispanstream.members-4.sentence-1)
|
||||
|
||||
(<ROS, std::span<charT>>) && [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_to [concept.convertible]")<ROS, std::span<const charT>> is true[.](#ispanstream.members-4.sentence-2)
|
||||
|
||||
[5](#ispanstream.members-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10576)
|
||||
|
||||
*Effects*: Let sp be std::span<const charT>(std::forward<ROS>(s))[.](#ispanstream.members-5.sentence-1)
|
||||
|
||||
Equivalent to:this->span(std::span<charT>(const_cast<charT*>(sp.data()), sp.size()));
|
||||
|
||||
### [31.9.5](#ospanstream) Class template basic_ospanstream [[ospanstream]](ospanstream)
|
||||
|
||||
#### [31.9.5.1](#ospanstream.general) General [[ospanstream.general]](ospanstream.general)
|
||||
|
||||
[ð](#lib:basic_ospanstream)
|
||||
|
||||
namespace std {template<class charT, class traits = char_traits<charT>>class basic_ospanstream : public basic_ostream<charT, traits> {public:using char_type = charT; using int_type = typename traits::int_type; using pos_type = typename traits::pos_type; using off_type = typename traits::off_type; using traits_type = traits; // [[ospanstream.cons]](#ospanstream.cons "31.9.5.2 Constructors"), constructorsexplicit basic_ospanstream(std::span<charT> s,
|
||||
ios_base::openmode which = ios_base::out);
|
||||
basic_ospanstream(const basic_ospanstream&) = delete;
|
||||
basic_ospanstream(basic_ospanstream&& rhs);
|
||||
|
||||
basic_ospanstream& operator=(const basic_ospanstream&) = delete;
|
||||
basic_ospanstream& operator=(basic_ospanstream&& rhs); // [[ospanstream.swap]](#ospanstream.swap "31.9.5.3 Swap"), swapvoid swap(basic_ospanstream& rhs); // [[ospanstream.members]](#ospanstream.members "31.9.5.4 Member functions"), member functions basic_spanbuf<charT, traits>* rdbuf() const noexcept;
|
||||
|
||||
std::span<charT> span() const noexcept; void span(std::span<charT> s) noexcept; private: basic_spanbuf<charT, traits> *sb*; // *exposition only*};}
|
||||
|
||||
#### [31.9.5.2](#ospanstream.cons) Constructors [[ospanstream.cons]](ospanstream.cons)
|
||||
|
||||
[ð](#lib:basic_ospanstream,constructor)
|
||||
|
||||
`explicit basic_ospanstream(std::span<charT> s,
|
||||
ios_base::openmode which = ios_base::out);
|
||||
`
|
||||
|
||||
[1](#ospanstream.cons-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10635)
|
||||
|
||||
*Effects*: Initializes the base class withbasic_ostream<charT, traits>(addressof(*sb*)) and *sb* withbasic_spanbuf<charT, traits>(s, which | ios_base::out) ([[spanbuf.cons]](#spanbuf.cons "31.9.3.2 Constructors"))[.](#ospanstream.cons-1.sentence-1)
|
||||
|
||||
[ð](#lib:basic_ospanstream,constructor_)
|
||||
|
||||
`basic_ospanstream(basic_ospanstream&& rhs) noexcept;
|
||||
`
|
||||
|
||||
[2](#ospanstream.cons-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10649)
|
||||
|
||||
*Effects*: Initializes the base class with std::move(rhs) and *sb* with std::move(rhs.*sb*)[.](#ospanstream.cons-2.sentence-1)
|
||||
|
||||
Next, basic_ostream<charT, traits>::set_rdbuf(addressof(*sb*)) is called to install the contained basic_spanbuf[.](#ospanstream.cons-2.sentence-2)
|
||||
|
||||
#### [31.9.5.3](#ospanstream.swap) Swap [[ospanstream.swap]](ospanstream.swap)
|
||||
|
||||
[ð](#lib:swap,basic_ospanstream)
|
||||
|
||||
`void swap(basic_ospanstream& rhs);
|
||||
`
|
||||
|
||||
[1](#ospanstream.swap-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10665)
|
||||
|
||||
*Effects*: Equivalent to:basic_ostream<charT, traits>::swap(rhs);*sb*.swap(rhs.*sb*);
|
||||
|
||||
[ð](#lib:swap,basic_ospanstream_)
|
||||
|
||||
`template<class charT, class traits>
|
||||
void swap(basic_ospanstream<charT, traits>& x, basic_ospanstream<charT, traits>& y);
|
||||
`
|
||||
|
||||
[2](#ospanstream.swap-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10681)
|
||||
|
||||
*Effects*: Equivalent to x.swap(y)[.](#ospanstream.swap-2.sentence-1)
|
||||
|
||||
#### [31.9.5.4](#ospanstream.members) Member functions [[ospanstream.members]](ospanstream.members)
|
||||
|
||||
[ð](#lib:rdbuf,basic_ospanstream)
|
||||
|
||||
`basic_spanbuf<charT, traits>* rdbuf() const noexcept;
|
||||
`
|
||||
|
||||
[1](#ospanstream.members-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10694)
|
||||
|
||||
*Effects*: Equivalent to:return const_cast<basic_spanbuf<charT, traits>*>(addressof(*sb*));
|
||||
|
||||
[ð](#lib:span,basic_ospanstream)
|
||||
|
||||
`std::span<charT> span() const noexcept;
|
||||
`
|
||||
|
||||
[2](#ospanstream.members-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10708)
|
||||
|
||||
*Effects*: Equivalent to: return rdbuf()->span();
|
||||
|
||||
[ð](#lib:span,basic_ospanstream_)
|
||||
|
||||
`void span(std::span<charT> s) noexcept;
|
||||
`
|
||||
|
||||
[3](#ospanstream.members-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10719)
|
||||
|
||||
*Effects*: Equivalent to rdbuf()->span(s)[.](#ospanstream.members-3.sentence-1)
|
||||
|
||||
### [31.9.6](#spanstream) Class template basic_spanstream [[spanstream]](spanstream)
|
||||
|
||||
#### [31.9.6.1](#spanstream.general) General [[spanstream.general]](spanstream.general)
|
||||
|
||||
[ð](#lib:basic_spanstream)
|
||||
|
||||
namespace std {template<class charT, class traits = char_traits<charT>>class basic_spanstream : public basic_iostream<charT, traits> {public:using char_type = charT; using int_type = typename traits::int_type; using pos_type = typename traits::pos_type; using off_type = typename traits::off_type; using traits_type = traits; // [[spanstream.cons]](#spanstream.cons "31.9.6.2 Constructors"), constructorsexplicit basic_spanstream(std::span<charT> s,
|
||||
ios_base::openmode which = ios_base::out | ios_base::in);
|
||||
basic_spanstream(const basic_spanstream&) = delete;
|
||||
basic_spanstream(basic_spanstream&& rhs);
|
||||
|
||||
basic_spanstream& operator=(const basic_spanstream&) = delete;
|
||||
basic_spanstream& operator=(basic_spanstream&& rhs); // [[spanstream.swap]](#spanstream.swap "31.9.6.3 Swap"), swapvoid swap(basic_spanstream& rhs); // [[spanstream.members]](#spanstream.members "31.9.6.4 Member functions"), members basic_spanbuf<charT, traits>* rdbuf() const noexcept;
|
||||
|
||||
std::span<charT> span() const noexcept; void span(std::span<charT> s) noexcept; private: basic_spanbuf<charT, traits> *sb*; // *exposition only*};}
|
||||
|
||||
#### [31.9.6.2](#spanstream.cons) Constructors [[spanstream.cons]](spanstream.cons)
|
||||
|
||||
[ð](#lib:basic_spanstream,constructor)
|
||||
|
||||
`explicit basic_spanstream(std::span<charT> s,
|
||||
ios_base::openmode which = ios_base::out | ios_bas::in);
|
||||
`
|
||||
|
||||
[1](#spanstream.cons-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10774)
|
||||
|
||||
*Effects*: Initializes the base class withbasic_iostream<charT, traits>(addressof(*sb*)) and *sb* withbasic_spanbuf<charT, traits>(s, which) ([[spanbuf.cons]](#spanbuf.cons "31.9.3.2 Constructors"))[.](#spanstream.cons-1.sentence-1)
|
||||
|
||||
[ð](#lib:basic_spanstream,constructor_)
|
||||
|
||||
`basic_spanstream(basic_spanstream&& rhs);
|
||||
`
|
||||
|
||||
[2](#spanstream.cons-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10788)
|
||||
|
||||
*Effects*: Initializes the base class with std::move(rhs) and *sb* with std::move(rhs.*sb*)[.](#spanstream.cons-2.sentence-1)
|
||||
|
||||
Next, basic_iostream<charT, traits>::set_rdbuf(addressof(*sb*)) is called to install the contained basic_spanbuf[.](#spanstream.cons-2.sentence-2)
|
||||
|
||||
#### [31.9.6.3](#spanstream.swap) Swap [[spanstream.swap]](spanstream.swap)
|
||||
|
||||
[ð](#lib:swap,basic_spanstream)
|
||||
|
||||
`void swap(basic_spanstream& rhs);
|
||||
`
|
||||
|
||||
[1](#spanstream.swap-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10804)
|
||||
|
||||
*Effects*: Equivalent to:basic_iostream<charT, traits>::swap(rhs);*sb*.swap(rhs.*sb*);
|
||||
|
||||
[ð](#lib:swap,basic_spanstream_)
|
||||
|
||||
`template<class charT, class traits>
|
||||
void swap(basic_spanstream<charT, traits>& x, basic_spanstream<charT, traits>& y);
|
||||
`
|
||||
|
||||
[2](#spanstream.swap-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10820)
|
||||
|
||||
*Effects*: Equivalent to x.swap(y)[.](#spanstream.swap-2.sentence-1)
|
||||
|
||||
#### [31.9.6.4](#spanstream.members) Member functions [[spanstream.members]](spanstream.members)
|
||||
|
||||
[ð](#lib:rdbuf,basic_spanstream)
|
||||
|
||||
`basic_spanbuf<charT, traits>* rdbuf() const noexcept;
|
||||
`
|
||||
|
||||
[1](#spanstream.members-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10833)
|
||||
|
||||
*Effects*: Equivalent to:return const_cast<basic_spanbuf<charT, traits>*>(addressof(*sb*));
|
||||
|
||||
[ð](#lib:span,basic_spanstream)
|
||||
|
||||
`std::span<charT> span() const noexcept;
|
||||
`
|
||||
|
||||
[2](#spanstream.members-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10847)
|
||||
|
||||
*Effects*: Equivalent to: return rdbuf()->span();
|
||||
|
||||
[ð](#lib:span,basic_spanstream_)
|
||||
|
||||
`void span(std::span<charT> s) noexcept;
|
||||
`
|
||||
|
||||
[3](#spanstream.members-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10858)
|
||||
|
||||
*Effects*: Equivalent to rdbuf()->span(s)[.](#spanstream.members-3.sentence-1)
|
||||
28
cppdraft/span/streams/overview.md
Normal file
28
cppdraft/span/streams/overview.md
Normal file
@@ -0,0 +1,28 @@
|
||||
[span.streams.overview]
|
||||
|
||||
# 31 Input/output library [[input.output]](./#input.output)
|
||||
|
||||
## 31.9 Span-based streams [[span.streams]](span.streams#overview)
|
||||
|
||||
### 31.9.1 Overview [span.streams.overview]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10001)
|
||||
|
||||
The header <spanstream> defines class templates and types
|
||||
that associate stream buffers with objects whose types are
|
||||
specializations of span as described in [[views.span]](views.span "23.7.2.2 Class template span")[.](#1.sentence-1)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
A user of these classes is responsible for ensuring
|
||||
that the character sequence represented by the given span outlives the use of the sequence by objects of the classes in [[span.streams]](span.streams "31.9 Span-based streams")[.](#1.sentence-2)
|
||||
|
||||
Using multiple basic_spanbuf objects
|
||||
referring to overlapping underlying sequences from different threads,
|
||||
where at least one basic_spanbuf object is used
|
||||
for writing to the sequence,
|
||||
results in a data race[.](#1.sentence-3)
|
||||
|
||||
â *end note*]
|
||||
139
cppdraft/span/sub.md
Normal file
139
cppdraft/span/sub.md
Normal file
@@ -0,0 +1,139 @@
|
||||
[span.sub]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.7 Views [[views]](views#span.sub)
|
||||
|
||||
### 23.7.2 Contiguous access [[views.contiguous]](views.contiguous#span.sub)
|
||||
|
||||
#### 23.7.2.2 Class template span [[views.span]](views.span#span.sub)
|
||||
|
||||
#### 23.7.2.2.4 Subviews [span.sub]
|
||||
|
||||
[ð](#lib:span,first)
|
||||
|
||||
`template<size_t Count> constexpr span<element_type, Count> first() const;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20640)
|
||||
|
||||
*Mandates*: Count <= Extent is true[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20644)
|
||||
|
||||
*Hardened preconditions*: Count <= size() is true[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20648)
|
||||
|
||||
*Effects*: Equivalent to: return R{data(), Count}; where R is the return type[.](#3.sentence-1)
|
||||
|
||||
[ð](#lib:span,last)
|
||||
|
||||
`template<size_t Count> constexpr span<element_type, Count> last() const;
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20660)
|
||||
|
||||
*Mandates*: Count <= Extent is true[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20664)
|
||||
|
||||
*Hardened preconditions*: Count <= size() is true[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20668)
|
||||
|
||||
*Effects*: Equivalent to: return R{data() + (size() - Count), Count}; where R is the return type[.](#6.sentence-1)
|
||||
|
||||
[ð](#lib:span,subspan)
|
||||
|
||||
`template<size_t Offset, size_t Count = dynamic_extent>
|
||||
constexpr span<element_type, see below> subspan() const;
|
||||
`
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20681)
|
||||
|
||||
*Mandates*: Offset <= Extent && (Count == dynamic_extent || Count <= Extent - Offset) is true[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20688)
|
||||
|
||||
*Hardened preconditions*: Offset <= size() && (Count == dynamic_extent || Count <= size() - Offset) is true[.](#8.sentence-1)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20695)
|
||||
|
||||
*Effects*: Equivalent to:return span<ElementType, *see below*>( data() + Offset, Count != dynamic_extent ? Count : size() - Offset);
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20703)
|
||||
|
||||
*Remarks*: The second template argument of the returned span type is:Count != dynamic_extent ? Count : (Extent != dynamic_extent ? Extent - Offset : dynamic_extent)
|
||||
|
||||
[ð](#lib:span,first_)
|
||||
|
||||
`constexpr span<element_type, dynamic_extent> first(size_type count) const;
|
||||
`
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20719)
|
||||
|
||||
*Hardened preconditions*: count <= size() is true[.](#11.sentence-1)
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20723)
|
||||
|
||||
*Effects*: Equivalent to: return {data(), count};
|
||||
|
||||
[ð](#lib:span,last_)
|
||||
|
||||
`constexpr span<element_type, dynamic_extent> last(size_type count) const;
|
||||
`
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20734)
|
||||
|
||||
*Hardened preconditions*: count <= size() is true[.](#13.sentence-1)
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20738)
|
||||
|
||||
*Effects*: Equivalent to: return {data() + (size() - count), count};
|
||||
|
||||
[ð](#lib:span,subspan_)
|
||||
|
||||
`constexpr span<element_type, dynamic_extent> subspan(
|
||||
size_type offset, size_type count = dynamic_extent) const;
|
||||
`
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20750)
|
||||
|
||||
*Hardened preconditions*: offset <= size() && (count == dynamic_extent || count <= size() - offset) is true[.](#15.sentence-1)
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20757)
|
||||
|
||||
*Effects*: Equivalent to:return {data() + offset, count == dynamic_extent ? size() - offset : count};
|
||||
13
cppdraft/span/syn.md
Normal file
13
cppdraft/span/syn.md
Normal file
@@ -0,0 +1,13 @@
|
||||
[span.syn]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.7 Views [[views]](views#span.syn)
|
||||
|
||||
### 23.7.2 Contiguous access [[views.contiguous]](views.contiguous#span.syn)
|
||||
|
||||
#### 23.7.2.1 Header <span> synopsis [span.syn]
|
||||
|
||||
[ð](#header:%3cspan%3e)
|
||||
|
||||
#include <initializer_list> // see [[initializer.list.syn]](initializer.list.syn "17.11.2 Header <initializer_list> synopsis")// mostly freestandingnamespace std {// constantsinline constexpr size_t [dynamic_extent](#lib:dynamic_extent "23.7.2.1 Header <span> synopsis [span.syn]") = numeric_limits<size_t>::max(); template<class T>concept [*integral-constant-like*](#concept:integral-constant-like "23.7.2.1 Header <span> synopsis [span.syn]") = // *exposition only* is_integral_v<remove_cvref_t<decltype(T::value)>> &&!is_same_v<bool, remove_const_t<decltype(T::value)>> &&[convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_to [concept.convertible]")<T, decltype(T::value)> &&[equality_comparable_with](concept.equalitycomparable#concept:equality_comparable_with "18.5.4 Concept equality_comparable [concept.equalitycomparable]")<T, decltype(T::value)> && bool_constant<T() == T::value>::value && bool_constant<static_cast<decltype(T::value)>(T()) == T::value>::value; template<class T>constexpr size_t [*maybe-static-ext*](#concept:maybe-static-ext "23.7.2.1 Header <span> synopsis [span.syn]") = dynamic_extent; // *exposition only*template<[*integral-constant-like*](#concept:integral-constant-like "23.7.2.1 Header <span> synopsis [span.syn]") T>constexpr size_t [*maybe-static-ext*](#concept:maybe-static-ext "23.7.2.1 Header <span> synopsis [span.syn]")<T> = {T::value}; // [[views.span]](views.span "23.7.2.2 Class template span"), class template spantemplate<class ElementType, size_t Extent = dynamic_extent>class span; // partially freestandingtemplate<class ElementType, size_t Extent>constexpr bool ranges::enable_view<span<ElementType, Extent>> = true; template<class ElementType, size_t Extent>constexpr bool ranges::enable_borrowed_range<span<ElementType, Extent>> = true; // [[span.objectrep]](span.objectrep "23.7.2.3 Views of object representation"), views of object representationtemplate<class ElementType, size_t Extent> span<const byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent> as_bytes(span<ElementType, Extent> s) noexcept; template<class ElementType, size_t Extent> span<byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent> as_writable_bytes(span<ElementType, Extent> s) noexcept;}
|
||||
Reference in New Issue
Block a user