This post has two questions:
1. What are the semantics of 'alias' template parameters when initialised using
runtime functions,
e.g.:
class Foo
{
int[] data;
int foo(int i) { return data[i]; }
auto allFoo()
{
auto fun = (int i) { return foo(i); };
// alternatively: auto fun = &this.foo; (same result)
return map!(fun)(iota(data.length));
}
}
This compiles, but gives you an access violation when you try to use it. Alias
is a compile time
construct (if I am not mistaken), so why does the compiler allow this?
2. How can I achieve what allFoo() above is trying to do? Obviously I could
just return data in this
trivial case, but imagine that foo(int) did something more complex, and I
didn't want to repeat the
logic of foo(int) in allFoo().
Thanks.