[PATCH] Unions with References

Sebastian Redl sebastian.redl at getdesigned.at
Thu May 30 07:18:31 PDT 2013


On 2013-05-30 15:36, Aaron Ballman wrote:
> Microsoft has a language extension which allows union members to be
> references.  What's more, they use this language extension in their
> ATL header files (which come as part of MFC and the Win32 SDK).
> Basically, they have code like this:
>
> struct s {
>    union {
>       foo *fp;
>       foo &fr;
>      };
>
>      s( foo &f ) : fr( f ) {}
>      s( foo *f ) : fp( f ) {}
> };
>
Seriously, what's wrong with

foo *fp;

s( foo &f) : fp( &f ) {}

? I'm really curious about what motivated the original authors to write 
this code.

Sebastian



More information about the cfe-commits mailing list