I\'ve just got confused how to implement something in a generic way in C++. It\'s a bit convoluted, so let me explain step by step.
Consider such code:
In order to solve this problem with templates, you have to use a template template parameter. Unfortunately, you cannot pass template template function as a type, because it has to be instantiated first. But there is a workaround with dummy structures. Here is an example:
template
struct a {
static void foo (T = T ())
{
}
};
template
struct b {
static void foo (T = T ())
{
}
};
struct SomeObj {};
struct SomeOtherObj {};
template class T>
void function ()
{
T::foo ();
T::foo ();
}
int main ()
{
function();
function();
}