Original Post
Okay, first the issue is I want to use a set with a custom comparator, which is normally fine.
Normally something like this would work fine:
However, what I''m looking to do is inside my comparison function I need to use data from a class to do the comparison. That proved to be more complicated that I thought. I ended up doing something like this:
This feels wrong to me, but I''m having a tough time coming up with a nice encapsulated way to do this. Any suggestions?
struct CompFunc
{
bool operator()(const int *p1,const int *p2)
{
// Do stuff with p1 and p2
}
};
std::set<int*,CompFunc> tada;
struct CompFunc
{
bool operator()(const int *p1,const int *p2)
{
// Do stuff with p1 and p2
}
static int dataNeeded;
};
int CompFunc::dataNeeded;
CompFunc::dataNeeded = value;
std::set<int*,CompFunc> tada;