加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 开始(容器)和结束(容器)是否标准化?

发布时间:2020-12-16 04:58:06 所属栏目:百科 来源:网络整理
导读:非成员函数模板是否开始(容器)和结束(容器)是C 0x的一部分?如果是这样,他们居住在哪个头文件中? 解决方法 是的,但正如交换在不同的地方定义并依赖于ADL一样,开始和结束也是如此. ‘通用’版本在 iterator中定义: // 24.6.5,range access:template class C
非成员函数模板是否开始(容器)和结束(容器)是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>.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读