H<F,G> _OR_( F f, G g );
where :
Parameter | Description |
---|---|
f | the first functor |
g | the second functor |
A functor of type H<F,G>
Creates a functor that returns true
if either f
or g
returns true
.
#include <iostream> #include <vector> #include "sftl.h" using namespace std; bool dividable_by_2( int x ) { return (x%2)==0; } bool dividable_by_3( int x ) { return (x%3)==0; } int main() { // create vector of numbers int numbers [] = {1,2,3,4,5,6,7,8,9}; vector<int> v_numbers( &numbers[0], &numbers[9] ); // extract numbers dividable by 2 OR 3 vector<int> v = filter( v_numbers, _OR_(dividable_by_2,dividable_by_3) ); // v containes 2 3 4 6 8 9 }