Boost logo

Boost Users :

From: Robin (robin_at_[hidden])
Date: 2004-06-03 02:54:27


The current bind defines the placeholder _1, _2 etc. I was wondering if
there is another placeholder that will deference the placeholder if the
container is holding pointers instead of copies?

Usually I store shared_ptrs in containers instead of direct copies as
they are polymorphic

  class C; // this is our object we are storing

  typedef boost::shared_ptr<C> CSP;

  std::vector<CSP> C_List;

Now we have a function that operates on C

  void Operate(C &c);

  C_List clist; // the list of shared_ptrs to C

  // this won't compile
  std::for_each (clist.begin (), clist.end (),
                 boost::bind (Operator,_1));

I have to make an auxillary function to compile

  void Wrap_Operate (CSP &c)

  std::for_each (clist.begin (), clist.end (),
                 boost::bind (Wrap_Operate, _1));

Is there to avoid making the additional function and have a placeholder
that will dereference directly (eg *_1, *_2)? Can I have the cake and
eat it?


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at