bsl::basic_string::resize_and_overwrite

Resize this string and overwrite its contents.

Synopsis

Declared in <bslstl_string.h>

template<class OPERATION>
void
resize_and_overwrite(
    size_type newLength,
    OPERATION operation);

Description

Change the length of this string to the specified newLength, erasing characters at the end if newLength < length() or appending the appropriate number of characters at the end if length() < newLength. Subsequently, invoke the specified operation passing the address of the null-terminated buffer and the adjusted length of this string as parameters. Finally, change the length of this string to the value returned by the operation. Throw length_error if `newLength > max_size()`. The behavior is undefined unless the value returned by the operation is less than or equal to newLength.

Parameters

NameDescription
newLengthnew length of this string
operationcallable that overwrites the resized buffer