Re: [Boost-users] [bind] Dereferencing placeholder argument
----- "Szymon Gatner"
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
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#id21... (section "Sizeof and typeid")
for_each(a.begin(), a.end(), cout << bind(&type_info::name, ll_typeid(*_1))); Have you tried *_1 ? Regards, Ivan
On Fri, Sep 9, 2011 at 10:04 AM, Ivan Le Lann
Is there a way of automatic placeholder argument dereferencing when using bind()? I mean:
std::vector
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#id21... (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.
2011/9/9 Nat Linden
On Fri, Sep 9, 2011 at 10:04 AM, Ivan Le Lann
wrote:
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.
Indeed I tried that - getting invalid indirection error.
participants (3)
-
Ivan Le Lann
-
Nat Linden
-
Szymon Gatner