Boost logo

Boost :

From: John Max Skaller (skaller_at_[hidden])
Date: 2001-05-31 18:21:10


Beman Dawes wrote:
 
> >> PS> Following Bruce Florman's suggestion, all of the global extern
> object
> >> declarations are now const declarations. Since there are no non-const
> >> operations being done on these objects (does not have data to modify
> >> in the first place), and since const objects are static by default,
> doing
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >
> >Since when? Have I missed something very significant?
>
> [basic.link] 3.5 Program and linkage
[]
> - an object or reference that is explicitly declared const and neither
> ^^^^^
> explicitly declared extern nor previously declared to have external
> linkage; or

I believe the rationale is that

        const int n = 1;

can be used to replace

        #define n 1

in header files. n is a 'const-expr' and so can be used to
specify array bounds. The value must be visible
for this to work, and this is not possible in multiple
translation units if 'n' has external linkage.
Of course,

        static const int n = 1;

would also work, but 'default' things are mainly
to save typing :-)

-- 
John (Max) Skaller, mailto:skaller_at_[hidden]
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download Interscript http://Interscript.sourceforge.net

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