Illustrating the generic swap algorithm: swap two integers : swap « STL Algorithms Modifying sequence operations « C++ Tutorial






#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
  int high = 250, low = 0;

  swap(high, low);

  cout << high << " ";
  cout << low;


  return 0;
}
0 250








24.21.swap
24.21.1.Illustrating the generic swap algorithm: swap two integers
24.21.2.Illustrating the generic swap algorithm
24.21.3.Swap elements at locations 0 and 1 of an array
24.21.4.Swap second and fourth element in a vector