Re: Set with Sort routine
- From: "Bruce Chastain" <bchastain@xxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 27 Jun 2006 15:26:36 -0500
"Pete Becker" <petebecker@xxxxxxx> wrote in message
news:GImdnZlHlqJw3zzZnZ2dnUVZ_q6dnZ2d@xxxxxxxxxxxxxxx
The second template argument to set has to be the name of a type. It names
type of the comparison object that the set is supposed to use.
To use your own comparison object, you have to pass its type to the
template, and construct the set object with a comparison object.
So, start out by defining a type:
typedef bool (*comp)(const MyElem&, const MyElem&);
Then define the corresponding function, My Compare, which you've already
done. Then create a set object that takes your type, and construct it with
your function:
set<MyElem, comp> database(MyCompare);
Very good. That seems to be working well. Thanks!
Bruce.
.
- References:
- Set with Sort routine
- From: Bruce Chastain
- Re: Set with Sort routine
- From: Pete Becker
- Set with Sort routine
- Prev by Date: Re: Set with Sort routine
- Next by Date: Re: Set with Sort routine
- Previous by thread: Re: Set with Sort routine
- Next by thread: Re: Set with Sort routine
- Index(es):