目录
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;
}
cytotec buy online usa buy cytotec in usa cytotec pills buy online
I want assembling utile info, this post has got me even more info! .
http://nolvadexbestprice.pro/# where to get nolvadex
cytotec abortion pill: buy cytotec over the counter – purchase cytotec
https://cytotecbestprice.pro/# buy cytotec online
http://prednisonebestprice.pro/# prednisone online pharmacy
purchase zithromax z-pak: zithromax 500mg price – zithromax over the counter
buy cytotec online fast delivery cytotec online Abortion pills online
After going over a number of the blog articles on your web page, I honestly like your technique of blogging. I bookmarked it to my bookmark site list and will be checking back soon. Please visit my web site as well and let me know your opinion.
mexican mail order pharmacies: reputable mexican pharmacies online – buying prescription drugs in mexico
best online pharmacies in mexico: mexico drug stores pharmacies – mexican border pharmacies shipping to usa
I’m amazed, I must say. Seldom do I come across a blog that’s both educative and entertaining, and without a doubt, you have hit the nail on the head. The problem is something not enough folks are speaking intelligently about. I am very happy that I stumbled across this in my search for something regarding this.
medicine in mexico pharmacies mexican online pharmacies prescription drugs reputable mexican pharmacies online
mexico drug stores pharmacies: best online pharmacies in mexico – mexico pharmacies prescription drugs
Hi! I simply want to give you a big thumbs up for the great info you’ve got here on this post. I’ll be coming back to your blog for more soon.
purple pharmacy mexico price list: mexico drug stores pharmacies – purple pharmacy mexico price list
purple pharmacy mexico price list mexican rx online medicine in mexico pharmacies
buying prescription drugs in mexico online: buying prescription drugs in mexico online – purple pharmacy mexico price list
mexican mail order pharmacies: mexican drugstore online – mexican mail order pharmacies
mexican pharmaceuticals online: buying prescription drugs in mexico online – reputable mexican pharmacies online
medicine in mexico pharmacies: mexican online pharmacies prescription drugs – mexican border pharmacies shipping to usa
mexican rx online medication from mexico pharmacy mexico drug stores pharmacies
It’s hard to find educated people for this topic, however, you sound like you know what you’re talking about! Thanks
mexican pharmaceuticals online: mexican online pharmacies prescription drugs – mexican border pharmacies shipping to usa
The degree of my admiration for your work is as substantial as your own sentiment. Your visual display is tasteful, and the authored content is stylish. However, you appear apprehensive about the possibility of delivering something that may be viewed as questionable. I believe you’ll be able to rectify this matter efficiently.
mexico drug stores pharmacies: mexican drugstore online – best online pharmacies in mexico
mexico drug stores pharmacies mexican pharmaceuticals online mexico drug stores pharmacies
buying from online mexican pharmacy: mexican border pharmacies shipping to usa – buying from online mexican pharmacy
mexican pharmaceuticals online: mexican border pharmacies shipping to usa – medicine in mexico pharmacies
Usually I do not read article on blogs however I would like to say that this writeup very compelled me to take a look at and do so Your writing taste has been amazed me Thanks quite nice post
mexico drug stores pharmacies: mexico drug stores pharmacies – mexico drug stores pharmacies
mexican drugstore online: mexican rx online – best online pharmacies in mexico
pharmacies in mexico that ship to usa mexican rx online medicine in mexico pharmacies
I have read some excellent stuff here Definitely value bookmarking for revisiting I wonder how much effort you put to make the sort of excellent informative website
reputable mexican pharmacies online: mexican drugstore online – mexico pharmacies prescription drugs
Thanks I have recently been looking for info about this subject for a while and yours is the greatest I have discovered so far However what in regards to the bottom line Are you certain in regards to the supply
buying from online mexican pharmacy: mexican mail order pharmacies – mexican rx online
buying prescription drugs in mexico buying prescription drugs in mexico online purple pharmacy mexico price list
purple pharmacy mexico price list: mexican online pharmacies prescription drugs – mexican pharmaceuticals online
purple pharmacy mexico price list: mexican rx online – mexico drug stores pharmacies
mexico drug stores pharmacies: pharmacies in mexico that ship to usa – mexican rx online
purple pharmacy mexico price list mexican drugstore online buying prescription drugs in mexico online
purple pharmacy mexico price list: buying prescription drugs in mexico online – п»їbest mexican online pharmacies
medicine in mexico pharmacies: purple pharmacy mexico price list – buying prescription drugs in mexico
mexican rx online mexico drug stores pharmacies п»їbest mexican online pharmacies
purple pharmacy mexico price list: buying prescription drugs in mexico online – mexican rx online
buying from online mexican pharmacy: mexican rx online – п»їbest mexican online pharmacies
п»їbest mexican online pharmacies: pharmacies in mexico that ship to usa – mexico drug stores pharmacies
п»їbest mexican online pharmacies: best online pharmacies in mexico – best online pharmacies in mexico
purple pharmacy mexico price list medication from mexico pharmacy buying prescription drugs in mexico online