mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 03:39:01 +08:00
add ei_cast_to_int, we are indeed somethings (e.g. in IO.h) casting scalars to int and the only way to allow users to extend that to their own scalar types that don't have int cast operators, was to allow them specialize ei_cast_to_int_impl.
This commit is contained in:
parent
8f99ae5ea4
commit
9e0d8697c7
@ -132,7 +132,7 @@ struct ei_significant_decimals_impl
|
||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||
static inline int run()
|
||||
{
|
||||
return (int) std::ceil(-ei_log(NumTraits<RealScalar>::epsilon())/ei_log(RealScalar(10)));
|
||||
return ei_cast_to_int(std::ceil(-ei_log(NumTraits<RealScalar>::epsilon())/ei_log(RealScalar(10))));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -44,6 +44,20 @@ template<typename T> inline typename NumTraits<T>::Real ei_hypot(T x, T y)
|
||||
return p * ei_sqrt(T(1) + qp*qp);
|
||||
}
|
||||
|
||||
template<typename T> struct ei_cast_to_int_impl
|
||||
{
|
||||
static int run(const T& x)
|
||||
{
|
||||
return int(x);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T> inline int ei_cast_to_int(const T& x)
|
||||
{
|
||||
return ei_cast_to_int_impl<T>::run(x);
|
||||
}
|
||||
|
||||
|
||||
/**************
|
||||
*** int ***
|
||||
**************/
|
||||
|
Loading…
x
Reference in New Issue
Block a user