The Simple Functional Template Library
[[not]]
 

__AND__

Definition

G<F> _NOT_( F f );

where :

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

Parameters

Parameter Description
f a functor returning a boolean value

Return value

A functor of type G<F>

Description

Creates a functor that returns the negation of f result.

Examples

#include <iostream>
#include <vector>
#include "sftl.h"
 
using namespace std;
 
bool dividable_by_2( int x ) {
    return (x%2)==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 non dividable by 2
    vector<int> v = filter( v_numbers, _NOT_(dividable_by_2) ); // v contains 1 3 5 7 9
}
 
not.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