[FunctionTypes] function_arity for non-built-ins

Dear all, How can I calculate the arity of function-objects? Obviously, function_arity won't do the job for that's only for built-ins. For instance, I need something like: function_types::function_object_arity<std::plus<double> >::value Anything in Boost for that? TIA, --Hossein

AMDG On 1/5/2011 4:21 PM, Hossein Haeri wrote:
How can I calculate the arity of function-objects? Obviously, function_arity won't do the job for that's only for built-ins. For instance, I need something like:
function_types::function_object_arity<std::plus<double> >::value
Anything in Boost for that?
No. It can't be done, because a function object doesn't necessarily have a unique arity. In Christ, Steven Watanabe

Hi Hossein, On Jan 5, 4:38 pm, Steven Watanabe <watanab...@gmail.com> wrote:
Anything in Boost for that?
No. It can't be done, because a function object doesn't necessarily have a unique arity.
Right, but if you tell us what you would do *if you had* such value, maybe we can help with a proper design. Alfredo

Hi Alfredo,
Anything in Boost for that?
No. It can't be done, because a function object doesn't necessarily have a unique arity.
Right, but if you tell us what you would do *if you had* such value, maybe we can help with a proper design.
I need to know whether a function object is callable with a given set of arguments. Obviously, the compiler will automatically let me know if it's not. Yet, the place where the compiler points my clients to is likely not to be suitable for them. So, the idea is to stop them at an appropriate point in my own code (perhaps with some appropriate error message and commenting) before the compiler nags about the unsuitability of the (function object) instantiation. It will perhaps be a good starting point if I can check it before further the actual template instantiation of the function object. Any ideas now please? TIA, --Hossein

2011/1/6 Hossein Haeri <powerprogman@yahoo.com>
I need to know whether a function object is callable with a given set of arguments. Obviously, the compiler will automatically let me know if it's not. Yet, the place where the compiler points my clients to is likely not to be suitable for them. So, the idea is to stop them at an appropriate point in my own code (perhaps with some appropriate error message and commenting) before the compiler nags about the unsuitability of the (function object) instantiation.
It will perhaps be a good starting point if I can check it before further the actual template instantiation of the function object. Any ideas now please?
This is actually possible in most cases. Check this nice article by Eric Niebler: http://www.boost.org/doc/libs/1_45_0/doc/html/proto/appendices.html#boost_pr... Roman Perepelitsa.

Hi Steven,
function_types::function_object_arity<std::plus<double>
::value
Anything in Boost for that?
No. It can't be done, because a function object doesn't necessarily have a unique arity.
That's not a matter for my application; if my code can check whether the function object does have a certain arity, then I'm fine. So, following the example of std::plus<> above, it would be nice if I can write something like: arity_set_contains<std::plus<double>, 2>::value What about this one then? TIA, --Hossein
participants (4)
-
alfC
-
Hossein Haeri
-
Roman Perepelitsa
-
Steven Watanabe