There it is:
struct ltEdgeDescriptor : public std::binary_function<DataEdge,DataEdge,bool>
{
bool operator() (const DataEdge& s1, const DataEdge& s2) const
{
return s1.m_source<s2.m_source || (!(s1.m_source<s2.m_source) && s1.m_target<s2.m_target);
}
};
I copied this pattern from stl_pair.h, so I thought I was safe.
Can someone point out the problem here and hopefully sugguest an alternate implementation?
Jeffrey Holle wrote:
I'm using gcc v3.4.2.
For the first time, I'm attempting to use std::distance and std::advance and am having trouble with at least std::distance.
Basically, I'm trying to deal with duplicates.
In the following code, I want to iterate thru just the non-duplicates.
In my test case, edges has a size of 47 and there are two sets of 4 duplicates each. So I want the for loop to execute 41 times.
typedef std::multiset<DataEdge,ltEdgeDescritor> Edges; Edges edges;
<populate edges>
for(Edges::iterator iter=edges.begin();
iter!=edges.end(); advance(iter,distance(edges.lower_bound(*iter),edges.upper_bound(*iter)))
{
.....
}
What I find is that my program enters distance and doesn't leave.
Am I somehow misusing distance?
Can someone sugguest an alternate method for me to accomplish what I'm trying to do?