>> * Added a no-throwing swap operation.
> Is there a good reason for this to be public? Isn't it just an
> implementation detail for assign()?
>> (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
one. One reason to have a public swap() method is to use it from a
global swap(). Another reason is exception safety. Often you can't
make your own class exception-safe if it contains members that don't
> RefCountedPointer<Foo> bar(new Foo);
> delete bar;
> But *really*. If one is so intent on shooting oneself in the foot....
I agree. I've been using implicit conversion to void* or even T* for a
long time, and I've never accidently used delete on a smart pointer.
Actually, well written code has very few explicit delete calls, so it's
hard to make a mistake there.