June 05, 2006 can't get function pointer to static member | ||||
|---|---|---|---|---|
| ||||
All lines of the following program are valid (I think). DMD however claims that the last line of foo is invalid (it assumes that &func is a delegate).
This fails with both structs and classes
<code>
import std.stdio;
//class Ag
struct Ag
{
static void func(){}
static void foo()
{
void function() fnp;
Ag a;
// valid works
fnp = &func;
fnp = &Ag.func;
with(a) fnp = &Ag.func;
// valid don't work
with(a) fnp = &func;
}
}
void main(){}
</code>
| ||||
June 29, 2006 Re: can't get function pointer to static member | ||||
|---|---|---|---|---|
| ||||
Posted in reply to BCS Attachments: | BCS schrieb am 2006-06-05: > All lines of the following program are valid (I think). DMD however claims that the last line of foo is invalid (it assumes that &func is a delegate). > > This fails with both structs and classes > ><code> > import std.stdio; > > //class Ag > struct Ag > { > static void func(){} > > static void foo() > { > void function() fnp; > Ag a; > // valid works > fnp = &func; > fnp = &Ag.func; > with(a) fnp = &Ag.func; > > // valid don't work > with(a) fnp = &func; > } > } > void main(){} ></code> Added to DStress as http://dstress.kuehne.cn/run/f/function_07_A.d http://dstress.kuehne.cn/run/f/function_07_B.d Thomas | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply