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

> C++ Atlas: `cppatlas.com/w/cpp/container/span/data` | Source: https://en.cppreference.com/w/cpp/container/span/data | Domain: Containers | Standards: C++20

Returns a pointer to the beginning of the sequence.

## Official Specification Summary (cppreference)

```cpp
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

```cpp
#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:

```text
ABCDEF
BCDEF
CDEF
DEF
EF
F
```

### See also

- [(constructor)](https://en.cppreference.com/w/cpp/container/span/span): constructs a `span` (public member function)

---
Attribution: content from https://en.cppreference.com/w/cpp/container/span/data (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.