Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does g++ states, that there is "no matching function for call cbegin(o)" for some valarray<double> o?

Tags:

c++

g++

c++14

Please consider the following code:

using custom_t = std::valarray<unsigned>;
custom_t o;
unsigned acc = std::accumulate(std::cbegin(o), std::cend(o), 0);

g++-5 says

No matching function for call to cbegin(custom_t&)

If I use std::begin(o) and std::end(o) instead, everything works. Is this a compiler bug? The code compiles with Visual Studio 2015.

like image 222
0xbadf00d Avatar asked Nov 21 '22 07:11

0xbadf00d


1 Answers

This is a libstdc++ bug, I've just created https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67374

like image 156
Jonathan Wakely Avatar answered Dec 05 '22 09:12

Jonathan Wakely