swap (<utility>)

Exchanges the elements of two pair Structure objects.

template<class Type1, class Type2>
void swap(pair<Type1, Type2>&_Left,
pair<Type1, Type2>&_Right);

Parameters

Parameter

Description

_Left

An object of type pair.

_Right

An object of type pair.

Remarks

One advantage of swap is that the types of objects that are being stored are determined automatically by the compiler and do not have to be explicitly specified. Don't use explicit template arguments such as swap<int, int>(1, 2) when you use swap because it is unnecessarily verbose and adds complex rvalue reference problems that might cause compilation failure.

Requirements

Header: <utility>

Namespace: std

See Also

Reference

<utility>