[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: casting an 'int' to a class
From:       Ellis Whitehead <kde () ellisw ! net>
Date:       2002-01-22 5:28:43
[Download RAW message or body]

> I don't think the obfuscation is worth the gains (if there are any).

Without:
	A a(b);
	a->transform( c );
        b = a->a;
With casting:
	((A*)&b)->transform( c );

Without casting requires wierd code or a non-OO API.  I wrote the non-OO API 
first, and decided that it was too convoluted.  Then I did the OO without 
casting, and decided it was too long and ugly.  Also, an inline function is 
used for the casting which pretties up the appearance, so the above code is 
just to show the principle.

On Monday 21 January 2002 23:44, Waldo Bastian wrote:
> On Monday 21 January 2002 07:30 pm, Ellis Whitehead wrote:
> > > 1) remove the &
> > > 2) I *think* some platforms (sparc64?) have sizeof(int) !=
> > > sizeof(void*)
> > >
> > > Of course, if sizeof(int) and sizeof(void*) were the same, and the
> > > variable is private, you should be able to just change the type.
> >
> > I don't really follow you...  What's this about a void*?  I'm not wanting
> > to point to anything, but rather use an 'int' as though it were a
> > particular class which contains a single 'int' member.
>
> I don't think the obfuscation is worth the gains (if there are any).
>
> Cheers,
> Waldo

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic