Joseph Artsimovich wrote:
>>> (Should probably define a global
>>> swap(x, y) to use this member)
> I am not the original poster, but I can explain that. The global swap()
> function is usually created so that template code such as std::sort()
> would use class-specific swap() implementation, rather than a generic
Ah, this also explains why you'd want member swap() to be public. But
it begs the question: why would one want to sort a collection of
refcounted pointers? Is it even appropriate to do so without comparison
operators that delegate to the pointed-to-type?
I'm not going to do anything about this immediately, so if someone comes
up with a reason for needing global swap() and thus keeping member
swap() public, I'm all ears. But if I don't hear anything I like before
the v3 development effort starts winding up, I'm going to hide member
swap(). If we discover the need for global swap() after v3 is released
and can't wait for v4 to break the ABI again, we can make it a friend.