I'm writing a library which involves a good amount of both template trickery and boost::any. I've run into a situation where I essentially have this:
boost::any a1, a2, a3, a4;
... and I need to call a function which looks like this:
template <typename A1, typename A2, typename A3, typename A4>
void somefunc (A1 a1, A2 a2, A3 a3, A4 a4);
I could resort to an obscenely nested series of if statements, but assuming I'm handling 10 distinct types, that's 10,000 if statements! Boost preprocessor could help here, but this is still a horrible solution.
Is there a better way to call a templated function with the contents of a boost::any without resorting to this sort of madness? As far as I can tell, there is not.