From -686507788878226032 X-Google-Thread: f78e5,4176870a6d7b2d6 X-Google-Attributes: gidf78e5,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!news-xfer.cox.net!peer01.cox.net!cox.net!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull From: skaller@nospam.com.au ("John Max Skaller") Newsgroups: comp.std.c++ Subject: Re: Union fun Date: Tue, 19 Oct 2004 06:28:46 GMT Lines: 32 Sender: mail2news@demon.net Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++) Message-ID: References: NNTP-Posting-Host: news.news.demon.net Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.demon.co.uk 1098167330 27644 158.152.254.254 (19 Oct 2004 06:28:50 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Tue, 19 Oct 2004 06:28:50 +0000 (UTC) X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov) X-User-Agent: Pan/0.13.3 (That cat's something I can't explain) X-Spam-Checker-Version: SpamAssassin 2.64-mulga_r1 (2004-01-11) on mulga.cs.mu.OZ.AU X-Spam-Status: No, hits=-4.9 required=5.0 tests=BAYES_00 autolearn=ham version=2.64-mulga_r1 X-Received: (from fjh@localhost) by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id i9J6SkVv020124; Tue, 19 Oct 2004 16:28:46 +1000 (EST) X-Path: comp-std-cpp-robomod!not-for-mail X-Delivered-To: std-c++@ucar.edu X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f X-Newsgroups: comp.std.c++ Xref: g2news1.google.com comp.std.c++:3111 On Mon, 18 Oct 2004 11:35:01 -0600, Ben Hutchings wrote: > "John Max Skaller" wrote: >> union U2 { int b; float a; U1() : a(1.0), b(1); } y; >> y.a; // 1.0f, well defined > The standard says in 12.6.2/3: > > "If a ctor-initializer specifies more than one mem-initializer for > the same member, for the same base class or for multiple members > of the same union (including members of anonymous unions), the > ctor-initializer is ill-formed." Ah, thanks. Pity you can put non-POD types in unions then, I need to do that.. is there a proposal for a template like store_of which has the alignment and size of T and which can be used in a union, for all value types T? If I had one of those, it might do as a poor man's replacement for unions of arbitrary types, the lack of which is a fairly serious defect. --- [ comp.std.c++ is moderated. To submit articles, try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]