Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2004-07-07 21:47:08


"Doug Gregor" <dgregor_at_[hidden]> wrote

>
> On Jul 3, 2004, at 4:38 AM, Andy Little wrote:
>
> > An example that I think demonstrates the superiority of this:
> >
> > binary_operation<A,Op,B>::result_type result;
> >
> > over this:
> >
> > result_of_plus<A, B>::type result;
> >
> > in this directory:
>
> In Boost CVS there is an implementation of result_of, which would be
> used like this:
>
> result_of<Op(A, B)>::type

One issue with calling the functor

  Op()(a,b);

compared to:

 binary_operation<A,Op,B>()(a,b);

is that it appears to limit you to either passing arguments by value or by
const reference for all arguments.(without much more specialization) Again
I can't be sure this is correct
but it seems to be the case
.
template<template < typename> class Op >
struct operator_ {

       /* ... result type decls members */.

        template<typename L, typename R>
        typename result<
            operator_<Op>(L,R)
>::type
        // Error cant deduce...
        operator()( typename meta::as_const_argument<L>::type l,
             typename meta::as_const_argument<R>::type r)
        //limited to one or other of the following
        operator()(L const& l, R const & r)
        operator()(L l, R r)
        {
            return binary_operator<L,Op,R>()(l,r);
        }
};

regards
Andy Little


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