I tried to write a quicksort boilerplate function. The thought in my head was that I would write a quicksort that can work with any data structure that has an index operator and an order relation to the objects contained in it, so I could do things like
quicksort<deque<int> >();
quicksort<vector<string> >();
and etc.
I started with a feature like
template<typename T>
void quicksort(T& list);
The problem that I immediately ran into came with a function that performs the swap operation, which is necessary for sorting. I need to know if the values that I am replacing are strings, characters, ints, regardless of what I can make temporary for the exchange!
- ( , , , ):
template<typename T, typename R>
void quicksort(T<R>& list);
, T, . , , T , , , .
? , . ?