Home

On Oct 4, 11:01 pm, Markus Schoder <a3vr6dsg-use...@yahoo.de> wrote:
> On Thu, 04 Oct 2007 14:09:02 +0000, esuvs81 wrote:
> > I wish to modify some values of items contained in a set after they have
> > been added. However, the Jossutis book tells me:

> > "...from an iterator's point of view, all element are considered
> > constant. This is necessary to ensure that you can't compromise the
> > order of the elements by changing their values."

> > I accept this makes sense - however I have provided custom comparison
> > operators and I know that the values I want to change are not used by
> > these comparison operators - hence changing them shouldn't affect the
> > ordering.

> [snip]
> > Visual C++ is actually fine with this, but GCC complains that my
> > 'setNormal()' function is non-const but is being called on a const
> > object. So I make 'setNormal()' a const function, which in turn means
> > making the normal variable mutable so it can still be changed.

> Visual C++ is compliant with the current C++ standard (2003) in this
> respect -- GCC is not. There is however a defect report that has made it
> into the working paper of the upcoming new standard which will change
> things around.

The 1998 version of the standard doesn't say one way or another,
so both VC++ and G++ are correct, depending on how you interpret
things. The defect report was because this wasn't specified,
and the resolution only clarified the original intent.
(Presumably---since that's all resolutions of defect reports are
supposed to do. In all likelihood, the people actually voting
on the original standard had different intents. At any rate, I
do know that there was some disagreement concerning this.)

> So eventually your code will very likely become illegal.

A TC is the standard committees way of saying: this is what the
standard means. So formally, the code is illegal today.

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

previous
next

cgi
Re: So what exactly is a complex number?
Re: Howto Launch a windows application ?
Re: The meaning of a = b in object oriented languages
Re: ImportError depending on the calling module
Dzieci Niczyje
Mam Marzenie
Fundacja Iskierka
Nasze Dzieci
Mimo Wszystko