[#bsl-basic_string-01d-assign-0c3a]
= xref:bsl.adoc[bsl]::xref:bsl/basic_string-01d.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]::assign
:relfileprefix: ../../
:mrdocs:

`assign` overloads

== Synopses

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

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&lowbar;on&lowbar;container&lowbar;move&lowbar;assignment`, and return a reference providing modifiable access to this string&period; The content of `replacement` is moved (in constant time) to this string if `get&lowbar;allocator() &equals;&equals; rhs&period;get&lowbar;allocator()` (after accounting for the aforementioned trait)&period; `replacement` is left in a valid but unspecified state&period; Note that this method has exactly the same behavior as the corresponding `operator&equals;`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/assign-09e.adoc[assign](xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef&lt;basic&lowbar;string&lt;char8&lowbar;t&gt;&gt;] replacement) noexcept(false);
----

[.small]#xref:bsl/basic_string-01d/assign-09e.adoc[_» more&period;&period;&period;_]#

Assign to this string the value resulting from first clearing this string and then inserting (in order) each `CHAR&lowbar;TYPE` object in the specified `values` initializer list&period; Return a reference providing modifiable access to this string&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/assign-0cc.adoc[assign](std::initializer&lowbar;list&lt;char8&lowbar;t&gt; values);
----

[.small]#xref:bsl/basic_string-01d/assign-0cc.adoc[_» more&period;&period;&period;_]#

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&lowbar;on&lowbar;container&lowbar;copy&lowbar;assignment`, and return a reference providing modifiable access to this string&period; Note that this method has exactly the same behavior as the corresponding `operator&equals;`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/assign-08.adoc[assign](xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;] const& replacement);
----

[.small]#xref:bsl/basic_string-01d/assign-08.adoc[_» more&period;&period;&period;_]#

Assign to this string the value of the specified null&hyphen;terminated `characterString` (of length `CHAR&lowbar;TRAITS&colon;&colon;length(characterString)`), and return a reference providing modifiable access to this string&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/assign-0c3b.adoc[assign](char8&lowbar;t const* characterString);
----

[.small]#xref:bsl/basic_string-01d/assign-0c3b.adoc[_» more&period;&period;&period;_]#

Assign to this string the value of the specified `replacement`, and return a reference providing modifiable access to this string&period; Note that this method has exactly the same behavior as the corresponding `operator&equals;`&period;


[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;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/assign-0fb.adoc[assign](STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE const& replacement);
----

[.small]#xref:bsl/basic_string-01d/assign-0fb.adoc[_» more&period;&period;&period;_]#

Assign to this string the value of the specified `string`, and return a reference providing modifiable access to this string&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class ALLOC2&gt;
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/assign-0f4.adoc[assign](std::basic&lowbar;string&lt;char8&lowbar;t, char&lowbar;traits&lt;char8&lowbar;t&gt;, ALLOC2&gt; const& string);
----

[.small]#xref:bsl/basic_string-01d/assign-0f4.adoc[_» more&period;&period;&period;_]#

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&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/assign-05.adoc[assign](
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] numChars,
    char8&lowbar;t character);
----

[.small]#xref:bsl/basic_string-01d/assign-05.adoc[_» more&period;&period;&period;_]#

Assign to this string the specified initial `numChars` characters in the specified `characterString`, and return a reference providing modifiable access to this string&period; The behavior is undefined unless `characterString` is at least `numChars` long&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/assign-0f5.adoc[assign](
    char8&lowbar;t const* characterString,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] numChars);
----

[.small]#xref:bsl/basic_string-01d/assign-0f5.adoc[_» more&period;&period;&period;_]#

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&lowbar;ITER`&period; Return a reference providing modifiable access to this string&period; 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`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class INPUT&lowbar;ITER&gt;
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/assign-07.adoc[assign](
    INPUT&lowbar;ITER first,
    INPUT&lowbar;ITER last);
----

[.small]#xref:bsl/basic_string-01d/assign-07.adoc[_» more&period;&period;&period;_]#

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 &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;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/assign-090.adoc[assign](
    xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;] const& replacement,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] position,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] numChars = npos);
----

[.small]#xref:bsl/basic_string-01d/assign-090.adoc[_» more&period;&period;&period;_]#

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;


[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;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/assign-03.adoc[assign](
    STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE const& replacement,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] position,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] numChars = npos);
----

[.small]#xref:bsl/basic_string-01d/assign-03.adoc[_» more&period;&period;&period;_]#


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