std::sort ERROR! HELP!

Started by
2 comments, last by riruilo 16 years, 11 months ago
Hi friends. I need your help, please. I would like to sort a std::vector<Myclass*> m_whatever; My classes has a KEY method, which is a float. Reading over here I did this: bool CCLScene::MyDataSortPredicate(CCLPolygonsInstance* a, CCLPolygonsInstance* b) { return (a->GetZ() < b->GetZ()); } and in the same file I have this. std::sort(m_transparent_polygons_instance_list.begin(), m_transparent_polygons_instance_list.end(),MyDataSortPredicate); But when I compile I get this: 1>Compiling... 1>CLScene.cpp 1>c:\project\colladaloader2\clscene.cpp(163) : error C3867: 'CCLScene::MyDataSortPredicate': function call missing argument list; use '&CCLScene::MyDataSortPredicate' to create a pointer to member 1>c:\project\colladaloader2\clscene.cpp(163) : error C2780: 'void std::sort(_RanIt,_RanIt)' : expects 2 arguments - 3 provided 1> c:\program files\microsoft visual studio 8\vc\include\algorithm(3109) : see declaration of 'std::sort' 1>Build log was saved at "file://c:\project\ColladaLoader2\Debug\BuildLog.htm" Do you have any idea where the problem is ? Thanks a lot.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
Advertisement
Make MyDataSortPredicate a static method,
and then do:

std::sort(m_transparent_polygons_instance_list.begin(), m_transparent_polygons_instance_list.end(),&CCLScene::MyDataSortPredicate);
Thanks a lot incin.

It works perfectly.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
Thanks a lot incin.

It works perfectly.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.

This topic is closed to new replies.

Advertisement