[#bsl-basic_string-0faf-assign-0ce]
= xref:bsl.adoc[bsl]::xref:bsl/basic_string-0faf.adoc[basic&lowbar;string]::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&period;


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

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

Assign a new value to this string&period;


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

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

Assign to this string the value of the specified `replacement` string&period;


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

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

Assign a new value to this string&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string]&
xref:bsl/basic_string-0faf/assign-05.adoc[assign](CHAR&lowbar;TYPE const* characterString);
----

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

Assign a new value to this string&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]&
xref:bsl/basic_string-0faf/assign-08e.adoc[assign](STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE const& replacement);
----

[.small]#xref:bsl/basic_string-0faf/assign-08e.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]&
xref:bsl/basic_string-0faf/assign-0e.adoc[assign](std::basic&lowbar;string&lt;CHAR&lowbar;TYPE, CHAR&lowbar;TRAITS, ALLOC2&gt; const& string);
----

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

Assign a new value to this string&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string]&
xref:bsl/basic_string-0faf/assign-03c.adoc[assign](
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] numChars,
    CHAR&lowbar;TYPE character);
----

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

Assign a new value to this string&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string]&
xref:bsl/basic_string-0faf/assign-038.adoc[assign](
    CHAR&lowbar;TYPE const* characterString,
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] numChars);
----

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

Assign a new value to this string&period;


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

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

Assign a substring of `replacement` to this string&period;


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

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

Assign a new value to this string&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]&
xref:bsl/basic_string-0faf/assign-0c6.adoc[assign](
    STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE const& replacement,
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] position,
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] numChars = npos);
----

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

== Return Value

* reference providing modifiable access to this string
* a reference to this string

== Parameters

[cols="1,4"]
|===
| Name| Description
| *replacement*
| string whose value is move&hyphen;assigned to this string
| *values*
| initializer list of characters
| *characterString*
| pointer to characters
| *string*
| null&hyphen;terminated character string
| *numChars*
| number of characters
| *character*
| character value
| *first*
| beginning of the range (inclusive)
| *last*
| end of the range (exclusive)
| *position*
| starting index in `replacement`
|===


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