On Sun, 25 Jan 2015 14:28:05 -0500, DSF <nota...@address.here>
wrote:
Hello, group!
> I have a template class that requires "==" to be overloaded in any
>class that uses it. If the class doesn't overload "==", I get the
>compile time message "Illegal structure operation" on the "=="
>comparison line. This is the error I am receiving. I have gone
>through the entire project and every class is never used with the
>template class or has "==" overloaded.
>
> If it were a runtime error, I could track down the class involved.
>But as it stands, I'm stuck! Any ideas on how to track down this
>error?
>
Problem found and solved! In retrospect, there was an "if it was a
snake, it would've bitten you" clue in my post "Linker errors
involving template". It only became obvious since I found this error.
How did I find it? Through many sleepless nights and blurry-eyed
days. :o)
Until I got the idea about 45 minutes ago to use the command line
version of the compiler and see if it gave a more detailed answer. It
did:
Error e:\library\include\CPP/FAList.h 530: Illegal structure operation
in function FAList<HashIndex>::Find(const HashIndex &) const
Finally! A class to go with FAList! (The same class referred to in
"Linker errors involving template".)
The problem? Almost too embarrassing to relate...almost.
HashIndex has six members:
bool firsthash;
int64 hash;
FString firstname;
FString originalname;
FAList<AlternateNames> altnames;
uint duplicates;
It overloads all of the comparison operators through friends. The
comparisons are all based on the member "hash". For some now unknown
reason, that was what I concentrated on. So I had the following code:
(Only one comparison operator shown for brevity, but they were all
this way...Sigh!)
HashIndex
{
public:
...
friend bool operator == (int64 h1, int64 h2);
};
inline bool operator==(int64 h1, int64 h2)
{return Cmp64To64(h1, h2) == 0);}
It finally occurred to me half an hour ago that you're supposed to
pass const references of the class to operator ==, not the member you
want to test! D'Oh!
So it became:
HashIndex
{
public:
...
friend bool operator==(const HashIndex& h1, const HashIndex& h2);
};
inline bool operator==(const HashIndex& h1, const HashIndex& h2)
{return Cmp64To64(h1.hash, h2.hash) == 0;}
And all is peaceful again in Whoville!