|
-
July 5th, 2007, 12:52 PM
#1
STL issues with sort()?
Hi,
I have a vector<MyStruct> and I'm trying to sort it. Basically I have a struct with two 32bit numbers that are in bit fields and I've overridden > < == and != and all they do is compare the bit fields to determine if the operator is true or not. I'd post it but it's useless and I know it works, trust me.
I have also overridden the = operator and all it does is a quickie memcpy() because as I say, there are just two 32bit numbers, no pointers in the struct or anything fancy.
Anyhow, this all works perfectly, until I have more than 261 elements in my vector! When I have more than 261 elements, the < operator fails and tells me the one local var in my function isn't defined and my two 32bit values are completely unintelligent.
The one local variable I have is a bool result; which just tells me if it's truly < the element it's being compared to and it's always initialized before the calculations take place.
I know all the elements are good because I've gone so far as looking at each one now manually. It only complains when it reaches the end of the function where the return result; sits.
In the STL source code, it fails on a line that reads "if (*_Last < *_Mid)" and that in turn is called from "_Med3(_Last - 2 * _Step, _Last - _Step, _Last);" in the <alogrithm> file. That is probably totally useless info though.
I'll post code for the struct if anyone thinks it's really necessary. I invoke it with "sort(sorted,begin(), sorted.end()); so nothing special there I think.
Any suggestions?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|