Skip to main content
1 of 3

The convention for swap, instead of declaring it friend, is to provide a public member function swap as well as specializing std::swap for your type.

namespace std {
    template<> void swap<Widget>(unique_ptr& a, unique_ptr& b) 
    {
        a.swap(b); 
    }
}