swap
Swap two arrays.
Synopsis
Defined in header <boost/json/array.hpp>.
Description
Exchanges the contents of the array lhs with another array rhs. Ownership of the respective boost::container::pmr::memory_resource objects is not transferred. If &lhs == &rhs, this function call has no effect.
-
If
*lhs.storage() == *rhs.storage()all iterators and references remain valid. -
Otherwise, the contents are logically swapped by making copies, which can throw. In this case all iterators and references are invalidated.
Complexity
If *lhs.storage() == *rhs.storage(), then constant; otherwise linear in lhs.size() + rhs.size().
Exception Safety
No-throw guarantee if *lhs.storage() == *rhs.storage(). Otherwise strong guarantee. Calls to memory_resource::allocate may throw.
Parameters
| Name | Description |
|---|---|
|
The array to exchange. |
|
The array to exchange. If |
See Also
Convenience header <boost/json.hpp>