Re: Compilation error with function object predicate

From: Anand Hariharan (desh_bakth_at_yahoo.com)
Date: 09/01/04


Date: 31 Aug 2004 16:10:02 -0700

Karl Heinz Buchegger <kbuchegg@gascad.at> wrote in message news:<41347595.AD9C7A73@gascad.at>...
> Alwyn wrote:
> > > > Can anyone explain to me what's wrong with this code? The compiler
> > > > seems to be complaining I haven't defined an appropriate operator() in
> > > > not_multiple, but I can't see what's wrong with it.
> > >
> > > filter() takes a unary_function as its first argument.
> > > And that one doesn't have an operator()
> >

Am afraid, I don't quite understand.

Dinkumware documents unary_function as -

<quote>

template<class Arg, class Result>
    struct unary_function {
    typedef Arg argument_type;
    typedef Result result_type;
    };
The template class serves as a base for classes that define a member
function of the form:

result_type operator()(const argument_type&) const
or a similar form taking one argument.

Hence, all such unary functions can refer to their sole argument type
as argument_type and their return type as result_type.

</quote>

In Alwyn's code, one sees that "not_multiple" is derived from the
templated unary_function class, and indeed has overloaded operator ().

Could someone please elaborate? Please be aware that I am not the OP,
and the OP's query has been addressed.

thank you,
- Anand Hariharan