Boost logo

Boost :

From: Doug Gregor (gregod_at_[hidden])
Date: 2001-04-30 10:39:21


On Sunday 29 April 2001 04:16, you wrote:
> Hello!
>
> While debugging boost build problems of HP's aCC compiler, Thomas
> Matelich and I came across code like this:
>
> template<class T>
> class X
> {
> BOOST_STATIC_CONSTANT(bool, value = true)
> };
>
>
> Note that this is lacking the definition of the static member, which
> is required whenever the static constant is "used" according to the
> One Definition Rule (ODR), see section 3.2 of the ISO C++ standard.
> Core issue 48 (should be in the upcoming Technical Corrigendum)
> cleaned up this area.
>
> Thus, for the above example to work, you need to add
>
> #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
> template<class T>
> const bool X<T>::value;
> #endif
>
> to your source code.
>

The proposed resolution to Core issue 48 seems to indicate that the value is
not considered "used" if it is used only as part of sizeof() or in an
integral constant expression, so the definition would be unnecessary.

If all of these definitions are actually required, wouldn't it make sense to
prefer using anonymous enums instead, to avoid the hassle of adding these
definitions?

        Doug Gregor


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