Templates and delegates trouble
    Lars Kyllingstad 
    public at kyllingen.NOSPAMnet
       
    Wed Oct  8 11:17:35 PDT 2008
    
    
  
Steven Schveighoffer wrote:
> "Lars Kyllingstad" wrote
>> Hello,
>>
>> I want to make a function (named 'call' in the example below) that calls 
>> another function (F). I want to allow F to be an ordinary function, a 
>> delegate, or a functor. I've been able to make it work with functions and 
>> functors, but not with delegates. Any tips would be greatly appreciated.
> 
> You can't alias a delegate like that.
> 
> Try this:
> 
> auto sqrt = new Sqrt;
> auto fn = &sqrt.eval;
> call!(fn)(4.0);
This works. Thank you!
> What is happening is you are aliasing the eval function symbol, but not the 
> sqrt instance to call it from.  Aliasing isn't exactly like a macro 
> substitution.
> 
> This might also work (haven't tested it):
> 
> call!(&sqrt.eval)(4.0);
This doesn't work.
    
    
More information about the Digitalmars-d-learn
mailing list