std::map<> error message only in in release mode

Discussion in 'C++' started by Rune Allnor, Oct 17, 2009.

  1. Rune Allnor

    Rune Allnor Guest

    Hi all.

    I have an application that compiles silently in debug mode. When
    switching
    to release mode, the following error message appears:

    C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xtree(1268) :
    error C3848: expression having type 'const
    mynamespace::pointListLess<T>' would lose some const-volatile
    qualifiers in order to call 'bool
    mynamespace::pointListLess<T>::eek:perator ()(const size_t &,const size_t
    &)'

    I have never seen this error before, and What should I look for to
    find the cause?
    Except for one message that points out the class where the map is
    declared, the
    remaining error messages refer to the map and xtree headers.

    Rune
     
    Rune Allnor, Oct 17, 2009
    #1
    1. Advertising

  2. On 17/10/09 23:36, Rune Allnor wrote:
    > Hi all.
    >
    > I have an application that compiles silently in debug mode. When
    > switching
    > to release mode, the following error message appears:
    >
    > C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xtree(1268) :
    > error C3848: expression having type 'const
    > mynamespace::pointListLess<T>' would lose some const-volatile
    > qualifiers in order to call 'bool
    > mynamespace::pointListLess<T>::eek:perator ()(const size_t&,const size_t
    > &)'


    It probably says that there is a const object of type
    mynamespace::pointListLess<T> whose operator() is being called. Make
    that operator a const functions, e.g.:

    bool operator()(...) const

    > I have never seen this error before, and What should I look for to
    > find the cause?
    > Except for one message that points out the class where the map is
    > declared, the
    > remaining error messages refer to the map and xtree headers.


    Normally, standard containers like set<> and map<> store the comparison
    functor as a member (or a base class of a member to take advantage of
    empty base class optimization). Some member functions of the container
    are const and in those functions the comparison functor is const. Thus
    there need to be a const version of functor::eek:perator().

    --
    Max
     
    Maxim Yegorushkin, Oct 18, 2009
    #2
    1. Advertising

  3. Rune Allnor

    Rune Allnor Guest

    On 18 Okt, 01:47, Maxim Yegorushkin <>
    wrote:
    > On 17/10/09 23:36, Rune Allnor wrote:
    >
    > > Hi all.

    >
    > > I have an application that compiles silently in debug mode. When
    > > switching
    > > to release mode, the following error message appears:

    >
    > > C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xtree(1268) :
    > > error C3848: expression having type 'const
    > > mynamespace::pointListLess<T>' would lose some const-volatile
    > > qualifiers in order to call 'bool
    > > mynamespace::pointListLess<T>::eek:perator ()(const size_t&,const size_t
    > > &)'

    >
    > It probably says that there is a const object of type
    > mynamespace::pointListLess<T> whose operator() is being called. Make
    > that operator a const functions, e.g.:
    >
    >      bool operator()(...) const


    Brilliant! Thanks, that solved the problem.

    Rune
     
    Rune Allnor, Oct 18, 2009
    #3
    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. Peter Jansson
    Replies:
    5
    Views:
    6,437
    Ivan Vecerina
    Mar 17, 2005
  2. Replies:
    1
    Views:
    456
    red floyd
    Dec 21, 2008
  3. Thomas J. Gritzan
    Replies:
    6
    Views:
    1,051
    James Kanze
    Dec 22, 2008
  4. James Kanze
    Replies:
    0
    Views:
    2,067
    James Kanze
    Dec 21, 2008
  5. TimG
    Replies:
    6
    Views:
    444
    Steven Cheng[MSFT]
    Sep 3, 2007
Loading...

Share This Page