A Simple Algorithm


STL has over 70 reusable algorithms, ranging from simple to complex. As a simple example, STL includes the algorithms min() and max() .

Example <ospace/osstd/examples/alg1.cpp>
 
#include <iostream>
#include <algorithm>

void
main()
  {
  int i = min( 4, 7 );
  cout << "min( 4, 7 ) = " << i << "\n";

  char c = max( 'a', 'z' );
  cout << "max( 'a', 'z' ) = " << c << "\n";
  }

min( 4, 7 ) = 4
max( ('a', 'z' ) = z
 

In addition to using the preprepared algorithms, you can add new algorithms without modifying any of the existing STL implementation code.


Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.