Re: functors and binary_function
Stephen Howe wrote:
Now does this occur for
Visual Studio 8.0 ?
Visual Studio 9.0 ?
Visual Studio 10.0 ?
Yes, STL implementation included with all these VS versions provides =
std::binary_function class that you can derive from...
I was certain of that Igor
... as well as certain wrappers and adapters that benefit from =
typedefs std::binary_function introduces.
What wrappers, adapters and benefits are those?
E.g. binary_negate, which is defined something like this:
template <class Predicate>
class binary_negate : public binary_function<
typename Predicate::first_argument_type,
typename Predicate::second_argument_type,
bool> {
bool operator() (
const first_argument_type& arg1,
const second_argument_type& arg2) const {
return !Predicate()(arg1, arg2);
}
};
Note how the template parameter (a user-defined predicate) is expected =
to provide typedefs named first_argument_type and second_argument_type. =
You can define them manually, or you can save some typing by deriving =
from binary_function.
There are a few other adapters in the similar vein.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not =
necessarily a good idea. It is hard to be sure where they are going to =
land, and it could be dangerous sitting under them as they fly overhead. =
-- RFC 1925