www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - delegate to shared member function

reply Benjamin Thaut <code benjamin-thaut.de> writes:
I'm currently trying to pass a delegate to a shared member function to a 
function. The compiler tells me that the type I'm passing is
(void delegate(const const(char[]) str) shared)

When I try to use this as type for the function argument, it does not 
accept it. I tried various combinations but couldn't find one that does 
work.

So what is the correct syntax for a delegate to a shared member function?
-- 
Kind Regards
Benjamin Thaut
Apr 24 2011
parent Robert Clipsham <robert octarineparrot.com> writes:
On 24/04/2011 09:17, Benjamin Thaut wrote:
 I'm currently trying to pass a delegate to a shared member function to a
 function. The compiler tells me that the type I'm passing is
 (void delegate(const const(char[]) str) shared)

 When I try to use this as type for the function argument, it does not
 accept it. I tried various combinations but couldn't find one that does
 work.

 So what is the correct syntax for a delegate to a shared member function?

The only way I've found to do this that works is using an alias - this is probably worth a bug report if there isn't one already. ---- class A { // Note that you get forward reference errors if you opt to // infer the return type here. That's also a bug. void method(const const(char[]) str) shared { } } alias typeof(&A.method) shdg; void foo(shdg foo) { } void main() { foo(&A.method); } ---- -- Robert http://octarineparrot.com/
Apr 24 2011