Boost logo

Boost Users :

Subject: Re: [Boost-users] [function] equivalent of std::binary_function
From: Alfredo Correa (alfredo.correa_at_[hidden])
Date: 2009-08-18 14:49:59


> 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


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