string::data

Return the underlying character array directly.

Synopsis

char*
data() noexcept; (1)

char const*
data() const noexcept; (2)

Description

Returns a pointer to the underlying array serving as storage. The value returned is such that the range [data(), data() + size()) is always a valid range, even if the container is empty.

The value returned from this function is never equal to nullptr.

Complexity

Constant.

Exception Safety

No-throw guarantee.