You would replace the subobjects:
swap(static_cast<Bar&>(a), static_cast<Bar&>(b));
You may need to implement the swap function for Barif you are std::swapnot completing the task. Also note that it swapmust be non-member (and if necessary a friend).
source
share