在C ++ 14中支持std :: cbegin() [英] Support of std::cbegin() in C++14

查看:119
本文介绍了在C ++ 14中支持std :: cbegin()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Scott Mayers的 Effective Modern C ++中的第13条指出,与迭代器相比,const_iterators更受欢迎。我同意,但我也想使用非成员函数而不是成员函数。根据这本书,应该有一个非成员函数 std :: cbegin() std :: cend()在C ++ 14中。

Item 13 from Scott Mayers' "Effective Modern C++" states to prefer const_iterators over iterators. I agree but I also want to use non-member functions rather than member functions. According to the book there should be a non-member function std::cbegin() and std::cend() in C++14.

要使用此功能,我刚刚安装了gcc版本4.9.2,并使用标志 -std = c ++ 14 。在我尝试使用 std :: cbegin()之前,它似乎一直可以编译。我开始寻找对此功能的支持,但找不到任何相关信息。例如,在 gnu onlinedocs状态中,甚至没有提到该功能。

To make use of this functions I just installed gcc version 4.9.2 and compiled with the flag -std=c++14. It seems to compile until I try to use std::cbegin(). I start searching for the support for this function but couldn't find anything about it. For example, at gnu onlinedocs status the function isn't even mentioned.

我的问题是,将 std :: cbegin() std :: cend()确实在c ++ 14中受支持,或者这是书中的错误吗?如果这将是C ++ 14功能,是否有已经支持这些功能的编译器?何时gcc会支持这些功能?

My question is, will std::cbegin() and std::cend() really be supported in c++14 or is this a mistake in the book? If it will be a C++14 feature, are there compilers which already support these functions and when will gcc support it?

SO中关于 begin(),但是这些问题与成员函数或constexpr-ness有关,而不与非成员变量的支持有关。

There are many questions at SO about begin() but these questions are about the member functions or about the constexpr-ness and not about the support of the non-member variant.

推荐答案

GCC 4.9对C ++ 14的支持是实验性的,并不完整。但是这里,您可以看到

GCC 4.9's support for C++14 is experimental and incomplete. But here, you can see that


全局函数cbegin,cend,rbegin,rend,crbegin和crend用于对容器,数组和初始化列表的范围访问。

global functions cbegin, cend, rbegin, rend, crbegin, and crend for range access to containers, arrays and initializer lists.

$在GCC 5.1中添加了b
$ b

were added in GCC 5.1.

这篇关于在C ++ 14中支持std :: cbegin()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆