[#bsl-basic_string-0faf-2constructor-06] = xref:bsl.adoc[bsl]::xref:bsl/basic_string-0faf.adoc[basic_string]::basic_string :relfileprefix: ../../ :mrdocs: Create a string from the first `numChars` of `characterString`. == Synopsis Declared in `<bslstl_string.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- basic_string( CHAR_TYPE const* characterString, xref:bsl/basic_string-0faf/size_type.adoc[size_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`. If `numChars` is not specified, `CHAR_TRAITS::length(characterString)` is used. Optionally specify the `basicAllocator` used to supply memory. If `basicAllocator` is not specified, a default‐constructed allocator is used. Throw `out_of_range` if `numChars >= npos`. == 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]#