Boost logo

Boost :

From: Torsten Maehne (Torsten.Maehne_at_[hidden])
Date: 2008-06-06 10:01:21


Hello Steven,

Steven Watanabe wrote:
>> - Is there a way to work around boost::lambda:bind's limitation
>> concerning the binding of overloaded functions? The required
>> static_cast to the function pointer (referring, e.g., a function
>> from boost/units/cmath.hpp) is tedious.
>>
>
> The problem is avoided by creating a function object. (untested)
>
> struct sin_t {
> template<class Args>
> struct sig {
> typedef typename boost::tuples::element<0>::type arg1_type;
> BOOST_TYPEOF_NESTED_TYPEDEF(nested, (sin(make<arg1_type>())));
> typedef typename nested::type type;
> };
> template<class T>
> ... operator()(const T& arg) { return(sin(arg)); }
> };

I finally came around to test your proposed solutions: I got it working
in the attached small example for two cases sin() and
pow<static_rational<N, D> >(). What do you think about a header
cmath_functor.hpp, which would collect functors under, e.g.,
boost::units::functor to replace the cmath functions in lambda expressions?

Best regards,

Torsten




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk