Newbie: STL Map Container find method functioN



 DEVELOP > c-Plus-Plus > Newbie: STL Map Container find method functioN

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: ""
Date: 23 Feb 2006 11:08:16 AM
Object: Newbie: STL Map Container find method functioN
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;
if( mymap.find(ID) == mymap.end() )
{
//do something
}
else
{
//do something
}
Any help is appreciated. Thanks.
.

User: "TB TB@SWEDEN"

Title: Re: Newbie: STL Map Container find method functioN 23 Feb 2006 11:20:23 AM
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?
--
TB @ SWEDEN
.
User: ""

Title: Re: Newbie: STL Map Container find method functioN 23 Feb 2006 01:10:53 PM
ID is actually passed in as a parameter. I just wanted to state it was
a DWORD.
.

User: "Richard Herring"

Title: Re: Newbie: STL Map Container find method functioN 01 Mar 2006 08:20:10 AM
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
.



  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER