Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   C2064: term does not evaluate to a function ( While using STL map) (http://www.velocityreviews.com/forums/t286709-c2064-term-does-not-evaluate-to-a-function-while-using-stl-map.html)

kushalsoftpro 11-03-2004 02:40 PM

C2064: term does not evaluate to a function ( While using STL map)
 
Hi I am using STL map in VC++6.0 application.
type of project is MFC DLL.

My code looks like:--

typedef std::map <unsigned long,LPVOID, BOOL> MyMap;

In class definition file i am using this map as:--

MyMap m_mapPHLRecorder ;
MyMap::iterator m_Iterator;

In one function of implementation file the code is :--

m_Iterator = m_mapPHLRecorder.find(nRecorderID);
if (m_Iterator != m_mapPHLRecorder.end())
{
return (*m_Iterator).second ;
}
else
{
// Error Reporting
// Message Line 1: Unable to find Protocol Handler Library.
// Message Line 2: Invalid Recorder Serial Number.
return NULL;
}


If I am not calling the STL map's functions then no errors are coming.

Can anybody please help.


Victor Bazarov 11-03-2004 02:55 PM

Re: C2064: term does not evaluate to a function ( While using STLmap)
 
kushalsoftpro wrote:
> Hi I am using STL map in VC++6.0 application.
> type of project is MFC DLL.
>
> My code looks like:--
>
> typedef std::map <unsigned long,LPVOID, BOOL> MyMap;


What's the BOOL for? The third argument of 'std::map' template is
supposed to be a _functor_.

>
> In class definition file i am using this map as:--
>
> MyMap m_mapPHLRecorder ;
> MyMap::iterator m_Iterator;
>
> In one function of implementation file the code is :--
>
> m_Iterator = m_mapPHLRecorder.find(nRecorderID);
> if (m_Iterator != m_mapPHLRecorder.end())
> {
> return (*m_Iterator).second ;
> }
> else
> {
> // Error Reporting
> // Message Line 1: Unable to find Protocol Handler Library.
> // Message Line 2: Invalid Recorder Serial Number.
> return NULL;
> }
>
>
> If I am not calling the STL map's functions then no errors are coming.
>
> Can anybody please help.


You can help yourself if you read the reference for the Standard library,
the section about the 'map' template.

V

John Harrison 11-03-2004 03:21 PM

Re: C2064: term does not evaluate to a function ( While using STL map)
 

"Victor Bazarov" <v.Abazarov@comAcast.net> wrote in message
news:vj6id.7916$Ae.4284@newsread1.dllstx09.us.to.v erio.net...
> kushalsoftpro wrote:
> > Hi I am using STL map in VC++6.0 application.
> > type of project is MFC DLL.
> >
> > My code looks like:--
> >
> > typedef std::map <unsigned long,LPVOID, BOOL> MyMap;

>
> What's the BOOL for? The third argument of 'std::map' template is
> supposed to be a _functor_.
>


There no reason apparent from the posted code why the OP couldn't simply
remove BOOL.

typedef std::map <unsigned long,LPVOID> MyMap;

john



Victor Bazarov 11-03-2004 03:27 PM

Re: C2064: term does not evaluate to a function ( While using STLmap)
 
John Harrison wrote:
> "Victor Bazarov" <v.Abazarov@comAcast.net> wrote in message
> news:vj6id.7916$Ae.4284@newsread1.dllstx09.us.to.v erio.net...
>
>>kushalsoftpro wrote:
>>
>>>Hi I am using STL map in VC++6.0 application.
>>>type of project is MFC DLL.
>>>
>>>My code looks like:--
>>>
>>> typedef std::map <unsigned long,LPVOID, BOOL> MyMap;

>>
>>What's the BOOL for? The third argument of 'std::map' template is
>>supposed to be a _functor_.
>>

>
>
> There no reason apparent from the posted code why the OP couldn't simply
> remove BOOL.
>
> typedef std::map <unsigned long,LPVOID> MyMap;


Right. But it is also possible that the OP thought it ought to be the
return value type of the comparator. Perhaps a special kind of the
sorting functor is needed... Anyway, our guesses are only as good as
the information available to us. Let's hope "softpro" gets that.

V

kushalsoftpro 11-04-2004 03:46 AM

Re: C2064: term does not evaluate to a function ( While using STL ma
 
Thanx John, Victor,

It worked.

Actually I havn't used STL much in past.

My intension was to put a third element in the map. For that only I put
BOOL as third parameter. Anyways, I have some other ways for managing this
third parameter.


Thanx again..




kushalsoftpro 11-04-2004 03:46 AM

Re: C2064: term does not evaluate to a function ( While using STL ma
 
Thanx John, Victor,

It worked.

Actually I havn't used STL much in past.

My intension was to put a third element in the map. For that only I put
BOOL as third parameter. Anyways, I have some other ways for managing this
third parameter.


Thanx again..




John Harrison 11-04-2004 07:47 AM

Re: C2064: term does not evaluate to a function ( While using STL ma
 

"kushalsoftpro" <kushal.khandelwal@gmail.com> wrote in message
news:2fe4a42e2ffb1746a75c5aded6ac2062@localhost.ta lkaboutprogramming.com...
> Thanx John, Victor,
>
> It worked.
>
> Actually I havn't used STL much in past.
>
> My intension was to put a third element in the map. For that only I put
> BOOL as third parameter. Anyways, I have some other ways for managing this
> third parameter.
>


The first parameter to a map is the key that you use to look up the value.
The second parameter to a map is the value.
The third (optional) parameter to a map is the key comparison object.
The fourth (optional) parameter to a map is the allocator object.

If you want to put an LPVOID and a BOOL into a map you do it like this

struct MyData
{
LPVOID v;
BOOL b;
};
typedef std::map <unsigned long,MyData> MyMap;

Of course this means that every entry in the map has an LPVOID and a BOOL,
not that some have an LPVOID and some have a BOOL. If that was your
intention, well there are ways of doing that too.

john




All times are GMT. The time now is 03:33 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.