D equivalent of C++ bind ?

Dsby via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 16 08:57:52 PDT 2016


On Monday, 16 May 2016 at 15:11:26 UTC, chmike wrote:
> On Thursday, 12 May 2016 at 10:38:37 UTC, Dsby wrote:
>
>> [...]
>
> Thank you. Would you agree to help me understand it ?
>
> The only thing I don't understand is why the function template 
> argument is defined as T and the argument as auto ref T fun. 
> Why the auto ref  and not alias T in the template argument list 
> ?
>
> This bind is better than Partial!() from std.functional since 
> it accepts any number of parameters. But the given parameters 
> are passed as first arguments of fun. The std::bind of C++ 
> allows to bind any parameter in any order and eventually 
> multiple times. It's really as if a new function was defined 
> with a total liberty degree on its signature.
>
> Anyway thank you very much.

you can remove "auto ref". and I remove the "auto ref" in my use.
if used the "alias T", It can not handle all while when the T is 
a delegate.

in C++ std::bind, the arguments order you can sort by used. in D 
I do not find how to enablement.



More information about the Digitalmars-d-learn mailing list