目录
lambda表达式
- 也就是匿名函数,我们可以在全局区、函数内、就像声明变量一样来声明一个函数出来用,而普通函数并不能在函数内声明。
- 示例:
int main() {
// 声明
auto fun = []() {
cout << 123 << endl;
};
// 调用
fun();
return 0;
}
递归
- 对于普通函数,递归调用很简单,我们可以在函数内直接调用函数自己。
int hello(int value) {
if(value < 0) {
return 0;
}
cout << value << endl;
hello(value - 1);
}
lambda递归
- 对于 lambda 实现递归,由于它是匿名函数,本身没有函数名,我们是把他赋值给了一个变量。
- 但要注意的是,像下面这样直接调用是不行的:
- 因为在 声明lambda表达式时,变量fun应当视为还没声明,fun需要等lambda表达式构造完成后赋值过来才算完成声明,因此在 lambda 内是不能访问 fun 这个变量的。
int main() {
auto fun = [&fun](int value) {
if(value < 0) {
return;
}
cout << value << endl;
// 这里是不行的!!!
fun(value - 1);
};
fun(10);
return 0;
}
- 既然如此,我们可以在lambda表达式前先声明一个 “容器”,让它去保存lambda,并且在声明 lambda时,由于这个容器是之前声明好的,因此可以引用捕获它,然后在 lambda内取到自己调用即可:
#include <iostream>
#include <functional>
using namespace std;
int main() {
int i = 10;
std::function<void()> myfun;
myfun = [&myfun, &i]() {
if (i < 0) {
return;
}
cout << i << endl;
--i;
myfun();
};
myfun();
return 0;
}
mexico pharmacies prescription drugs: buying from online mexican pharmacy – buying prescription drugs in mexico online
reputable mexican pharmacies online: medicine in mexico pharmacies – mexico drug stores pharmacies
I was recommended this website by my cousin I am not sure whether this post is written by him as nobody else know such detailed about my trouble You are amazing Thanks
Vitazen Keto Gummies very informative articles or reviews at this time.
mexico drug stores pharmacies medicine in mexico pharmacies mexican drugstore online
Fantastic site Lots of helpful information here I am sending it to some friends ans additionally sharing in delicious And of course thanks for your effort
mexico pharmacies prescription drugs: pharmacies in mexico that ship to usa – buying prescription drugs in mexico
buying prescription drugs in mexico online: buying prescription drugs in mexico – pharmacies in mexico that ship to usa
mexico drug stores pharmacies: mexican rx online – mexican mail order pharmacies
mexico pharmacies prescription drugs mexican border pharmacies shipping to usa mexico pharmacies prescription drugs
mexican drugstore online: purple pharmacy mexico price list – medication from mexico pharmacy
buying prescription drugs in mexico: mexican rx online – medicine in mexico pharmacies
Exchange-traded funds (ETFs) began to feature commodities in 2003.
buying prescription drugs in mexico online mexico pharmacy mexico drug stores pharmacies
However, some of the folks I have referred to them have had some unsettling issues with EZ Trader.
mexican online pharmacies prescription drugs: buying from online mexican pharmacy – buying from online mexican pharmacy
medication from mexico pharmacy: mexico drug stores pharmacies – mexican pharmaceuticals online
buying prescription drugs in mexico online: mexican mail order pharmacies – buying from online mexican pharmacy
purple pharmacy mexico price list mexico drug stores pharmacies mexico drug stores pharmacies
mexico pharmacies prescription drugs: mexican mail order pharmacies – mexican drugstore online
mexican online pharmacies prescription drugs: mexican pharmaceuticals online – buying prescription drugs in mexico online
mexico drug stores pharmacies: mexico drug stores pharmacies – mexico pharmacies prescription drugs
mexican pharmacy buying prescription drugs in mexico online mexico drug stores pharmacies
mexico drug stores pharmacies: reputable mexican pharmacies online – mexican pharmaceuticals online
reputable mexican pharmacies online: medication from mexico pharmacy – purple pharmacy mexico price list
buying prescription drugs in mexico: reputable mexican pharmacies online – best online pharmacies in mexico
buying prescription drugs in mexico online best online pharmacies in mexico mexican pharmaceuticals online
pharmacies in mexico that ship to usa: mexican mail order pharmacies – reputable mexican pharmacies online
pharmacies in mexico that ship to usa: mexican pharmaceuticals online – mexico pharmacies prescription drugs
mexican border pharmacies shipping to usa: medicine in mexico pharmacies – best online pharmacies in mexico
mexico drug stores pharmacies mexican pharmaceuticals online mexican rx online
reputable mexican pharmacies online: п»їbest mexican online pharmacies – reputable mexican pharmacies online
mexican online pharmacies prescription drugs: buying prescription drugs in mexico online – buying prescription drugs in mexico
mexican drugstore online: reputable mexican pharmacies online – mexican pharmaceuticals online
buying prescription drugs in mexico mexican pharmaceuticals online mexico pharmacy
mexico drug stores pharmacies: pharmacies in mexico that ship to usa – medication from mexico pharmacy
mexican online pharmacies prescription drugs: mexico pharmacies prescription drugs – mexican drugstore online
mexican border pharmacies shipping to usa: purple pharmacy mexico price list – mexican drugstore online
buying from online mexican pharmacy mexican pharmaceuticals online purple pharmacy mexico price list
medication from mexico pharmacy: mexico drug stores pharmacies – medication from mexico pharmacy
mexican online pharmacies prescription drugs: mexico drug stores pharmacies – buying prescription drugs in mexico
mexican pharmaceuticals online: mexican mail order pharmacies – mexican online pharmacies prescription drugs
purple pharmacy mexico price list mexico drug stores pharmacies buying prescription drugs in mexico
mexican mail order pharmacies: mexican border pharmacies shipping to usa – medicine in mexico pharmacies
mexico pharmacies prescription drugs: buying prescription drugs in mexico – mexico pharmacies prescription drugs
mexico drug stores pharmacies: purple pharmacy mexico price list – best online pharmacies in mexico
I have been surfing online more than 3 hours today yet I never found any interesting article like yours It is pretty worth enough for me In my opinion if all web owners and bloggers made good content as you did the web will be much more useful than ever before
I wanted to take a moment to commend you on the outstanding quality of your blog. Your dedication to excellence is evident in every aspect of your writing. Truly impressive!
reputable mexican pharmacies online medicine in mexico pharmacies buying prescription drugs in mexico
What i do not understood is in truth how you are not actually a lot more smartlyliked than you may be now You are very intelligent You realize therefore significantly in the case of this topic produced me individually imagine it from numerous numerous angles Its like men and women dont seem to be fascinated until it is one thing to do with Woman gaga Your own stuffs nice All the time care for it up