Inhaltsverzeichnis

swap()

#include <utility>

void swap (T& a, T& b) 

Vertauscht die Werte von a und b.

Parameter

a Variable
b Variable

Ergebnis

Rückgabewert: keiner.

Siehe auch

exchange(), iter_swap().

Beispiel

swap.cpp
#include <utility>
#include <iostream>
 
int main()
{
  int m=2, n=3;
 
  std::swap(m, n);  
 
  std::cout << m << " " << n << '\n';
  return 0;
}