scaling of templates with alias argument

Frank Benoit keinfarbton at googlemail.com
Mon May 14 16:05:33 PDT 2007


Stephen Waits schrieb:
> Frank Benoit wrote:
>>
>> Ok, 'should' is said twice :)
> 
> Intentionally so, because I don't know if Walter's compiler and linker
> behave this way.
> 
> Note that the compiler needn't do anything here - this may be completely
> handled by the linker.  In fact that's probably the smarter way to do it
> (DRY, etc.).
> 
> Can you look at a map file?  Your answer lies therein.
> 
> --Steve

doing a objdump yields 4 functions with 4 different addresses.

An other approach can be this:

regMemberImpl( T )( inout T t, uint offset, char[] name ){
}
char[] rm( char[] name ){
    return "regMemberImpl( "~name~", "~name~".offsetof, \""~name~"\" );";
}

class MyClass{
    bool data1;
    void func(){
        mixin( rm( "data1" ));
    }
}

This avoids the template alias argument and is the first time, i see an
advantage in using this text mixin :)







More information about the Digitalmars-d mailing list