- if(st.args.size()!=3) throw TypeError("Wrong number of arguments");
- (dynamic_cast<L &>(l).*func)(st.args[0].get<A0>(), st.args[1].get<A1>(), st.args[2].get<A2>());
+ (l.*func)(std::forward<Args>(args)...);
+ }
+};
+
+template<unsigned I, typename Head, typename... Tail>
+struct Apply<I, Head, Tail...>
+{
+ template<typename L, typename F, typename... Args>
+ static void apply(L &l, F func, const Statement &st, Args &&... args)
+ {
+ Apply<I+1, Tail...>::apply(l, func, st, std::forward<Args>(args)..., std::move(st.args[I].get<Head>()));
+ }
+
+ template<typename L, typename F, typename... Args>
+ static void apply(L &l, F func, const ArgumentStore &as, Args &&... args)
+ {
+ Apply<I+1, Tail...>::apply(l, func, as, std::forward<Args>(args)..., std::move(as.get<Head>(I)));