非成员函数模板是否开始(容器)和结束(容器)是C 0x的一部分?如果是这样,他们居住在哪个头文件中?
解决方法
是的,但正如交换在不同的地方定义并依赖于ADL一样,开始和结束也是如此. ‘通用’版本在< 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]);
另请注意,24.6.5说:
In addition to being available via inclusion of the
<iterator>
header,the function templates in 24.6.5 are available when any of the following headers are included:<array>
,<deque>
,<forward_list>
,<list>
,<map>
,<regex>
,<set>
,<string>
,<unordered_map>
,<unordered_set>
,and<vector>
.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。