[#bsl-basic_string-0fb-assign-0e]
= xref:bsl.adoc[bsl]::xref:bsl/basic_string-0fb.adoc[basic&lowbar;string&lt;char&gt;]::assign
:relfileprefix: ../../
:mrdocs:

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 &plus; numChars &gt; replacement&period;length()`&period; If `numChars` is not specified, `npos` is used&period; Return a reference providing modifiable access to this string&period; Throw `out&lowbar;of&lowbar;range` if `position &gt; replacement&period;length()`&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;string&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE&gt;
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char&gt;]&
assign(
    STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE const& replacement,
    xref:bsl/basic_string-0fb/size_type.adoc[size&lowbar;type] position,
    xref:bsl/basic_string-0fb/size_type.adoc[size&lowbar;type] numChars = npos);
----


[.small]#Created with https://www.mrdocs.com[MrDocs]#
