Boost logo

Boost :

From: Luis Coelho (deepblack_at_[hidden])
Date: 1999-09-17 19:31:18


[If this is not the appropriate way to submit this, I appoligise]

I have used boost's shared_ptr (from smart_ptr) for some time now. There is
however one function I feel is missing. I have added it in my own header
and I think other users could benefit from it: a nonthrowing swap.
I will not dwell into the benefits of this function since they are well
known to readers of comp.lang.c++.mod.
I propuse this simple implementation:

template <typename T>
void shared_ptr<T>::swap(shared_ptr<T>& other) throw()
{
    std::swap(px,other.px);
    std::swap(pn,other.pn);
}

Of course shared_array could also benefit from it.

Regards,
Luis Coelho.
C++ Programming Language, 3rd Ed. by B. Stroustrup. My exercise answers at:
http://www.geocities.com/SiliconValley/Way/3972/index.html


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk