proj home

Files   Classes   Functions   Hierarchy  

functionalobjectoperators.h

Go to the documentation of this file.
00001 #ifndef FUNCTIONALOBJECTOPERATORS_H
00002 #define FUNCTIONALOBJECTOPERATORS_H
00003 
00004 #include <typedefs.h>
00005 
00006 // The aim of this file is to add functional operators when needed.
00007 // ie Encountering a situation where new operators are needed or
00008 // the current solution is inadequate.
00009 
00010 // STL has implemented functional operators with nasty baggage.
00011 // For example the not2 operator requires the binary operator
00012 // to have certain data members which is totally unnecessary.
00013 
00022 //template< typename F, typename T >
00023 template< typename F >
00024 class mynot2object
00025 {
00026 public:
00027   F f;
00028 
00030   mynot2object(F const & f_)
00031     : f(f_) {}
00032 
00034   template< typename T >
00035   boolc operator()(T const & p1, T const & p2)
00036     { return !f(p1,p2); }
00037 };
00038 
00039 template< typename F >
00040 mynot2object<F> mynot2(F const & f_)
00041 {
00042   return mynot2object<F>(f_);
00043 }
00044 
00045 
00046 
00047 template< typename F >
00048 class mycomparexobject
00049 {
00050 public:
00051 
00053   F bin;
00054 
00056   mycomparexobject() {}
00058   mycomparexobject(F const & bin_)
00059     : bin(bin_) {}
00060 
00063   template< typename T >
00064   boolc operator()(T const & p1, T const & p2)
00065     { return bin(p1.x,p2.x); }
00066 };
00067 
00068 template< typename F >
00069 mycomparexobject<F> mycomparex(F const & f_)
00070 {
00071   return mycomparexobject<F>(f_);
00072 }
00073 
00074 
00075 
00076 template< typename F >
00077 class mycompareyobject
00078 {
00079 public:
00080 
00082   F bin;
00083 
00085   mycompareyobject() {}
00087   mycompareyobject(F const & bin_)
00088     : bin(bin_) {}
00089 
00092   template< typename T >
00093   boolc operator()(T const & p1, T const & p2)
00094     { return bin(p1.y,p2.y); }
00095 };
00096 
00097 template< typename F >
00098 mycompareyobject<F> mycomparey(F const & f_)
00099 {
00100   return mycompareyobject<F>(f_);
00101 }
00102 
00103 
00104 template< typename F >
00105 class mycomparezobject
00106 {
00107 public:
00108 
00110   F bin;
00111 
00113   mycomparezobject() {}
00115   mycomparezobject(F const & bin_)
00116     : bin(bin_) {}
00117 
00120   template< typename T >
00121   boolc operator()(T const & p1, T const & p2)
00122     { return bin(p1.z,p2.z); }
00123 };
00124 
00125 template< typename F >
00126 mycomparezobject<F> mycomparez(F const & f_)
00127 {
00128   return mycomparezobject<F>(f_);
00129 }
00130 
00131 
00132 #endif
00133 
00134 

Generated on Fri Mar 4 00:49:29 2011 for Chelton Evans Source by  doxygen 1.5.8