std::basic_string::data
| const CharT* data() const; |
||
Returns pointer to the underlying array serving as character storage. The pointer is such that the range [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 |
(until C++11) |
|
The returned array is null-terminated, that is, If |
(since C++11) |
The pointer obtained from data() may be invalidated by:
- Passing a non-const reference to the string to any standard library function, or
- Calling non-const member functions on the string, excluding
operator[],at,front,back,begin,rbegin,end, andrend.
Modifying the character array accessed through data is undefined behavior.
Contents |
[edit] Parameters
(none)
[edit] Return value
Pointer to the underlying character storage.
|
data()[i] == operator[](i) for every |
(until C++11) |
|
data() + i == &operator[](i) for every |
(since C++11) |
[edit] Complexity
Constant.
[edit] Exceptions
[edit] See also
| (C++11) |
accesses the first character (public member function) |
| (C++11) |
accesses the last character (public member function) |
| returns a non-modifiable standard C character array version of the string (public member function) | |