• Create Account

### #ActualÁlvaro

Posted 31 May 2013 - 12:19 PM

I am not sure I can explain the exact reason for that being disallowed, but I can tell you how to fix it:

myList.sort(sortDescending<int>);

Now I'll try to explain it anyway. The compiler tries to figure out the type of what you are passing to std::list<int>::sort, and it can't figure it out because you are passing something with an "unresolved overloaded function type" (that's what the error message in g++ calls it). If you specify sortDescending<int>, now the compiler knows the type being passed and can continue to figure out what version of the overloaded std::list<int>::sort you are calling.

EDIT: Double ninja'd. I must be getting slow.

### #1Álvaro

Posted 31 May 2013 - 12:18 PM

I am not sure I can explain the exact reason for that being disallowed, but I can tell you how to fix it:

myList.sort(sortDescending<int>);

Now I'll try to explain it anyway. The compiler tries to figure out the type of what you are passing to std::list<int>::sort, and it can't figure it out because you are passing something with an "unresolved overloaded function type" (that's what the error message in g++ calls it). If you specify sortDescending<int>, now the compiler knows the type being passed and can continue to figure out what version of the overloaded std::list<int>::sort you are calling.

PARTNERS