From Jason Turner

[string.view.template.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpmb9j6ymc/{from.md → to.md} +153 -0
tmp/tmpmb9j6ymc/{from.md → to.md} RENAMED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### General <a id="string.view.template.general">[[string.view.template.general]]</a>
2
+
3
+ ``` cpp
4
+ namespace std {
5
+ template<class charT, class traits = char_traits<charT>>
6
+ class basic_string_view {
7
+ public:
8
+ // types
9
+ using traits_type = traits;
10
+ using value_type = charT;
11
+ using pointer = value_type*;
12
+ using const_pointer = const value_type*;
13
+ using reference = value_type&;
14
+ using const_reference = const value_type&;
15
+ using const_iterator = implementation-defined // type of basic_string_view::const_iterator; // see [string.view.iterators]
16
+ using iterator = const_iterator;
17
+ using const_reverse_iterator = reverse_iterator<const_iterator>;
18
+ using reverse_iterator = const_reverse_iterator;
19
+ using size_type = size_t;
20
+ using difference_type = ptrdiff_t;
21
+ static constexpr size_type npos = size_type(-1);
22
+
23
+ // [string.view.cons], construction and assignment
24
+ constexpr basic_string_view() noexcept;
25
+ constexpr basic_string_view(const basic_string_view&) noexcept = default;
26
+ constexpr basic_string_view& operator=(const basic_string_view&) noexcept = default;
27
+ constexpr basic_string_view(const charT* str);
28
+ basic_string_view(nullptr_t) = delete;
29
+ constexpr basic_string_view(const charT* str, size_type len);
30
+ template<class It, class End>
31
+ constexpr basic_string_view(It begin, End end);
32
+ template<class R>
33
+ constexpr explicit basic_string_view(R&& r);
34
+
35
+ // [string.view.iterators], iterator support
36
+ constexpr const_iterator begin() const noexcept;
37
+ constexpr const_iterator end() const noexcept;
38
+ constexpr const_iterator cbegin() const noexcept;
39
+ constexpr const_iterator cend() const noexcept;
40
+ constexpr const_reverse_iterator rbegin() const noexcept;
41
+ constexpr const_reverse_iterator rend() const noexcept;
42
+ constexpr const_reverse_iterator crbegin() const noexcept;
43
+ constexpr const_reverse_iterator crend() const noexcept;
44
+
45
+ // [string.view.capacity], capacity
46
+ constexpr size_type size() const noexcept;
47
+ constexpr size_type length() const noexcept;
48
+ constexpr size_type max_size() const noexcept;
49
+ [[nodiscard]] constexpr bool empty() const noexcept;
50
+
51
+ // [string.view.access], element access
52
+ constexpr const_reference operator[](size_type pos) const;
53
+ constexpr const_reference at(size_type pos) const;
54
+ constexpr const_reference front() const;
55
+ constexpr const_reference back() const;
56
+ constexpr const_pointer data() const noexcept;
57
+
58
+ // [string.view.modifiers], modifiers
59
+ constexpr void remove_prefix(size_type n);
60
+ constexpr void remove_suffix(size_type n);
61
+ constexpr void swap(basic_string_view& s) noexcept;
62
+
63
+ // [string.view.ops], string operations
64
+ constexpr size_type copy(charT* s, size_type n, size_type pos = 0) const;
65
+
66
+ constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
67
+
68
+ constexpr int compare(basic_string_view s) const noexcept;
69
+ constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const;
70
+ constexpr int compare(size_type pos1, size_type n1, basic_string_view s,
71
+ size_type pos2, size_type n2) const;
72
+ constexpr int compare(const charT* s) const;
73
+ constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
74
+ constexpr int compare(size_type pos1, size_type n1, const charT* s, size_type n2) const;
75
+
76
+ constexpr bool starts_with(basic_string_view x) const noexcept;
77
+ constexpr bool starts_with(charT x) const noexcept;
78
+ constexpr bool starts_with(const charT* x) const;
79
+ constexpr bool ends_with(basic_string_view x) const noexcept;
80
+ constexpr bool ends_with(charT x) const noexcept;
81
+ constexpr bool ends_with(const charT* x) const;
82
+
83
+ constexpr bool contains(basic_string_view x) const noexcept;
84
+ constexpr bool contains(charT x) const noexcept;
85
+ constexpr bool contains(const charT* x) const;
86
+
87
+ // [string.view.find], searching
88
+ constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept;
89
+ constexpr size_type find(charT c, size_type pos = 0) const noexcept;
90
+ constexpr size_type find(const charT* s, size_type pos, size_type n) const;
91
+ constexpr size_type find(const charT* s, size_type pos = 0) const;
92
+ constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept;
93
+ constexpr size_type rfind(charT c, size_type pos = npos) const noexcept;
94
+ constexpr size_type rfind(const charT* s, size_type pos, size_type n) const;
95
+ constexpr size_type rfind(const charT* s, size_type pos = npos) const;
96
+
97
+ constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept;
98
+ constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept;
99
+ constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const;
100
+ constexpr size_type find_first_of(const charT* s, size_type pos = 0) const;
101
+ constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept;
102
+ constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept;
103
+ constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const;
104
+ constexpr size_type find_last_of(const charT* s, size_type pos = npos) const;
105
+ constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept;
106
+ constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept;
107
+ constexpr size_type find_first_not_of(const charT* s, size_type pos,
108
+ size_type n) const;
109
+ constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const;
110
+ constexpr size_type find_last_not_of(basic_string_view s,
111
+ size_type pos = npos) const noexcept;
112
+ constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
113
+ constexpr size_type find_last_not_of(const charT* s, size_type pos,
114
+ size_type n) const;
115
+ constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
116
+
117
+ private:
118
+ const_pointer data_; // exposition only
119
+ size_type size_; // exposition only
120
+ };
121
+
122
+ // [string.view.deduct], deduction guides
123
+ template<class It, class End>
124
+ basic_string_view(It, End) -> basic_string_view<iter_value_t<It>>;
125
+ template<class R>
126
+ basic_string_view(R&&) -> basic_string_view<ranges::range_value_t<R>>;
127
+ }
128
+ ```
129
+
130
+ [^2]
131
+
132
+ In every specialization `basic_string_view<charT, traits>`, the type
133
+ `traits` shall meet the character traits requirements [[char.traits]].
134
+
135
+ [*Note 1*: The program is ill-formed if `traits::char_type` is not the
136
+ same type as `charT`. — *end note*]
137
+
138
+ For a `basic_string_view str`, any operation that invalidates a pointer
139
+ in the range
140
+
141
+ ``` cpp
142
+ {[}str.data(), {str.data() + str.size()}{)}
143
+ ```
144
+
145
+ invalidates pointers, iterators, and references returned from `str`’s
146
+ member functions.
147
+
148
+ The complexity of `basic_string_view` member functions is 𝑂(1) unless
149
+ otherwise specified.
150
+
151
+ `basic_string_view<charT, traits>` is a trivially copyable type
152
+ [[term.trivially.copyable.type]].
153
+