Boost logo

Boost :

From: jsiek_at_[hidden]
Date: 2000-09-06 09:15:10


Yes, these are very much needed. All the binary functions
should have three template paramters.

Mark Rodgers writes:
> I was thinking of adding something like
>
> template <class Arg1, class Arg2 = Arg1, class Result = Arg1>
> struct plus : std::binary_function<Arg1,Arg2,Result>
> {
> Result operator()(typename call_traits<Arg1>::param_type x,
> typename call_traits<Arg2>::param_type y) const
> {
> return x + y;
> }
> };
>
> template <class Arg1, class Arg2 = Arg1, class Result = Arg1>
> struct minus : std::binary_function<Arg1,Arg2,Result>
> {
> Result operator()(typename call_traits<Arg1>::param_type x,
> typename call_traits<Arg2>::param_type y) const
> {
> return x - y;
> }
> };
>
> to functional.hpp. The idea would be to allow things like
>
> boost::plus<Foo*,std::ptrdiff_t,Foo*>()
> or boost::minus<Foo*,std::ptrdiff_t,Foo*>()
> or boost::minus<Foo*,Foo*,std::ptrdiff_t>()
>
> as well as the traditional
>
> boost::minus<int>()
>
> Thoughts anyone?
>
> Mark
>
>
>
>
>
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk