Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2004-07-03 20:30:01


"Doug Gregor" <dgregor_at_[hidden]> wrote
> On Jul 3, 2004, at 6:47 PM, Andy Little wrote:
> > I have seen this, but BTW I cant find the
> > utilities/detail/result_of_iterate.hpp header in the boost CVS
>
> ??? It's there (and the regression tests are finding it). Are you using
> "cvs update -d"?

nope... IE explorer ie "the web browser cvs interface". All I'm seeing is
an empty directory.
I better rtm.

> If we had "smarter" versions of std::plus, std::minus, etc. that played
> well with result_of, I think that would solve the issue reasonably
> well.

Are there moves in this direction?

> ... which is just a function object. Something like this:
>
> struct minus ;

abracadabra...??? (*magic*)....

 struct minus
{
   template<typename> struct result;

   template<typename F, typename T, typename U>
     struct result<F(T, U)>
     {//*** assuming this is not "automagic"??? ie require user
specialization...
        typedef typename binary_operation<T,std::minus,U>::result_type type;
     };//***
    template<typename T, typename U>
      typename result<minus(T, U)>::type operator()(T t, U u)
     { return t-u; }
 } ^^^

magic1 operator +(MyUDT<Ta> a, MyUDT<Tb> b);
magic 2 operator -(MyUDT<Ta> a, MyUDT<Tb> b);
etc operator * (MyUDT<Ta> a, MyUDT<Tb> b);
etc operator / (MyUDT<Ta> a, MyUDT<Tb> b);

    template<typename Ta,template < typename> class Op, typename Tb>
    struct binary_operation<
        MyUDT<Ta>,
        Op,
        MyUDT<Tb>
>
    {
        typedef MyUDT<typename binary_operation<Ta,Op,Tb>::result_type >
result_type;
    };

How does the alternative to the above look?

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