Boost logo

Boost Users :

Subject: Re: [Boost-users] [bind] Dereferencing placeholder argument
From: Ivan Le Lann (ivan.lelann_at_[hidden])
Date: 2011-09-09 10:04:07


----- "Szymon Gatner" <szymon.gatner_at_[hidden]> a écrit :

> 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);

>From http://www.boost.org/doc/libs/1_47_0/doc/html/lambda/le_in_details.html#id2114223
(section "Sizeof and typeid")

for_each(a.begin(), a.end(),
         cout << bind(&type_info::name, ll_typeid(*_1)));

Have you tried *_1 ?

Regards,
Ivan


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