[#bsl-swap-0a1] = xref:bsl.adoc[bsl]::swap :relfileprefix: ../ :mrdocs: Exchange the value of the specified `a` object with that of the specified `b` object; also exchange the allocator of `a` with that of `b` if the (template parameter) type `ALLOCATOR` has the `propagate_on_container_swap` trait, and do not modify either allocator otherwise. This function provides the no‐throw exception‐safety guarantee. This operation has `O[1]` complexity if either `a` was created with the same allocator as `b` or `ALLOCATOR` has the `propagate_on_container_swap` trait; otherwise, it has `O[n + m]` complexity, where `n` and `m` are the number of elements in `a` and `b`, respectively. Note that this function`s support for swapping objects created with different allocators when `ALLOCATOR` does not have the `propagate_on_container_swap` trait is a departure from the C++ Standard. == Synopsis Declared in `<bslstl_vector.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class VALUE_TYPE, class ALLOCATOR> void swap( xref:bsl/vector-00d.adoc[vector<VALUE_TYPE, ALLOCATOR>]& a, xref:bsl/vector-00d.adoc[vector<VALUE_TYPE, ALLOCATOR>]& b) noexcept(noexcept(a.swap(b))); ---- [.small]#Created with https://www.mrdocs.com[MrDocs]#