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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kushalsoftpro

    #1

    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_mapPHLRecorde r ;
    MyMap::iterator m_Iterator;

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

    m_Iterator = m_mapPHLRecorde r.find(nRecorde rID);
    if (m_Iterator != m_mapPHLRecorde r.end())
    {
    return (*m_Iterator).s econd ;
    }
    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

    #2
    Re: C2064: term does not evaluate to a function ( While using STLmap)

    kushalsoftpro wrote:[color=blue]
    > 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;[/color]

    What's the BOOL for? The third argument of 'std::map' template is
    supposed to be a _functor_.
    [color=blue]
    >
    > In class definition file i am using this map as:--
    >
    > MyMap m_mapPHLRecorde r ;
    > MyMap::iterator m_Iterator;
    >
    > In one function of implementation file the code is :--
    >
    > m_Iterator = m_mapPHLRecorde r.find(nRecorde rID);
    > if (m_Iterator != m_mapPHLRecorde r.end())
    > {
    > return (*m_Iterator).s econd ;
    > }
    > 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.[/color]

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

    V

    Comment

    • John Harrison

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


      "Victor Bazarov" <v.Abazarov@com Acast.net> wrote in message
      news:vj6id.7916 $Ae.4284@newsre ad1.dllstx09.us .to.verio.net.. .[color=blue]
      > kushalsoftpro wrote:[color=green]
      > > 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;[/color]
      >
      > What's the BOOL for? The third argument of 'std::map' template is
      > supposed to be a _functor_.
      >[/color]

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

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

      john


      Comment

      • Victor Bazarov

        #4
        Re: C2064: term does not evaluate to a function ( While using STLmap)

        John Harrison wrote:[color=blue]
        > "Victor Bazarov" <v.Abazarov@com Acast.net> wrote in message
        > news:vj6id.7916 $Ae.4284@newsre ad1.dllstx09.us .to.verio.net.. .
        >[color=green]
        >>kushalsoftp ro wrote:
        >>[color=darkred]
        >>>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;[/color]
        >>
        >>What's the BOOL for? The third argument of 'std::map' template is
        >>supposed to be a _functor_.
        >>[/color]
        >
        >
        > There no reason apparent from the posted code why the OP couldn't simply
        > remove BOOL.
        >
        > typedef std::map <unsigned long,LPVOID> MyMap;[/color]

        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

        Comment

        • kushalsoftpro

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



          Comment

          • kushalsoftpro

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



            Comment

            • John Harrison

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


              "kushalsoft pro" <kushal.khandel wal@gmail.com> wrote in message
              news:2fe4a42e2f fb1746a75c5aded 6ac2062@localho st.talkaboutpro gramming.com...[color=blue]
              > 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.
              >[/color]

              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


              Comment

              Working...