Reputation: 803
Look at this code:
template<class T, class Compare>
void foo(const std::set<T, Compare> & bar)
{
// here I need the comparative function BUT with another type
// like this:
if (Compare<float>()(...))
}
Something like this, but it doesn't work:
template<class T, class Compare>
void foo(const std::set<T, Compare<T>> & bar)
...
Is it possible?
Upvotes: 0
Views: 56
Reputation: 110778
You want a template template parameter:
template<class T, template<class> class Compare>
Now the Compare
template parameter is a template itself.
Upvotes: 4