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

K

kushalsoftpro

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.
 
V

Victor Bazarov

kushalsoftpro said:
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
 
J

John Harrison

Victor Bazarov said:
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
 
V

Victor Bazarov

John said:
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
 
K

kushalsoftpro

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..
 
K

kushalsoftpro

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..
 
J

John Harrison

kushalsoftpro said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top