X Tutup
The Wayback Machine - https://web.archive.org/web/20220817031643/https://en.cppreference.com/w/cpp/container/span/data
Namespaces
Variants
Views
Actions

std::span<T,Extent>::data

From cppreference.com
< cpp‎ | container‎ | span
constexpr pointer data() const noexcept;

Returns a pointer to the beginning of the sequence.

[edit] Return value

A pointer to the beginning of the sequence.

[edit] Example

#include <span>
#include <iostream>
 
int main()
{
    constexpr char str[] = "ABCDEF\n";
 
    const std::span sp{str};
 
    for (auto n{sp.size()}; n != 2; --n) {
        std::cout << sp.last(n).data();
    }
}

Output:

ABCDEF
BCDEF
CDEF
DEF
EF
F

[edit] See also

constructs a span
(public member function) [edit]
X Tutup