Files
cppdraft_translate/cppdraft/string/erase.md
2025-10-25 03:02:53 +03:00

3.6 KiB
Raw Blame History

[string.erase]

27 Strings library [strings]

27.4 String classes [string.classes]

27.4.3 Class template basic_string [basic.string]

27.4.3.7 Modifiers [string.modifiers]

27.4.3.7.5 basic_string::erase [string.erase]

🔗

constexpr basic_string& erase(size_type pos = 0, size_type n = npos);

1

#

Effects: Determines the effective length xlen of the string to be removed as the smaller of n andsize() - pos.

Removes the characters in the range [begin() + pos, begin() + pos + xlen).

2

#

Returns: *this.

3

#

Throws: out_of_range if pos> size().

🔗

constexpr iterator erase(const_iterator p);

4

#

Preconditions: p is a valid dereferenceable iterator on *this.

5

#

Effects: Removes the character referred to by p.

6

#

Returns: An iterator which points to the element immediately following p prior to the element being erased.

If no such element exists,end() is returned.

7

#

Throws: Nothing.

🔗

constexpr iterator erase(const_iterator first, const_iterator last);

8

#

Preconditions: first and last are valid iterators on*this.

[first, last) is a valid range.

9

#

Effects: Removes the characters in the range [first, last).

10

#

Returns: An iterator which points to the element pointed to by last prior to the other elements being erased.

If no such element exists,end() is returned.

11

#

Throws: Nothing.

🔗

constexpr void pop_back();

12

#

Hardened preconditions: empty() is false.

13

#

Effects: Equivalent to erase(end() - 1).

14

#

Throws: Nothing.