[Exceptional C++ Style] Exceptional C++ Style - Item 24:

Hammond, Peter peter.hammond at amsjv.com
Thu Jan 27 06:52:57 EST 2005




> -----Original Message-----
> From: White Wolf [mailto:wolof at freemail.hu]
> Sent: 27 January 2005 11:28
> To: effective-cpp at accu.org
> Subject: RE: [Exceptional C++ Style] Exceptional C++ Style - Item 24:
> 
> "Hammond, Peter" wrote:
> > I was wondering about this in the context of coding
> standards recently. In
> > Exceptional C++ (item 43) Herb remarks that const on a
> value parameter is
> > pointless, and when I see it in a header it worries me: it
> is a sign that
> > someone may have misunderstood const, or pass-by-vlaue, or
> both. On the
> > other hand, having the constness of the argument enforced
> in the
> > implementaion can be very useful. The obvious way to solve
> it is to leave it
> > in the implemtation, but remove it from the definition, as
> the guideline
> > above. However, the difference between declaration and
> definition would seem
> > to be a source of confusion for many. Has anyone got any
> experience of this
> > kind of guideline and whether in practice it helps or
> confuses?
> 
> You don't want to do that unless you are sure you won't need
> to use those version of the Sun C++ compiler which (going
> against the standard) count the constness of passed-by-value
> arguments into the function signature - but only while
> mangling the name.  They accept your (header non-const,
> impl. const) function, it compiles, but it cannot link, as
> the callers (who see the header only) will refer to the
> function with a different name.
> 
> WW aka Attila
>

Ouch. We have many problems caused by the need to support old Sun and other
compilers. I'll not be introducing this guideline then. Thanks for the
warning.

Pete.
[ *** LongSig auto truncated *** ]



More information about the Effective-cpp mailing list