[Probing interest] -- automatization of writing predicates.

Hi folks, I often find myself in a situation where I need a simple comparison predicate for filtering, look-up, etc. Writing such predicates can get tedious over time and adds unnecessary "bloat", especially when you use the predicate only once. For that reason I have automated this process and I'm interested whether others might find it useful as well. Usage example: auto_predicate(&ClassName::getter, compareWithMe) -- this returns functor which compares the returned value with compareWithMe using == operator. auto_predicate(&ClassName::getter, compareWithMe, comparator) -- this returns functor which compares the returned value with compareWithMe using the given comparator. (Note: getter return type does not have to match compareWithMe type have you supplied comparator with proper signature.) Best regards, Petr Pilař.

On Thu, Nov 18, 2010 at 9:27 PM, Petr Pilař <email@palmik.net> wrote:
Hi folks, I often find myself in a situation where I need a simple comparison predicate for filtering, look-up, etc. Writing such predicates can get tedious over time and adds unnecessary "bloat", especially when you use the predicate only once.
Not sure how your solution is better than using Boost.Phoenix or Boost.Lambda. Can you explain what's the difference? -- Dean Michael Berris deanberris.com

Dean Michael Berris wrote:
On Thu, Nov 18, 2010 at 9:27 PM, Petr Pilař <email@palmik.net> wrote:
Hi folks, I often find myself in a situation where I need a simple comparison predicate for filtering, look-up, etc. Writing such predicates can get tedious over time and adds unnecessary "bloat", especially when you use the predicate only once.
Not sure how your solution is better than using Boost.Phoenix or Boost.Lambda.
Can you explain what's the difference?
or even: bind(&ClassName::getter, _1) == compareWithMe bind IIRC, supports all of the comparison operators. Jeff

At November 18th 2010 20:58:06 Jeff Flinn wrote:
or even:
bind(&ClassName::getter, _1) == compareWithMe
bind IIRC, supports all of the comparison operators.
You are right, this does not look that ugly. Problem solved. :) Petr Pilař.
participants (3)
-
Dean Michael Berris
-
Jeff Flinn
-
Petr Pilař