Are the start (container) and end (container) standardized?

Are function templates that are not members of begin(container) and end(container) part of C ++ 0x? If so, in which header file do they live?

+6
source share
1 answer

Yes, but just like swap is defined in different places and depends on ADL, i.e. begin and end . The "general" versions are defined in the <iterator> :

 // 24.6.5, range access: template <class C> auto begin(C& c) -> decltype(c.begin()); template <class C> auto begin(const C& c) -> decltype(c.begin()); template <class C> auto end(C& c) -> decltype(c.end()); template <class C> auto end(const C& c) -> decltype(c.end()); template <class T, size_t N> T* begin(T (&array)[N]); template <class T, size_t N> T* end(T (&array)[N]); 

We also note that in 24.6.5 it says:

In addition to accessibility by including the <iterator> header, function templates in 24.6.5 are available if any of the following headers are included: <array> , <deque> , <forward_list> , <list> , <map> , <regex> , <set> , <string> , <unordered_map> , <unordered_set> and <vector> .

+8
source

Source: https://habr.com/ru/post/893934/


All Articles