sort() - No matching function for call to 'swap'

It turns out it's a very simple problem, but not very obvious to spot (and the error message doesn't do a very good job in helping out either):

Remove the const declaration on run() - voilá.


The compiler refers to swap because std::sort internally uses function swap. However as member function run is declared as constant function

void run() const;

then the object of the class itself is considered as a constant object and hence data member list also is a constant object

std::vector<std::string> list;

So the compiler tries to call swap with parameters that are constant references or even are not references and can not find such a function.