$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Richard Peters (R.A.Peters_at_[hidden])
Date: 2001-12-06 10:09:42
Are the boost::bind() versions acceptable replacement for those classes? I
think they nicely fit in the functional library. Their use could be much
more intuitive than the bind() alternatives.
Richard Peters
From: "Peter Dimov" <pdimov_at_[hidden]>
> From: "Richard Peters" <R.A.Peters_at_[hidden]>
> > What about a more general case: a constant generator, and a
unary_function
> > that ignores the first value but returns the generator instead? Combined
> > they provide the functionality of your Constant, and they are also
usable
> as
> > stand-alone functors. And maybe the generator class that behaves similar
> to
> > unary_function/binary_function (doesn't it already exist?)
> >
> > template<class Result>
> > struct generator {
> >     typedef Result result_type;
> > };
> >
> > template<class Arg, class Result, class Generator>
> > struct unary_ignore: public unary_function<Arg, Result> {
> >     unary_ignore() {}
> >     unary_ignore(Generator thegenerator):
> >         generator(thegenerator) {}
> >     Result operator()(typename call_traits<Arg>::param_type)
> >     {
> >         return Generator();
> >     };
> > private:
> >     Generator generator;
> > };
>
> boost::bind(thegenerator);
>
> > template<class Result>
> > struct constant: public generator<Result> {
> >     constant(Result thevalue):
> >         value(thevalue) {}
> >     Result operator()()
> >     {
> >         return value;
> >     }
> > private:
> >     const Result value;
> > };
>
> boost::bind(identity<Result>(), value);
>
> > and the same for the binary_function, you could ignore one of the two
> > parameters:
>
> Ditto.
>
> --
> Peter Dimov
> Multi Media Ltd.