/* * Copyright (c) 2014 Eran Pe'er. * * This program is made available under the terms of the MIT License. * * Created on Mar 10, 2014 */ #pragma once #include namespace fakeit { template struct apply_func { template static bool applyTuple(std::function f, std::tuple &t, Args &... args) { return apply_func::applyTuple(f, t, std::get(t), args...); } }; template<> struct apply_func<0> { template static bool applyTuple(std::function f, std::tuple & /* t */, Args &... args) { return f(args...); } }; template bool applyTuple(std::function f, std::tuple &t) { return apply_func::applyTuple(f, t); } template bool invoke(std::function func, const std::tuple &arguments) { std::tuple &args = const_cast &>(arguments); return applyTuple(func, args); } template void for_each(TupleType &&, FunctionType &, std::integral_constant::type>::value>) { } template::type>::value>::type> void for_each(TupleType &&t, FunctionType &f, std::integral_constant) { f(I, std::get(t)); for_each(std::forward(t), f, std::integral_constant()); } template void for_each(TupleType &&t, FunctionType &f) { for_each(std::forward(t), f, std::integral_constant()); } template void for_each(TupleType1 &&, TupleType2 &&, FunctionType &, std::integral_constant::type>::value>) { } template::type>::value>::type> void for_each(TupleType1 &&t, TupleType2 &&t2, FunctionType &f, std::integral_constant) { f(I, std::get(t), std::get(t2)); for_each(std::forward(t), std::forward(t2), f, std::integral_constant()); } template void for_each(TupleType1 &&t, TupleType2 &&t2, FunctionType &f) { for_each(std::forward(t), std::forward(t2), f, std::integral_constant()); } }