www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - template expressions in C++ to an equivalent in D

reply Dominic Jones <dominic.jones qmul.ac.uk> writes:
Hello,

I want to compute, for example
d = a + b + c
where a..d are of some derived type, without incurring the cost of temporaries
for each overloaded operation.

In a similar post a while ago, Walter Bright proposed using function literals
instead of template expressions to do this. After looking at function literals,
I can't work out what he had in mind with this suggestion. May someone present
a succinct
complete example to demonstrate how solve this?

Many thanks,
Dominic Jones
Oct 28 2011
parent reply deadalnix <deadalnix gmail.com> writes:
Le 28/10/2011 19:18, Dominic Jones a écrit :
 Hello,

 I want to compute, for example
 d = a + b + c
 where a..d are of some derived type, without incurring the cost of temporaries
for each overloaded operation.

 In a similar post a while ago, Walter Bright proposed using function literals
instead of template expressions to do this. After looking at function literals,
I can't work out what he had in mind with this suggestion. May someone present
a succinct
 complete example to demonstrate how solve this?

 Many thanks,
 Dominic Jones
I was thinking about porting http://eigen.tuxfamily.org/index.php in D. I'm currently on SFML2 but it goes quite fast (thanks to Trass3r for porting SFML to D2 so a big part of the job is done). You may want to do so ? Anyway, I'm not surefunction literal can do the trick. I would be interested on knowing more on the topic. If it is more suitable, maybe I should reconside my project to port eigen. Deadalnix
Oct 28 2011
parent Trass3r <un known.com> writes:
 I was thinking about porting http://eigen.tuxfamily.org/index.php in D.
Don't we have a LinAlg library now thx to that GSoC project?
 I'm currently on SFML2 but it goes quite fast (thanks to  Trass3r for  
 porting SFML to D2 so a big part of the job is done).
You're welcome.
Oct 30 2011