On Thu, Mar 3, 2016 at 10:21 AM, Joaquin M LópezMuñoz
Dominique Devienne
writes: I would like to support a slightly unusual use-case. [...]
Steven's answer is, as always, correct, and we can leave it at that. But, if you want to venture into uncharted lands...
it always is indeed. But also terse as well, also as usual :) I appreciate the hand-holding here Joaquin, I can definitely use it!
Suppose we use the following:
template
struct punctured_less { bool operator()(const T& x,const T& y)const { if(x==puncture&&y==puncture)return true;
But can we do better? If like in any initial email, you take into account that the to-be-indexed int is part of a larger struct with other fields, which can be used to "break ties" between elements who's index match the "puncture"? This is why I asked about the comparator accessing the whole element struct.
return x
using set=boost::multi_index_container< int, indexed_by< ordered_unique
> > ;
Stated differently, this is closer to our actual use-case:
struct entry {
int uid; // real uuid in reality, but enough for our needs here
int occurence; // the field to be indexed, uniquely "except for -1"
};
struct by_occurence{};
using bmi = boost::multi_index_container<
entry,
indexed_by<
random_access<>,
ordered_unique<
tag
;
except right now, we have,
ordered_non_unique<
tag
First thing to notice is: punctured_less
is *not* a strict weak ordering.
Yes. And that's why I'm asking whether "other" fields can "make it better" somehow. I "think" lookups would be resolved then, but I'm unsure that's "sound". --DD