fixstr::basic_fixed_string::data
#1 |
| |
#2 |
|
Returns a 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 null-terminated, that is, data()
and c_str()
perform the same function.
#
Parameters(none)
#
Return valueA pointer to the underlying character storage.
data() + i == std::addressof(operator[](i))
for every i
in [0, size()]
.
#
ComplexityConstant.
#
Example#include <fixed_string.hpp>#include <iostream>#include <memory>
int main(){ { fixstr::fixed_string hw_s = "hello, world!"; char* const f = std::addressof(hw_s.front()); *f = 'H'; std::cout << "data() after modification: " << hw_s.data() << '\n'; // Hello, world! }
{ constexpr const fixstr::fixed_string hw_c = "Hello, world!"; const char* const f = std::addressof(hw_c.front()); std::cout << std::boolalpha << "f == data(): " << (f == hw_c.data()) << '\n'; }}
data() after modification: Hello, world!f == data(): true