template<typename Iterator, typename typename Comparator = std::less<typename std::iterator_traits<Iterator>::value_type>>
static void sort(Iterator begin, Iterator end, Comparator cmp = Comparator())
{
...
}
I have the following template function:
template<typename func>
static void sort_test(func sort)
{
...
sort(somevector.begin(), somevector.end());
...
}
int main()
{
sort_test(&sort<vector<int, allocator<int>>::iterator>);
return 0;
}
error C2198: 'void (__cdecl *)(iterator,iterator,std::less)' : too few arguments for call
If I try to bypass the default argument by providing it:
template<typename func>
static void sort_test(func sort)
{
...
sort(somevector.begin(), somevector.end(), std::less<int>);
...
}
int main()
{
sort_test(&sort<vector<int, allocator<int>>::iterator>,
std::less<int>);
return 0;
}
error C2275: 'std::less' : illegal use of this type as an expression