32 using traits_type = string_view::traits_type;
33 using value_type = string_view::value_type;
34 using pointer = string_view::pointer;
35 using const_pointer = string_view::const_pointer;
36 using reference = string_view::reference;
37 using const_reference = string_view::const_reference;
38 using iterator = string_view::iterator;
39 using const_iterator = string_view::const_iterator;
40 using const_reverse_iterator = string_view::const_reverse_iterator;
41 using reverse_iterator = string_view::reverse_iterator;
42 using size_type = string_view::size_type;
43 using difference_type = string_view::difference_type;
45 static constexpr size_type npos = string_view::npos;
47 constexpr buffer()
noexcept =
default;
48 constexpr buffer(
char const* s, std::size_t count)
51 constexpr buffer(
char const* s)
58 typename std::enable_if_t<
59 is_input_iterator<It>::value &&
60 is_input_iterator<End>::value
63 constexpr buffer(It first, End last)
64 :view_{&*first, &*first + std::distance(first, last)}
73 explicit constexpr buffer(string_view sv)
74 : view_{force_move(sv)}
83 explicit buffer(std::string) =
delete;
92 : view_{force_move(sv)},
93 life_{force_move(life)}
97 buffer(
char const* s, std::size_t count, any life)
99 life_{force_move(life)}
101 buffer(
char const* s, any life)
103 life_{force_move(life)}
109 typename std::enable_if_t<
110 is_input_iterator<It>::value &&
111 is_input_iterator<End>::value
114 buffer(It first, End last, any life)
115 : view_{&*first, static_cast<std::size_t>(std::distance(first, last))},
116 life_{force_move(life)}
119 constexpr const_iterator begin() const noexcept {
120 return view_.begin();
122 constexpr const_iterator cbegin() const noexcept {
123 return view_.cbegin();
125 constexpr const_iterator end() const noexcept {
128 constexpr const_iterator cend() const noexcept {
131 constexpr const_reverse_iterator rbegin() const noexcept {
132 return view_.rbegin();
134 constexpr const_reverse_iterator crbegin() const noexcept {
135 return view_.crbegin();
137 constexpr const_reverse_iterator rend() const noexcept {
140 constexpr const_reverse_iterator crend() const noexcept {
141 return view_.crend();
144 constexpr const_reference operator[](size_type pos)
const {
147 constexpr const_reference at(size_type pos)
const {
148 return view_.at(pos);
151 constexpr const_reference front()
const {
152 return view_.front();
154 constexpr const_reference back()
const {
158 constexpr const_pointer data() const noexcept {
162 constexpr size_type size() const noexcept {
165 constexpr size_type length() const noexcept {
166 return view_.length();
168 constexpr size_type max_size() const noexcept {
169 return view_.max_size();
172 constexpr bool empty() const noexcept {
173 return view_.empty();
176 constexpr void remove_prefix(size_type n) {
177 view_.remove_prefix(n);
180 constexpr void remove_suffix(size_type n) {
181 view_.remove_suffix(n);
184 void swap(buffer& buf)
noexcept {
185 view_.swap(buf.view_);
186 life_.swap(buf.life_);
189 size_type copy(
char* dest, size_type count, size_type pos = 0 )
const {
190 return view_.copy(dest, count, pos);
203 return buffer(view_.substr(pos, count), life_);
216 return buffer(view_.substr(pos, count), force_move(life_));
219 constexpr int compare(
buffer const& buf)
const noexcept {
220 return view_.compare(buf.view_);
222 constexpr int compare(string_view
const& v)
const noexcept {
223 return view_.compare(v);
225 constexpr int compare(size_type pos1, size_type count1, buffer
const& buf)
const noexcept {
226 return view_.compare(pos1, count1, buf.view_);
228 constexpr int compare(size_type pos1, size_type count1, string_view
const& v)
const noexcept {
229 return view_.compare(pos1, count1, v);
231 constexpr int compare(
238 return view_.compare(pos1, count1, buf.view_, pos2, count2);
240 constexpr int compare(
243 string_view
const& v,
247 return view_.compare(pos1, count1, v, pos2, count2);
249 constexpr int compare(
char const* s)
const noexcept {
250 return view_.compare(s);
252 constexpr int compare(size_type pos1, size_type count1,
char const* s)
const noexcept {
253 return view_.compare(pos1, count1, s);
255 constexpr int compare(
262 return view_.compare(pos1, count1, s, pos2, count2);
265 constexpr size_type find(buffer
const& buf, size_type pos = 0) const noexcept {
266 return view_.find(buf.view_, pos);
268 constexpr size_type find(string_view v, size_type pos = 0) const noexcept {
269 return view_.find(v, pos);
271 constexpr size_type find(
char ch, size_type pos = 0) const noexcept {
272 return view_.find(ch, pos);
274 constexpr size_type find(
char const* s, size_type pos, size_type count)
const {
275 return view_.find(s, pos, count);
277 constexpr size_type find(
char const* s, size_type pos = 0)
const {
278 return view_.find(s, pos);
281 constexpr size_type rfind(buffer
const& buf, size_type pos = npos)
const noexcept {
282 return view_.rfind(buf.view_, pos);
284 constexpr size_type rfind( string_view v, size_type pos = npos)
const noexcept {
285 return view_.rfind(v, pos);
287 constexpr size_type rfind(
char ch, size_type pos = npos)
const noexcept {
288 return view_.rfind(ch, pos);
290 constexpr size_type rfind(
char const* s, size_type pos, size_type count)
const {
291 return view_.rfind(s, pos, count);
293 constexpr size_type rfind(
char const* s, size_type pos = npos)
const {
294 return view_.rfind(s, pos);
297 constexpr size_type find_first_of(buffer
const& buf, size_type pos = 0) const noexcept {
298 return view_.find_first_of(buf.view_, pos);
300 constexpr size_type find_first_of( string_view v, size_type pos = 0) const noexcept {
301 return view_.find_first_of(v, pos);
303 constexpr size_type find_first_of(
char ch, size_type pos = 0) const noexcept {
304 return view_.find_first_of(ch, pos);
306 constexpr size_type find_first_of(
char const* s, size_type pos, size_type count)
const {
307 return view_.find_first_of(s, pos, count);
309 constexpr size_type find_first_of(
char const* s, size_type pos = 0)
const {
310 return view_.find_first_of(s, pos);
313 constexpr size_type find_last_of(buffer
const& buf, size_type pos = npos)
const noexcept {
314 return view_.find_last_of(buf.view_, pos);
316 constexpr size_type find_last_of( string_view v, size_type pos = npos)
const noexcept {
317 return view_.find_last_of(v, pos);
319 constexpr size_type find_last_of(
char ch, size_type pos = npos)
const noexcept {
320 return view_.find_last_of(ch, pos);
322 constexpr size_type find_last_of(
char const* s, size_type pos, size_type count)
const {
323 return view_.find_last_of(s, pos, count);
325 constexpr size_type find_last_of(
char const* s, size_type pos = npos)
const {
326 return view_.find_last_of(s, pos);
329 constexpr size_type find_first_not_of(buffer
const& buf, size_type pos = 0) const noexcept {
330 return view_.find_first_not_of(buf.view_, pos);
332 constexpr size_type find_first_not_of( string_view v, size_type pos = 0) const noexcept {
333 return view_.find_first_not_of(v, pos);
335 constexpr size_type find_first_not_of(
char ch, size_type pos = 0) const noexcept {
336 return view_.find_first_not_of(ch, pos);
338 constexpr size_type find_first_not_of(
char const* s, size_type pos, size_type count)
const {
339 return view_.find_first_not_of(s, pos, count);
341 constexpr size_type find_first_not_of(
char const* s, size_type pos = 0)
const {
342 return view_.find_first_not_of(s, pos);
345 constexpr size_type find_last_not_of(buffer
const& buf, size_type pos = npos)
const noexcept {
346 return view_.find_last_not_of(buf.view_, pos);
348 constexpr size_type find_last_not_of( string_view v, size_type pos = npos)
const noexcept {
349 return view_.find_last_not_of(v, pos);
351 constexpr size_type find_last_not_of(
char ch, size_type pos = npos)
const noexcept {
352 return view_.find_last_not_of(ch, pos);
354 constexpr size_type find_last_not_of(
char const* s, size_type pos, size_type count)
const {
355 return view_.find_last_not_of(s, pos, count);
357 constexpr size_type find_last_not_of(
char const* s, size_type pos = npos)
const {
358 return view_.find_last_not_of(s, pos);
361 any
const& get_life()
const {
365 operator as::const_buffer()
const {
366 return as::buffer(view_.data(), view_.size());
369 operator string_view()
const {
374 constexpr bool operator==(buffer
const& lhs, buffer
const& rhs )
noexcept {
375 return lhs.view_ == rhs.view_;
378 constexpr bool operator!=(buffer
const& lhs, buffer
const& rhs )
noexcept {
379 return lhs.view_ != rhs.view_;
382 constexpr bool operator<(buffer
const& lhs, buffer
const& rhs )
noexcept {
383 return lhs.view_ < rhs.view_;
386 constexpr bool operator<=(buffer
const& lhs, buffer
const& rhs )
noexcept {
387 return lhs.view_ <= rhs.view_;
390 constexpr bool operator>(buffer
const& lhs, buffer
const& rhs )
noexcept {
391 return lhs.view_ > rhs.view_;
394 constexpr bool operator>=(buffer
const& lhs, buffer
const& rhs )
noexcept {
395 return lhs.view_ >= rhs.view_;
399 std::ostream& operator<<(std::ostream& o, buffer
const& buf) {