I thought that this conversion cannot fail. So boost::numeric_cast<double>(long)
should produce the same result as just a regular cast.
Is this correct? If so, why is the boost::numeric_cast
slower than a regular cast? Is there some sort of check it is doing?
From the documentation:
So it looks like boost's numeric casts do some extra checking, and can throw exceptions -- so they're not always the same as a "regular cast".