Boost logo

Boost Users :

Subject: [Boost-users] Two questions on boost::function
From: CHRISTOPHE KOUDELLA, CITADEL INVESTMENT G (ckoudell_at_[hidden])
Date: 2009-11-10 14:58:11


Hi, I am hopng to get some help from boost::function users on two questions I have.

First, is it possible to extract the underlying functor out of a function? The reason for this is that it is useful to have the boost::function abstraction to move around functors in a generic fashion, but the interface is obviously limited to operator(), so being able to extract the underlying class out of a boost::function would be useful. I am thinking mostly about applied math applications in which functions are defined by more than an operator, whence the interface of boost::function is sometimes insufficient.

Second, I was looking to implement a "function algebra" for boost::function (of a given arity, for a start). This algebra would implement sum, difference, product, composition, etc... operations on a pair of like boost::functions. In a template implementation in order to implement the operator() of the result boost::function, I need to access the result type and the argument types of the boost::functions being operated on. So, suppose I want to implement a product operation on a pair of template functors, then in order to define the operator() of the product of the functors, I need the result and argument types. Does boost::function make these types available as some typedefs? Does what I say make at all sense or would you proceed entirely differently in order to define such operations on boost::function?

Thanks for any input,
CK


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