Create a string from a user‐defined string literal.
Synopsis
Declared in <bslstl_string.h>
string
operator""_s(
char const* characterString,
std::size_t length);
Description
Convert a character sequence of the specified length excluding the terminating null character starting at the beginning of the specified characterString to a string object of the indicated return type. Use the bslma::Default::defaultAllocator() to supply memory. (See the "User‐Defined Literals" section in the component‐level documentation.)
Example: ` using namespace bsl::string_literals; bsl::string str1 = "1230abc"; bsl::string str2 = "1230abc"_s; assert(3 == str1.size()); assert(7 == str2.size());
bsl::wstring str3 = L"1230abc"_s; assert(7 == str3.size()); `
Return Value
string constructed from the character literal
Parameters
Name |
Description |
characterString |
pointer to the character sequence |
length |
number of characters excluding the null terminator |
Created with MrDocs