| | | | | |

Binding - 2

template < class Incoming >
class BinderFirst : public FunctorImpl 
  < typename Incoming::ResultType , typename Incoming::ParmList::Tail >
{
  typedef
    Functor<typename Incoming::ResultType, typename Incoming::ParmList::Tail>
    Outgoing;
  typedef typename Incoming::ResultType ResultType;
  typedef typename Incoming::Parm1 Bound;
  typedef typename Incoming::Parm2 Parm1;
  typedef typename Incoming::Parm3 Parm2;
  ...
public:
  BinderFirst(const Incoming& fun, Bound bound)
    : fun_(fun), bound_(bound) {}
  DEFINE_CLONE_FUNCTORIMPL(BinderFirst)
  ResultType operator() ()
  {
    return fun_(bound_);
  }
  ResultType operator() (typename Outgoing::Parm1 p1)
  {
    return fun_(bound_, p1);
  }
  ResultType operator() (typename Outgoing::Parm1 p1, typename Outgoing::Parm2 p2)
  {
    return fun_(bound_, p1, p2);
  }
  ...
private:
  Incoming fun_;
  Bound bound_;
};

| | Top of Page | 8. Generalized Functors - 20 of 26