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

From cppreference.com
< cpp‎ | container‎ | span
 
 
 
std::span
Member functions
(C++20)
Element access
(C++20)
span::data
(C++20)
Iterators
(C++20)(C++23)
(C++20)(C++23)
Observers
(C++20)
Subviews
(C++20)
Non-member functions
Non-member constant
Deduction guides(C++20)
 
constexpr pointer data() const noexcept;
(since C++20)

Returns a pointer to the beginning of the sequence.

Return value

A pointer to the beginning of the sequence.

Example

#include <iostream>
#include <span>
 
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

See also

constructs a span
(public member function)