From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-07-24 14:36:52
----- Original Message -----
From: "Daryle Walker" <darylew_at_[hidden]>
Sent: Tuesday, July 24, 2001 2:26 PM
Subject: [boost] Re: Review: Boost Coding Guidelines
> on 7/24/01 12:40 AM, Tim Butler at tim_at_[hidden] wrote:
> > ------------------------------------------------------------------
> >> 6.7. Place const after the base type it modifies. This simple rule
> >> easier to write type declarations correctly and will make your
> >> consistent with compiler-generated type descriptions in error messages.
> > o I disagree with this simply because I suspect the "const before" form
> > more familiar to most people. I think most people find the *compiler*
> > confusing and I don't think it is valuable making them spend extra
> > interpreting declarations in the code with an unfamiliar style. In fact
> > are a couple instances in this document that appear wrong but require a
> > "double take".
> I also disagree with the compiler message reason, especially since my
> compiler does _not_ do it (i.e. it puts the "const" before the type when
> There is a better reason; putting the qualifier after its base type makes
> the placement consistent with all types. I don't think you realize that
> all types support the pre-qualifier form!
Yes, I do, but apparently I don't always write down the best rationale ;-)
> Pointer declarations, that are
> not hidden in a typedef, must use the post-qualifier form. However, all
> pre-qualifier types can be post-qualified, so using post-qualification all
> the time is the most consistent.
> const int i;
> A constant integer
> int const i;
> Also a constant integer
> const int * p;
> A regular (i.e. non-const) pointer to a constant integer
> int const * p;
> Also a regular pointer to a constant integer
> int * const p;
> A constant pointer to a regular integer
> const int ** p;
> A regular pointer to a regular pointer to a constant integer
> int const ** p;
> Also a regular pointer to a regular pointer to a constant integer
> int * const * p;
> A regular pointer to a constant pointer to a regular integer
> int ** const p;
> A constant pointer to a regular pointer to a regular integer
> volatile int const * volatile * const * p;
> A regular pointer to a constant pointer to a volatile
> pointer to a constant & volatile integer
> > You might rephrase this:
> > Place const before the base type it modifies. Every C++ textbook does
> > so does the C++ standard. :) (please note smiley)
> Use the reason I just gave instead.
Not sure who/what you're responding to here.
Anyway, I doubt this particular point will ever be agreed upon, except if we
say that any form is permissible. I find the pre-qualifier form more
readable myself, but as you say it's less consistent. I'm still trying to
wean myself from it.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk