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
2010-08-09 15:39:17
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.
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.