os_find_if


Locates an item that satisfies a predicate in a container.

A helper algorithm for find_if() . Sets result to point to the first element in container c that causes pred to return true , or zero if no such element exists.

Library

Helper<ToolKit>

Declaration

#include <ospace/helper/helpalgo.h>

template< class Container, class Predicate, class T >
void os_find_if( Container& c, Predicate pred, T*& result )
Example <ospace/helper/examples/ofindif0.cpp>
#include <iostream>
#include <vector>
#include <ospace/helper.h>

int numbers[ 6 ] = { 2, 4, 8, 15, 32, 64 };

bool
odd( int a_ )
  {
  return a_ % 2;
  }

void
main()
  {
  vector< int > v( numbers, numbers + 6 );
  int* location = 0;

  os_find_if( v, odd, location );

  if ( location )
    cout << "Found " << *location << "\n";
  }

Found 15

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