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 enablemen
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.
On Thursday, 12 May 2016 at 10:38:37 UTC, Dsby wrote:
I write one, bind functon to a delegate.
In here:
https://github.com/putao-dev/collie/blob/master/source/collie/utils/functional.d
this is the code:
auto bind(T,Args...)(auto ref T fun,Args args) if
(isCallable!(T))
{
alias FUNTYPE
On Tuesday, 10 May 2016 at 15:33:03 UTC, chmike wrote:
Thanks. This does the job but it's not as concise.
The std.functional.partial can not use in runtime, only on
complier time.
and it can not bind args that more than one.
On Tuesday, 10 May 2016 at 09:39:53 UTC, chmike wrote:
Is there an equivalent in D of the C++11 std.bind template
class
[http://en.cppreference.com/w/cpp/utility/functional/bind] ?
Here is a blog post showing different examples of its use
https://oopscenities.net/2012/02/24/c11-stdfunction-and
On Tuesday, 10 May 2016 at 09:39:53 UTC, chmike wrote:
Is there an equivalent in D of the C++11 std.bind template class
See http://dlang.org/phobos/std_functional.html#partial
Salut Christophe,
Did you have a look at
https://dlang.org/phobos/std_functional.html#partial ?
On Tuesday, 10 May 2016 at 15:33:03 UTC, chmike wrote:
Thanks. This does the job but it's not as concise.
I've never missed C++'s bind functionality because D has first
class support for delegates.
If async_task is changed to the following:
void async_task(void delegate(int error) cb) { . .
Thanks. This does the job but it's not as concise.
I know this really isn't what you want, but it may help you:
void doFunc(int a, int b, string text) {
import std.stdio : writeln;
writeln(text, ": ", a, " <> ", b);
}
void receiver(void delegate(string text) del) {
del("Hey");
}
void main() {
struct Binder
Is there an equivalent in D of the C++11 std.bind template class
[http://en.cppreference.com/w/cpp/utility/functional/bind] ?
Here is a blog post showing different examples of its use
https://oopscenities.net/2012/02/24/c11-stdfunction-and-stdbind/
A possible use case is for a callback functio
11 matches
Mail list logo