By neam

2012-06-14 23:11:20 8 Comments

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 :)


@Some programmer dude 2012-06-15 05:57:28

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 {};

@neam 2012-06-15 07:16:35

With this line, it just move the error. I get a ./x.cpp:x:x: error: 'get' is not a member of 'wrapper<main()::<lambda(int)>>' (this is the only line). It seems my specialisation does not match with a lambda function.

Related Questions

Sponsored Content

8 Answered Questions

[SOLVED] Java 8 lambda Void argument

2 Answered Questions

4 Answered Questions

3 Answered Questions

[SOLVED] Explicit Return Type of Lambda

2 Answered Questions

[SOLVED] infer lambda return type in template

1 Answered Questions

[SOLVED] Does lambda capture support variadic template arguments

4 Answered Questions

[SOLVED] How to use a lambda expression as a template parameter?

2 Answered Questions

5 Answered Questions

[SOLVED] Passing a lambda into a function template

0 Answered Questions

Template argument deduction on lambdas

Sponsored Content