Strange C++ compile error with valarrays
问题 I have a strange compile error using valarrays in C++. This is a stripped down version of my code: #include <iostream> #include <valarray> using namespace std; bool test(const int &x,const valarray<int> &a,const valarray<int> &b) { return a*x==b; } int main() { int a1[3]= {1,2,3}; int b1[3]= {2,4,6}; valarray<int> a(a1,3); valarray<int> b(b1,3); int x=2; cout<<test(x,a,b); return 0; } Expected behavior: outputs some variant of true or 1 The compile error (using g++): main.cpp: In function