Boost logo

Boost :

From: John Maddock (John_Maddock_at_[hidden])
Date: 2001-02-04 07:59:24


>This doesn't correspond with my recent experience. If what you are saying
>were true, counting_iterator_test.cpp would always fail for plain VC6.

I don't see any integral constant expressions that are actually used in
that file, (at first glance) is_numeric appears not to be used?

Anyway, after some more investigation there is some strange stuff going on
here, consider the following program:

template <class T>
struct int_checker_good
{
   enum{ t = std::numeric_limits<T>::is_specialized };
   typedef int (&type)[t ? 1 : -1];
   BOOST_STATIC_ASSERT(t);

        static void check()
        {
      typedef int (&type)[std::numeric_limits<T>::is_specialized ? 1 : -1];
      BOOST_STATIC_ASSERT(std::numeric_limits<T>::is_specialized);
        }
};

//
// this class will fail on VC6, even if we never instantiate it!!
template <class T>
struct int_checker_bad
{
   typedef int (&type)[std::numeric_limits<T>::is_specialized ? 1 : -1];
   BOOST_STATIC_ASSERT(std::numeric_limits<T>::is_specialized);

        static void check()
        {
      typedef int (&type)[std::numeric_limits<T>::is_specialized ? 1 : -1];
      BOOST_STATIC_ASSERT(std::numeric_limits<T>::is_specialized);
        }
};

int_checker_good<int> c1;
// int_checker_bad<int> c2;

The int_checker_bad template, generates static_assertion failures, even
though no instances are ever instantiated! Assigning the value to test to
an enum first and then passing the enum to the assertion fixes the problem,
however this workaround breaks some other compilers (Borland C++). Ideally
I would encapsulate the fix inside the BOOST_STATIC_ASSERT macro, but that
requires __LINE__ to be working which it doesn't (at least not reliably
under VC6). Any ideas?

BTW at function scope everything is OK, it's just static assertion at class
scope with VC6 that are broken.

- John Maddock
http://ourworld.compuserve.com/homepages/john_maddock/


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