Mitja <odtih...@gmail.com> wrote:
I would like to have a template which returns appropriate delegate, something like this:
So like this? module mod1; import std.algorithm; import std.functional; import std.stdio; void main( ) { auto haystack = ["a","b","c"]; auto needle = "b"; auto flt = (string s){return s == needle;}; auto dg = toDelegate( flt ); auto result = filter!dg(haystack); writeln(result); } I would have to argue that the delegate is hardly templated, though. Not sure what that means.
What would be the correct way for templated delegate?
Depending on what you mean by 'templated delegate', I would say std.functional's toDelegate, as used above. Perhaps if you explained what you mean by 'templated delegate', I could give a better answer. -- Simen