Is it possible to have a generic method which takes in two functions f and g (both returning void and taking in arguments of the same type) and return a new function which takes in arguments of the same type as f and g and first applies f to the passed arguments and then g?
Specifically, I want to define something like this:
template <typename FunctionType>
// FunctionType is void(ArgType1 arg1, ArgType2 arg2, ..)
FunctionType CombineTwoFunctions(FunctionType f, FunctionType g) {
// Using the lambda syntax just for illustration:
return [f, g](ArgsOf(FunctionType) args) {
f(args);
g(args);
};
}
Aucun commentaire:
Enregistrer un commentaire