Is there any difference between normal function
Code
and a function created using std::function
Code
# | User | Rating |
---|---|---|
1 | Benq | 3813 |
2 | tourist | 3768 |
3 | maroonrk | 3570 |
4 | Radewoosh | 3535 |
5 | fantasy | 3526 |
6 | jiangly | 3523 |
7 | Um_nik | 3522 |
8 | orzdevinwang | 3441 |
9 | cnnfls_csy | 3427 |
10 | zh0ukangyang | 3423 |
# | User | Contrib. |
---|---|---|
1 | awoo | 180 |
2 | -is-this-fft- | 179 |
3 | nor | 169 |
4 | Um_nik | 168 |
5 | SecondThread | 164 |
6 | adamant | 163 |
6 | maroonrk | 163 |
8 | kostka | 161 |
9 | YouKn0wWho | 158 |
10 | errorgorn | 155 |
Use of std::function in c++
Is there any difference between normal function
#include<bits/stdc++.h>
using namespace std;
int square(int a)
{
return a*a;
}
int main()
{
cout<<square(5);
return 0;
}
and a function created using std::function
#include<bits/stdc++.h>
using namespace std;
int main()
{
function<int(int)> square=[&](int a){
return a*a;
};
cout<<square(5);
return 0;
}
Name |
---|