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

Steven Schveighoffer schveiguy at yahoo.com
Tue Apr 26 05:05:41 PDT 2011


On Tue, 26 Apr 2011 07:24:28 -0400, bearophile <bearophileHUGS at lycos.com>  
wrote:

> 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?

I think he means member function.  Clearly the function is not virtual.

-Steve


More information about the Digitalmars-d-learn mailing list