BloombergLP::bslstp::Util::swapContainers

Exchange the contents of the specified containers.

Synopsis

Declared in <bslstp_util.h>

template<
    class CONTAINER,
    class QUICKSWAP_FUNC>
static
void
swapContainers(
    CONTAINER& c1,
    CONTAINER& c2,
    QUICKSWAP_FUNC const& quickswap);

Description

Correctly handle the case where the two containers have different allocator values. The quickswap argument is a binary function object that is called to quickly swap two CONTAINER objects with matching allocators. (The quickswap object does not need to check that the allocator matched -- it is guaranteed by the caller.) Strong exception guarantee: if the allocator or copy constructor of either container throws an exception, then the values of c1 and c2 are left unchanged. The quickswap function must not throw an exception.