[#bsl-basic_string-0faf-2constructor-0ec]
= xref:bsl.adoc[bsl]::xref:bsl/basic_string-0faf.adoc[basic&lowbar;string]::basic&lowbar;string
:relfileprefix: ../../
:mrdocs:

Constructors

== Synopses

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

Create an empty string using a default&hyphen;constructed allocator&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf/2constructor-0d7.adoc[basic&lowbar;string]() noexcept;
----

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

Create a string having the same value as the specified `original`&period;


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

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

A string cannot be constructed from a null pointer&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf/2constructor-09e.adoc[basic&lowbar;string](xref:bsl/nullptr_t-08.adoc[bsl::nullptr&lowbar;t] unused) = delete;
----

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

Create a `basic&lowbar;string` object&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf/2constructor-09b.adoc[basic&lowbar;string](xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef&lt;basic&lowbar;string&gt;] original) noexcept;
----

[.small]#xref:bsl/basic_string-0faf/2constructor-09b.adoc[_» more&period;&period;&period;_]#

Create a `basic&lowbar;string` object&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
explicit
xref:bsl/basic_string-0faf/2constructor-00e.adoc[basic&lowbar;string](ALLOCATOR const& basicAllocator) noexcept;
----

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

Create a `basic&lowbar;string` object&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE&gt;
explicit
xref:bsl/basic_string-0faf/2constructor-098.adoc[basic&lowbar;string](STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE const& object);
----

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

Create a `basic&lowbar;string` object&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf/2constructor-05c.adoc[basic&lowbar;string](
    xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef&lt;basic&lowbar;string&gt;] original,
    ALLOCATOR const& basicAllocator);
----

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

Create a `basic&lowbar;string` object&period;


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

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

Create a string that has the same value as the specified `original` string and uses the specified `basicAllocator` to supply memory&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf/2constructor-004.adoc[basic&lowbar;string](
    xref:bsl/basic_string-0faf.adoc[basic&lowbar;string] const& original,
    ALLOCATOR const& basicAllocator);
----

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

Create a `basic&lowbar;string` object&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf/2constructor-01.adoc[basic&lowbar;string](
    xref:BloombergLP/bslstl/StringRefData-04.adoc[BloombergLP::bslstl::StringRefData&lt;CHAR&lowbar;TYPE&gt;] const& strRef,
    ALLOCATOR const& basicAllocator = ALLOCATOR());
----

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

Create a string from a null&hyphen;terminated character string&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;&gt;
requires bsl&colon;&colon;IsStdAllocator&lt;ALLOCATOR&gt;&colon;&colon;value
xref:bsl/basic_string-0faf/2constructor-02.adoc[basic&lowbar;string](
    CHAR&lowbar;TYPE const* characterString,
    ALLOCATOR const& basicAllocator = ALLOCATOR());
----

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

Create a `basic&lowbar;string` object&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class ALLOC2&gt;
xref:bsl/basic_string-0faf/2constructor-0c0.adoc[basic&lowbar;string](
    std::basic&lowbar;string&lt;CHAR&lowbar;TYPE, CHAR&lowbar;TRAITS, ALLOC2&gt; const& original,
    ALLOCATOR const& basicAllocator = ALLOCATOR());
----

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

Create a `basic&lowbar;string` object&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf/2constructor-05b.adoc[basic&lowbar;string](
    xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef&lt;basic&lowbar;string&gt;] original,
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] position,
    ALLOCATOR const& basicAllocator = ALLOCATOR());
----

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

Create a `basic&lowbar;string` object&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf/2constructor-08d.adoc[basic&lowbar;string](
    xref:bsl/basic_string-0faf.adoc[basic&lowbar;string] const& original,
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] position,
    ALLOCATOR const& basicAllocator = ALLOCATOR());
----

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

Create a string from the first `numChars` of `characterString`&period;


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

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

Create a string filled with copies of a character&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;&gt;
requires bsl&colon;&colon;IsStdAllocator&lt;ALLOCATOR&gt;&colon;&colon;value
xref:bsl/basic_string-0faf/2constructor-0de.adoc[basic&lowbar;string](
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] numChars,
    CHAR&lowbar;TYPE character,
    ALLOCATOR const& basicAllocator = ALLOCATOR());
----

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

Create a `basic&lowbar;string` object&period;


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

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

Create a `basic&lowbar;string` object&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class RANGE&gt;
xref:bsl/basic_string-0faf/2constructor-07.adoc[basic&lowbar;string](
    std::from&lowbar;range&lowbar;t tag,
    RANGE&& range,
    ALLOCATOR const& basicAllocator = ALLOCATOR());
----

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

Create a `basic&lowbar;string` object&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf/2constructor-0b.adoc[basic&lowbar;string](
    xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef&lt;basic&lowbar;string&gt;] original,
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] position,
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] numChars,
    ALLOCATOR const& basicAllocator = ALLOCATOR());
----

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

Create a `basic&lowbar;string` object&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf/2constructor-0c1b.adoc[basic&lowbar;string](
    xref:bsl/basic_string-0faf.adoc[basic&lowbar;string] const& original,
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] position,
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] numChars,
    ALLOCATOR const& basicAllocator = ALLOCATOR());
----

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

Create a `basic&lowbar;string` object&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE&gt;
xref:bsl/basic_string-0faf/2constructor-0ea.adoc[basic&lowbar;string](
    STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE const& object,
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] position,
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] numChars,
    ALLOCATOR const& basicAllocator = ALLOCATOR());
----

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

== Parameters

[cols="1,4"]
|===
| Name| Description
| *original*
| string whose value is copied
| *unused*
| unused&semi; this constructor is deleted
| *basicAllocator*
| allocator used to supply memory
| *object*
| source object providing characters
| *values*
| initializer list of characters
| *strRef*
| string reference providing characters
| *characterString*
| null&hyphen;terminated string used to initialize this string
| *position*
| starting index
| *numChars*
| number of characters to take from `characterString`
| *character*
| character value used to fill the string
| *first*
| beginning of the range (inclusive)
| *last*
| end of the range (exclusive)
| *tag*
| disambiguation tag for range construction
| *range*
| input range of characters
|===


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