标签: function delegates d
我有一个接受委托的属性:http.onReceiveHeader = (in char\[\] key, in char\[\] value) { }。我想使用一个separed函数而不是,例如:
http.onReceiveHeader = (in char\[\] key, in char\[\] value) { }
void do_something(char[] key, char[] value) { } http.onReceiveHeader = do_something;
可以在D?
答案 0 :(得分:3)
toDelegate中有std.functional个功能。
toDelegate
std.functional
所以这应该有效:
http.onReceiveHeader = toDelegate(do_something);