The Simple Functional Template Library
[[and]]
 

__AND__

Definition

H<F,G> _AND_( F f, G g );

where :

  • F is the type of functor f
  • G is the type of functor g
  • H is the type of resulting functor

Parameters

Parameter Description
f the first functor
g the second functor

Return value

A functor of type H<F,G>

Description

Creates a functor that returns true if both f and g return true.

Examples

#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"
}
 
and.txt · Last modified: 2007/08/24 23:31 (external edit)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki