Can't use map (and friends) for virtual functions?

bearophile bearophileHUGS at lycos.com
Tue Apr 26 04:24:28 PDT 2011


Andrej Mitrovic:

> import std.algorithm;
> 
> struct Foo
> {
>     int bar(string) { return 1; }
>     
>     void run()
>     {
>         auto result = map!(bar)(["test"]);
>     }
> }
> 
> void main()
> {   
> }
> 
> D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(128): Error: this for bar needs to be type Foo not type Map!(bar,string[])
> 
> I can't use a virtual function as an alias parameter to a template, it either has to be a free function or a static function.

Where's the virtual function?

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list