
Hi, I find the interface: function_traits<F>::arity function_traits<F>::result_type function_traits<F>::argN_type (especially the last) awkward in TMP code. In the interest of not having metafunction blobs, I'd suggest the interface: function_arity<F>::value function_result<F>::type function_arg_c<N, F>::type function_arg<mpl::int_<N>, F>::type In particular, I need the function_arg(_c) metafunctions. It is very awkward to get the Nth function argument, given a constant N. Thoughts? Cheers, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net

Joel de Guzman <joel@boost-consulting.com> writes:
In the interest of not having metafunction blobs, I'd suggest the interface:
function_arity<F>::value
function_arity<F>::type::value please.
function_result<F>::type function_arg_c<N, F>::type function_arg<mpl::int_<N>, F>::type
In particular, I need the function_arg(_c) metafunctions. It is very awkward to get the Nth function argument, given a constant N.
-- Dave Abrahams Boost Consulting www.boost-consulting.com

Joel de Guzman wrote:
Hi,
I find the interface:
function_traits<F>::arity function_traits<F>::result_type function_traits<F>::argN_type
(especially the last) awkward in TMP code.
In the interest of not having metafunction blobs, I'd suggest the interface:
function_arity<F>::value function_result<F>::type function_arg_c<N, F>::type function_arg<mpl::int_<N>, F>::type
In particular, I need the function_arg(_c) metafunctions. It is very awkward to get the Nth function argument, given a constant N.
Tobias Swinger is working on an updated version of function traits. The interface is documented here (but my implementation is naive): http://www.kangaroologic.com/function_traits/ Jonathan

Jonathan Turkanis wrote:
Jonathan Turkanis wrote:
Tobias Swinger is working on an updated version of function traits.
^^^ Schwinger
Sorry, Tobias!!
Nevermind, I found it kind-of funny (-8 I'll also create an audio file with its correct pronounciation, as soon as I become as famous as Bjarne Stroustrup 8-).

Jonathan Turkanis wrote:
Joel de Guzman wrote:
Hi,
I find the interface:
function_traits<F>::arity function_traits<F>::result_type function_traits<F>::argN_type
(especially the last) awkward in TMP code.
In the interest of not having metafunction blobs, I'd suggest the interface:
function_arity<F>::value function_result<F>::type function_arg_c<N, F>::type function_arg<mpl::int_<N>, F>::type
In particular, I need the function_arg(_c) metafunctions. It is very awkward to get the Nth function argument, given a constant N.
Tobias Swinger is working on an updated version of function traits.
The interface is documented here (but my implementation is naive):
Unfortunately I'm too busy to clean the code until the end of next week. Expect an initial release about the beginning of march. I can provide a brief overview of the low-level interface underneath Jonanthan's. It can be used directly and is quite powerful. In fact, it'll be a matter of minutes to implement the proposed metafunctions on top of it (and without using the preprocessor, that is): // Pseudo code (please ask if something is unclear) signature_traits< type > { // classification typedef <mpl-bool> is_function_ptr typedef <mpl-bool> is_function_ref typedef <mpl-bool> is_function typedef <mpl-bool> is_mem_fun_ptr typedef <mpl-bool> is_const_mem_fun_ptr typedef <mpl-bool> is_volatile_mem_fun_ptr typedef <mpl-bool> is_template // does not support non-type or template-parameters typedef <mpl-size_t> arity // decomposition typedef <mpl-sequence> signature template<signature> rebind { typedef signature::* type } } signature< types > // mpl-sequence { // type synthesis typedef <bind-to> function_ptr typedef <bind-to> function_ref typedef <bind-to> mem_fun_ptr typedef <bind-to> const_mem_fun_ptr typedef <bind-to> volatile_mem_fun_ptr typedef <bind-to> const_volatile_mem_fun_ptr template<lambda> struct bind { typedef <apply lambda with types> type } } ( Yes, it is "blobby" -- in fact it is a _real_ "metafunction blob" - a "blob of metafunctions" with the same input signature instead of *one* "blobby metafunction" with several results ;-). This is done for reasons of efficiency and easier maintainance - it saves a lot of redundant code. ) Tobias

Forget about my previous post. After thinking some more about it, I concluded that it can still be improved a lot. So this will change... ...and I won't paste my scratch-pad-version in here, before being sure about it - to avoid any further confusion ;-). Tobias
participants (4)
-
David Abrahams
-
Joel de Guzman
-
Jonathan Turkanis
-
Tobias Schwinger