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

Discussion in 'C++' started by kushalsoftpro, Nov 3, 2004.

  1. 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.
    kushalsoftpro, Nov 3, 2004
    #1
    1. Advertising

  2. 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
    Victor Bazarov, Nov 3, 2004
    #2
    1. Advertising

  3. "Victor Bazarov" <> wrote in message
    news:vj6id.7916$09.us.to.verio.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
    John Harrison, Nov 3, 2004
    #3
  4. Re: C2064: term does not evaluate to a function ( While using STLmap)

    John Harrison wrote:
    > "Victor Bazarov" <> wrote in message
    > news:vj6id.7916$09.us.to.verio.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
    Victor Bazarov, Nov 3, 2004
    #4
  5. 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, Nov 4, 2004
    #5
  6. 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, Nov 4, 2004
    #6
  7. Re: C2064: term does not evaluate to a function ( While using STL ma

    "kushalsoftpro" <> wrote in message
    news:...
    > 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
    John Harrison, Nov 4, 2004
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon
    Replies:
    1
    Views:
    363
    Jonathan Mcdougall
    Oct 6, 2003
  2. Abhi
    Replies:
    7
    Views:
    2,479
  3. Replies:
    2
    Views:
    552
    klaus hoffmann
    Feb 22, 2006
  4. kl
    Replies:
    7
    Views:
    1,285
    James Kanze
    Jan 1, 2008
  5. KevinSimonson
    Replies:
    6
    Views:
    836
    Bo Persson
    Oct 23, 2010
Loading...

Share This Page