H<F,G> _AND_( 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 both f
and g
return 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 the numbers dividable by 2 AND 3 vector<int> v = filter( v_numbers, _AND_(dividable_by_2,dividable_by_3) ); // v contains "6" }