[#BloombergLP-bslstl-StringRefImp-02-2constructor-00] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstl.adoc[bslstl]::xref:BloombergLP/bslstl/StringRefImp-02.adoc[StringRefImp<char>]::StringRefImp :relfileprefix: ../../../ :mrdocs: Constructors == Synopses Declared in `<bslstl_stringref.h>` Create an object representing an empty `std::string` value that is independent of any external representation and with the following attribute values: ` begin() == end() isEmpty() == true ` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bslstl/StringRefImp-02/2constructor-0b.adoc[StringRefImp](); ---- [.small]#xref:BloombergLP/bslstl/StringRefImp-02/2constructor-0b.adoc[_» more..._]# Create a string ref referencing the specified `bsl::basic_string`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bslstl/StringRefImp-02/2constructor-081.adoc[StringRefImp](xref:bsl/basic_string-0faf.adoc[bsl::basic_string<char>] const& str); ---- [.small]#xref:BloombergLP/bslstl/StringRefImp-02/2constructor-081.adoc[_» more..._]# Create a string ref referencing the specified `std::pmr::basic_string`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bslstl/StringRefImp-02/2constructor-06.adoc[StringRefImp](std::pmr::basic_string<char> const& str); ---- [.small]#xref:BloombergLP/bslstl/StringRefImp-02/2constructor-06.adoc[_» more..._]# Create a string ref referencing the specified `std::basic_string`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bslstl/StringRefImp-02/2constructor-08d.adoc[StringRefImp](std::basic_string<char> const& str); ---- [.small]#xref:BloombergLP/bslstl/StringRefImp-02/2constructor-08d.adoc[_» more..._]# Create a string‐reference object having a valid `std::string` value, whose external representation is defined by the specified `str` object. The external representation must remain valid as long as it is bound to this string reference. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bslstl/StringRefImp-02/2constructor-04.adoc[StringRefImp](bsl::basic_string_view<char> const& str); ---- [.small]#xref:BloombergLP/bslstl/StringRefImp-02/2constructor-04.adoc[_» more..._]# Create a string‐reference object having a valid `std::string` value, whose external representation begins at the specified `data` address and extends for `std::char_traits<CHAR_TYPE>::length(data)` characters. The external representation must remain valid as long as it is bound to this string reference. The behavior is undefined unless `data` is null‐terminated. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bslstl/StringRefImp-02/2constructor-0c.adoc[StringRefImp](char const* data); ---- [.small]#xref:BloombergLP/bslstl/StringRefImp-02/2constructor-0c.adoc[_» more..._]# Create a string‐reference object having a valid `std::string` value, whose external representation begins at the specified `begin` iterator and extends up to, but not including, the specified `end` iterator. The external representation must remain valid as long as it is bound to this string reference. The behavior is undefined unless `begin <= end`. Note that, like an `std::string`, the string need not be null‐terminated and may contain embedded null characters. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bslstl/StringRefImp-02/2constructor-01.adoc[StringRefImp]( xref:BloombergLP/bslstl/StringRefImp-02/const_iterator.adoc[const_iterator] begin, xref:BloombergLP/bslstl/StringRefImp-02/const_iterator.adoc[const_iterator] end); ---- [.small]#xref:BloombergLP/bslstl/StringRefImp-02/2constructor-01.adoc[_» more..._]# Create a string‐reference object having a valid `std::string` value, whose external representation begins at the specified `data` address and extends for the specified `length` characters. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bslstl/StringRefImp-02/2constructor-0de.adoc[StringRefImp]( char const* data, xref:BloombergLP/bslstl/StringRefImp-0c/size_type.adoc[size_type] length); ---- [.small]#xref:BloombergLP/bslstl/StringRefImp-02/2constructor-0de.adoc[_» more..._]# Create a string‐reference object having a valid `std::string` value, whose external representation begins at the specified `data` address and extends for the specified `length`. The external representation must remain valid as long as it is bound to this string reference. Passing 0 has the same effect as default construction. The behavior is undefined unless `0 <= length` and, if `0 == data`, then `0 == length`. Note that, like an `std::string`, the `data` need not be null‐terminated and may contain embedded null characters. Note that the template and non‐template versions combine to allow various integral and enumeration types to be used for length while preventing `(char *, 0)` initializer arguments from matching the two‐iterator constructor below. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class INT_TYPE> xref:BloombergLP/bslstl/StringRefImp-02/2constructor-07.adoc[StringRefImp]( char const* data, INT_TYPE length) requires bsl::is_integral<INT_TYPE>::value; ---- [.small]#xref:BloombergLP/bslstl/StringRefImp-02/2constructor-07.adoc[_» more..._]# Create a string‐reference object having a valid `std::string` value, whose external representation begins at the specified `startIndex` in the specified `original` string reference, and extends either the specified `numCharacters` or until the end of the `original` string reference, whichever comes first. The external representation must remain valid as long as it is bound to this string reference. The behavior is undefined unless `startIndex <= original.length()`. Note that if `startIndex` is `original.length()` an empty string reference is returned. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bslstl/StringRefImp-02/2constructor-0da.adoc[StringRefImp]( xref:BloombergLP/bslstl/StringRefImp-0c.adoc[StringRefImp<char>] const& original, xref:BloombergLP/bslstl/StringRefImp-0c/size_type.adoc[size_type] startIndex, xref:BloombergLP/bslstl/StringRefImp-0c/size_type.adoc[size_type] numCharacters); ---- [.small]#xref:BloombergLP/bslstl/StringRefImp-02/2constructor-0da.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#