Boost logo

Boost :

Subject: Re: [boost] numeric_cast
From: Vicente Botet (vicente.botet_at_[hidden])
Date: 2011-06-22 12:50:44

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;
> };


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.


View this message in context:
Sent from the Boost - Dev mailing list archive at

Boost list run by bdawes at, gregod at, cpdaniel at, john at