Search
 
SCRIPT & CODE EXAMPLE
 

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 */ });
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: priority queue c++ type of pairs 
Cpp :: convert decimal to binary c++ 
Cpp :: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools" 
Cpp :: c++ show current time 
Cpp :: print hello world on c++ 
Cpp :: map defualt value c++ 
Cpp :: loop through char in string c++ 
Cpp :: how to get command arguments c++ 
Cpp :: bit c++ 
Cpp :: c++ kruskal algorithm 
Cpp :: check if an element is in a map c++ 
Cpp :: min vector c++ 
Cpp :: check if float has decimals c++ 
Cpp :: built in led 
Cpp :: maximum int c++ 
Cpp :: max of two elements c++ 
Cpp :: Frequency of a substring in a string C++ 
Cpp :: 2d vector c++ size 
Cpp :: arguments to a class instance c++ 
Cpp :: c++ reading string 
Cpp :: nth node from end of linked list 
Cpp :: cpp Sieve algorithm 
Cpp :: header file for unordered_map in c++ 
Cpp :: strlen in c++ 
Cpp :: c++ vector move element to front 
Cpp :: matrix in vector c++ 
Cpp :: c++ loop vector 
Cpp :: why is using namespace std a bad practice 
Cpp :: sqrt in c++ 
Cpp :: how to read files in c++ 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =