Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

cpp take lambda as parameter

#include <functional>

// For a int->int lambda
void foo1(std::function<int(int)> lambda);

// For an empty lambda
void foo2(std::function<void()> lambda);

int main()
{
  foo1([](int param) { return param * 2; });
  foo2([]() { /* Do something */ });
}
 
PREVIOUS NEXT
Tagged: #cpp #lambda #parameter
ADD COMMENT
Topic
Name
1+9 =