-
Sorting vector<MyClass>
Hi,
I am having a problem sorting a vector<MyClass>
Code:
vector<Faces3D> tmp;
//
std::sort(tmp.begin(),tmp.end(),ZSort);
Faces3D is a simple class that only hold 3 indexes to vertices, and the Set/Get methods. my compare function is like that...
Code:
bool ZSort(const Faces3D& left, const Faces3D& right)
{
//
if(/**/)return false;
return true;
}
but, altought it look like all the samples i saw in books and in the board, i get this error
Code:
d:\Arquivos de programas\Microsoft Visual Studio .NET 2003\Vc7\include\algorithm(1862): error C2064: el término no se evalúa como una función con 2 argumentos
d:\Arquivos de programas\Microsoft Visual Studio .NET 2003\Vc7\include\algorithm(1863): error C2064: el término no se evalúa como una función con 2 argumentos
d:\Arquivos de programas\Microsoft Visual Studio .NET 2003\Vc7\include\algorithm(1863): fatal error C1903: no se puede recuperar de errores anteriores; se detiene la compilación
the error c2064 translate to somewhat like "the term is not evaluated as a function with 2 args" in english
the error is inside <algorithm>, in _Unguarded_partition template
i am using msvc 2003 .net, spanish version
thanks for any help,
jmgk
-
That code looks fine. The error is probably elsewhere, like maybe you didn't declare the ZSort function before you used it with the sort. Could you take the important code and post a small but complete example that we can compile and get that error?
-
Daved,
thanks for the help.
Your post opened my eyes to search for the bug elsewhere.
ZSort() was a member function... it was MyClass2::ZSort(), and coz this couldnt be found by the code in <algorithm>, thus the error
i just made it static, and now all work fine
thanks again,
jmgk