|
Boost : |
From: Marcus Lindblom (macke_at_[hidden])
Date: 2007-05-15 12:24:11
Peter Dimov wrote:
> Marcus Lindblom wrote:
>
>
>> In the bind()-cases, it uses mem_fn to call the actual function:
>>
>> template<class C>
>> template<class T, typename A1, typename A2>
>> void ScriptClassImpl<C>::ElemBinder::bind(void (T::*f)(A1, A2),
>> const char* n1, const char* n2) {
>> BOOST_STATIC_ASSERT((::boost::is_base_and_derived<T,
>> C>::value||::boost::is_same<T, C>::value));
>>
>> typedef boost::function<void (T&, A1, A2)> func_type;
>> *m_f = xml::mkApplyElemFunctor<func_type>(boost::mem_fn(f),
>> *m_log).arg(n1).arg(n2);
>> }
>>
>
> Sounds sensible, although you can use something like
>
> *m_f = boost::bind( f, _1,
>
> boost::bind( getArg<A1>, _2, n1 ),
> boost::bind( getArg<A2>, _2, n2 ) );
>
> here.
>
Hmm. Yup, that might be possible. I'll have to think about it. :)
> I'm somewhat reluctant to introduce features into boost::mem_fn since
> std::tr1::mem_fn and the upcoming std::mem_fn don't/won't have them. If you
> start using ::argN_type, you won't be able to switch to std::mem_fn once it
> becomes available. Of course if this is not a concern for the Boost
> community we can easily add the typedefs and the arity.
>
Valid point. Perhaps function_traits could be extended to handle all
type of function objects as well as regular functions, somehow?
Cheers,
/Marcus
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk