David
David

Reputation: 103

What is the syntax for an argument of type pointer to generic function?

I have the following generic methods of sorting:

template< typename T > void SortMethod_1( T i, T j )
{
...
}

template< typename T > void SortMethod_2( T i, T j )
{
...
}

And I would like to implement another test method that receives a pointer to any of the above methods. For example,

void TestingSortMethod( argument_1, argument_2, void (* AnyGenericSortMethod)... )
{
...
}

How I do it?

How I call it?

Upvotes: 0

Views: 69

Answers (1)

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272497

It sounds like you want your test function to be a function template as well:

template <typename T>
void TestingSortMethod(
    T argument_1,
    T argument_2,
    void (* AnyGenericSortMethod)(T,T))
{
    ...
}

Upvotes: 6

Related Questions