Create a basic_string object.

Synopsis

Declared in <bslstl_string.h>

basic_string(
    BloombergLP::bslmf::MovableRef<basic_string> original,
    size_type position,
    size_type numChars,
    ALLOCATOR const& basicAllocator = ALLOCATOR());

Description

Create a string that has the same value as the substring of the specified numChars length starting at the specified position in the specified original string. If numChars is more than the available string length, then the remaining length of the string is used (i.e., numChars is set to original.length() ‐ position). Optionally specify the basicAllocator used to supply memory. If basicAllocator is not specified, a default‐constructed allocator is used. The contents of original are moved (in constant time) to the new string if basicAllocator == original.get_allocator(), and are copied (in linear time) using basicAllocator otherwise. original is left in a valid but unspecified state. Throw out_of_range if `position > original.length()`.

Parameters

Name

Description

original

source string

position

starting index

numChars

number of characters

basicAllocator

allocator used to supply memory

Created with MrDocs