GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::span::end(3) C++ Standard Libary std::span::end(3)

std::span::end - std::span::end


constexpr iterator end() const noexcept;


Returns an iterator to the element following the last element of the span.


This element acts as a placeholder; attempting to access it results in undefined
behavior.


range-begin-end.svg


(none)


Iterator to the element following the last element.


Constant.

// Run this code


#include <span>
#include <iostream>


void print(std::span<const int> sp)
{
for(auto it = sp.begin(); it != sp.end(); ++it) {
std::cout << *it << ' ';
}
std::cout << '\n';
}


void transmogrify(std::span<int> sp)
{
if (!sp.empty()) {
std::cout << *sp.begin() << '\n';
*sp.begin() = 2;
}
}


int main()
{
int array[] { 1, 3, 4, 5 };
print(array);
transmogrify(array);
print(array);
}


1 3 4 5
1
2 3 4 5


begin returns an iterator to the beginning
(C++20) (public member function)
end
cend returns an iterator to the end of a container or array
(C++11) (function template)
(C++14)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.