c++11 - Lambdas in C++ giving a Function to a other Function -


I'm trying to call

  template & lt; Typename FUNC & gt; Int execute (FNC) {int a {5}; Int b {8}; Return FUNC (A, B); }  

From the following line:

  std :: cout & lt; & Lt; Execute ([] (int a, int b) {back a + b;}) & lt; & Lt; Std :: endl;  

with the following error:

  error C2661: 'main :: and lt; Lambda_5994edd6ba73caf12c83e036d510d0d8 & gt; :: & lt; Lambda_5994edd6ba73caf12c83e036d510d0d8 & gt; ' Ken überladene Funktion akzeptiert 2 logic  

So the question is what am I doing wrong? The error is German but it basically says that the function does not take 2 parameters which should be done explicitly

No, it is not how you should call that function. You have not specified the name of the argument. Whatever you tried to do, use the type as a function.

The correct template function is:

  template & lt; Typename FUNC & gt; Int executable (FUNC f) {int a {5}; Int b {8}; Return F (A, B); }  

Comments

Popular posts from this blog

c# - Process.Kill() returns access denied -

c# - NewtonSoft JArray - how to select multiple elements with LINQ -

c# - Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments -