This is probably rather obvious, but I wasn't able to locate this guarantee in MIC docs. Take,
struct Foo {
explicit Foo(Bar* b = nullptr) : bar(b) {}
Bar* bar;
};
int getBarValue (const Foo& f) {
assert( f.bar );
return f.bar->getValue();
}
boost::multi_index< Foo, indexed_by<
< hashed_unique < member<Foo, Bar* , &Foo::bar > >>
, hashed_non_unique < global_fun<const Foo&, int, &getBarValue >>
>> FooIndex;
void grill() {
FooIndex fooIndex;
Bar* b;
{
auto bWork = make_unique<Bar>();
// ...
fooIndex.emplace( bWork.get() );
b = bWork.get();
}
fooIndex.erase(b);
// ...
}
Please ignore the fact that raw-pointers are potentially dangerous etc. The question is does erase() call getBarValue() despite the fact I am using the first index? More generally, do key extractors get called *at all* except at the point of insertion?
Thanks,
Nick