[function] How to obtain the signature type?
Hi, Currently I have the following: typedef boost::function<void (int)> MyFunction; Is there a typedef in the boost::function class for the Signature template parameter? I need access to the function type passed into the boost::function object. I've tried finding the boost::function class in the source, but that turned out to be impossible. The documentation also does not explain how to do this from what I saw. Any help is appreciated.
In a rush here, you want boost function_traits. Damien _____ From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Dailey Sent: Tuesday, February 05, 2008 5:00 PM To: boost [usr] Subject: [Boost-users] [function] How to obtain the signature type? Hi, Currently I have the following: typedef boost::function<void (int)> MyFunction; Is there a typedef in the boost::function class for the Signature template parameter? I need access to the function type passed into the boost::function object. I've tried finding the boost::function class in the source, but that turned out to be impossible. The documentation also does not explain how to do this from what I saw. Any help is appreciated.
AFAIUC, this is different, what the original need is to get the type from a given MyFunction type. Max
In a rush here, you want boost function_traits.
Damien
_____
From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Dailey Sent: Tuesday, February 05, 2008 5:00 PM To: boost [usr] Subject: [Boost-users] [function] How to obtain the signature type?
Hi,
Currently I have the following:
typedef boost::function<void (int)> MyFunction;
Is there a typedef in the boost::function class for the Signature template parameter? I need access to the function type passed into the boost::function object. I've tried finding the boost::function class in the source, but that turned out to be impossible. The documentation also does not explain how to do this from what I saw.
Any help is appreciated.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Robert Dailey wrote:
Still looking for a solution to this :)
You could use the new function_traits library, but that's not in a release yet. Or recreate the type "manually" using the component typedefs in function <http://boost.org/doc/html/boost/functionN.html>. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail
On Feb 6, 2008 11:18 AM, Rene Rivera <grafikrobot@gmail.com> wrote:
You could use the new function_traits library, but that's not in a release yet. Or recreate the type "manually" using the component typedefs in function <http://boost.org/doc/html/boost/functionN.html>.
I just created my own quick little class for this: template< typename t_fun > class FunctionHolder { public: typedef t_fun type; }; I don't understand why boost::function can't just have the following: *typedef Signature signature_type;* It would be very useful!
On Feb 6, 2008 10:41 AM, Robert Dailey <rcdailey@gmail.com> wrote:
On Feb 6, 2008 11:18 AM, Rene Rivera <grafikrobot@gmail.com> wrote:
You could use the new function_traits library, but that's not in a release yet. Or recreate the type "manually" using the component typedefs in function <http://boost.org/doc/html/boost/functionN.html>.
I just created my own quick little class for this:
template< typename t_fun > class FunctionHolder { public: typedef t_fun type; };
I don't understand why boost::function can't just have the following:
typedef Signature signature_type;
It would be very useful!
If you're only using boost::function, you could do something along the lines of template<typename T> struct signature; template<typename Signature, typename Allocator> struct signature<boost::function<Signature, Allocator> > { typedef Signature type; } // is_same<signature<boost::function<void (int)> >::type, void(int)> If you're using boost::functionN classes directly, you'd have to recreate it like Rene is suggesting. Stjepan
participants (5)
-
Damien Hocking
-
Max
-
Rene Rivera
-
Robert Dailey
-
Stjepan Rajko