I can't figure out how to invoke a function with a variable number of arguments retrieved from an iterator. I have a simple example using std::plus
to illustrate the problem:
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/apply.hpp>
#include <iostream>
#include <array>
namespace mpl = boost::mpl;
int main() {
using OP = std::plus<mpl::_>;
std::array<int, 2> args = {1, 2};
// This works (passing each arg separately)
auto n1 = mpl::apply<OP, int>::type()(args[0], args[1]);
std::cout << "plus (1,2) = " << n1 << std::endl;
// what I want is more like:
// auto n2 = mpl::apply<OP, int>::type()(args);
// or
// auto n3 = mpl::apply<OP, int>::type()(args.begin(), args.end());
}
I can't figure out how to cross this compile-time/run-time boundary. Thanks for any pointers!