The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

swap Function

Exchanges the elements of two concurrent_vector objects.

   typename _Ty,
   class _Ax
inline void swap(
   _Ax> &_A,
   _Ax> &_B


The data type of the elements stored in the concurrent vectors.


The allocator type of the concurrent vectors.


The concurrent vector whose elements are to be exchanged with those of the concurrent vector _B.


The concurrent vector providing the elements to be swapped, or the vector whose elements are to be exchanged with those of the concurrent vector _A.

The template function is an algorithm specialized on the container class concurrent_vector to execute the member function _A.concurrent_vector::swap(_B). These are instances of the partial ordering of function templates by the compiler. When template functions are overloaded in such a way that the match of the template with the function call is not unique, then the compiler will select the most specialized version of the template function. The general version of the template function, template <class T> void swap(T&, T&), in the algorithm class works by assignment and is a slow operation. The specialized version in each container is much faster as it can work with the internal representation of the container class.

This method is not concurrency-safe. You must ensure that no other threads are performing operations on either of the concurrent vectors when you call this method.

Header: concurrent_vector.h

Namespace: concurrency

© 2014 Microsoft