I\'m re-learning C++, and have started by trying what should be a simple algorithm: QuickSort. My function has this signature:
template
void
The compiler has no way to deduce T
from your function call. Think about what happens when std::vector
is T*
:
int *b = ...;
int *e = ...;
QSort(b, e);
In general, if you write typename Something
, then the TemplateParemter
cannot be deduced in the call. It must be explicitly provided
QSort(b, e);
I recommend to just use T
as the parameter type. That will allow you to not only accept vector iterators, but also T*
, or std::deque
and any other random access iterators.