
Kim Barrett skrev:
At 2:41 AM -0500 11/11/08, David Abrahams wrote:
boost::polymorphic_downcast is meant to be used where you think you really know what derived type you've got, and you want an assertion to reinforce your reasoning with a runtime check. I suppose you can have a similar situation for numeric types (e.g. "I know this long int should fit in a short int").
How about boost::checked_cast, or boost::checked_narrowing_cast or boost::narrow_cast?
Is this any different from boost::numeric_cast with an asserting rather than throwing overflow handler, plus boost/numeric/conversion paying attention to BOOST_NO_EXCEPTIONS, possibly by using boost::throw_exception?
It depends. I can't remember how the overflow handler mechanism works, but we need to be able to have both types of casts in the same program. -Thorsten