template<class Ret, class Input>
bool OEIsSafeCast(Input arg, std::string &msg)

Returns true if the input value in arg can be safely cast to the output type Ret without loss of information. Returns false if there would be lost information, i.e., casting an negative number to an unsigned type. If false is returned, an error message is placed into the msg argument string.