This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: I'm sorry, but this is unacceptable (union members and ctors)
- From: "michael.a" <wild dot eyed dot boy dot from dot freecloud at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Sun, 17 Jun 2007 10:31:35 -0700 (PDT)
- Subject: Re: I'm sorry, but this is unacceptable (union members and ctors)
- References: <11149318.post@talk.nabble.com>
Just for the record, this construction was proposed to me from behind the
scenes:
> class Rect
> {
> Rect()
> {
> new (&xlat) Vec2<T>(); // Explicit calls to the ctor
> new (&size) Vec2<T>();
> }
> ~Rect()
> {
> xlat.~Vec2<T>();
> size.~Vec2<T>();
> }
> public:
> union
> {
> struct{ Vec2_<T> xlat, size; };
> struct{ T_ x,y,w,h; };
> };
> };
>
I think this would likely do the job in many cases with only a little extra
trickery, though I wouldn't be at all surprised if somewhere along the way
the compiler/specs might throw a wrench into the works.
Nevertheless, it is an interesting expiriment I think, which might contain
further advantages. However, I feel strongly that either avenue of approach
should be open, so that a course of action may be freely chosen.
I also can't help but consider this a fair ways to go simply to work around
what is I feel a temporary specifications anomale sure to be eventually
sorted out of the future of c++ .
sincerely,
michael
PS: I really don't think is precisely what the proponents of "placement new"
have in mind, but feel free to rally around this proposal if you must
-michael
--
View this message in context: http://www.nabble.com/I%27m-sorry%2C-but-this-is-unacceptable-%28union-members-and-ctors%29-tf3930964.html#a11165235
Sent from the gcc - Dev mailing list archive at Nabble.com.