[mpl][bind][doc] bind.html fails to mention dissimilarity with boost.bind

The mpl bind doc: http://www.boost.org/libs/mpl/doc/refmanual/bind.html contains: bind is [skipping] a compile-time counterpart of the similar run-time functionality provided by Boost.Bind and Boost.Lambda libraries. However, further down, it looks like mpl bind creates a metafunciton with the same arity as the original. IOW, the g::apply arity is apparently the same arity as the original f metafunction class. OTOH, the boost.bind doc: http://www.boost.org/libs/bind/bind.html#Purpose shows examples where the arity is reduced by the number or arguments passed to bind. Quoting, it says: bind(f, 1, 2) will produce a "nullary" function object that takes no arguments and returns f(1, 2). To avoid this confusion, the mpl bind doc should make explicit mention that the arity of the resulting metafunction is the same as the original, which is in contrast to the boost.bind's affect on the arity of the result functions w.r.t. the original. Or am I missing something? -regards, Larry

On 10/21/2006 09:08 AM, Larry Evans wrote:
Or am I missing something?
Judging from the apply0 test on line 60 of: http://boost.cvs.sourceforge.net/boost/boost/libs/mpl/test/bind.cpp apparently I am missing something. That example clearly shows the reduction in arity from 1 to 0 (in f1 case) and 5 to 0 (in f5 case). Sorry for noise. I still need to reread the docs and experiment before I understand how bind works. -regards, Larry

On 10/21/2006 11:11 AM, Larry Evans wrote: [snip]
Sorry for noise. I still need to reread the docs and experiment before I understand how bind works.
The following works: template < unsigned I
struct a {}; struct f4 { template< typename T1, typename T2, typename T3, typename T4 > struct apply { typedef vector<T1,T2,T3,T4> type; }; }; MPL_TEST_CASE() // partially bound metafunction classes { typedef bind4<f4, a<1>,a<2>,_1,_2 > f4_a1_a2; typedef apply_wrap2<f4_a1_a2, a<3>,a<4> >::type f4_a1_a2_a3_a4; MPL_ASSERT(( boost::is_same<f4_a1_a2_a3_a4,vector<a<1>,a<2>,a<3>,a<4> > > )); } So, apparently, the n in apply_wrapn is >= max placeholder arg in the bind args. Rereading boost.bind, I now see the similarity. Sorry for the noise, but further examples like the f4 example above would have helped.
participants (1)
-
Larry Evans