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

2.6 KiB

[string.access]

27 Strings library [strings]

27.4 String classes [string.classes]

27.4.3 Class template basic_string [basic.string]

27.4.3.6 Element access [string.access]

🔗

constexpr const_reference operator[](size_type pos) const; constexpr reference operator[](size_type pos);

1

#

Hardened preconditions: pos <= size() is true.

2

#

Returns: *(begin() + pos) if pos < size().

Otherwise, returns a reference to an object of type charT with valuecharT(), where modifying the object to any value other thancharT() leads to undefined behavior.

3

#

Throws: Nothing.

4

#

Complexity: Constant time.

🔗

constexpr const_reference at(size_type pos) const; constexpr reference at(size_type pos);

5

#

Returns: operator.

6

#

Throws: out_of_range ifpos >= size().

🔗

constexpr const charT& front() const; constexpr charT& front();

7

#

Hardened preconditions: empty() is false.

8

#

Effects: Equivalent to: return operator;

🔗

constexpr const charT& back() const; constexpr charT& back();

9

#

Hardened preconditions: empty() is false.

10

#

Effects: Equivalent to: return operator[](size() - 1);