 st8b7c:f320:99b9:690f:4595:cd17:293a:c069span<T,Extent>8b7c:f320:99b9:690f:4595:cd17:293a:c069gin    constexpr iterator begin() const noexcept;
       Returns an iterator to the first element of the span.
If the span is empty, the returned iterator will be equal to end().

 Parameters (none).
 Return value Iterator to the first element.
 Complexity Constant.
 Example  #include <span>
#include <iostream>
 
void print(st8b7c:f320:99b9:690f:4595:cd17:293a:c069span<const int> sp)
{
    for(auto it = sp.begin(); it != sp.end(); ++it) {
        st8b7c:f320:99b9:690f:4595:cd17:293a:c069cout << *it << ' ';
    }
    st8b7c:f320:99b9:690f:4595:cd17:293a:c069cout << '\n';
}
 
void transmogrify(st8b7c:f320:99b9:690f:4595:cd17:293a:c069span<int> sp)
{
    if (!sp.empty()) {
        st8b7c:f320:99b9:690f:4595:cd17:293a:c069cout << *sp.begin() << '\n';
        *sp.begin() = 2;
    }
}
 
int main()
{
    int array[] { 1, 3, 4, 5 };
    print(array);
    transmogrify(array);
    print(array);
} Output:
1 3 4 5 
1
2 3 4 5   See also     end
(C++20)   returns an iterator to the end  (public member function) 
    begincbegin
(C++11)(C++14)   returns an iterator to the beginning of a container or array  (function template) 
  

    
{'path': 'public/docs/cpp/container/span/begin.html', 'source': 'DevDocs.IO'}