I need to call a function passed as argument to another function and it must be passed its needed arguments firstly. In c++, this problem is solved with a macro:
#include <iostream>
#define CALL(x) x; \
std::cout << "Called!" << std::endl;
void foo(int a, int b)
{
std::cout << a * b << std::endl;
}
int main()
{
CALL(foo(9, 8)); // I want to pass 2 int parameters inside 'foo' function call
system("PAUSE");
}
It sould output:
> 72
> Called!
That is exactly how I need to call the function in D. Any ideas?
Edit: I need this to be done in D. I want to call "foo" inside CALL like:
CALL(foo(9, 8)) // and not like: CALL(foo, 9, 8)
But I don't know how this is achieved in D. Perhaps with a mixin?