Boost logo

Boost Users :

From: Scott Meyers (usenet_at_[hidden])
Date: 2006-03-07 00:18:16


 From a cursory look through the library doc, it appears that it's possible to
create a UDT such that numeric_cast will work with it. For example,

   class int24 { ... }; // for 24-bit ints; must also specialize
                            // std::numeric_limits, create a range
                            // checking policy, etc.

   int i;
   ...
   int24 myInt = numeric_cast<int24>(i); // throws if i's value won't
                                            // fit in an int24

   short s = numeric_cast<short>(myInt); // throws if myInt's value won't
                                            // fit in a short

Can somebody who knows this library please tell me if my understanding is
correct -- that numeric_cast can be made to work with integral UDTs?

Thanks,

Scott


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net