
Brandon Kohn wrote:
Hello,
Recently I was creating a new numeric type which I wanted to use along with boost::numeric_cast. I read over the docs and examples and found that it seemed to support (at least partially) the notion of policy driven casting operations. I was unable to figure out how one might use a custom conversion or overflow policy along with the actual boost::numeric_cast<N>(x) function. In the end I created a workaround which seemed to work nicely:
template <typename ConversionTraits, typename EnableIf = void> struct numeric_cast_traits { typedef def_overflow_handler overflow_handler; typedef UseInternalRangeChecker range_checker; typedef Trunc < typename ConversionTraits::source_type > rounding_policy; };
Hi, I would prefer that numeric_cast_traits is templated with typename Target, typename Source, typename EnableIf = void as it seems to me more natural than using another trait as parameter. Best, Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/numeric-cast-tp3602499p3617554.html Sent from the Boost - Dev mailing list archive at Nabble.com.