delegate to shared member function
Robert Clipsham
robert at octarineparrot.com
Sun Apr 24 06:38:35 PDT 2011
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/
More information about the Digitalmars-d-learn
mailing list