In message <43fdedba$0$8257$6d36acad@taz.nntpserver.com>, TB
<TB@SWEDEN.?.invalid> writes
lakepeir@yahoo.com skrev:
Hello,
I'm having problems with the find function of the STL map structure.
Whenever I call the find method with an ID, the else is executed as if
the value exist in the map. The ID does not exist in the map because I
haven't added it.
Here's the Code:
std::map<CComVariant, CComPtr<Interface> > mymap;
DWORD ID;
Maybe you should initialize 'ID'.
if( mymap.find(ID) == mymap.end() )
{
//do something
}
else
{
//do something
}
Any help is appreciated. Thanks.
How does CComVariant perform equality testing?
Almost but not quite. The relevant question (for std::map) is
"how does CComVariant perform less-than comparisons?" If that isn't a
strict weak ordering, none of std::map's operations will work properly.
Also, how does DWORD get converted to CComVariant? The argument to
map::find should be a (const reference to) key_value, which is
CComVariant, not DWORD.
--
Richard Herring
.