Templated delegate

Stanislav Blinov blinov at loniir.ru
Tue Jan 11 06:47:38 PST 2011


10.01.2011 21:08, Mitja пишет:
> Thanks, toDelegate is what I've been looking for.
>
> It still segfaults, though.
> The setup:
> =======
> module mod1;
>
> import std.algorithm;
> import std.functional;
> import std.stdio;
>
> void main( ) {
>     auto haystack = ["a","b","c"];
>     auto needle = "b";
>     auto flt = delegate(string s){return s == needle;};
>     auto dg = toDelegate( flt );
>     auto result = filter!dg(haystack);
>     writeln(result);
> }
> =========
> module mod2;
>
> import std.string;
> // or import std.conv;
> // or import std.random;
> ========
> dmd mod2.d mod1.d compiles, but compiled program segfaults.
> System is Debian GNU/Linux 5.0 on 2.6.26-2-686 #1 SMP i686.
> dmd is D 2.051.
>
Try it with previous compiler version. It looks like a bug I've reported 
not so long ago: in 2.051 functions with 'auto' result type and at least 
one parameter cause segfault during compilation when they are in a 
separate module. I can't remember issue number right now (and have no 
internet connection to find it), but it's pretty recent.


More information about the Digitalmars-d-learn mailing list