bsl::basic_string::assign

Assign a substring of replacement to this string.

Synopsis

Declared in <bslstl_string.h>

basic_string&
assign(
    basic_string const& replacement,
    size_type position,
    size_type numChars = npos);

Description

Assign to this string the value of the optionally specified numChars characters starting at the specified position in the specified replacement string, or the suffix of replacement starting at position if position + numChars > replacement.length(). If numChars is not specified, npos is used. Return a reference providing modifiable access to this string. Throw out_of_range if position > replacement.length().

Return Value

a reference to this string

Parameters

NameDescription
replacementstring providing the characters to assign
positionstarting index in replacement
numCharsnumber of characters to assign