If I have a std::shared_ptr<Foo>
with a custom deleter, is it guaranteed that all associated weak pointers are seen as expired by the deleter? (I would appreciate it very much if you could cite relevant sections in the standard.)
In other words is the assertion below guaranteed not to fire?
std::weak_ptr<Foo> weak;
std::shared_ptr<Foo> strong{
new Foo,
[&weak] (Foo* f) {
assert(weak.expired());
delete f;
},
};
weak = strong;
strong.reset();
There is apparently nothing in the C++14 standard that guarantees this. I've now opened a defect report for the standard covering the problem.