Should this work?
bobef
aasd.aasdasd.asd.ad.ad.as.d.a at asdasdas.das.da.d.ad.sa.d
Sat Jan 30 05:47:12 PST 2010
Jacob Carlborg Wrote:
> On 1/30/10 14:06, bobef wrote:
> > I get these errors DMD 1.055:
> >
> > (void(char[] _param_0))()
> > bug.d(2): Error: expected 1 function arguments, not 0
> > (void(char[] _param_0))()
> > bug.d(15): Error: template instance bug.Foo!(a) error instantiating
> >
> > //code----------------------------------------------------------------------------------------------
> >
> > void Foo(alias X)() {
> > pragma(msg,typeof(X).stringof);
> > }
> >
> > class A {
> > void a(char[]) {
> > }
> >
> > void b() {
> > }
> > }
> >
> > void main() {
> >
> > Foo!(A.a)(); //doesnt work
> > Foo!(A.b)(); //works
> >
> > }
> >
> > //end of code ----------------------------------------------------------------------
>
> Since "a" is a method and when you do "typeof(X)" it tries to call the
> method but since it takes one parameter it fails. "b" doesn't fail
> because it doesn't take any parameters. This is all because of the
> optional parentheses in function calls. Change to: "typeof(&X)".
This is not true. You can't call neither A.a nor A.b because A is a class, not an instance of a class - there is no this. Maybe I should file a bug.
More information about the Digitalmars-d-learn
mailing list