(C++17) | ||||
| Sequence | ||||
(C++11) | ||||
(C++26) | ||||
(C++26) | ||||
(C++11) | ||||
| Associative | ||||
| Unordered associative | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
| Adaptors | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
| Views | ||||
(C++20) | ||||
(C++23) | ||||
| Tables | ||||
| Iterator invalidation | ||||
| Member function table | ||||
| Non-member function table |
| Member functions | |||||||
| Non-member functions | |||||||
| |||||||
| Deduction guides(C++17) | |||||||
iterator end(); | (1) | (noexcept since C++11) (constexpr since C++26) |
const_iterator end()const; | (2) | (noexcept since C++11) (constexpr since C++26) |
const_iterator cend()constnoexcept; | (3) | (since C++11) (constexpr since C++26) |
Returns an iterator past the last element of*this.
This returned iterator only acts as a sentinel. It is not guaranteed to bedereferenceable.
Contents |
Iterator past the last element.
Constant.
libc++ backportscend() to C++98 mode.
#include <algorithm>#include <cassert>#include <cstddef>#include <iostream>#include <map>#include <string> int main(){auto show_node=[](constauto& node,char ending='\n'){std::cout<<"{ "<< node.first<<", "<< node.second<<" }"<< ending;}; std::multimap<std::size_t,std::string> mmap;assert(mmap.begin()== mmap.end());// OKassert(mmap.cbegin()== mmap.cend());// OK mmap.insert({ sizeof(long),"LONG"}); show_node(*(mmap.cbegin()));assert(mmap.begin()!= mmap.end());// OKassert(mmap.cbegin()!= mmap.cend());// OK mmap.begin()->second="long"; show_node(*(mmap.cbegin())); mmap.insert({ sizeof(int),"int"}); show_node(*mmap.cbegin()); mmap.insert({ sizeof(short),"short"}); show_node(*mmap.cbegin()); mmap.insert({ sizeof(char),"char"}); show_node(*mmap.cbegin()); mmap.insert({{ sizeof(float),"float"},{ sizeof(double),"double"}}); std::cout<<"mmap = { ";std::for_each(mmap.cbegin(), mmap.cend(),[&](constauto& n){ show_node(n,' ');});std::cout<<"};\n";}
Possible output:
{ 8, LONG }{ 8, long }{ 4, int }{ 2, short }{ 1, char }mmap = { { 1, char } { 2, short } { 4, int } { 4, float } { 8, long } { 8, double } };(C++11) | returns an iterator to the beginning (public member function)[edit] |
(C++11)(C++14) | returns an iterator to the end of a container or array (function template)[edit] |