os_for_each


Applies a function to every item in a container.

A helper algorithm for for_each() . Applies function f to every element in container c and returns the input parameter f .

Library

Helper<ToolKit>

Declaration

#include <ospace/helper/helpalgo.h>

template< class Container, class Function >
Function os_for_each( Container& c, Function f )
Example <ospace/helper/examples/oforech0.cpp>
#include <iostream>
#include <vector>
#include <ospace/helper.h>

int numbers[ 10 ] = { 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 };

void
print( int a_ )
  {
  cout << a_ << ` `;
  }

void
main()
  {
  vector< int > v( numbers, numbers + 10 );

  os_for_each( v, print );
  cout << "\n";
  }

1 1 2 3 5 8 13 21 34 55

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