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

R

Rune Allnor

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
 
M

Maxim Yegorushkin

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().
 
R

Rune Allnor

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
 

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

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top