inout delegate
Manu via Digitalmars-d
digitalmars-d at puremagic.com
Sun Oct 2 02:55:26 PDT 2016
Can someone explain this to me?
class Test
{
inout(int) f() inout { return 10; }
void t()
{
f(); // calls fine with mutable 'this'
auto d = &this.f; // error : inout method Test.f is not callable
using a mutable this
d();
}
}
That error message seems very unhelpful, and it's not true. Of course
an inout method is callable with a mutable 'this'...
I suspect that the problem is the type for the delegate; "inout(int)
delegate()" doesn't leave anything for the type system to resolve the
inout with.
I guess the expectation is that this delegate has it's inout-ness
resolved when you capture the delegate:
is(typeof(&this.f) == int delegate())
Or if 'this' were const:
is(typeof(&this.f) == const(int) delegate())
But I get this unhelpful error instead.
What's the story here?
More information about the Digitalmars-d
mailing list