支持`std :: cbegin()`在C ++ 14 [英] Support of `std::cbegin()`in C++14
问题描述
std :: cbegin()
和 std :: cend()
在C ++ 14。 为了使用这个函数,我刚刚安装了gcc版本4.9.2,并使用 -std = c ++ 14
。它似乎编译,直到我尝试使用 std :: cbegin()
。我开始搜索对这个函数的支持,但没有找到任何关于它。例如,在 gnu onlinedocs状态下,该功能甚至未提及。
我的问题是, std :: cbegin()
和 std :: cend c $ c>真的支持在c ++ 14或这是一个错误的书?如果它将是一个C ++ 14功能,是否有编译器已经支持这些功能和什么时候gcc支持它?
有很多问题,SO约 begin()
但是这些问题是关于成员函数或关于constexprness,而不是关于非成员变量的支持。
全局函数cbegin,cend,rbegin,rend,crbegin和crend用于范围访问容器,数组和初始化器列表。
已添加到GCC 5.1中。
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.
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.
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?
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's support for C++14 is experimental and incomplete. But here, you can see that
global functions cbegin, cend, rbegin, rend, crbegin, and crend for range access to containers, arrays and initializer lists.
were added in GCC 5.1.
这篇关于支持`std :: cbegin()`在C ++ 14的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!