如何在现代C ++中对valarray使用range-for循环?
test.cpp
#include <fstream>
#include <valarray>
void test(std::valarray<float> const& v){
printf( "%s", "first" );
for (float i : v){
printf( "%f", i );
}
}
int main() {
std::valarray<float> v(3,0);
test(v);
return 0;
}
>$ g++ test.cpp -o test -Wall -std=c++17
>$ ./test
first⏎