Boost logo

Boost :

From: Paul A. Bristow (boost_at_[hidden])
Date: 2003-10-12 12:11:39


But Please Don't Do It!

Write two lines for those of us less knowledgeable.

C++ rules for multiple declarations and application of * are too complicated
(crazy).

IMO it is always better to write delarations one per line, even for several
ints,
and to declare as close as possible to first use (even though MSVC compilers
seem to ignore the potential optimisations for reusing stack for local variables
declared close to their use, thus increasing the likelihood of keeping within
cache).

Paul

Paul A Bristow, Prizet Farmhouse, Kendal, Cumbria, LA8 8AB UK
+44 1539 561830 Mobile +44 7714 33 02 04
mailto:pbristow_at_[hidden]

| -----Original Message-----
| From: boost-bounces_at_[hidden]
| [mailto:boost-bounces_at_[hidden]]On Behalf Of Ehsan Akhgari
| Sent: Sunday, October 12, 2003 5:10 PM
| To: 'Boost mailing list'
| Subject: RE: [boost] [OT] Quick const question
|
|
| [snip]
| > I'm wondering if this rule also applies to qualifiers. If I want two
| > pointers to constant objects, can I do:
| >
| > int const *a, *b; //[3]
| >
| > or do I have to do:
| >
| > int const *a, const *b; //[4]
| >
| > (which means that [3] gives one const and one non-const pointer)?
|
| The correct form is [3].
|
| > This is an one-time thing, so I don't want to waste time with a
| > typedef or two separate object declaration lines if I don't have to.
|
| You could have easily figured this out by trying to compile the
| following:
|
| int main()
| {
| int const * p1, * p2;
| *p1 = 0;
| *p2 = 0;
| }
|
| -------------
| Ehsan Akhgari
|
| List Owner: MSVC_at_[hidden]
|
| [ Email: ehsan_at_[hidden] ]
| [ WWW: http://www.beginthread.com/Ehsan ]
|
|
| _______________________________________________
| Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
|
|


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk