#include <iostream>
#include <tuple>
using namespace std;
template<class Func, size_t index>
class ForwardsApplicator{
public:
template<class ...Components>
void operator()(Func func, const std::tuple<Components...>& t){
ForwardsApplicator<Func, index - 1>()(func, t);
func(std::get<index - 1>(t));
}
};
template<class Func>
class ForwardsApplicator<Func, 0> {
public:
template<class ...Components>
void operator()(Func func, const std::tuple<Components...>& t){}
};
template<class Func, class ...Components>
void apply(Func func, const std::tuple<Components...>& t) {
ForwardsApplicator<Func, sizeof...(Components)>()(func, t);
}
class Lambda{
public:
template<class T>
void operator()(T arg){ std::cout << arg << "; "; }
};
int main() {
apply(Lambda{}, std::make_tuple(1, 2.0f));
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dHVwbGU+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp0ZW1wbGF0ZTxjbGFzcyBGdW5jLCBzaXplX3QgaW5kZXg+CmNsYXNzIEZvcndhcmRzQXBwbGljYXRvcnsKcHVibGljOgoJdGVtcGxhdGU8Y2xhc3MgLi4uQ29tcG9uZW50cz4KICAgIHZvaWQgb3BlcmF0b3IoKShGdW5jIGZ1bmMsIGNvbnN0IHN0ZDo6dHVwbGU8Q29tcG9uZW50cy4uLj4mIHQpewogICAgICAgIEZvcndhcmRzQXBwbGljYXRvcjxGdW5jLCBpbmRleCAtIDE+KCkoZnVuYywgdCk7CiAgICAgICAgZnVuYyhzdGQ6OmdldDxpbmRleCAtIDE+KHQpKTsKICAgIH0KfTsKCnRlbXBsYXRlPGNsYXNzIEZ1bmM+CmNsYXNzIEZvcndhcmRzQXBwbGljYXRvcjxGdW5jLCAwPiB7CnB1YmxpYzoKCXRlbXBsYXRlPGNsYXNzIC4uLkNvbXBvbmVudHM+CiAgICB2b2lkIG9wZXJhdG9yKCkoRnVuYyBmdW5jLCBjb25zdCBzdGQ6OnR1cGxlPENvbXBvbmVudHMuLi4+JiB0KXt9Cn07Cgp0ZW1wbGF0ZTxjbGFzcyBGdW5jLCBjbGFzcyAu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