Boost logo

Boost :

From: Mark Rodgers (mark.rodgers_at_[hidden])
Date: 2000-07-14 03:02:33


> I knew Borland was having some trouble with (partial)
> specialization on non-type (bool) template paramters in operators.hpp, so
I
> suspected it wouldn't work.

The problem with operators.hpp was the default value, and even then
only if the default is a static const member of a template!

So given

  template <class T> struct is_chained_base;
  template <class T> struct op {};
  struct foo { static const bool value = false; };

All of these work fine

  template <class T, bool O>
  struct V : op<T> {};

  template <class T, bool O = false>
  struct W : op<T> {};

  template <class T, bool O = foo::value>
  struct X : op<T> {};

But this fails. :-(

  template <class T, bool O = is_chained_base<T>::value>
  struct Y : op<T> {};

That's why we needed to fall back on

  template <class T,class O = typename is_chained_base<T>::value>
  struct Z : op<T> {};

> Terriffic. I think the difference is that MSVC's native <limits>
> uses enums to define static constants, and the compiler is able
> to use these at compile time. The STLport uses out-of-line static
> const bools.
> Boris, take note!

STLport is wrong in this case. 18.2.1p3 is quite explicit that
your code is valid. The constants must be usable as integral
constant expressions, which means they should be enums or in line.

Mark


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