function template
<iterator> <array> <deque> <forward_list> <list> <map> <regex> <set> <string> <unordered_map> <unordered_set> <vector>
std::end container (1)template <class Container> auto end (Container& cont) -> decltype (cont.end());template <class Container> auto end (const Container& cont) -> decltype (cont.end());array (2)
template <class T, size_t N> T* end (T(&arr)[N]);container (1)
template <class Container> auto end (Container& cont) -> decltype (cont.end());template <class Container> auto end (const Container& cont) -> decltype (cont.end());array (2)
template <class T, size_t N> constexpr T* end (T(&arr)[N]) noexcept;
Iterator to end
Returns an iterator pointing to the past-the-end element in the sequence:cont.end()
.
arr+N
.
These function templates are defined in multiple headers: Each of these headers includes the generic templates for all container and array types and not simply a specific overload. The headers are: <iterator>, <array>, <deque>, <forward_list>, <list>, map, <regex>, <set>, <string>, <unordered_map>, <unordered_set> and <vector>.
Conversely, end is overloaded (with a different definition) in headers <initializer_list>
and <valarray>
.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// std::begin / std::end example
#include <iostream> // std::cout
#include <vector> // std::vector, std::begin, std::end
int main () {
int foo[] = {10,20,30,40,50};
std::vector<int> bar;
// iterate foo: inserting into bar
for (auto it = std::begin(foo); it!=std::end(foo); ++it)
bar.push_back(*it);
// iterate bar: print contents:
std::cout << "bar contains:";
for (auto it = std::begin(bar); it!=std::end(bar); ++it)
std::cout << ' ' << *it;
std::cout << '\n';
return 0;
}
bar contains: 10 20 30 40 50
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4