Boost logo

Boost Users :

From: David Morrison (dave_at_[hidden])
Date: 2005-03-23 04:04:19


Peter Dimov wrote:
> David Morrison wrote:
>
>> Peter Dimov wrote:
>>
>>> Change this to boost::mem_fn( f )( a1, a2, a3 ) and you'll be there.
>>
>>
>> Yep, that's much cleaner, thanks.
>>
>> I was hoping that there'd be some clever way to use type_traits to
>> magically select the right way of invoking the function f. That way,
>> one could have a (possibly enhanced version of?) apply.hpp so that
>> code to invoke apply on a set of member and non-member functions
>> would look the same.
>
> On a reasonably conforming compiler, adding an overload to apply<>
> should work:
>
> template<class F, class A1, class A2, class A3>
> result_type operator()
> (F & f, A1 & a1, A2 & a2, A3 & a3) const
> {
> return f(a1, a2, a3);
> }
>
> // add this
>
> template<class M, class T, class A1, class A2, class A3>
> result_type operator()
> (M T::* pm, A1 & a1, A2 & a2, A3 & a3) const
> {
> return mem_fn(pm)(a1, a2, a3);
> }
>
> It might be a good idea to add this to apply.hpp, but I would need to
> write a test for apply<> first.
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users

-- 
David Morrison  Brookhaven National Laboratory  phone: 631-344-5840
                 Physics Department, Bldg 510 C    fax: 631-344-3253
		          Upton, NY 11973-5000  email: dave_at_[hidden]

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net