visual studio 7.1.6030, bugged? std::random_shuffle or std::vector
- From: chrispisz@xxxxxxxxx
- Date: 17 Aug 2006 13:14:34 -0700
You guys see anything wrong with the code here? before I raise a
hub-bub about visual studio 2003 being broken?
Tried to make the most simplistic test case as possible.
Here is test code to prove the case. It appears to only be bugged when
using vector<bool> as a container. We tested over several iterations
with bools, ints and floats, and everything works as expected except
for vector<bool>. This was compiled on version 7.1.3088 and 7.1.6030 of
Visual Studio 2003. I remember when I was new to programming how people
would always claim the compiler was broken only to find out it was a
silly code mistake and I hope this is not one of those times, but it
sure seems to be broken.
#include <algorithm>
#include <vector>
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
vector<bool> mvector;
int count = 1;
mvector.resize(4);
srand(time(NULL));
for(int i = 0; i < 4; i++)
mvector[i] = i < count;
cout << "Before\n";
cout << "vector size: " << mvector.size() << endl;
for(vector<bool>::iterator i = mvector.begin(); i != mvector.end();
i++)
cout << *i << endl;
random_shuffle( mvector.begin(), mvector.end() );
//DEBUG
cout << "\n\nAfter\n";
cout << "vector size: " << mvector.size() <<std::endl;
for(vector<bool>::iterator i = mvector.begin(); i != mvector.end();
i++)
cout << *i << endl;
system("pause");
return 0;
}
Output:
Before
vector size: 4
1
0
0
0
After
vector size: 4
1
1
1
1
.
- Prev by Date: Re: Deployment requirement even Possible?
- Next by Date: Unable to "Go to definition" nor "Go to reference" in context help popup
- Previous by thread: Re: VS.NET 2003 SP1, no installation messages?
- Next by thread: Unable to "Go to definition" nor "Go to reference" in context help popup
- Index(es):
Relevant Pages
|