Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2004-09-04 21:33:04


"David Abrahams" <dave_at_[hidden]> wrote
> "Andy Little" <andy_at_[hidden]> writes:

> > If so ... Is this not a lurking bug waiting to happen?
>
> No, why?
>
> > Note however that run_time numeric_cast Source parameter would not
> > be deducible if changed, I think.
>
> ??
>
> > Other similar inconsistency is (I think) is_convertible).
>
> Specifically?

#include "boost/numeric/converter.hpp"
#include "boost/type_traits/is_convertible.hpp"
#include <complex>
#include <cassert>

template<typename Target, typename Source>
Target do_conv( Source const & s)
{
   typedef boost::numeric::converter<Target,Source> conv;
   assert((boost::is_convertible<Target,Source>::value) );
   typedef conv::result_type result_type;
   result_type res = conv()(s);
   return res;
}
int main()
{
  do_conv<int>(2.);

/* once a year*/
  do_conv<std::complex<double> >(2.);
}

regards
Andy Little


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