Boost logo

Boost Users :

From: me22 (me22.ca_at_[hidden])
Date: 2006-07-20 11:34:23


On 7/20/06, Dave Dribin <dave-ml_at_[hidden]> wrote:
> Hmmm... I'm not sure that would help in my case. The endianness need
> not be different for unions to be useful.
>
I was just guessing. Now that you've described your case, I see what
your reason is.

I'm not a fan of that macro hackery, however...

> Sure, I'll go over the details in a second. But what's the use case/
> rationale for *not* wanting to support unions?
>
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.

But take out the constructors and then the following rather logical
program doesn't work any more:
#include <boost/integer/endian.hpp>
#include <iostream>

int main() {
        boost::integer::big4_t x = 42;
        std::cout << x << "\n";
}

And it can no longer be initialised in member initializer lists. I
don't know whether this or unions is a more pressing concern, however.

Do SFINAE-awayed constructors prevent a class from being used in
unions? That might be a way to allow both if an eventual review can't
come to a conclusion.

~ Scott McMurray


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