Greetings,
in an interpreter-like environment, I have a function lookup table. To handle different signatures in one table, the function pointers are wrapped, and the wrappers share a common ancestor class. Parameters are wrapped too, and (un-)wrapped by the function pointer wrapper via "get" and "create" functions, allowing "normal" C++ functions to be put into the lookup table without any internal overhead (the overhead for calls via the lookup table is irrelevant; receiving a string via TCP and parsing it is much more time consuming than (un)wrapping and dereferencing some pointers...). The call looks like this:
|
result = variable_traits<R>::create(((t->*pfun)(variable_traits<T0>::get(param[0]),variable_traits<T1>::get(param[1]))));
|
Of course for this construct to work, I need the same wrapper class once for
- each number of arguments
- static/free and member functions
- for members also all 4 possible cv qualifications
...altogether 5 classes for each number of arguments. Currently, we support 0 to 6 arguments, making 35 classes, all doing the same job (any template meta-programming magic eliminating some of the cases would be greatly appreciated...).
But that's not all - we actually need twice that ammount: if
t->*pfun
returns void, then
variable_traits<R>::create()
would have to accept, as an argument, void, however
gives an
error: invalid use of void expression |
Any suggestions on how to write a
variable_traits<void>::create()
-function, allowing this sort of call?