Boost logo

Boost Users :

From: Dave Dribin (dave-ml_at_[hidden])
Date: 2006-07-20 15:27:52


On Jul 20, 2006, at 10:34 AM, me22 wrote:
> The problem is that the classes can't properly act "like ints". The
> way they are now they can't be used in a union, as you've mentions.

One more area where they can't act like int's is in variable length
arguments. Even using my init() method, the following code won't
compile on the printf:

     big4_t x = big4_t::init(42);
     std::cout << x << "\n";
     printf("%d\n", x);

warning: cannot pass objects of non-POD type 'struct
boost::integer::big4_t' through '...'; call will abort at runtime

One way around this is to add a get() method, so you can use:

     printf("%d\n", x.get());

Or, as I prefer, use operator():

     printf("%d\n", x());

Implemented as follows:

         T operator()() const
           { return detail::load_big_endian<T, n_bytes>(bytes); }

-Dave


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