typedef: what's it good for?

BCS none at anon.com
Wed Nov 11 12:26:41 PST 2009


Hello Simen,

> BCS <none at anon.com> wrote:
> 
>> One important aspect of what I proposed is that operators that aren't
>> overridden still exist and use the same codegen as the base type (or
>> are  guarantied to generate the same machine code in all cases).
>> 
> struct foo {
> float f;
> alias f this;
> }
> void main( ) {
> foo f;
> f = 3;
> f *= 4;
> f /= 8;
> f += 4/5;
> f -= sqrt( f );
> }
> This compiles and runs beautifully, so it seems alias this does what
> you want.
> 

Hmm, I missed that bit. OTOH it still dosn't cover the "use the base ops 
but redefine the types" asspect. I so want that so that I can redo my Unit 
checking type with guarantied zero runtime overhead.





More information about the Digitalmars-d mailing list