I have to write a template that would swap two arguments, if second one is smaller than first. But in case of string beeing passed to function it would swap them, if second is smaller than first by length. Is it possible to implement that using just one template?
Here is what I have written so far.
template <typename T>
void SWAP(T &A, T &B)
{
T temp;
if ( B < A )
{
temp = A;
A = B;
B = temp;
}
}