Boost logo

Boost :

From: Bryan Ewbank (ewbank_at_[hidden])
Date: 2006-11-03 14:16:17


Perhaps I'm misunderstanding or oversimplifying, but doesn't this work?

   template<class A, class B, class C>
   class Pipeline
   {
   public:
      Pipeline(A & a, B & b, C & c)
         : a_(a), b_(b), c_(c) { }

   public:
      template<class ARG>
      void operator()(ARG starting_val)
         {
            c_( b_( a_(starting_val) ) );
         }

   private:
         A & a_;
         B & b_;
         C & c_;
   };

   {
      A a;
      B b;
      C c;

      Pipeline<A,B,C> p(a,b,c);
      ... ... ...
      int arg(10);
      p(arg);
   }

On 11/3/06, Fernando Cacciola <fernando_cacciola_at_[hidden]> wrote:
> Hi people
>
> 3 years of C# programming is eroding my metaprogramming habilities :(
>
> Say I have a few arbitrary function objects:
>
> A a ; B b ; C c ;
>
> I can easily pipe them together using Boost.Bind:
>
> bind(a, bind(b, bind(c,_1) ) )(some_starting_value);
>
> But how do I create such a composed functor programatically from an arbitrary
> tuple of function objects, as in tuple<A,B,C>?
>
> The idea is to present to the user a simple interface were he pass just a
> tuple of functors and I do the magic of turning them into a pipe.


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