Boost logo

Boost :

From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2001-04-29 15:16:58


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.

I've done so for boost/integer_traits.hpp, and I would like to
ask all developers to check and possibly augment their code
similarly.

Note that compilers are free not to diagnose the problem, and
most compilers actually don't in this particular case.

Jens Maurer


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