Click here to Skip to main content
15,914,767 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: custom allocator for one container instance Pin
Joaquín M López Muñoz22-Nov-04 23:03
Joaquín M López Muñoz22-Nov-04 23:03 
Generalcustom allocator for one container instance Pin
peterchen22-Nov-04 8:19
peterchen22-Nov-04 8:19 
Generallist::sort() question Pin
nm_11421-Nov-04 16:51
nm_11421-Nov-04 16:51 
GeneralRe: list::sort() question Pin
Ryan Binns21-Nov-04 18:06
Ryan Binns21-Nov-04 18:06 
GeneralRe: list::sort() question Pin
nm_11421-Nov-04 18:58
nm_11421-Nov-04 18:58 
GeneralRe: list::sort() question Pin
peterchen22-Nov-04 8:23
peterchen22-Nov-04 8:23 
GeneralRe: list::sort() question Pin
nm_11422-Nov-04 19:29
nm_11422-Nov-04 19:29 
GeneralRe: list::sort() question Pin
peterchen22-Nov-04 23:15
peterchen22-Nov-04 23:15 
OK, now I see the problem Smile | :)

First, you have to define a "greater", not a "less than" functor. (that's an awkwardness of the STL I never understood, sometimes a "less", sometimes a "greater")

I assume you are working with the STL implementaiton coming with VC6. This one has a severe limitation, it does not suport member templates.

The "totally standard" solution would be to switch to a "good" STL implementation, and use the following template:
struct greaterThan_CSort
{
bool operator()(const CSort &pfi1, const CSort &pfi2) const
{
return pfi1.m_i > pfi2.m_i; // note the "greater"!!
}



For VC6, there is a workaround. the list::sort documentation states:

if a translator does not support member template functions, the template:

template<class Pred> void sort(Pred pr);
is replaced by:
void sort(greater<T> pr);


i.e. you cannot provide an arbitrary predicate functor, but you can work with a specialization of the greater template:

namespace std // this is not nice, but the only way it works
{
template<>
struct greater<CSort> : public binary_function<CSort, CSort, bool> {
    bool operator()(const CSort& x, const CSort& y) const
    { ... }
    };  
}






we are here to help each other get through this thing, whatever it is Vonnegut jr.
boost your code || Fold With Us! || sighist | doxygen

GeneralRe: list::sort() question Pin
nm_11423-Nov-04 13:38
nm_11423-Nov-04 13:38 
GeneralRe: list::sort() question Pin
peterchen23-Nov-04 13:49
peterchen23-Nov-04 13:49 
GeneralRe: list::sort() question Pin
nm_11423-Nov-04 14:08
nm_11423-Nov-04 14:08 
GeneralRe: list::sort() question Pin
toxcct23-Nov-04 8:12
toxcct23-Nov-04 8:12 
GeneralRe: list::sort() question Pin
peterchen23-Nov-04 13:58
peterchen23-Nov-04 13:58 
GeneralRe: list::sort() question Pin
toxcct23-Nov-04 21:37
toxcct23-Nov-04 21:37 
GeneralRe: list::sort() question Pin
peterchen23-Nov-04 22:28
peterchen23-Nov-04 22:28 
GeneralRe: list::sort() question Pin
Nemanja Trifunovic24-Nov-04 2:21
Nemanja Trifunovic24-Nov-04 2:21 
GeneralATL7 and VS.NET2k3 wizard, completely stuck Pin
seriema19-Nov-04 10:59
seriema19-Nov-04 10:59 
GeneralRe: ATL7 and VS.NET2k3 wizard, completely stuck Pin
Michael Dunn19-Nov-04 13:25
sitebuilderMichael Dunn19-Nov-04 13:25 
GeneralRe: ATL7 and VS.NET2k3 wizard, completely stuck Pin
seriema19-Nov-04 13:33
seriema19-Nov-04 13:33 
GeneralPrevent IHTMLDocument2 from updating IE screen Pin
Wim Jans19-Nov-04 9:33
Wim Jans19-Nov-04 9:33 
Questionhow to use char* in ATL Pin
yingkou18-Nov-04 23:26
yingkou18-Nov-04 23:26 
AnswerRe: how to use char* in ATL Pin
geo_m18-Nov-04 23:39
geo_m18-Nov-04 23:39 
GeneralRe: how to use char* in ATL Pin
yingkou19-Nov-04 1:56
yingkou19-Nov-04 1:56 
GeneralRe: how to use char* in ATL Pin
geo_m19-Nov-04 2:52
geo_m19-Nov-04 2:52 
GeneralMemory leaks with BSTR Pin
prasad_som18-Nov-04 22:03
prasad_som18-Nov-04 22:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.