W
woessner
Hi all,
I just tried to create a map<int, valarray<int> > and got some really
weird behavior. Here's a simple example:
int main()
{
std::map<int, std::valarray<int> > m;
std::valarray<int> v(3);
v[0] = 13;
v[1] = 42;
v[2] = 99;
m[0] = v;
std::cout << m[0][0] << ", " << m[0][1] << ", " << m[0][2] << '\n';
return EXIT_SUCCESS;
}
Instead of getting "13, 42, 99", I got "0, 0, 0". And, sure enough, if
I change valarray to vector, I get the expected output.
This is my first time using valarrays. Is there some hidden pitfall
I'm missing? Or is this possible an implementation problem? (For
reference, I'm using g++ 4.1.0).
Thanks in advance,
Bill
I just tried to create a map<int, valarray<int> > and got some really
weird behavior. Here's a simple example:
int main()
{
std::map<int, std::valarray<int> > m;
std::valarray<int> v(3);
v[0] = 13;
v[1] = 42;
v[2] = 99;
m[0] = v;
std::cout << m[0][0] << ", " << m[0][1] << ", " << m[0][2] << '\n';
return EXIT_SUCCESS;
}
Instead of getting "13, 42, 99", I got "0, 0, 0". And, sure enough, if
I change valarray to vector, I get the expected output.
This is my first time using valarrays. Is there some hidden pitfall
I'm missing? Or is this possible an implementation problem? (For
reference, I'm using g++ 4.1.0).
Thanks in advance,
Bill