Arrays of functions, function signatures and template instantiation
anonymous
anonymous at example.com
Mon Apr 29 19:38:25 PDT 2013
On Monday, 29 April 2013 at 23:49:18 UTC, JR wrote:
[...]
> http://dpaste.dzfl.pl/9273fb92
>
> Can't it be done neater than this? It *does* work now, but it's
> incredibly hacky and I'm not satisfied with it. The whole
> 'passing a function pointer to a function that casts the
> signature and invokes it' deal makes me cringe. :>
To get rid of the cast:
13c13
< void applyFunc(F* func, E[I][T] matrix) {
---
> void applyFunc(F func, E[I][T] matrix) {
16c16
< func(major, minor, &element);
---
> func(major, minor, element);
29,30c29,30
< void run(T major, I minor, F* func) {
< (cast(void function(T,I))*func)(major, minor);
---
> void run(T major, I minor, F func) {
> func(major, minor);
52c52
< alias
MatrixWalker!(typeof(runner),typeof(funcyMatrix)).applyFunc apply;
---
> alias
> MatrixWalker!(typeof(&runner),typeof(funcyMatrix)).applyFunc
> apply;
More information about the Digitalmars-d-learn
mailing list