Topic: Union member with user-def = op. forbidden! Why?


Author: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Date: Tue, 1 Mar 1994 03:55:20 GMT
Raw View
pjac@emma.ruc.dk (Peter Jacobsen) writes:

>howland@us-es.sel.de (Gary Howland US/END 60/1/25) writes:
>
>>pjac@emma.ruc.dk (Peter Jacobsen) writes:
>>> An object of a class with a user-defined assignment operator,
>>> why can't it be a member of a union? (r.9.5)

Because the ARM says so.

>>Suppose union U contains a member which is a class with an overloaded
>>assignment operator.  When assigning to an instance of U, which assignment
>>operator should we use; the one for the union, or the one for the member
>>with the assignment operator?  We cannot choose, so it is disallowed

This is the rationale behind the ARM rule, but it is misguided.
A better rule would be to prohibit assignment of unions containing
these members, unless the union itself has a user-defined assignment
operator.

--
Fergus Henderson - fjh@munta.cs.mu.oz.au