[function] equivalent of std::binary_function

Does Boost have the technology to define the equivalent of std::binary_function<double, double, double> eg something like boost::nary_function<double(double, double)> Note that I am not interested in storing any function pointer, so using boost::function<double(double, double)> would be a waste. But I want to use the nice syntax "<double(double,double)>" that boost::function uses, instead of "<double, double, double>". The objective is to inherit from this class and instead of class op : std::binary_function<double, double, double>{ ... } to have class op: nary_function<double(double, double)>{ ... } if possible. Thank you, Alfredo

On Sat, Aug 15, 2009 at 1:03 PM, alfC<alfredo.correa@gmail.com> wrote:
Does Boost have the technology to define the equivalent of std::binary_function<double, double, double> eg something like
boost::nary_function<double(double, double)>
Note that I am not interested in storing any function pointer, so using
boost::function<double(double, double)> would be a waste.
But I want to use the nice syntax "<double(double,double)>" that boost::function uses, instead of "<double, double, double>".
The objective is to inherit from this class
and instead of class op : std::binary_function<double, double, double>{ ... }
to have class op: nary_function<double(double, double)>{ ... } if possible.
The Boost.Function_Types (Function_Traits?) library lets you handle syntax like double(double, double) easily.

The Boost.Function_Types (Function_Traits?) library lets you handle syntax like double(double, double) easily.
Thank you for pointing out, apparently the library is Boost.TypeTraits/ function_traits, Here it is the example that worked for me: #include<functional> struct oldf : std::binary_function<int, int, int>{ result_type operator()(first_argument_type a, second_argument_type b) { return a+b; } }; #include<boost/static_assert.hpp> #include<boost/type_traits/function_traits.hpp> struct newf : boost::function_traits<int(int,int)>{ BOOST_STATIC_ASSERT(arity==2); result_type operator()(arg1_type a, arg2_type b){ //or result_type operator()(first_argument_type a, second_argument_type b){ return a+b; } }; int main(){} Thank you, Alfredo
participants (3)
-
alfC
-
Alfredo Correa
-
OvermindDL1