![]() |
Home | Libraries | People | FAQ | More |
boost::overloaded_function — Function object to overload functions with distinct signatures.
// In header: <boost/functional/overloaded_function.hpp> template<typename F1, typename F2, ... > class overloaded_function { public: // construct/copy/destruct overloaded_function(const boost::function< F1 > &, const boost::function< F2 > &, ...); // public member functions boost::function_traits< F1 >::result_type operator()(typename boost::function_traits< F1 >::arg1_type, typename boost::function_traits< F1 >::arg2_type, ...) const; boost::function_traits< F2 >::result_type operator()(typename boost::function_traits< F2 >::arg1_type, typename boost::function_traits< F2 >::arg2_type, ...) const; };
This function object aggregates together calls to functions of all the specified function types F1
, F2
, etc. The specified function types must have distinct parameters from one another and they must be in the following format (which is the Boost.Function preferred syntax):
result_type (argument1_type, argumgnet2_type, ...)
In some cases, the make_overloaded_function
function template can be useful to construct the overloaded function object without explicitly specifying the function types.
The maximum number of functions to overload is given by the BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX
configuration macro. The maximum number of function parameters for each of the specified function types is given by the BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX
configuration macro.
See: Tutorial section, make_overloaded_function
, BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX
, BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX
, Boost.Function.
overloaded_function
public member functionsboost::function_traits< F1 >::result_type operator()(typename boost::function_traits< F1 >::arg1_type, typename boost::function_traits< F1 >::arg2_type, ...) const;Call operator matching the signature of the function type specified as 1st template parameter.
This will in turn invoke the call operator of the 1st function passed to the constructor.
boost::function_traits< F2 >::result_type operator()(typename boost::function_traits< F2 >::arg1_type, typename boost::function_traits< F2 >::arg2_type, ...) const;Call operator matching the signature of the function type specified as 2nd template parameter.
This will in turn invoke the call operator of the 2nd function passed to the constructor.
Note: Similar call operators are present for all specified function types F1
, F2
, etc (even if not exhaustively listed by this documentation).