24 Strings library [strings]

24.3 String classes [string.classes]

24.3.2 Class template basic_­string [basic.string]

24.3.2.6 basic_­string modifiers [string.modifiers]

24.3.2.6.3 basic_­string​::​assign [string.assign]

basic_string& assign(const basic_string& str);
Effects: Equivalent to *this = str.
Returns: *this.
basic_string& assign(basic_string&& str) noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value || allocator_traits<Allocator>::is_always_equal::value);
Effects: Equivalent to *this = std​::​move(str).
Returns: *this.
basic_string& assign(const basic_string& str, size_type pos, size_type n = npos);
Throws: out_­of_­range if pos > str.size().
Effects: Determines the effective length rlen of the string to assign as the smaller of n and str.size() - pos and calls assign(str.data() + pos, rlen).
Returns: *this.
basic_string& assign(basic_string_view<charT, traits> sv);
Effects: Equivalent to: return assign(sv.data(), sv.size());
template<class T> basic_string& assign(const T& t, size_type pos, size_type n = npos);
Throws: out_­of_­range if pos > sv.size().
Effects: Creates a variable, sv, as if by basic_­string_­view<charT, traits> sv = t.
Determines the effective length rlen of the string to assign as the smaller of n and sv.size() - pos and calls assign(sv.data() + pos, rlen).
Remarks: This function shall not participate in overload resolution unless is_­convertible_­v<const T&, basic_­string_­view<charT, traits>> is true and is_­convertible_­v<const T&, const charT*> is false.
Returns: *this.
basic_string& assign(const charT* s, size_type n);
Requires: s points to an array of at least n elements of charT.
Throws: length_­error if n > max_­size().
Effects: Replaces the string controlled by *this with a string of length n whose elements are a copy of those pointed to by s.
Returns: *this.
basic_string& assign(const charT* s);
Requires: s points to an array of at least traits​::​length(s) + 1 elements of charT.
Effects: Calls assign(s, traits​::​length(s)).
Returns: *this.
basic_string& assign(initializer_list<charT> il);
Effects: Calls assign(il.begin(), il.size()).
*this.
basic_string& assign(size_type n, charT c);
Effects: Equivalent to assign(basic_­string(n, c)).
Returns: *this.
template<class InputIterator> basic_string& assign(InputIterator first, InputIterator last);
Effects: Equivalent to assign(basic_­string(first, last, get_­allocator())).
Returns: *this.