|
Boost Users : |
Subject: [Boost-users] framework for invoking func-ptrs with different argument numbers
From: firespot (firespot71_at_[hidden])
Date: 2013-08-16 13:14:26
Hi,
Consider the following task: Given a
-) pointer to a function, and
-) an iterator range with elements of type void *,
the function-ptr shall be called with all the elements in the range as
arguments.
So conceptionally something like this:
template <typename Func, typename Iter>
void make_call(Func, Iter begin, Iter end)
{
int n = std::distance(begin, end);
(*Func) (*(begin), *(begin + 1), *(begin + 2), ..., *(begin + n - 1))
}
The interface (function declaration) here is +- what I want, the
implementation shown of course is dummy-code not working. Does boost
provide a more or less easy way to get this implementation smoothly
done? C++ is 2003 version, so code must be compatible with e.g. VS
2008.. Note that I would know in principle a way how to do implement it
myself, which involves the creation of a separate class for each number
of arguments, but that's precisely what I want to avoid and I hope that
wheel has already been invented in some boost-library :)
thanks and regards,
Thomas
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net