STL And Visual Studio 6 Issue...

Started by
6 comments, last by Julian Spillane 18 years, 8 months ago
First off, I know I shouldn't be using Visual Studio 6's STL libraries for any type of decent code, but that's a moot point right now. The problem is that I occasionally get this compiler error: c:\program files\microsoft visual studio\vc98\include\xutility(88) : error C2678: binary '==' : no operator defined which takes a left-hand operand of type 'const struct CPoly' (or there is no acceptable conversion) c:\program files\microsoft visual studio\vc98\include\xutility(30) : see reference to function template instantiation 'struct std::pair<struct CPoly const *,struct CPoly const *> __cdecl std::mismatch(const struct CPoly *,const struct CPoly *,const struct CPoly *)' being compiled And it only seems to happen when I define a structure like such: struct Bar { std::vector<float> m_vFloat; } struct Foo { std::vector<Bar> m_vBars; }; And since it's a templated error, it's nigh impossible to pinpoint where it's happening, and it's driving me up the wall. Do you guys have any suggestions? Thanks a lot.
Advertisement
If you're going to call std::mismatch on a container (directly or indirectly), the objects it contains must have an == operator. CPoly doesn't - or you've made it a non-const member function.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Ah, but there's the thing: I'm not calling std::mismatch...-anywhere-.

That's what's flummoxed me the most.
And I don't see how it could be calling indirectly... all I'm doing are standard accessor operations with the vectors.
Okay, ridiculously enough, defining an == operator made it compile.

I'm still a little miffed at why this was happening, though.
Quote:Original post by Julian Spillane
Okay, ridiculously enough, defining an == operator made it compile.

I'm still a little miffed at why this was happening, though.
Try putting in a breakpoint inside of that operator == function, and see what is in the call stack when/if it hits the breakpoint.
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms
Quote:Original post by Julian Spillane
Okay, ridiculously enough, defining an == operator made it compile.

I'm still a little miffed at why this was happening, though.


Are you sure you're not doing == between two vectors somewhere? That will trigger an element-by-element comparison, possibly relying on std::mismatch.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Hmm...I could be.

It's getting late though, so I'll look it over tomorrow.

Thanks a lot though for being so swift to reply and helpful. Cheers!

rate++!

This topic is closed to new replies.

Advertisement