Boost logo

Boost Users :

Subject: [Boost-users] [bind] Dereferencing placeholder argument
From: Szymon Gatner (szymon.gatner_at_[hidden])
Date: 2011-09-09 09:35:46


Hi,

Is there a way of automatic placeholder argument dereferencing when
using bind()? I mean:

struct SomePredicate
{
  bool operator()(int num, const Foo& foo) const
  {
    return SomeTestOnFoo(num, foo);
  }
}

std::vector<Foo*> foos;

// line below gives compilation error because second argument passed
// to functor is Foo* and not Foo.

std::for_each(foos.begin(), foos.end(), bind(SomePredicate(), 123, _1);

I don't want to use indirect() adaptor from boost.range because I want
final output range to still have Foo* as value_type so that it can still be
copied to another std::vector<Foo*> etc.

So: is there a way of telling bind() that is should dereference
a placeholder argument before passing it to underlying bound functor?

Regards,
Simon

-- 
Szymon Gatner
The Lordz Games Studio
www.thelordzgamesstudio.com

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