为什么 g++ 声明某些 valarray o 存在"no matching function for call cbegin(o)"<double>?
Why does g++ states, that there is "no matching function for call cbegin(o)" for some valarray<double> o?
请考虑以下代码:
using custom_t = std::valarray<unsigned>;
custom_t o;
unsigned acc = std::accumulate(std::cbegin(o), std::cend(o), 0);
g++-5表示
呼叫
cbegin(custom_t&)
没有匹配函数
如果我使用std::begin(o)
和std::end(o)
代替,一切工作。这是一个编译器错误吗?该代码使用Visual Studio 2015编译。
这是一个libstdc++的bug,我刚刚创建了https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67374
没有
std::cbegin.
使用unsigned acc = std::accumulate(o.cbegin(), o.cend(), 0);
感觉更面向对象。
相关文章:
- 请解释这句话(cout<<1+int((a<b)^((b-a)&1) )<<endl
- 呼叫运营商<<临时
- 如何防止clang格式在流运算符调用之间添加换行符<<
- <<操作员在下面的行中工作
- 为什么 std::span 缺少 cbegin 和 cend 方法?
- begin() 在 C++17 年被制作为 constexpr 但在 C++14 年成为 cbegin() 吗?
- 如何显式调用运算符<<
- 如何实现 cbegin() 和 cend() 从 begin() 和 end() ?
- 在载体中使用cbegin和cend
- 无法在 cbegin 中定义initializer_list
- begin(),end()和cbegin(),cend()之间的区别是什么?
- 模板操作员&lt;未打电话
- C / CUDA中的模板方法是3个角括号(&lt;&lt;&lt;)
- C - 创建矢量&lt; vector&lt; double&gt;&gt;矩阵具有分配而不是inizializ
- 错误:调用"std::vector<:vector<int>>::p ush_back(std::vector<std::__cxx11::basic_string<
- 是cbegin/Cend不足以使循环范围
- C 建造者Clang STD :: Sill,找不到超载的操作员&lt;
- 为什么 std::cbegin() 不调用容器上的 .cbegin()?
- 为什么STD :: MAP需要操作员&lt;以及我如何写一个
- 'cbegin'未在此范围内声明