![]() |
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-05-15 12:18:42
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.
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.
Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk