Boost logo

Boost :

From: Craig Henderson (cdm.henderson_at_[hidden])
Date: 2002-10-16 09:55:27


"David Abrahams" <dave_at_[hidden]> wrote in message
news:uvg42pmzd.fsf_at_boost-consulting.com...
> Michael Stevens <michael_at_[hidden]> writes:
>
> >
> > template <class IntType>
> > class fred
> > {
> > static const bool x = std::numeric_limits<IntType>::is_integer;
> > BOOST_STATIC_ASSERT(std::numeric_limits<int>::is_integer); //
OK
> > BOOST_STATIC_ASSERT(std::numeric_limits<IntType>::is_integer); //
> > FAILS on definition of template!
> > };
> >
> >
> > This little beauty is stoping the current random implementation from
> > compiling. Obvious solution is to enable
> > BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS for VC7.
> >
> > Any ideas?
>
> You could try:
>
> BOOST_STATIC_CONSTANT(bool, x =
std::numeric_limits<IntType>::is_integer);
> BOOST_STATIC_ASSERT(x);
>
> You could also try forcing x to be an enum, if BOOST_STATIC_CONSTANT
> isn't already configured that way for vc7.

I had a similar problem recently with the Borland compiler and enums. I
solved it in a similar way to David's suggestion above, try something like
this:

// untested code follows:
typedef std::numeric_limits<IntType> limit_t;
BOOST_STATIC_ASSERT(limit_t::is_integer);

or if VC7 really needs it spelling out:

// untested code follows:
typedef std::numeric_limits<IntType> limit_t;
BOOST_STATIC_CONSTANT(bool, x = limit_t::is_integer);
BOOST_STATIC_ASSERT(x);

:-)
-- Craig


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