00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef ESBTL_COMBINE_BOOLEAN_OPERATOR_H
00036 #define ESBTL_COMBINE_BOOLEAN_OPERATOR_H
00037
00038
00039 namespace ESBTL{
00040
00045 template <class S>
00046 struct Not_functor:public S{
00047 Not_functor(){}
00048 Not_functor(const S& s):S(s){}
00049
00050 template <class T>
00051 bool operator()(const T& t) const {
00052 return ! S::operator()(t);
00053 }
00054 };
00055
00056 #ifndef __GXX_EXPERIMENTAL_CXX0X__
00057
00058 template <class S1=void,class S2=void,class S3=void,class S4=void,class S5=void,class S6=void,class S7=void,class S8=void,class S9=void,class S10=void>
00059 class And_functors;
00060
00061
00062 template <class S1,class S2>
00063 class And_functors<S1,S2>: public S2{
00064 S1 s1_;
00065 public:
00066 And_functors(){}
00067 And_functors(const S1& s1,const S2& s2):s1_(s1),S2(s2){}
00068
00069 template <class T>
00070 bool operator()(const T& i) const{
00071 return s1_(i) && S2::operator()(i);
00072 }
00073 };
00074
00075 template <class S1,class S2,class S3>
00076 class And_functors<S1,S2,S3>: public And_functors<S2,S3>{
00077 S1 s1_;
00078 public:
00079 And_functors(){}
00080 And_functors(const S1& s1,const S2& s2,const S3& s3):s1_(s1),And_functors<S2,S3>(s2,s3){}
00081
00082 template <class T>
00083 bool operator()(const T& i) const{
00084 return s1_(i) && And_functors<S2,S3>::operator()(i);
00085 }
00086 };
00087
00088 template <class S1,class S2,class S3,class S4>
00089 class And_functors<S1,S2,S3,S4>: public And_functors<S2,S3,S4>{
00090 S1 s1_;
00091 public:
00092 And_functors(){}
00093 And_functors(const S1& s1,const S2& s2,const S3& s3,const S4& s4):s1_(s1),And_functors<S2,S3,S4>(s2,s3,s4){}
00094
00095 template <class T>
00096 bool operator()(const T& i) const{
00097 return s1_(i) && And_functors<S2,S3,S4>::operator()(i);
00098 }
00099 };
00100
00101 template <class S1,class S2,class S3,class S4,class S5>
00102 class And_functors<S1,S2,S3,S4,S5>: public And_functors<S2,S3,S4,S5>{
00103 S1 s1_;
00104 public:
00105 And_functors(){}
00106 And_functors(const S1& s1,const S2& s2,const S3& s3,const S4& s4,const S5& s5):s1_(s1),And_functors<S2,S3,S4,S5>(s2,s3,s4,s5){}
00107
00108 template <class T>
00109 bool operator()(const T& i) const{
00110 return s1_(i) && And_functors<S2,S3,S4,S5>::operator()(i);
00111 }
00112 };
00113
00114 template <class S1,class S2,class S3,class S4,class S5,class S6>
00115 class And_functors<S1,S2,S3,S4,S5,S6>: public And_functors<S2,S3,S4,S5,S6>{
00116 S1 s1_;
00117 public:
00118 And_functors(){}
00119 And_functors(const S1& s1,const S2& s2,const S3& s3,const S4& s4,const S5& s5,const S6& s6):s1_(s1),And_functors<S2,S3,S4,S5,S6>(s2,s3,s4,s5,s6){}
00120
00121 template <class T>
00122 bool operator()(const T& i) const{
00123 return s1_(i) && And_functors<S2,S3,S4,S5,S6>::operator()(i);
00124 }
00125 };
00126
00127 template <class S1,class S2,class S3,class S4,class S5,class S6,class S7>
00128 class And_functors<S1,S2,S3,S4,S5,S6,S7>: public And_functors<S2,S3,S4,S5,S6,S7>{
00129 S1 s1_;
00130 public:
00131 And_functors(){}
00132 And_functors(const S1& s1,const S2& s2,const S3& s3,const S4& s4,const S5& s5,const S6& s6,const S7& s7):s1_(s1),And_functors<S2,S3,S4,S5,S6,S7>(s2,s3,s4,s5,s6,s7){}
00133
00134 template <class T>
00135 bool operator()(const T& i) const{
00136 return s1_(i) && And_functors<S2,S3,S4,S5,S6,S7>::operator()(i);
00137 }
00138 };
00139
00140 template <class S1,class S2,class S3,class S4,class S5,class S6,class S7,class S8>
00141 class And_functors<S1,S2,S3,S4,S5,S6,S7,S8>: public And_functors<S2,S3,S4,S5,S6,S7,S8>{
00142 S1 s1_;
00143 public:
00144 And_functors(){}
00145 And_functors(const S1& s1,const S2& s2,const S3& s3,const S4& s4,const S5& s5,const S6& s6,const S7& s7,const S8& s8):s1_(s1),And_functors<S2,S3,S4,S5,S6,S7,S8>(s2,s3,s4,s5,s6,s7,s8){}
00146
00147 template <class T>
00148 bool operator()(const T& i) const{
00149 return s1_(i) && And_functors<S2,S3,S4,S5,S6,S7,S8>::operator()(i);
00150 }
00151 };
00152
00153 template <class S1,class S2,class S3,class S4,class S5,class S6,class S7,class S8,class S9>
00154 class And_functors<S1,S2,S3,S4,S5,S6,S7,S8,S9>: public And_functors<S2,S3,S4,S5,S6,S7,S8,S9>{
00155 S1 s1_;
00156 public:
00157 And_functors(){}
00158 And_functors(const S1& s1,const S2& s2,const S3& s3,const S4& s4,const S5& s5,const S6& s6,const S7& s7,const S8& s8,const S9& s9):s1_(s1),And_functors<S2,S3,S4,S5,S6,S7,S8,S9>(s2,s3,s4,s5,s6,s7,s8,s9){}
00159
00160 template <class T>
00161 bool operator()(const T& i) const{
00162 return s1_(i) && And_functors<S2,S3,S4,S5,S6,S7,S8,S9>::operator()(i);
00163 }
00164 };
00173 template <class S1,class S2,class S3,class S4,class S5,class S6,class S7,class S8,class S9,class S10>
00174 class And_functors: public And_functors<S2,S3,S4,S5,S6,S7,S8,S9,S10>{
00175 S1 s1_;
00176 public:
00177 And_functors(){}
00178 And_functors(const S1& s1,const S2& s2,const S3& s3,const S4& s4,const S5& s5,const S6& s6,const S7& s7,const S8& s8,const S9& s9,const S10& s10):And_functors<S2,S3,S4,S5,S6,S7,S8,S9,S10>(s1,s2,s3,s4,s5,s6,s7,s8,s9,s10){}
00179
00180 template <class T>
00181 bool operator()(const T& i) const{
00182 return s1_(i) && And_functors<S2,S3,S4,S5,S6,S7,S8,S9,S10>::operator()(i);
00183 }
00184 };
00185
00187 template <class S1=void,class S2=void,class S3=void,class S4=void,class S5=void,class S6=void,class S7=void,class S8=void,class S9=void,class S10=void>
00188 class Or_functors;
00189
00190
00191 template <class S1,class S2>
00192 class Or_functors<S1,S2>: public S2{
00193 S1 s1_;
00194 public:
00195 Or_functors(){}
00196 Or_functors(const S1& s1,const S2& s2):s1_(s1),S2(s2){}
00197
00198 template <class T>
00199 bool operator()(const T& i) const{
00200 return s1_(i) || S2::operator()(i);
00201 }
00202 };
00203
00204 template <class S1,class S2,class S3>
00205 class Or_functors<S1,S2,S3>: public Or_functors<S2,S3>{
00206 S1 s1_;
00207 public:
00208 Or_functors(){}
00209 Or_functors(const S1& s1,const S2& s2,const S3& s3):s1_(s1),Or_functors<S2,S3>(s2,s3){}
00210
00211 template <class T>
00212 bool operator()(const T& i) const{
00213 return s1_(i) || Or_functors<S2,S3>::operator()(i);
00214 }
00215 };
00216
00217 template <class S1,class S2,class S3,class S4>
00218 class Or_functors<S1,S2,S3,S4>: public Or_functors<S2,S3,S4>{
00219 S1 s1_;
00220 public:
00221 Or_functors(){}
00222 Or_functors(const S1& s1,const S2& s2,const S3& s3,const S4& s4):s1_(s1),Or_functors<S2,S3,S4>(s2,s3,s4){}
00223
00224 template <class T>
00225 bool operator()(const T& i) const{
00226 return s1_(i) || Or_functors<S2,S3,S4>::operator()(i);
00227 }
00228 };
00229
00230 template <class S1,class S2,class S3,class S4,class S5>
00231 class Or_functors<S1,S2,S3,S4,S5>: public Or_functors<S2,S3,S4,S5>{
00232 S1 s1_;
00233 public:
00234 Or_functors(){}
00235 Or_functors(const S1& s1,const S2& s2,const S3& s3,const S4& s4,const S5& s5):s1_(s1),Or_functors<S2,S3,S4,S5>(s2,s3,s4,s5){}
00236
00237 template <class T>
00238 bool operator()(const T& i) const{
00239 return s1_(i) || Or_functors<S2,S3,S4,S5>::operator()(i);
00240 }
00241 };
00242
00243 template <class S1,class S2,class S3,class S4,class S5,class S6>
00244 class Or_functors<S1,S2,S3,S4,S5,S6>: public Or_functors<S2,S3,S4,S5,S6>{
00245 S1 s1_;
00246 public:
00247 Or_functors(){}
00248 Or_functors(const S1& s1,const S2& s2,const S3& s3,const S4& s4,const S5& s5,const S6& s6):s1_(s1),Or_functors<S2,S3,S4,S5,S6>(s2,s3,s4,s5,s6){}
00249
00250 template <class T>
00251 bool operator()(const T& i) const{
00252 return s1_(i) || Or_functors<S2,S3,S4,S5,S6>::operator()(i);
00253 }
00254 };
00255
00256 template <class S1,class S2,class S3,class S4,class S5,class S6,class S7>
00257 class Or_functors<S1,S2,S3,S4,S5,S6,S7>: public Or_functors<S2,S3,S4,S5,S6,S7>{
00258 S1 s1_;
00259 public:
00260 Or_functors(){}
00261 Or_functors(const S1& s1,const S2& s2,const S3& s3,const S4& s4,const S5& s5,const S6& s6,const S7& s7):s1_(s1),Or_functors<S2,S3,S4,S5,S6,S7>(s2,s3,s4,s5,s6,s7){}
00262
00263 template <class T>
00264 bool operator()(const T& i) const{
00265 return s1_(i) || Or_functors<S2,S3,S4,S5,S6,S7>::operator()(i);
00266 }
00267 };
00268
00269 template <class S1,class S2,class S3,class S4,class S5,class S6,class S7,class S8>
00270 class Or_functors<S1,S2,S3,S4,S5,S6,S7,S8>: public Or_functors<S2,S3,S4,S5,S6,S7,S8>{
00271 S1 s1_;
00272 public:
00273 Or_functors(){}
00274 Or_functors(const S1& s1,const S2& s2,const S3& s3,const S4& s4,const S5& s5,const S6& s6,const S7& s7,const S8& s8):s1_(s1),Or_functors<S2,S3,S4,S5,S6,S7,S8>(s2,s3,s4,s5,s6,s7,s8){}
00275
00276 template <class T>
00277 bool operator()(const T& i) const{
00278 return s1_(i) || Or_functors<S2,S3,S4,S5,S6,S7,S8>::operator()(i);
00279 }
00280 };
00281
00282
00283 template <class S1,class S2,class S3,class S4,class S5,class S6,class S7,class S8,class S9>
00284 class Or_functors<S1,S2,S3,S4,S5,S6,S7,S8,S9>: public Or_functors<S2,S3,S4,S5,S6,S7,S8,S9>{
00285 S1 s1_;
00286 public:
00287 Or_functors(){}
00288 Or_functors(const S1& s1,const S2& s2,const S3& s3,const S4& s4,const S5& s5,const S6& s6,const S7& s7,const S8& s8,const S9& s9):s1_(s1),Or_functors<S2,S3,S4,S5,S6,S7,S8,S9>(s2,s3,s4,s5,s6,s7,s8,s9){}
00289
00290 template <class T>
00291 bool operator()(const T& i) const{
00292 return s1_(i) || Or_functors<S2,S3,S4,S5,S6,S7,S8,S9>::operator()(i);
00293 }
00294 };
00303 template <class S1,class S2,class S3,class S4,class S5,class S6,class S7,class S8,class S9,class S10>
00304 class Or_functors: public Or_functors<S2,S3,S4,S5,S6,S7,S8,S9,S10>{
00305 S1 s1_;
00306 public:
00307 Or_functors(){}
00308 Or_functors(const S1& s1,const S2& s2,const S3& s3,const S4& s4,const S5& s5,const S6& s6,const S7& s7,const S8& s8,const S9& s9,const S10& s10):s1_(s1),Or_functors<S2,S3,S4,S5,S6,S7,S8,S9,S10>(s2,s3,s4,s5,s6,s7,s8,s9,s10){}
00309
00310 template <class T>
00311 bool operator()(const T& i) const{
00312 return s1_(i) || Or_functors<S2,S3,S4,S5,S6,S7,S8,S9,S10>::operator()(i);
00313 }
00314 };
00315
00316
00317 #else
00318
00319 template <class ... S>
00320 class And_functors;
00321
00322 template <class S1,class ... S>
00323 class And_functors<S1,S... >: And_functors<S...>{
00324 S1 s1_;
00325 public:
00326 And_functors(){}
00327 And_functors(const S1& s1,S... s):s1_(s1),And_functors<S...>(s...) {}
00328
00329 template <class T>
00330 bool operator()(const T& i) const{
00331 return s1_(i) && And_functors<S...>::operator()(i);
00332 }
00333 };
00334
00335 template <class S1,class S2>
00336 struct And_functors<S1,S2>: public S2{
00337 S1 s1_;
00338 public:
00339 And_functors(){}
00340 And_functors(const S1& s1,const S2& s2):s1_(s1),S2(s2){}
00341
00342 template <class T>
00343 bool operator()(const T& i) const{
00344 return s1_(i) && S2::operator()(i);
00345 }
00346 };
00347
00348 template <class ... S>
00349 struct Or_functors;
00350
00351 template <class S1,class ... S>
00352 struct Or_functors<S1,S... >: Or_functors<S...>{
00353 S1 s1_;
00354 public:
00355 Or_functors(){}
00356 Or_functors(const S1& s1,S... s):S1(s1),Or_functors<S...>(s...) {}
00357
00358 template <class T>
00359 bool operator()(const T& i) const{
00360 return s1_(i) || Or_functors<S...>::operator()(i);
00361 }
00362 };
00363
00364 template <class S1,class S2>
00365 struct Or_functors<S1,S2>: S2{
00366 S1 s1_;
00367 public:
00368 Or_functors(){}
00369 Or_functors(const S1& s1,const S2& s2):s1_(s1),S2(s2){}
00370
00371 template <class T>
00372 bool operator()(const T& i) const{
00373 return s1_(i) || S2::operator()(i);
00374 }
00375 };
00377 #endif
00378
00379 }
00380
00381 #endif //ESBTL_COMBINE_BOOLEAN_OPERATOR_H
00382