Virtual value types during compile-time for static type safety, static optimizations and function overloading.
Tamas via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jul 18 07:54:26 PDT 2015
On Saturday, 18 July 2015 at 13:16:26 UTC, Adam D. Ruppe wrote:
> On Saturday, 18 July 2015 at 10:06:07 UTC, Tamas wrote:
>> Compile & execute:
>> $ dmd positive0.d; ./positive0; echo $?
>> $ ldc2 positive0.d; ./positive0; echo $?
>
> Try adding the automatic optimize flags in all your cases. For
> dmd, `-O -inline`. Not sure about ldc but I think it is `-O` as
> well.
Thanks, indeed, after -O -inline the bodies of the two abs
functions are the same! :)
The asm code of the templated version is still longer overall,
but I think it's only some garbage that is not really executed.
(e.g some with assert and unittest in the name, although I have
none such)
Soo thank you, it's really awesome! :)
More information about the Digitalmars-d-learn
mailing list