[omniORB] Corba union waste of space?

Bruce Visscher bruce.visscher at gmail.com
Thu Dec 4 13:27:11 GMT 2008


> This seems like a bug (waste of space) to me or is there any reason that the
> string members do not go into the union?

I think you answered your own question:

> (I suppose the
> complex types are not allowed in a C++union?).

But you indicate that:

> [...] orbacus [...] uses pointers here so they fit into the C++ union data type

For some reason I had thought that the space wasting implementation
was somehow required by the standard but maybe not.

In C++ I find that I only occasionally wish I had some kind of
discriminated union type ("plain ol;" unions are of course odious).
Maybe that is because I can use polymorphism or generic programming as
an alternative (or even casting through void*).  But since IDL doesn't
have classes (an interface isn't quite the same thing) it does seems
to come up more often.  However, I usually don't worry about wasting
the space.  If you think about it, your example isn't as bad as it
might seem at first.  It only "wastes" instances of the class
String_member which are only going to have pointers and (maybe) ints
in them.  The unbounded string data is on the heap.

I suppose if IONA doesn't have a patent on this (it is obvious so it
shouldn't) maybe someone could implement this if they wanted.



More information about the omniORB-list mailing list