A: 

It sounds like what you want is generally called a Lambda. For now, you could look up Boost::lambda. In C++0x, lambda expressions will be directly supported by the language.

Jerry Coffin
+2  A: 

Using that expression syntax is going to make it very difficult. The way I've always done this in the past is to have an abstract Rule class from which I derive concrete rule types. I then add these to the validator:

Validator v;
v.add( new NotValueRule( "foo" ) );
v.add( new NotIntRule ) );
v.add( new BetweenRule( "a", "z" ) );

and then call the validate() function on the validator. This doesn't allow directly for ands and ors, but you can get round that with a couple of "fake" rules called AndRule and OrRule.

anon