<br><font size=3><tt>Hello,<br>
<br>
I have read the "Mapping for Union Types" available on the omg
website <br>
</tt></font><a href=http://www.omg.org/spec/CPP/1.2/PDF/><font size=3 color=blue><tt><u>http://www.omg.org/spec/CPP/1.2/PDF/</u></tt></font></a><font size=3><tt><br>
(and honestly I'm not sure I understand it completly)<br>
<br>
Here's an IDL I have to use :<br>
<br>
enum MyEnum<br>
{<br>
myEnum1,<br>
myEnum2<br>
};<br>
<br>
union MyUnion switch(MyEnum)<br>
{<br>
case myEnum1: LightweightObject lightweight;<br>
case myEnum2: FatObject fat;<br>
};<br>
<br>
I don't have a control over it and I need to allocate a sequence of it
<br>
(possibly long).<br>
<br>
Basically, this is what I would like to write : (#1)<br>
MyUnion &union = seq[no]; // seq is a sequence of MyUnion<br>
union._d(myEnum2); // oops, discriminant not initialized yet<br>
FatObject &fat = union.fat();<br>
initializeFat(fat);<br>
<br>
But it does not work, the correct compliant way is : (#2)<br>
MyUnion &union = seq[no]; // seq is a sequence of MyUnion<br>
FatObject fat;<br>
initializeFat(fat);<br>
union.fat(fat); // initialize discriminant and performs deep copy<br>
<br>
Is there any way to avoid the deep copy ? It can be costly if the sequence
<br>
is very long.<br>
Is there any good reason the spec disallow writing code #1 ?<br>
<br>
Looking at the code generated by omniidl, it would be completly possible
<br>
and safe to do it in the #1 way, but I would have to manually patch the
<br>
generated code to explictly allow it.<br>
Any thought about it ?<br>
<br>
Tx<br>
<br>
David<br>
</tt></font><pre>
This message and any attachments (the "message") is intended solely for
the addressees and is confidential. If you receive this message in error,
please delete it and immediately notify the sender. Any use not in accord
with its purpose, any dissemination or disclosure, either whole or partial,
is prohibited except formal approval. The internet can not guarantee the
integrity of this message. BNP PARIBAS (and its subsidiaries) shall (will)
not therefore be liable for the message if modified. Please note that certain
functions and services for BNP Paribas may be performed by BNP Paribas RCC, Inc.</pre>