sort order of boost::weak_ptr after expiring?

For boost::weak_ptr the operator< is defined, so that it can be used in associative containers.

My question is: Is the sort order of several weak_ptr objects stable even when some of them change to a refcount of zero? Doesn't that mess with containers like std::set?

Example:

using namespace boost;
shared_ptr<A> sptrA1(new A);
weak_ptr<A> wptrA1 = sptrA1;
weak_ptr<A> wptrA2;

{ // begin Scope 1
    shared_ptr<A> sptrA2(new A);
    wptrA2 = sptrA2;
    assert(wptrA1 < wptrA2); // assert #1
}
assert(wptrA1 < wptrA2); // assert #2
  • Will assert #2 always hold true if assert #1 is true?
  • Is wptrA2 in the same state before and after the Scope 1?
5
задан Hanno S. 21 January 2011 в 17:59
поделиться