1
votes

I've been searching for an answer for hours, but I didn't find anything... So, Here is my problem:

template<typename Signature> struct wrapper; // (1)

template<typename Ret, typename... Args>
struct wrapper<Ret(Args...)> // (2)
{
  function static get(Ret(*fnc)(Args...), Args... args)
  {
    return function(/*some more stuff here that work*/);
  }
}

basically, this code extract the return type and the parameters of a function and return a generic function container. This code work with simple function. But then I tried to use lambdas. Without this wrapper (by handwriting the complete prototype) the code work, and I am able to call lambda. But when I use this wrapper with lambda functions, I get some

'./some-file.cpp:xy:z: error: incomplete type 'wrapper >' used in nested name specifier'

Is the error caused by the two points (1) and (2) because a lambda could not fit into a function pointer ? I am searching a way to get the arguments types of the lambda into a template argument pack (the return type is not important, all my lambdas does not return values (so it's void)) Thanks in advance for your help :)

1
Can you post the full error message?R. Martinho Fernandes
This is the full error message ;)neam
What version of what compiler are you using?ildjarn
gcc (Gentoo 4.5.3-r2 p1.1, pie-0.4.7) 4.5.3 (and yes, lambda functions work)neam
I don't think variadic templates do though (not properly anyway)... You ought to try on GCC 4.7+.ildjarn

1 Answers

-1
votes

It seems you only declare the wrapper structure, you don't actually define it.

Try to properly define the structure:

template<typename Signature> struct wrapper {};