Assertion `invariant_()' failed. in boost multi index

Hi Everybody, Boost multi index is a very nice library. But I have a situation where the invariant_() assertion fails. One of the indices is ordered based on a score which is computed with a function. The score of the same element can change when computed at different times. but however, the scores change, score decay over time, such that the previously computed order will always be right. While I don't know if this is the issue, I wanted to make sure that this kind of scoring functions does not cause a problem because of some caching that boost may be doing internally .. and also, the return value of the scoring function is a double which I can imagine can introduce some comparison issues. I am digging into the code to make sure that that is not the problem .. any pointers from the community is greatly appreciated. Thanks, Sunil.

Sunil S Nandihalli
Hi Everybody, Boost multi index is a very nice library. But I have a situation where the invariant_() assertion fails. One of the indices is ordered based on a score which is computed with a function. The score of the same element can change when computed at different times. but however, the scores change, score decay over time, such that the previously computed order will always be right. While I don't know if this is the issue, I wanted to make sure that this kind of scoring functions does not cause a problem because of some caching that boost may be doing internally .. and also, the return value of the scoring function is a double which I can imagine can introduce some comparison issues. I am digging into the code to make sure that that is not the problem .. any pointers from the community is greatly appreciated.
Hi Sunil,
The invariant_() code does not cache keys, but that's not the point really:
the very fact that the score changes over time can lead to inconsistencies
even if no caching is done because of some implicit caching happening
at the comparison point. Suppose your element looks like:
struct element
{
double score()const; // decreases over time
};
and you have elements x and y such that x
participants (2)
-
Joaquin M Lopez Munoz
-
Sunil S Nandihalli