#ifndef PREDICATE_HPP #define PREDICATE_HPP #include template class predicate { public: typedef boost::function1 type; struct and { and(const type &left, const type &right): left_(left), right_(right) {} bool operator()(const ValueType &value) { return left_(value) && right_(value); } private: type left_; type right_; }; struct or { or(const type &left, const type &right): left_(left), right_(right) {} bool operator()(const ValueType &value) { return left_(value) || right_(value); } private: type left_; type right_; }; }; template typename predicate::type operator &(const typename predicate::type &left, const typename predicate::type &right) { return typename predicate::and(left, right); } template typename predicate::type operator |(const typename predicate::type &left, const typename predicate::type &right) { return typename predicate::or(*this, right); } #endif