valarray problem with gcc-2.95.1
Serge Barral
sbarral@ippt.gov.pl
Wed Nov 3 02:34:00 GMT 1999
Hi,
I'm using libsdc++-2.90.6 with gcc-2.95.1, and I have problems when
slicing a valarray. For instance this code:
#include <valarray>
using namespace std;
int main()
{
slice range(1,2,1);
double l[]={1.0 , 2.0 , 3.0 , 4.0};
valarray<double> c(l,4);
valarray<double> b(2);
b=c[range]+c[range]; // error here
return 0;
}
gives the following compile error:
>rien.cpp:In function `int main()':
>rien.cpp:12: no match for `slice_array<double> + slice_array<double>'
It looks like gcc does not choose the right signature for 'operator[]'
of class valarray, which I think in this case should be:
_Expr<_SClos<_ValArray,_Tp>, _Tp> operator[](slice) const;
and not:
slice_array<_Tp> operator[](slice);
Surprisingly, if I comment out the second signature in the file
'std_valarray.h', the code compiles. However, an expression like
'b=exp(c[slice(..,..,..])' will still not compile.
I'm quite new to c++, so maybe I'm missing something?
Is it really a problem with gcc? In this case, should I try gcc-2.95.0
or 2.95.2?
Thanks for help.
Serge
More information about the Libstdc++
mailing list