Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2004-04-20 14:05:05


From: "Dill, John" <john-dill_at_[hidden]>
>
> I am wondering about the use-case of numeric_cast in this sample.
>
> unsigned char uchar_max = std::numeric_limits<unsigned char>::max();
> char schar_value = 0;
>
> try {
> schar_value = boost::numeric_cast<char>( uchar_max );
> }
> catch ( boost::bad_numeric_cast )
> { std::cout << "Overflow occurred..." << std::endl; }
>
> When I execute this sample, I don't get the exception. What's
> the background on this behavior? I'm using gcc 3.3.1.

Your char is unsigned.

-- 
Rob Stewart                           stewart_at_[hidden]
Software Engineer                     http://www.sig.com
Susquehanna International Group, LLP  using std::disclaimer;

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk