|
Boost Users : |
Subject: [Boost-users] [multi_index] do erase() call key extractors?
From: Nick Stokes (randomaccessiterator_at_[hidden])
Date: 2015-12-22 19:01:38
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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net