Code doesn't compile
Mohammad Sadegh Khoeini
mskco.tp at gmail.com
Fri Jul 5 04:24:12 PDT 2013
Hi D community,
I was just playing with some code and encountered a problem:
```
struct Foo(alias T)
{
void call() { T(); }
}
struct Bar
{
void fun() {}
}
struct Baz(T)
{
void fun(U)() {}
}
void main()
{
auto b = Bar();
auto f = Foo!(delegate{b.fun();})(); // this works
f.call();
auto foobaz = &b.fun;
auto t = Foo!(foobaz)(); // this works
// auto u = Foo!(&b.fun)(); // doesn't work: vaiable b cannot be
read at compile time
// auto v = Foo!(Baz!int.fun!int)(); //doesn't work: this for fun
needs to be type Baz not type Foo!(fun)
}
```
I wonder if this is a bug or I'm doing it wrong!
I'm using "DMD64 D Compiler v2.063" on Mac OS X 10.8
More information about the Digitalmars-d
mailing list