Boost logo

Boost Users :

Subject: Re: [Boost-users] [bind] Dereferencing placeholder argument
From: Nat Linden (nat_at_[hidden])
Date: 2011-09-09 10:48:32


On Fri, Sep 9, 2011 at 10:04 AM, Ivan Le Lann <ivan.lelann_at_[hidden]> wrote:

>> Is there a way of automatic placeholder argument dereferencing when
>> using bind()? I mean:
>>
>> 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 ?

I think that works with boost::lambda::bind and boost::lambda::_1
(also, presumably, the corresponding constructs in Phoenix) but not
with plain boost::bind.


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