BUG: The STL list::sort() Function Doesn't Sort a List of Pointers (265109)
The information in this article applies to:
- Microsoft C/C++ Compiler (CL.EXE)
This article was previously published under Q265109 SYMPTOMS
The Standard Template Library (STL) list::sort function doesn't sort a list of pointers when a predicate function is defined for sorting.
CAUSE
The Microsoft Developer Network (MSDN) documentation for the list::sort function states that, if a translator doesn't support member function templates, the following template
template <class Pred>;
void sort(Pred pr);
is replaced by:
void sort(greater<T> pr);
You can specify the predicate function for sorting, but it will always call the greater function.
RESOLUTION
Override struct greater<T> and specify your comparison function for sorting. See the workaround in the "More Information" section for details.
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Minor | Last Reviewed: | 7/5/2005 |
---|
Keywords: | kbBug kbfix kbSTL kbtemplate KB265109 |
---|
|