inline constexpr /*unspecified*/ cdata = /*unspecified*/;
Call signature
template< class T > requires /* see below */
Returns a pointer to the first element of constant type(since C++23) of a contiguous range denoted by a const-qualified(until C++23) argument.
If ranges::cdata(t) is valid, then it returns a pointer to an object of constant type(since C++23).
Customization point objectsThe name ranges::cdata
denotes a customization point object, which is a const function object of a literal semiregular
class type. See CustomizationPointObject for details.
#include <cstring> #include <iostream> #include <ranges> #include <string> int main() { std::string src {"hello world!\n"}; // std::ranges::cdata(src)[0] = 'H'; // error, src.data() is treated as read-only std::ranges::data(src)[0] = 'H'; // OK, src.data() is a non-const storage char dst[20]; // storage for a C-style string std::strcpy(dst, std::ranges::cdata(src)); // [data(src), data(src) + size(src)] is guaranteed to be an NTBS std::cout << dst; }
Output:
[edit] See also obtains a pointer to the beginning of a contiguous rangeRetroSearch 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