D
Daniel Brewer
Hi there,
I would like to define a general operator>> function for valarrays that
allows the input of an arbitary sized array from a file. An example data
file would be like:
0 1 2 3 4 5 6
4 5 6 7 8 9 10 11 12
With each line defining a different valarray. Is it possible to do this?
So far I have:
std::istream& operator>>( std::istream& is, std::valarray<double>& t )
{
for(i=0;;i++)
{
t.resize(i+1);
is >> t;
if (is.eof()) break;
}
return is;
}
but this does not seem to work.
Any ideas what the best approach to this would be?
Thanks
Dan
I would like to define a general operator>> function for valarrays that
allows the input of an arbitary sized array from a file. An example data
file would be like:
0 1 2 3 4 5 6
4 5 6 7 8 9 10 11 12
With each line defining a different valarray. Is it possible to do this?
So far I have:
std::istream& operator>>( std::istream& is, std::valarray<double>& t )
{
for(i=0;;i++)
{
t.resize(i+1);
is >> t;
if (is.eof()) break;
}
return is;
}
but this does not seem to work.
Any ideas what the best approach to this would be?
Thanks
Dan