const CharT* data() const;
(1) (noexcept since C++11)CharT* data() noexcept;
(2) (since C++17)Returns a pointer to the underlying array serving as character storage. The pointer is such that the range
[
data(),
data() + size())
[
data(),
data() + size()]
is valid and the values in it correspond to the values stored in the string.
The returned array is not required to be null-terminated.
If empty() returns true, the pointer is a non-null pointer that should not be dereferenced.
(until C++11)The returned array is null-terminated, that is, data()
and c_str() perform the same function.
If empty() returns true, the pointer points to a single null character.
(since C++11)The pointer obtained from data()
may be invalidated by:
operator[]()
, at(), front(), back(), begin(), end(), rbegin(), rend().1) Modifying the character array accessed through the const overload of data
has undefined behavior.
Modifying the past-the-end null terminator stored at
data() +
size()
to any value other than
CharT()
has undefined behavior.
[edit] Parameters(none)
[edit] Return valueA pointer to the underlying character storage.
data()[i] == operator[](i) for every i
in [
â0â,
size())
.
data() + i == std::addressof(operator[](i)) for every i
in [
â0â,
size()]
.
Constant.
[edit] Example [edit] See also accesses the first characterstd::basic_string_view<CharT,Traits>
) [edit]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4