[#bsl-basic_string-0faf-assign-08c] = xref:bsl.adoc[bsl]::xref:bsl/basic_string-0faf.adoc[basic_string]::assign :relfileprefix: ../../ :mrdocs: Assign a substring of `replacement` to this string. == Synopsis Declared in `<bslstl_string.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string]& assign( xref:bsl/basic_string-0faf.adoc[basic_string] const& replacement, xref:bsl/basic_string-0faf/size_type.adoc[size_type] position, xref:bsl/basic_string-0faf/size_type.adoc[size_type] numChars = npos); ---- == Description 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()`. == Return Value a reference to this string == Parameters [cols="1,4"] |=== | Name| Description | *replacement* | string providing the characters to assign | *position* | starting index in `replacement` | *numChars* | number of characters to assign |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#