[#bsl-basic_string-0ce-assign-01] = xref:bsl.adoc[bsl]::xref:bsl/basic_string-0ce.adoc[basic_string<char16_t>]::assign :relfileprefix: ../../ :mrdocs: `assign` overloads == Synopses Declared in `<bslstl_string.h>` Assign to this string the value of the specified `replacement` string, propagate to this object the allocator of `replacement` if the `ALLOCATOR` type has trait `propagate_on_container_move_assignment`, and return a reference providing modifiable access to this string. The content of `replacement` is moved (in constant time) to this string if `get_allocator() == rhs.get_allocator()` (after accounting for the aforementioned trait). `replacement` is left in a valid but unspecified state. Note that this method has exactly the same behavior as the corresponding `operator=`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char16_t>]& xref:bsl/basic_string-0ce/assign-08e.adoc[assign](xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef<basic_string<char16_t>>] replacement) noexcept(false); ---- [.small]#xref:bsl/basic_string-0ce/assign-08e.adoc[_» more..._]# Assign to this string the value resulting from first clearing this string and then inserting (in order) each `CHAR_TYPE` object in the specified `values` initializer list. Return a reference providing modifiable access to this string. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char16_t>]& xref:bsl/basic_string-0ce/assign-04.adoc[assign](std::initializer_list<char16_t> values); ---- [.small]#xref:bsl/basic_string-0ce/assign-04.adoc[_» more..._]# Assign to this string the value of the specified `replacement` string, propagate to this object the allocator of `replacement` if the `ALLOCATOR` type has trait `propagate_on_container_copy_assignment`, and return a reference providing modifiable access to this string. Note that this method has exactly the same behavior as the corresponding `operator=`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char16_t>]& xref:bsl/basic_string-0ce/assign-00.adoc[assign](xref:bsl/basic_string-0faf.adoc[basic_string<char16_t>] const& replacement); ---- [.small]#xref:bsl/basic_string-0ce/assign-00.adoc[_» more..._]# Assign to this string the value of the specified null‐terminated `characterString` (of length `CHAR_TRAITS::length(characterString)`), and return a reference providing modifiable access to this string. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char16_t>]& xref:bsl/basic_string-0ce/assign-0ea.adoc[assign](char16_t const* characterString); ---- [.small]#xref:bsl/basic_string-0ce/assign-0ea.adoc[_» more..._]# Assign to this string the value of the specified `replacement`, and return a reference providing modifiable access to this string. Note that this method has exactly the same behavior as the corresponding `operator=`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class STRING_VIEW_LIKE_TYPE> xref:bsl/basic_string-0faf.adoc[basic_string<char16_t>]& xref:bsl/basic_string-0ce/assign-072.adoc[assign](STRING_VIEW_LIKE_TYPE const& replacement); ---- [.small]#xref:bsl/basic_string-0ce/assign-072.adoc[_» more..._]# Assign to this string the value of the specified `string`, and return a reference providing modifiable access to this string. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class ALLOC2> xref:bsl/basic_string-0faf.adoc[basic_string<char16_t>]& xref:bsl/basic_string-0ce/assign-0e3.adoc[assign](std::basic_string<char16_t, char_traits<char16_t>, ALLOC2> const& string); ---- [.small]#xref:bsl/basic_string-0ce/assign-0e3.adoc[_» more..._]# Assign to this string the value of a string of the specified `numChars` length whose every character is equal to the specified `character`, and return a reference providing modifiable access to this string. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char16_t>]& xref:bsl/basic_string-0ce/assign-06.adoc[assign]( xref:bsl/basic_string-0ce/size_type.adoc[size_type] numChars, char16_t character); ---- [.small]#xref:bsl/basic_string-0ce/assign-06.adoc[_» more..._]# Assign to this string the specified initial `numChars` characters in the specified `characterString`, and return a reference providing modifiable access to this string. The behavior is undefined unless `characterString` is at least `numChars` long. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char16_t>]& xref:bsl/basic_string-0ce/assign-0b.adoc[assign]( char16_t const* characterString, xref:bsl/basic_string-0ce/size_type.adoc[size_type] numChars); ---- [.small]#xref:bsl/basic_string-0ce/assign-0b.adoc[_» more..._]# Assign to this string the characters in the range starting at the specified `first` iterator and ending right before the specified `last` iterator of the (template parameter) type `INPUT_ITER`. Return a reference providing modifiable access to this string. The behavior is undefined unless `first` and `last` refer to a sequence of valid values where `first` is at a position at or before `last`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class INPUT_ITER> xref:bsl/basic_string-0faf.adoc[basic_string<char16_t>]& xref:bsl/basic_string-0ce/assign-075.adoc[assign]( INPUT_ITER first, INPUT_ITER last); ---- [.small]#xref:bsl/basic_string-0ce/assign-075.adoc[_» more..._]# Assign to this string the value of the optionally specified `numChars` characters starting at the specified `position` in the specified `replacement` string, or the suffix of `replacement` starting at `position` if `position + numChars > replacement.length()`. If `numChars` is not specified, `npos` is used. Return a reference providing modifiable access to this string. Throw `out_of_range` if `position > replacement.length()`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char16_t>]& xref:bsl/basic_string-0ce/assign-02.adoc[assign]( xref:bsl/basic_string-0faf.adoc[basic_string<char16_t>] const& replacement, xref:bsl/basic_string-0ce/size_type.adoc[size_type] position, xref:bsl/basic_string-0ce/size_type.adoc[size_type] numChars = npos); ---- [.small]#xref:bsl/basic_string-0ce/assign-02.adoc[_» more..._]# Assign to this string the value of the optionally specified `numChars` characters starting at the specified `position` in the specified `replacement`, or the suffix of the `replacement` starting at `position` if `position + numChars > replacement.length()`. If `numChars` is not specified, `npos` is used. Return a reference providing modifiable access to this string. Throw `out_of_range` if `position > replacement.length()`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class STRING_VIEW_LIKE_TYPE> xref:bsl/basic_string-0faf.adoc[basic_string<char16_t>]& xref:bsl/basic_string-0ce/assign-08c.adoc[assign]( STRING_VIEW_LIKE_TYPE const& replacement, xref:bsl/basic_string-0ce/size_type.adoc[size_type] position, xref:bsl/basic_string-0ce/size_type.adoc[size_type] numChars = npos); ---- [.small]#xref:bsl/basic_string-0ce/assign-08c.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#