[Bind][Lambda] Processing containers of pointers
Hi All
I believe boost.bind has the capability to look through pointers and smart
pointers to
transparently process the pointed-to objects. Does boost.lambda.bind also
have this
capability?
I.e., this bit of code (and I am specifically using boost 1.37 for this btw)
#include
2010/3/24 Robert Jones
Hi All
I believe boost.bind has the capability to look through pointers and smart pointers to transparently process the pointed-to objects. Does boost.lambda.bind also have this capability?
As your code demonstrates, lambda.bind works for pointers, but not for smart pointers. Roman Perepelitsa.
AMDG Peter Dimov wrote:
Robert Jones wrote:
I believe boost.bind has the capability to look through pointers and smart pointers to transparently process the pointed-to objects. Does boost.lambda.bind also have this capability?
No, but you should be able to use bind( &A::f, *_1 ) for that.
This should work unless A is an abstract type. In Christ, Steven Watanabe
On Wed, Mar 24, 2010 at 3:15 PM, Steven Watanabe
AMDG
Peter Dimov wrote:
Robert Jones wrote:
I believe boost.bind has the capability to look through pointers and smart pointers to transparently process the pointed-to objects. Does boost.lambda.bind also have this capability?
No, but you should be able to use bind( &A::f, *_1 ) for that.
This should work unless A is an abstract type.
I don't understand this; if this passes by reference as Peter states in this thread, why can A not be an abstract type? - Rob.
AMDG Robert Jones wrote:
On Wed, Mar 24, 2010 at 3:15 PM, Steven Watanabe
wrote: Peter Dimov wrote:
No, but you should be able to use bind( &A::f, *_1 ) for that.
This should work unless A is an abstract type.
I don't understand this; if this passes by reference as Peter states in this thread, why can A not be an abstract type?
Because of a long standing bug in the return type deduction mechanism. In Christ, Steven Watanabe
On Wed, Mar 24, 2010 at 11:39 AM, Peter Dimov
Robert Jones wrote:
Hi All
I believe boost.bind has the capability to look through pointers and smart pointers to transparently process the pointed-to objects. Does boost.lambda.bind also have this capability?
No, but you should be able to use bind( &A::f, *_1 ) for that.
Which I imagine passes by value? Hence the original objects pointed to by the container pointers are unchanged? Is that the semantics implemented by boost::bind when it looks through smart pointers? Thanks, - Rob.
Robert Jones wrote:
On Wed, Mar 24, 2010 at 11:39 AM, Peter Dimov
wrote: Robert Jones wrote:
Hi All
I believe boost.bind has the capability to look through pointers and smart pointers to transparently process the pointed-to objects. Does boost.lambda.bind also have this capability?
No, but you should be able to use bind( &A::f, *_1 ) for that.
Which I imagine passes by value?
It should pass by reference. You could also use bind( mem_fn( &A::f ), _1 ), if you like that better. This is what boost::bind does under the hood, more or less.
participants (4)
-
Peter Dimov
-
Robert Jones
-
Roman Perepelitsa
-
Steven Watanabe