Boost logo

Boost :

From: Rozental, Gennadiy (gennadiy.rozental_at_[hidden])
Date: 2002-10-02 13:27:30

> Are those just a few exceptions? I think I read in D&E a
> discussion that const is almost useless (but I can't locate
> D&E now, so I can't look it up). Searching for material on
> this now, I find a reference to an article by Andrew Koenig
> (How much does const promise? - C++ Report/1997) that
> apparently seems to make the same point but I don't know
> because I haven't read the article. Another page I found
> gave an example that the compiler must make sure that "this"
> is not saved in any of the constructors as this would allow
> the object to access itself non-constly. This means the
> compiler must know the content of the constructor with which
> your optimization candidate was initialized, and the content
> of the constructors used in the initializer list of that
> constructor for each the object's members, etc etc
> recursively, before considering optimizations. Maybe I'm
> just talking nonsense, but it was just my (perhaps-mistaken)
> understanding that compilers cannot really do optimizat!
> ions based on const, without a lot of work that is not worth
> it just for this optimization capability. Anyway, this is
> all I can say on the subject :)

I second this. I also beleive that due to presence in a language const_cast
and mutable in majority of the cases compiler is not capable of any
optimization based in constness.


Boost list run by bdawes at, gregod at, cpdaniel at, john at