John Maddock wrote:
Kirit Sælensminde wrote:
John Maddock wrote:
Kirit Sælensminde wrote:
I think I have a misunderstanding of what the boost::function_traits is doing. From your explanation it seems that boost::function_traits is there to examine only function signatures where a function type is of the form R( A1, A2, etc. ), Correct. What is the reason for the restriction?
Well I didn't write that trait.... but the general idea was that the type traits library should encapsulate the C++ type system only, and that higher level functionality would be provided later.
BTW boost::result_of does help with the verbiage if include the remove_pointer, but it still doesn't work with the result of a boost::bind.
:-(
The trouble is, I'm not sure that there's any way to actually implement that in the general sense without full introspection in C++, and/or a working typeof operator. However, I would have expected Boost.Bind to play nice and work with result_of.
Sorry I can't be more helpful at present.
Thanks a lot for your time and explanations. Now that I understand more what boost::function_traits is trying to do it makes a lot more sense. The documentation of function_traits (at least at http://www.boost.org/doc/html/boost_typetraits/reference.html#boost_typetrai... ) has no indication of what it is meant to do. Maybe something along the lines of this could be added to the documentation (the function pointer restriction is not very visible as the last example - it's only now that I've looked at the documentation a lot more closely that I've noticed it was there at all): "function_traits is intended to introspect only C++ functions of the form R (), R( A1 ), R ( A1, ... etc. ) and not function pointers or class member functions. To convert a function pointer type to a suitable type use boost::remove_pointer." I hesitate to add something about using boost::mem_fn to convert a member function to a suitable type as I've not been able to get it to do it yet. I'm guessing that boost::mem_fn is intended to do one of the following two type transformations, but again it isn't clear from the documentation. R (C::*)( ... ) const -> R ( const C *, ... ) R (C::*)( ... ) -> R ( C *, ... ) But maybe it is this: R (C::*)( ... ) const -> R (*)( const C *, ... ) R (C::*)( ... ) -> R (*)( C *, ... ) Or one of the above with a C& instead of a C*. Maybe a note on which type transformation it does should be in the documentation? K