Search code examples
c++c++11lambdafreestanding

Deciding return type for variadic C++11 templated lambda function


I've got the following function;

template<typename T, typename U, typename... Parameters>
void transform(void (*func)(Parameters...))
               {
                  auto lambda_function = [func](T args, U params)
                  {
                     auto combined = std::tuple_cat(args, params);
                     helper(func, combined);
                  };
                  return lambda_function;
               }

That I can't seem to find a feasible return type for, or way to call, I'd like to be able to call it alike this;

auto func = transform<std::tuple<char,int>, std::tuple<const char*>>(f);
func(arg, param);

Given 'f','arg' and 'param' as;

void f(char arg1, int arg2, const char* arg3);
std::tuple<char,int> arg = std::tuple<char,int>('C',-3);
std::tuple<const char*> param = std::tuple<const char*>("PO");

Anyone got a hint, or even a solution?

Note: Code can be found at; Linkage


Solution

  • You can either return std::function, or make a named function object type.