how to compose delegate type
Ellery Newcomer
ellery-newcomer at utulsa.edu
Fri Dec 6 17:18:05 PST 2013
On 12/05/2013 09:33 PM, Jesse Phillips wrote:
>
> I don't think I understand what you mean:
this code illustrates it:
class Z {
string a() immutable {
return " 1";
}
string b() {
return "2";
}
}
template F(t) {
alias immutable(t) F;
}
alias typeof(&Z.init.a) Texpected;
alias typeof(&Z.init.a) T;
static assert(is(F!(T) == Texpected));
void main() {}
above F doesn't work; immutable(void delegate()) and void delegate()
immutable are different types (I think the latter means 'this' is
immutable).
If t were a function pointer, you would apply the immutable to the
pointer target like so:
alias immutable(pointerTarget!t)* F
More information about the Digitalmars-d-learn
mailing list