Boost logo

Boost :

From: John Maddock (John_Maddock_at_[hidden])
Date: 2000-04-27 06:30:41


Jens,

>After we're sure what the real reason is, we can work around
appropriately. It would be good to know what has to be done
to boost/rational.hpp for a start; this might be simpler.
<

I've started separate threads with C++ Builder specific fixes for
operators.hpp and rational.hpp, most of the problems here relate to
template friend functions specifically:

Template friend functions are terminally buggy in C++ Builder (in common
with every other compiler I've tried).
non-template friends of template classes cannot access the class's template
parameters, but as a workaround can access member-typedefs. In addition the
body of these functions must be declared class-inline or the the body will
not be found (you get unresolved externals at compile time).

With regard to random.hpp classes like:

template<class URNG, bool fixed = URNG::has_fixed_range>
struct random_minmax;

template<class URNG>
struct random_minmax<URNG, true>
{
  static typename URNG::result_type min(const URNG & urng)
  { return URNG::min_value; }

  static typename URNG::result_type max(const URNG & urng)
  { return URNG::max_value; }
};

template<class URNG>
struct random_minmax<URNG, false>
{
  static typename URNG::result_type min(const URNG & urng)
  { return urng.min(); }

  static typename URNG::result_type max(const URNG & urng)
  { return urng.max(); }
};

will not compile: the derived default non-type parameter is the problem
here and can be completely hidden using inheritance:

template<class URNG, bool fixed>
struct random_minmax_base;

template<class URNG>
struct random_minmax_base<URNG, true>
{
  static typename URNG::result_type min(const URNG & urng)
  { return URNG::min_value; }

  static typename URNG::result_type max(const URNG & urng)
  { return URNG::max_value; }
};

template<class URNG>
struct random_minmax_base<URNG, false>
{
  static typename URNG::result_type min(const URNG & urng)
  { return urng.min(); }

  static typename URNG::result_type max(const URNG & urng)
  { return urng.max(); }
};

template<class URNG>
struct random_minmax : public random_minmax_base<URNG,
URNG::has_fixed_range>{};

except that that doesn't seem to work either (internal compiler error) -
I'll get hold of your latest code and try to find a better method.

- John.


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