Thanks Peter

Am I right in saying std::bind for gcc will be based on boost's bind? If that is the case, then there could be a point?

TIA
Steve

On 27 July 2010 11:41, Peter Dimov <pdimov@pdimov.com> wrote:
Steve Lorimer wrote:
I haven't tested it yet, but I imagine a call to bind with more arguments
will involve a lot more copying, as bind looks something like this for
argument lists internally:

template< class A1 , class A2 , class A3 , class A4  > class list4: private
storage4< A1 , A2 , A3 , A4  >
template< class A1 , class A2 , class A3 , class A4  > struct  storage4  :
public  storage3< A1 , A2 , A3 >
template< class A1 , class A2 , class A3  > struct  storage3  : public
storage2< A1 , A2  >
template< class A1 , class A2  > struct  storage2  : public  storage1< A1  >
template< class A1  > struct  storage1

Argument A1 is copied for each constructor in the list as it's passed down
the inheritance hierarchy.

This is the optimization that makes the placeholders not occupy any space... its purpose was to allow function<> to store bind( &X::f, p, _1, _2, _3 ) without going to the heap. Unfortunately, you're right that it results in a lot more copies. Not sure what can be done here.


Are there plans to implement bind using variadic templates? Not sure if that
would reduce the number of copies?

Rvalue references can help, as the copies can be converted into moves. But every compiler that has variadic templates and rvalue references also has std::bind, so there's not much point.
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users