Re: auto const promotion question
Adrian Hawryluk wrote:
I have a question in regards to auto const promotion. When a class
object gets const promoted, all aggregate parts of the class get
promoted as well. However, anything pointed to outside of the class do
not get const promoted. I'm assuming this originally was because of C
and the wish to keep it a subset of C++.
However, I am designing a template library that will manage memory
pointers and while I am at it, I wish to know if anyone thinks that it
would be a good idea to plug this const promotion 'problem'. I asked
this question on comp.lang.c++ and got some responses which lead me to
believe that they don't care. But as I am trying to make a library that
will be used by all, I want some opinions before full implementation.
So I'm asking, is const promotion w.r.t. pointers useful in the context
of the development/maintenance and type-safety of a class?
Take a look at std::vector. Basically (yes, I'm assuming a particular
implementation) it consists of three pointers. The interface however
propagates the const to the pointees, too.
Take a look at std::auto_ptr. It also just wraps a pointer, but the const is
not propagated and since it is supposed to mimic the behaviour of a raw
pointer (to a certain extent) it shouldn't.
In other words, the correct behaviour depends on the context. BTW: the same
applies to 'volatile'.
\ My newsgroup writings are licensed under the Creative Commons /
\ Attribution-Noncommercial-Share Alike 3.0 License /
\_____[http://creativecommons.org/licenses/by-nc-sa/3.0/]_____/
This is complete and utter nonsense. If this was supposed to be applicable,
you would have to state it before the content. As far as I am concerned, I
don't feel bound to this license. As many others here, I'm a professional
C++ developer and asking me to not use any of the info you provided in a
commercial way is silly. I'd even ask moderators to reject such things, as
it is against the open nature of the Usenet.
Uli
--
Sator Laser GmbH
Gesch??ftsf??hrer: Ronald Boers Steuernummer: 02/858/00757
Amtsgericht Hamburg HR B62 932 USt-Id.Nr.: DE183047360
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]