Files
2025-10-25 03:02:53 +03:00

3.3 KiB
Raw Permalink Blame History

[string.view.access]

27 Strings library [strings]

27.3 String view classes [string.view]

27.3.3 Class template basic_string_view [string.view.template]

27.3.3.6 Element access [string.view.access]

🔗

constexpr const_reference operator[](size_type pos) const;

1

#

Hardened preconditions: pos < size() is true.

[Note 1:

This precondition is stronger than the one on basic_string::operator[].

— end note]

2

#

Returns: data_[pos].

3

#

Throws: Nothing.

🔗

constexpr const_reference at(size_type pos) const;

4

#

Returns: data_[pos].

5

#

Throws: out_of_range if pos >= size().

🔗

constexpr const_reference front() const;

6

#

Hardened preconditions: empty() is false.

7

#

Returns: data_[0].

8

#

Throws: Nothing.

🔗

constexpr const_reference back() const;

9

#

Hardened preconditions: empty() is false.

10

#

Returns: data_[size() - 1].

11

#

Throws: Nothing.

🔗

constexpr const_pointer data() const noexcept;

12

#

Returns: data_.

13

#

[Note 2:

Unlike basic_string::data() and string-literals,data() can return a pointer to a buffer that is not null-terminated.

Therefore it is typically a mistake to pass data() to a function that takes just a const charT* and expects a null-terminated string.

— end note]