Click here to Skip to main content
15,068,471 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What is the function declaration  called ?? 


I am using a tutorial where "delay " function in implemented in main .
It is unknown syntax to me and I do not understand
what is the advantage of this instead of using "global" function.

Of course my program does not compile as coded.

Any reference "what is it called ? " will be welcome. I'll be happy to ask Mrs Google if I have a clue what it is I am looking at.


C++
<pre> // Our function to compute
    std::function<void(int&)> spin = [](int &iteration) {
        const int work = 1000 * 1000 * 40;
        volatile int v = 0;
        for (int j = 0; j < work; ++j)
            ++v;

        qDebug() << "iteration" << iteration << "in thread" << QThread::currentThreadId();
    };




What I have tried:

Nothing, need definition first to do search.
Posted
Updated 18-Jan-21 20:20pm
Comments
CPallini 19-Jan-21 3:09am
   
It is called 'lambda' see, for instance
https://docs.microsoft.com/en-us/cpp/cpp/lambda-expressions-in-cpp?view=msvc-160

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900