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

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

== Synopsis

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

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

== Description

Create a string that has the same value as the substring of the optionally specified `numChars` length starting at the beginning of the specified `characterString`&period; If `numChars` is not specified, `CHAR&lowbar;TRAITS&colon;&colon;length(characterString)` is used&period; Optionally specify the `basicAllocator` used to supply memory&period; If `basicAllocator` is not specified, a default&hyphen;constructed allocator is used&period; Throw `out&lowbar;of&lowbar;range` if `numChars &gt;&equals; npos`&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *characterString*
| character array used to initialize the string
| *numChars*
| number of characters to take from `characterString`
| *basicAllocator*
| allocator used to supply memory
|===


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