
On Tue, Oct 16, 2012 at 5:40 PM, Felipe Magno de Almeida
Is there a way to know how many overloads are there in a overloaded_function
I'm not sure I understand your question... for example, in the code below: boost::overloaded_function< const std::string& (const std::string&) , int (int) , double (double)
identity(identity_s, identity_i, identity_d);
You want a way to query the type of identity at compile-time to get 3 and/or the identity object at run-time to get 3? If so, why? Don't you know already know that such a number is 3 given that you are constructing the overloaded_function type passing 3 function signatures and/or constructing the identity object passing 3 functors... what's your actual use case for this feature?
without resorting to preprocessor metaprogramming
The pp will only tell you the max number of possible overloads BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX but not the actual number of overloads that an overloaded_function type/object has at compile/run time. For example, in the code above BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX is always 5 (unless you #define it differently) even if the number of identity overloads is 3.
in C++03? It doesn't seem to be a MPL sequence, for example.
No, it's not. The overloaded_function accepts a number of type template parameters from a min of 1 to a max of BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX. --Lorenzo