Boost logo

Boost :

From: Dave Dribin (dave-ml_at_[hidden])
Date: 2006-07-20 16:49:23


I started a thread on Boost-users about the proposed endian library,
but it's probably more suitable on the dev list. Here's a link to
the thread in the archives:


I see two issues with the library as of 0.5. First, the endian
classes cannot be used in unions. And, second the classes cannot be
used in variable argument lists. I'm attaching a patch to help
resolve both of these issues.

In order to be used in a union, a class must not have any
constructors. However, removing constructors breaks the following code:

   big4_t x = 42;

My solution was to provide a static init() method to help in these

   big4_t x = big_t::init(42);

The second problem shows up using varargs. For example, this will
not compile:

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

The solution I came up with is to use operator() to get the native

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

In my patch, I've also added a check_unions() function to
endian_test.cpp that tests the sizes of unions.



Boost list run by bdawes at, gregod at, cpdaniel at, john at