[#bsl-basic_string-0faf-2constructor-0ec] = xref:bsl.adoc[bsl]::xref:bsl/basic_string-0faf.adoc[basic_string]::basic_string :relfileprefix: ../../ :mrdocs: Constructors == Synopses Declared in `<bslstl_string.h>` Create an empty string using a default‐constructed allocator. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf/2constructor-0d7.adoc[basic_string]() noexcept; ---- [.small]#xref:bsl/basic_string-0faf/2constructor-0d7.adoc[_» more..._]# Create a string having the same value as the specified `original`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf/2constructor-0f.adoc[basic_string](xref:bsl/basic_string-0faf.adoc[basic_string] const& original); ---- [.small]#xref:bsl/basic_string-0faf/2constructor-0f.adoc[_» more..._]# A string cannot be constructed from a null pointer. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf/2constructor-09e.adoc[basic_string](xref:bsl/nullptr_t-08.adoc[bsl::nullptr_t] unused) = delete; ---- [.small]#xref:bsl/basic_string-0faf/2constructor-09e.adoc[_» more..._]# Create a `basic_string` object. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf/2constructor-09b.adoc[basic_string](xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef<basic_string>] original) noexcept; ---- [.small]#xref:bsl/basic_string-0faf/2constructor-09b.adoc[_» more..._]# Create a `basic_string` object. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- explicit xref:bsl/basic_string-0faf/2constructor-00e.adoc[basic_string](ALLOCATOR const& basicAllocator) noexcept; ---- [.small]#xref:bsl/basic_string-0faf/2constructor-00e.adoc[_» more..._]# Create a `basic_string` object. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class STRING_VIEW_LIKE_TYPE> explicit xref:bsl/basic_string-0faf/2constructor-098.adoc[basic_string](STRING_VIEW_LIKE_TYPE const& object); ---- [.small]#xref:bsl/basic_string-0faf/2constructor-098.adoc[_» more..._]# Create a `basic_string` object. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf/2constructor-05c.adoc[basic_string]( xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef<basic_string>] original, ALLOCATOR const& basicAllocator); ---- [.small]#xref:bsl/basic_string-0faf/2constructor-05c.adoc[_» more..._]# Create a `basic_string` object. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf/2constructor-0c13.adoc[basic_string]( std::initializer_list<CHAR_TYPE> values, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:bsl/basic_string-0faf/2constructor-0c13.adoc[_» more..._]# Create a string that has the same value as the specified `original` string and uses the specified `basicAllocator` to supply memory. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf/2constructor-004.adoc[basic_string]( xref:bsl/basic_string-0faf.adoc[basic_string] const& original, ALLOCATOR const& basicAllocator); ---- [.small]#xref:bsl/basic_string-0faf/2constructor-004.adoc[_» more..._]# Create a `basic_string` object. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf/2constructor-01.adoc[basic_string]( xref:BloombergLP/bslstl/StringRefData-04.adoc[BloombergLP::bslstl::StringRefData<CHAR_TYPE>] const& strRef, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:bsl/basic_string-0faf/2constructor-01.adoc[_» more..._]# Create a string from a null‐terminated character string. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<> requires bsl::IsStdAllocator<ALLOCATOR>::value xref:bsl/basic_string-0faf/2constructor-02.adoc[basic_string]( CHAR_TYPE const* characterString, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:bsl/basic_string-0faf/2constructor-02.adoc[_» more..._]# Create a `basic_string` object. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class ALLOC2> xref:bsl/basic_string-0faf/2constructor-0c0.adoc[basic_string]( std::basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOC2> const& original, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:bsl/basic_string-0faf/2constructor-0c0.adoc[_» more..._]# Create a `basic_string` object. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf/2constructor-05b.adoc[basic_string]( xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef<basic_string>] original, xref:bsl/basic_string-0faf/size_type.adoc[size_type] position, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:bsl/basic_string-0faf/2constructor-05b.adoc[_» more..._]# Create a `basic_string` object. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf/2constructor-08d.adoc[basic_string]( xref:bsl/basic_string-0faf.adoc[basic_string] const& original, xref:bsl/basic_string-0faf/size_type.adoc[size_type] position, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:bsl/basic_string-0faf/2constructor-08d.adoc[_» more..._]# Create a string from the first `numChars` of `characterString`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf/2constructor-06.adoc[basic_string]( CHAR_TYPE const* characterString, xref:bsl/basic_string-0faf/size_type.adoc[size_type] numChars, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:bsl/basic_string-0faf/2constructor-06.adoc[_» more..._]# Create a string filled with copies of a character. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<> requires bsl::IsStdAllocator<ALLOCATOR>::value xref:bsl/basic_string-0faf/2constructor-0de.adoc[basic_string]( xref:bsl/basic_string-0faf/size_type.adoc[size_type] numChars, CHAR_TYPE character, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:bsl/basic_string-0faf/2constructor-0de.adoc[_» more..._]# Create a `basic_string` object. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class INPUT_ITER> xref:bsl/basic_string-0faf/2constructor-080.adoc[basic_string]( INPUT_ITER first, INPUT_ITER last, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:bsl/basic_string-0faf/2constructor-080.adoc[_» more..._]# Create a `basic_string` object. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class RANGE> xref:bsl/basic_string-0faf/2constructor-07.adoc[basic_string]( std::from_range_t tag, RANGE&& range, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:bsl/basic_string-0faf/2constructor-07.adoc[_» more..._]# Create a `basic_string` object. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf/2constructor-0b.adoc[basic_string]( xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef<basic_string>] original, xref:bsl/basic_string-0faf/size_type.adoc[size_type] position, xref:bsl/basic_string-0faf/size_type.adoc[size_type] numChars, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:bsl/basic_string-0faf/2constructor-0b.adoc[_» more..._]# Create a `basic_string` object. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf/2constructor-0c1b.adoc[basic_string]( xref:bsl/basic_string-0faf.adoc[basic_string] const& original, xref:bsl/basic_string-0faf/size_type.adoc[size_type] position, xref:bsl/basic_string-0faf/size_type.adoc[size_type] numChars, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:bsl/basic_string-0faf/2constructor-0c1b.adoc[_» more..._]# Create a `basic_string` object. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class STRING_VIEW_LIKE_TYPE> xref:bsl/basic_string-0faf/2constructor-0ea.adoc[basic_string]( STRING_VIEW_LIKE_TYPE const& object, xref:bsl/basic_string-0faf/size_type.adoc[size_type] position, xref:bsl/basic_string-0faf/size_type.adoc[size_type] numChars, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:bsl/basic_string-0faf/2constructor-0ea.adoc[_» more..._]# == Parameters [cols="1,4"] |=== | Name| Description | *original* | string whose value is copied | *unused* | unused; 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‐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]#