why do I get the error cannot deduce template argument for Comparable? I don't see where i went wrong (duh). Comparator comp is a functor used to compare two items while sorting.
Code:
template <class Iter, class Comparable, class Comparator>
void insertionSort( Iter begin, Iter end, Comparator comp)
{
for(Iter p = begin+1; p != end; p++ )
{
Comparable tmp = *p;
Iter j;
for( j = p; j != begin && comp(tmp, *(j-1)); --j )
*j = *(j - 1);
*j = tmp;
}
}
// My main call looks like this. assume that everything prior is done right
// including declarations of variables. LessThanByIDnum() is the functor that im trying
// to use
insertionSort(people.begin(), people.end(), LessThanByIDnum() );
What am I doing wrong?
edit:
Well now i see that the compiler will not recognize what type Comparable should be. What is a reasonable way to solve this problem?
Thanks in advance
btw, im trying to work with maps.