Boost logo

Boost Users :

Subject: [Boost-users] Why doesn't boost::function use get_pointer() ?
From: Peter Soetens (peter.soetens_at_[hidden])
Date: 2010-09-14 17:12:22


When using boost::bind, I can write this:

struct X
{
  void foo(int) {}
};

  shared_ptr<X> x( new X );
  // bind takes shared_ptr:
  bind(&X::foo, x, 3)();

But I can't write this:

  function<void(X*,int)> foo = &X::foo;
  // function refuses shared_ptr:
  foo(x,1);

Why doesn't boost::function have the same get_pointer() trick ? Or how can I
rewrite the function signature such that it does work with shared pointers ?

Any chance it gets into C++0x ;-) ?

Thanks,
Peter


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net