C++ Extensions (cppx) Documentation Internal Version
Main | Namespaces | Classes | NamespaceMembers | ClassMembers | Files

stdxFunctional.h Classes and Functions

A collection of simple function objects to help make stl eaiser to use. Many of these are nicer ways to create comparison predicates for use with various _if STL algorithms. You can achieve the same effect with std::bind2nd but it's ugly and harder to read. So below are two ways to do the same thing:

 copy_if( iseq(lst1), back_inserter(lst2), bind2nd( less<int>(), 7 );
 copy_if( iseq(lst1), back_inserter(lst2), less_than(7) );

In combination with the stdx::filter() functions this can be pretty powerful and elegant. For example if we have a collection of Person objects and we want to create a view of that list which only contains people whose occupation is Student then we could use the following:

 list<Person> lst;
 // ... fill lst with people ...
 list<Person> students;
 copy_if( iseq(lst), back_inserter(students), 
          filter( &Person::getOccupation, equal(Student) ) );

Compounds

Functions

Comparison Predicate Helper Functions

Detailed Documentation

Function Documentation

template<class T>
Equal<T> equal const T &    val
 

template<class T>
NotEqual<T> not_equal const T &    val
 

template<class T>
LessThan<T> less_than const T &    val
 

template<class T>
GreaterThan<T> greater_than const T &    val
 

template<class T>
LessThanOrEqual<T> less_than_or_equal const T &    val
 

template<class T>
GreaterThanOrEqual<T> greater_than_or_equal const T &    val
 

Generated on Mon Aug 15 21:43:09 2005 by Doxygen 1.2.13-20020210 written by Dimitri van Heesch © 1997-2002