D equivalent of C++ bind ?
chmike via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon May 16 23:51:18 PDT 2016
On Monday, 16 May 2016 at 15:57:52 UTC, Dsby wrote:
>
> 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.
Yes this doesn't look easy. Maybe by using a mixin. Unfortunately
this slows down compilation. I don't know the impact on
optimization.
I'm not sure if converting a function to a delegate is a good
thing. It is good for your use case where the bind functions are
used as callbacks. But sometime, users may really want to create
a function. The user should then use ToDelegate! If he wants to
convert the function to a delegate. But from the the
documentation, ToDelegate doesn't work with functions with the
@safe attribute.
More information about the Digitalmars-d-learn
mailing list