...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::type_erasure::call
// In header: <boost/type_erasure/call.hpp> template<typename Concept, typename Op, class... U> unspecified call(const binding< Concept > & binding, const Op &, U &&... args); template<typename Op, class... U> unspecified call(const Op &, U &&... args);
Dispatches a type erased function.
Op
must be a primitive concept which is present in Concept
. Its signature determines how the arguments of call
are handled. If the argument is a placeholder
, call
expects an any
using that placeholder
. This any
is unwrapped by call
. The type that it stores must be the same type specified by binding
. Any arguments that are not placeholders in the signature of Op
are passed through unchanged.
If binding
is not specified, it will be deduced from the arguments. Naturally this requires at least one argument to be an any
. In this case, all any
arguments must have the same binding
.
Example:
typedef mpl::vector< copy_constructible<_b>, addable<_a, int, _b> > concept; any<concept, _a> a = ...; any<concept, _b> b(call(addable<_a, int, _b>(), a, 10));
The signature of addable
is _b(const _a&, const int&)
Returns: |
The result of the operation. If the result type of the signature of |
Throws: |
bad_function_call if relaxed is in Concept and there is a type mismatch. |