|
Boost : |
From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2002-09-26 07:08:14
Björn Karlsson wrote:
> I'm confused - I thought that BOOST_STATIC_CONSTANT already does The Right
> Thing by declaring an enum if there's no support for in-class member
> initialization? What am I missing?
>
> Answer to self (with a little help from the Standard):
>
> "If a static data member is of const integral or const enumeration type, its
> declaration in the class
> definition can specify a constant initializer which shall be an integral
> constant expression (5.19). In that
> case, the member can appear in integral constant expressions within its
> scope. The member shall still be
> defined in a namespace scope if it is used in the program and the namespace
> scope definition shall not contain
> an initializer."
>
> The key: "The member shall still be defined in a namespace scope if it is
> used in the program..."
>
> But doesn't this imply that every use of BOOST_STATIC_CONSTANT must be
> followed by a (out-of-class) definition #ifdef:ed with
> BOOST_NO_INCLASS_MEMBER_INITIALIZATION? If that's the case, I guess we need
> a twin macro - BOOST_STATIC_CONSTANT_DEFINITION (or just use enums). Would
> someone enlighten me, please?
>
See the thread starting with
news://news.gmane.org:119/3D873A4C.82F17098@ginit-technology.com and
especially my reply to
news://news.gmane.org:119/15752.26452.911000.261383@gargle.gargle.HOWL.
(In case you cant use the URLs above, it's the thread titled "question
on static data members of class templates" in this group.)
There are boost libs that do contain definitions for the constants, see
for example the random library.
Markus
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk