<[EMAIL PROTECTED]> wrote in message 3D8559AE95B4D611B02C0002557C6C8B3C45BF@STH-EXCH">news:3D8559AE95B4D611B02C0002557C6C8B3C45BF@STH-EXCH... > > From: Thorsten Ottosen [mailto:[EMAIL PROTECTED]] > > > > Hi Boosters, > > > > I was wondering if it would be possible to implement a wrapper around > > built-in types to provide automatic detection of conversion > > problems: > > [snip] > > What would the advantage be over using boost::numeric_cast directly, and > thus explicitly? Using these wrappers, it wouldn't be obvious that there are > numeric_casts involved (implying possible failure [and therefore try/catch > blocks for bad_numeric_cast]).
you would't have to worry about if you forgot a numeric_cast somewhere in your code or if you compiled on a platform with different ranges for built-ins which suddenly could make conversion problems appear. > As I see it, automatic detection of > conversion problems wouldn't buy much unless it could also remedy the > problem. that depends on what the "problem" is. I would say that an _undetected_ false conversion is the biggest problem. >Doing it "manually", and acknowledging the potential problem by > using numeric_cast is (in addition to ensuring correct behavior) > self-documenting, a property that I think is rather important. by using a wrapper, you also acknowledge a potential problem. I might also be beneficial when you are chaning a variable from one type to another; the change might cause conversion problems some different place in the code and/or require numeric_cast to be inserted. By using wrappers this would be detected. regards Thorsten _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost