
Why is the shared counter used to compare shared_ptr objects, and not the container pointer? Until revision 1.24, the container pointer was used to compare shared_ptr objects, see http://cvs.sourceforge.net/viewcvs.py/boost/boost/boost/shared_ptr.hpp?r1=1.23&r2=1.24 . This introduced a change in shared_ptr behaviour and introduced a case where (p1 < p2 && p1 == p2) is true where p1 and p2 are two shared pointers, see the included example. Was this change in behaviour intentional, and is this behaviour documented anywhere? Example: struct A {}; struct deleter1 { template<class T> void operator()(T*) const {} }; struct deleter2 { template<class T> void operator()(T*) const {} }; int main() { A* a = new A(); boost::shared_ptr<A> p1(a, deleter1()); boost::shared_ptr<A> p2(a, deleter2()); std::cout << "p1 < p2 = " << (p1 < p2) << std::endl ; std::cout << "p1 == p2 = " << (p1 == p2) << std::endl ; } Output: p1 < p2 = 1 p1 == p2 = 1 -- Valentin Samko - http://val.samko.info