I have been cruising through SGI's STL website:

http://www.sgi.com/tech/stl/table_of_contents.html

I have a complex data structure X that only defines operator==(). I have a std::vector<X>, and I am trying to find the unique elements of this vector, using std::unique.

I can use std::unique on this data structure if data type X defines operator==(),but std::unique also requires that similar entires are grouped together. For an integral type, calling std::sort will do this for me, such as this bunch of code:

Code://MatRef is an std::vector<int> std::sort(MatRef.begin(), MatRef.end()); std::vector<X>::iterator RetVal; //This should be renamed to 'NewEnd' RetVal = std::unique(MatRef.begin(),MatRef.end());I am looking for a function contained in <algorithm> that will group identical entires of a complex data structure together

Here is what I am trying to achieve:

I could easily write my own implementation of this, but I have a hard time believing this isn't already implemented in the stl.Code:void NT_MODEL::BuildFromMS3DModel(CMS3D_MODEL & model) { std::vector<NT_VERTEX> all_model_vertexes; //not necessarily unique at this point std::vector<NT_VERTEX> unique_vertexes; ConvertMS3DVertsToNT_Verts(model,all_model_vertexes); //In order for unique to work, operator== must be overloaded, and the entries must be 'sorted' //which, in this case, means all of the same vertexes are grouped together //works on any data structure that defines operator == //std::sort(all_model_vertexes.begin(),all_model_vertexes.end());//doh, can't do this std::vector<NT_VERTEX>::iterator new_end = std::unique(all_model_vertexes.begin(),all_model_vertexes.end()); std::copy(all_model_vertexes.begin(),new_end,unique_vertexes.begin()); }